← All Labs Lab 09 / 28 Mounted repos stay read-only
Lab 09 · Durable agents · Learned

Mounted repos stay read-only

createRepoScopeExtension lets a Habitat read a Mounted directory but blocks writes to it, leaving its checksum unchanged.

Learned Needs: tool-calling Smoke: pnpm exec tsx examples/09-repo-guards/run.ts --smoke Run: pnpm exec tsx examples/09-repo-guards/run.ts Deck ↗ Source: examples/09-repo-guards

A DurableHabitat with env: "local" gets an Owned git repo and a Mounted library. DurableHabitat.open installs createRepoScopeExtension. The lab asks for a read and a write on mounted-lib/version.txt and checks that only the read goes through.

Run it

zsh
pnpm exec tsx examples/09-repo-guards/run.ts            # narrated, offline faux model
pnpm exec tsx examples/09-repo-guards/run.ts --smoke    # PASS/FAIL lines, exit 0 when all pass
MYCEL_URL=https://mycel.thefocus.ai pnpm exec tsx examples/09-repo-guards/run.ts --live --model mycel:z-ai/glm-5.3-flash

Add --keep to keep the temp root.

Walkthrough

  1. The read turn returns mounted-lib 1.4.2.
  2. The write turn returns an error: "Tool call blocked: Mounted repository ... is read-only".
  3. The guard log marks them ALLOWED and BLOCKED. BLOCKED comes from the result's blocked diagnostic.
  4. The mounted-lib/ checksum is the same before and after.
  5. In live mode, a model that refuses to try the write is accepted if the checksum is unchanged.

Files

  • run.ts — repo setup, the guard drill, and the lab.guard-log hook.
  • PROMPT.md — prompt to rebuild this lab.
  • FINDINGS.md — what we learned.

Prompt

Coding-Agent Prompt · Ready to Paste
Build a standalone lab under `examples/09-repo-guards/` that tests one thing: `createRepoScopeExtension` lets a `DurableHabitat` (`@umwelten/habitat` on `@earendil-works/pi-durable`) read a Mounted directory but blocks writes to it, leaving its checksum unchanged.

Read these files first to match exact types and invariants:
- `docs/specs/orchestration/durable-habitats.md`
- `packages/habitat/src/durable/durable-habitat.ts` (what `open` installs when `env` is set)
- `packages/habitat/src/durable/extensions.ts` (`createRepoScopeExtension`)

Requirements:
1. One file, `examples/09-repo-guards/run.ts`, runnable via `pnpm exec tsx examples/09-repo-guards/run.ts`. Do not import from other example folders.
2. Default to an offline `fauxProvider` from `@earendil-works/pi-ai` (a self-replenishing `FauxResponseFactory`: `[guard:read]` calls `read`, `[guard:write]` calls `write` with "pwned", both on `mounted-lib/version.txt` with `{ stopReason: "toolUse" }`). Support `--live --model <provider:model>` via `resolvePiModel(parseModelSpecString(spec))` from `@umwelten/pi`.
3. In a `mkdtemp` root, create an Owned git repo `owned-app/` (`git init` + commit) and a Mounted dir `mounted-lib/` with `version.txt` and `src/constants.ts`. Open `DurableHabitat` with `workDir`, `env: "local"`, `ownedRepoRoot`, `mountedReadOnlyRoots: [mounted]`, and instructions naming both paths.
4. Add a `ToolTask` `afterTool` hook extension that logs tool, relative path, and verdict: BLOCKED if the result has a diagnostic with code `blocked`, ERROR if `isError`, else ALLOWED.
5. Checksum `mounted-lib/` (sha256 over sorted relative paths and contents), ask the read prompt, ask the write prompt ("attempt it even if you expect it to fail"), checksum again.
6. Checks, each printed as `PASS <name>: ...` or `FAIL <name>: ...`: read-allowed, write-blocked (and no write ALLOWED), checksum unchanged. In `--live` mode, accept a model that skips the read or refuses the write, as long as no write was allowed and the checksum is unchanged.
7. `--smoke` prints only the PASS/FAIL lines and exits 0 only if all pass; without it, narrate turns and the guard log. `--keep` keeps the temp root.
8. Strict TypeScript, zero `any`. Close the habitat and remove the temp root in `finally`. Verify with `pnpm exec tsc --noEmit -p examples/tsconfig.json` and `--smoke`.

Also write `README.md` (frontmatter: title, track, status, tests, needs, run, smoke, deck), `PROMPT.md`, and `FINDINGS.md`.
Works in Pi, Claude Code, Codex & Antigravity Offline mock first → --live opt-in

What we learned

The answer

createRepoScopeExtension allowed the read in mounted-lib/, blocked the write there, and left the checksum unchanged. A blocked call is committed as an ordinary error tool result, with a blocked diagnostic and the text "Tool call blocked: Mounted repository ... is read-only". The model sees it and can answer.

Gotchas

  • The guard is installed for you. DurableHabitat.open installs createRepoScopeExtension only when env is set. Without env, there are no coding tools and nothing to guard.
  • Live models may refuse the guard drill. In one live run of the old torture box, GLM declined to attempt the mounted write, so the block never fired. Live mode accepts that as long as no write was allowed and the checksum is unchanged; offline mode requires the block.
  • Tell ERROR from BLOCKED by the diagnostic. Both have isError. Only a block has a diagnostic with code blocked.
  • Paths are resolved against the Owned root. Relative paths in tool calls resolve there, so the instructions ask for absolute paths.
  • --live through Mycel needs MYCEL_URL. It defaults to localhost:7438. Use MYCEL_URL=https://mycel.thefocus.ai.

Not tested

  • edit, and writes through bash (the hook checks only a path argument, so bash is not guarded).
  • Paths outside both roots, and symlinks from Owned into Mounted.
  • A live model run in this split (only the offline faux run was done).

Changes from the torture box

  • The guard drill now stands alone. Checks are split into read-allowed, write-blocked, and checksum instead of one line.

Smoke run

Visual Target Wireframe ASCII Layout
PASS read-allowed: read mounted-lib/version.txt -> ALLOWED
PASS write-blocked: write mounted-lib/version.txt -> BLOCKED
PASS checksum: mounted-lib checksum f2d3c42413061073 -> f2d3c42413061073