# Compact-proof task persistence recovery

audience: AI coding agents first.
status: DONE
owner: `how-do-agents`
task: `#15`

## Outcome

Make `compact-context-restore.mjs` read current persisted task files named `<task-id>.json`; prove exact-session and fallback compact-proof injection from disk; install and verify real hook; land minimal current-compatible delta.

## Source request

Coordinator released task #15: recover frozen one-commit WIP `Read persisted JSON task files` without continuing stale base. Preserve source as evidence only; reimplement minimal delta from current `origin/main`; test, review, install, land, deploy, prove.

## Acceptance criteria

1. `readTaskDir()` accepts only regular files named `^\d+\.json$`.
2. Exact-session and fallback tests write/read real `<task-id>.json` files.
3. Malformed-file, ordering, byte-budget, and status behavior remain green.
4. Workstation hook tests pass without warning.
5. Installed `~/.claude/hooks/compact-context-restore.mjs` resolves to repo-managed runtime and renders a persisted JSON task in a deterministic no-model probe.
6. Commit contains only current-compatible hook, tests, and durable-plan receipt changes.
7. Land through repository ship path; deploy installed runtime; record landed SHA and proof.

## Preserved WIP

- Frozen path: `/home/user/Projects/overdeck/.claude/worktrees/agent-ae40c87263f8d2c18`
- Frozen branch: `worktree-agent-ae40c87263f8d2c18`
- Frozen HEAD: `7597fc7333e3eb44034a4f26f3887ff791fbf221`
- Recovery ref: `refs/recovery/wip-triage/20260811T061444Z/worktree-head/agent-ae40c87263f8d2c18-refs-heads-worktree-agent-ae40c87263f8d2c18-d237359d3a`
- Source shape: clean; one unique commit; two changed files; no uncommitted snapshot.
- Frozen source is read-only. NEVER modify, rebase, or copy whole files from it.

## Constraints

- Fresh carrier: `/home/user/Projects/overdeck/.worktrees/compact-proof-task-persistence`, branch `wt/compact-proof-task-persistence`, based on `origin/main` at `2fddbc9da`.
- Canonical behavior: `docs/specs/2026-08-05-compact-proof-todo-injection.md`.
- Related task-store contract: `docs/plans/2026-08-05-agent-seats-on-buildboxes.md`.
- Avoid `modules/harness/factory/**`, `modules/gptbridge/**`, `wt/factory-gpt-model`, and dark-delivery controller files.
- No model request during verification.

## Execution steps

1. Compare preserved commit with current hook, tests, and canonical spec.
2. Add failing regression proving persisted `.json` task discovery.
3. Apply minimal filename-filter fix.
4. Run focused hook test and relevant workstation gate.
5. Review diff against plan/spec and excluded paths.
6. Install/deploy runtime; invoke installed hook with isolated persisted JSON fixture.
7. Commit, land through repository ship path, redeploy, and prove installed landed bytes.

## Current receipt

Task #15 complete. Fresh worktree and preserved frozen source remained isolated; excluded lanes/files were untouched. TDD red proved `<id>.json` omission; complete focused hook suite passes 82/82 with clean output. Independent review found no findings and measured 2,607 numeric `.json` task files versus zero bare numeric files. Guarded land fetch was repaired by removing six unrecoverable local `refs/rescued/codex-*` refs whose target objects were missing and absent from origin. Guarded candidate typecheck passed; shared full test gate stopped only on pre-existing host-state `agent-slice-memorymax`/`build-slice-memorymax` drift (33 passed, 2 failed, 1 skipped), so documented fleet-drift direct-land escape was used without weakening or suppressing any gate. Source deployed at `c394e28a983a`; `packaging/deploy-local.sh` exited 0. Its `shim-drift(copy)` hazard lines concern unrelated frozen carriers; live shims match `origin/main`; this task did not alter them. `deckctl sync apply claude hooks` installed hooks from immutable deploy clone and backed up the prior `muxhost-final` link. Installed hook resolves to `/home/user/.local/share/overdeck/deploy/modules/workstation/claude/hooks/compact-context-restore.mjs`; deploy clone `HEAD == origin/main`; isolated startup probe rendered `#47 [in_progress] installed persisted json proof` from `47.json`.

## Next executable action

None. Persisted JSON task recovery is tested, reviewed, landed, deployed, installed, and runtime-proven.