protected-path boundary: land 10d0a8b's wider runtime exemptions deferred by #280 (caches two-way; .env/secrets/*_token a posture call) #284

Open
opened 2026-10-17 06:36:55 +00:00 by matou-build-agent · 1 comment

Spun out of #280. The deadlock fix that landed on main (a4be7db) exempts the THREE gitignored runtime trees .sandcastle/.gitignore declares — .sandcastle/logs/*, .sandcastle/.state/*, .sandcastle/worktrees/* — plus the _pp_words word-split hardening. The stranded 10d0a8b (#272's superset) exempted a WIDER set that #280 deliberately did NOT fold in:

logs/ worktrees/ pnpm-store/ nix-store/ .state/ .env __pycache__/ secrets/*_token

Two distinct classes remain:

(a) Benign cache/runtime trees — two-way door, a session can land. .sandcastle/pnpm-store/*, .sandcastle/nix-store/*, __pycache__/* are gitignored runtime artifacts exactly like logs/state/worktrees; exempting them is the same low-risk class and TDD-able offline. Land these the same way (anchored under .sandcastle/, red-first test, same commit).

(b) .env and secrets/*_token — a protected-boundary POSTURE change, needs a human ruling (ADR 0174 one-way door). 10d0a8b's rationale: the runtime token files are rewritten mid-run by a Claude-account failover, so the boundary sees a false changed AND blob-copies live token bytes into two mktemp snapshot dirs per run (a secret-exposure surface). Exempting them FIXES that, but it also REMOVES .env/token files from what the boundary protects/rolls-back — a widening of what a worker could touch undetected. 10d0a8b split secrets/ deliberately: only secrets/*_token is exempt, the one tracked secrets/README.md stays machinery. A session that reaches (b) should escalate it ready-for-human per ADR 0174 rather than widen posture unilaterally. The token-failover false-positive + blob-copy leak is worth confirming as a real current hazard before deciding.

10d0a8b is on the rescue branch sandcastle/rescue-20261017-052212 and in git log for the exact diff.

Acceptance

  • (a) caches exempted, red-first test, machinery still caught; or a note why not.
  • (b) a human ruling recorded on whether .env/secrets/*_token are exempted from the #445 boundary, with the token-failover-leak evidence.

Ruled by agent under ADR 0174 (#280) — veto anytime.

Spun out of #280. The deadlock fix that landed on `main` (a4be7db) exempts the THREE gitignored runtime trees `.sandcastle/.gitignore` declares — `.sandcastle/logs/*`, `.sandcastle/.state/*`, `.sandcastle/worktrees/*` — plus the `_pp_words` word-split hardening. The stranded `10d0a8b` (#272's superset) exempted a WIDER set that #280 deliberately did NOT fold in: ``` logs/ worktrees/ pnpm-store/ nix-store/ .state/ .env __pycache__/ secrets/*_token ``` Two distinct classes remain: **(a) Benign cache/runtime trees — two-way door, a session can land.** `.sandcastle/pnpm-store/*`, `.sandcastle/nix-store/*`, `__pycache__/*` are gitignored runtime artifacts exactly like logs/state/worktrees; exempting them is the same low-risk class and TDD-able offline. Land these the same way (anchored under `.sandcastle/`, red-first test, same commit). **(b) `.env` and `secrets/*_token` — a protected-boundary POSTURE change, needs a human ruling (ADR 0174 one-way door).** `10d0a8b`'s rationale: the runtime token files are rewritten mid-run by a Claude-account failover, so the boundary sees a false `changed` AND blob-copies live token bytes into two mktemp snapshot dirs per run (a secret-exposure surface). Exempting them FIXES that, but it also REMOVES `.env`/token files from what the boundary protects/rolls-back — a widening of what a worker could touch undetected. `10d0a8b` split `secrets/` deliberately: only `secrets/*_token` is exempt, the one tracked `secrets/README.md` stays machinery. A session that reaches (b) should escalate it `ready-for-human` per ADR 0174 rather than widen posture unilaterally. The token-failover false-positive + blob-copy leak is worth confirming as a real current hazard before deciding. `10d0a8b` is on the rescue branch `sandcastle/rescue-20261017-052212` and in `git log` for the exact diff. ## Acceptance - (a) caches exempted, red-first test, machinery still caught; or a note why not. - (b) a human ruling recorded on whether `.env`/`secrets/*_token` are exempted from the #445 boundary, with the token-failover-leak evidence. Ruled by agent under ADR 0174 (#280) — veto anytime.
Author
Member

Ruled by agent under ADR 0174 — veto anytime.

(a) — DONE, landed on main (two-way door)

The benign gitignored cache trees under .sandcastle/ are now exempt from the #445 boundary, exactly the same low-risk runtime class as logs//.state//worktrees/ that #280 already folded in:

  • PP_EXEMPT_GLOBS_DEFAULT gained .sandcastle/pnpm-store/*, .sandcastle/nix-store/*, .sandcastle/__pycache__/* and the per-subpackage .sandcastle/*/__pycache__/* (swarm-db.py + the TUI) — all declared never-committed by .sandcastle/.gitignore, anchored under .sandcastle/ so a worker can't hide a machinery edit under an invented cache-looking dir.
  • Red-first, same commit (tests/protected-paths-lib-test.sh, 47 → 59 checks): each cache path is exempt (incl. a nested .sandcastle/tui/__pycache__/), .sandcastle/run-swarm.sh stays protected, and a run that churns all three caches alongside a real .sandcastle/evil.sh edit attributes/rolls back only the machinery edit.

Proof: full offline suite green — tests/ 89/89, onboarding/tests/ 0 fails, protected-paths-lib 59 checks, verify-lib 11 groups, docs-budget 4/4.
Commit: 14cf51f on main (d5c4a95..14cf51f), pre-push gate clean.
Root protected-paths-lib.sh only — INERT in the running .sandcastle/ self-copy and every consumer until a human re-vendors + bumps FACTORY_REF (GOTCHAS 4).

(b) — ready-for-human

Why human

Exempting .sandcastle/.env and .sandcastle/secrets/*_token from the #445 boundary is a protected-boundary posture change, not a benign-cache exemption: it removes host secrets from what the boundary protects and rolls back — a worker could then touch .sandcastle/.env (which injects env into every worker) or a token file undetected. That is a security-posture widening — a one-way door ADR 0174 reserves for a human ruling. A session must not make it unilaterally.

The hazard #272 cited is CONFIRMED real and current on main (so the fix is genuinely wanted — only the posture call is owed):

  1. verify_pp_snapshot "$PWD" (run-swarm.sh:402) fingerprints the whole .sandcastle/ tree before any worker runs. secrets/claude_oauth_token, secrets/forgejo_token and .env are not exempt today, so pp_snapshot blob-copies their live bytes into the VERIFY_PP_BEFORE mktemp -d dir.
  2. A Claude-account failover mid-run (_execute_failover → provision_write_claude_secret "$EXECUTE_SECRETS_DIR", with EXECUTE_SECRETS_DIR="$here" = the .sandcastle dir, run-swarm.sh:387) rewrites secrets/claude_oauth_token with the live standby-account token.
  3. verify_protected_paths then blob-copies it again into VERIFY_PP_AFTER, and pp_enforce sees changed → a false #445 red that parks HEAD on a sandcastle/rescue-* branch, and pp_rollback clobbers the live token with the dead/limited account's bytes (breaking the very failover the retry depends on).

Net current hazards: (i) a false-positive protected-path red on every failover run; (ii) rollback restoring a dead token; (iii) live token + .env bytes duplicated into two mktemp -d snapshot dirs per run — a secret-exposure surface.

The fix, when a human approves the posture: add .sandcastle/.env and .sandcastle/secrets/*_token to PP_EXEMPT_GLOBS_DEFAULT (the exact lines are in the stranded 10d0a8b). The one tracked file under secrets/, README.md, is not a *_token, so it stays machinery and a worker editing it is still caught — the split is deliberate and safe.

Decision owed from Ben: exempt .sandcastle/.env + .sandcastle/secrets/*_token from the #445 boundary (accepting that those host-secret files leave the rollback-protected set), yes/no? If yes, a follow-up session lands it root-only (red-first, same shape as (a)) and the coordinated re-vendor carries it live.

(Ruled by agent under ADR 0174 — veto anytime.)

**Ruled by agent under ADR 0174 — veto anytime.** ### (a) — DONE, landed on `main` (two-way door) The benign gitignored cache trees under `.sandcastle/` are now exempt from the #445 boundary, exactly the same low-risk runtime class as `logs/`/`.state/`/`worktrees/` that #280 already folded in: - `PP_EXEMPT_GLOBS_DEFAULT` gained `.sandcastle/pnpm-store/*`, `.sandcastle/nix-store/*`, `.sandcastle/__pycache__/*` and the per-subpackage `.sandcastle/*/__pycache__/*` (swarm-db.py + the TUI) — all declared never-committed by `.sandcastle/.gitignore`, **anchored** under `.sandcastle/` so a worker can't hide a machinery edit under an invented cache-looking dir. - **Red-first**, same commit (`tests/protected-paths-lib-test.sh`, 47 → 59 checks): each cache path is exempt (incl. a nested `.sandcastle/tui/__pycache__/`), `.sandcastle/run-swarm.sh` stays protected, and a run that churns all three caches **alongside** a real `.sandcastle/evil.sh` edit attributes/rolls back **only** the machinery edit. **Proof:** full offline suite green — `tests/` 89/89, `onboarding/tests/` 0 fails, `protected-paths-lib` 59 checks, `verify-lib` 11 groups, `docs-budget` 4/4. **Commit:** `14cf51f` on `main` (`d5c4a95..14cf51f`), pre-push gate clean. Root `protected-paths-lib.sh` only — **INERT** in the running `.sandcastle/` self-copy and every consumer until a human re-vendors + bumps `FACTORY_REF` (GOTCHAS 4). ### (b) — `ready-for-human` ## Why human Exempting `.sandcastle/.env` and `.sandcastle/secrets/*_token` from the #445 boundary is a **protected-boundary posture change**, not a benign-cache exemption: it **removes host secrets from what the boundary protects and rolls back** — a worker could then touch `.sandcastle/.env` (which injects env into every worker) or a token file undetected. That is a security-posture widening — a one-way door ADR 0174 reserves for a human ruling. A session must not make it unilaterally. **The hazard #272 cited is CONFIRMED real and current on `main`** (so the fix is genuinely wanted — only the posture call is owed): 1. `verify_pp_snapshot "$PWD"` (`run-swarm.sh:402`) fingerprints the whole `.sandcastle/` tree **before** any worker runs. `secrets/claude_oauth_token`, `secrets/forgejo_token` and `.env` are **not exempt today**, so `pp_snapshot` **blob-copies their live bytes** into the `VERIFY_PP_BEFORE` `mktemp -d` dir. 2. A Claude-account failover mid-run (`_execute_failover` → `provision_write_claude_secret "$EXECUTE_SECRETS_DIR"`, with `EXECUTE_SECRETS_DIR="$here"` = the `.sandcastle` dir, `run-swarm.sh:387`) **rewrites `secrets/claude_oauth_token`** with the live standby-account token. 3. `verify_protected_paths` then blob-copies it **again** into `VERIFY_PP_AFTER`, and `pp_enforce` sees `changed` → a **false #445 red** that parks HEAD on a `sandcastle/rescue-*` branch, **and** `pp_rollback` **clobbers the live token with the dead/limited account's bytes** (breaking the very failover the retry depends on). Net current hazards: (i) a false-positive protected-path red on every failover run; (ii) rollback restoring a dead token; (iii) live token + `.env` bytes duplicated into two `mktemp -d` snapshot dirs per run — a secret-exposure surface. **The fix, when a human approves the posture:** add `.sandcastle/.env` and `.sandcastle/secrets/*_token` to `PP_EXEMPT_GLOBS_DEFAULT` (the exact lines are in the stranded `10d0a8b`). The one **tracked** file under `secrets/`, `README.md`, is **not** a `*_token`, so it stays machinery and a worker editing it is still caught — the split is deliberate and safe. **Decision owed from Ben:** exempt `.sandcastle/.env` + `.sandcastle/secrets/*_token` from the #445 boundary (accepting that those host-secret files leave the rollback-protected set), yes/no? If yes, a follow-up session lands it root-only (red-first, same shape as (a)) and the coordinated re-vendor carries it live. *(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/dev-factory#284
No description provided.