Skip to content

feat(engine): purge work-unit scratch cache at close + migration 050 backfill#502

Merged
leeovery merged 1 commit into
mainfrom
feat/cache-purge-on-close
Jul 22, 2026
Merged

feat(engine): purge work-unit scratch cache at close + migration 050 backfill#502
leeovery merged 1 commit into
mainfrom
feat/cache-purge-on-close

Conversation

@leeovery

Copy link
Copy Markdown
Owner

Banked from the render-surfaces programme (design log #489, stage-5 notes): the cache-purge-at-close item, now as its own PR.

What

Close purges scratch. workunit complete, workunit cancel, and workunit absorb (the absorbed feature's cache) remove .workflows/.cache/{wu}/ inside the transaction. Caches are rebuildable per-phase scratch — their job is surviving a context refresh mid-phase; reactivation regenerates them on demand, and the restart paths already rm -rf them.

Disk-only, with one honest guard. Cache is gitignored (.workflows/.gitignore, migration 049), so the purge is normally pure disk. But gitignore never untracked files committed before 049 — so purgeWorkUnitCache checks the index and, when tracked residue exists, hands the pathspec to the transaction commit so the deletions land inside it rather than lingering as dirt outside the .workflows/{wu} scope.

Migration 050 backfills existing installs: purges caches of already-completed/cancelled units and orphan cache dirs whose unit no longer exists. In-progress units and unreadable manifests keep their caches — unknown state is live state.

During investigation we also confirmed (correcting an earlier mis-read): the durable per-cycle analysis/review artifacts live in the phase directory (.workflows/{wu}/implementation/{topic}/…), not cache — nothing deliberately commits cache; the split is already right.

Test plan

  • Migration 050 suite: happy path (completed+cancelled purged, in-progress kept), orphan purge, malformed-manifest keep, no-cache-root skip, idempotency, live-content byte preservation.
  • Engine: complete purges untracked scratch with zero dirt; tracked pre-049 residue deletions ride the completion commit (asserted via git show --name-only); cancel purges; absorb purges the feature's cache.
  • npm test 1543/1543 · npm run test:migrations 10/10 · typecheck clean.

🤖 Generated with Claude Code

…backfill

Work-unit close now removes the unit's .workflows/.cache/{wu}/ scratch
(complete, cancel, and absorb — the absorbed feature's cache goes with
it). Caches are rebuildable per-phase scratch: their only job is
surviving a context refresh mid-phase, and reactivation regenerates
them on demand — the restart paths already rm -rf them today.

Disk-only in the normal case (cache is gitignored via
.workflows/.gitignore since migration 049), with one guard: files
tracked from before 049 exist in old installs, so purgeWorkUnitCache
checks the index and, when residue is tracked, hands the pathspec to
the transaction commit so the deletions land inside it rather than
lingering as dirt.

Migration 050 backfills: purges the caches of already-completed and
already-cancelled work units, and orphan cache dirs whose work unit no
longer exists (absorbed features). In-progress units and unreadable
manifests keep their caches — never delete scratch under live work.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@leeovery
leeovery merged commit df39a1a into main Jul 22, 2026
@leeovery
leeovery deleted the feat/cache-purge-on-close branch July 22, 2026 16:23
leeovery added a commit that referenced this pull request Jul 22, 2026
…eraction in engine.md (#503)

* docs(lifecycle): closing a work unit clears its scratch working files

The cache purge landed in #502; the lifecycle doc now says so in its
own register — scaffolding goes at close, artifacts and history stay,
reactivation rebuilds working files on demand.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* docs(engine): the interactive layer is engine-rendered too

The v0.6.4 render-surface work in the docs voice: menus, gates,
resume notes, and entry blockers come from the deterministic core and
are relayed verbatim; state-dependent verdicts are computed at the
moment of asking; approved changes are shown as true diffs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant