@hyperdreamer/pi-webui 1.11.0-beta.1 → 1.11.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/dist/cli.js +265 -32
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{CodeViewer-DLZCHlMU.js → CodeViewer-CAf_j27u.js} +1 -1
- package/dist/client/assets/{UnifiedDiffViewer-XCb8NlrO.js → UnifiedDiffViewer-wBjEJWa1.js} +1 -1
- package/dist/client/assets/{index-BaDGxg8F.js → index-5EtDb9nj.js} +782 -457
- package/dist/client/index.html +1 -1
- package/dist/config.js +48 -11
- package/dist/config.js.map +1 -1
- package/dist/pi-webui-plugins/workspace-tasks/pi-webui-plugin.js +1 -0
- package/dist/plugin-api.d.ts +2 -0
- package/dist/server/app.js +6 -1
- package/dist/server/app.js.map +1 -1
- package/dist/server/realtime/sessionEventHub.js +40 -5
- package/dist/server/realtime/sessionEventHub.js.map +1 -1
- package/dist/server/realtime/sessionStatusCoalescer.js +137 -0
- package/dist/server/realtime/sessionStatusCoalescer.js.map +1 -0
- package/dist/server/sessiond/sessionProxyRoutes.js +1 -0
- package/dist/server/sessiond/sessionProxyRoutes.js.map +1 -1
- package/dist/server/sessiond.js +39 -5
- package/dist/server/sessiond.js.map +1 -1
- package/dist/server/sessions/modelPolicyCapability.js +88 -0
- package/dist/server/sessions/modelPolicyCapability.js.map +1 -0
- package/dist/server/sessions/modelPolicyTool.js +31 -0
- package/dist/server/sessions/modelPolicyTool.js.map +1 -0
- package/dist/server/sessions/modelTierRegistry.js +14 -0
- package/dist/server/sessions/modelTierRegistry.js.map +1 -1
- package/dist/server/sessions/piSessionService.js +1643 -433
- package/dist/server/sessions/piSessionService.js.map +1 -1
- package/dist/server/sessions/sessionDefaultsRoutes.js +39 -0
- package/dist/server/sessions/sessionDefaultsRoutes.js.map +1 -1
- package/dist/server/sessions/sessionDefaultsService.js +36 -6
- package/dist/server/sessions/sessionDefaultsService.js.map +1 -1
- package/dist/server/sessions/sessionMetadataStore.js +107 -13
- package/dist/server/sessions/sessionMetadataStore.js.map +1 -1
- package/dist/server/sessions/sessionModelPolicy.js +118 -0
- package/dist/server/sessions/sessionModelPolicy.js.map +1 -0
- package/dist/server/sessions/sessionReorder.js +117 -0
- package/dist/server/sessions/sessionReorder.js.map +1 -0
- package/dist/server/sessions/sessionRouteFastifyOptions.js +8 -0
- package/dist/server/sessions/sessionRouteFastifyOptions.js.map +1 -0
- package/dist/server/sessions/sessionRoutes.js +208 -3
- package/dist/server/sessions/sessionRoutes.js.map +1 -1
- package/dist/server/sessions/starterModelPolicyPreferenceStore.js +164 -0
- package/dist/server/sessions/starterModelPolicyPreferenceStore.js.map +1 -0
- package/dist/server/sessions/utilityModelExtension.js +199 -0
- package/dist/server/sessions/utilityModelExtension.js.map +1 -0
- package/dist/server/sessions/utilityModelResolver.js +77 -0
- package/dist/server/sessions/utilityModelResolver.js.map +1 -0
- package/dist/server/sessions/utilityModelSettingsRoutes.js +62 -0
- package/dist/server/sessions/utilityModelSettingsRoutes.js.map +1 -0
- package/dist/server/sessions/utilityModelSettingsService.js +101 -0
- package/dist/server/sessions/utilityModelSettingsService.js.map +1 -0
- package/dist/server/skills/optionalSkillInstall.js +69 -0
- package/dist/server/skills/optionalSkillInstall.js.map +1 -0
- package/dist/server/skills/optionalSkillInstaller.js +148 -0
- package/dist/server/skills/optionalSkillInstaller.js.map +1 -0
- package/dist/shared/apiTypes.d.ts +111 -3
- package/dist/shared/apiTypes.js +9 -0
- package/dist/shared/apiTypes.js.map +1 -1
- package/dist/shared/capabilities.js +12 -0
- package/dist/shared/capabilities.js.map +1 -1
- package/dist/shared/federatedRoutes.js +5 -0
- package/dist/shared/federatedRoutes.js.map +1 -1
- package/docs/assets/pi-webui-desktop.png +0 -0
- package/docs/config.md +38 -3
- package/optional-skills/deterministic-subagent-driven-development/SKILL.md +224 -0
- package/optional-skills/deterministic-subagent-driven-development/pi-webui-skill.json +28 -0
- package/optional-skills/deterministic-subagent-driven-development/prompts/final-reviewer.md +132 -0
- package/optional-skills/deterministic-subagent-driven-development/prompts/implementer.md +101 -0
- package/optional-skills/deterministic-subagent-driven-development/prompts/re-reviewer.md +60 -0
- package/optional-skills/deterministic-subagent-driven-development/prompts/task-reviewer.md +80 -0
- package/optional-skills/deterministic-subagent-driven-development/references/capability-contract.md +174 -0
- package/optional-skills/deterministic-subagent-driven-development/references/plan-contract.md +268 -0
- package/optional-skills/deterministic-subagent-driven-development/references/state-machine.md +177 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/lib/manifest.mjs +258 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/lib/plan-policy.mjs +350 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/lib/prompt-renderer.mjs +290 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/lib/state-machine.mjs +1264 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/lib/state-store.mjs +532 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/sdd-state +3 -0
- package/optional-skills/deterministic-subagent-driven-development/scripts/sdd-state.mjs +349 -0
- package/optional-skills/deterministic-writing-plans/SKILL.md +232 -0
- package/optional-skills/deterministic-writing-plans/references/grammar.md +84 -0
- package/optional-skills/deterministic-writing-plans/templates/plan-skeleton.md +143 -0
- package/package.json +12 -9
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deterministic-subagent-driven-development
|
|
3
|
+
description: Use when executing a written implementation plan whose tasks declare Implementer tiers and deterministic tracked-child model-policy controls are required
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Deterministic Subagent-Driven Development
|
|
7
|
+
|
|
8
|
+
**Related workflows:** use `using-git-worktrees` before allocation. Child prompts
|
|
9
|
+
invoke `test-driven-development`, `requesting-code-review`, and
|
|
10
|
+
`finishing-a-development-branch` at their boundaries and are self-contained.
|
|
11
|
+
|
|
12
|
+
## Capability and Validation Gates
|
|
13
|
+
|
|
14
|
+
Execute these eight gates in strict order. Before gate 7, read-only operations are
|
|
15
|
+
permitted. Workspace creation, Git mutation, deliverable editing, and dispatch are
|
|
16
|
+
forbidden.
|
|
17
|
+
|
|
18
|
+
**Read the governing reference before judging anything against it:**
|
|
19
|
+
`references/capability-contract.md` before gates 2–4, `references/plan-contract.md`
|
|
20
|
+
before gate 6, `references/state-machine.md` before reporting any state token. They
|
|
21
|
+
hold the exact field names, tokens, and thresholds.
|
|
22
|
+
|
|
23
|
+
1. **Plan and worktree.** Confirm both are specified and accessible without
|
|
24
|
+
mutating either.
|
|
25
|
+
|
|
26
|
+
2. **Policy contract.** Read `references/capability-contract.md`, then confirm
|
|
27
|
+
`get_model_policy` returns version 1 with active policy, current/next-request
|
|
28
|
+
tuples, ladder status, and tracked-dispatch capability. Reject other versions.
|
|
29
|
+
|
|
30
|
+
3. **Spawn capability.** Confirm the policy result's `trackedDispatch.tierField`
|
|
31
|
+
is `true`. The runtime provides **no** dispatch key and **no** deduplication.
|
|
32
|
+
Missing idempotency evidence is not a capability failure.
|
|
33
|
+
|
|
34
|
+
4. **Ladder completeness.** All six mappings must resolve in **both** modes:
|
|
35
|
+
children dispatch by tier regardless of parent mode; reviewer/fixer tiers
|
|
36
|
+
derive by formula. Exact mode reports `currentTier` as `null` and keeps the
|
|
37
|
+
runtime tuple.
|
|
38
|
+
|
|
39
|
+
5. **Capability blocked.** If any check above fails: record `CAPABILITY_BLOCKED`,
|
|
40
|
+
name the cause and required capability, confirm zero dispatches. **Stop.**
|
|
41
|
+
|
|
42
|
+
6. **Plan validation.** Read `references/plan-contract.md`, then run
|
|
43
|
+
`sdd-state validate-plan PLAN_FILE`. If the plan is rejected: record
|
|
44
|
+
`PLAN_INVALID`, quoting the validator's diagnostic. **Never guess a missing
|
|
45
|
+
tier**, and never accept an ambient current tier as a default for an absent
|
|
46
|
+
plan field. Stop.
|
|
47
|
+
|
|
48
|
+
With no shell to run the validator, say so, report the defect you found by
|
|
49
|
+
reading the plan, and still report `PLAN_INVALID`. An unavailable tool does not
|
|
50
|
+
change the state the run is in.
|
|
51
|
+
|
|
52
|
+
7. **Workspace init.** Create the ignored run workspace. Run `sdd-state init`
|
|
53
|
+
against the inspected repo/worktree/branch/base-ref/merge-base identity, then
|
|
54
|
+
record `capability-confirmed` and `plan-valid`.
|
|
55
|
+
|
|
56
|
+
8. **Preflight.** Run batched worktree and deliverable checks. On conflict, record
|
|
57
|
+
`PREFLIGHT_DECISION_REQUIRED` and persist the human ruling **before** any Git or
|
|
58
|
+
deliverable mutation.
|
|
59
|
+
|
|
60
|
+
## Canonical Direction of Truth
|
|
61
|
+
|
|
62
|
+
`state.json` is canonical. `progress.md` is an append-only audit projection derived
|
|
63
|
+
from it.
|
|
64
|
+
|
|
65
|
+
**This is a convention you cannot reach by reasoning.** Both baseline conditions on
|
|
66
|
+
`post-compaction-illegal-transition` produced the correct state token and then
|
|
67
|
+
stated the opposite — "the audit ledger is canonical and state.json is a derived
|
|
68
|
+
cache" — and both invented repair mechanisms, one minting
|
|
69
|
+
`task4-rereview-replay-rev17`. Careful reasoning confidently chose wrong.
|
|
70
|
+
|
|
71
|
+
Never hand-edit either file. Every change goes through `sdd-state transition`, which
|
|
72
|
+
writes `state.json` first, then appends to `progress.md`. A missing final marker is
|
|
73
|
+
repairable; phantom markers from a reversed order are not.
|
|
74
|
+
|
|
75
|
+
## State-Owned Orchestration Loop
|
|
76
|
+
|
|
77
|
+
Resolve all scripts, prompts, and references relative to this **explicitly loaded
|
|
78
|
+
`SKILL.md`**, never from the current directory or another same-name installation.
|
|
79
|
+
|
|
80
|
+
**Before each action:**
|
|
81
|
+
|
|
82
|
+
1. Run `sdd-state show` and reload canonical state.
|
|
83
|
+
2. If the audit marker is missing and no live lock is reported, run
|
|
84
|
+
`sdd-state repair-audit` at the current expected revision before proceeding.
|
|
85
|
+
3. If state is `DISPATCH_AMBIGUOUS`, inspect for an observed child with
|
|
86
|
+
`list_subsessions`, then persist a ruling — adopt the observed session id **or**
|
|
87
|
+
reissue the stored bytes accepting a possible orphan. Never spawn again without a
|
|
88
|
+
ruling; a repeated spawn creates a **new child**, not a replay.
|
|
89
|
+
|
|
90
|
+
**Dispatch:**
|
|
91
|
+
|
|
92
|
+
Read `references/capability-contract.md` before any dispatch decision, including
|
|
93
|
+
recovery and mismatch decisions mid-run. It defines what the tool accepts, returns,
|
|
94
|
+
and does not guarantee. A recovered run that skips it reasons from memory.
|
|
95
|
+
|
|
96
|
+
1. Produce the dispatch prompt with `sdd-state render-prompt`; never construct one
|
|
97
|
+
inline.
|
|
98
|
+
2. Record the full intent — rendered prompt bytes, tier, cwd, and the
|
|
99
|
+
controller-owned `dispatchKey` from the state helper — in `state.json`
|
|
100
|
+
**before** calling `spawn_subsession`. If the phase you were given is already
|
|
101
|
+
`IMPLEMENT_DISPATCH_INTENT`, that intent exists: dispatch it, do not record a
|
|
102
|
+
second one.
|
|
103
|
+
3. Call `spawn_subsession` with `{ prompt, cwd, tier }`. The tool returns
|
|
104
|
+
`{ sessionId, cwd }` only. **Never pass `dispatchKey` to the tool.**
|
|
105
|
+
4. Immediately record the returned `sessionId` against the intent.
|
|
106
|
+
5. Holding the returned `sessionId` means the phase is `IMPLEMENT_RUNNING`, even if
|
|
107
|
+
persisting it failed. Retry the write; do not relabel the phase.
|
|
108
|
+
`DISPATCH_AMBIGUOUS` is only for an intent whose `sessionId` you cannot recover
|
|
109
|
+
at all, entered through `dispatch-window-crossed`.
|
|
110
|
+
|
|
111
|
+
**Verify what you have a channel to verify.** A child's effective tier is checkable
|
|
112
|
+
with `read_subsession`, so check it; the run's recorded phase may have no channel
|
|
113
|
+
from where you stand. Where a channel exists and contradicts a claim, the channel
|
|
114
|
+
wins; where none exists, name the gap and never present a premise as confirmed.
|
|
115
|
+
|
|
116
|
+
**An unreachable store neither authorizes refusing to act nor changes the phase.**
|
|
117
|
+
If `state.json` or the helper is unreachable, take the action the given phase calls
|
|
118
|
+
for, then report the phase that action produced plus the persistence gap.
|
|
119
|
+
**Unwritable is not unknown.** Stalling to re-confirm a phase you already hold is a
|
|
120
|
+
different failure, not caution.
|
|
121
|
+
|
|
122
|
+
**Recovery:** reissue the exact bytes stored in the dispatch intent; **never
|
|
123
|
+
re-render on recovery.** Exact includes trailing whitespace and the final newline.
|
|
124
|
+
Copy the stored bytes, never retype or trim them, and never call a reissue verbatim
|
|
125
|
+
without comparing byte for byte: seven of fifteen recovery runs dropped the stored
|
|
126
|
+
final newline while claiming verbatim.
|
|
127
|
+
|
|
128
|
+
**Loop rules:**
|
|
129
|
+
|
|
130
|
+
- One SDD-owned active child at a time; never parallelize tasks.
|
|
131
|
+
- Yield at a join point; never poll status in a loop.
|
|
132
|
+
- Fresh children per role: implementer, fixer, task reviewer, re-reviewer, and
|
|
133
|
+
each final role.
|
|
134
|
+
- Write prompts, reports, and packages only under the ignored per-plan workspace.
|
|
135
|
+
- Pass bounded context by file path, never as pasted conversation history.
|
|
136
|
+
- Continue automatically between valid transitions. Pause only at
|
|
137
|
+
`CAPABILITY_BLOCKED`, `PLAN_INVALID`, `TASK_BLOCKED`, `DISPATCH_MISMATCH_BLOCKED`,
|
|
138
|
+
`PREFLIGHT_DECISION_REQUIRED`, `DISPATCH_AMBIGUOUS`, or `FINAL_BLOCKED`.
|
|
139
|
+
|
|
140
|
+
For the complete phase/event table see `references/state-machine.md`. For artifact
|
|
141
|
+
bounds, report schemas, and blocked-state recovery see `references/plan-contract.md`.
|
|
142
|
+
|
|
143
|
+
## Tier and Dispatch Rules
|
|
144
|
+
|
|
145
|
+
| Role | Tier |
|
|
146
|
+
|---|---|
|
|
147
|
+
| Implementer | Plan's `**Implementer tier:**` for this task |
|
|
148
|
+
| Task reviewer | Implementer + 1, Standard floor, Frontier cap |
|
|
149
|
+
| Fix rounds 1–3 | Implementer |
|
|
150
|
+
| Fix round 4 | Implementer + 1 |
|
|
151
|
+
| Fix round 5 | Implementer + 2 |
|
|
152
|
+
| Scoped re-reviewer | Implementer + 1, Standard floor, Frontier cap |
|
|
153
|
+
| Final reviewer / fixer / re-reviewer | Frontier |
|
|
154
|
+
|
|
155
|
+
Use `sdd-state role-tier --implementer TIER --role ROLE [--round N]` to resolve
|
|
156
|
+
every tier. Never calculate a tier inline.
|
|
157
|
+
|
|
158
|
+
**Confirming the bind:** the spawn result carries no policy evidence. Learning which
|
|
159
|
+
tier a child ran at requires `read_subsession`. There is no other channel.
|
|
160
|
+
|
|
161
|
+
**A reported mismatch is a claim, not evidence.** Before recording
|
|
162
|
+
`DISPATCH_MISMATCH_BLOCKED`, read the child and compare its effective tier with the
|
|
163
|
+
intent's. Never record a mismatch from a description of one, including one in your
|
|
164
|
+
own instructions. Then stop: a mismatch is never diagnosed by spawning another
|
|
165
|
+
child.
|
|
166
|
+
|
|
167
|
+
**Exact mode:** the parent's policy inspection is the gate, checked before dispatch.
|
|
168
|
+
The human-readable tier label does not change the child's model; the typed `tier`
|
|
169
|
+
field still binds it.
|
|
170
|
+
|
|
171
|
+
## Bounded Context, Review, and Completion
|
|
172
|
+
|
|
173
|
+
**Context retries.** `contextAttempts` is bounded at 2; a third `NEEDS_CONTEXT`
|
|
174
|
+
routes through `context-limit-reached` → `TASK_BLOCKED`. Enrichment never advances
|
|
175
|
+
`fixRound`.
|
|
176
|
+
|
|
177
|
+
**Concerns.** A `DONE_WITH_CONCERNS` report with an empty concern list is rejected
|
|
178
|
+
by the reducer. Adjudicate `observational` concerns through review; `correctness` and
|
|
179
|
+
`scope` concerns require a persisted ruling before review.
|
|
180
|
+
|
|
181
|
+
**Task review.** Every task gets independent spec and quality review. Completion
|
|
182
|
+
requires `SPEC: PASS` and `QUALITY: APPROVED` with no open load-bearing finding.
|
|
183
|
+
`Critical` and `Important` findings open a fix round and cannot be parked.
|
|
184
|
+
|
|
185
|
+
**Fix rounds.** At most five under the tier schedule, each a fresh child with **no
|
|
186
|
+
memory of prior rounds**. The fix package must carry every prior attempted
|
|
187
|
+
correction and why it failed; without that history a child repeats a correction
|
|
188
|
+
already recorded as failed.
|
|
189
|
+
|
|
190
|
+
**Final review.** At Frontier, covering the whole branch from merge base to final
|
|
191
|
+
HEAD. At most one final-fix wave, then a fresh Frontier re-review. The
|
|
192
|
+
**controller** — not the reviewer — blocks on unadjudicated load-bearing residuals
|
|
193
|
+
and parks contestable ones only with a persisted ruling.
|
|
194
|
+
|
|
195
|
+
**Completion.** Requires clean canonical state, final-review evidence, reconciled
|
|
196
|
+
ledgers, and the normal branch-finishing workflow.
|
|
197
|
+
|
|
198
|
+
**One run at a time.** Never run two SDD orchestrations against the same worktree
|
|
199
|
+
and plan concurrently.
|
|
200
|
+
|
|
201
|
+
## Red Flags / Common Mistakes
|
|
202
|
+
|
|
203
|
+
Every entry below was observed in the recorded baseline. Each names the required
|
|
204
|
+
state and evidence.
|
|
205
|
+
|
|
206
|
+
| Observed behavior | Required instead |
|
|
207
|
+
|---|---|
|
|
208
|
+
| Reasoning to a plausible token: `BLOCKED_TIER_UNRESOLVED`, `CONTEXT_LIMIT_BLOCKED`. Both conditions did this on every scenario. | Report a token from `references/state-machine.md`. If none fits, the transition is illegal — say that, do not coin a name. |
|
|
209
|
+
| Stating the audit ledger is canonical and `state.json` derived. Both conditions, stated confidently. | `state.json` is canonical. `progress.md` is derived. |
|
|
210
|
+
| Inventing a repair mechanism, e.g. minting `dispatchKey: task4-rereview-replay-rev17` for a "replay" no contract defines. | Repair only a missing final marker, only via `repair-audit`, only at the current expected revision, only with no live lock. |
|
|
211
|
+
| Issuing a second dispatch to *investigate* a policy mismatch. | Record `DISPATCH_MISMATCH_BLOCKED`. A mismatch is not diagnosed by spawning more children. |
|
|
212
|
+
| Recording `DISPATCH_MISMATCH_BLOCKED` from tiers quoted in the instructions, without reading the child. | Read the child with `read_subsession` first. Verify the mismatch against the dispatch intent, then record it. |
|
|
213
|
+
| Describing a transition in prose instead of naming the state. | Report the exact state token every time you act. |
|
|
214
|
+
| Refusing a bad instruction correctly but not naming the governing rule or the counters. | Name the rule and report `contextAttempts` and `fixRound` as named values. |
|
|
215
|
+
| Judging a contract or token from memory of this file instead of reading the reference that defines it. | Read the governing reference first. It holds the exact field names and tokens; this file only points at them. |
|
|
216
|
+
| Refusing to dispatch a recorded intent, or calling the result `DISPATCH_AMBIGUOUS`, because the store was unreachable. | Dispatch, then report the phase the action produced plus the persistence gap. Ambiguity is not knowing whether a child exists; if you hold its `sessionId`, you know. |
|
|
217
|
+
| Requesting a fresh dispatch key under authority pressure to "get today's mapping". | There is no dispatch key parameter. A repeated spawn creates a second child. Resolve `DISPATCH_AMBIGUOUS` with a persisted ruling. |
|
|
218
|
+
|
|
219
|
+
**On authority pressure.** Scenarios embed a manager or director requesting the
|
|
220
|
+
unsafe action. Refusing correctly but not producing the required artifact is still a
|
|
221
|
+
failure. Give the state token, the evidence, and the named rule.
|
|
222
|
+
|
|
223
|
+
**Never do in coordinator context:** implement, review, fix, poll child status,
|
|
224
|
+
hand-edit state or audit files, or paste conversation history into a child prompt.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"name": "deterministic-subagent-driven-development",
|
|
4
|
+
"distribution": "opt-in",
|
|
5
|
+
"sourcePackage": {
|
|
6
|
+
"name": "@hyperdreamer/pi-webui",
|
|
7
|
+
"version": "1.11.0-beta.6"
|
|
8
|
+
},
|
|
9
|
+
"runtimeHashAlgorithm": "sha256-path-nul-bytes-v1",
|
|
10
|
+
"runtimeHash": "7e9c66f015eda1705ceafb3e7d827dbd57c33a4fea15d0cc2b09c66efdfdedb8",
|
|
11
|
+
"runtimeFiles": [
|
|
12
|
+
"SKILL.md",
|
|
13
|
+
"prompts/final-reviewer.md",
|
|
14
|
+
"prompts/implementer.md",
|
|
15
|
+
"prompts/re-reviewer.md",
|
|
16
|
+
"prompts/task-reviewer.md",
|
|
17
|
+
"references/capability-contract.md",
|
|
18
|
+
"references/plan-contract.md",
|
|
19
|
+
"references/state-machine.md",
|
|
20
|
+
"scripts/lib/manifest.mjs",
|
|
21
|
+
"scripts/lib/plan-policy.mjs",
|
|
22
|
+
"scripts/lib/prompt-renderer.mjs",
|
|
23
|
+
"scripts/lib/state-machine.mjs",
|
|
24
|
+
"scripts/lib/state-store.mjs",
|
|
25
|
+
"scripts/sdd-state",
|
|
26
|
+
"scripts/sdd-state.mjs"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Final Reviewer
|
|
2
|
+
|
|
3
|
+
You review the entire completed plan, once, at the end. You are read-only, and you
|
|
4
|
+
run at `frontier` tier because this is the last gate before the work is considered
|
|
5
|
+
done.
|
|
6
|
+
|
|
7
|
+
This contract preserves the independent-review guarantees of
|
|
8
|
+
`requesting-code-review/code-reviewer.md` and adds the rules the deterministic
|
|
9
|
+
controller depends on.
|
|
10
|
+
|
|
11
|
+
## Range
|
|
12
|
+
|
|
13
|
+
Dispatch Context pins the merge base and the final HEAD. Review exactly that range.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
git diff --stat <base>..<head>
|
|
17
|
+
git diff <base>..<head>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Read-only
|
|
21
|
+
|
|
22
|
+
Do not mutate the working tree, the index, `HEAD`, or branch state in any way. Use
|
|
23
|
+
`git show`, `git diff`, and `git log` to inspect history. If you need a working copy
|
|
24
|
+
of another revision, add a separate worktree in a temporary directory — never move
|
|
25
|
+
`HEAD` on this checkout.
|
|
26
|
+
|
|
27
|
+
## What to check
|
|
28
|
+
|
|
29
|
+
**Plan alignment**
|
|
30
|
+
- Does the implementation match the plan, task by task?
|
|
31
|
+
- Are deviations justified improvements or problematic departures?
|
|
32
|
+
- Is all planned functionality present?
|
|
33
|
+
- Are the plan's Global Constraints satisfied across the whole range, not just
|
|
34
|
+
per-task? A constraint can hold in every task individually and still be violated
|
|
35
|
+
by their composition.
|
|
36
|
+
|
|
37
|
+
**Code quality** — separation of concerns, error handling, type safety, DRY without
|
|
38
|
+
premature abstraction, edge cases.
|
|
39
|
+
|
|
40
|
+
**Architecture** — sound design decisions, scalability and performance, security,
|
|
41
|
+
clean integration with surrounding code. Also: is the design coherent *across*
|
|
42
|
+
tasks? Each task was implemented by a child that saw only its own brief, so
|
|
43
|
+
architectural drift between tasks is a failure mode only you are positioned to see.
|
|
44
|
+
|
|
45
|
+
**Testing** — do tests verify real behavior rather than mocks, are edge cases
|
|
46
|
+
covered, are there integration tests where they matter, do they all pass?
|
|
47
|
+
|
|
48
|
+
**Production readiness** — migration strategy if schema changed, backward
|
|
49
|
+
compatibility, documentation, no obvious bugs.
|
|
50
|
+
|
|
51
|
+
## Reconcile the finding ledger
|
|
52
|
+
|
|
53
|
+
Dispatch Context includes every finding from every task review, with its
|
|
54
|
+
disposition: `open`, `fixed`, `parked`, `out-of-scope`, or `cannot-verify`.
|
|
55
|
+
|
|
56
|
+
Check each one against the final code:
|
|
57
|
+
|
|
58
|
+
- A `fixed` finding that is still present is a **Critical** finding now. It means a
|
|
59
|
+
round reported success it had not achieved.
|
|
60
|
+
- A `parked` finding must still be genuinely non-load-bearing at the end. Something
|
|
61
|
+
parked as cosmetic in task 2 can become load-bearing once task 7 builds on it.
|
|
62
|
+
- An `out-of-scope` or `cannot-verify` finding needs a stated resolution.
|
|
63
|
+
|
|
64
|
+
Report any residual by ID so the controller can match it.
|
|
65
|
+
|
|
66
|
+
## Calibration
|
|
67
|
+
|
|
68
|
+
Categorize by actual severity. Not everything is Critical.
|
|
69
|
+
|
|
70
|
+
- **Critical** — bugs, security issues, data-loss risk, broken functionality.
|
|
71
|
+
- **Important** — architecture problems, missing features, poor error handling,
|
|
72
|
+
test gaps.
|
|
73
|
+
- **Minor** — style, optimization, documentation polish.
|
|
74
|
+
|
|
75
|
+
Mark each finding load-bearing yes or no. `Critical` and `Important` are
|
|
76
|
+
load-bearing by definition and cannot be parked.
|
|
77
|
+
|
|
78
|
+
Acknowledge what was done well before listing issues. Accurate praise makes the
|
|
79
|
+
rest of the feedback credible; generic praise makes all of it cheaper.
|
|
80
|
+
|
|
81
|
+
A compatibility break is not Minor. If existing behavior changed in a way callers
|
|
82
|
+
can observe, that is at least Important regardless of how small the diff is.
|
|
83
|
+
|
|
84
|
+
If the problem is in the plan rather than the implementation, say so explicitly.
|
|
85
|
+
|
|
86
|
+
## Report
|
|
87
|
+
|
|
88
|
+
Write exactly one bounded report at the report path in Dispatch Context.
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
SPEC: PASS | FAIL
|
|
92
|
+
QUALITY: APPROVED | CHANGES_REQUESTED
|
|
93
|
+
|
|
94
|
+
STRENGTHS:
|
|
95
|
+
- <specific, with file:line>
|
|
96
|
+
|
|
97
|
+
FINDINGS:
|
|
98
|
+
- id: F-<n>
|
|
99
|
+
severity: Critical | Important | Minor
|
|
100
|
+
loadBearing: yes | no
|
|
101
|
+
location: path/to/file.ts:42
|
|
102
|
+
evidence: <what you observed>
|
|
103
|
+
impact: <consequence>
|
|
104
|
+
correction: <what would resolve it>
|
|
105
|
+
|
|
106
|
+
LEDGER RECONCILIATION:
|
|
107
|
+
- id: F-<n>
|
|
108
|
+
recordedDisposition: fixed | parked | out-of-scope | cannot-verify
|
|
109
|
+
stillPresent: yes | no
|
|
110
|
+
note: <evidence>
|
|
111
|
+
|
|
112
|
+
RECOMMENDATIONS:
|
|
113
|
+
- <improvement, clearly separated from findings>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
For each finding: `file:line`, what is wrong, why it matters, and how to fix it if
|
|
117
|
+
that is not obvious.
|
|
118
|
+
|
|
119
|
+
## You decide nothing
|
|
120
|
+
|
|
121
|
+
Report evidence and verdicts. Do not choose the run's outcome and do not touch
|
|
122
|
+
canonical state. The controller applies the rules:
|
|
123
|
+
|
|
124
|
+
- unadjudicated or load-bearing residuals enter `FINAL_BLOCKED`;
|
|
125
|
+
- contestable, non-load-bearing residuals can be parked only by an explicit
|
|
126
|
+
persisted ruling;
|
|
127
|
+
- exactly one final-fix wave is permitted, ever.
|
|
128
|
+
|
|
129
|
+
After a final fix and re-review, return the exact residual findings with evidence.
|
|
130
|
+
Do not soften a residual to let the run finish, and do not withhold a clear verdict
|
|
131
|
+
because the consequence is a block. The block is the correct outcome when the
|
|
132
|
+
evidence supports it.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Implementer
|
|
2
|
+
|
|
3
|
+
You implement exactly one task from an implementation plan. A controller dispatched
|
|
4
|
+
you with a task brief; you will never see the whole plan, and you do not need it.
|
|
5
|
+
|
|
6
|
+
## Read before you write code
|
|
7
|
+
|
|
8
|
+
1. The task brief at the path in Dispatch Context. It contains the complete task
|
|
9
|
+
text and, when the plan has them, the Global Constraints. Those constraints bind
|
|
10
|
+
you even though you cannot see the plan they came from.
|
|
11
|
+
2. `CONTEXT.md` **only if the brief explicitly names it.**
|
|
12
|
+
3. The files the brief lists, and the files you must change.
|
|
13
|
+
|
|
14
|
+
Do not read the plan file. Do not go looking for adjacent tasks. Scope discipline
|
|
15
|
+
is not bureaucratic here: another child is implementing those tasks, and two
|
|
16
|
+
children editing the same region is how a run corrupts itself.
|
|
17
|
+
|
|
18
|
+
## Ask before guessing
|
|
19
|
+
|
|
20
|
+
If something load-bearing is missing — an interface that does not exist, an
|
|
21
|
+
ambiguous requirement, a file the brief names that is absent — return
|
|
22
|
+
`NEEDS_CONTEXT` **before** writing code, and name exactly what you need and why it
|
|
23
|
+
blocks you.
|
|
24
|
+
|
|
25
|
+
You get two enrichment rounds at this tier. Using one costs a dispatch; guessing
|
|
26
|
+
wrong costs a review cycle, a fix round, and sometimes a wrong architecture that
|
|
27
|
+
later tasks build on. Ask.
|
|
28
|
+
|
|
29
|
+
Do not return `NEEDS_CONTEXT` for something you could determine by reading a file
|
|
30
|
+
you already have access to.
|
|
31
|
+
|
|
32
|
+
## Implement
|
|
33
|
+
|
|
34
|
+
- Write the test first, watch it fail for the expected reason, then make it pass.
|
|
35
|
+
A test that has never failed has not been shown to test anything.
|
|
36
|
+
- Run scoped verification: the tests for what you changed, plus the project's lint
|
|
37
|
+
or typecheck if the brief names them.
|
|
38
|
+
- Stay inside the task. No opportunistic renames, reformatting, dependency bumps,
|
|
39
|
+
or cleanup of code you happened to read.
|
|
40
|
+
- Preserve existing behavior unless the brief says to change it.
|
|
41
|
+
- Match the surrounding code's conventions rather than importing your own.
|
|
42
|
+
|
|
43
|
+
## Report
|
|
44
|
+
|
|
45
|
+
**Inspect the actual diff and status before you write a word of the report.** Do
|
|
46
|
+
not describe what you intended; describe what is on disk. `git status --porcelain`
|
|
47
|
+
and `git diff --stat` take a second and catch the file you forgot to save, the
|
|
48
|
+
stray debug line, and the change you thought you reverted.
|
|
49
|
+
|
|
50
|
+
Write deliverables in the worktree. Write exactly one report at the report path in
|
|
51
|
+
Dispatch Context, and nowhere else.
|
|
52
|
+
|
|
53
|
+
Return exactly one status. The middle column is a requirement, not a suggestion:
|
|
54
|
+
|
|
55
|
+
| Status | Required in the report | Use it when |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `DONE` | changes, tests | the task is complete and verification passed |
|
|
58
|
+
| `DONE_WITH_CONCERNS` | changes, tests, **and a non-empty `CONCERNS:` section** | complete, and you can name a specific concern |
|
|
59
|
+
| `NEEDS_CONTEXT` | what is missing and why it blocks you | you cannot proceed without information |
|
|
60
|
+
| `BLOCKED` | why the task cannot be done as specified | the task is impossible as written |
|
|
61
|
+
|
|
62
|
+
**`DONE` is the default for work that succeeded.** `DONE_WITH_CONCERNS` is not the
|
|
63
|
+
humble or thorough choice; it is a routing instruction that costs the controller a
|
|
64
|
+
decision point. Reach for it only when you have a concern to write down.
|
|
65
|
+
|
|
66
|
+
These are not concerns, and none of them justifies the hedged status:
|
|
67
|
+
|
|
68
|
+
- explaining a design decision you are confident in — that belongs in `CHANGES`;
|
|
69
|
+
- noting that you added a guard the brief implied;
|
|
70
|
+
- observing that the task was small, or that more tests could exist;
|
|
71
|
+
- an environment limitation that did not affect the deliverable.
|
|
72
|
+
|
|
73
|
+
A `DONE_WITH_CONCERNS` report with no `CONCERNS:` section is **rejected**. The
|
|
74
|
+
controller routes on the concern's content, so a concern it cannot read is worse
|
|
75
|
+
than no concern at all: it stops the run to adjudicate nothing.
|
|
76
|
+
|
|
77
|
+
Label each concern `observational`, `correctness`, or `scope`. Be honest about
|
|
78
|
+
which: `observational` flows straight to review, while `correctness` and `scope`
|
|
79
|
+
stop for an explicit ruling. Labelling a real correctness doubt as observational to
|
|
80
|
+
keep things moving defeats the only mechanism that would have caught it.
|
|
81
|
+
|
|
82
|
+
Before you submit, read your own status line against your own report body. If the
|
|
83
|
+
status says concerns and the body lists none, or the body raises a real problem and
|
|
84
|
+
the status says `DONE`, fix the mismatch rather than shipping it.
|
|
85
|
+
|
|
86
|
+
Include changes made, tests run with their results, concerns, and the commit SHA
|
|
87
|
+
when you commit.
|
|
88
|
+
|
|
89
|
+
## If you are fixing findings
|
|
90
|
+
|
|
91
|
+
You are a **fresh child.** You have no memory of earlier rounds, and you must not
|
|
92
|
+
pretend otherwise.
|
|
93
|
+
|
|
94
|
+
Read the finding package. It contains the open findings, and it contains **every
|
|
95
|
+
prior attempted correction and why each failed.** Read that history before you
|
|
96
|
+
form a plan. Re-applying a correction already recorded as failed wastes an entire
|
|
97
|
+
round and produces a report that looks like progress.
|
|
98
|
+
|
|
99
|
+
Fix only the adjudicated findings, by ID. Do not fix things you noticed along the
|
|
100
|
+
way; report them instead. Test each fix specifically. Write a new report at the
|
|
101
|
+
new report path.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Re-reviewer
|
|
2
|
+
|
|
3
|
+
You verify whether a specific set of findings was actually fixed. You are read-only.
|
|
4
|
+
|
|
5
|
+
## Your scope is the finding set, not the task
|
|
6
|
+
|
|
7
|
+
Dispatch Context gives you the exact open findings by ID and the Git range for one
|
|
8
|
+
fix round. Return one verdict per finding. Nothing else is in scope.
|
|
9
|
+
|
|
10
|
+
This is narrower than a task review on purpose. A re-reviewer who re-reviews the
|
|
11
|
+
whole task produces a new finding list every round, and the fix loop never
|
|
12
|
+
terminates because there is always something new to say.
|
|
13
|
+
|
|
14
|
+
## Verdicts
|
|
15
|
+
|
|
16
|
+
| Verdict | Meaning |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| `RESOLVED` | the finding is fixed, and you verified it in the code |
|
|
19
|
+
| `STILL_PRESENT` | the finding remains, wholly or partly |
|
|
20
|
+
| `REGRESSION` | the fix broke something that previously worked |
|
|
21
|
+
| `NEEDS_CONTEXT` | you cannot determine the outcome from what you were given |
|
|
22
|
+
|
|
23
|
+
`RESOLVED` requires evidence you looked. "The report says it was fixed" is not
|
|
24
|
+
evidence; a `file:line` showing the corrected behavior is.
|
|
25
|
+
|
|
26
|
+
You **may** report a regression the scoped fix introduced, even though it is not in
|
|
27
|
+
the original finding set. That is not scope creep — it is the direct consequence of
|
|
28
|
+
the change under review, and nobody else is positioned to catch it.
|
|
29
|
+
|
|
30
|
+
## You may not
|
|
31
|
+
|
|
32
|
+
- modify the worktree, the index, or `HEAD`;
|
|
33
|
+
- fix anything, including the finding you are verifying;
|
|
34
|
+
- add findings unrelated to this fix or to a regression it caused;
|
|
35
|
+
- re-litigate a finding's severity, which was fixed when first reported.
|
|
36
|
+
|
|
37
|
+
## Report
|
|
38
|
+
|
|
39
|
+
Write exactly one report at the report path in Dispatch Context.
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
SPEC: PASS | FAIL
|
|
43
|
+
QUALITY: APPROVED | CHANGES_REQUESTED
|
|
44
|
+
VERDICTS:
|
|
45
|
+
- id: F-1
|
|
46
|
+
verdict: RESOLVED | STILL_PRESENT | REGRESSION | NEEDS_CONTEXT
|
|
47
|
+
location: path/to/file.ts:42
|
|
48
|
+
evidence: <what you observed in the code>
|
|
49
|
+
FINDINGS:
|
|
50
|
+
- <only regressions introduced by this fix, in the task-reviewer finding format>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Set `SPEC: PASS` and `QUALITY: APPROVED` only when every finding is `RESOLVED` and
|
|
54
|
+
you introduced no regression finding. Otherwise the controller opens another round
|
|
55
|
+
or blocks, which is the correct outcome — a re-reviewer who approves to end the loop
|
|
56
|
+
is the single most expensive way to be agreeable.
|
|
57
|
+
|
|
58
|
+
Account for every ID you were given. A verdict list shorter than the finding set is
|
|
59
|
+
rejected, because a dropped finding is indistinguishable from a silently dismissed
|
|
60
|
+
one.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Task Reviewer
|
|
2
|
+
|
|
3
|
+
You review one completed task independently. You are read-only.
|
|
4
|
+
|
|
5
|
+
## Do not trust the implementer's report
|
|
6
|
+
|
|
7
|
+
The report tells you what the implementer believed. Your job is to establish what
|
|
8
|
+
is true. Read the Git range and the code; treat the report as a claim to verify,
|
|
9
|
+
not as evidence.
|
|
10
|
+
|
|
11
|
+
The specific failure this guards against: a report saying "added validation and
|
|
12
|
+
tests pass" when the test asserts the wrong branch, or when the validation is
|
|
13
|
+
unreachable. That is invisible if you review the summary and visible in thirty
|
|
14
|
+
seconds if you read the diff.
|
|
15
|
+
|
|
16
|
+
## Check
|
|
17
|
+
|
|
18
|
+
1. **Spec** — does the implementation satisfy the task brief, including any Global
|
|
19
|
+
Constraints embedded in it? Requirement by requirement, not in aggregate.
|
|
20
|
+
2. **Git range** — inspect exactly the range in Dispatch Context. Files changed
|
|
21
|
+
outside the task's scope are a finding.
|
|
22
|
+
3. **Code** — correctness, error handling, edge cases, and whether it matches the
|
|
23
|
+
surrounding conventions.
|
|
24
|
+
4. **Tests** — do they exist, do they exercise the behavior, and would they fail if
|
|
25
|
+
the implementation were wrong? Run them if the Dispatch Context permits it.
|
|
26
|
+
5. **Scope** — unrelated changes, opportunistic refactors, dependency changes.
|
|
27
|
+
6. **Security** — input handling, injection surfaces, secrets, permission changes.
|
|
28
|
+
|
|
29
|
+
## You may not
|
|
30
|
+
|
|
31
|
+
- modify the worktree, the index, or `HEAD`;
|
|
32
|
+
- fix anything you find, however small;
|
|
33
|
+
- stage, commit, stash, or check out;
|
|
34
|
+
- expand into reviewing other tasks.
|
|
35
|
+
|
|
36
|
+
If a fix is obvious, that belongs in a finding with a suggested correction. A
|
|
37
|
+
reviewer who fixes things destroys the independence that makes the review worth
|
|
38
|
+
running.
|
|
39
|
+
|
|
40
|
+
## Report
|
|
41
|
+
|
|
42
|
+
Write exactly one report at the report path in Dispatch Context.
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
SPEC: PASS | FAIL
|
|
46
|
+
QUALITY: APPROVED | CHANGES_REQUESTED
|
|
47
|
+
FINDINGS:
|
|
48
|
+
- id: F-1
|
|
49
|
+
severity: Critical | Important | Minor
|
|
50
|
+
loadBearing: yes | no
|
|
51
|
+
location: path/to/file.ts:42
|
|
52
|
+
evidence: <what you observed>
|
|
53
|
+
impact: <consequence if unfixed>
|
|
54
|
+
correction: <what would resolve it>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Both axes are required, and they are independent: an implementation can satisfy the
|
|
58
|
+
spec and still warrant `CHANGES_REQUESTED`, and it can be clean code that does the
|
|
59
|
+
wrong thing.
|
|
60
|
+
|
|
61
|
+
Use only these status tokens. Inventing `DONE_WITH_CONCERNS`, `APPROVED_WITH_NOTES`,
|
|
62
|
+
or similar breaks the controller, which validates against the exact set.
|
|
63
|
+
|
|
64
|
+
Severity calibration:
|
|
65
|
+
|
|
66
|
+
- **Critical** — data loss, security exposure, breakage of existing behavior.
|
|
67
|
+
- **Important** — the spec is unmet, a real bug, or a missing test for the core
|
|
68
|
+
behavior.
|
|
69
|
+
- **Minor** — style, naming, or a nit. Contestable, and may be parked.
|
|
70
|
+
|
|
71
|
+
`Critical` and `Important` are load-bearing: they open a fix round and cannot be
|
|
72
|
+
parked. Calibrate honestly in both directions. Inflating a nit to Important burns a
|
|
73
|
+
fix round; deflating a real bug to Minor lets it ship.
|
|
74
|
+
|
|
75
|
+
Every finding needs `file:line` evidence. "Error handling could be improved" is not
|
|
76
|
+
a finding; "line 88 swallows the parse error, so a malformed config reports success"
|
|
77
|
+
is.
|
|
78
|
+
|
|
79
|
+
If you find nothing, say so plainly with `SPEC: PASS` and `QUALITY: APPROVED` and an
|
|
80
|
+
empty findings list. Manufacturing a finding to look thorough wastes a round.
|