mirror of
https://github.com/garrytan/gstack.git
synced 2026-10-04 10:26:52 +02:00
* refactor(resolvers): split review.ts into MECE resolver modules (pure move) Move every function from scripts/resolvers/review.ts, unchanged, into: - review-dashboard.ts: review dashboard, plan-file review report - plan-gates.ts: approval check, exit-plan-mode gate, plan-file discovery, plan-completion audit/gate (ship + review), plan verification exec - spec-review.ts: both spec review loops, benefits-from, anti-shortcut clause - outside-voice-steps.ts: Codex second opinion, adversarial step, Codex plan review, Codex doc review, disabled-outside record - review-scope.ts: scope drift, cross-review dedup, shared-code reuse review.ts is deleted; index.ts imports the new modules. gen-skill-docs output is byte-identical for every host (--host all). Test imports and source-path references are re-pointed; the two source-text report/gate tests in gen-skill-docs.test.ts become behavioral renders across every consuming skill and host. All 46 touchfile entries that named review.ts now name all five modules, guarded by a recorded selection golden. * test(browse): black-box auth matrix for every server route and both surfaces Drives buildFetchHandler fetchLocal/fetchTunnel with no token, wrong token, root token, scoped token and the SSE cookie for all 33 routes, plus unmatched paths and wrong methods. Denials assert today's exact status, body and content type; allowed credentials assert the handler was reached. Written against the unchanged if-chain server so the W3 route-table refactor must keep it green. * refactor(shard-engine): move scripts/test-strict-output.ts to scripts/lib/shard-engine.ts The shared shard engine grows from the existing strict-output module (runShardChild, killProcessGroup, signal forwarding, strict classifier). scripts/test-strict-output.ts stays as a re-export so existing importers, mock.module paths and the strict-output/run-shard-child tests are unchanged. The engine inherits the global touchfile entry; the free runner's CLI-routing fixture copies the new module. * refactor(resolvers): decompose the three >150-line review resolvers (output-neutral) Split generateAdversarialStep, generateCodexPlanReview and generatePlanCompletionAuditInner into per-section helpers whose template literals are copied verbatim, so every function in the new modules is at or under 150 lines. gen-skill-docs output is byte-identical for every host (--host all, compared against96764e80with a fixed --link-root). * refactor(resolvers): one outside-voice failure policy (deliberate prose unification) outsideVoiceFailurePolicy(ctx, opts) in outside-voice.ts now renders the auth / timeout / empty-response bullets for all four call sites that hand-typed them (Codex second opinion, adversarial step, Codex plan review, design outside voices). Options are explicit per site (timeoutMinutes, onTimeout, stderrOnEmpty, fallback, escape) with no defaults. Deliberate generated-prose changes (every host): - office-hours: 'Fall back to <native> subagent.' becomes 'Fall back to the <native> subagent below.' - plan-devex-review: the plain 'Auth failure (stderr contains ...)' bullets become the canonical bold bullets; auth also triggers on 'API key'; 'auth failed' becomes 'authentication failed'. - review/ship adversarial: 'exceeded 9 minutes and was terminated' becomes 'timed out after 9 minutes and was terminated'; the timeout is still MISSING COVERAGE. - design outside voices: unchanged. Adds ratchet (d) (test/outside-voice-failure-policy.test.ts) with a reasoned allowlist for /codex's own CLI errors, the MISSING COVERAGE retention test, refreshed codex/factory ship goldens, and outside-voice.ts in every touchfile entry of review.ts and design.ts (selection golden extended). * test(pty): fake PTY session driver with an injectable clock through the runner launch seam The three plan-skill runners take an optional PtyDriver (launch, now, monotonic, sleep); omitted, they use the real launcher and clocks exactly as before. test/helpers/pty/fake-session.ts feeds scripted frames through that seam, and claude-pty-runner.runners.unit.test.ts runs observation, counting and floor for success, deadline timeout, permission prompt and plan-ready outcomes with no CLI or real timers. These cases must stay green unchanged through the W4 split and the runPtySession extraction. Touchfiles: every entry that lists claude-pty-runner.ts or pty-screen.ts now also lists test/helpers/pty/**. * refactor(shard-engine): run both lanes on the shared engine; lane policy injected Engine (scripts/lib/shard-engine.ts) gains the W2 primitives: per-shard tmp/Chromium sandbox + async cleanup backstop, log-path allocation and full-stream log capture, one duration-seed reader/writer with a lane predicate, LanePolicy (seed predicate + zero-execution verdict), strictShardStatus, and the shared CLI flag loop. runShardChild takes an optional companion (signal/settle) and waits a bounded 250ms to reap a wall-killed child. Free lane stops spawning shards itself: runFreeShard uses runShardChild with trackShardBrowser as the companion (win32 path unchanged: no process group, no negative-pid kill). Its sync state-dir removal stays lane policy. Paid lane uses the sandbox, log, seed, verdict and flag primitives; the hollow-shard guard applies PAID_LANE_POLICY. Lane outcomes are unchanged (free keeps >= 0 seeds and file-count zero-exec rule; paid keeps > 0 seeds, warning under selection and passed-empty under EVALS_ALL). paid-free-boundary's closure assertion now names the engine module, where the strict classifier lives. * test(shard-engine): engine unit tests, fixture-corpus equivalence, per-lane CLI parity - test/shard-engine.test.ts: failing/unhandled/module-load output fails both lanes, per-lane zero-execution and seed rules, whole-group kill on a wall timeout (both lanes), mocked-win32 path with no negative-pid kill, companion settle order, log capture, sandbox isolation, flag loop. - test/shard-engine-equivalence.test.ts + test/fixtures/shard-equivalence: seven outcome fixtures plus one real shard, run through both lanes and compared with classifications recorded from the base runners (96764e80). - test/shard-cli-parity.test.ts + test/fixtures/shard-cli-parity: flag set, defaults, validation errors and the Unknown argument error per lane match the base runners. * refactor(shard-engine): decompose runFreeShard and runPaidShard to <= 150 lines Output-neutral extraction under the fixture-corpus equivalence and runner tests: captureFreeStream, explainFreeVerdict and logFreeRecovery (free); paidShardCommand, settleShardSpool, settleBootstrapRetention and printLogTail (paid). The bootstrap scope-creation block that bootstrap-retention.test.ts evaluates stays verbatim. * refactor(pty): split claude-pty-runner.ts into test/helpers/pty/* behind a barrel Pure move: every line of the former 5,047-line runner lands verbatim in one module (four private helpers gain `export` for cross-module use): binary, screen (absorbs test/helpers/pty-screen.ts, which now re-exports it), launch, session (PtyDriver), judge, classify, auq, plan-native, boundaries, runners/{observation,counting,floor}. claude-pty-runner.ts re-exports the original public surface by name; pty/ modules import siblings directly. Tests that read the runner's source text: - rewritten as behavioral: the unit test's model-pin tripwire (fake CLI argv: fallback chain, --model before extraArgs, hermetic --strict-mcp-config), pty-skill-seeding-wiring (runners through the fake driver; launcher through a fake CLI reporting CLAUDE_CONFIG_DIR). The "three wrappers forward model" grep is replaced by the runners' fake-driver launch assertions. - pty-screen-session / pty-screen-supervision: stop copying runner source; they mock.module the real pty/screen.ts (and the fixture cleanup) instead. - re-pointed to the owning module (they execute a sliced runner body with injected boundaries; no seam exists for those boundaries yet): eng-seeded-completion-ai, plan-floor-permission, plan-create-prepublication, plan-count-completion; hermetic-wiring's source guard now reads pty/launch.ts and scans every pty/ module for raw process.env spreads. - plan-count-timeout and pty-output-wake mock the viewport at pty/screen.ts. * test(ratchet-c): enforcing module/function size ratchet and moved-code touchfile coverage Ratchet (c) ships enforcing: test/helpers/module-size.ts counts file and top-level function lengths by brace matching over masked source (strings, comments, regex literals and template text masked; ${} expressions kept), covering function declarations, arrow functions assigned to consts and route-table handler properties, with no parser dependency. Its self-test uses template literals and code-fence braces copied from scripts/resolvers/review.ts and design.ts. test/fixtures/module-size-ratchet.json binds scripts/lib/shard-engine.ts (<= 800 lines, <= 150 per function) and records the residual runner sizes (free 2352, paid 1921) as non-growth caps; allowlist entries are keyed on file plus matched text and need a reason. Failure output lists file:line, the rule, Fix: and the allowlist path. touchfiles.test.ts gains the moved-code superset check over test/fixtures/touchfile-move-goldens/ (W2 golden recorded at96764e80: test-strict-output.ts and test-paid-shards.ts global, test-free-shards.ts none). * refactor(browse): declared route table replaces the buildFetchHandler if-chain The ~1,300-line if-chain in buildFetchHandler becomes a route table: each entry declares method, path, auth kind and surfaces, and one auth gate in browse/src/routes/table.ts returns the per-kind denial (root-bearer, scoped, root-or-sse-cookie: 401 Unauthorized; root-token: 403 Root token required; extension-origin: 403 Forbidden). Unmatched requests take the declared fallthrough (root-bearer check, then plain-text 404). Handlers move to browse/src/routes/{core,pairing,pty,tokens,tunnel,activity,commands,files, inspector}.ts and receive a RouteContext with auth checks as functions instead of closing over factory locals. Dispatch order is unchanged: tunnel filter, beforeRoute overlay, gate, handler. TUNNEL_PATHS stays a literal in server.ts. Behavior-preserving: the black-box auth matrix from the previous commit passes unchanged. /memory and /inspector/events are declared root-bearer because the blanket check always ran before their SSE-cookie branch. Source-text route tests are rewritten as behavioral tests through buildFetchHandler or a route's real handler with a stub RouteContext (browse/test/route-test-harness.ts). Checks with no runtime seam are re-pointed to the route modules: Surface type, /inspector/events SSE helper, sanitizeReplacer imports, /pty-inject-scan sidecar-client import, and the ngrok config lookup and startTunnel wiring that stay in server.ts. * test(browse): stubbed-handler auth matrix and route inventory for the route table Every ROUTES entry runs through the real dispatcher and gate with stub handlers on each declared surface and six credentials; denials assert the exact status and body each auth kind returned at96764e8, admitted credentials assert the handler ran (with the gate's TokenInfo for scoped routes). Also pins the reviewed route inventory (method, path, auth kind, surfaces), that every entry declares auth and surfaces, that the table's tunnel paths equal the TUNNEL_PATHS literal with GET /connect admitted, the unmatched fallthrough, and that the root token is rejected on every tunnel route through buildFetchHandler. * test(browse): ratchet (b) keeps route dispatch inside the route table Scans browse/src/server.ts and browse/src/routes/*.ts for pathname comparisons; only the table matcher and the tunnel-surface filter are allowed, listed with reasons in browse/test/fixtures/route-dispatch-allowlist.json (keyed on file plus line text). Also checks every entry declares auth and surfaces and that gstack registers no beforeRoute overlay itself. Self-tests plant a violation and assert the file:line, Fix: and allowlist path in the message, that a shifted line stays allowlisted, and that a reasonless entry is rejected. * test: touchfile superset check for modules moved out of browse/src/server.ts Records the paid evals selected by touching browse/src/server.ts at96764e80(17 E2E, 1 LLM judge) and asserts every browse/src/routes/*.ts module selects a superset. The test reads every golden in test/fixtures/moved-module-selection/ so other moved-code goldens can sit beside it. * test(shard-engine): give non-timeout corpus fixtures CI headroom; keep the POSIX golden off the Windows lane Only the wall-timeout fixture keeps a 3s wall; the rest get 60s so a loaded host cannot turn a pass into a timeout. Base and branch runners still agree on every classification under the new walls. The Windows exclusion entry moves the free runner's ratchet (c) residual cap to 2356 lines. * refactor(pty): one runPtySession loop drives observation, counting and floor test/helpers/pty/session.ts owns launch -> start -> (poll -> tick)* -> timeout and the failure contract the three runners each hand-rolled: the run's own error wins over capture and close errors, close always runs, owned fixture cleanup runs last (also when launch fails). Each runner now supplies a PtySessionPlan: its boot/command step, poll cadence (2s observation/floor sleep; counting's output wake + 250ms coalesce), tick policy (permission handling, native identity, terminal rules stay per runner because they differ) and capture hooks. The runner bodies are decomposed into top-level steps so no function exceeds 150 lines; behavior is unchanged and the fake-driver cases from the first W4 commit pass unmodified. The counting capture step and the native completion-summary predicate are now named functions (countingCapture, isNativeCompletionSummary), so plan-create-prepublication and plan-count-completion call them directly instead of executing sliced source. The two harnesses that still execute a sliced runner body with injected boundaries (eng-seeded-completion-ai, plan-floor-permission) pass the PtyDriver seam instead of overriding Date/Bun.sleep. * test(ratchet-c): register route modules, review resolver modules and server.ts residual cap * refactor(pty): decompose launchClaudePty and engNumberedFindingAUQ under 150 lines launchClaudePty (349 lines) becomes launch preparation (args, hermetic child env, owned state roots), recorder creation, spawn, the trust-dialog watcher, close, and the session handle over one PtyProcess state object. The failure order is unchanged: abort the viewport, dispose any recorders created so far, dispose the viewport, rethrow. The --model / --strict-mcp-config ordering and seedSkills wiring stay pinned by the behavioral fake-CLI tests. engNumberedFindingAUQ (345 lines) keeps its guards and dispatch; each self-contained issue family (declared cache, library retry hooks, cache owner, injected singleton, shared writers, injected export) moves verbatim into its own function. Every pty/ module is now <= 800 lines and every top-level function <= 150 lines. * test(pty): split claude-pty-runner.unit.test.ts along the pty/ module seams The 188 unit tests move verbatim into claude-pty-runner.{screen,classify, auq,launch,plan-native,boundaries}.unit.test.ts (test names unchanged; each file imports only what it uses from the barrel). The five files that no longer read a SKILL.md template join the test-of-test ratchet baseline with a reason. * test(touchfiles): moved PTY modules keep their paid-eval selection test/fixtures/touchfile-selection/w4-pty.json records, at96764e8, the paid evals selected by touching test/helpers/claude-pty-runner.ts (20) and test/helpers/pty-screen.ts (20). touchfiles.test.ts now asserts every .ts file under test/helpers/pty/ (and pty/screen.ts for both sources) selects a superset, reading every golden in that directory so later moves can add one; a planted-violation case pins the report and its Fix line. * fix(browse): unexchanged pair setup keys no longer authenticate bearer requests validateToken accepted a gsk_setup_ key as a bearer on /command, /batch and /file (found while building the W3 auth matrix). A setup key now only authenticates the /connect exchange. * W1: one state-root owner (lib/state-root.ts + bin/gstack-state-root.sh), gstack-paths --explain and fail-stop, parity tests * W1: guarded migration of every executable state-root site; uninstall deletes only ~/.gstack Bins, careful/freeze hooks, setup, upgrade migrations, browse/src, design, ios-qa daemon, lib and scripts resolve the state root through bin/gstack-state-root.sh (bash) or lib/state-root.ts (TS). Bins source the twin and stop with a reinstall message when it is missing; hooks source it and never spawn gstack-paths. browse/src/config.ts and lib/cso/state.ts delegate to resolveStateRoot. Analytics writers and readers move together so the usage log stays one file. gstack-uninstall deletes state only at ~/.gstack, refuses (exit 2) when it resolves to /, $HOME or an ancestor, the checkout or the git root, and leaves any other resolved root in place with the removal command. Fixtures that copy single bins now copy the twin. * W1: privacy keys and trust-policy deny tiers merge across state roots; gstack-config reporting; test hermeticity readConfigKey / gstack_read_config_key return the most restrictive telemetry, memorable_recall, codex_reviews and update_check across the resolved root and ~/.gstack; other keys read the resolved root only. gstack-config set reports an overriding root with the exact override command, list shows the winning root and a root-variable disagreement line. gstack-gbrain-repo-policy get merges deny/read-only tiers. gstack-egress reads through readConfigKey. test-setup.ts strips inherited GSTACK_STATE_ROOT/GSTACK_STATE_DIR and redirects the legacy root. * W1: shared hook logging helper (hosts/claude/hooks/hook-log.ts) One hook-errors.log writer: root from resolveStateRoot, 0600 on every append, opt-in rate limit used only by memorable-user-prompt. The five hooks route through it. * W1: docs/state-root.md and README troubleshooting pointer Precedence table, a real --explain example, the move-your-state recipe, merged privacy keys, the uninstall rule, the resolver-failure fix, and the plugin-mode note (evidence gate: no official plugin distribution). * W1b: template and resolver prose resolve state through guarded gstack-paths; ratchet (a) Every gstack-paths eval in templates and resolvers carries the fail-stop guard; executable ~/.gstack paths in bash blocks (context recovery preamble, eureka log, analytics, project artifacts, upgrade snooze, setup-gbrain lock, retro snapshots, ship consent marker) use $GSTACK_STATE_ROOT, and the writer prose that pairs with them points at the printed PROJECT_DIR / RETRO_FILE. ship drops export GSTACK_STATE_ROOT. SKILL.md regenerated (claude + codex), ship goldens re-pinned, parity and context-budget caps raised to the measured sizes with notes. test/state-root-ratchet.test.ts enforces the rule with a reasoned allowlist; W1 touchfile entries plus a superset golden. * refactor: apply W1 state-root edits in W2/W3/W5-owned files; one moved-code touchfile golden for all workstreams * test: fold the moved-code touchfile golden into touchfiles.test.ts; fix integration fixture closure and caps * v1.91.11.0: CHANGELOG, TODOS, docs and conventions for the refactor wave * test: re-measure plan-ceo/design-consultation caps and ship goldens after the guarded plan-discovery and spec-review blocks; add the state-root twin to the workflow-boundaries fixture * fix(windows): migrations resolve their directory with either path separator; state-root parity compares under the HOME Git Bash actually sees * fix(review,ship): state plan-check timing after smoke expiry and test_stub Skip semantics (review workflow judge clarity) * test(qa-eval): webhook fix eval asks for the fix loop's post-repair probes; eight-scenario coverage stays in the report-only case and the harness recheck * test(qa-eval): re-pin the webhook prompt contract to the fix-loop stage; R29 coverage omissions stay bound by the report-only case * fix(review,ship): plan checks publish a checkpoint before each probe; only the smoke expiry stop is skipped * fix(qa): carry #2999's checkpoint receipt link, report-template line and full-revision placeholder (identical hunks) * test(qa-callers): disable git auto maintenance in the caller fixture Git 2.47+ runs auto maintenance detached after commit; on the CI runner's git 2.55 it rewrote .git/objects fan-out directories while the write observer was running, which surfaced as unauthorized mutations. Same gc.auto=0 / maintenance.auto=false guard the shared-libs fixture already uses. * test(plan-mode-no-op): require prose evidence for the prose-fallback members so a spinner-frame judge verdict cannot end the run as asked * test(ship-docsync): carry #2999's seeded-attempt docsync harness (identical files) The doc-sync fault cases replayed attempt 1 before reaching their gate and ran out of their 285s budget. The fixture now seeds attempt 1 and the parent starts at the gate under test. Taken byte-identical from origin/capy/audit-fix-wave (fb526898,e6ac813d,6ce10ff7,d0c53577,77cce3be). Local: stale-before, recovery and late-result 6/6 PASS (97-164s); the whole file 12/12 PASS.
611 lines
39 KiB
Cheetah
611 lines
39 KiB
Cheetah
## Review Sections (11 sections, after scope and mode are agreed)
|
||
|
||
**Anti-skip rule:** Evaluate Sections 1–10 in full for every plan, including strategy,
|
||
spec, code and infra. Run Section 11 if accepted work adds or changes UI screens,
|
||
components, user interactions, frontend frameworks, user-visible states,
|
||
mobile/responsive behavior or the design system. Otherwise record `SKIPPED (no UI scope)`. In evaluated sections,
|
||
say "No issues found" only when there are zero findings.
|
||
|
||
**Use the review depth chosen in Step 0.** For scope prioritization, use each
|
||
section to decide inclusion and feasibility under accepted constraints. Diagrams
|
||
and maps must show candidate boundaries, failure mechanisms, feasibility conditions
|
||
and unresolved risks. Resolve material blockers now; revisit priorities when new
|
||
evidence changes them. Leave non-blocking implementation choices pending with an
|
||
owner and required verification. Use Step 0's depth-expansion decision before
|
||
designing endpoint, method or state-machine contracts beyond that depth. In strategy-only depth, use
|
||
capability-level rows and "implementation owner must prove ___" notes instead
|
||
of method-level registries. In implementation-ready depth, require the concrete
|
||
method/codepath, contract, rescue and test rows. Report what is approved, what
|
||
is verified and what remains unchosen; completing prioritization does not mean
|
||
the implementation is ready.
|
||
|
||
**Preserve accepted requirements.** Compare the proposed implementation with
|
||
stated invariants and acceptance criteria. Report gaps and propose remedies,
|
||
including omitted mechanisms in HOLD SCOPE. Never weaken a guarantee, accept its
|
||
violation or change a test to expect it. Low frequency, bounded impact and
|
||
documentation do not meet stricter requirements. Changing a requirement needs
|
||
explicit authority; until then, keep both the proposal and original gap unresolved.
|
||
Carry prior approvals into findings, tasks and the report. Routine auto-decide
|
||
cannot override user constraints or non-goals.
|
||
|
||
## CRITICAL RULE — How to ask questions
|
||
Use 0D's decision procedure and the preamble's AskUserQuestion format:
|
||
* **One decision unit = one AskUserQuestion call.** Use Step 0D boundaries, not topic labels.
|
||
* Describe the concrete problem with file/line references. Offer 2-3 options,
|
||
including "do nothing" when reasonable.
|
||
* Give each option one line covering effort, risk and maintenance.
|
||
* The recommended option's description must offer a complete remedy for this
|
||
issue: rescue behavior, verification and failure visibility. Exclude unrelated
|
||
work; ask about independent findings and new TODOs separately.
|
||
* Connect the recommendation to one engineering preference in a sentence.
|
||
* Use `D<N>` and A/B/C labels. Cite the stable ledger ID separately to retain
|
||
reopened decision history.
|
||
* An "obvious fix" still needs approval when it is not covered by an exact accepted choice.
|
||
|
||
## Formatting Rules
|
||
* Use short labels and 0D's exact `currentDecision` question and option descriptions.
|
||
* Use **CRITICAL GAP** / **WARNING** / **OK** for scannability.
|
||
|
||
## Mode Quick Reference
|
||
|
||
Mode controls included work, not depth or section coverage. Review and produce
|
||
outputs for accepted work in every mode.
|
||
|
||
| Step | SCOPE EXPANSION | SELECTIVE EXPANSION | HOLD SCOPE | SCOPE REDUCTION |
|
||
|------|-----------------|---------------------|------------|-----------------|
|
||
| Scope proposals | Offer additions individually | Offer cherry-picks individually | No expansions | Offer cuts individually |
|
||
| 10x check | Required; additions need approval | Required; additions need approval | Skip | Skip |
|
||
| Platonic ideal | Required | Skip | Skip | Skip |
|
||
| Delight opportunities | At least 5, each opt-in | At least 5, each opt-in | Skip | Skip |
|
||
| Complexity | Review accepted ambition | Review baseline and accepted additions | Simplest correct accepted scope | Minimum valuable scope |
|
||
| Temporal interrogation (0I) | Run | Run | Run | Skip |
|
||
| Separate CEO archive (0H) | Write | Write | Skip | Skip |
|
||
| Future direction (Section 10) | Review accepted trajectory | Review accepted cherry-picks | Maintainability; no expansions | Maintainability of remaining scope |
|
||
| Design (Section 11) | Review if UI scope | Review if UI scope | Review if UI scope | Review if UI scope |
|
||
|
||
Save to the permitted working plan; with no permitted plan/report write, present
|
||
it in chat as not persisted and end with completion blocked. The CEO archive is
|
||
additional expansion-mode output.
|
||
|
||
### Working review decisions
|
||
|
||
At each section's **Decision gate**, follow Analyze → Resolve → Apply below.
|
||
Continue the six-column ledger with each row's owner section. Review only;
|
||
do not change code.
|
||
|
||
**Analyze.** Check input, source and actual approvals. Correct false claims and
|
||
dependent test/runbook text without changing approved behavior. Preserve contracts
|
||
and mitigations even if later text omits them. Flag approval conflicts. Unavailable
|
||
code proves neither failure nor safety; record unknown risks with their owners
|
||
and required verification.
|
||
|
||
**Resolve.** Take the first applicable path for each finding:
|
||
1. This section needs a new choice, or evidence warrants reopening its prior
|
||
answer: use 0D's Plan decision route through its post-answer save, then
|
||
return here to Apply.
|
||
Use the same row ID in the ledger, `currentDecision` and question; complete
|
||
the pre-question checkpoint before asking. Resolve critical risks now.
|
||
2. An exact prior answer covers it: cite that answer and go to Apply.
|
||
3. A non-blocking choice belongs to a later section: reference its pending row
|
||
and owner; leave it undecided here.
|
||
|
||
Keep independent safety fixes and throughput improvements in separate rows,
|
||
following 0D's test table. No path selects the mode again.
|
||
|
||
**Apply.** Check the saved plan against each answer's exact scope. Preserve existing
|
||
content, approved behavior, required implementation, tests and success/failure
|
||
contracts. Leave unapproved remedies and extra verification pending; do not put
|
||
them into tasks or prescribe them in diagrams. If the plan already matches, do
|
||
not save again. Correct discrepancies under the storage policy; if a correction
|
||
needs approval, resolve it through 0D before repeating this check.
|
||
|
||
Record findings and dispositions, then review the next section. Do not write its
|
||
conclusions or tasks before reviewing it. After Sections 1–10 and Section 11's
|
||
review or no-UI skip, follow Closing sequence. Keep unresolved choices in the
|
||
ledger and report; an approval is not proof of implementation or verification.
|
||
|
||
### Section 1: Architecture Review
|
||
Publish **Current scope** in chat before the architecture analysis:
|
||
- Retain 0E's selected mode, rationale and preference attribution.
|
||
- Show each governing row's ID, disposition and answer reference, including scope
|
||
decisions after 0E. Keep earlier answers as history.
|
||
- Distinguish accepted, deferred, rejected and pending work.
|
||
|
||
This is a scope update, not another mode handoff; do not ask or log the mode again.
|
||
Then say `Section 1: Architecture Review`.
|
||
|
||
Evaluate and diagram:
|
||
* System design and component boundaries. Draw the dependency graph.
|
||
* Data flow — all four paths. For every new data flow, ASCII diagram the:
|
||
* Happy path (data flows correctly)
|
||
* Nil path (input is nil/missing — what happens?)
|
||
* Empty path (input is present but empty/zero-length — what happens?)
|
||
* Error path (upstream call fails — what happens?)
|
||
* State machines. ASCII diagram for every new stateful object. Include impossible/invalid transitions and what prevents them.
|
||
* Coupling concerns. What new coupling exists, and is it justified? Draw before/after dependencies.
|
||
* Scaling characteristics. What breaks first under 10x and 100x load?
|
||
* Single points of failure. Map them.
|
||
* Security architecture. Auth boundaries, data access patterns, API surfaces. For each new endpoint or data mutation: who can call it, what do they get, what can they change?
|
||
* Production failure scenarios. For each integration point, describe one realistic failure and whether the plan handles it.
|
||
* Rollback posture. If this ships broken, name the rollback path and time.
|
||
|
||
**EXPANSION and SELECTIVE EXPANSION additions:**
|
||
* What would make this architecture elegant and obvious to a new engineer?
|
||
* What infrastructure makes this a platform for later features?
|
||
|
||
**SELECTIVE EXPANSION:** If any accepted cherry-picks from Step 0G affect the architecture, evaluate their architectural fit here. Flag any that create coupling concerns or don't integrate cleanly — this is a chance to revisit the decision with new information.
|
||
|
||
Required ASCII diagram: full system architecture showing new components and their relationships to existing ones.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 2: Error & Rescue Map
|
||
This is the section that catches silent failures. It is not optional.
|
||
For strategy-only depth, map each retained capability, integration or data
|
||
boundary that can fail. For implementation-ready depth, map every new method,
|
||
service or codepath that can fail. Use the same table shape for both:
|
||
```
|
||
METHOD/CODEPATH | WHAT CAN GO WRONG | EXCEPTION CLASS
|
||
-------------------------|-----------------------------|-----------------
|
||
ExampleService#call | API timeout | TimeoutError
|
||
| API returns 429 | RateLimitError
|
||
| malformed JSON | JSONParseError
|
||
-------------------------|-----------------------------|-----------------
|
||
|
||
EXCEPTION CLASS | RESCUED? | RESCUE ACTION | USER SEES
|
||
-----------------------------|-----------|------------------------|------------------
|
||
TimeoutError | Y | Retry 2x, then raise | Temporary outage
|
||
RateLimitError | Y | Backoff + retry | Transparent
|
||
JSONParseError | N ← GAP | — | 500 error ← BAD
|
||
```
|
||
Rules for this section:
|
||
* Catch-all error handling (`rescue StandardError`, `catch (Exception e)`, `except Exception`) is ALWAYS a smell. Name the specific exceptions.
|
||
* Generic-only logging is insufficient. Log what was attempted, with what args and for what user/request.
|
||
* Every rescued error must retry with backoff, degrade gracefully with a user-visible message, or re-raise with added context. "Swallow and continue" is almost never acceptable.
|
||
* For each GAP (unrescued error that should be rescued): specify the rescue action and what the user should see.
|
||
* For LLM/AI calls: handle malformed, empty, hallucinated-invalid JSON and refusals as distinct failure modes.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 3: Security & Threat Model
|
||
Security is not a sub-bullet of architecture. It gets its own section.
|
||
Evaluate:
|
||
* Attack surface expansion. What new attack vectors does this plan introduce? New endpoints, new params, new file paths, new background jobs?
|
||
* Input validation. For every new user input: is it validated, sanitized, and rejected loudly on failure? What happens with: nil, empty string, string when integer expected, string exceeding max length, unicode edge cases, HTML/script injection attempts?
|
||
* Authorization. For every new data access: is it scoped to the right user/role? Is there a direct object reference vulnerability? Can user A access user B's data by manipulating IDs?
|
||
* Secrets and credentials. New secrets? In env vars, not hardcoded? Rotatable?
|
||
* Dependency risk. New gems/npm packages? Security track record?
|
||
* Data classification. PII, payment data, credentials? Handling consistent with existing patterns?
|
||
* Injection vectors. SQL, command, template, LLM prompt injection — check all.
|
||
* Audit logging. For sensitive operations: is there an audit trail?
|
||
|
||
For each finding: threat, likelihood (High/Med/Low), impact (High/Med/Low), and whether the plan mitigates it.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 4: Data Flow & Interaction Edge Cases
|
||
Trace data and user interactions adversarially.
|
||
|
||
**Data Flow Tracing:** For every new data flow, produce an ASCII diagram showing:
|
||
`INPUT -> VALIDATION -> TRANSFORM -> PERSIST -> OUTPUT`, with shadow paths for
|
||
nil/empty/wrong type, invalid/too long, exception/timeout/OOM, conflict/dup/lock,
|
||
stale/partial/encoding.
|
||
For each node: what happens on each shadow path? Is it tested?
|
||
|
||
**Async ordering:** For flows sharing mutable state:
|
||
1. **Define the boundary.** State the invariant and its exact caller/time boundary. Draw a combined ASCII schedule with one column per operation and one for shared state.
|
||
2. **Exercise both orders.** For each pair of overlapping awaits that can affect that invariant, show both completion orders. At each relevant `await`, callback or job handoff: pause, let a competing operation complete, resume, then start a fresh consumer. Exclude an order only by naming the mechanism that prevents it.
|
||
3. **Compare the result.** Show the observed result against the invariant. The invariant is a requirement, not proof that the implementation meets it. If safe, name the mechanism that prevents the violating schedule. Separate diagrams, one favorable schedule, single-thread execution and atomic calls do not prove ordering across awaits. An accepted exception needs its exact contract clause; bounded damage is insufficient.
|
||
4. **Specify regression proof.** Test the relevant completion orders with controlled pause/release points. Compare relevant pairs; exhaustive permutations are unnecessary.
|
||
|
||
**Interaction Edge Cases:** For every new user-visible interaction, evaluate:
|
||
`INTERACTION | EDGE CASE | HANDLED? | HOW?`. Include Double-click/stale submit,
|
||
navigate away/timeout/retry, zero/large/changing list, and failed/duplicate/backlogged jobs.
|
||
Flag any unhandled edge case as a gap. For each gap, specify the fix.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 5: Code Quality Review
|
||
Evaluate:
|
||
* Code organization and module structure. Does new code fit existing patterns?
|
||
* DRY violations. Be aggressive. If the same logic exists elsewhere, flag it and reference the file and line.
|
||
* Naming quality. Are new classes, methods, and variables named for what they do, not how they do it?
|
||
* Error handling patterns. (Cross-reference with Section 2 — this section reviews the patterns; Section 2 maps the specifics.)
|
||
* Missing edge cases: nil, empty, 429/timeouts and boundary values.
|
||
* Over-engineering: abstractions for problems that do not exist yet.
|
||
* Under-engineering: happy-path fragility or missing defensive checks.
|
||
* Cyclomatic complexity. Flag any new method that branches more than 5 times. Propose a refactor.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 6: Test Review
|
||
Carry requested or approved coverage forward, including directly determined tests, without re-asking. For an unresolved test-method choice or additional verification scope/depth, name the distinct regression existing tests miss and resolve that choice through 0D before prescribing it. An approved runtime contract alone does not choose extra verification scope.
|
||
|
||
Make a complete diagram of every new thing this plan introduces:
|
||
new UX flows, data flows, codepaths, background jobs/async work,
|
||
integrations/external calls, and error/rescue paths (cross-reference Section 2).
|
||
For each item in the diagram:
|
||
* What type of test covers it? (Unit / Integration / System / E2E)
|
||
* Does a test for it exist in the plan? If not, draft its header within requested or approved coverage; keep new verification proposals pending until their decision.
|
||
* What is the happy path test?
|
||
* What is the failure path test? (Be specific — which failure?)
|
||
* What is the edge case test? (nil, empty, boundary values, concurrent access)
|
||
|
||
For each behavior, complete this assertion check:
|
||
1. **Map the requirement.** Name its observable assertion and a wrong result it rejects. Map it to the user's exact requirement or individually approved remedy. A stated outcome plus its retained caller contract can determine the assertion, even without assertion syntax. Translate semantic counts, conditions and quantifiers exactly; never weaken an exact count to a lower bound.
|
||
2. **Reuse settled proof.** Selecting an existing probe or spelling out a determined check is implementation work, not another approval. Reuse these requirements without asking again. Verify the caller's path; helper coverage alone does not prove it. Honor previously accepted risks and equivalent caller coverage.
|
||
3. **Resolve actual gaps.** Explain what the existing requirement or approved remedy fails to cover before calling a check missing. Ask individually only for an unresolved behavioral choice, new outcome, or independent uncovered failure mode. Vague success labels do not settle values; scope/approach approval does not resolve an individual assertion gap. Never silently add, defer or waive a missing behavioral assertion. Keep required behaviors mandatory unless the user explicitly approves changing them.
|
||
|
||
Test ambition check (all modes): For each new feature, answer:
|
||
* What's the test that would make you confident shipping at 2am on a Friday?
|
||
* What's the test a hostile QA engineer would write to break this?
|
||
* What's the chaos test?
|
||
|
||
Test pyramid check: Many unit, fewer integration, few E2E? Or inverted?
|
||
Flakiness risk: Flag any test depending on time, randomness, external services, or ordering.
|
||
Load/stress test requirements: For any new codepath called frequently or processing significant data.
|
||
|
||
For LLM/prompt changes: Check CLAUDE.md for the "Prompt/LLM changes" file patterns. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 7: Performance Review
|
||
Evaluate:
|
||
* N+1 queries. For ORM-backed data access, especially association traversal: does the plan preload/batch instead of querying in a loop?
|
||
* Memory usage. For every new data structure: what's the maximum size in production?
|
||
* Database indexes. For every new query: is there an index?
|
||
* Caching opportunities. For every expensive computation or external call: should it be cached?
|
||
* Background job sizing. For every new job: worst-case payload, runtime, retry behavior?
|
||
* Slow paths. Top 3 slowest new codepaths and estimated p99 latency.
|
||
* Connection pool pressure. New DB connections, Redis connections, HTTP connections?
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 8: Observability & Debuggability Review
|
||
New systems break. This section ensures you can see why.
|
||
Evaluate:
|
||
* Logging. For every new codepath: structured log lines at entry, exit, and each significant branch?
|
||
* Metrics. For every new feature: what metric tells you it's working? What tells you it's broken?
|
||
* Tracing. For new cross-service or cross-job flows: trace IDs propagated?
|
||
* Alerting. What new alerts should exist?
|
||
* Dashboards. What new dashboard panels do you want on day 1?
|
||
* Debuggability. If a bug is reported 3 weeks post-ship, can you reconstruct what happened from logs alone?
|
||
* Admin tooling. New operational tasks that need admin UI or rake tasks?
|
||
* Runbooks. For each new failure mode: what's the operational response?
|
||
|
||
**EXPANSION and SELECTIVE EXPANSION addition:**
|
||
* What observability would make this feature a joy to operate? (For SELECTIVE EXPANSION, include observability for any accepted cherry-picks.)
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 9: Deployment & Rollout Review
|
||
Evaluate:
|
||
* Migration safety. For every new DB migration: backward-compatible? Zero-downtime? Table locks?
|
||
* Feature flags. Should any part be behind a feature flag?
|
||
* Rollout order. Correct sequence: migrate first, deploy second?
|
||
* Rollback plan. Explicit step-by-step.
|
||
* Deploy-time risk window. Old code and new code running simultaneously — what breaks?
|
||
* Environment parity. Tested in staging?
|
||
* Post-deploy verification checklist. First 5 minutes? First hour?
|
||
* Smoke tests. What automated checks should run immediately post-deploy?
|
||
|
||
**EXPANSION and SELECTIVE EXPANSION addition:**
|
||
* What deploy infrastructure would make shipping this feature routine? (For SELECTIVE EXPANSION, assess whether accepted cherry-picks change the deployment risk profile.)
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 10: Long-Term Trajectory Review
|
||
Evaluate:
|
||
* Technical debt introduced. Code debt, operational debt, testing debt, documentation debt.
|
||
* Path dependency. Does this make future changes harder?
|
||
* Knowledge concentration. Documentation sufficient for a new engineer?
|
||
* Reversibility. Rate 1-5: 1 = one-way door, 5 = easily reversible.
|
||
* Ecosystem fit. Aligns with this repo's framework conventions?
|
||
* The 1-year question. Is this obvious to a new engineer in 12 months?
|
||
|
||
**EXPANSION and SELECTIVE EXPANSION additions:**
|
||
* What comes after this ships? Phase 2? Phase 3? Does the architecture support that trajectory?
|
||
* Platform potential. Does this create capabilities other features can leverage?
|
||
* (SELECTIVE EXPANSION only) Retrospective: Were the right cherry-picks accepted? Did any rejected expansions turn out to be load-bearing for the accepted ones?
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
### Section 11: Design & UX Review (skip if no UI scope detected)
|
||
The CEO calling in the designer. Not a pixel-level audit — that's /plan-design-review and /design-review. This is ensuring the plan has design intentionality.
|
||
|
||
Evaluate:
|
||
* Information architecture — what does the user see first, second, third?
|
||
* Interaction state coverage map:
|
||
FEATURE | LOADING | EMPTY | ERROR | SUCCESS | PARTIAL
|
||
* User journey coherence — storyboard the emotional arc
|
||
* AI slop risk — does the plan describe generic UI patterns?
|
||
* DESIGN.md alignment — does the plan match the stated design system?
|
||
* Responsive intention — is mobile mentioned or afterthought?
|
||
* Accessibility basics — keyboard nav, screen readers, contrast, touch targets
|
||
|
||
**EXPANSION and SELECTIVE EXPANSION additions:**
|
||
* What would make this UI feel *inevitable*?
|
||
* What 30-minute UI touches would make users think "oh nice, they thought of that"?
|
||
|
||
Required ASCII diagram: user flow showing screens/states and transitions.
|
||
|
||
If this plan has significant UI scope, recommend: "Consider running /plan-design-review for a deep design review of this plan before implementation."
|
||
|
||
**Post-Implementation Design Audit (if UI scope detected):** After implementation, run `/design-review` on the live site to catch visual issues that can only be evaluated with rendered output.
|
||
**Decision gate.** Complete Analyze → Resolve → Apply above for this section before continuing.
|
||
|
||
## Closing sequence
|
||
|
||
Continue through the blocks below in file order:
|
||
1. **Outside Voice:** run the configured review and resolve its findings through 0D. Record disabled or unavailable coverage and continue when no reviewer runs.
|
||
2. **Resolve remaining TODO choices:** use the selected mode's scope rules.
|
||
3. **Approval readiness:** check the ledger and record PASS before writing outputs. Its complete checklist is immediately after the TODO choices; no report or log is needed yet.
|
||
4. **Required Outputs:** follow the three stages below: prepare the plan body and summary, save and verify the terminal report, then publish the summary in chat.
|
||
5. **Cleanup and history:** perform permitted cleanup, attempt Review Log under the Artifact outcomes policy, then display the dashboard with the actual logging outcome.
|
||
6. **Navigation:** choose Next Steps and any docs/designs promotion; queue the next skill. For a substantive answer, call 0D for only that change, repeat Approval readiness and Required Outputs, then repeat step 5. Resume navigation without asking settled choices again. Navigation alone does not reopen decisions.
|
||
7. **Learnings:** finish learning and brain write-back. Return to this skill's main `SKILL.md`, at **Section self-check**. Its EXIT gate verifies completed work and saved readiness without asking again. After a passing gate, refresh the cache, run telemetry last, then exit or return to the caller.
|
||
|
||
### Outside Voice Integration Rule
|
||
|
||
Apply Analyze above to each outside finding before adding it to the same ledger.
|
||
Correct unsupported draft claims and preserve unknown risks. Reviewer agreement
|
||
is not new evidence or approval. Reopen a choice only for a supported material
|
||
risk, citing its prior answer and the new evidence; resolve it through 0D before
|
||
amending the plan.
|
||
|
||
{{CODEX_PLAN_REVIEW}}
|
||
|
||
## Resolve remaining TODO choices
|
||
|
||
### TODOS.md updates
|
||
**Keep the selected mode.** In HOLD SCOPE, a potential TODO must address an
|
||
evidenced gap in the accepted scope or its required correctness and operability.
|
||
Hypothetical future capacity, optional features, and alternatives to an adequate
|
||
approved remedy are expansions even when labeled TODOs; do not surface them in
|
||
HOLD SCOPE. Still audit observability and performance against the requirements,
|
||
and approve each real deferred gap individually. Expansion modes retain their
|
||
expansion scan and opt-in ceremony.
|
||
|
||
Only unanswered TODO proposals reach this menu. Do not ask again about an item
|
||
already deferred, skipped or kept; carry its actual answer and destination forward.
|
||
Resolve each remaining proposal through all four steps of 0D, using the menu
|
||
below. Keep its full comparison, saved question/options, Read-back and actual
|
||
answer. Never batch TODOs — one per question. If none remain, record that and continue.
|
||
Follow the format in `~/.claude/skills/gstack/review/TODOS-format.md`.
|
||
|
||
For each TODO, describe:
|
||
* **What:** One-line description of the work.
|
||
* **Why:** The concrete problem it solves or value it unlocks.
|
||
* **Pros:** What you gain by doing this work.
|
||
* **Cons:** Cost, complexity, or risks of doing it.
|
||
* **Context:** Enough detail that someone picking this up in 3 months understands the motivation, the current state, and where to start.
|
||
* **Effort estimate:** Give separate human-team and CC+gstack S/M/L/XL labels.
|
||
For a rough backlog estimate, start with S→S, M→S, L→M, XL→L. These are size
|
||
categories, not time ratios. When work is decomposed into Implementation Tasks,
|
||
estimate hours/minutes using that section's task-type ratios and actual work;
|
||
use those estimates to refine the backlog labels.
|
||
* **Priority:** P1/P2/P3
|
||
* **Depends on / blocked by:** Any prerequisites or ordering constraints.
|
||
|
||
Then present options: **A)** Add to TODOS.md **B)** Skip — not valuable enough **C)** Keep in the current plan as required work, only when it is already part of accepted scope.
|
||
|
||
{{PLAN_REVIEW_APPROVAL_CHECK}}
|
||
|
||
## Required Outputs
|
||
|
||
Complete these three stages in order. They separate preparing review content from
|
||
announcing saved completion; no stage depends on a completion log written later.
|
||
|
||
### Stage 1 — Prepare the plan body and summary
|
||
|
||
Write the following sections, registries, diagrams, Markdown tasks and Completion
|
||
Summary in the working plan from approved changes. Keep them before the terminal
|
||
report. Task JSONL and approved TODOs use their specified paths, separate from the
|
||
0H CEO archive. The prepared summary supplies the report's current facts; it is
|
||
not yet a chat announcement of saved completion.
|
||
|
||
### Review facts
|
||
|
||
Derive facts from the approved ledger and completed sections: mode, findings,
|
||
unresolved choices, critical gaps, scope dispositions and each outside attempt's
|
||
coverage. Status is `clean` only with zero unresolved choices and critical gaps;
|
||
otherwise `issues_open`. No report or completion log is needed yet.
|
||
|
||
Use these facts in the Summary, report row and Review Log. Artifact cells stay
|
||
pending until confirmed writes, or not persisted when forbidden. A substantive
|
||
late decision repeats readiness and recomputes facts before refreshing outputs.
|
||
|
||
### "NOT in scope" section
|
||
List explicitly deferred and rejected work separately, with each actual answer
|
||
and one-line rationale. Deferred work also goes to TODOS.md; rejected work does not.
|
||
|
||
### "What already exists" section
|
||
List existing code/flows that partially solve sub-problems and whether the plan reuses them.
|
||
|
||
### "Dream state delta" section
|
||
Where this plan leaves us relative to the 12-month ideal.
|
||
|
||
### Error & Rescue Registry (from Section 2)
|
||
Match the approved review depth. For implementation-ready work, list every method
|
||
that can fail, its exception classes, rescue status/action and user impact.
|
||
For strategy-only work, use capability rows with failure mechanisms, user impact,
|
||
known safeguards, and an owner who must verify each unknown before implementation.
|
||
Do not invent method contracts. For one narrow decision, include only its dependencies.
|
||
|
||
### Failure Modes Registry
|
||
```
|
||
CODEPATH | FAILURE MODE | RESCUED? | TEST? | USER SEES? | LOGGED?
|
||
---------|----------------|----------|-------|----------------|--------
|
||
```
|
||
Any row with RESCUED=N, TEST=N, USER SEES=Silent → **CRITICAL GAP**.
|
||
For strategy-only rows, CODEPATH names the capability; mark unknown rescue/test
|
||
coverage as unknown and name the verification owner. Count capability rows in the
|
||
Completion Summary; implementation-ready reviews count method/codepath rows.
|
||
|
||
### Scope Expansion Decisions (EXPANSION and SELECTIVE EXPANSION only)
|
||
For EXPANSION and SELECTIVE EXPANSION, reference the CEO plan's full 0G scope record
|
||
under the storage policy. List its dispositions without asking again:
|
||
* Accepted: {list items added to scope}
|
||
* Deferred: {list items sent to TODOS.md}
|
||
* Skipped: {list items rejected}
|
||
|
||
### Diagrams (mandatory, produce all that apply)
|
||
1. System architecture
|
||
2. Data flow (including shadow paths)
|
||
3. State machine
|
||
4. Error flow
|
||
5. Deployment sequence
|
||
6. Rollback flowchart
|
||
|
||
### Stale Diagram Audit
|
||
List every ASCII diagram in files this plan touches. Still accurate?
|
||
|
||
{{TASKS_SECTION_EMIT:ceo-review}}
|
||
|
||
### Completion Summary
|
||
Fill this plan-body template from Review facts. Artifact outcomes stay pending
|
||
until writes are confirmed. Stage 3 publishes it after report verification;
|
||
forbidden writes stay labeled not persisted.
|
||
|
||
Use the full mode name from Step 0E; replace spaces with underscores only in the
|
||
review log's `MODE` field. "System Audit" summarizes repository findings from
|
||
Step 0 and the review sections. Compute "Lake Score" (complete options selected):
|
||
1. Select answered questions scored for coverage under 0D that offered a 10/10
|
||
option. Exclude unscored mode/scope choices and unanswered questions.
|
||
2. Count a reopened choice only once, using its latest answered option.
|
||
3. Y is the number of eligible questions; X is how many selected the 10/10
|
||
option. Report X/Y, or `N/A` when Y is zero.
|
||
|
||
```
|
||
+====================================================================+
|
||
| MEGA PLAN REVIEW — COMPLETION SUMMARY |
|
||
+====================================================================+
|
||
| Mode selected | [full mode name from Step 0E] |
|
||
| System Audit | [key findings] |
|
||
| Step 0 | [mode + key decisions] |
|
||
| Section 1 (Arch) | ___ issues found |
|
||
| Section 2 (Errors) | ___ error paths mapped, ___ GAPS |
|
||
| Section 3 (Security)| ___ issues found, ___ High severity |
|
||
| Section 4 (Data/UX) | ___ edge cases mapped, ___ unhandled |
|
||
| Section 5 (Quality) | ___ issues found |
|
||
| Section 6 (Tests) | Diagram produced, ___ gaps |
|
||
| Section 7 (Perf) | ___ issues found |
|
||
| Section 8 (Observ) | ___ gaps found |
|
||
| Section 9 (Deploy) | ___ risks flagged |
|
||
| Section 10 (Future) | Reversibility: _/5, debt items: ___ |
|
||
| Section 11 (Design) | ___ issues / SKIPPED (no UI scope) |
|
||
+--------------------------------------------------------------------+
|
||
| NOT in scope | written (___ items) |
|
||
| What already exists | written |
|
||
| Dream state delta | written |
|
||
| Error/rescue registry| ___ rows, ___ CRITICAL GAPS |
|
||
| Failure modes | ___ total, ___ CRITICAL GAPS |
|
||
| TODOS.md updates | ___ items proposed |
|
||
| Scope proposals | ___ proposed, ___ accepted (EXP + SEL) |
|
||
| CEO plan | written / not persisted / skipped by mode |
|
||
| Outside voice | provider + completed/unavailable/disabled/skipped |
|
||
| Lake Score | X/Y recommendations chose complete option |
|
||
| Diagrams produced | ___ (list types) |
|
||
| Stale diagrams found | ___ |
|
||
| Unresolved decisions | ___ (listed below) |
|
||
+====================================================================+
|
||
```
|
||
|
||
### Unresolved Decisions
|
||
If any AskUserQuestion goes unanswered, note it here. Never silently default.
|
||
|
||
### Stage 2 — Save and verify the terminal report
|
||
|
||
Use the prepared summary above, then follow this report procedure. Preserve the
|
||
complete body and summary before the report; no new body section follows it.
|
||
|
||
{{PLAN_FILE_REVIEW_REPORT}}
|
||
|
||
### Stage 3 — Publish the Completion Summary
|
||
|
||
**Publish the Completion Summary:** After the report Read-back gate passes, show
|
||
the prepared summary in chat with confirmed artifact outcomes. Do not append it
|
||
after the report in the file. If no plan/report write is permitted, show the
|
||
complete plan, report and summary as not persisted, then use **Gate outcome:
|
||
Blocked**. This delivers the review content without claiming saved completion;
|
||
skip Review Log, success telemetry and the next-skill handoff.
|
||
|
||
## Handoff Note Cleanup
|
||
|
||
After producing the Completion Summary, remove this branch's handoff notes only if the storage policy permits cleanup. Otherwise retain them and report that cleanup was not performed.
|
||
|
||
```bash
|
||
eval "$(~/.claude/skills/gstack/bin/gstack-paths)"; : "${GSTACK_STATE_ROOT:?gstack-paths failed; reinstall with ./setup or /gstack-upgrade}"
|
||
setopt +o nomatch 2>/dev/null || true # zsh compat
|
||
# gstack-slug prints both SLUG and BRANCH; eval sets them in this shell.
|
||
{{SLUG_EVAL}}
|
||
rm -f "$GSTACK_STATE_ROOT"/projects/$SLUG/*-$BRANCH-ceo-handoff-*.md 2>/dev/null || true
|
||
```
|
||
|
||
## Review Log
|
||
|
||
Attempt these history writes only after the plan/report's successful write and
|
||
Read-back. A failed plan/report save or verification stops before this block.
|
||
If metadata writes are forbidden, skip these commands and show their actual
|
||
fields in chat as **not persisted**.
|
||
|
||
Both history commands below are best-effort under Step 0's **Artifact outcomes**
|
||
policy. If one fails, retain its diagnostic, show its actual unsaved fields and
|
||
continue; do not claim that entry was recorded. Display the dashboard from saved
|
||
history, clearly identifying this run as unlogged when its review-log write failed
|
||
or was forbidden. This differs from 0H's required spec-metrics write.
|
||
This payload omits the dashboard's optional `plan_sha256`: use age for freshness
|
||
without claiming a content match when no hash was recorded.
|
||
|
||
Substitute these values from the Completion Summary before running the commands:
|
||
- **TIMESTAMP**: current UTC ISO 8601 datetime (e.g., 2026-03-16T14:30:00Z)
|
||
- **STATUS**: "clean" if 0 unresolved decisions AND 0 critical gaps; otherwise "issues_open"
|
||
- **unresolved**: number from "Unresolved decisions" in the summary
|
||
- **critical_gaps**: number from "Failure modes: ___ CRITICAL GAPS" in the summary
|
||
- **MODE**: the mode the user selected (SCOPE_EXPANSION / SELECTIVE_EXPANSION / HOLD_SCOPE / SCOPE_REDUCTION)
|
||
- **scope_proposed**: number from "Scope proposals: ___ proposed" in the summary (0 for HOLD/REDUCTION)
|
||
- **scope_accepted**: number from "Scope proposals: ___ accepted" in the summary (0 for HOLD/REDUCTION)
|
||
- **scope_deferred**: number of items deferred to TODOS.md from scope decisions (0 for HOLD/REDUCTION)
|
||
- **COMMIT**: output of `git rev-parse --short HEAD`
|
||
|
||
The second command records the accepted scope so later sessions can reuse it.
|
||
Substitute `SCOPE_SUMMARY` (e.g. "accepted 4 of 6 proposals", "held scope" or
|
||
"cut 3 items") and `VERDICT` (the summary's one-line verdict).
|
||
|
||
```bash
|
||
~/.claude/skills/gstack/bin/gstack-review-log '{"skill":"plan-ceo-review","timestamp":"TIMESTAMP","status":"STATUS","unresolved":N,"critical_gaps":N,"mode":"MODE","scope_proposed":N,"scope_accepted":N,"scope_deferred":N,"commit":"COMMIT"}' || { _CEO_LOG_EXIT=$?; echo "Review history not persisted (exit $_CEO_LOG_EXIT)." >&2; }
|
||
~/.claude/skills/gstack/bin/gstack-decision-log '{"decision":"CEO review (MODE): SCOPE_SUMMARY","rationale":"VERDICT","scope":"branch","source":"skill","confidence":8}' || { _CEO_DECISION_EXIT=$?; echo "Decision history not persisted (exit $_CEO_DECISION_EXIT)." >&2; }
|
||
```
|
||
|
||
{{REVIEW_DASHBOARD}}
|
||
|
||
## Next Steps — Review Chaining
|
||
|
||
After displaying the Review Readiness Dashboard, recommend the next review(s) based on what this CEO review discovered. Read the dashboard output to see which reviews have already been run and whether they are stale.
|
||
|
||
**Recommend /plan-eng-review if eng review is not skipped globally** — check the dashboard output for `skip_eng_review`. If it is `true`, eng review is opted out — do not recommend it. Otherwise, eng review is the required shipping gate. If this CEO review expanded scope, changed architectural direction, or accepted scope expansions, emphasize that a fresh eng review is needed. If an eng review already exists in the dashboard but the commit hash shows it predates this CEO review, note that it may be stale and should be re-run.
|
||
|
||
**Recommend /plan-design-review if UI scope was detected** — specifically if Section 11 (Design & UX Review) was NOT skipped, or if accepted scope expansions included UI-facing features. If an existing design review is stale (commit hash drift), note that. In SCOPE REDUCTION mode, skip this recommendation — design review is unlikely relevant for scope cuts.
|
||
|
||
**If both are needed, recommend eng review first** (required gate), then design review.
|
||
|
||
Use AskUserQuestion to present the next step. Include only applicable options:
|
||
- **A)** Run /plan-eng-review next (required gate)
|
||
- **B)** Run /plan-design-review next (only if UI scope detected)
|
||
- **C)** Skip — I'll handle reviews manually
|
||
|
||
## docs/designs Promotion (EXPANSION and SELECTIVE EXPANSION only)
|
||
|
||
At the end of the review, if the vision produced a compelling feature direction, offer to promote the CEO plan to the project repo. AskUserQuestion:
|
||
|
||
"The vision from this review produced {N} accepted scope expansions. Want to promote it to a design doc in the repo?"
|
||
- **A)** Promote to `docs/designs/{FEATURE}.md` (committed to repo, visible to the team)
|
||
- **B)** Keep in `~/.gstack/projects/` only (local, personal reference)
|
||
- **C)** Skip
|
||
|
||
If promoted and those writes are permitted, copy the CEO plan content to `docs/designs/{FEATURE}.md` (create the directory if needed) and update the original CEO plan's `status` from `ACTIVE` to `PROMOTED`. Otherwise present the proposed design document in chat, marked not persisted; do not claim promotion occurred.
|
||
|
||
## Learnings and brain write-back
|
||
|
||
Finish these review tasks without changing the plan. Then return to
|
||
this skill's main `SKILL.md` at **Section self-check** for terminal verification.
|
||
Success telemetry and exit happen there.
|
||
|
||
{{LEARNINGS_LOG}}
|
||
|
||
{{GBRAIN_SAVE_RESULTS}}
|
||
|
||
{{BRAIN_WRITE_BACK}}
|
||
|
||
Return to this skill's main `SKILL.md`: Section self-check → EXIT PLAN MODE GATE.
|