git:20260703.e20cd5a to git:20260912.4fd8aab

11 added, 1 removed. Audit A to A.

# DOX — packages/goal-plugin/src/server
Files in this directory. One row per source file.
| File | Purpose |
|------|---------|
- | `index.ts` | Server entry. `registerPiHandler("goal_status")` caches snapshot per session, `broadcastToSubscribers` a `plugin_event`. `registerBrowserHandler("plugin_action")` maps set/pause/resume/done/clear/subgoal → `/goal …` via `goalCommandFor`, dispatches with `sendToSession`. `cleared` status deletes cache. See change: add-goal-continuation-plugin. `detectGoalCommandSurface()` baselines `{acceptsSubgoal:true}`. `probeGoalCommandSurface` picks tier, logs it. `goalCommandFor(action,payload,tier)` gains `config` action → `goalConfigCommand`. See change: sophisticate-goal-authoring-and-control. |
+ | `index.ts` | Server entry + PRODUCT composition root (relocated from core `server.ts` wiring). `createGoalStore()` → `goals_update` via `broadcastToSubscribers` with `decorateGoalsWithSpend`; `goal_status` peers (accumulator → projector → budget guard → snapshot) via `registerPiHandler` in core's order; primer on `sendToSession` + `renameSession`; `registerGoalRoutes` on `ctx.fastify` (knownFolderCwds via `consume("host.knownFolderCwds")`, `applyGoalIdToSession` → `assignSessionRef`); `spawnDriver` via `ctx.spawnSession` (caller token verbatim, `resume`, `initialPrompt`, `lifecycle {recover:false}`); supervisor (`mintSpawnToken`/`abortSpawnedRun` deps); death fanout `onSessionEnded`; driver-link handover `onSessionResolved` (first-register only, idempotent, C2e clear via `assignSessionRef persist:false`); dispose `onShutdown` (clear boot-reconcile timer + supervisor.dispose). Snapshot cache + `plugin_action` control shell unchanged. Manifest id `goal` = the owner id core used. See change: add-goal-continuation-plugin, sophisticate-goal-authoring-and-control, relocate-goal-product-to-plugin. |
| `probe.ts` | `probeGoalCommandSurface(surface?)` → tier `full`\|`criteria-dashboard-budget`\|`intent-only`. `goalConfigCommand(tier,{budget,judge})` emits `/goal config …` only in full tier (upgrade seam), else null. `tierEnforcesBudgetDashboardSide(tier)`. Extension not vendored; baseline tier `criteria-dashboard-budget`. See change: sophisticate-goal-authoring-and-control. |
+ | `decorate-goals-spend.ts` | PURE read-time spend join: `decorateGoalsWithSpend(goals, sessions)` → new records with `totalSpendUsd` (Σ `DashboardSession.cost` over `sessionIds`; unresolvable/throwing lookup contributes 0). `SpendSessionLookup` minimal `{get(id)}` surface. Never mutates inputs (load-bearing: store write-through cache). Moved from core `src/goal/` (relocation). See change: fix-goal-detail-turns-and-spend, relocate-goal-product-to-plugin. |
+ | `goal-budget-guard.ts` | PURE budget-halt decision: `decideBudgetHalt(state, budget)` → `{halt, command:"/goal pause"}` when active loop `turnsUsed>=budget.maxTurns` (cumulative). Moved from core `src/goal/` (relocation). See change: sophisticate-goal-authoring-and-control, relocate-goal-product-to-plugin. |
+ | `goal-session-primer.ts` | `primeGoalSession(deps,{sendPrompt,renameSession},sessionId,goal)` — rename card to objective + dispatch `/goal` kickoff commands. `buildGoalReprime(goal)` for fresh respawn re-prime. Deps injected (host: `ctx.sendToSession`/`ctx.renameSession`). Moved from core `src/goal/` (relocation). See change: add-goal-session-supervisor, relocate-goal-product-to-plugin. |
+ | `goal-status-projector.ts` | `goal_status` peer projecting live snapshots onto GoalRecord durable status + turn fields. `createGoalStatusProjector({store, lookupSession})`. Moved from core `src/goal/` (relocation). See change: persist-goal-status-and-progress, relocate-goal-product-to-plugin. |
+ | `goal-store.ts` | Durable per-cwd GoalRecord store at `~/.pi/dashboard/goals/<folderHash>.json` (schemaVersion 1, atomic tmp+rename writes, write-through cache, per-cwd write mutex). CRUD + `linkSession`/`unlinkSession`/`replaceDriver`/`setInFlightSpawn`/`recordRespawn`/`setStatus`/`appendVerdict`; trailing-debounced `subscribe` broadcasts. Moved from core `src/goal/` (relocation) — data dir + format byte-identical. See change: add-goals-folder-page, relocate-goal-product-to-plugin. |
+ | `goal-supervisor.ts` | Goal PURSUIT policy: progress-gated auto-respawn (`RESPAWN_BACKOFF_MS` 5s/15s/45s), crash-loop breaker, cumulative budget. `createGoalSupervisor(deps)` — deps now INJECTED: `mintSpawnToken()` (was core `../auth/spawn-token` import), `killByToken`/`killBySession` (host: `ctx.abortSpawnedRun`), `spawnDriver`, `isSessionLive`/`resolveSessionFile` (host sessionManager). `onDriverDeath`/`abort`/`reconcileOnBoot`/`dispose`/`pendingTimers`. `performSpawn` persists `inFlightSpawn` BEFORE launch. Moved from core `src/goal/` (relocation). See change: add-goal-session-supervisor, relocate-goal-product-to-plugin. |
+ | `goal-verdict-accumulator.ts` | `goal_status` peer appending bounded judge-verdict history (`GoalVerdict {turn,at,verdict,note}`) to the owning GoalRecord. `verdictKind(status)`: active→continue, paused→paused, done→satisfied. Moved from core `src/goal/` (relocation). See change: sophisticate-goal-authoring-and-control, relocate-goal-product-to-plugin. |
+ | `routes.ts` | Goal REST surface (moved from core's old `routes/goal-routes.ts`; paths/shapes byte-identical): GET/POST `/api/folders/goals`, PATCH/DELETE `/api/folders/goals/:id`, POST `/api/folders/goals/:id/sessions` (link\|spawn), DELETE `/api/folders/goals/:id/sessions/:sid`. Deps re-declared on plugin surface: `PluginSessionManager`, `knownFolderCwds: () => string[]` (host service, replaces `sessionManager.listAll() ∪ preferencesStore.getPinnedDirectories()`), `networkGuard = ServerPluginContext["networkGuard"]` on ALL routes. `parseCriteria`/`parseBudget`/`parseJudge` validators; TERMINAL_OR_PAUSED routes through supervisor abort. See change: add-goals-folder-page, add-goal-session-supervisor, relocate-goal-product-to-plugin. |
+ | `goal-product.AGENTS.md` | Dir-overview sidecar carried from the old core `src/goal/` directory AGENTS.md (product-level notes; per-file rows now live here). See change: relocate-goal-product-to-plugin. |
+ | `__tests__/` | Moved core goal tests (8 suites, imports rewritten) + new `plugin-action-handler.test.ts` (composition-root scenarios E21/E22/E23/E23b/E24/E25/X5/X6) + route scenarios E18/E19/E20 in `goal-routes.test.ts`. → see `__tests__/AGENTS.md`. See change: relocate-goal-product-to-plugin (D4). |