Skip to content

F: run plan suggestions through lane D in planning's own worker (#117, part 2) - #120

Merged
mchwang merged 4 commits into
mainfrom
feat/117-planning-worker
Oct 4, 2026
Merged

mchwang merged 4 commits into
mainfrom
feat/117-planning-worker

Conversation

@mchwang

@mchwang mchwang commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Part 2 of #117, after #118. Plan suggestions now run Claude through lane D in production.

What changes

  • One worker per feature. AgentWorker (formerly QuestionWorker, which stays as an alias) and runner/question-worker.ts each serve one feature. LeftoverLedger, worker roots, locks, the record file and the recovery wording now take a WorkerNaming. ASK_NAMING reproduces every Ask name and message exactly.
  • Planning's own isolation. Planning gets its own worker thread, TMPDIR root (codeboost-plan-*), ledger (<db>.planning-leftovers.json), lock directory and a per-database owner token (planning_owner). Its recovery never touches Ask's or the runner's Docker objects, and Ask's never touches planning's.
  • PlanningAgent (runner/planning.ts) runs each request on the review repository at the current snapshot head, with the vendor chosen in Settings. Codex is refused before any lock, worker or Docker work (D: decide how Codex reads code in review, execute and fix (shell is off in every phase) #93).
  • Budget. E3's suggestion timer and the request share one 10-minute budget (PLANNING_BUDGET_MS). The worker's deadline leaves Ask's 5 s settle margin.
  • Issue text. PlanningDeps.describe may be async. The server replays a recorded start first, then reads the issue from GitHub before the recorded action, using the existing bounded, collaborators-only issueText. A GitHub failure returns 502 and is not recorded. A shutdown during the read returns 503.
  • Shutdown. After E3 aborts the requests, any still unsettled after 20 s (Ask's grace) are ended by closing planning's worker.
  • Wiring. web/planning.ts and web/cli.ts turn planning on for any non-demo review with a github block. Demos never plan.

Behavior to note

  • Lazy recovery, as for Ask. A crashed process's planning container is removed by the next process's first planning request, not at startup. Its output has no route back to the Store, so cancelling such a pending request stays safe. runner-lifecycle.md is updated to say so; it previously said startup recovery stopped it.
  • Base ref. The prompt names the base by its commit, because main has no base-branch setting yet. This can switch to F: publish a finished task's pull request in production (#103) #110's github.baseBranch once that lands.

Validation

  • npm run typecheck: passed.
  • CI's npm test command: 62 files, 1417 tests passed.
  • The real-Docker planning test (test/agent-planning.test.ts, added to the agent-isolation workflow) passes locally. A fake token reaches Anthropic from inside the container and gets a 401, and the test checks that nothing carrying planning's owner is left behind.
  • Ask's suites (question-agent, question-leftovers, questions) pass unchanged.

Independent review

A fresh subagent compared Ask's names, messages and step order with main and found no difference Ask could observe. It also confirmed the isolation between Ask and planning and the security of the issue text. Fixed from its findings:

  • a replayed start depended on GitHub (now replays first);
  • a describe failure returned 409 (now 502, or 503 during shutdown);
  • shutdown could wait about 10 minutes (now bounded by Ask's grace);
  • a doc said a stray container ran at most 10 minutes (corrected);
  • seven test gaps.

Not changed:

  • CLI wiring has no test (it is one call);
  • WorkerNaming's size;
  • Ask and planning may each build the same image tag concurrently on a first run;
  • an issue that fits an execute prompt but not a planning prompt is refused, with that refusal recorded.

🤖 Generated with Claude Code

mchwang and others added 4 commits October 3, 2026 19:22
… part 2)

- AgentWorker (was QuestionWorker) and question-worker.ts serve one feature
  each; LeftoverLedger, worker roots, locks and recovery wording take a
  WorkerNaming. Ask's names and messages are unchanged (ASK_NAMING).
- Planning gets its own worker, TMPDIR root, ledger, lock and per-database
  owner token (planning_owner), so its recovery never touches Ask's or the
  runner's agents.
- PlanningAgent (runner/planning.ts) runs each request at the snapshot head of
  the review repository, with the Settings vendor; Codex is refused (#93).
- E3's suggestion timer and the request share one ten-minute budget.
- The server awaits PlanningDeps.describe before a start; web/planning.ts
  reads the issue from GitHub with a bound and is on for any non-demo review
  with a github block.
- Real-Docker planning test in the agent-isolation workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A suggestion start replays its recorded outcome before reading GitHub, and
  reads nothing for a start that would be refused (no planning, shutdown,
  stale revision or snapshot). A GitHub failure is a 502, not recorded; a
  shutdown during the read is a 503.
- Shutdown gives planning requests Ask's 20 s grace after E3 aborts them,
  then closes planning's worker, which abandons one stuck in lane D's setup.
- Docs: a crashed process's container runs until Claude exits or the next
  planning request's recovery removes it (no host-side deadline is left).
- Tests: E3 budget wiring, deadline lower bound, replay without GitHub, 502,
  503, shutdown bound, reverse isolation, worker-side refusal of another
  feature's job, and a leak check in the real-Docker planning test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mchwang
mchwang merged commit 854ca6d into main Oct 4, 2026
2 checks passed
@mchwang
mchwang deleted the feat/117-planning-worker branch October 4, 2026 02:59
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