Skip to content

manifest writes recreate a session folder that gc removed #196

Closed

Description

@ThomasK33

A session manifest write that lands after gc removed the session folder brings the folder back, holding only session.json. list --all then shows that stub session until the next gc removes it.

Cause

writeTextFileAtomic in src/storage/manifests.ts runs mkdir(outputDirectory, { recursive: true }) before it writes. So every writeManifest to a removed session folder creates the folder again. Only allocateSession should create a session folder.

Repro (from the independent verification of #194)

  1. Create a session with -- sleep 300.
  2. Run destroy --force with its second session.json read held, using the skill's hold script: REPLAY_HOLD='destroy:readFile:/session.json:2:3000' NODE_OPTIONS="--import $PWD/.agents/skills/verify-session-lifecycle/scripts/replay-hold.mjs".
  3. Run gc --json during the hold. It removes the folder.
  4. After the hold, destroy's final write recreates the folder with session.json reading destroyed, and list --all shows it.

Main has the same defect on other paths. With the hold on the reconcile read inside the old force path, main recreated a stub with status failed. The lifecycle model's Scope section already counts a write that lands after gc's removal as harm.

Direction

Write session manifests through a writer that fails when the session folder is gone, instead of creating it, and let each caller treat that failure as "the session was removed". Model it in .agents/skills/verify-session-lifecycle as a write that cannot recreate a removed folder.

Refs #194


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingready-for-agentFully specified, ready for an AFK agent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions