@oscaner-skills/cdd-engine 4.1.0 → 4.3.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 +39 -9
- package/README.zh-CN.md +44 -9
- package/dist/contract/completion-criterion.js +351 -0
- package/dist/contract/declare.js +181 -43
- package/dist/contract/doc.js +84 -271
- package/dist/contract/frontmatter.js +2 -1
- package/dist/contract/home-extractors.js +49 -316
- package/dist/contract/invariants.js +400 -296
- package/dist/contract/judge.js +74 -49
- package/dist/contract/lint.js +3 -2
- package/dist/contract/liveness-signal.js +103 -0
- package/dist/contract/markdown-document.js +410 -0
- package/dist/contract/markdown-tree-types.js +6 -0
- package/dist/contract/markdown-tree.js +137 -0
- package/dist/contract/project.js +1 -1
- package/dist/contract/rules.js +106 -0
- package/dist/contract/selector-engine.js +332 -0
- package/dist/contract/selector-spec.js +74 -0
- package/dist/contract/skill-anatomy.js +29 -1
- package/dist/contract/task-block-grammar.js +285 -0
- package/dist/contract/task-blocks.js +65 -0
- package/dist/contract/translate.js +21 -0
- package/dist/contract/wave-width.js +15 -0
- package/dist/face/board-view.js +401 -131
- package/dist/face/capsule.js +66 -89
- package/dist/face/cli.js +174 -48
- package/dist/face/declare.js +59 -23
- package/dist/face/gate.js +117 -40
- package/dist/face/host.js +9 -35
- package/dist/face/init.js +108 -0
- package/dist/face/lifecycle.js +540 -123
- package/dist/face/plugins.js +73 -0
- package/dist/face/preview.js +43 -10
- package/dist/face/projection.js +3 -3
- package/dist/face/route-render.js +51 -21
- package/dist/face/termination.js +135 -261
- package/dist/face/words.js +134 -12
- package/dist/infra/atomic.js +15 -0
- package/dist/infra/git.js +25 -0
- package/dist/infra/proc.js +150 -0
- package/dist/infra/round-log.js +104 -0
- package/dist/infra/runtime.js +16 -4
- package/dist/infra/workspace.js +7 -2
- package/dist/render/brief.js +15 -17
- package/dist/render/skeleton.js +41 -28
- package/dist/render/templates.js +128 -84
- package/dist/session/faces.js +47 -20
- package/dist/session/graph.js +13 -37
- package/dist/session/handoff-schema.js +16 -8
- package/dist/session/inflight.js +282 -0
- package/dist/session/ledger.js +581 -136
- package/dist/session/line-identity.js +33 -0
- package/dist/session/next.js +138 -80
- package/dist/session/preflight.js +276 -68
- package/dist/session/round-naming.js +56 -8
- package/dist/session/run.js +317 -78
- package/dist/session/wave.js +94 -14
- package/package.json +13 -3
- package/dist/infra/process.js +0 -22
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/contract/task-block-grammar.ts
|
|
2
|
+
// P21 §7 — the task-block grammar: the structural constants and the ONE block parse
|
|
3
|
+
// over the document index. The `### Task N:` heading shape and the legacy
|
|
4
|
+
// `- **Key**:` bullet shape normalize into the same `TaskBlock` record, so the
|
|
5
|
+
// block grammar has exactly one home; `PlanTaskBlocksReader` (task-blocks.ts) is
|
|
6
|
+
// the facade every consumer reads through.
|
|
7
|
+
//
|
|
8
|
+
// The parse is split out of the tree facade (markdown-tree.ts) so the block
|
|
9
|
+
// grammar, the document index and the selector engine each own one concern.
|
|
10
|
+
import { TASK_ID_VALUE_PATTERN } from "./declare.js";
|
|
11
|
+
/**
|
|
12
|
+
* TaskBlockGrammar — the task-block structural constants. They live with the ONE
|
|
13
|
+
* block parse, so the grammar has exactly one home.
|
|
14
|
+
*/
|
|
15
|
+
// biome-ignore lint/complexity/noStaticOnlyClass: the plan-mandated static data face — the zero-bare-function discipline admits no standalone constant functions.
|
|
16
|
+
export class TaskBlockGrammar {
|
|
17
|
+
/** The seven reserved section keys, in the canonical document order. */
|
|
18
|
+
static RESERVED = [
|
|
19
|
+
"Objective",
|
|
20
|
+
"Files",
|
|
21
|
+
"Consumes",
|
|
22
|
+
"Produces",
|
|
23
|
+
"Steps",
|
|
24
|
+
"Acceptance",
|
|
25
|
+
"DependsOn",
|
|
26
|
+
];
|
|
27
|
+
/** The task-block heading — `### Task N: <title>` (the title stays optional). */
|
|
28
|
+
static TASK_HEADING = /^Task (\d+):(.*)$/;
|
|
29
|
+
/** The legacy field marker — `- **Key**: <value>`. */
|
|
30
|
+
static LEGACY_FIELD = /^- \*\*(.+?)\*\*:(.*)$/;
|
|
31
|
+
/** The step bullet — a list item's text line. */
|
|
32
|
+
static STEP_LINE = /^[-*]\s+(.*)$/;
|
|
33
|
+
/** The `— checkable:` clause separator. */
|
|
34
|
+
static CHECKABLE = "— checkable:";
|
|
35
|
+
/** A dependency id token — the declared `DependsOn id` value domain (the SAME
|
|
36
|
+
* source string the registry element carries). */
|
|
37
|
+
static ID_TOKEN = new RegExp(TASK_ID_VALUE_PATTERN);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* TaskBlocksParser — the ONE `### Task N:` block parse over the document index.
|
|
41
|
+
* The parse is lazy (most documents carry no task block) and cached; the field
|
|
42
|
+
* spans ride beside the blocks so a child walk can scope itself to one field.
|
|
43
|
+
*
|
|
44
|
+
* Rule zero (over the 200-line class limit): the block parse stays one class because
|
|
45
|
+
* the two node shapes normalize into one record and share the section-span
|
|
46
|
+
* machinery — splitting by shape would duplicate the boundary logic.
|
|
47
|
+
*/
|
|
48
|
+
export class TaskBlocksParser {
|
|
49
|
+
#document;
|
|
50
|
+
#parsed = null;
|
|
51
|
+
constructor(document) {
|
|
52
|
+
this.#document = document;
|
|
53
|
+
}
|
|
54
|
+
/** The `### Task N:` blocks of the document, in document order. */
|
|
55
|
+
tasks() {
|
|
56
|
+
return this.#parse().blocks;
|
|
57
|
+
}
|
|
58
|
+
/** The field spans of one block (parallel to the block's `fields`). */
|
|
59
|
+
sectionsOf(index) {
|
|
60
|
+
return this.#parse().sections[index] ?? [];
|
|
61
|
+
}
|
|
62
|
+
/** The task-field candidates — the block's `#### Key` heading line plus its value
|
|
63
|
+
* lines (the legacy bullet shape normalizes into the same fields, so one
|
|
64
|
+
* declaration locates both). */
|
|
65
|
+
fieldCandidates() {
|
|
66
|
+
const out = [];
|
|
67
|
+
for (const [index, block] of this.tasks().entries()) {
|
|
68
|
+
const spans = this.sectionsOf(index);
|
|
69
|
+
for (const [fieldIndex, field] of block.fields.entries()) {
|
|
70
|
+
const span = spans[fieldIndex];
|
|
71
|
+
const start = span?.start ?? block.range.start;
|
|
72
|
+
const end = span?.end ?? block.range.end;
|
|
73
|
+
const anchor = `#### ${field.key}`;
|
|
74
|
+
out.push({
|
|
75
|
+
text: anchor,
|
|
76
|
+
bare: anchor,
|
|
77
|
+
lines: field.lines,
|
|
78
|
+
line: start,
|
|
79
|
+
from: start,
|
|
80
|
+
to: end,
|
|
81
|
+
});
|
|
82
|
+
field.lines.forEach((line, lineIndex) => {
|
|
83
|
+
out.push({
|
|
84
|
+
text: line,
|
|
85
|
+
bare: this.#document.bareOf(span?.entries[lineIndex]?.line ?? start),
|
|
86
|
+
lines: [line],
|
|
87
|
+
line: span?.entries[lineIndex]?.line ?? start,
|
|
88
|
+
from: start,
|
|
89
|
+
to: end,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
/** The task-step candidates — one per raw step line of a block's `Steps` field
|
|
97
|
+
* (the line the step shapes judge, never a reconstruction). The bare view is the
|
|
98
|
+
* document's own inline-code span map, the SAME boundary every prose node reads. */
|
|
99
|
+
stepCandidates() {
|
|
100
|
+
const out = [];
|
|
101
|
+
for (const [index, block] of this.tasks().entries()) {
|
|
102
|
+
const steps = this.sectionsOf(index).find((span) => span.key === "Steps");
|
|
103
|
+
if (steps === undefined)
|
|
104
|
+
continue;
|
|
105
|
+
for (const entry of steps.entries) {
|
|
106
|
+
if (!TaskBlockGrammar.STEP_LINE.test(entry.text))
|
|
107
|
+
continue;
|
|
108
|
+
out.push({
|
|
109
|
+
text: entry.text,
|
|
110
|
+
bare: this.#document.bareOf(entry.line),
|
|
111
|
+
lines: [entry.text],
|
|
112
|
+
line: entry.line,
|
|
113
|
+
from: block.range.start,
|
|
114
|
+
to: block.range.end,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/** The block parse result (lazy; one parse per document). */
|
|
121
|
+
#parse() {
|
|
122
|
+
if (this.#parsed === null)
|
|
123
|
+
this.#parsed = this.#parseTasks();
|
|
124
|
+
return this.#parsed;
|
|
125
|
+
}
|
|
126
|
+
/** Parse the `### Task N:` blocks from the mdast top-level headings. */
|
|
127
|
+
#parseTasks() {
|
|
128
|
+
const nodes = this.#document.topNodes();
|
|
129
|
+
const blocks = [];
|
|
130
|
+
const allSections = [];
|
|
131
|
+
for (const [index, node] of nodes.entries()) {
|
|
132
|
+
if (node.type !== "heading" || node.depth !== 3)
|
|
133
|
+
continue;
|
|
134
|
+
const match = TaskBlockGrammar.TASK_HEADING.exec(this.#document.textOf(node).trim());
|
|
135
|
+
if (match === null)
|
|
136
|
+
continue;
|
|
137
|
+
const start = node.position?.start?.line ?? 0;
|
|
138
|
+
if (start === 0)
|
|
139
|
+
continue;
|
|
140
|
+
const boundary = this.#blockBoundary(nodes, index);
|
|
141
|
+
const inner = nodes.slice(index + 1, boundary.index);
|
|
142
|
+
const shape = inner.some((child) => child.type === "heading" &&
|
|
143
|
+
child.depth === 4 &&
|
|
144
|
+
TaskBlockGrammar.RESERVED.includes(this.#document.textOf(child).trim()))
|
|
145
|
+
? "heading"
|
|
146
|
+
: "legacy";
|
|
147
|
+
const end = boundary.line - 1;
|
|
148
|
+
const sections = shape === "heading"
|
|
149
|
+
? this.#headingSections(inner, end)
|
|
150
|
+
: this.#legacySections(inner, start + 1, end);
|
|
151
|
+
const block = {
|
|
152
|
+
id: Number(match[1]),
|
|
153
|
+
heading: this.#document.line(start),
|
|
154
|
+
fields: sections.map((section) => ({ key: section.key, lines: section.lines })),
|
|
155
|
+
steps: this.#stepsOf(sections),
|
|
156
|
+
range: { start, end },
|
|
157
|
+
shape,
|
|
158
|
+
};
|
|
159
|
+
this.#assertNoDuplicateKeys(block);
|
|
160
|
+
blocks.push(block);
|
|
161
|
+
allSections.push(sections);
|
|
162
|
+
}
|
|
163
|
+
return { blocks, sections: allSections };
|
|
164
|
+
}
|
|
165
|
+
/** The node index/line at which one block ends — the first following top-level
|
|
166
|
+
* heading of rank 3 or shallower, or the document's last non-blank line. */
|
|
167
|
+
#blockBoundary(nodes, index) {
|
|
168
|
+
for (let next = index + 1; next < nodes.length; next += 1) {
|
|
169
|
+
const node = nodes[next];
|
|
170
|
+
if (node?.type !== "heading" || (node.depth ?? 0) > 3)
|
|
171
|
+
continue;
|
|
172
|
+
return { index: next, line: node.position?.start?.line ?? this.#document.lineCount() };
|
|
173
|
+
}
|
|
174
|
+
return { index: nodes.length, line: this.#document.lineCount() + 1 };
|
|
175
|
+
}
|
|
176
|
+
/** The heading sections of a new-shape block — every depth-4 heading partitions
|
|
177
|
+
* the block; a heading with no body still registers (the author's empty value). */
|
|
178
|
+
#headingSections(inner, blockEnd) {
|
|
179
|
+
const sections = [];
|
|
180
|
+
for (const [index, node] of inner.entries()) {
|
|
181
|
+
if (node?.type !== "heading" || node.depth !== 4)
|
|
182
|
+
continue;
|
|
183
|
+
const line = node.position?.start?.line;
|
|
184
|
+
if (line === undefined)
|
|
185
|
+
continue;
|
|
186
|
+
let end = blockEnd;
|
|
187
|
+
for (const next of inner.slice(index + 1)) {
|
|
188
|
+
const nextLine = next?.position?.start?.line;
|
|
189
|
+
if (next?.type === "heading" && nextLine !== undefined) {
|
|
190
|
+
end = nextLine - 1;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const entries = this.#valueEntries(line + 1, end);
|
|
195
|
+
sections.push({
|
|
196
|
+
key: this.#document.textOf(node).trim(),
|
|
197
|
+
start: line,
|
|
198
|
+
end,
|
|
199
|
+
lines: entries.map((entry) => entry.text),
|
|
200
|
+
entries,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return sections;
|
|
204
|
+
}
|
|
205
|
+
/** The legacy sections of a compatibility-shape block — the `- **Key**:` markers
|
|
206
|
+
* and their continuation runs. A `####` extension section inside the block is a
|
|
207
|
+
* field of its own and never leaks into the preceding bullet's run. */
|
|
208
|
+
#legacySections(inner, from, to) {
|
|
209
|
+
const spans = this.#headingSections(inner, to);
|
|
210
|
+
const inSpan = (line) => spans.some((span) => line >= span.start && line <= span.end);
|
|
211
|
+
const sections = [];
|
|
212
|
+
for (let line = from; line <= to; line += 1) {
|
|
213
|
+
if (inSpan(line))
|
|
214
|
+
continue;
|
|
215
|
+
const match = TaskBlockGrammar.LEGACY_FIELD.exec(this.#document.line(line));
|
|
216
|
+
if (match === null)
|
|
217
|
+
continue;
|
|
218
|
+
let end = to;
|
|
219
|
+
for (let next = line + 1; next <= to; next += 1) {
|
|
220
|
+
if (inSpan(next) || TaskBlockGrammar.LEGACY_FIELD.test(this.#document.line(next))) {
|
|
221
|
+
end = next - 1;
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const rem = (match[2] ?? "").trim();
|
|
226
|
+
const rest = this.#valueEntries(line + 1, end);
|
|
227
|
+
const entries = rem === "" ? rest : [{ text: rem, line }, ...rest];
|
|
228
|
+
sections.push({
|
|
229
|
+
key: (match[1] ?? "").trim(),
|
|
230
|
+
start: line,
|
|
231
|
+
end,
|
|
232
|
+
lines: entries.map((entry) => entry.text),
|
|
233
|
+
entries,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return [...sections, ...spans];
|
|
237
|
+
}
|
|
238
|
+
/** The trimmed, blank-dropping raw lines of one inclusive 1-based span, each
|
|
239
|
+
* carrying its document line number. */
|
|
240
|
+
#valueEntries(from, to) {
|
|
241
|
+
const out = [];
|
|
242
|
+
for (let line = from; line <= to; line += 1) {
|
|
243
|
+
const text = this.#document.line(line).trim();
|
|
244
|
+
if (text !== "")
|
|
245
|
+
out.push({ text, line });
|
|
246
|
+
}
|
|
247
|
+
return out;
|
|
248
|
+
}
|
|
249
|
+
/** The parsed steps of a block — the `Steps` field's bullet lines. */
|
|
250
|
+
#stepsOf(sections) {
|
|
251
|
+
const steps = sections.find((section) => section.key === "Steps");
|
|
252
|
+
if (steps === undefined)
|
|
253
|
+
return [];
|
|
254
|
+
const out = [];
|
|
255
|
+
for (const line of steps.lines) {
|
|
256
|
+
const match = TaskBlockGrammar.STEP_LINE.exec(line);
|
|
257
|
+
if (match === null)
|
|
258
|
+
continue;
|
|
259
|
+
const text = (match[1] ?? "").trim();
|
|
260
|
+
const marker = text.indexOf(TaskBlockGrammar.CHECKABLE);
|
|
261
|
+
if (marker === -1) {
|
|
262
|
+
out.push({ action: text, checkable: null });
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
out.push({
|
|
266
|
+
action: text.slice(0, marker).trim(),
|
|
267
|
+
checkable: text.slice(marker + TaskBlockGrammar.CHECKABLE.length).trim(),
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
return out;
|
|
271
|
+
}
|
|
272
|
+
/** Reject a duplicated reserved key inside one block (the section identity is the
|
|
273
|
+
* parse face's own invariant, loud at parse time). */
|
|
274
|
+
#assertNoDuplicateKeys(block) {
|
|
275
|
+
const seen = new Set();
|
|
276
|
+
for (const field of block.fields) {
|
|
277
|
+
if (!TaskBlockGrammar.RESERVED.includes(field.key))
|
|
278
|
+
continue;
|
|
279
|
+
if (seen.has(field.key)) {
|
|
280
|
+
throw new Error(`task ${block.id} carries the reserved section "#### ${field.key}" more than once`);
|
|
281
|
+
}
|
|
282
|
+
seen.add(field.key);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/contract/task-blocks.ts
|
|
2
|
+
// P21 §7 — the plan task-block contract: the record family plus the reader facade
|
|
3
|
+
// over the ONE block parse (markdown-tree.ts). The block STRUCTURE is read through
|
|
4
|
+
// the markdown tree instead of the retired line-marker grammar:
|
|
5
|
+
//
|
|
6
|
+
// · the new shape carries the seven reserved sections as `#### Key` headings inside
|
|
7
|
+
// a `### Task N:` block; any additional `####` section is an extension section
|
|
8
|
+
// (body text only — it never participates in the required/domain judgment);
|
|
9
|
+
// · the legacy bullet shape (`- **Key**: …`) stays readable as a compatibility
|
|
10
|
+
// input: the normalization of the two node shapes into ONE `TaskBlock` is a
|
|
11
|
+
// method of the tree's block parse, never a second declaration in the registry;
|
|
12
|
+
// · the block's `range` (1-based line numbers) is the brief's slice basis — a
|
|
13
|
+
// line-scan that stops at any `#` heading truncates a block at its first `####`
|
|
14
|
+
// child, so a heading-shaped plan would render a brief with missing sections.
|
|
15
|
+
//
|
|
16
|
+
// Module-level exports are types / the class — zero behavior-carrying bare functions.
|
|
17
|
+
import { TASK_ID_VALUE_PATTERN } from "./declare.js";
|
|
18
|
+
import { MarkdownTree, TaskBlockGrammar } from "./markdown-tree.js";
|
|
19
|
+
/**
|
|
20
|
+
* PlanTaskBlocksReader — the plan's task-block read face: a thin facade over the
|
|
21
|
+
* tree's block parse, so the block grammar lives in ONE place (markdown-tree.ts)
|
|
22
|
+
* and every consumer — the graph's `DependsOn`, the brief's slices, the skeleton —
|
|
23
|
+
* reads the same `TaskBlock` records.
|
|
24
|
+
*/
|
|
25
|
+
export class PlanTaskBlocksReader {
|
|
26
|
+
/** The seven reserved section keys, in the canonical document order. */
|
|
27
|
+
static RESERVED = TaskBlockGrammar.RESERVED;
|
|
28
|
+
/** The task-block heading — `### Task N: <title>` (the title stays optional). */
|
|
29
|
+
static TASK_HEADING = TaskBlockGrammar.TASK_HEADING;
|
|
30
|
+
/** The legacy field marker — `- **Key**: <value>`. */
|
|
31
|
+
static LEGACY_FIELD = TaskBlockGrammar.LEGACY_FIELD;
|
|
32
|
+
/** The step bullet — a list item's text line. */
|
|
33
|
+
static STEP_LINE = TaskBlockGrammar.STEP_LINE;
|
|
34
|
+
/** The `— checkable:` clause separator. */
|
|
35
|
+
static CHECKABLE = TaskBlockGrammar.CHECKABLE;
|
|
36
|
+
/** A dependency id token — the declared `DependsOn id` value domain (the SAME
|
|
37
|
+
* source string the registry element carries). */
|
|
38
|
+
static ID_TOKEN = new RegExp(TASK_ID_VALUE_PATTERN);
|
|
39
|
+
/** Parse a whole plan document into its `### Task N:` blocks. */
|
|
40
|
+
parse(content) {
|
|
41
|
+
return MarkdownTree.parse(content).tasks();
|
|
42
|
+
}
|
|
43
|
+
/** The dependency ids one block declares — the `DependsOn` section's FIRST line
|
|
44
|
+
* (the declared single-line value; `none` / empty carries zero edges). The
|
|
45
|
+
* parenthetical tail after `(` / `(` is prose, never a dependency. */
|
|
46
|
+
dependsOn(block) {
|
|
47
|
+
const field = block.fields.find((entry) => entry.key === "DependsOn");
|
|
48
|
+
const first = field?.lines.find((line) => line.trim().length > 0);
|
|
49
|
+
if (first === undefined)
|
|
50
|
+
return [];
|
|
51
|
+
const prefix = first.split(/[((]/)[0] ?? "";
|
|
52
|
+
const ids = [];
|
|
53
|
+
for (const token of prefix.split(/[,\s]+/)) {
|
|
54
|
+
if (PlanTaskBlocksReader.ID_TOKEN.test(token))
|
|
55
|
+
ids.push(Number(token));
|
|
56
|
+
}
|
|
57
|
+
return [...new Set(ids)].sort((left, right) => left - right);
|
|
58
|
+
}
|
|
59
|
+
/** The body text of one `## Heading` section (the brief's `## Constraints` mirror)
|
|
60
|
+
* — the tree's section read, so a deeper `###`/`####` heading inside the section
|
|
61
|
+
* never truncates it. "" when absent. */
|
|
62
|
+
section(content, heading) {
|
|
63
|
+
return MarkdownTree.parse(content).sectionText(heading);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -21,6 +21,27 @@
|
|
|
21
21
|
// capsule machine face (status · next: · CDD_BLOCKED:) is deliberately NOT in the
|
|
22
22
|
// locale rows — the machine surface is English-constant and never localizable.
|
|
23
23
|
// Module-level exports are types / the class — zero behavior-carrying bare functions.
|
|
24
|
+
import { FrontMatterExtractor } from "./frontmatter.js";
|
|
25
|
+
/**
|
|
26
|
+
* RowSource — the row-source seam: the ONE place the engine canonicalizes a
|
|
27
|
+
* document. `read(content)` resolves the front-matter head on the RAW content,
|
|
28
|
+
* then canonicalizes the body ONCE (never a per-line translator API), so every
|
|
29
|
+
* consumer of the normalized view — the parse face, the tree, the judgment
|
|
30
|
+
* context, a foreign document's lineage read — reads the SAME bytes.
|
|
31
|
+
*/
|
|
32
|
+
export class RowSource {
|
|
33
|
+
/** The translator the row source canonicalizes through. */
|
|
34
|
+
#translator;
|
|
35
|
+
constructor(translator) {
|
|
36
|
+
this.#translator = translator;
|
|
37
|
+
}
|
|
38
|
+
/** Split + canonicalize one document into its head and normalized body. */
|
|
39
|
+
read(content) {
|
|
40
|
+
const { head, body } = FrontMatterExtractor.split(content);
|
|
41
|
+
const text = this.#translator.canonicalize(body);
|
|
42
|
+
return { head, text, lines: text.split("\n") };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
24
45
|
/**
|
|
25
46
|
* Translator — the single bidirectional translation layer. canonicalize() recognizes
|
|
26
47
|
* an input line — every registered Chinese alias span maps to its canonical English
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/contract/wave-width.ts
|
|
2
|
+
// P22 T8 — the wave-width ceiling's ONE declaration (design spec §6): a wave may carry
|
|
3
|
+
// at most three tasks. Three readers share this single value — the plan-scope rule
|
|
4
|
+
// (`wave-width-at-most-three`), the dispatch face's two hard rejections
|
|
5
|
+
// (`wave-too-wide` / `too-many-tasks`) and their wording — so changing the limit here
|
|
6
|
+
// changes all of them at once.
|
|
7
|
+
//
|
|
8
|
+
// The value lives on the contract plane (not in `session/`) so the rule surface can read
|
|
9
|
+
// it without importing the session plane: the direction is session → contract, never the
|
|
10
|
+
// reverse. `session/next.ts` re-exports it as the dispatch face's constant, beside
|
|
11
|
+
// `REVIEW_CYCLE_CAP`.
|
|
12
|
+
//
|
|
13
|
+
// Module-level exports are the constant — zero behavior-carrying bare functions.
|
|
14
|
+
/** The wave-width ceiling — the most tasks one dispatch wave (one task layer) may carry. */
|
|
15
|
+
export const MAX_TASKS_PER_WAVE = 3;
|