@oscaner-skills/cdd-engine 3.0.1 → 4.0.0
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 +9 -1
- package/README.zh-CN.md +10 -2
- package/dist/contract/declare.js +52 -59
- package/dist/contract/doc.js +31 -35
- package/dist/contract/frontmatter.js +10 -13
- package/dist/contract/invariants.js +172 -96
- package/dist/contract/judge.js +6 -3
- package/dist/contract/lint.js +4 -3
- package/dist/contract/project.js +15 -15
- package/dist/face/board-view.js +203 -242
- package/dist/face/capsule.js +18 -10
- package/dist/face/cli.js +170 -60
- package/dist/face/declare.js +5 -6
- package/dist/face/host.js +1 -1
- package/dist/face/lifecycle.js +192 -92
- package/dist/face/preview.js +1 -1
- package/dist/face/termination.js +33 -5
- package/dist/face/words.js +73 -8
- package/dist/infra/doc-roots.js +1 -0
- package/dist/infra/runtime.js +4 -13
- package/dist/infra/slug-index.js +325 -0
- package/dist/infra/workspace.js +3 -76
- package/dist/render/skeleton.js +21 -30
- package/dist/render/templates.js +48 -23
- package/dist/session/handoff-schema.js +84 -72
- package/dist/session/ledger.js +24 -16
- package/dist/session/next.js +1 -1
- package/dist/session/preflight.js +27 -24
- package/dist/session/round-naming.js +2 -2
- package/dist/session/run.js +28 -16
- package/dist/session/wave.js +30 -7
- package/package.json +1 -1
package/dist/render/skeleton.js
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
// standard parser): the frontmatter-home slots render as a `---`-fenced YAML
|
|
13
13
|
// record emitted by `yaml.stringify` in one call — an independent line set, never
|
|
14
14
|
// hand-spun header lines and never part of the slot/probe channel. §4.2's
|
|
15
|
-
// placeholder three-way split: the
|
|
16
|
-
//
|
|
17
|
-
//
|
|
15
|
+
// placeholder three-way split: the slug-reference key (`program`) emits a `<…>`
|
|
16
|
+
// scalar on the judge's placeholder-exemption chain; the content keys (`title` ·
|
|
17
|
+
// `author` · `base` · `slug`) emit `:::fill <key>`; the
|
|
18
18
|
// truth keys (`doc-type` · `version` · `date` · `status`) emit true values. The
|
|
19
19
|
// optional `parent-version` key is deliberately NOT emitted — its shape is typed
|
|
20
20
|
// (`v<n>.<m>`, so a fill or a link scalar would violate the domain) and absence
|
|
@@ -31,19 +31,17 @@
|
|
|
31
31
|
// Module-level exports are types / the class — zero behavior-carrying bare
|
|
32
32
|
// functions (the plan's zero-bare-function discipline).
|
|
33
33
|
import { Pair, Scalar, stringify as stringifyYaml, YAMLMap } from "yaml";
|
|
34
|
-
/** The placeholder scalars of the front-matter
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* the
|
|
42
|
-
*
|
|
43
|
-
* consumer copying the exemplar fills a bare path, never a markdown link). */
|
|
34
|
+
/** The placeholder scalars of the front-matter slug-reference keys (spec §4.2 + D3)
|
|
35
|
+
* — the phase-spec `program:` head key renders a `<…>`-shaped value that rides
|
|
36
|
+
* the judge's placeholder-exemption chain (a bare `^<[^>]+>$` target the
|
|
37
|
+
* file-existence / sibling-scan / slug-reference strategies all skip), never a
|
|
38
|
+
* `:::fill` (a fill in a link slot is a guaranteed finding). The placeholder IS
|
|
39
|
+
* the fill contract (show-don't-tell — zero prose rules): its inner shape is the
|
|
40
|
+
* SLUG of the parent overall document, the exact form the consumer must fill
|
|
41
|
+
* (the value domain of `program:` is `SLUG_VALUE_PATTERN`, so a path exemplar
|
|
42
|
+
* would seed a violating document). */
|
|
44
43
|
const FRONT_MATTER_LINKS = {
|
|
45
|
-
|
|
46
|
-
"parent-program": "<docs/kairos/specs/…-overall.md>",
|
|
44
|
+
program: "<overall-slug>",
|
|
47
45
|
};
|
|
48
46
|
/** The generator truths of the pattern-typed body slots (spec §3.2/§4.1) —
|
|
49
47
|
* hand-pinned legal literals consistent with each declared value domain (the
|
|
@@ -107,8 +105,8 @@ export class SkeletonAssembler {
|
|
|
107
105
|
* the probe set (each composition helper probes the anchors it emits). */
|
|
108
106
|
#compose(probe) {
|
|
109
107
|
switch (this.#docType) {
|
|
110
|
-
case "overall
|
|
111
|
-
return this.#
|
|
108
|
+
case "overall":
|
|
109
|
+
return this.#renderOverall(probe);
|
|
112
110
|
case "plan":
|
|
113
111
|
return this.#renderPlan(probe);
|
|
114
112
|
case "phase-spec":
|
|
@@ -145,15 +143,14 @@ export class SkeletonAssembler {
|
|
|
145
143
|
// -------------------------------------------------------------------------
|
|
146
144
|
// the per-doc-type compositions — the doc section sequence + its scaffolds
|
|
147
145
|
// -------------------------------------------------------------------------
|
|
148
|
-
/** The overall
|
|
149
|
-
* (the
|
|
146
|
+
/** The overall skeleton — the front-matter head, the section sequence
|
|
147
|
+
* (the three table sections, the charter facets, the dependency graph, the
|
|
150
148
|
* Form-A constraints surface and the change-history table): every required
|
|
151
|
-
* overall
|
|
152
|
-
#
|
|
149
|
+
* overall element lands in its structural position. */
|
|
150
|
+
#renderOverall(probe) {
|
|
153
151
|
const lines = [];
|
|
154
152
|
this.#pushFrontmatter(lines);
|
|
155
153
|
lines.push(...this.#section("## Document scope", [":::fill document-scope"], probe));
|
|
156
|
-
lines.push(...this.#section("## File paths", this.#filePathsTable(probe), probe));
|
|
157
154
|
lines.push(...this.#section("## Program charter", this.#programCharter(probe), probe));
|
|
158
155
|
lines.push(...this.#section("## Issue inventory", this.#issueTable(probe), probe));
|
|
159
156
|
lines.push(...this.#section("## Phase inventory", this.#phaseTable(probe), probe));
|
|
@@ -212,7 +209,7 @@ export class SkeletonAssembler {
|
|
|
212
209
|
/** The single-spec skeleton — the front-matter head, the four prose sections
|
|
213
210
|
* (`:::fill` slots) and the change-history table: the lightweight scaffold of
|
|
214
211
|
* the free-form spec (P6 T2 · spec §2.1). No `### N.` double-layer outline and
|
|
215
|
-
* no
|
|
212
|
+
* no `program:` key — the single-spec's deliberate deviations from the
|
|
216
213
|
* phase-spec form. */
|
|
217
214
|
#renderSingleSpec(probe) {
|
|
218
215
|
const lines = [];
|
|
@@ -247,7 +244,7 @@ export class SkeletonAssembler {
|
|
|
247
244
|
// the link placeholders plain (the <>-bookended exemplar — exemption-shaped).
|
|
248
245
|
const fields = new YAMLMap();
|
|
249
246
|
// The emission list is the projection's independent front-matter set — the
|
|
250
|
-
// required head keys plus the type's optional keys (`base` / `
|
|
247
|
+
// required head keys plus the type's optional keys (`base` / `issues`);
|
|
251
248
|
// `parent-version` never appears (the projection excludes it — §4.2's
|
|
252
249
|
// optional shape-typed key, whose `v<n>.<m>` domain admits no placeholder).
|
|
253
250
|
for (const slot of this.#frontmatterSlots) {
|
|
@@ -315,12 +312,6 @@ export class SkeletonAssembler {
|
|
|
315
312
|
probe.add(anchor);
|
|
316
313
|
return [heading, "", ...body, ""];
|
|
317
314
|
}
|
|
318
|
-
/** The File-paths artifact table — the two-column header + the minimal one-row
|
|
319
|
-
* scaffold (the backticked path cell keeps the `File path row` shape). */
|
|
320
|
-
#filePathsTable(probe) {
|
|
321
|
-
probe.add("File path row");
|
|
322
|
-
return ["| Artifact | Path |", "| --- | --- |", "| overall-spec | `:::fill overall-path` |"];
|
|
323
|
-
}
|
|
324
315
|
/** The charter facets — the three required `###` facet headings with their
|
|
325
316
|
* content bullets (the optional decision-group / endorsements leaves generate
|
|
326
317
|
* no slot — the optional/conditional zero-gen contract). */
|
package/dist/render/templates.js
CHANGED
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
// Module-level exports are types / the declared constant data / the class — zero
|
|
49
49
|
// behavior-carrying bare functions (the plan's zero-bare-function discipline).
|
|
50
50
|
import { DISPATCH } from "../face/host.js";
|
|
51
|
+
import { TerminationPolicy } from "../face/termination.js";
|
|
51
52
|
/** The nominal fixed-frame cells shared by every shell (byte-identical words — the
|
|
52
53
|
* fixed prefix is read on every dispatch, so every word costs child context). */
|
|
53
54
|
const FRAME_ITEMS = [
|
|
@@ -68,12 +69,14 @@ const LICENSE_ITEMS = [
|
|
|
68
69
|
"- {{> cl:eof-newline}}",
|
|
69
70
|
"- {{> cl:no-full-tree-find}}",
|
|
70
71
|
"- {{> cl:bash-stall-limit}}",
|
|
72
|
+
"- {{> cl:no-infinite-loop}}",
|
|
71
73
|
"- {{> cl:plan-freeze}}",
|
|
72
74
|
"- {{> cl:atomic-commit}}",
|
|
73
75
|
"- {{> cl:self-validate}}",
|
|
76
|
+
"- {{> cl:sync-completion}}",
|
|
74
77
|
];
|
|
75
78
|
/** The `## Handoff schema` section — the injected writable-subset fence at every
|
|
76
|
-
* shell's tail (the {{HANDOFF_SCHEMA}} slot; the
|
|
79
|
+
* shell's tail (the {{HANDOFF_SCHEMA}} slot; the plane's sets differ per mode, so
|
|
77
80
|
* the section's bytes are fixed per mode — §3.5 prefix-cache grouping). */
|
|
78
81
|
const SCHEMA_SECTION = ["", "## Handoff schema", "", "{{HANDOFF_SCHEMA}}"];
|
|
79
82
|
/** The implement row's fixed prefix — header + instructions + the shared work tail. */
|
|
@@ -83,7 +86,7 @@ const IMPLEMENT_SHELL = [
|
|
|
83
86
|
"## Instructions",
|
|
84
87
|
"",
|
|
85
88
|
...FRAME_ITEMS,
|
|
86
|
-
`**implement:** read \`INPUT_WAVE_BRIEF\` (the complete plan mirror — every \`### Task N:\` of the wave + the plan's \`## Constraints\` section, fresh-extracted at dispatch). \`WAVE\` = this round's wave (the task list); implement ALL tasks of the wave, never a subset. \`CONFIRMED_SEAMS\` in the brief → apply as-is; else propose test boundaries in the report, then invoke **\`${DISPATCH.implement}\`**. Write the handoff draft at \`OUTPUT_HANDOFF\` per \`## Handoff schema\` BEFORE the return block: \`status\` (APPROVED once applied, else BLOCKED + \`
|
|
89
|
+
`**implement:** read \`INPUT_WAVE_BRIEF\` (the complete plan mirror — every \`### Task N:\` of the wave + the plan's \`## Constraints\` section, fresh-extracted at dispatch). \`WAVE\` = this round's wave (the task list); implement ALL tasks of the wave, never a subset. \`CONFIRMED_SEAMS\` in the brief → apply as-is; else propose test boundaries in the report, then invoke **\`${DISPATCH.implement}\`**. Write the handoff draft at \`OUTPUT_HANDOFF\` per \`## Handoff schema\` BEFORE the return block: \`status\` (APPROVED once applied, else BLOCKED + the reason in \`notes\`) and \`artifacts\` (the prescribed \`OUTPUT_REPORT\`/\`OUTPUT_EVIDENCE\` paths from the round context — the \`{family}-{key}-\` canonical names, zero free naming).`,
|
|
87
90
|
EVIDENCE_ITEM,
|
|
88
91
|
...LICENSE_ITEMS,
|
|
89
92
|
...SCHEMA_SECTION,
|
|
@@ -104,7 +107,7 @@ const FIX_SHELL = [
|
|
|
104
107
|
"**fix:** read `INPUT_REVIEWS` (open findings) + the plan context (`INPUT_WAVE_BRIEF` on a wave line — the complete plan mirror; `INPUT_PLAN` on the plan/branch lines — the plan document; `INPUT_SPEC` on the spec line — the spec document). Fix ALL findings (blocker/warn/nit), verifying against `INPUT_REVIEWS` none remain open. Fix + write the draft at `OUTPUT_HANDOFF` per `## Handoff schema` in one process; draft write failure → `status: BLOCKED`; retry = full re-run (idempotent).",
|
|
105
108
|
EVIDENCE_ITEM,
|
|
106
109
|
...LICENSE_ITEMS,
|
|
107
|
-
// T5 (v0.3) — The work
|
|
110
|
+
// T5 (v0.3) — The work plane's ONE strict-schema sentence: every top-level draft
|
|
108
111
|
// field comes from the `## Handoff schema` declared properties (the fields'
|
|
109
112
|
// single source is the injected fence below — never a second enumeration in the
|
|
110
113
|
// shell prose; a fix child that mirrors the source review carrier's top-level
|
|
@@ -114,27 +117,24 @@ const FIX_SHELL = [
|
|
|
114
117
|
...SCHEMA_SECTION,
|
|
115
118
|
];
|
|
116
119
|
/** The docs-fix row's fixed prefix — header + instructions (no evidence — the
|
|
117
|
-
* docs-fix
|
|
120
|
+
* docs-fix round writes no evidence file). */
|
|
118
121
|
const DOCS_FIX_SHELL = [
|
|
119
122
|
"# CDD dispatch — docs-fix round",
|
|
120
123
|
"",
|
|
121
124
|
"## Instructions",
|
|
122
125
|
"",
|
|
123
126
|
...FRAME_ITEMS,
|
|
124
|
-
"**docs-fix:** apply `INPUT_REVIEWS` (all severities) directly to the judged doc — `INPUT_PLAN` on a plan-doc line, `INPUT_SPEC` on a spec-doc line — removing fixed findings; record the path in `artifacts.doc
|
|
127
|
+
"**docs-fix:** apply `INPUT_REVIEWS` (all severities) directly to the judged doc — `INPUT_PLAN` on a plan-doc line, `INPUT_SPEC` on a spec-doc line — removing fixed findings; record the path in `artifacts.doc` and report the round in `status` (APPROVED once every finding is applied, else BLOCKED + the reason in `notes`). Fix + write the draft at `OUTPUT_HANDOFF` per `## Handoff schema` in one process; retry = full re-run (idempotent).",
|
|
125
128
|
...LICENSE_ITEMS,
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
// work shell's field list is never copied here, and no field enumeration rides
|
|
131
|
-
// the findings shell's prose either).
|
|
132
|
-
"**Draft fields:** every top-level field of the draft comes from the `## Handoff schema` declared `properties` — `findings` (required) rides over from `INPUT_REVIEWS` verbatim, unmodified; the declaration is the field source, zero extra keys.",
|
|
129
|
+
// The generic strict-schema sentence — the SAME one the work shells carry: the
|
|
130
|
+
// injected declaration is the draft's single field source, zero per-mode field
|
|
131
|
+
// enumeration in the shell prose.
|
|
132
|
+
"**Draft fields:** every top-level field of the draft comes from the `## Handoff schema` declared `properties` — the declaration is the field source, zero extra keys.",
|
|
133
133
|
...SCHEMA_SECTION,
|
|
134
134
|
];
|
|
135
135
|
/** The review variants' shared instruction text — the review's mode rule (the
|
|
136
136
|
* criteria body + the lens vocabulary ride per-type fixed items below). */
|
|
137
|
-
const REVIEW_ITEM = "**review:** review the criteria below against the reference face named in the round context. Wave reviews judge `INPUT_WAVE_BRIEF` (the complete plan mirror); the plan/branch reviews judge the plan at `INPUT_PLAN`, the spec review judges the spec at `INPUT_SPEC`. Write findings into the draft at `OUTPUT_HANDOFF` per `## Handoff schema` (never print them); empty `findings` = approved. The engine derives the conclusion from the draft's findings (blocker → CHANGES_REQUESTED · warn/nit → REVIEW_FIX · none → APPROVED) — a review never declares its own status.";
|
|
137
|
+
const REVIEW_ITEM = "**review:** review the criteria below against the reference face named in the round context. Wave reviews judge `INPUT_WAVE_BRIEF` (the complete plan mirror); the plan/branch reviews judge the plan at `INPUT_PLAN`, the spec review judges the spec at `INPUT_SPEC`, and a face whose spec carries a `program:` also carries the parent charter at `INPUT_OVERALL`. Write findings into the draft at `OUTPUT_HANDOFF` per `## Handoff schema` (never print them); empty `findings` = approved. The engine derives the conclusion from the draft's findings (blocker → CHANGES_REQUESTED · warn/nit → REVIEW_FIX · none → APPROVED) — a review never declares its own status. **Read-only:** never mutate tracked content, the index, HEAD, or branch state — the prescribed `OUTPUT_*` artifacts are a review's only writes, and committing belongs to the orchestrator — read history through `git show` / `git diff` / `git log`, and inspect another revision in a separate directory rather than moving HEAD here; repairs belong to the fix round, never to a review. **Single agent:** do the whole review yourself — never spawn a subagent for part of the diff or for a second opinion; this overrides any dispatched skill's parallel-sub-agent default.";
|
|
138
138
|
/** The review mode's shared reduced tail — the only dynamic region of every review
|
|
139
139
|
* variant (the criteria/lens are fixed-prefix per type, never here). Each review
|
|
140
140
|
* type carries its own judged-doc referent (wave → `INPUT_WAVE_BRIEF`; plan/branch
|
|
@@ -148,6 +148,7 @@ const REVIEW_CONTEXT = [
|
|
|
148
148
|
"- `INPUT_WAVE_BRIEF`: {{INPUT_WAVE_BRIEF}}",
|
|
149
149
|
"- `INPUT_PLAN`: {{INPUT_PLAN}}",
|
|
150
150
|
"- `INPUT_SPEC`: {{INPUT_SPEC}}",
|
|
151
|
+
"- `INPUT_OVERALL`: {{INPUT_OVERALL}}",
|
|
151
152
|
"- `BASE_BRANCH`: {{BASE_BRANCH}}",
|
|
152
153
|
"- `OUTPUT_REPORT`: {{OUTPUT_REPORT}}",
|
|
153
154
|
"- `OUTPUT_HANDOFF`: {{OUTPUT_HANDOFF}}",
|
|
@@ -186,6 +187,7 @@ const MODE_PROMPTS = {
|
|
|
186
187
|
"- `INPUT_WAVE_BRIEF`: {{INPUT_WAVE_BRIEF}}",
|
|
187
188
|
"- `INPUT_PLAN`: {{INPUT_PLAN}}",
|
|
188
189
|
"- `INPUT_SPEC`: {{INPUT_SPEC}}",
|
|
190
|
+
"- `INPUT_OVERALL`: {{INPUT_OVERALL}}",
|
|
189
191
|
"- `INPUT_REVIEWS`: {{INPUT_REVIEWS}}",
|
|
190
192
|
"- `OUTPUT_REPORT`: {{OUTPUT_REPORT}}",
|
|
191
193
|
"- `OUTPUT_EVIDENCE`: {{OUTPUT_EVIDENCE}}",
|
|
@@ -204,6 +206,7 @@ const MODE_PROMPTS = {
|
|
|
204
206
|
"- `WAVE`: {{WAVE}}",
|
|
205
207
|
"- `INPUT_PLAN`: {{INPUT_PLAN}}",
|
|
206
208
|
"- `INPUT_SPEC`: {{INPUT_SPEC}}",
|
|
209
|
+
"- `INPUT_OVERALL`: {{INPUT_OVERALL}}",
|
|
207
210
|
"- `INPUT_REVIEWS`: {{INPUT_REVIEWS}}",
|
|
208
211
|
"- `OUTPUT_REPORT`: {{OUTPUT_REPORT}}",
|
|
209
212
|
"- `OUTPUT_HANDOFF`: {{OUTPUT_HANDOFF}}",
|
|
@@ -218,15 +221,15 @@ const MODE_PROMPTS = {
|
|
|
218
221
|
export const REVIEWS = {
|
|
219
222
|
wave: {
|
|
220
223
|
lensEnum: ["standards", "spec", "buildability"],
|
|
221
|
-
axesGuide: "Standards axis (repo coding standards + code-review smell baseline) + Spec axis (wave brief / plan requirements) + Buildability axis (the reviewer explicitly runs the repository's typecheck command — `tsc --noEmit`, or the repo equivalent — AND its test command; every buildability finding self-reports the dual evidence, both commands ran) + Scope axis (changed-surface reasonableness): run `git diff origin/<BASE_BRANCH>..HEAD` yourself (BASE_BRANCH as named in the round context; on a missing artifact judge the working tree) — every changed file must fall within the wave brief's file surface (`**Files:**` seams) or be attributable to the plan / reviewed intent; an unattributable changed file is a candidate finding (severity by your judgment). The reviewer is the changed-surface judge — the engine reconciles nothing. The reviewed artifact is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable user would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust).
|
|
224
|
+
axesGuide: "Standards axis (repo coding standards + code-review smell baseline) + Spec axis (wave brief / plan requirements) + Buildability axis (the reviewer explicitly runs the repository's typecheck command — `tsc --noEmit`, or the repo equivalent — AND its test command; every buildability finding self-reports the dual evidence, both commands ran) + Scope axis (changed-surface reasonableness): run `git diff origin/<BASE_BRANCH>..HEAD` yourself (BASE_BRANCH as named in the round context; on a missing artifact judge the working tree) — every changed file must fall within the wave brief's file surface (`**Files:**` seams) or be attributable to the plan / reviewed intent; an unattributable changed file is a candidate finding (severity by your judgment). The reviewer is the changed-surface judge — the engine reconciles nothing. The reviewed artifact is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable user would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust).",
|
|
222
225
|
},
|
|
223
226
|
branch: {
|
|
224
227
|
lensEnum: ["standards", "spec", "buildability"],
|
|
225
|
-
axesGuide: "Same four axes as task (branch-wide health: run `git diff origin/<BASE_BRANCH>..HEAD` + plan conformance) + Buildability axis (the reviewer explicitly runs the repository's typecheck command — `tsc --noEmit`, or the repo equivalent — AND its test command; every buildability finding self-reports the dual evidence, both commands ran) + Scope axis (changed-surface reasonableness): branch review IS the full diff — every changed file must be attributable to a finding, a plan requirement, or the reviewed intent; unrelated surface = candidate finding (severity by your judgment), normal finding → fix loop. The reviewed artifact is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable user would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust).",
|
|
228
|
+
axesGuide: "Same four axes as task (branch-wide health: run `git diff origin/<BASE_BRANCH>..HEAD` + plan conformance) + Buildability axis (the reviewer explicitly runs the repository's typecheck command — `tsc --noEmit`, or the repo equivalent — AND its test command; every buildability finding self-reports the dual evidence, both commands ran) + Scope axis (changed-surface reasonableness): branch review IS the full diff — every changed file must be attributable to a finding, a plan requirement, or the reviewed intent; unrelated surface = candidate finding (severity by your judgment), normal finding → fix loop. The reviewed artifact is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable user would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust). Three things a green run cannot show you: design — does the changed structure fit this codebase and is it the simplest structure that solves the plan's problem (over-engineering is a finding, not a preference); test adequacy — would these tests fail if the code broke (a run that cannot go red is not evidence); migration — does every breaking change name the path a not-yet-migrated consumer takes.",
|
|
226
229
|
},
|
|
227
230
|
spec: {
|
|
228
231
|
lensEnum: ["completeness", "consistency", "clarity"],
|
|
229
|
-
axesGuide: "Follow URC: single-cycle, lens-tagged findings (completeness/consistency/clarity) + the writing-plans self-check + verification evidence — the reviewer runs the repository's typecheck and test commands and self-reports the dual evidence + Claimed→pin: every behavior claim (usage-line attribution · semantic contract · byte face) must cite a colocated pin (path:line + the assertion face) — the review checks every claim against its pin, claim by claim; a pinless claim is a lens-tagged finding + The reviewed spec is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable downstream author would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust).",
|
|
232
|
+
axesGuide: "Follow URC: single-cycle, lens-tagged findings (completeness/consistency/clarity) + the writing-plans self-check + verification evidence — the reviewer runs the repository's typecheck and test commands and self-reports the dual evidence + Claimed→pin: every behavior claim (usage-line attribution · semantic contract · byte face) must cite a colocated pin (path:line + the assertion face) — the review checks every claim against its pin, claim by claim; a pinless claim is a lens-tagged finding + program conformance — judge the phase against its parent overall at `INPUT_OVERALL` (the charter its `program:` names): the phase must sit inside the scope the overall's Phase inventory registered for it, and a phase that reaches beyond it is a completeness finding + The reviewed spec is a vision, not an exhaustive enumeration — behavior it is silent on is judged by what a reasonable downstream author would expect; its silence is not permission, and a finding's severity grades that expectation, not whether the text mentions the trigger. Before your verdict, list every behavior you considered and set aside as outside the reviewed scope — one line each with the reason; nothing set aside is dropped silently; an empty list means you set nothing aside. Calibrate findings by real severity — not everything is a blocker — and acknowledge what was done well before listing findings (accurate praise earns the rest of the report trust).",
|
|
230
233
|
},
|
|
231
234
|
plan: {
|
|
232
235
|
lensEnum: ["completeness", "decomposition", "buildability"],
|
|
@@ -337,6 +340,7 @@ const TOKENS = [
|
|
|
337
340
|
{ name: "HANDOFF_SCHEMA", zone: "shell" },
|
|
338
341
|
{ name: "INPUT_PLAN", zone: "round-context" },
|
|
339
342
|
{ name: "INPUT_SPEC", zone: "round-context" },
|
|
343
|
+
{ name: "INPUT_OVERALL", zone: "round-context" },
|
|
340
344
|
{ name: "INPUT_REVIEWS", zone: "round-context" },
|
|
341
345
|
{ name: "INPUT_WAVE_BRIEF", zone: "round-context" },
|
|
342
346
|
// find #5 — the prescribed artifact write paths (the {family}-{key}-{artifact}
|
|
@@ -355,19 +359,40 @@ export const CLAUSES = {
|
|
|
355
359
|
"cl:english-comments": "Write code comments and shipped prose in English only — English-primary (no other-language comment blocks, no translated mirrors).",
|
|
356
360
|
"cl:eof-newline": "Every text file must end with exactly one newline (EOF newline): no missing final newline and no trailing blank lines.",
|
|
357
361
|
"cl:no-full-tree-find": "Never run an unbounded full-tree `find` over a large directory and never bare-read a large file — constrain to explicit paths with `maxdepth`/`-path`, or read only the needed range.",
|
|
358
|
-
"cl:bash-stall-limit":
|
|
362
|
+
"cl:bash-stall-limit": `Put a \`timeout\` on every Bash command — no single invocation may run longer than ${TerminationPolicy.CHILD_BASH_TIMEOUT_MS / 60_000} minutes; a command that stalls without progress is terminated and replaced with an equivalent, lighter command.`,
|
|
363
|
+
"cl:no-infinite-loop": "Never run an unbounded loop — no `while True: pass`, no `while true; do …; done`, no spin-wait or tail-follow that only a human can stop. A wait must carry a bounded exit condition (a timeout, a max-attempt counter, or a terminating predicate) that ends the loop on its own.",
|
|
359
364
|
"cl:plan-freeze": "Approved plan/spec files are frozen — zero modification authority; any change needed is reported to the orchestrator through findings, never edited in place.",
|
|
360
365
|
"cl:atomic-commit": "Commit each round's change as one atomic conventional commit scoped to the round — no mixed or out-of-scope content, no AI-generation trailers.",
|
|
361
366
|
"cl:self-validate": "Self-validate before returning: run the validation/checks your change requires and record the evidence (command + exit code + result) in the report.",
|
|
367
|
+
"cl:sync-completion": "This dispatch is one-shot and non-interactive: end your turn with anything still running and the process exits — the work and the handoff die with it. So do not end your turn — a background command, a background subagent, or any yield-and-wait path such as `bg_run` / `bg_delegate` — before the handoff draft is written. Finish nested work in this same turn: complete it synchronously in this process turn, then write the handoff and finish.",
|
|
362
368
|
};
|
|
363
|
-
/** The dispatch-prompt data plane — the typed template-contract surface. $version
|
|
364
|
-
*
|
|
365
|
-
*
|
|
369
|
+
/** The dispatch-prompt data plane — the typed template-contract surface. $version 16
|
|
370
|
+
* unifies the handoff carrier on one op-derived plane (work / judge — implement /
|
|
371
|
+
* fix author a status-bearing work carrier, review a findings-only judge carrier)
|
|
372
|
+
* and gives the docs-fix round a `status` to report its outcome in. $version 15
|
|
373
|
+
* carries the `INPUT_OVERALL` read face (the parent charter a spec's `program:`
|
|
374
|
+
* names, mirroring `INPUT_SPEC` — a face without `program:` drops the slot) and
|
|
375
|
+
* adds the spec axis's program-scope conformance criterion (the phase judged against
|
|
376
|
+
* the scope its charter's Phase inventory registered for it). $version 14
|
|
377
|
+
* rewrites the sync-completion clause to name the one-shot fact (ending your turn with
|
|
378
|
+
* work still running exits the process — the work and the handoff die with it) and the
|
|
379
|
+
* subagent class (a background subagent is a yield-and-wait path, exactly like a
|
|
380
|
+
* background command; `bg_run` / `bg_delegate` were the only names before). $version 13
|
|
381
|
+
* adds the two hard review disciplines (read-only — a review mutates no tracked
|
|
382
|
+
* content, index, HEAD, or branch state; single agent — a review never spawns a
|
|
383
|
+
* subagent) and the branch axis's three judgment points (design · test adequacy ·
|
|
384
|
+
* migration). $version 12 adds the bounded-loop discipline clause (no `while True: pass` /
|
|
385
|
+
* spin-wait — every wait carries its own terminating condition). $version 11 makes the Bash discipline
|
|
386
|
+
* clause a hard per-command ceiling (every Bash run carries a `timeout`, no invocation
|
|
387
|
+
* longer than `CHILD_BASH_TIMEOUT_MS`). $version 10 adds the sync-completion discipline
|
|
388
|
+
* clause (P14 — one-shot CDD children must finish nested work in-process before writing
|
|
389
|
+
* the handoff; no bg_run / bg_delegate yield).
|
|
390
|
+
* $version 9 was the kind-named doc-anchor shape (INPUT_PLAN / INPUT_SPEC replace the
|
|
391
|
+
* generic INPUT_DOC; INPUT_WAVE_BRIEF), the branch scope anchor BASE_BRANCH, the single
|
|
366
392
|
* prose return contract (`RETURN_PROSE` — nothing downstream parses the child's
|
|
367
|
-
* stdout), and the per-type review criterion shells.
|
|
368
|
-
* return-shape change (the two-line key-value block retired). */
|
|
393
|
+
* stdout), and the per-type review criterion shells. */
|
|
369
394
|
export const TEMPLATE_PROMPT = {
|
|
370
|
-
$version:
|
|
395
|
+
$version: 16,
|
|
371
396
|
modes: MODE_PROMPTS,
|
|
372
397
|
reviews: REVIEW_VARIANTS,
|
|
373
398
|
return: RETURN_ZONE,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// packages/cdd-engine/src-next/session/handoff-schema.ts
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// The handoff schema face: the child's writable handoff contract as ONE typed
|
|
3
|
+
// declaration projected onto the two carrier planes. The cutover deleted the old
|
|
4
4
|
// JSON schema file together with its Ajv loader; the structural constraint now lives
|
|
5
5
|
// here as a typed declaration — zero JSON schema files, one source, two consumers:
|
|
6
6
|
//
|
|
7
7
|
// · projections: ① the prompt-injection text (schemaText — the ```json fences
|
|
8
|
-
// byte-fixed per
|
|
8
|
+
// byte-fixed per plane, so the fixed prefix tail of the dispatch prompt stays
|
|
9
9
|
// cache-friendly) and ② the engine read-back validator (violations /
|
|
10
10
|
// evidenceViolations — the child draft is validated against exactly the same
|
|
11
|
-
//
|
|
12
|
-
// ·
|
|
13
|
-
//
|
|
14
|
-
// test-evidence file for task-family rounds) or `
|
|
11
|
+
// projected objects the prompt showed it).
|
|
12
|
+
// · planes: the carrier plane is DERIVED from the op (planeOf), never declared per
|
|
13
|
+
// family — `work` (implement/fix: status + artifacts, plus the separate
|
|
14
|
+
// test-evidence file for task-family rounds) or `judge` (reviews: findings-only
|
|
15
15
|
// carrier — the engine rolls the status up from the findings, never a
|
|
16
16
|
// child-authored status).
|
|
17
17
|
//
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
//
|
|
27
27
|
// Module-level exports are types / the declared schema objects / the class — zero
|
|
28
28
|
// behavior-carrying bare functions (the plan's zero-bare-function discipline).
|
|
29
|
-
/** One finding row — the shared base declaration of the
|
|
29
|
+
/** One finding row — the shared base declaration of the judge plane (severity +
|
|
30
30
|
* lens + summary required; the extra review columns — section / line / fix — are
|
|
31
31
|
* declared optional, and unknown extra fields ride along). */
|
|
32
32
|
const FINDING = {
|
|
@@ -41,40 +41,42 @@ const FINDING = {
|
|
|
41
41
|
fix: { type: "string" },
|
|
42
42
|
},
|
|
43
43
|
};
|
|
44
|
-
/** The
|
|
45
|
-
*
|
|
44
|
+
/** The ONE carrier declaration — the four child-writable slots. DECLARATION ORDER IS
|
|
45
|
+
* PROJECTION ORDER: `#writable(plane)` filters these properties in this order, so the
|
|
46
|
+
* judge fence keeps its `findings` · `artifacts` · `notes` byte order. Reserved
|
|
46
47
|
* fields (phase · tasks) are NOT declared and are DROPPED by materialize (never a
|
|
47
48
|
* BLOCK) — the engine stays the carrier's single author.
|
|
48
|
-
* `as const` preserves the literal property keys — the
|
|
49
|
-
*
|
|
50
|
-
const
|
|
49
|
+
* `as const` preserves the literal property keys — the `Carrier` type family below
|
|
50
|
+
* derives its field set FROM these declared keys. */
|
|
51
|
+
const CARRIER = {
|
|
51
52
|
type: "object",
|
|
52
|
-
required: ["status", "artifacts"],
|
|
53
53
|
properties: {
|
|
54
54
|
status: { type: "string", enum: ["APPROVED", "BLOCKED"] },
|
|
55
|
-
failure_category: { type: "string" },
|
|
56
|
-
artifacts: { type: "object" },
|
|
57
|
-
notes: { type: "array", items: { type: "string" } },
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
/** The `findings` writable subset — review + docs-fix carrier. NO status: the
|
|
61
|
-
* conclusion is derived from the findings at judgment time
|
|
62
|
-
* (`conclusionOf("findings", carrier)` → `rollup(findings)`), never a carrier field
|
|
63
|
-
* the child authors or the engine persists — the declaration plane IS the writable
|
|
64
|
-
* plane (one face, one field set). `as const` — see CARRIER_WORK. */
|
|
65
|
-
const CARRIER_FINDINGS = {
|
|
66
|
-
type: "object",
|
|
67
|
-
required: ["findings"],
|
|
68
|
-
properties: {
|
|
69
55
|
findings: { type: "array", items: FINDING },
|
|
70
56
|
artifacts: { type: "object" },
|
|
71
57
|
notes: { type: "array", items: { type: "string" } },
|
|
72
58
|
},
|
|
73
59
|
};
|
|
60
|
+
/** The plane → writable slot table — the ONE projection source (`#writable`) the
|
|
61
|
+
* prompt fence, the read-back validator and the dropped-key walk all read. The
|
|
62
|
+
* shared slots (artifacts · notes) are both-plane by design; the exclusive slot IS
|
|
63
|
+
* the plane (`status` for work, `findings` for judge). */
|
|
64
|
+
const PLANE_SLOTS = {
|
|
65
|
+
work: ["status", "artifacts", "notes"],
|
|
66
|
+
judge: ["findings", "artifacts", "notes"],
|
|
67
|
+
};
|
|
68
|
+
/** The plane → required slot table. The work plane's round conclusion is the child's
|
|
69
|
+
* own declared status, so status + artifacts are the required core. The judge plane
|
|
70
|
+
* requires the findings its conclusion rolls up from; artifacts / notes ride as
|
|
71
|
+
* declared optional slots (a review writes only what it has). */
|
|
72
|
+
const PLANE_REQUIRED = {
|
|
73
|
+
work: ["status", "artifacts"],
|
|
74
|
+
judge: ["findings"],
|
|
75
|
+
};
|
|
74
76
|
/** The test-evidence file schema — the evidence gate's engine read-back contract
|
|
75
77
|
* (the second fix for a prose-only claim: the old prompt asserted an engine read-back
|
|
76
|
-
* that the engine never performed; now both projections are real). A
|
|
77
|
-
*
|
|
78
|
+
* that the engine never performed; now both projections are real). A work-plane wave /
|
|
79
|
+
* branch round missing or violating this file rewrites the round to BLOCKED. */
|
|
78
80
|
const EVIDENCE = {
|
|
79
81
|
type: "object",
|
|
80
82
|
required: ["command", "exit_code", "passed", "warnings_count", "typecheck"],
|
|
@@ -95,30 +97,28 @@ const EVIDENCE = {
|
|
|
95
97
|
behavior_change: { type: "boolean" },
|
|
96
98
|
},
|
|
97
99
|
};
|
|
98
|
-
/** The face → declared writable-subset table (the single source both projections read).
|
|
99
|
-
* `as const` keeps the declarations' literal property keys visible — the carrier type
|
|
100
|
-
* family's `[K in keyof (typeof BY_FACE)[F]["properties"]]` derives its field set from
|
|
101
|
-
* exactly these tables, so a schema edit reshapes the carrier types by construction. */
|
|
102
|
-
const BY_FACE = {
|
|
103
|
-
work: CARRIER_WORK,
|
|
104
|
-
findings: CARRIER_FINDINGS,
|
|
105
|
-
};
|
|
106
100
|
/**
|
|
107
|
-
* HandoffSchema — one declaration, two projections. `violations(
|
|
101
|
+
* HandoffSchema — one declaration, two projections. `violations(plane, value)` is
|
|
108
102
|
* the read-back validator (projection ② — the engine's seat, session plane);
|
|
109
|
-
* `schemaText(
|
|
110
|
-
* prefix tail, byte-stable per
|
|
103
|
+
* `schemaText(plane, evidence)` is the injected prompt text (projection ① — fixed
|
|
104
|
+
* prefix tail, byte-stable per plane so the dispatch prompt stays cache-friendly).
|
|
111
105
|
* `rollup(findings)` derives the review conclusion the old JSON face rolled up.
|
|
112
106
|
*/
|
|
113
107
|
export class HandoffSchema {
|
|
114
|
-
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
108
|
+
/** The carrier plane of an op — the ONE derivation, never a per-family declaration.
|
|
109
|
+
* implement / fix author a work carrier (status + artifacts); review authors a
|
|
110
|
+
* judge carrier (findings — conclusion rolled up). */
|
|
111
|
+
static planeOf(op) {
|
|
112
|
+
return op === "review" ? "judge" : "work";
|
|
113
|
+
}
|
|
114
|
+
/** Projection ① — the `## Handoff schema` section text: the plane's writable
|
|
115
|
+
* subset in a ```json fence + (work plane) the evidence file's schema in a second
|
|
116
|
+
* fence. The text is byte-stable per (plane, evidence, prefix) — the fixed bytes
|
|
117
117
|
* of the dispatch prompt's contract surface. The evidence prefix is the family
|
|
118
118
|
* spine (§3.7 naming: `tasks-` for the task families, `branch-` for the branch
|
|
119
119
|
* fix — a branch evidence file never carries the misleading tasks- prefix). */
|
|
120
|
-
schemaText(
|
|
121
|
-
const carrier = this.#json(
|
|
120
|
+
schemaText(plane, evidence, evidencePrefix = "tasks") {
|
|
121
|
+
const carrier = this.#json(this.#writable(plane));
|
|
122
122
|
let text = `Write the handoff draft at \`OUTPUT_HANDOFF\` per this writable subset — the engine validates it, then materializes the final carrier in place; fields not listed here are engine-reserved, do not write them.\n\n\`\`\`json\n${carrier}\n\`\`\``;
|
|
123
123
|
if (evidence) {
|
|
124
124
|
text += `\n\nThe evidence file (\`${evidencePrefix}-{key}-test-evidence.json\` under \`WORKSPACE_DIR\`) must comply with this schema — the engine reads it back with the same stakes:\n\n\`\`\`json\n${this.#json(EVIDENCE)}\n\`\`\``;
|
|
@@ -129,15 +129,15 @@ export class HandoffSchema {
|
|
|
129
129
|
evidenceSchemaText() {
|
|
130
130
|
return this.#json(EVIDENCE);
|
|
131
131
|
}
|
|
132
|
-
/** Projection ② — validate a child draft against a
|
|
132
|
+
/** Projection ② — validate a child draft against a plane's writable subset. Every
|
|
133
133
|
* problem is a read-back BLOCK; the draft is left untouched for the child's
|
|
134
134
|
* resume (never overwritten — the engine never clobbers a child's work). */
|
|
135
|
-
violations(
|
|
135
|
+
violations(plane, value) {
|
|
136
136
|
const problems = [];
|
|
137
|
-
this.#check(
|
|
137
|
+
this.#check(this.#writable(plane), value, "", problems);
|
|
138
138
|
return problems.map((problem) => problem.path.length === 0 ? problem.reason : `${problem.path}: ${problem.reason}`);
|
|
139
139
|
}
|
|
140
|
-
/** Projection ② — validate the test-evidence file (
|
|
140
|
+
/** Projection ② — validate the test-evidence file (work-plane wave / branch rounds). */
|
|
141
141
|
evidenceViolations(value) {
|
|
142
142
|
if (value === null || value === undefined)
|
|
143
143
|
return ["the evidence file is missing"];
|
|
@@ -145,11 +145,11 @@ export class HandoffSchema {
|
|
|
145
145
|
this.#check(EVIDENCE, value, "", problems);
|
|
146
146
|
return problems.map((problem) => problem.path.length === 0 ? problem.reason : `${problem.path}: ${problem.reason}`);
|
|
147
147
|
}
|
|
148
|
-
/** The round conclusion, DERIVED at judgment time from the
|
|
149
|
-
*
|
|
150
|
-
* The
|
|
148
|
+
/** The round conclusion, DERIVED at judgment time from the plane — the single
|
|
149
|
+
* source the review/fix ledger legs read (D27 · judgment face ⊥ input face).
|
|
150
|
+
* The judge plane rolls its conclusion UP from its findings (defined for every
|
|
151
151
|
* carrier — a review never carries a child-authored status, and the persisted
|
|
152
|
-
* findings carrier holds none). The work
|
|
152
|
+
* findings carrier holds none). The work plane reads its DECLARED status, and the
|
|
153
153
|
* absence of a declaration is itself a fact: an ABSENT status → `undefined` (no
|
|
154
154
|
* conclusion was declared — never an invented approval OR an invented failure ·
|
|
155
155
|
* D27 present-facts-only), while a PRESENT-but-invalid byte (outside the enum the
|
|
@@ -158,13 +158,13 @@ export class HandoffSchema {
|
|
|
158
158
|
* treats undefined as "not a failure", a declared BLOCKED as the failure face), so
|
|
159
159
|
* a work carrier that predates the status field never reads as a fabricated
|
|
160
160
|
* failure. `carrier` is the on-disk carrier (or a freshly built one) — the
|
|
161
|
-
* conclusion is never a stored field, so any
|
|
162
|
-
conclusionOf(
|
|
163
|
-
if (
|
|
161
|
+
* conclusion is never a stored field, so any plane's carrier derives it the same way. */
|
|
162
|
+
conclusionOf(plane, carrier) {
|
|
163
|
+
if (plane === "judge") {
|
|
164
164
|
const findings = Array.isArray(carrier.findings) ? carrier.findings : [];
|
|
165
165
|
return this.rollup(findings);
|
|
166
166
|
}
|
|
167
|
-
// The work
|
|
167
|
+
// The work plane reads its DECLARED status. Absent → undefined (no declaration);
|
|
168
168
|
// present-but-invalid → BLOCKED (a declared conclusion that is malformed is a
|
|
169
169
|
// failure signal, never silently approved). This is the ONE ruling for a work
|
|
170
170
|
// status: the reconstruct's work leg delegates here, so the read-back and the
|
|
@@ -199,23 +199,36 @@ export class HandoffSchema {
|
|
|
199
199
|
}
|
|
200
200
|
return rows;
|
|
201
201
|
}
|
|
202
|
-
/** The
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
/** The plane's writable subset — the ONE projection every consumer reads (prompt
|
|
203
|
+
* fence · read-back validator · dropped-key walk). The properties are CARRIER's
|
|
204
|
+
* own slot declarations filtered in declaration order; the required set comes from
|
|
205
|
+
* the plane table — zero second declaration. */
|
|
206
|
+
planeSchema(plane) {
|
|
207
|
+
return this.#writable(plane);
|
|
206
208
|
}
|
|
207
|
-
/** The draft keys materialize drops — every key the
|
|
208
|
-
* child-writable `properties` slot (extra child fields such as a
|
|
209
|
-
* `
|
|
209
|
+
/** The draft keys materialize drops — every key the plane does not declare as a
|
|
210
|
+
* child-writable `properties` slot (extra child fields such as a work draft
|
|
211
|
+
* `findings`). The read-back validator judges these the same way (drop, never a
|
|
210
212
|
* BLOCK) — materialize surfaces them as the single §8.7 WARN on the carrier's
|
|
211
213
|
* notes. A non-object draft drops nothing here (its shape is the validator's
|
|
212
214
|
* semantic refusal). */
|
|
213
|
-
droppedKeys(
|
|
215
|
+
droppedKeys(plane, value) {
|
|
214
216
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
215
217
|
return [];
|
|
216
|
-
const declared = new Set(Object.keys(
|
|
218
|
+
const declared = new Set(Object.keys(this.#writable(plane).properties ?? {}));
|
|
217
219
|
return Object.keys(value).filter((key) => !declared.has(key));
|
|
218
220
|
}
|
|
221
|
+
/** The plane's writable subset — CARRIER's declared slots filtered to the plane's
|
|
222
|
+
* writable set (declaration order preserved) + the plane's required slots. */
|
|
223
|
+
#writable(plane) {
|
|
224
|
+
const slots = PLANE_SLOTS[plane];
|
|
225
|
+
const properties = {};
|
|
226
|
+
for (const [key, node] of Object.entries(CARRIER.properties)) {
|
|
227
|
+
if (slots.includes(key))
|
|
228
|
+
properties[key] = node;
|
|
229
|
+
}
|
|
230
|
+
return { type: "object", required: [...PLANE_REQUIRED[plane]], properties };
|
|
231
|
+
}
|
|
219
232
|
/** Serialize a declared schema object into the prompt's fence — COMPACT (no pretty
|
|
220
233
|
* indent: the injected text is the per-mode fixed prefix's biggest token cost, and
|
|
221
234
|
* every dispatch pays it in the child context — minify keeps the round cheap). The
|
|
@@ -245,11 +258,10 @@ export class HandoffSchema {
|
|
|
245
258
|
if (obj[key] !== undefined)
|
|
246
259
|
this.#check(sub, obj[key], this.#at(path, key), problems);
|
|
247
260
|
}
|
|
248
|
-
// Non-declared keys (extra child fields such as a
|
|
249
|
-
//
|
|
250
|
-
//
|
|
251
|
-
//
|
|
252
|
-
// refuse the draft.
|
|
261
|
+
// Non-declared keys (extra child fields such as a work-draft `findings`) are
|
|
262
|
+
// DROPPED by materialize, never a BLOCK — the validator and materialize judge
|
|
263
|
+
// the same field the same way (§8.7). Only semantic errors on declared fields
|
|
264
|
+
// (required / type / enum / length) refuse the draft.
|
|
253
265
|
return;
|
|
254
266
|
}
|
|
255
267
|
if (node.type === "array") {
|