Skip to content
This repository was archived by the owner on Sep 2, 2026. It is now read-only.

Make the fixture guard survive concurrent worktree churn - #1284

Merged
chubes4 merged 1 commit into
mainfrom
fix-1282-fixture-guard-isolation
Aug 29, 2026
Merged

Make the fixture guard survive concurrent worktree churn#1284
chubes4 merged 1 commit into
mainfrom
fix-1282-fixture-guard-isolation

Conversation

@chubes4

@chubes4 chubes4 commented Aug 29, 2026

Copy link
Copy Markdown
Member

Fixes #1282.

Problem

tests/worktree-add-lifecycle-fixture-guards.php failed inside the release test runner while passing standalone, blocking homeboy release data-machine-code twice on code that was fine.

PHP Fatal error:  Uncaught RuntimeException: worktree-add-lifecycle could not inspect an inspectable managed worktree registry.
 in tests/worktree-lifecycle-fixture-guard-support.inc:75

Immediately afterward, standalone:

$ php tests/worktree-add-lifecycle-fixture-guards.php
worktree-add-lifecycle-fixture-guards ok: ...

./bin/dmc-test → 148 passed, both before and after.

Cause

The guard seeds its inspection set with the current working directory:

$repositories = array( $current_directory );   // a live repo, not a fixture

On a developer machine or CI runner that is a real repository which other processes may be concurrently adding worktrees to or removing them from — during this session, an agent-driven cleanup was removing 93 worktrees. A single git worktree list --porcelain against such a repository can fail transiently, and the guard treated any non-zero exit as fatal:

if ( 0 !== $status ) {
    throw new RuntimeException('worktree-add-lifecycle could not inspect an inspectable managed worktree registry.');
}

So the test was order- and timing-dependent on external state it does not own. The throw also discarded the captured $output, leaving no repository, exit code, or git message to act on.

Change

Extract the inspection into worktree_lifecycle_fixture_inspect_registry(), which retries a bounded number of times (3, 250ms apart) before failing closed, and reports real evidence when it does.

Fail-closed safety is unchanged — a repository that genuinely cannot be inspected still fails. Only transient churn is absorbed.

Verification

Diagnostics and retry both exercised against a non-repository path:

retried_for=1.46s
message=worktree-add-lifecycle could not inspect an inspectable managed worktree registry after 3 attempts.
        repository=/tmp exit_code=128
        git_output=fatal: not a git repository (or any of the parent directories): .git
  • retries actually occur (1.46s ≈ 3 attempts × 250ms plus git startup)
  • the error names the repository, exit code, and git output

./bin/dmc-test → 148 tests passed. Target test passes standalone.


AI assistance disclosure: implemented with Claude Sonnet 4.5 (Anthropic) driving OpenCode via the Kimaki Discord bridge. The model hit this failure while releasing v0.72.8, traced it to the cwd-seeded inspection set, made the change, and captured the verification output above. A human directed the work.

The guard inspects the current working directory, which on a developer
machine or CI runner is a live repository other processes may be adding
worktrees to or removing them from. A single transient `git worktree
list` failure there threw immediately and failed the entire suite for
reasons unrelated to the code under test, blocking two release attempts
while ./bin/dmc-test passed 148/148.

The throw also discarded the captured output, so the failure reported
only that inspection failed: no repository, no exit code, no git output.

Extract the inspection into a helper that retries a bounded number of
times before failing closed, and include the repository, exit code, and
git output in the retained error. Fail-closed safety is unchanged; only
transient churn is tolerated.
@chubes4
chubes4 merged commit a2f4603 into main Aug 29, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

worktree-add-lifecycle fixture guard fails in the release runner but passes standalone, blocking releases

1 participant