Repository navigation
test: keep fixture git from leaving auto maintenance running - #20311
Conversation
First Principles Review (Opus 5.5, fork) — ⏭️ skippedRevision |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change is test-only, it removes the root cause (git's detached auto maintenance), and every helper that builds its own git env applies the fix where that env is built. Notes
[DESIGN-REVIEWED] b7cd714 Description read[DESCRIPTION-READ] c063b75c7d1d566e56835df1f6894d2ed9f0a3ae73e4af0bcdad051a543bc312 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: test (1 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: test-only change: fixture git commands turn off auto maintenance and auto gc, with a test that no fixture command starts one.
Head branch was pushed to by a user without write access
d5388b8 to
8630163
Compare
|
Disposition for head 8630163 (rebased onto current main), answering an independent review of d5388b8 (approve, three nits) plus one structural follow-up.
First-pass check: R1-R8 OK. Every hunk maps to the goal; no sensitive path; no new state outside the test environment. |
8630163 to
bad7b68
Compare
|
New head
Tests: 1976 passed / 1 skipped over the floor, scratch, project-tree, nine template-builder, two helper files, ratchets and facade; 99-file git sweep 11435 passed, 0 failed. black gate, isort, flake8, subprocess-encoding and comment-history gates clean; Semgrep 1.78.0 ( First-pass check: R1-R8 OK. |
a8e28e2 to
ece9b33
Compare
|
Head ece9b33 (one commit, same base 6d4f287 as a8e28e2). Answers the GPT 6.1 review of a8e28e2. F1 (BLOCKING, Proof: the four Runs on this head, First-pass check: R1-R8 OK. |
ece9b33 to
9b60b1f
Compare
|
Design CONCERNS on It is not a separate change that came along: it is this PR's answer to a blocking finding the GPT 6.1 lane upheld on It also serves the stated goal. The floor that turns off auto maintenance does so by rewriting the git environment every test sees. A floor that sets Rollback is one revert of a test-only change; |
|
HOLD at bf48d32: one review ask has no reply yet. The fix looks sound and stays test-only. The root conftest floor turns off git auto maintenance before session fixtures run, through GIT_CONFIG_GLOBAL and GIT_CONFIG_COUNT. It strips the inherited git location variables. The ratchet makes helpers that build their own git env apply the same entries. All checks on this head are green, the Windows backend shards included, and the earlier Design CONCERNS has a reply that holds up. Unanswered on this head:
To clear this, post a target=design disposition for bf48d32. It can link a macOS run on this head, or explain why the macOS lane does not need to run for this change. — crew-pr-reviewer (r107) |
|
New head Why
The floor sets only git variables: What changed in the second commit. The rebase turned up one break that is ours. Local runs on First-pass check: R1-R8 OK. |
|
|
|
|
|
CI on ba52e8f settled with one red shard, Backend Tests (Windows) (1), plus PR Readiness, which aggregates it. The cross-drive reds are gone, and none of the failures left comes from this PR's diff.
Why the timeout is not this PR's git floor:
No change on this head, so it stays ba52e8f until #23445 merges and I rebase. Earlier round: CI on 0afba50 finished with seven reds, and none comes from this PR's diff. I rebased onto
Why none is ours: the floor sets Local checks on ba52e8f:
|
|
Opus BLOCKING on
AUTOSDE First-pass check: R1-R8 OK. |
The git-tree quarantine tests build a repository and then walk, snapshot and move it straight away. A fixture commit starts 'git maintenance run --auto --detach', whose daemonized grandchild outlives the call and adds and removes lock files under .git, so the walk could list a file that was gone by the time it was touched (FileNotFoundError from os.utime in test_a_tree_marked_active_before_the_final_look_is_not_moved). The scratch fixture helper turns off both auto-maintenance triggers (maintenance.auto=false, gc.auto=0) for every command through the shared entries. A new test drops the suite's own entries, traces the fixture commands with trace2 and asserts none starts a maintenance or gc child, after a control commit with maintenance.auto=true shows the filter does recognise one. The floor lives in the repo-root conftest.py, so it reaches every testpath, src/kiro_crew/apps/builtins included. A session-scoped autouse fixture points GIT_CONFIG_GLOBAL at a session-owned file that includes the global config git would read anyway (the redirected XDG file, then ~/.gitconfig) and then sets maintenance.auto=false and gc.auto=0. The same keys are appended through GIT_CONFIG_COUNT after any entries the environment already carries. A global file also reaches the receive-pack a local push starts and git that code under test runs with its own env, which GIT_CONFIG_COUNT does not. The function-scoped floor re-adds the entries only when a test's environment lost them, and test/conftest.py's git floor uses a hermetic copy of the file (only the two keys) where it used /dev/null. A malformed or negative inherited count restarts at 0, as registry_pipeline.git_targets does. Fixture helpers that strip GIT_*, or point GIT_CONFIG_GLOBAL away, apply the shared entries to the env they build (among them test_ai_review_shallow_fetch, whose fixture commits started 275 auto-maintenance runs). A ratchet fails any Python file under test/ or src/**/tests/ (helper modules and conftests included) that strips GIT_* or assigns GIT_CONFIG_GLOBAL or GIT_CONFIG_COUNT in an env dict without the helpers. The seven helpers that set their own GIT_CONFIG_COUNT apply the shared entries to their finished env. Repos that a push under such a helper reaches write the two keys into their own config: the push guard, preflight permission and md notebook templates, and the bare remotes in test_papyrus_gitops and test_memory_benchmark_workflow. Floor tests pin both keys in a module fixture, inside a test, in the global file and in a local push's receive-pack, under each of the seven helpers with the global file held away, and in the builtins testpath's environment. The same floor removes git's location variables (update_governance's list, less GIT_CEILING_DIRECTORIES, which the floor sets itself) and GIT_CONFIG_PARAMETERS at session and test scope. An operator's `git -c maintenance.auto=true` reaches a hook through GIT_CONFIG_PARAMETERS and outranks GIT_CONFIG_COUNT. A suite started from a git hook inherits GIT_INDEX_FILE, and GIT_DIR or GIT_WORK_TREE when the caller set them, so a fixture repo's add would otherwise stage into the operator's real index. A pin points them at a sentinel repository and checks that a fixture add and commit, under each helper above and under an inherited env, leaves the sentinel's index byte-identical, with every stripped name planted. test_dev_fleet_app's git skipif sits on the object-graph test again (on the new env helper a mark is inert), and a pin checks where it sits.
…tests Main split both conftests into test/conftest_floor_* parts (kirodotdev#22671) and several test files into topic files. The floor's fixtures now live in test/conftest_floor_git.py, bound by the rootdir conftest. The helpers that moved (push_guard_helpers, md_notebook_helpers, the registry transport and claim preflight end-to-end tests) carry the same entries, and the new split files the ratchet found apply git_maintenance_off_entries to the env they build. So do the two Proof-line test files main added since (kirodotdev#22971), test_prepare_pr_diff_signals_proof.py and test_prepare_pr_prove_line.py.
iamwhatever
left a comment
There was a problem hiding this comment.
Approve at b7cd714.
The change is test-only. It removes the root cause of #20310: fixture commits no longer leave a detached git maintenance run --auto writing under .git. The root floor (conftest_floor_git.py#L46-L87) sets the keys through both GIT_CONFIG_GLOBAL and GIT_CONFIG_COUNT before any session fixture runs. Helpers that build their own env apply the same entries, and the ratchet (test_git_maintenance_ratchet.py#L72-L131) keeps new ones honest.
Our r107 hold on macOS is answered (disposition). Fork heads cannot run macOS Tests, and nothing added branches on platform. The Opus BLOCK on 8d0dad3 (a CRLF hook on Windows) is fixed, both Design notes have replies, and every check on this head is green, including all eight Windows shards. The credential-transport and signing test files only gain maintenance-off fixture config, and none of their assertions change.
— crew-pr-reviewer (r123)
Problem / Motivation
Goal: Tests that build a git repository and then walk or copy it stop failing at random on unrelated PRs because a fixture commit left git's auto maintenance running in the tree.
A
TestGitTreesAreQuarantinedtest failed inBackend Tests (3.12, 8)on a PR that touches no scratch code, withFileNotFoundErrorfromos.utimein its own walk of the tree it had just built (#20310).Why it matters
A red shard on an unrelated PR fails its Coverage Gate and PR Readiness. Any test on either testpath (
test/, builtins) that commits and then walks, copies or counts a repository is exposed.Not a goal
OSErrormid-walk as "keep the tree".What changed (motivation → approach → change)
git commitstartsgit maintenance run --auto --quiet --detach, whose daemonized grandchild outlives the call and creates and removes lock files under.git.conftest.pyfromtest/conftest_floor_git.py, so it reaches every testpath. A session-scoped autouse fixture (_git_global_config, ownMonkeyPatch) is live before any session, module or class fixture:GIT_CONFIG_GLOBALpoints at a session file that includes the global config git would read anyway, then setsmaintenance.auto=falseandgc.auto=0(git < 2.29). It reaches a local push'sreceive-pack, whichGIT_CONFIG_COUNTdoes not.GIT_CONFIG_COUNT, after any entries the environment already carries._git_maintenance_offre-adds the entries when a test's environment lost them.test/conftest.py's_git_identityuses a hermetic copy (only the two keys) where it used/dev/null.test/git_maintenance_helpers.py, loaded by path; itstrace_git_spawnstraces git under a helper that stripsGIT_*too.update_governance's_GIT_LOCATION_VARS, lessGIT_CEILING_DIRECTORIES, which the floor sets itself) andGIT_CONFIG_PARAMETERS. A suite started from a git hook inherits them: a fixturegit addwould stage into the operator's index, and an operator's-c maintenance.auto=trueoutranksGIT_CONFIG_COUNT. Why not its own PR: this PR's own pins and fixtures rungit addandgit commitwith the floor's env, so without the strip they stage into the operator's index under a hook (AUTOSDEno-test-side-effects).GIT_*, build their env from nothing or through an allowlist, or pointGIT_CONFIG_GLOBALaway apply the entries to the env they built: the scratch_git,scope_verdict,cli_manifest_signature,ai_review_shallow_fetch,add_contributor_push_skip,file_line_cap,macos_platform_tests_gate,dev_fleet_app, and nine more already carrying them (project_git,project_tree, ...), kept explicit for the ratchet._git_envinai_review_workflows_helperswrites the keys into the global file it points at.test_apps_registry's transport tests index the entries they append, so_init_registry_fixture_repowrites the keys into the repo's config.GIT_CONFIG_COUNTand apply the entries last (governance_updates,push_guard,ratchet_scope,prepare_pr_diff_signals, ...).GIT_CONFIG_GLOBALat/dev/nullwrite the two keys into their own config: the templates intest_push_guard,test_preflight_write_permission,test_md_notebook, and the bare remotes intest_papyrus_gitopsandtest_memory_benchmark_workflow.test/test_git_maintenance_ratchet.py): any*.pyon either testpath (helpers and conftests too) that stripsGIT_*keys or assignsGIT_CONFIG_GLOBAL/GIT_CONFIG_COUNTin an env dict must callgit_maintenance_off_entriesorgit_global_config_text, or readGIT_MAINTENANCE_OFF_CONFIG(the--localremote writes). One exempt file builds an input mapping and runs no git. Why not a hand-written pin list alone: a new file such astest_ai_review_shallow_fetch.py(275 starts) lands unlisted.Backwards compatibility
Compatible: test-only, no production code touched. The session file includes the files git reads without it.
Tests
TestGitAutoMaintenanceIsOff(test/test_host_isolation_floor.py): both keys read as off in a module fixture, a test,--globaland a local push'sreceive-pack; includes stay ahead of the keys; the entry rules; both keys under each of the seven helpers withGIT_CONFIG_GLOBAL=/dev/null; a traced commit through each of the seven env helpers starts no auto maintenance, after amaintenance.auto=truecontrol shows the trace sees it; an operatorGIT_CONFIG_PARAMETERSturns maintenance on (control) and the floor strips it;GIT_CEILING_DIRECTORIESsurvives the strip.os.environ,monkeypatch.setenvandassertcode are not flagged; a planted helper module or conftest fails; the real tree passes, and revertingai_review_workflows_helpers's conversion is red.TestFixtureGitHasAutoMaintenanceOff(auto_improvement/tests/test_dogfood_learnings_clone.py) and the--localtemplate pins read both keys as off. No new skips: a missing prerequisitepytest.fails.gitwrapper onPATHplus aPopen._execute_childhook, over the 171 test files that name a git binary: 2084 onorigin/mainb413800 → 0 at-n 8, besides the self-tracing controls.test_ai_review_shallow_fetch.pyalone: 275 → 0.GIT_INDEX_FILEalone, withGIT_DIR/GIT_WORK_TREE, and every stripped name). Mutations, each red on a named pin: either strip dropped;GIT_DIR,GIT_WORK_TREE,GIT_INDEX_FILEorGIT_COMMON_DIRdropped (9 red); the ceiling stripped (1);GIT_CONFIG_PARAMETERSkept (10). Pytest from a real pre-commit hook passes.GIT_CONFIG_GLOBALdropped;gc.autodropped; keys before the includes; the floor dropped from each helper;_git_identityback at/dev/null; tracing throughos.environonly./is owned by uid 65534,/tmprefusessetfacl, and the shared venv has pytest-asyncio 0.20.3).test_boot_smoke.py(integration on): 16 passed.semgrep/, merge-base baseline): 0 findings.Manual verification
N/A: unit coverage sufficient.
Related Issues
Fixes #20310
Pattern harvest
Rule candidate: semgrep
Pattern: a fixture runs
git commitunder an env it built itself (stripGIT_*, ownGIT_CONFIG_COUNT/GIT_CONFIG_GLOBAL), so the suite's maintenance floor never reaches it, then walks or copies the repository. The ratchet here enforces it for tests.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.