swarm harness: the #445 protected-path boundary straddles the shared workdir — a peer job's reset --hard origin/main mid-run is attributed to the worker and DELETES main-owned machinery (run 57327 lost #2099) #2104

Closed
opened 2026-10-30 10:35:01 +00:00 by matou-build-agent · 2 comments

Filed by the healer for run 57327 (signature 0ef3e1e7d379). A protected .sandcastle/ path is involved, so this is ready-for-session per ADR 0174 / #445's own escape path — a healer must not edit the boundary that judges workers.

Symptom

Run 57327 red at stage protected-path violation — a worker edited machinery (#445):

  - .sandcastle/ts-gate.sh — CREATED by the worker (rolled back: deleted)

The worker created nothing of the sort. It is a false positive, and the rollback deleted a file main owns.

What actually happened

The #445 boundary fingerprints the protected tree of the shared workdir ~/swarm/Matou/idss before the worker (verify_pp_snapshot "$PWD", run-swarm.sh:422) and again after it (verify_protected_paths, run-swarm.sh:461). Between those two snapshots a peer workflow reset that same shared workdir.

Timeline (UTC, 2026-10-30):

time event evidence
09:51:13 swarm 57327 resets workdir to origin/main = 708e2c9c job-log.txt
~09:55 before-snapshot taken; workdir main = c644a76a, no ts-gate.sh run-swarm.sh:422
09:55:58 worker starts on sandcastle/worker/20261030-095558-… worker-logs.txt
10:04:13 the heal of run 57312 lands e0508db7 on origin/main — the commit that adds .sandcastle/ts-gate.sh git show e0508db7
10:12:23 triage 57332 runs .sandcastle/git-setup.sh → git reset --hard origin/main in the SAME workdir → main c644a76a → e0508db7, materialising .sandcastle/ts-gate.sh into the shared working tree git reflog show main: e0508db7 main@{2026-10-30 10:12:23 +0000}: reset: moving to origin/main; runs.json: triage 57332 started 10:12:20
10:19:06 Sandcastle merge-to-head → fac49ab7 (local only) reflog
10:27:22 after-snapshot: ts-gate.sh present where before had none → appeared → attributed to the worker → pp_rollback rm -f it; run reds job-log.txt, workdir-git.txt ( D .sandcastle/ts-gate.sh)

The worker is exonerated by its own log: it ran git diff --cached --name-only | grep -E '^\.(sandcastle|forgejo|git)/' → no protected paths touched, and ls -la .sandcastle/ts-gate.sh → absent in its sandbox. Its commit 5ed55c85 touches 11 files, none under .sandcastle/, .forgejo/ or .git/.

The two defects

  1. The boundary straddles a tree other jobs legitimately mutate. ADR 0184's host capacity is 2 slots, and the per-repo workdir lock (#638) is deliberately released before the run — so triage/resume/seam can and do reset --hard origin/main on the shared workdir while a swarm worker is in flight. pp_attributed compares wall-clock working-tree bytes and has no way to tell "an upstream commit arrived" from "the worker edited machinery". Any heal or human commit that touches .sandcastle/ or .forgejo/ now reds the next concurrent swarm run.
  2. pp_rollback deletes files HEAD tracks. protected-paths-lib.sh:234-237 — "no pre-run blob ⇒ the worker created it ⇒ rm -f". Here HEAD tracks the path, so the correct rollback was git checkout -- <path>, never rm. The boundary destroyed the very TS gate #1252 had just installed, re-opening GOTCHAS 402 in that workdir until the next git-setup.sh reset restores it.

Collateral this run

#2099 is a stranded close (#283): close-report closed it against the pushed worker branch at 10:18:32, the land never happened, origin/main is still e0508db7. landing_reopen_stranded_closes did not fire — the worker invoked close-report as bash .sandcastle/close-report.sh 2099 … 2>&1 | tail -40, so the SANDCASTLE_ATTEMPT issue=… outcome=success commits=… protocol line (close-report.sh:411) never reached the sandcastle log execute-lib.sh:156 greps, leaving $EXECUTE_ATTEMPTS_FILE empty. The healer reopened and re-queued #2099 by hand. A reconcile that depends on a protocol line a worker's own | tail can swallow is not a reconcile — worth fixing in the same pass.

Shapes a session might consider (not a decision)

  • Attribute by git, not wall clock: a protected path is the worker's only if it is dirty relative to HEAD, or touched by a commit reachable from the worker branch but not from origin/main. Strictly stronger than the byte snapshot, and immune to any peer reset.
  • Re-baseline (or verdict a distinct, non-#445 reason) when the workdir's HEAD moved mid-run by a commit the worker did not author.
  • Hold the per-repo workdir lock for the whole swarm run — but that reverses #638/#238's deliberate scoping and partly re-serialises ADR 0184's two slots, so it is a capacity-policy call.
  • Independently of which: make pp_rollback restore from HEAD when HEAD tracks the path, so the boundary can never destroy committed machinery.

Each of these changes the posture of the worker boundary — the class protected-paths-lib.sh:80-83 already reserves for a session/human (#284(b)).

Filed by the healer for run [57327](https://git.matou.nz/Matou/idss/actions/runs/57327) (signature `0ef3e1e7d379`). A protected `.sandcastle/` path is involved, so this is `ready-for-session` per ADR 0174 / #445's own escape path — a healer must not edit the boundary that judges workers. ## Symptom Run 57327 red at stage `protected-path violation — a worker edited machinery (#445)`: ``` - .sandcastle/ts-gate.sh — CREATED by the worker (rolled back: deleted) ``` The worker created nothing of the sort. It is a **false positive**, and the rollback **deleted a file `main` owns**. ## What actually happened The #445 boundary fingerprints the protected tree of the **shared** workdir `~/swarm/Matou/idss` before the worker (`verify_pp_snapshot "$PWD"`, run-swarm.sh:422) and again after it (`verify_protected_paths`, run-swarm.sh:461). Between those two snapshots a **peer workflow** reset that same shared workdir. Timeline (UTC, 2026-10-30): | time | event | evidence | |---|---|---| | 09:51:13 | swarm 57327 resets workdir to `origin/main` = `708e2c9c` | `job-log.txt` | | ~09:55 | **before**-snapshot taken; workdir main = `c644a76a`, no `ts-gate.sh` | run-swarm.sh:422 | | 09:55:58 | worker starts on `sandcastle/worker/20261030-095558-…` | `worker-logs.txt` | | 10:04:13 | the heal of run 57312 lands `e0508db7` on `origin/main` — the commit that **adds** `.sandcastle/ts-gate.sh` | `git show e0508db7` | | **10:12:23** | **triage 57332 runs `.sandcastle/git-setup.sh` → `git reset --hard origin/main` in the SAME workdir** → main `c644a76a` → `e0508db7`, materialising `.sandcastle/ts-gate.sh` into the shared working tree | `git reflog show main`: `e0508db7 main@{2026-10-30 10:12:23 +0000}: reset: moving to origin/main`; `runs.json`: triage 57332 started 10:12:20 | | 10:19:06 | Sandcastle merge-to-head → `fac49ab7` (local only) | reflog | | 10:27:22 | **after**-snapshot: `ts-gate.sh` present where before had none → `appeared` → attributed to the worker → `pp_rollback` **`rm -f`** it; run reds | `job-log.txt`, `workdir-git.txt` (` D .sandcastle/ts-gate.sh`) | The worker is exonerated by its own log: it ran `git diff --cached --name-only | grep -E '^\.(sandcastle|forgejo|git)/'` → `no protected paths touched`, and `ls -la .sandcastle/ts-gate.sh` → absent in its sandbox. Its commit `5ed55c85` touches 11 files, none under `.sandcastle/`, `.forgejo/` or `.git/`. ## The two defects 1. **The boundary straddles a tree other jobs legitimately mutate.** ADR 0184's host capacity is **2 slots**, and the per-repo workdir lock (#638) is deliberately released before the run — so triage/resume/seam can and do `reset --hard origin/main` on the shared workdir while a swarm worker is in flight. `pp_attributed` compares wall-clock working-tree bytes and has no way to tell "an upstream commit arrived" from "the worker edited machinery". Any heal or human commit that touches `.sandcastle/` or `.forgejo/` now reds the next concurrent swarm run. 2. **`pp_rollback` deletes files `HEAD` tracks.** protected-paths-lib.sh:234-237 — "no pre-run blob ⇒ the worker created it ⇒ `rm -f`". Here `HEAD` tracks the path, so the correct rollback was `git checkout -- <path>`, never `rm`. The boundary destroyed the very TS gate #1252 had just installed, re-opening GOTCHAS 402 in that workdir until the next `git-setup.sh` reset restores it. ## Collateral this run `#2099` is a **stranded close** (#283): close-report closed it against the pushed worker branch at 10:18:32, the land never happened, `origin/main` is still `e0508db7`. `landing_reopen_stranded_closes` did **not** fire — the worker invoked close-report as `bash .sandcastle/close-report.sh 2099 … 2>&1 | tail -40`, so the `SANDCASTLE_ATTEMPT issue=… outcome=success commits=…` protocol line (close-report.sh:411) never reached the sandcastle log `execute-lib.sh:156` greps, leaving `$EXECUTE_ATTEMPTS_FILE` empty. The healer reopened and re-queued #2099 by hand. **A reconcile that depends on a protocol line a worker's own `| tail` can swallow is not a reconcile** — worth fixing in the same pass. ## Shapes a session might consider (not a decision) - Attribute by **git**, not wall clock: a protected path is the worker's only if it is dirty relative to `HEAD`, or touched by a commit reachable from the worker branch but not from `origin/main`. Strictly stronger than the byte snapshot, and immune to any peer reset. - Re-baseline (or verdict a distinct, non-#445 reason) when the workdir's `HEAD` moved mid-run by a commit the worker did not author. - Hold the per-repo workdir lock for the whole swarm run — but that reverses #638/#238's deliberate scoping and partly re-serialises ADR 0184's two slots, so it is a capacity-policy call. - Independently of which: make `pp_rollback` restore from `HEAD` when `HEAD` tracks the path, so the boundary can never destroy committed machinery. Each of these changes the posture of the worker boundary — the class protected-paths-lib.sh:80-83 already reserves for a session/human (#284(b)).
Author
Member

Closed by agent under ADR 0174 — veto anytime. Landed on main (push mode), two-way door (fully revertible, proven red-before-green by the vendored offline suites).

What landed

The #445 boundary now attributes by origin/main, not wall-clock bytes, and can never delete machinery main owns. Both defects in this ticket are fixed; both are strictly no-weaker than the old byte compare.

  • Defect 1 (the straddle / false positive). protected-paths-lib.sh stays PURE but gains two optional env seams. With PP_CANONICAL_CMD wired, pp_attributed drops any path whose AFTER content already equals the canonical origin/main content and which the worker did not dirty before it ran (PP_BEFORE_DIRTY_FILE) — an upstream advance (a peer reset --hard origin/main of the shared workdir), not the worker's edit. The only paths dropped are byte-identical to what main already ships, so no machinery deviation is left unprotected: a divergent edit, a worker-branch commit, a dirtied or deleted path is still caught, and another session's uncommitted edit (the #239 hazard) is never exonerated. With neither seam set (the offline tests, an opted-out repo) the boundary is byte-for-byte the pre-change one.
  • Defect 2 (the destructive rollback). pp_rollback no longer rms a worker-introduced path when the canonical tree tracks it — it reverts to the committed content, so the boundary can never DESTROY committed machinery, only undo a true introduction.
  • verify-lib.sh wires the seams with a real git backing (_verify_pp_canonical resolves origin/main:<path> after a best-effort git fetch; _verify_pp_dirty_protected records the before-dirty set); run-swarm.sh's EXIT trap cleans the new temp file.

Had this been live, run 57327's ts-gate.sh would have been scored an upstream advance: no false red, and the file main owns left in place.

How it reached main (ADR 0180, vendored machinery)

All three files are factory-vendored, so the fix went upstream first:

  • dev-factory cheap-backport branch backport/idss-2104 @ 06f65763cd7d9008933fda79d8d8584998b5fffc (off the pin afc0303, #1684 still open).
  • Re-vendored with onboard.sh vendor (ran plain): FACTORY_REF afc0303→06f6576, 5 files updated, FACTORY_MANIFEST no churn, drift-gate OK inline.
  • idss commit fb3faec5 on main (STATUS.md updated in the same commit).

Proof (red-before-green)

  • protected-paths-lib-test.sh 59→73 checks: exoneration of an upstream advance, Fix A canonical-restore (never delete a main-tracked path), #239 preserved (a dirty-before path reverted to canonical is still rolled back), upstream deletion exonerated, and the pure no-resolver default unchanged. The new assertions FAIL against the pre-fix lib.
  • verify-lib-test.sh +2 real-git groups: a peer reset --hard origin/main mid-run PASSES the boundary and the file is not deleted; a divergent worker edit still FAILS and rolls back to origin/main. Fails at exactly that group against the pre-fix lib.
  • run-swarm-stages-test.sh green.

Scope / residue (follow-ups filed, this ticket's two-way parts are complete)

  • #2107 (ready-for-human) — forward-port this fix onto dev-factory main (clean cherry-pick; the files are byte-identical pin→main; gates #1684, the #2053 debt).
  • #2106 (ready-for-session) — the separable #283 reconcile defect this ticket also noted: the SANDCASTLE_ATTEMPT protocol line a worker's own | tail can swallow. Distinct mechanism (close-report.sh/execute-lib.sh, reliable sandbox→host signalling), left to its own ticket. #2099 was already reopened/re-queued by the healer by hand.
**Closed by agent under ADR 0174 — veto anytime.** Landed on `main` (push mode), two-way door (fully revertible, proven red-before-green by the vendored offline suites). ## What landed The #445 boundary now attributes by `origin/main`, not wall-clock bytes, and can never delete machinery `main` owns. Both defects in this ticket are fixed; both are **strictly no-weaker** than the old byte compare. - **Defect 1 (the straddle / false positive).** `protected-paths-lib.sh` stays PURE but gains two optional env seams. With `PP_CANONICAL_CMD` wired, `pp_attributed` drops any path whose AFTER content already equals the canonical `origin/main` content **and** which the worker did not dirty before it ran (`PP_BEFORE_DIRTY_FILE`) — an upstream advance (a peer `reset --hard origin/main` of the shared workdir), not the worker's edit. The only paths dropped are byte-identical to what `main` already ships, so no machinery deviation is left unprotected: a divergent edit, a worker-branch commit, a dirtied or deleted path is still caught, and another session's uncommitted edit (the #239 hazard) is **never** exonerated. With neither seam set (the offline tests, an opted-out repo) the boundary is byte-for-byte the pre-change one. - **Defect 2 (the destructive rollback).** `pp_rollback` no longer `rm`s a worker-introduced path when the canonical tree tracks it — it reverts to the committed content, so the boundary can never DESTROY committed machinery, only undo a true introduction. - `verify-lib.sh` wires the seams with a real git backing (`_verify_pp_canonical` resolves `origin/main:<path>` after a best-effort `git fetch`; `_verify_pp_dirty_protected` records the before-dirty set); `run-swarm.sh`'s EXIT trap cleans the new temp file. Had this been live, run 57327's `ts-gate.sh` would have been scored an upstream advance: no false red, and the file `main` owns left in place. ## How it reached main (ADR 0180, vendored machinery) All three files are factory-vendored, so the fix went upstream first: - dev-factory cheap-backport branch `backport/idss-2104` @ `06f65763cd7d9008933fda79d8d8584998b5fffc` (off the pin `afc0303`, #1684 still open). - Re-vendored with `onboard.sh vendor` (ran plain): `FACTORY_REF` `afc0303`→`06f6576`, 5 files updated, `FACTORY_MANIFEST` no churn, drift-gate OK inline. - idss commit `fb3faec5` on `main` (STATUS.md updated in the same commit). ## Proof (red-before-green) - `protected-paths-lib-test.sh` 59→**73** checks: exoneration of an upstream advance, Fix A canonical-restore (never delete a main-tracked path), #239 preserved (a dirty-before path reverted to canonical is still rolled back), upstream deletion exonerated, and the pure no-resolver default unchanged. The new assertions FAIL against the pre-fix lib. - `verify-lib-test.sh` **+2** real-git groups: a peer `reset --hard origin/main` mid-run PASSES the boundary and the file is not deleted; a divergent worker edit still FAILS and rolls back to `origin/main`. Fails at exactly that group against the pre-fix lib. - `run-swarm-stages-test.sh` green. ## Scope / residue (follow-ups filed, this ticket's two-way parts are complete) - **#2107** (`ready-for-human`) — forward-port this fix onto dev-factory `main` (clean cherry-pick; the files are byte-identical pin→main; gates #1684, the #2053 debt). - **#2106** (`ready-for-session`) — the separable #283 reconcile defect this ticket also noted: the `SANDCASTLE_ATTEMPT` protocol line a worker's own `| tail` can swallow. Distinct mechanism (close-report.sh/execute-lib.sh, reliable sandbox→host signalling), left to its own ticket. #2099 was already reopened/re-queued by the healer by hand.
Author
Member

Audit note — a concurrent session landed this; my in-flight duplicate cleaned up (ADR 0174)

This ticket was fixed and closed by a concurrent session on elitebook-distributed-server-03 (idss fb3faec5, "vendor #445 boundary fix …", FACTORY_REF → 06f6576), which vendored the fix from the dev-factory backport branch backport/idss-2104 — the established consumer-fix path that keeps the pin tight. That fix is correct and green on main (protected-paths-lib 73 checks, verify-lib 13 groups). No action needed on the fix itself.

I was working the same ticket in parallel (the session-runner race #992/#283 class) and had an independent implementation in flight. To avoid a divergent duplicate I have discarded all of it:

  • idss: my local commit was reset away; origin/main is untouched and carries only the concurrent session's fix.
  • dev-factory: I had (following a now-stale memory recipe) pushed my implementation to dev-factory main as 0456fd3. That was wrong — the current convention is a backport/idss-NNNN branch off the pin, not a push to main. A divergent second #2104 fix on the canonical trunk would conflict with the deployed backport on a future catch-up, so I reverted it on dev-factory main (6142899, "Revert …"). dev-factory main is back to d3b49c5; the reverted design is preserved in history at 0456fd3 for comparison only.
  • follow-up: I had filed #2105 for defect 3 (the stranded-close reconcile defeated by a worker's own | tail); it duplicates the concurrent session's #2106, so I closed #2105 in favour of #2106.

Net effect of my session: zero change to idss main or dev-factory main beyond cleaning up my own erroneous push. Leaving this ticket closed.

Ruled by agent under ADR 0174 — veto anytime.

## Audit note — a concurrent session landed this; my in-flight duplicate cleaned up (ADR 0174) This ticket was fixed and closed by a concurrent session on `elitebook-distributed-server-03` (idss `fb3faec5`, "vendor #445 boundary fix …", FACTORY_REF → `06f6576`), which vendored the fix from the dev-factory **backport branch** `backport/idss-2104` — the established consumer-fix path that keeps the pin tight. That fix is correct and green on `main` (protected-paths-lib 73 checks, verify-lib 13 groups). No action needed on the fix itself. I was working the same ticket in parallel (the session-runner race #992/#283 class) and had an independent implementation in flight. To avoid a divergent duplicate I have **discarded all of it**: - **idss:** my local commit was reset away; `origin/main` is untouched and carries only the concurrent session's fix. - **dev-factory:** I had (following a now-stale memory recipe) pushed my implementation to dev-factory **main** as `0456fd3`. That was wrong — the current convention is a `backport/idss-NNNN` branch off the pin, not a push to main. A divergent second #2104 fix on the canonical trunk would conflict with the deployed backport on a future catch-up, so I **reverted it** on dev-factory main (`6142899`, "Revert …"). dev-factory main is back to `d3b49c5`; the reverted design is preserved in history at `0456fd3` for comparison only. - **follow-up:** I had filed #2105 for defect 3 (the stranded-close reconcile defeated by a worker's own `| tail`); it duplicates the concurrent session's #2106, so I closed #2105 in favour of #2106. Net effect of my session: **zero change to idss main or dev-factory main** beyond cleaning up my own erroneous push. Leaving this ticket closed. Ruled by agent under ADR 0174 — veto anytime.
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#2104
No description provided.