Skip to content

Fix #5001: isolate Journey.git() from host git hooks and global config - #5004

Open
openwiz[bot] wants to merge 4 commits into
mainfrom
fix/5001-onboard-journey-git-hooks
Open

openwiz[bot] wants to merge 4 commits into
mainfrom
fix/5001-onboard-journey-git-hooks

Conversation

@openwiz

@openwiz openwiz Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5001

Summary

  • Isolates Journey.git() in tools/install/tests/onboard/test_journey.py from the caller's Git environment: it now drops every inherited GIT_* variable (repository-scoped ones such as GIT_INDEX_FILE, GIT_DIR, GIT_WORK_TREE, GIT_OBJECT_DIRECTORY, GIT_COMMON_DIR, plus GIT_CONFIG_*), then sets GIT_CONFIG_NOSYSTEM=1, GIT_CONFIG_GLOBAL=os.devnull and -c core.hooksPath=<devnull>. Dropping the whole prefix fails closed on variables the helper does not name. Source followed: Git's own list of repository-local variables (git rev-parse --local-env-vars, documented in git-rev-parse(1)) and the environment section of git(1).
  • test_git_helper_ignores_host_pre_push_hook (from the first round): a failing global pre-push hook and commit signing no longer stop the fixture's push.
  • New test_git_helper_keeps_caller_repository_untouched (fix for review R1): a disposable caller repository has existing.txt staged; for each of the five repository-scoped variables pointed at it, a full Journey setup plus origin_write() must leave every byte of the caller repository unchanged, succeed, and push exactly README.md and probe.txt; afterwards the caller index still stages only existing.txt.

Evidence

  • Red at 60860f3 (test only, helper still dropping just GIT_CONFIG_*): python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched -> FAILED (failures=6): GIT_INDEX_FILE and GIT_DIR let the fixture write the caller repository; GIT_WORK_TREE (init exit 128), GIT_OBJECT_DIRECTORY (clone exit 128) and GIT_COMMON_DIR (init exit 1) broke the fixture git call; the caller index ended as probe.txt instead of existing.txt.
  • Green at bf6b0c4: the same command -> OK; full python3 -I tools/install/tests/onboard/test_journey.py with the pinned skills linked -> Ran 34 tests ... OK.
  • End to end, the reviewer's scenario: a disposable caller repository with existing.txt staged, then GIT_INDEX_FILE=<caller>/.git/index python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_ignores_host_pre_push_hook -> OK; the caller index's sha256 prefix was af22582168e51b52 before and after, and git ls-files --stage still lists only existing.txt.

Self-check

  • Undo the fix, rerun the proof (at 60860f3, fix absent): python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched printed FAILED (failures=6), one failing subtest per variable plus the caller-index check
  • Proof at this head: python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper printed Ran 2 tests ... OK
  • Full suite: python3 -I tools/install/tests/onboard/test_journey.py printed Ran 34 tests in 94.456s OK
  • Reviewer break (R1): GIT_INDEX_FILE=<caller index> python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_ignores_host_pre_push_hook printed OK; the caller index hash and staged entries were unchanged
  • Comment rule: python3 -I tools/comment-check/check.py diff --base origin/main printed comment-check: ok
  • Owned paths: python3 -I tools/owned-paths/check.py --ticket 5001 --base origin/main printed owned-paths: ok: 1 file(s)
  • Error paths: python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched printed OK; at 60860f3 it printed broke the fixture git call for three variables, so a failing fixture git call raises and is reported
  • Guards fail closed: grep -n "startswith('GIT_')" tools/install/tests/onboard/test_journey.py printed the Journey.git() filter line, which drops the whole GIT_ prefix so an unlisted variable cannot leak
  • Failed reads or partial writes keep existing data: python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched printed OK; it compares the caller repository byte for byte after every variant, including ones where the fixture call failed part way at 60860f3
  • Nothing private in output: n/a: fixtures use synthetic names and temporary directories only
  • No overwrite or delete of user data: n/a: the caller repository is a disposable TemporaryDirectory, and the test proves the fixture no longer writes into it
  • Unchanged consumers of a changed producer: grep -c 'self.git(\|j.git(' tools/install/tests/onboard/test_journey.py printed 9, every call inside this file with unchanged arguments; Journey.env() was already an allowlist and is unchanged

Merge danger

Door: two-way. Blast radius: test-only.

Rulings

  1. Drop every inherited GIT_* variable instead of only Git's repository-local list. Why: the fixture sets all the Git config it needs itself, so a prefix filter fails closed on future or unlisted variables. Cost if wrong: low: a host relying on a GIT_* variable for these local-only fixture calls would see a test failure, not data loss.

Facts

  • Branch: fix/5001-onboard-journey-git-hooks
  • Head: bf6b0c41343366985177480279c6324a2dcd51f8
  • Tree: ad09b452c2fdb906a614f4599f2e1b3be413ffbc
  • Size: 1 file, 80 added and 2 deleted lines, all test code (the ticket has no Size: line, so ticket.py size refuses)
  • Changed paths: tools/install/tests/onboard/test_journey.py (owned). No supporting edits. Tests only, so no changelog line; no-changelog label applied.
  • Tests: test_git_helper_ignores_host_pre_push_hook, catches: Journey.git() picking up a host's global core.hooksPath, GIT_CONFIG_* or commit-signing config. test_git_helper_keeps_caller_repository_untouched, catches: Journey.git() inheriting GIT_INDEX_FILE, GIT_DIR, GIT_WORK_TREE, GIT_OBJECT_DIRECTORY or GIT_COMMON_DIR and writing into, or failing because of, the caller's repository
  • Red run: commit 60860f3, its message holds the synthetic log
  • Review: R1 fixed at this head; R2 (polish) handled by the no-changelog label
  • CI at this head: pending at push
  • Gaps: none known

openwiz Bot added 2 commits December 6, 2026 13:05
The test name already states what it catches; the two-line comment
failed tools/comment-check (owned-paths job), which failed ci and web-test.

Built-by: claude-opus-5-5
Requested-by: Wiz (Delivery)
Fixed-by: Anthropic Claude opus-medium
@openwiz

openwiz Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

VERDICT: CHANGES at 389a4a1
reviewer: gpt-6.2-sol medium

Full review by OpenAI Codex, Sol 6.2 Medium. CI green on this commit: ci, privacy.

Intent: Keep the onboarding journey's temporary Git repositories independent of a contributor's Git settings and hooks.

  • R1 [blocking] tools/install/tests/onboard/test_journey.py:201 (Sweep) The subprocess still inherits repository-scoped Git environment variables. In particular, an absolute GIT_INDEX_FILE overrides the fixture index even when git -C points at the temporary clone. Its add -A replaces the caller's staged entries, and the test can pass after doing so. Strip repository-scoped Git variables before running these fixture commands and add a regression that preserves a separately staged synthetic index byte for byte.
    Class: files
    Risk: data loss: Running the journey from a Git hook or another environment with a caller index set can erase staged changes in that index.
    Shows the break: At this head, the focused python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_ignores_host_pre_push_hook run inherited the index of a separate disposable repository with existing.txt staged. The test exited 0. The caller index bytes changed, and its only entries became README.md and probe.txt. The probe used only temporary repositories.
  • R2 [polish] tools/install/tests/onboard/test_journey.py:201 (Standards) The test-only change is exempt from a changelog entry. Apply the no-changelog label as specified by changes/README.md. Polish issue: Apply the no-changelog label to the test-only onboarding fixture fix (polish for #5001, R2) #5008.

Rulings: none.

Disproved: 1 candidate findings dropped.

Checked: Standards (fleet rules, owned path and base comment check), Spec (#5001), and full sweep. The synthetic hook-only probe failed at the parent's local push and the focused regression passed at this head. The full onboarding suite passed all 33 tests with the pinned skills installed. The linked issue's proposed CI wiring is already present: the pinned CI's Rust job ran skills::onboard_journey_fixtures_pass successfully, which invokes this suite.

Next: the builder fixes or disputes R1 once, then one re-check.

openwiz Bot added 2 commits December 6, 2026 13:56
…ed (red)

R1 at 389a4a1: Journey.git() still inherits repository-scoped Git
variables. Red run at this commit:
python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched
-> FAILED (failures=6)
  GIT_INDEX_FILE: let the fixture write the caller repository
  GIT_DIR: let the fixture write the caller repository
  GIT_WORK_TREE: broke the fixture git call (init exit 128)
  GIT_OBJECT_DIRECTORY: broke the fixture git call (clone exit 128)
  GIT_COMMON_DIR: broke the fixture git call (init exit 1)
  caller index: b'probe.txt\n' != b'existing.txt\n'

Built-by: claude-opus-5-5
Requested-by: Wiz (Delivery)
Fixed-by: Anthropic Claude opus-medium
R1 at 389a4a1: the fixture's git calls inherited repository-scoped
variables (GIT_INDEX_FILE, GIT_DIR, GIT_WORK_TREE, GIT_OBJECT_DIRECTORY,
GIT_COMMON_DIR), so a run from a hook or a caller with an index set could
rewrite that caller's staged entries. Journey.git() now drops every GIT_*
variable before setting its own isolated config, failing closed on
variables it does not name.

python3 -I tools/install/tests/onboard/test_journey.py -> Ran 34 tests, OK

Built-by: claude-opus-5-5
Requested-by: Wiz (Delivery)
Fixed-by: Anthropic Claude opus-medium
@openwiz openwiz Bot added the no-changelog Infra, docs or tests: no product changelog; reviewer checks the reason label Dec 6, 2026
@openwiz

openwiz Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

R1 fixed at bf6b0c4: Class: files | Variants: Journey.git() inheriting GIT_INDEX_FILE (reported route), GIT_DIR, GIT_WORK_TREE, GIT_OBJECT_DIRECTORY and GIT_COMMON_DIR; cause shared: the helper filtered only GIT_CONFIG_*, now it drops every inherited GIT_* variable before setting its own isolated config | Red run: python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_keeps_caller_repository_untouched at 60860f3 -> FAILED (failures=6): GIT_INDEX_FILE and GIT_DIR wrote the caller repository, GIT_WORK_TREE (exit 128), GIT_OBJECT_DIRECTORY (exit 128) and GIT_COMMON_DIR (exit 1) broke the fixture call, caller index ended as probe.txt instead of existing.txt; same command at bf6b0c4 -> OK, full suite Ran 34 tests ... OK | Shows the break: no command supplied; the described probe (disposable caller repository with existing.txt staged, GIT_INDEX_FILE=<caller index> python3 -I tools/install/tests/onboard/test_journey.py -k test_git_helper_ignores_host_pre_push_hook) at bf6b0c4 -> OK, caller index sha256 unchanged, git ls-files --stage still lists only existing.txt
R2 (polish): no-changelog label applied; no code change.

@openwiz

openwiz Bot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

VERDICT: APPROVE at bf6b0c4
reviewer: gpt-6.2-sol medium

Re-check of R1 and the code changed since 389a4a1, by OpenAI Codex, Sol 6.2, Medium. CI green on this commit: ci, privacy.

Intent: Keep the onboarding journey's temporary Git repositories isolated from the caller's hooks, configuration, and repository environment.

  • R1 [blocking] resolved at bf6b0c4: Journey.git() now drops inherited GIT_* variables before applying its fixture config. The regression failed at 60860f3 and passed at this head. Each case checked the caller repository byte for byte and verified the files pushed to the fixture's local origin.
    Class: files

  • R2 [polish] Polish issue: Apply the no-changelog label to the test-only onboarding fixture fix (polish for #5001, R2) #5008.

  • Ruling 1 upheld: clearing the inherited prefix covers Git's repository-local variables while preserving the fixture's explicit hook and config settings.

Disproved: 1 candidate findings dropped.

Checked: Standards (the base comment checker and owned-paths check passed, and the PR has no-changelog), Spec (#5001), and the sweep of the re-check diff (the Git helper and its callers). Ran: python3 -I tools/install/tests/onboard/test_journey.py (34 passed), and its focused regression at 60860f3 (six expected failures).

Next: none open. It merges by the project's merge rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Infra, docs or tests: no product changelog; reviewer checks the reason

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/install/tests/onboard/test_journey.py fails all 32 tests when host git sets a global core.hooksPath

0 participants