Skip to content

test(host-git-repo-exec): pin mtime before hook liveness check - #25469

Merged
iamwhatever merged 1 commit into
mainfrom
unflaky/host-git-repo-exec-fixture-liveness
Oct 29, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
unflaky/host-git-repo-exec-fixture-liveness

Conversation

@CrysisDeu

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the post-index-change hook liveness check in TestDashboardFileDiff::test_fixed_key_programs_and_hooks_do_not_run deterministic on fast runners.

After a fresh git commit every tracked file's cached mtime in the index exactly matches its on-disk mtime. When the self-check runs git -c core.fsmonitor= status --porcelain (fsmonitor explicitly disabled), git compares each file's stat against the index, finds them identical, skips the re-check, never writes the refreshed entry back, and post-index-change never fires. The marker stays empty and the liveness assertion fails.

Seen on two unrelated PRs (#19831, #23094) that do not touch this code; example run: https://github.com/kirodotdev/KiroCrew/actions/runs/40754675759 job 123058092936.

Why it matters

The test is new (landed in #24822 today) and already flaky on every CI run that follows a fast commit. It will block unrelated PRs on the same xdist shard until fixed.

Not a goal

  • Not changing the hook neutralization logic itself.
  • Not adding a retry or xfail.
  • Not touching the production path.

What changed (motivation → approach → change)

After a fresh git commit, the index caches the exact mtime of each tracked file. git status compares stat data and finds no mismatch, so it takes the fast path: no file re-read, no index write, no post-index-change hook. On Linux with nanosecond-resolution ext4, this is the common case because the file write and the commit happen at different nanoseconds.

Fix: call os.utime(repo / "a.txt", (1, 1)) before the liveness check. This sets the file's mtime to epoch+1s, which mismatches the index's cached value, forces git to re-read the file, find it unchanged, write the refreshed stat entry, and fire post-index-change -- deterministically regardless of runner speed or timestamp resolution.

The same os.utime(f, (1, 1)) pattern is already used in _with_nested_filter_repo for the same reason.

Backwards compatibility

Compatible: test-only change; no production code altered.
Removes nothing: no capability removed.

Tests

TestDashboardFileDiff::test_fixed_key_programs_and_hooks_do_not_run -- the liveness check now fires post-index-change deterministically; the real assertion (dashboard diff runs no hook) is unchanged.

Proof: not provable -- test-only change

Manual verification

N/A -- unit coverage sufficient. Determinism confirmed by analysis: os.utime(f, (1, 1)) guarantees a stat mismatch on every filesystem with any timestamp resolution.

Screenshots / video

N/A

…ess check

The fixture liveness check proved post-index-change fires by running
  git -c core.fsmonitor= status --porcelain
but this only triggers the hook when git must refresh a cached stat entry.
After a fresh commit every tracked file's cached mtime matches its on-disk
mtime exactly, so git skips the re-check on fast runners with nanosecond
timestamps and post-index-change never fires.

Fix: call os.utime(repo / 'a.txt', (1, 1)) before the liveness check.
This makes the file's mtime mismatch the index-cached stat, forcing git
to re-read the file, find it unchanged, write the refreshed entry back,
and fire post-index-change -- deterministically on every runner speed.

The same utime pattern is already used in _with_nested_filter_repo.
@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 28, 2026 22:56
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 5b2a5549e916744815bf23478d2fa1b635c0cfb4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Test-only change that makes the hook fixture's liveness probe deterministic; nothing blocks.

Notes

  • The probe's own git status writes the refreshed stat for a.txt back to the index. When the handler runs git status after it, all stats match again, so post-index-change would not fire even if hooks were not neutralized. That leaves the hook half of assert _ran(marker) == "" vacuous. Calling os.utime(repo / "a.txt", (2, 2)) again after _prove_planted_vector_fires keeps the real assertion able to fail.

[DESIGN-REVIEWED] 5b2a554

Description read

[DESCRIPTION-READ] ba79ca45bf196307d45ce1e33df5f4595d63dcd3e7fc57085c7652807fc5362f

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 5b2a5549e916744815bf23478d2fa1b635c0cfb4 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 5b2a554

Verdict parsed from the review's SHA-scoped output markers for commit 5b2a5549e916744815bf23478d2fa1b635c0cfb4.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 5b2a5549e916744815bf23478d2fa1b635c0cfb4 false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 5b2a5549e916744815bf23478d2fa1b635c0cfb4 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 5b2a554

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 5b2a5549e916744815bf23478d2fa1b635c0cfb4 false-positive: <reason, 20 to 500 characters>

@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 28, 2026

@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. Reviewed head 5b2a554.

The fix is sound and minimal: os.utime(repo / "a.txt", (1, 1)) makes a tracked file's stat disagree with the freshly committed index, so the unpinned git status probe must refresh the index and fire post-index-change on every runner (test L583-L594). The same pattern is already used elsewhere in this file. Test-only; no production code changes. All checks on this head are green and the AI lanes report no blocking findings.

AI findings judged non-blocking

  • Design Review (PASS note): after the probe refreshes the index, the handler's own git status has nothing to rewrite, so the hook half of assert _ran(marker) == "" cannot fail. This is correct, but it is not introduced here: on main the same vacuity existed whenever the old racy probe fired. The fsmonitor/pager half of the assertion stays live (_plant L79-L88). Re-staling a.txt after the probe would be a worthwhile small follow-up but does not block this flake fix.

— crew-pr-reviewer (r134)

@iamwhatever
iamwhatever merged commit da1af97 into main Oct 29, 2026
107 checks passed
@iamwhatever
iamwhatever deleted the unflaky/host-git-repo-exec-fixture-liveness branch October 29, 2026 06:42
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants