seam flake: TestConfigRepo_SlowApplyDoesNotEatTheGitBudget reds ci under runner load — the 100 ms git budget cannot cover four git spawns on a busy 8-core box #1878

Closed
opened 2026-09-25 12:17:17 +00:00 by matou-build-agent · 2 comments

The ci seam reds intermittently on main in the Go stage — Go: go.work resolves both modules; build, vet, test, lint each — with:

--- FAIL: TestConfigRepo_SlowApplyDoesNotEatTheGitBudget (0.50s)
FAIL	git.matou.nz/Matou/idss/internal/clan	35.892s

Seen on run https://git.matou.nz/Matou/idss/actions/runs/32679 (head 907a3006,
2026-09-25 12:01 UTC). Filed by the swarm healer; classified product, so the
healer made no code change.

Why it is the test's margin, not the behaviour

The #1760 fix is in place and correct: internal/clan/configrepo.go:127 starts the
commit sequence's budget with context.WithTimeout(base, configRepoMutationTimeout)
after apply returns, so a cold-store download can no longer eat it.

The test (internal/clan/configrepo_coldstore_test.go:35) shrinks
configRepoMutationTimeout to 100 ms and sleeps 3 * timeout inside apply. That
100 ms then has to cover four git subprocess spawns plus a working-tree walk:

  • firstConflictMarker() — filepath.WalkDir over the tree (configrepo.go:135)
  • git add -A (configrepo.go:149)
  • git status --porcelain via isClean (configrepo.go:306)
  • git commit -q -m … (configrepo.go:160)
  • git rev-parse HEAD via Head (configrepo.go:166)

Idle, that sequence is single-digit ms and the test passes with room. But the seam
runs go test ./..., which runs up to NumCPU package binaries concurrently on the
shared 8-core runner — process spawn + fs latency degrade far worse than CPU-bound
work under that contention. The failing run took 0.50 s where a healthy run takes
~0.33 s (0.30 s of which is the deliberate sleep), i.e. the git tail took ~200 ms
against a 100 ms budget. The same run's internal/clan package took 35.9 s vs 27.0 s
on the idle host — the whole package was ~33 % slower.

Reproduction attempts (healer, matou-workstation, same sha 907a3006)

  • go test ./internal/clan -run TestConfigRepo_SlowApplyDoesNotEatTheGitBudget -count=15 — pass
  • same, under 8 busy-loop CPU hogs — pass
  • 8 concurrent copies of the compiled test binary, -test.count=12 each (96 runs) — pass
  • full go test ./... (the seam's Go stage) — pass, 53 s, internal/clan 27.0 s

So it is not reproducible on an idle host and main is not persistently red; it is a
load-sensitive flake that will keep reding the seam on a busy runner.

What "done" looks like

The test's claim (a slow apply must not consume the git budget) is worth keeping —
only its wall-clock margin is unsafe. A fix should make the proof insensitive to
runner load rather than just nudging the number, e.g. keep the apply sleep tied to
the budget but give the budget enough headroom that a loaded 8-core box cannot blow
it, or assert the decoupling structurally (observe when the commit budget's clock
starts, rather than racing it). internal/clan/configrepo_deadline_test.go (which
sets the budget to time.Nanosecond) is deterministic by construction and does not
have this problem — a useful shape to borrow.

Please also check the rest of the Go suite for the same pattern: any test that pins a
production timeout to a short wall-clock value and then races real subprocesses under
it is the same flake waiting to happen.

Evidence

  • Run: https://git.matou.nz/Matou/idss/actions/runs/32679 (workflow ci.yml, job seam)
  • Healer incident signature 6e2243f659e0 — first occurrence in the healer ledger
  • Sandcastle worker logs for the run window show no worker fault (both workers found
    an empty ready queue and signalled COMPLETE); the fault is the seam's Go stage alone
The `ci` seam reds intermittently on main in the Go stage — `Go: go.work resolves both modules; build, vet, test, lint each` — with: ``` --- FAIL: TestConfigRepo_SlowApplyDoesNotEatTheGitBudget (0.50s) FAIL git.matou.nz/Matou/idss/internal/clan 35.892s ``` Seen on run https://git.matou.nz/Matou/idss/actions/runs/32679 (head `907a3006`, 2026-09-25 12:01 UTC). Filed by the swarm healer; classified **product**, so the healer made no code change. ## Why it is the test's margin, not the behaviour The #1760 fix is in place and correct: `internal/clan/configrepo.go:127` starts the commit sequence's budget with `context.WithTimeout(base, configRepoMutationTimeout)` **after** `apply` returns, so a cold-store download can no longer eat it. The test (`internal/clan/configrepo_coldstore_test.go:35`) shrinks `configRepoMutationTimeout` to **100 ms** and sleeps `3 * timeout` inside apply. That 100 ms then has to cover **four git subprocess spawns** plus a working-tree walk: - `firstConflictMarker()` — `filepath.WalkDir` over the tree (configrepo.go:135) - `git add -A` (configrepo.go:149) - `git status --porcelain` via `isClean` (configrepo.go:306) - `git commit -q -m …` (configrepo.go:160) - `git rev-parse HEAD` via `Head` (configrepo.go:166) Idle, that sequence is single-digit ms and the test passes with room. But the seam runs `go test ./...`, which runs up to `NumCPU` package binaries concurrently on the shared 8-core runner — process spawn + fs latency degrade far worse than CPU-bound work under that contention. The failing run took 0.50 s where a healthy run takes ~0.33 s (0.30 s of which is the deliberate sleep), i.e. the git tail took ~200 ms against a 100 ms budget. The same run's `internal/clan` package took 35.9 s vs 27.0 s on the idle host — the whole package was ~33 % slower. ## Reproduction attempts (healer, matou-workstation, same sha `907a3006`) - `go test ./internal/clan -run TestConfigRepo_SlowApplyDoesNotEatTheGitBudget -count=15` — pass - same, under 8 busy-loop CPU hogs — pass - 8 concurrent copies of the compiled test binary, `-test.count=12` each (96 runs) — pass - full `go test ./...` (the seam's Go stage) — **pass**, 53 s, `internal/clan` 27.0 s So it is not reproducible on an idle host and main is not persistently red; it is a load-sensitive flake that will keep reding the seam on a busy runner. ## What "done" looks like The test's claim (a slow apply must not consume the git budget) is worth keeping — only its wall-clock margin is unsafe. A fix should make the proof insensitive to runner load rather than just nudging the number, e.g. keep the apply sleep tied to the budget but give the budget enough headroom that a loaded 8-core box cannot blow it, or assert the decoupling structurally (observe when the commit budget's clock starts, rather than racing it). `internal/clan/configrepo_deadline_test.go` (which sets the budget to `time.Nanosecond`) is deterministic by construction and does not have this problem — a useful shape to borrow. Please also check the rest of the Go suite for the same pattern: any test that pins a production timeout to a short wall-clock value and then races real subprocesses under it is the same flake waiting to happen. ## Evidence - Run: https://git.matou.nz/Matou/idss/actions/runs/32679 (workflow `ci.yml`, job `seam`) - Healer incident signature `6e2243f659e0` — first occurrence in the healer ledger - Sandcastle worker logs for the run window show no worker fault (both workers found an empty ready queue and signalled COMPLETE); the fault is the seam's Go stage alone
Author
Member

swarm-claim host=matou-dev-server-01 run=32705
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=32705 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #1878 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 1878,
  "status": "success",
  "commits": [
    "ae02b277"
  ],
  "changed_files": [
    "STATUS.md",
    "internal/clan/configrepo.go",
    "internal/clan/configrepo_coldstore_test.go"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci -c go test ./internal/clan/ -run 'TestConfigRepo_SlowApplyDoesNotEatTheGitBudget|TestConfigRepo_TimedOutCommit' -count=5",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c go build ./... && go vet ./internal/clan/ && go test ./internal/clan/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Fix makes the proof insensitive to runner load rather than nudging the number": "internal/clan/configrepo_coldstore_test.go now keeps the production 2-minute configRepoMutationTimeout and races no git; it observes the commit budget's deadline at birth via the new configRepoOnCommitBudget seam and asserts budgetAtBirth > timeout-applyDelay — a comparison with no wall-clock race between subprocesses",
    "Assert the decoupling structurally (observe when the commit budget's clock starts)": "internal/clan/configrepo.go adds nil-in-production test seam configRepoOnCommitBudget, called the instant Mutate creates the commit context after apply; the test reads its Deadline() to prove the #1760 invariant that the clock starts AFTER apply",
    "Test's #1760 claim (a slow apply must not consume the git budget) is kept": "the test still exercises a 100ms download-dominated apply and asserts the operator write lands and the budget carries its full life; #1760 comment preserved",
    "Check the rest of the Go suite for the same pattern": "audit in commit message + STATUS.md: only configrepo_coldstore_test.go shrank a real production timeout and raced real subprocesses; phaseTimeout/installerBuildTimeout/cli_reap race test doubles or assert the timeout firing with generous slack; configrepo_deadline_test.go's nanosecond budget is deterministic by construction"
  },
  "summary": "Rewrote the config-repo cold-store proof to assert the #1760 budget-decoupling structurally (observe the commit budget at birth) instead of racing four real git spawns under a shrunk 100ms timeout, removing the load-sensitive ci flake.",
  "blockers": []
}
**close-report** for #1878 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 1878, "status": "success", "commits": [ "ae02b277" ], "changed_files": [ "STATUS.md", "internal/clan/configrepo.go", "internal/clan/configrepo_coldstore_test.go" ], "tests": [ { "command": "nix develop .#go-ci -c go test ./internal/clan/ -run 'TestConfigRepo_SlowApplyDoesNotEatTheGitBudget|TestConfigRepo_TimedOutCommit' -count=5", "exit_code": 0 }, { "command": "nix develop .#go-ci -c go build ./... && go vet ./internal/clan/ && go test ./internal/clan/", "exit_code": 0 }, { "command": "nix develop .#go-ci -c golangci-lint run ./internal/clan/", "exit_code": 0 } ], "criteria": { "Fix makes the proof insensitive to runner load rather than nudging the number": "internal/clan/configrepo_coldstore_test.go now keeps the production 2-minute configRepoMutationTimeout and races no git; it observes the commit budget's deadline at birth via the new configRepoOnCommitBudget seam and asserts budgetAtBirth > timeout-applyDelay — a comparison with no wall-clock race between subprocesses", "Assert the decoupling structurally (observe when the commit budget's clock starts)": "internal/clan/configrepo.go adds nil-in-production test seam configRepoOnCommitBudget, called the instant Mutate creates the commit context after apply; the test reads its Deadline() to prove the #1760 invariant that the clock starts AFTER apply", "Test's #1760 claim (a slow apply must not consume the git budget) is kept": "the test still exercises a 100ms download-dominated apply and asserts the operator write lands and the budget carries its full life; #1760 comment preserved", "Check the rest of the Go suite for the same pattern": "audit in commit message + STATUS.md: only configrepo_coldstore_test.go shrank a real production timeout and raced real subprocesses; phaseTimeout/installerBuildTimeout/cli_reap race test doubles or assert the timeout firing with generous slack; configrepo_deadline_test.go's nanosecond budget is deterministic by construction" }, "summary": "Rewrote the config-repo cold-store proof to assert the #1760 budget-decoupling structurally (observe the commit budget at birth) instead of racing four real git spawns under a shrunk 100ms timeout, removing the load-sensitive ci flake.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#1878
No description provided.