rehearsal: an untracked file wedges the cycle's sync gate — the drive rides a STALE checkout and re-fires already-healed reds (drive 20260825T022044Z) #766

Closed
opened 2026-08-25 02:36:10 +00:00 by matou-build-agent · 2 comments

Failure

The droplet drive 20260825T022044Z went red on leg invite-member with:

member landed cleanly on /settings/admin (HTTP 403, url "https://files.rehearsal-b.idss.nz/settings/admin") with no redirect and no access-denied marker — a plain member must never reach the admin screen (DDR 0173 story 11, story 4)

There is no product defect and no live harness defect. That assertion was already fixed on origin/main before the drive started. The drive ran ~51-minute-stale code.

Evidence

  1. The red is the PRE-heal assertion. test-results/drive-droplet/20260825T022044Z/report/data/ac26d1e03d…md quotes the throwing source at provision.ts:875 with the old wording "with no redirect and no access-denied marker" and the old two-signal check (redirectedAway/deniedCount only, status interpolated but never gated).
    HEAD's app/tests/e2e/fixtures/provision.ts:871-905 is readMemberAdminDenial — 403 is a first-class denial — and its failure text reads "with no 403, no redirect and no access-denied marker". The strings do not match, so the drive did not run HEAD.

  2. The heal predates the drive. a9bc6b5d ("sandcastle: #765 — assertMemberIsNotAdmin gates on 403") authored 2026-08-25 02:19:12. The drive's artifacts/verdict.json has startedAt: 2026-08-25T02:21:50Z.

  3. The drive checkout never synced. git -C /home/dev/swarm/Matou/idss reflog — last reset --hard origin/main at 2026-08-25 01:29:28, landing on c9d0c61c. No entry after it. c9d0c61c is a9bc6b5d's parent.

  4. The sync gate is the cause. scripts/rehearsal-cycle.sh:157:

    if [ -z "$(git status --porcelain)" ] && [ "$(git branch --show-current)" = "main" ]; then
    

    git status --porcelain (no -uno) counts untracked files as dirt. The drive checkout carries two untracked strays:

    • .sandcastle/.env.bak-20260822T113103Z (mtime Aug 22 — written by the harness's own token-sync path, not a human's work-in-flight)
    • docs/adr/0194-host-baseline-is-a-property-of-the-host-shape-not-the-install-mode.md

    So the gate takes the else branch every tick. /home/dev/swarm/rehearsal-executor.log shows the flip: the last twelve ==> rehearsal cycle: syncing main lines are followed by nine consecutive ==> rehearsal cycle: tree dirty or not on main — driving as-is (no sync).

  5. Only the reporter rescues the checkout. .sandcastle/rehearsal-report.sh:165 (git -C "$co" reset -q --hard origin/main) is the ONLY thing still advancing that checkout — every reflog entry above is its. It runs post-drive, so any commit landing between one report and the next drive is invisible to the drive. That is exactly the 01:29→02:21 window a9bc6b5d fell into.

  6. Nothing in the run records what SHA was driven. artifacts/verdict.json, artifacts/host.json and logs/claude-env.txt carry no commit SHA — grepped, zero hits. This is why a stale-code red is indistinguishable from a live red without reflog forensics, and why the healer loop can burn a paid droplet re-firing a defect that main already fixed.

The rest of the drive was healthy: 24 green, 1 skip (backup-honest-floor, planned), 1 red.

Suspected layer

Harness orchestration — the rehearsal cycle's pre-drive checkout sync. Not the product, not the e2e assertion (already healed at a9bc6b5d).

What plugging it needs

Primary — scripts/rehearsal-cycle.sh:157-162. The gate's stated intent (line 153-156) is "a dirty tree or a non-main branch means someone else's work is in flight — drive the tree as it stands rather than yanking it". Untracked files are not in-flight work that a sync can yank: git pull --ff-only never touches them. Gate on tracked dirt only:

if [ -z "$(git status --porcelain --untracked-files=no)" ] && [ "$(git branch --show-current)" = "main" ]; then

This opens ONE new failure mode that must be handled in the same change: git pull --ff-only aborts ("untracked working tree files would be overwritten") when an incoming commit claims a path that exists untracked in the worktree — and under set -euo pipefail (line 27) that kills the cycle before it drives at all. So the pull must be non-fatal, falling through to the as-is path with a loud note rather than exiting:

if git fetch origin && git pull --ff-only origin main; then
  echo "==> rehearsal cycle: synced main"
else
  echo "==> rehearsal cycle: WARN sync refused (untracked path collision?) — driving as-is; THE DRIVE MAY BE STALE"
fi

This is a live hazard, not hypothetical: docs/adr/0194-host-baseline-…md sits untracked at a path a future ADR commit could claim.

Factor the gate decision into a pure function in scripts/lib/ (a rehearsal_should_sync <tracked-porcelain> <branch> shape) with an offline test in scripts/tests/ — that is the established convention for this layer (scripts/lib/rehearsal-queue-lib.sh + scripts/tests/rehearsal-queue-test.sh), and it makes the gate regressible without a droplet.

Secondary — record the driven SHA. Write git rev-parse HEAD (and whether the sync succeeded) into artifacts/verdict.json at drive start, so a red carries the code it actually ran. Point 6 above shows the current evidence bundle cannot answer "was this a live defect or stale code?" at all — which is what makes this failure mode expensive rather than merely annoying.

Operational, outside this repo (do NOT do it from a swarm worker): the two stray files in /home/dev/swarm/Matou/idss are what tripped the gate. .sandcastle/.env.bak-20260822T113103Z looks like harness litter and should be swept or gitignored at its source; the untracked ADR is someone's draft and is not the swarm's to delete. Note that with the primary fix in place neither file wedges the sync any more, so this is hygiene, not the plug.

Note for whoever re-drives: invite-member needs no product change. Once the drive checkout reaches a9bc6b5d or later, that leg should green — HEAD's pnpm --filter app exec vitest run tests/e2e/fixtures/provision.test.ts passes 13/13 on this machine.

Related: a9bc6b5d's own commit message flags a neighbouring hazard in the same family — a healer reporting action=healed with a SHA no ref carries silently reconverts a diagnosed red into a repeating one — as a candidate docs/GOTCHAS.md entry. This ticket is the second instance of the same class (a heal that exists but does not reach the drive), and both deserve one GOTCHAS entry: a green heal is not a landed heal until the drive checkout provably carries it.

drive 20260825T022044Z red at invite-member: member landed cleanly on /settings/admin (HTTP 403, url "https://files.rehearsal-b.idss.nz/settings/admin") with no redirect and no access-denied marker — a plain member must never reach the admin s
evidence: test-results/…/20260825T022044Z/ on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596)

## Failure The droplet drive `20260825T022044Z` went red on leg `invite-member` with: > member landed cleanly on /settings/admin (HTTP 403, url "https://files.rehearsal-b.idss.nz/settings/admin") with no redirect and no access-denied marker — a plain member must never reach the admin screen (DDR 0173 story 11, story 4) **There is no product defect and no live harness defect.** That assertion was already fixed on `origin/main` before the drive started. The drive ran ~51-minute-stale code. ## Evidence 1. **The red is the PRE-heal assertion.** `test-results/drive-droplet/20260825T022044Z/report/data/ac26d1e03d…md` quotes the throwing source at `provision.ts:875` with the old wording `"with no redirect and no access-denied marker"` and the old two-signal check (`redirectedAway`/`deniedCount` only, status interpolated but never gated). HEAD's `app/tests/e2e/fixtures/provision.ts:871-905` is `readMemberAdminDenial` — 403 is a first-class denial — and its failure text reads `"with no 403, no redirect and no access-denied marker"`. The strings do not match, so the drive did not run HEAD. 2. **The heal predates the drive.** `a9bc6b5d` ("sandcastle: #765 — assertMemberIsNotAdmin gates on 403") authored `2026-08-25 02:19:12`. The drive's `artifacts/verdict.json` has `startedAt: 2026-08-25T02:21:50Z`. 3. **The drive checkout never synced.** `git -C /home/dev/swarm/Matou/idss reflog` — last `reset --hard origin/main` at `2026-08-25 01:29:28`, landing on `c9d0c61c`. No entry after it. `c9d0c61c` is `a9bc6b5d`'s parent. 4. **The sync gate is the cause.** `scripts/rehearsal-cycle.sh:157`: ```sh if [ -z "$(git status --porcelain)" ] && [ "$(git branch --show-current)" = "main" ]; then ``` `git status --porcelain` (no `-uno`) counts **untracked** files as dirt. The drive checkout carries two untracked strays: - `.sandcastle/.env.bak-20260822T113103Z` (mtime Aug 22 — written by the harness's own token-sync path, not a human's work-in-flight) - `docs/adr/0194-host-baseline-is-a-property-of-the-host-shape-not-the-install-mode.md` So the gate takes the else branch every tick. `/home/dev/swarm/rehearsal-executor.log` shows the flip: the last twelve `==> rehearsal cycle: syncing main` lines are followed by nine consecutive `==> rehearsal cycle: tree dirty or not on main — driving as-is (no sync)`. 5. **Only the reporter rescues the checkout.** `.sandcastle/rehearsal-report.sh:165` (`git -C "$co" reset -q --hard origin/main`) is the ONLY thing still advancing that checkout — every reflog entry above is its. It runs post-drive, so any commit landing between one report and the next drive is invisible to the drive. That is exactly the 01:29→02:21 window `a9bc6b5d` fell into. 6. **Nothing in the run records what SHA was driven.** `artifacts/verdict.json`, `artifacts/host.json` and `logs/claude-env.txt` carry no commit SHA — grepped, zero hits. This is why a stale-code red is indistinguishable from a live red without reflog forensics, and why the healer loop can burn a paid droplet re-firing a defect that main already fixed. The rest of the drive was healthy: 24 green, 1 skip (`backup-honest-floor`, planned), 1 red. ## Suspected layer Harness orchestration — the rehearsal cycle's pre-drive checkout sync. Not the product, not the e2e assertion (already healed at `a9bc6b5d`). ## What plugging it needs **Primary — `scripts/rehearsal-cycle.sh:157-162`.** The gate's stated intent (line 153-156) is "a dirty tree or a non-main branch means someone else's work is in flight — drive the tree as it stands rather than yanking it". Untracked files are not in-flight work that a sync can yank: `git pull --ff-only` never touches them. Gate on **tracked** dirt only: ```sh if [ -z "$(git status --porcelain --untracked-files=no)" ] && [ "$(git branch --show-current)" = "main" ]; then ``` This opens ONE new failure mode that must be handled in the same change: `git pull --ff-only` aborts ("untracked working tree files would be overwritten") when an incoming commit claims a path that exists untracked in the worktree — and under `set -euo pipefail` (line 27) that kills the cycle before it drives at all. So the pull must be non-fatal, falling through to the as-is path with a loud note rather than exiting: ```sh if git fetch origin && git pull --ff-only origin main; then echo "==> rehearsal cycle: synced main" else echo "==> rehearsal cycle: WARN sync refused (untracked path collision?) — driving as-is; THE DRIVE MAY BE STALE" fi ``` This is a live hazard, not hypothetical: `docs/adr/0194-host-baseline-…md` sits untracked at a path a future ADR commit could claim. Factor the gate decision into a pure function in `scripts/lib/` (a `rehearsal_should_sync <tracked-porcelain> <branch>` shape) with an offline test in `scripts/tests/` — that is the established convention for this layer (`scripts/lib/rehearsal-queue-lib.sh` + `scripts/tests/rehearsal-queue-test.sh`), and it makes the gate regressible without a droplet. **Secondary — record the driven SHA.** Write `git rev-parse HEAD` (and whether the sync succeeded) into `artifacts/verdict.json` at drive start, so a red carries the code it actually ran. Point 6 above shows the current evidence bundle cannot answer "was this a live defect or stale code?" at all — which is what makes this failure mode expensive rather than merely annoying. **Operational, outside this repo (do NOT do it from a swarm worker):** the two stray files in `/home/dev/swarm/Matou/idss` are what tripped the gate. `.sandcastle/.env.bak-20260822T113103Z` looks like harness litter and should be swept or gitignored at its source; the untracked ADR is someone's draft and is not the swarm's to delete. Note that with the primary fix in place neither file wedges the sync any more, so this is hygiene, not the plug. **Note for whoever re-drives:** `invite-member` needs no product change. Once the drive checkout reaches `a9bc6b5d` or later, that leg should green — HEAD's `pnpm --filter app exec vitest run tests/e2e/fixtures/provision.test.ts` passes 13/13 on this machine. Related: `a9bc6b5d`'s own commit message flags a neighbouring hazard in the same family — a healer reporting `action=healed` with a SHA no ref carries silently reconverts a diagnosed red into a repeating one — as a candidate `docs/GOTCHAS.md` entry. This ticket is the second instance of the same class (a heal that exists but does not reach the drive), and both deserve one GOTCHAS entry: **a green heal is not a landed heal until the drive checkout provably carries it.** drive `20260825T022044Z` red at `invite-member`: `member landed cleanly on /settings/admin (HTTP 403, url "https://files.rehearsal-b.idss.nz/settings/admin") with no redirect and no access-denied marker — a plain member must never reach the admin s` evidence: `test-results/…/20260825T022044Z/` on matou-workstation (legs.json, droplet-journal.txt, trace) — a representative screenshot is attached here if one was captured (#596) <!-- rehearsal-sig: 1dc3e7a84786 -->
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=9984
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=9984 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #766 — status success

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

envelope
{
  "issue": 766,
  "status": "success",
  "commits": [
    "56ea196"
  ],
  "changed_files": [
    "scripts/rehearsal-cycle.sh",
    "scripts/lib/rehearsal-sync-lib.sh",
    "scripts/tests/rehearsal-sync-test.sh",
    "app/tests/e2e/fixtures/legs.ts",
    "app/tests/e2e/fixtures/legs.test.ts",
    "app/tests/e2e/journey.droplet.spec.ts",
    "app/tests/e2e/journey.selfhosted.spec.ts",
    "app/tests/e2e/journey.rented.spec.ts",
    "docs/agents/e2e-driver-contract.md",
    "docs/GOTCHAS.md"
  ],
  "tests": [
    {
      "command": "bash scripts/tests/rehearsal-sync-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh",
      "exit_code": 0
    },
    {
      "command": "CI=true pnpm --filter app exec vitest run tests/e2e/fixtures/",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Primary: sync gate counts tracked dirt only, not untracked strays": "scripts/rehearsal-cycle.sh:165 runs `git status --porcelain --untracked-files=no` via rehearsal_should_sync; scripts/lib/rehearsal-sync-lib.sh is the pure gate; scripts/tests/rehearsal-sync-test.sh checks 1-5 prove it (6/6 pass)",
    "Primary: the pull is non-fatal so an untracked-path collision cannot kill the cycle under set -e": "scripts/rehearsal-cycle.sh:173-177 runs the sync inside an `if` with a `THE DRIVE MAY BE STALE` warn on the else branch; test check 6 pins it",
    "Primary: gate factored into scripts/lib with an offline test (established convention)": "scripts/lib/rehearsal-sync-lib.sh + scripts/tests/rehearsal-sync-test.sh, mirroring rehearsal-queue-lib.sh + rehearsal-queue-test.sh",
    "Secondary: the run records the driven SHA so a red carries the code it ran": "VerdictJson.commit + driveCommit() in app/tests/e2e/fixtures/legs.ts; the three journey specs capture it at drive start and pass it to computeVerdict; legs.test.ts asserts it (14/14); e2e-driver-contract.md clause 5 documents it",
    "GOTCHAS entry for the class (a green heal is not a landed heal)": "docs/GOTCHAS.md #82"
  },
  "summary": "The rehearsal cycle's pre-drive sync gate now counts tracked dirt only and its pull is non-fatal, so an untracked stray no longer wedges the drive onto a stale checkout; verdict.json now stamps the driven SHA.",
  "reason": "",
  "blockers": [],
  "no_code_change": ""
}
**close-report** for #766 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 766, "status": "success", "commits": [ "56ea196" ], "changed_files": [ "scripts/rehearsal-cycle.sh", "scripts/lib/rehearsal-sync-lib.sh", "scripts/tests/rehearsal-sync-test.sh", "app/tests/e2e/fixtures/legs.ts", "app/tests/e2e/fixtures/legs.test.ts", "app/tests/e2e/journey.droplet.spec.ts", "app/tests/e2e/journey.selfhosted.spec.ts", "app/tests/e2e/journey.rented.spec.ts", "docs/agents/e2e-driver-contract.md", "docs/GOTCHAS.md" ], "tests": [ { "command": "bash scripts/tests/rehearsal-sync-test.sh", "exit_code": 0 }, { "command": "bash scripts/tests/rehearsal-drive-exclusive-test.sh", "exit_code": 0 }, { "command": "CI=true pnpm --filter app exec vitest run tests/e2e/fixtures/", "exit_code": 0 } ], "criteria": { "Primary: sync gate counts tracked dirt only, not untracked strays": "scripts/rehearsal-cycle.sh:165 runs `git status --porcelain --untracked-files=no` via rehearsal_should_sync; scripts/lib/rehearsal-sync-lib.sh is the pure gate; scripts/tests/rehearsal-sync-test.sh checks 1-5 prove it (6/6 pass)", "Primary: the pull is non-fatal so an untracked-path collision cannot kill the cycle under set -e": "scripts/rehearsal-cycle.sh:173-177 runs the sync inside an `if` with a `THE DRIVE MAY BE STALE` warn on the else branch; test check 6 pins it", "Primary: gate factored into scripts/lib with an offline test (established convention)": "scripts/lib/rehearsal-sync-lib.sh + scripts/tests/rehearsal-sync-test.sh, mirroring rehearsal-queue-lib.sh + rehearsal-queue-test.sh", "Secondary: the run records the driven SHA so a red carries the code it ran": "VerdictJson.commit + driveCommit() in app/tests/e2e/fixtures/legs.ts; the three journey specs capture it at drive start and pass it to computeVerdict; legs.test.ts asserts it (14/14); e2e-driver-contract.md clause 5 documents it", "GOTCHAS entry for the class (a green heal is not a landed heal)": "docs/GOTCHAS.md #82" }, "summary": "The rehearsal cycle's pre-drive sync gate now counts tracked dirt only and its pull is non-fatal, so an untracked stray no longer wedges the drive onto a stale checkout; verdict.json now stamps the driven SHA.", "reason": "", "blockers": [], "no_code_change": "" } ``` </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.

Reference
Matou/idss#766
No description provided.