Skip to content

test: isolate fixture git repos from the host's global git config - #17416

Merged
kyle-sexton merged 9 commits into
mainfrom
test/17304-isolate-test-git-config
Nov 19, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
test/17304-isolate-test-git-config

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Closes #17304

Summary

Test suites that build throwaway git repositories read the host's ~/.gitconfig and system config when run directly (bash x.test.sh, node --test, pytest), so a host that signs every commit could fail a fixture commit through its signing program. Each fixture-building suite, or the shared harness it sources, now isolates git from global and system config.

Fix

  • Shell suites and the harnesses they source (scripts/test-git-helpers.sh, scripts/lib/fixture-tree.sh, guardrails-test-helpers.sh, session-telemetry-test-helpers.sh, judge-test-helpers.sh, the work-item-tracker tests/lib.sh) export GIT_CONFIG_GLOBAL="${GIT_CONFIG_GLOBAL:-/dev/null}" GIT_CONFIG_NOSYSTEM=1 beside their existing GIT_DIR clear. Python suites set the same through os.environ, JS test files through process.env, at load time, so the code under test inherits it too.
  • A value the caller already exported wins by design: under the repo's runners each suite keeps the per-suite config scripts/lib/test-git-env.sh writes, so CI runs are unchanged. This host exports neither variable (printenv).
  • Two code-tidying helpers (test_comment_census.py, test_rank_comment_targets.py) built their fixture env by dropping every GIT_CONFIG* variable, which fell back to ~/.gitconfig; they now set both variables explicitly.
  • Left as they are: suites that already point GIT_CONFIG_GLOBAL at their own file, the three app-control suites that isolate through a temp HOME plus GIT_CONFIG_NOSYSTEM, eval scaffold.sh files, *.fixture copies, vendor/, and product code that runs git init. JS tests whose spawns pass an env without HOME already read no global config.
  • One bump: none changelog fragment per touched plugin (47).

Verification

  • Before the edits, 249 target suites run directly with GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_NOSYSTEM=1 (3 at a time): every failure also failed with no variables set, so /dev/null breaks nothing.
  • After the edits, the same 249 run 3 at a time with no variables set, on this host whose global config has commit.gpgsign=true (gpg.format=ssh): the only failures are the ones listed below that fail without this change.
  • After the edits, 365 suites (the targets plus every suite that sources an edited harness), each with HOME pointed at a temp dir holding a .gitconfig that signs every commit through gpg.program=false: no log shows a signing or identity error once the code-tidying helpers were fixed (both pass). Other failures in that run come from moving HOME (tool resolution, $HOME-relative path checks) and also fail without it.
  • scripts/check-fixture-git-isolation.sh (352 isolated), check-changelog-fragments.sh --check and --check-required origin/main (47 plugins), sync-shared-copies.sh --check, run-ruff.sh check on the edited Python, and bash -n / node --check / py_compile on every edited file.
  • A direct reproduction (a fixture commit under the host config) was denied by the permission system and not retried.

Failures present without this change (each reproduced with no variables set, or on the unedited file):

  • environment: missing node_modules (ajv, yaml, vitest) for callers.test.mjs, report-outcome.test.mjs and the two video-digest tests; missing PyYAML and npm packages for run-hygiene-gate, check-artifact-retention and check-read-caller-keys;
  • an empty /tmp/.git directory on this host, created before these runs by another process: explain-change.test.mjs refuses /tmp as a working tree;
  • fails in both modes: markdown-format.test.sh (spawn budget 2 vs 1), present.test.mjs, board-md.test.mjs, test_hygiene.py, test_interview_server.py;
  • post-merge-demotion-alert.test.sh fails with the unedited file too.

Related

🤖 Generated with Claude Code

A suite run directly (bash x.test.sh, node --test, pytest) read the host's
~/.gitconfig and system config, so a host that signs every commit could
fail a fixture commit through its signing program. Each fixture-building
suite, or the harness it sources, now sets GIT_CONFIG_GLOBAL to /dev/null
when unset and GIT_CONFIG_NOSYSTEM=1. Under the repo's test runners the
per-suite config from scripts/lib/test-git-env.sh is kept unchanged.

Closes #17304

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 19, 2026 07:57
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T07:59:47.210068Z 2853764 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 3eb1d383a29f4c5c8434f9db4f4822952fb972db: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found.

This review covers only what changed since b48f5c7294c3ef5c0feefe7592ae28be1233bdb7. That is one file, and I read its whole change: plugins/code-tidying/scripts/test_rank_comment_targets.py.

  • What changed: the git clone in test_shallow_clone_degrades_with_notice gets a new environment. As before, it copies the process environment minus every GIT_CONFIG* variable. It now also sets GIT_CONFIG_GLOBAL to os.devnull and GIT_CONFIG_NOSYSTEM to "1". This matches the PR's stated fix for the code-tidying helpers.
  • Why it is safe: the values are fixed constants and the command runs as an argument list, not through a shell. The change only stops the test's clone from reading the host's global and system git config. It touches no token, secret, network call, credentialed step, trust control, merge hold, manifest or standing instruction.
  • Trusted paths: this file matches none of the listed trusted-path globs.
  • Earlier rounds: this lane already reviewed an earlier head, so this review is blocking only. It found no CRITICAL or IMPORTANT issues. The one prior post has no line anchor and reported no issues. No settled thread concerns this file.
  • Spend: none. This is a test-only change.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 2 inline finding(s) on 28537645c1d3aea2e8ee142b9e4d2c0e2cfd674b; the summary is in this lane's pull request comment.

claude-lane: claude-review

Comment thread scripts/test_count_capture_sources.py Resolved
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 3eb1d383a29f4c5c8434f9db4f4822952fb972db: read 1 of 1 changed file(s); 0 finding(s), 0 as inline comments.

Incremental review of b48f5c7..3eb1d38: no blocking findings. I read the whole change to the one file in scope, plugins/code-tidying/scripts/test_rank_comment_targets.py. This lane has reviewed earlier heads of this PR (blocking only: yes), so this review reports blocking findings only.

What changed. In test_shallow_clone_degrades_with_notice, the git clone --depth 1 call still drops every inherited GIT_CONFIG* variable. It now adds back GIT_CONFIG_GLOBAL=os.devnull and GIT_CONFIG_NOSYSTEM=1 (L245-L249).

What I checked.

  • Matches the file's own helper. This is the same pattern the git() helper uses at L50-L60. Before this change, the clone was the one fixture git call in the file that still read ~/.gitconfig and /etc/gitconfig.
  • Child processes are covered. The file:// clone starts upload-pack as a child process, and that child inherits this env, so it gets the isolation too.
  • The later calls are covered. run_rank and the later subprocess inherit os.environ, which the module sets at load time (L24-L25). So the shallow clone's history reads stay isolated as well.

Closing issue #17304. For this file, the change meets "Every test helper that creates a throwaway repository isolates it from global and system git config". The second criterion is that suites pass in parallel on a host that signs commits. That is the author's claim and is unverified: I have no shell and ran nothing.

Prior and settled threads.

  • The three earlier inline findings (scope-code-files.test.sh, test_count_capture_sources.py, lane-launcher.test.sh) are resolved by owner replies saying they were fixed. None of those files is in this push.
  • The previous summary comment's chunk 2 named one summary-only blocking finding. That text is cut off in the prior-findings file, so I could not compare it with this push. This push adds the missing isolation to the one fixture clone in this file that lacked it, which may be what that finding was about.

Loosened checks. The job sent no loosened_check_verdict: or loosened_check_patterns: lines, so I used fail with no consumer entries. It sent no decision-record line either, so I did not check the citation requirement. Loosened-check verdict: fail by default. Nothing in this change weakens a check.

Not applicable. No plugin manifests change. The PR context and the thread files contain no embedded instructions. Nothing here costs money or spends credits.

Verifier dropped 0 of 0 candidates.

kyle-sexton and others added 2 commits November 19, 2026 03:11
- scope-code-files.test.sh exported GIT_CONFIG_GLOBAL and
  GIT_CONFIG_NOSYSTEM before the loop that unsets every GIT_CONFIG_*
  variable, so the loop removed them; the export now follows the loop.
- test_count_capture_sources.py built ENV without any GIT_ key, so its
  fixture git commands lost the isolation; ENV now carries both values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/resolve-conflicts
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed none (read lane)
Run 44490770490

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-unblock/apply-conflict-patch
Model rung 0
Leg base
Run job success
Activity step skipped
Commits pushed none recorded
Run 44490770490

Failed GitHub API calls

Method Path Status
GET /repos/{repo}/git/ref/tags/* 404

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 4f987977f9ef09b0f53a3c6f01693d927dc71caf; the summary is in this lane's pull request comment.

claude-lane: claude-review

kyle-sexton and others added 6 commits November 19, 2026 04:02
…t fixture

The GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM export, with the GIT_DIR
unset, sat beside the execution-target cases, after the suite had already
run real git for its sha256 fixture and hash-object stub. It now runs
right after set -uo pipefail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nfig

audit-size.test.sh, persist-report.test.sh and the docs-naming
audit-file-names fixture builder and its inventory, sweep and
emit-findings suites created throwaway repositories without the
GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM export. Each now sets it after
its GIT_DIR unset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_shallow_clone_degrades_with_notice built its clone env by dropping
every GIT_CONFIG* variable, so `git clone --depth 1` read host config.
The env now carries GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM, as the
file's git() helper does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit fac2a5f Nov 19, 2026
57 checks passed
@kyle-sexton
kyle-sexton deleted the test/17304-isolate-test-git-config branch November 19, 2026 10:09
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 0, survived 2, timeout 0, no coverage 0, invalid 0, not run 3.
Covered-code score 0%; mutation score 0%.

File Killed Survived Timeout No coverage Invalid Not run
plugins/guardrails/hooks/guardrails-test-helpers.sh 0 0 0 0 0 1
plugins/session-telemetry/hooks/session-telemetry-test-helpers.sh 0 1 0 0 0 0
plugins/testing/hooks/judge-test-helpers.sh 0 1 0 0 0 0
scripts/lib/fixture-tree.sh 0 0 0 0 0 1
scripts/test-git-helpers.sh 0 0 0 0 0 1

Surviving mutants

Location Operator Disposition Cause
plugins/session-telemetry/hooks/session-telemetry-test-helpers.sh:19 SBR productive no-assertion
plugins/testing/hooks/judge-test-helpers.sh:10 SBR productive input-gap

The run's summary has the full report.

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

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: isolate throwaway test repositories from global git config

1 participant