# Source audit: goal

Decision: OMP-port-backlog, fail-closed locally. Real goal lifecycle belongs to OMP `GoalRuntime` and `GoalTool`; `miloc-pi` must port or thin-wrap that behavior before enabling a goal plugin.

Current local state:

- `extensions/goal/index.ts` registers primary `goal`, legacy `goalSet`, and `/goal`.
- `goal`, `goalSet`, and `/goal` return `isError=true` or a fail-closed widget status instead of mutating local goal state.
- The extension no longer registers `session_start` or `before_agent_start` hooks.
- The extension is disabled by default through `package.json#pi.extensions`.

OMP source evidence:

- `/tmp/oh-my-pi-review/packages/coding-agent/src/goals/tools/goal-tool.ts` defines `GoalTool`, `name = "goal"`, operations `create`, `get`, `complete`, `resume`, `drop`, `objective`, optional `token_budget`, and result details.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/goals/state.ts` defines `Goal`, `GoalModeState`, `GoalStatus`, and `GoalToolDetails`.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/goals/runtime.ts` owns goal creation, pause/resume/drop/complete, token/time accounting, budget-limit steering, continuation prompts, and prompt rendering.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/tools/goal.md` documents the model-facing goal tool contract and the completion warning.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/goals/goal-mode-active.md` and `/tmp/oh-my-pi-review/packages/coding-agent/src/prompts/goals/goal-continuation.md` define hidden goal-mode context and completion-audit rules.
- `/tmp/oh-my-pi-review/packages/coding-agent/src/session/agent-session.ts` wires `GoalRuntime` into session events, mode persistence, tool completion accounting, abort handling, and hidden goal messages.

Implementation boundary:

- Do not keep the old hidden-context injection as product behavior.
- Do not call this extension product-ready until goal state transitions, token/time accounting, continuation prompts, completion audit, persistence, and session integration are either ported from OMP or intentionally out of scope with a documented API.
- `goalSet` may remain only as a temporary compatibility alias after the primary OMP-shaped `goal` tool is implemented.

License note: OMP files are source evidence for the future port. No OMP implementation code was copied in the fail-closed slice.
