Skip to content

test: keep fixture git from leaving auto maintenance running - #20311

Merged
iamwhatever merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/scratch-quarantine-walk-race
Oct 24, 2026
Merged

iamwhatever merged 2 commits into
kirodotdev:mainfrom
jeeshofone:fix/scratch-quarantine-walk-race

Conversation

@jeeshofone

@jeeshofone jeeshofone commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

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 TestGitTreesAreQuarantined test failed in Backend Tests (3.12, 8) on a PR that touches no scratch code, with FileNotFoundError from os.utime in 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

  • No change to the scratch sweep. Its tree walks already treat an OSError mid-walk as "keep the tree".
  • No change to production git calls. Only the test suite's own environment changes.

What changed (motivation → approach → change)

  • Root cause: a git commit starts git maintenance run --auto --quiet --detach, whose daemonized grandchild outlives the call and creates and removes lock files under .git.
  • The floor is bound by the repo-root conftest.py from test/conftest_floor_git.py, so it reaches every testpath. A session-scoped autouse fixture (_git_global_config, own MonkeyPatch) is live before any session, module or class fixture:
    • GIT_CONFIG_GLOBAL points at a session file that includes the global config git would read anyway, then sets maintenance.auto=false and gc.auto=0 (git < 2.29). It reaches a local push's receive-pack, which GIT_CONFIG_COUNT does not.
    • The same two keys are appended through GIT_CONFIG_COUNT, after any entries the environment already carries.
    • The function-scoped _git_maintenance_off re-adds the entries when a test's environment lost them. test/conftest.py's _git_identity uses a hermetic copy (only the two keys) where it used /dev/null.
    • Shared logic: test/git_maintenance_helpers.py, loaded by path; its trace_git_spawns traces git under a helper that strips GIT_* too.
    • The same two fixtures remove git's location variables (update_governance's _GIT_LOCATION_VARS, less GIT_CEILING_DIRECTORIES, which the floor sets itself) and GIT_CONFIG_PARAMETERS. A suite started from a git hook inherits them: a fixture git add would stage into the operator's index, and an operator's -c maintenance.auto=true outranks GIT_CONFIG_COUNT. Why not its own PR: this PR's own pins and fixtures run git add and git commit with the floor's env, so without the strip they stage into the operator's index under a hook (AUTOSDE no-test-side-effects).
  • Bypasses, each closed where it happens:
    • Helpers that strip GIT_*, build their env from nothing or through an allowlist, or point GIT_CONFIG_GLOBAL away 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_env in ai_review_workflows_helpers writes the keys into the global file it points at. test_apps_registry's transport tests index the entries they append, so _init_registry_fixture_repo writes the keys into the repo's config.
    • Seven helpers set their own GIT_CONFIG_COUNT and apply the entries last (governance_updates, push_guard, ratchet_scope, prepare_pr_diff_signals, ...).
    • Remotes pushed to under an env that points GIT_CONFIG_GLOBAL at /dev/null write the two keys into their own config: the templates in test_push_guard, test_preflight_write_permission, test_md_notebook, and the bare remotes in test_papyrus_gitops and test_memory_benchmark_workflow.
  • Ratchet (test/test_git_maintenance_ratchet.py): any *.py on either testpath (helpers and conftests too) that strips GIT_* keys or assigns GIT_CONFIG_GLOBAL/GIT_CONFIG_COUNT in an env dict must call git_maintenance_off_entries or git_global_config_text, or read GIT_MAINTENANCE_OFF_CONFIG (the --local remote writes). One exempt file builds an input mapping and runs no git. Why not a hand-written pin list alone: a new file such as test_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, --global and a local push's receive-pack; includes stay ahead of the keys; the entry rules; both keys under each of the seven helpers with GIT_CONFIG_GLOBAL=/dev/null; a traced commit through each of the seven env helpers starts no auto maintenance, after a maintenance.auto=true control shows the trace sees it; an operator GIT_CONFIG_PARAMETERS turns maintenance on (control) and the floor strips it; GIT_CEILING_DIRECTORIES survives the strip.
  • Ratchet: each of five planted shapes fails without a remedy and passes with each of three; os.environ, monkeypatch.setenv and assert code are not flagged; a planted helper module or conftest fails; the real tree passes, and reverting ai_review_workflows_helpers's conversion is red.
  • TestFixtureGitHasAutoMaintenanceOff (auto_improvement/tests/test_dogfood_learnings_clone.py) and the --local template pins read both keys as off. No new skips: a missing prerequisite pytest.fails.
  • Auto-maintenance starts, counted with trace2 by a git wrapper on PATH plus a Popen._execute_child hook, over the 171 test files that name a git binary: 2084 on origin/main b413800 → 0 at -n 8, besides the self-tracing controls. test_ai_review_shallow_fetch.py alone: 275 → 0.
  • Stripped variables: with them aimed at a sentinel repo, a fixture add and commit under each helper and an inherited env leaves the sentinel's index byte-identical (GIT_INDEX_FILE alone, with GIT_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_FILE or GIT_COMMON_DIR dropped (9 red); the ceiling stripped (1); GIT_CONFIG_PARAMETERS kept (10). Pytest from a real pre-commit hook passes.
  • Mutations, each red on a named pin: root floor or GIT_CONFIG_GLOBAL dropped; gc.auto dropped; keys before the includes; the floor dropped from each helper; _git_identity back at /dev/null; tracing through os.environ only.
  • Scoped runner's related set, 727 files, on base 680291f in one pytest run: 39728 passed, 1216 skipped. Its 27 failures fail the same way at that base on this host (the sandbox's / is owned by uid 65534, /tmp refuses setfacl, and the shared venv has pytest-asyncio 0.20.3). test_boot_smoke.py (integration on): 16 passed.
  • black, isort, flake8, mypy, the flake-pattern ratchet and the profile's repo-policy checks clean. Semgrep 1.78.0 (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 commit under an env it built itself (strip GIT_*, own GIT_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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners October 14, 2026 13:29
@jeeshofone
jeeshofone requested a review from mbriones98 October 14, 2026 13:29
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ⏭️ skipped

Revision b7cd71428f597634e5a89c8eceb6c0ef643e8aeb ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision b7cd71428f597634e5a89c8eceb6c0ef643e8aeb touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of b7cd71428f597634e5a89c8eceb6c0ef643e8aeb via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • The location-variable strip (GIT_DIR, GIT_INDEX_FILE, GIT_CONFIG_PARAMETERS) is a separate concern from auto maintenance. The description explains why it ships here, and stripping more variables in tests has no production reach.
  • The ratchet checks per file, not per helper, and it does not see an env built from nothing. Its docstring says both. A new hand-built env will slip past it until someone adds that helper to the traced-spawn parametrize list.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed b7cd71428f597634e5a89c8eceb6c0ef643e8aeb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] b7cd714

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed b7cd71428f597634e5a89c8eceb6c0ef643e8aeb via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b7cd714

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 14, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) October 14, 2026 15:05

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@jeeshofone jeeshofone changed the title test(scratch): stop fixture git leaving auto maintenance running test: keep fixture git from leaving auto maintenance running Oct 14, 2026
auto-merge was automatically disabled October 14, 2026 15:09

Head branch was pushed to by a user without write access

@jeeshofone
jeeshofone force-pushed the fix/scratch-quarantine-walk-race branch from d5388b8 to 8630163 Compare October 14, 2026 15:09
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Disposition for head 8630163 (rebased onto current main), answering an independent review of d5388b8 (approve, three nits) plus one structural follow-up.

  • NIT-1, the regression had no positive control: fixed.

The test now runs a control commit with git's defaults and trace2 on. A word search over every argv, independent of the filter, must find a maintenance or gc child (else the test skips: this git starts none), and the filter must recognise it.
Filtering on argv[0:1], with or without dropping maintenance.auto=false from the helper, now turns the test red.

The commit waits for its direct child; the daemonized grandchild is what outlives the call. Only that sentence changed.

  • NIT-3, gc.auto=0 looked like dead config: fixed.

The helper comment now says gc.auto=0 covers git older than 2.29, where a commit ran gc --auto directly.

  • Class fix: the test/conftest.py git floor also exports maintenance.auto=false.

It appends through GIT_CONFIG_COUNT/KEY_n/VALUE_n after any entries the environment already carries. Every test that inherits the environment and commits then walks a repo (test_project_tree among them) is covered; helpers that strip GIT_* keep their own flags, so the scratch helper change stays.
Pinned by two floor tests: git reads false inside a test, and pre-existing entries survive. Both mutations (floor sets true, floor overwrites index 0) go red.

First-pass check: R1-R8 OK. Every hunk maps to the goal; no sensitive path; no new state outside the test environment.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Oct 14, 2026
@jeeshofone
jeeshofone force-pushed the fix/scratch-quarantine-walk-race branch from 8630163 to bad7b68 Compare October 14, 2026 17:23
@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head bad7b68883 (one commit, rebased onto current main). Disposition for the independent review of 8630163:

  • SF-1 (floor not live in session/module/class fixtures): fixed. test/conftest.py adds _git_maintenance_off_session, a session-scoped autouse fixture with its own MonkeyPatch, so the entry is in place before template builders such as test_project_tree._repo_template. The function floor appends only when the entry is missing. Pinned by a module-scoped fixture in test_host_isolation_floor.py that reads maintenance.auto as false; removing the session floor turns it red. trace2 on test_project_tree.py: 6 maintenance run --auto starts before at -n 9 (1 at -n 0), 0 after. Body line on the scope rule corrected.
  • NIT-A: the control passes -c maintenance.auto=true, and the regression drops the suite entry (GIT_CONFIG_COUNT=0), so M9 (helper keeps GIT_*, drops its flags) is now red, not a skip.
  • NIT-B: test_agent_scratch git-tree tests race git's background auto maintenance #20310 now says the daemonized grandchild outlives the commit in both places.
  • NIT-C: both helpers pass -c maintenance.auto=false -c gc.auto=0; trace2 shows 1 maintenance start each before, 0 after.
  • NIT-D: a malformed or negative inherited GIT_CONFIG_COUNT restarts at 0, matching git_targets.py; parametrized tests cover both plus "already false adds nothing" and "a later true gets a new false". Each of those mutations is red.
  • PR Hygiene "11 commits" (stale event base) and the Await Fast Gate skip on 8630163: not code findings; this push is the fresh event.

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 (semgrep/): 0 findings on changed lines.

First-pass check: R1-R8 OK.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 14, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/scratch-quarantine-walk-race branch from a8e28e2 to ece9b33 Compare October 15, 2026 17:07
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Head ece9b33 (one commit, same base 6d4f287 as a8e28e2). Answers the GPT 6.1 review of a8e28e2.

F1 (BLOCKING, test/test_host_isolation_floor.py:1855, UPHOLD-FENCED): fixed. #20654 split test_ai_review_workflows.py and moved the _git helper onto UxEvidenceGateHarness in the non-test helper module, so _drive_ai_review_git now imports ai_review_workflows_helpers.UxEvidenceGateHarness and drives its _git. The old lookup was the only reference to the moved class in test/.

Proof: the four ai_review_git cases (test_a_helper_that_builds_its_own_git_env_starts_no_auto_maintenance[ai_review_git] and the three test_a_fixture_commit_under_a_hook_env_leaves_the_outer_index_alone[*-ai_review_git]) fail on a8e28e2 with AttributeError and pass on this head.

Runs on this head, -n 8: every file that imports from the split modules (test_ai_review_workflows*.py, test_fork_stage2_checkout.py, test_review_lane_prompt_parity.py, test_git_maintenance_ratchet.py), test_host_isolation_floor.py and every test/*ratchet*.py: 1970 passed, 0 failed. The black gate, isort, flake8 and the comment-history gate pass. Semgrep 1.78.0 with the CI rule sets, baselined on the merge base, reports nothing on the changed file.

First-pass check: R1-R8 OK.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 15, 2026
@jeeshofone
jeeshofone force-pushed the fix/scratch-quarantine-walk-race branch from ece9b33 to 9b60b1f Compare October 15, 2026 18:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 15, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Design CONCERNS on 9b60b1f53 (advisory): the location-variable strip stays in this PR.

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 279cb82dc (no-test-side-effects). The PR's own fixture, test/test_host_isolation_floor.py's run helper, passed the operator's full environment to git add/git commit. Under a git hook, GIT_INDEX_FILE/GIT_DIR/GIT_WORK_TREE leaked in and the fixture could stage into the operator's real index. Splitting the strip out would put that blocking finding back on this head.

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 GIT_CONFIG_PARAMETERS but keeps an inherited GIT_DIR still lets a test's git act on the operator's repository, maintenance included. The delta review of 2b5524be2 ran real pre-commit hooks against it: the outer index stayed byte-identical, and 10 of 12 mutations went red.

Rollback is one revert of a test-only change; src/ is untouched.

@iamwhatever

Copy link
Copy Markdown
Contributor

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)

@jeeshofone

Copy link
Copy Markdown
Contributor Author

New head 0afba5089 (two commits), rebased from e1b24c5fc onto main 5cc82ba24.

Why Backend Tests (Windows) (7) was red on e1b24c5fc. Both failures are outside this diff:

The floor sets only git variables: GIT_CONFIG_GLOBAL, the GIT_CONFIG_COUNT entries, and the removal of git's location variables and GIT_CONFIG_PARAMETERS. _ci_sees_tests hands bash an env of PATH, PR_BODY and GITHUB_OUTPUT alone, so none of it reaches that call. Here both tests pass the same with the floor and on origin/main: 148 passed each, the shard test in 14.4 s and 14.5 s.

What changed in the second commit. The rebase turned up one break that is ours. test/test_git_maintenance_ratchet.py failed on two files main added in #22971, test_prepare_pr_diff_signals_proof.py (_git_env) and test_prepare_pr_prove_line.py (_env). Both strip GIT_* and point GIT_CONFIG_GLOBAL at /dev/null, so their fixture commits ran with auto maintenance on. Each now ends with env.update(git_maintenance_off_entries(env)), the edit the second commit already makes in the other split prepare_pr_* files. I amended that commit, kept its author, and named the two files in its message. The first commit is unchanged (git range-diff shows =). The body now says where the floor's fixtures live (test/conftest_floor_git.py), names test_dogfood_learnings_clone.py, and gives this head's runs.

Local runs on 0afba5089. 87 files at -n 8 (touched tests, every ratchet, the facade test, every importer of the helpers): 4768 passed, 8 skipped. test_boot_smoke.py with integration on: 16 passed. Flake-pattern ratchet: 60 passed. black (baselined), isort, flake8, mypy src/kiro_crew/, subprocess-encoding and comment-history clean. Semgrep 1.78.0 (semgrep/, merge-base baseline): 0 findings.

First-pass check: R1-R8 OK.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • span=9a9839f33041: the location-variable strip stays in this PR (Note 2 of the PASS on e1b24c5fc)

Rebutted, as answered for 9b60b1f53 in issuecomment-6200449689. The floor's own fixtures run git add and git commit with the floor's env, and a suite started from a git hook inherits GIT_INDEX_FILE (and GIT_DIR or GIT_WORK_TREE when the caller set them), which would point those commands at the operator's repository (AUTOSDE no-test-side-effects).
Splitting the strip out would leave the floor's fixtures exposed to that on whichever head carries the floor.
Revert path: both commits are test-only and change no production file under src/, so one revert takes the floor and the strip out together.
0afba5089 leaves the strip as it was. Its second commit only adds the maintenance entries to two env builders main added.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Note 1 of the PASS on e1b24c5fc: the ratchet checks per file, not per helper

Kept as is. The ratchet's docstring names this miss itself ("It checks the file, not the helper").
The case that recurs is a new file that rebuilds a git env, and the ratchet catches that: on this rebase it found two that main added (test_prepare_pr_diff_signals_proof.py, test_prepare_pr_prove_line.py), both fixed on 0afba5089.
The miss left is narrower: a second from-scratch builder inside a file that already applies the entries. Any builder that starts from os.environ keeps the floor's session-scoped entries without a call, so a per-function scan would add machinery to a flake guard for that one shape.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Design PASS on bf48d32: check the Windows and macOS backend shards (the HOLD in issuecomment-6220741156)

macOS Tests does not run on a fork head: macos-on-demand.yml gives a fork PR only the ci:macos label switch, and the nightly runs the suite after merge.
Nothing in this diff branches on the platform: no added line checks sys.platform, os.name or platform.system. The floor works through git's own GIT_CONFIG_GLOBAL and GIT_CONFIG_COUNT, which git reads the same way on every OS.
Windows is the non-Linux runner this head does get. On e1b24c5fc seven of eight Windows backend shards passed, and shard 7's reds are main's (#23259, fixed by #23264, and #23365), answered in the comment above. 0afba5089 carries #23264.
A darwin verdict before merge needs a maintainer's ci:macos label.

@jeeshofone

Copy link
Copy Markdown
Contributor Author
  • Security Scope Review BLOCK on 9b0c1fa82: "no leg reported"

That verdict names no regression. No [SCOPE-REVIEWED] marker was produced for 9b0c1fa82, so the lane withheld the model's text and listed no newly refused operation.
The PR is test-only. On 0afba5089 every changed file is a conftest, a test helper or a test module, and no production file under src/ changes, so no legitimate operation can be newly refused.
On e1b24c5fc the Security Scope Review check concluded success. The BLOCK comment was last written for 9b0c1fa82, several heads back.

@jeeshofone

jeeshofone commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

Red on ba52e8f Failing test Cause Tracker
Backend Tests (Windows) (1) test_proof_line_check.py::test_tests_is_found_exactly_when_the_template_check_finds_it (33 cases) bare bash starts the WSL launcher on the hosted Windows runner #23391 and #23406, fixed by #23445
Backend Tests (Windows) (1) test_check_decisions_history_selftest.py::test_self_test_passes_on_this_platform the test runs the gate's self-test in a child process capped at 60 s, and on a loaded hosted runner the child ran past the cap #23473, which runs the self-test in-process without the cap
Backend Tests (Windows) (1) ERROR at teardown of test_store_settings.py::TestRecommendationsAndLabelCache::test_two_languages_do_not_evict_each_other the timeout above killed the self-test's child inside a TemporaryDirectory() block, so one tmpXXXXXXXX directory outlived the run in that worker's temp root. The temp-residue guard reports it when the worker's session ends and names the worker's last test, which is not the culprit #23473, same cause
PR Readiness none of its own it aggregates the checks above the rows above

Why the timeout is not this PR's git floor:

  • Run 39934645184 on fix(security): redact both of two credentials written back to back #23326 (head 0f8eecc), which does not carry the floor, failed the same way: the self-test timed out at 60 s on gw0, and gw0's last test_store_settings.py teardown reported one leftover tmp directory.
  • Across 88 hosted windows-latest runs of Windows (1) on 23 Oct between 03:35 and 12:04 UTC, the self-test took a median of 10.1 s and a 90th percentile of 14.9 s, with a tail from 16 s to 38 s. Only these two runs reached 60 s. This PR's two previous heads ran it in 8.2 s (e1b24c5) and 10.3 s (0afba50) on the same runner type. On CodeBuild Windows it never took longer than 14.6 s in 114 runs.
  • Locally on Linux the self-test starts 117 git processes, and none of them is auto maintenance, under both main's git environment and the floor's. Its median runtime over 10 alternating runs is 0.40 s against 0.41 s. It never commits, so none of the git it runs reaches the auto-maintenance step the floor's maintenance.auto and gc.auto entries turn off.
  • The leftover directory is the killed child's. Its name, tmpx4vd6h6q, is TemporaryDirectory()'s default, the guard says no tempfile call in the worker made it, and it sits in the temp root of gw0 (pid 1956), the worker that ran the self-test. Killing the self-test's child locally at six points through its run left exactly one such directory each time.

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 main 99cced3 to pick up #23405. The new head is ba52e8f, still two commits, and git range-diff shows both unchanged. The second commit keeps its author.

Red on 0afba50 Failing tests Cause Tracker
Backend Tests (Windows) (1) test_proof_line_check.py::test_tests_is_found_exactly_when_the_template_check_finds_it (33 cases) bare bash starts the WSL launcher on the hosted Windows runner #23391 (also #23406); a fix for the hosted runner is on the way
Backend Tests (Windows) (1), (3), (4) test_workspace_file_transactions.py (6), test_coder_archive_write_races.py (5), test_remote_workspace_file_integrity.py (6) os.path.commonpath in workspace_tools.py across the C: temp directory and the D: checkout #23392, fixed by #23405, which this head includes
Backend Tests (Windows) (8) test_auto_research_campaign_contract.py::TestTransitionSerialization::test_concurrent_starts_are_single_flight a fixed 5 s bound on the first start's status write #23446
Backend Tests (3.12, 7) test_remote_session.py::test_child_exit_flushes_output_and_finishes_the_link the remote worker signals a child that has already exited, which reaps it before asyncio's watcher does, so the exit reads 255 #23435 (cause and a deterministic check), also #23402
Backend Tests (3.12, 7) test_config_loader_default_agent.py::TestDanglingDefaultAgentReset::test_a_relative_workspace_is_placed_under_the_data_home unraisable-exception warnings from a sibling test's teardown #23427
Coverage Gate (derived) none of its own it fails closed on backend-test=failure the shards above
PR Readiness none of its own it aggregates the checks above the shards above

Why none is ours: the floor sets GIT_CONFIG_GLOBAL and the GIT_CONFIG_COUNT maintenance entries, and removes git's location variables. It does not set TMP, TEMP, HOME, USERPROFILE or pytest's base temp, so tmp_path stays in the runner's own C: temp directory. The trackers above show the Windows failures on unrelated PRs. The 255 failure is on seven other PR runs since 07:44 UTC, and it reproduces at the merge base 5cc82ba without this PR.

Local checks on ba52e8f:

  • 86 files at -n 16 (touched tests, every ratchet, the facade test, every importer of the helpers): 5311 passed, 8 skipped.
  • test_boot_smoke.py with integration on: 16 passed.
  • The black gate, isort, flake8, mypy and the comment-history gate are clean. Semgrep reports 0 findings on the diff.

@jeeshofone

Copy link
Copy Markdown
Contributor Author

Opus BLOCKING on 8d0dad32c, test/test_host_isolation_floor.py:1669 (the post-receive hook gets CRLF endings on Windows): fixed on 86e0d8afbb.

test_a_local_push_starts_receive_pack_with_both_keys_off now writes its hook with newline="\n" (test/test_host_isolation_floor.py:1671-1677), as test_ratchet_scope.py:616 does for its post-commit hook, and a comment says why. The fix is amended into our commit (261b5ed491). The maintainer's commit is unchanged (git range-diff: =).
I checked the other files that commit writes, and none of them is run by sh:

  • The two git config files (test/conftest_floor_git.py:75 and :77, test/ai_review_workflows_helpers.py:1077) are read by git's config parser, which drops the CR from a CRLF line.
  • The planted ratchet sources go through read_text, which turns CRLF into LF, before ast parses them.
  • The rest are data files that a test commits.

AUTOSDE tests-are-deterministic: the hook's bytes no longer depend on the host's line ending.

First-pass check: R1-R8 OK.

jeeshofone and others added 2 commits October 23, 2026 19:04
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 iamwhatever 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.

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)

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

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_agent_scratch git-tree tests race git's background auto maintenance

4 participants