@oscaner-skills/cdd-engine 4.4.0 → 4.5.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/dist/contract/doc-body.js +77 -0
- package/dist/contract/invariants.js +58 -1
- package/dist/contract/rules.js +8 -2
- package/dist/face/board-view.js +9 -9
- package/dist/face/cli.js +136 -99
- package/dist/face/gate.js +61 -149
- package/dist/session/dispatch-authority.js +282 -0
- package/dist/session/ledger.js +12 -6
- package/dist/session/line-identity.js +2 -1
- package/dist/session/next.js +55 -16
- package/dist/session/pipeline.js +13 -0
- package/dist/session/preflight.js +10 -26
- package/dist/session/run.js +8 -7
- package/dist/session/wave.js +6 -6
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/contract/doc-body.ts
|
|
2
|
+
// P26 T1 (spec §1.2/§1.3) — the doc-body projection: the ONE slice every
|
|
3
|
+
// `doc-revision` hashes. A reviewed document's identity is its BODY, never its
|
|
4
|
+
// bookkeeping: the front-matter head (`version:`, `date:`, …) and the
|
|
5
|
+
// `## Change history` register are closed-out registrations, so a write to either
|
|
6
|
+
// must not reopen a reviewed line, while a substantive body edit still drifts.
|
|
7
|
+
//
|
|
8
|
+
// The projection strips exactly two faces and nothing else:
|
|
9
|
+
// · the opening YAML block — the first `---` fence through the next `---` fence
|
|
10
|
+
// (fence recognition only: no YAML parse, and a `---` later in the body is
|
|
11
|
+
// body, not a fence);
|
|
12
|
+
// · the rank-2 `## Change history` section — located through
|
|
13
|
+
// `MarkdownTree.sections()` (the tree's rank-2 read), never a bare regex over
|
|
14
|
+
// the whole text, so a fenced sample of that heading inside the body stays.
|
|
15
|
+
// With neither face present the projection returns the input verbatim — the
|
|
16
|
+
// mapping is byte-identical there by construction, never an empty document.
|
|
17
|
+
var _a;
|
|
18
|
+
import { FrontMatterExtractor } from "./frontmatter.js";
|
|
19
|
+
import { MarkdownTree } from "./markdown-tree.js";
|
|
20
|
+
/**
|
|
21
|
+
* DocBodyProjection — the reviewed-body slice: `project(content)` returns the
|
|
22
|
+
* document with its bookkeeping faces removed. One stateless read; the hash
|
|
23
|
+
* itself stays at the single caller (`ReviewRefs#docRevision`), so this class
|
|
24
|
+
* answers WHAT the body is and never HOW it is digested.
|
|
25
|
+
*/
|
|
26
|
+
export class DocBodyProjection {
|
|
27
|
+
/** The normalized rank-2 heading of the registration section — the one section
|
|
28
|
+
* name the projection strips (compared after heading normalization). */
|
|
29
|
+
static CHANGE_HISTORY = "change history";
|
|
30
|
+
/** Project a document onto its reviewed body: front matter and the change-history
|
|
31
|
+
* section removed, every other line kept in order. Returns the input unchanged
|
|
32
|
+
* when neither face is present (byte-identical, never an empty string). */
|
|
33
|
+
project(content) {
|
|
34
|
+
const lines = FrontMatterExtractor.lineSplit(content);
|
|
35
|
+
const bodyStart = this.#bodyStart(lines);
|
|
36
|
+
const dropped = this.#changeHistoryLines(lines.slice(bodyStart));
|
|
37
|
+
if (bodyStart === 0 && dropped.size === 0)
|
|
38
|
+
return content;
|
|
39
|
+
const kept = lines.filter((_, index) => index >= bodyStart && !dropped.has(index - bodyStart));
|
|
40
|
+
return FrontMatterExtractor.lineJoin(kept);
|
|
41
|
+
}
|
|
42
|
+
/** The first body line's index — past the closing fence when the document opens
|
|
43
|
+
* with one, 0 otherwise (a `---` deeper in the body is body, not a fence). */
|
|
44
|
+
#bodyStart(lines) {
|
|
45
|
+
if (lines[0]?.trim() !== "---")
|
|
46
|
+
return 0;
|
|
47
|
+
const closing = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
48
|
+
return closing === -1 ? 0 : closing + 1;
|
|
49
|
+
}
|
|
50
|
+
/** The body-relative line indices of every `## Change history` section — the
|
|
51
|
+
* heading line plus its section body, read from the tree's rank-2 sections. */
|
|
52
|
+
#changeHistoryLines(body) {
|
|
53
|
+
const dropped = new Set();
|
|
54
|
+
const tree = MarkdownTree.parse(FrontMatterExtractor.lineJoin(body));
|
|
55
|
+
for (const section of tree.sections()) {
|
|
56
|
+
if (!_a.#isChangeHistory(section.text))
|
|
57
|
+
continue;
|
|
58
|
+
// `section.line` is 1-based: the heading sits at index line-1 and the section
|
|
59
|
+
// body runs `section.lines.length` lines further.
|
|
60
|
+
for (let index = section.line - 1; index < section.line + section.lines.length; index++) {
|
|
61
|
+
dropped.add(index);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return dropped;
|
|
65
|
+
}
|
|
66
|
+
/** Whether a heading text normalizes to the change-history name — fence markers
|
|
67
|
+
* and surrounding whitespace dropped, case folded. */
|
|
68
|
+
static #isChangeHistory(heading) {
|
|
69
|
+
const name = heading
|
|
70
|
+
.trim()
|
|
71
|
+
.replace(/^#+\s*/, "")
|
|
72
|
+
.trim()
|
|
73
|
+
.toLowerCase();
|
|
74
|
+
return name === _a.CHANGE_HISTORY;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
_a = DocBodyProjection;
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// doc scope — presence (with the registration-uniqueness leg) · domain ·
|
|
7
7
|
// crosslink · section-order · continuity · residue · hollow ·
|
|
8
8
|
// file-existence · sibling-scan · link-shape · slug-ref ·
|
|
9
|
-
// cross-doc-chain · section-scoped-domain
|
|
9
|
+
// cross-doc-chain · section-scoped-domain ·
|
|
10
|
+
// phase-design-spec-is-phase-spec;
|
|
10
11
|
// the change-history family — change-history-version-unique ·
|
|
11
12
|
// front-matter-version-in-lineage ·
|
|
12
13
|
// change-history-row-not-in-other-table · list-marker-not-doubled;
|
|
@@ -25,6 +26,7 @@ import path from "node:path";
|
|
|
25
26
|
import { ENGINE_DOC_ROOTS } from "../infra/doc-roots.js";
|
|
26
27
|
import { SlugIndex } from "../infra/slug-index.js";
|
|
27
28
|
import { docTypeParsers, MarkdownPrimitives } from "./doc.js";
|
|
29
|
+
import { FrontMatterExtractor } from "./frontmatter.js";
|
|
28
30
|
import { RowSource } from "./translate.js";
|
|
29
31
|
import { MAX_TASKS_PER_WAVE } from "./wave-width.js";
|
|
30
32
|
// ---------------------------------------------------------------------------
|
|
@@ -984,6 +986,61 @@ export class SiblingScanInvariant extends FileExistenceInvariant {
|
|
|
984
986
|
];
|
|
985
987
|
}
|
|
986
988
|
}
|
|
989
|
+
/** phase-design-spec-is-phase-spec — a Phase-inventory row's Design-spec cell must
|
|
990
|
+
* point at a document declaring `doc-type: phase-spec` (§4.4: the belonging judgment
|
|
991
|
+
* made executable). A phase row registered in a program's ledger cannot borrow a
|
|
992
|
+
* bespoke `single-spec` as its design: either the design belongs to the program (and
|
|
993
|
+
* is therefore a phase-spec) or it belongs nowhere and the row must leave the
|
|
994
|
+
* inventory. The cell's link target resolves through the ONE link-space reading
|
|
995
|
+
* (`FileExistenceInvariant.targetPath`); the target document's front-matter
|
|
996
|
+
* `doc-type:` is the judged fact — a document declaring no doc-type at all fails
|
|
997
|
+
* the same "must declare phase-spec" shape. Present facts only: a cell with no
|
|
998
|
+
* single bare link target, a placeholder, or a target the seam cannot read is NOT
|
|
999
|
+
* judged — a missing file is `file-existence`'s call, never a doc-type
|
|
1000
|
+
* contradiction. */
|
|
1001
|
+
export class PhaseDesignSpecIsPhaseSpecInvariant extends Invariant {
|
|
1002
|
+
name = "phase-design-spec-is-phase-spec";
|
|
1003
|
+
evaluate(ctx) {
|
|
1004
|
+
if (ctx.docKey !== "overall")
|
|
1005
|
+
return [];
|
|
1006
|
+
const data = this.record(ctx, "overall");
|
|
1007
|
+
if (data === null)
|
|
1008
|
+
return [];
|
|
1009
|
+
const findings = [];
|
|
1010
|
+
for (const phase of data.chain.phases) {
|
|
1011
|
+
const docType = this.#targetDocType(ctx, phase.designCell);
|
|
1012
|
+
// `undefined` = not judged (no judgeable target); `null` = the target declares
|
|
1013
|
+
// no doc-type, which is red — the cell must point at a phase-spec.
|
|
1014
|
+
if (docType === undefined || docType === "phase-spec")
|
|
1015
|
+
continue;
|
|
1016
|
+
findings.push(this.finding(ctx, `Phase inventory · ${phase.id}`, PhaseDesignSpecIsPhaseSpecInvariant.#messageOf(phase.id, docType), "either register this design as a phase document (doc-type: phase-spec, with program: and parent-version: naming this program) or drop the row from the Phase inventory"));
|
|
1017
|
+
}
|
|
1018
|
+
return findings;
|
|
1019
|
+
}
|
|
1020
|
+
/** The one-line message — the row, the doc-type the target actually declares.
|
|
1021
|
+
* A target declaring no doc-type reads as that absence, never as an empty value. */
|
|
1022
|
+
static #messageOf(phaseId, docType) {
|
|
1023
|
+
const declared = docType === null ? "declares no doc-type" : `declares doc-type: ${docType}`;
|
|
1024
|
+
return `the Phase inventory row ${phaseId} points its Design spec at a document that ${declared} — a registered phase's design spec must be a phase-spec`;
|
|
1025
|
+
}
|
|
1026
|
+
/** The `doc-type:` the cell's single link target declares — `undefined` when the
|
|
1027
|
+
* cell carries no judgeable target (no single link, a placeholder, a malformed
|
|
1028
|
+
* target shape, or an unreadable document), null when the readable target
|
|
1029
|
+
* declares no doc-type. */
|
|
1030
|
+
#targetDocType(ctx, cell) {
|
|
1031
|
+
const links = this.linksOnLine(cell);
|
|
1032
|
+
if (links.length !== 1)
|
|
1033
|
+
return undefined;
|
|
1034
|
+
const shape = LinkTargetShape.of(links[0].target);
|
|
1035
|
+
if (shape.target === null || this.isPlaceholder(shape.target))
|
|
1036
|
+
return undefined;
|
|
1037
|
+
const resolved = FileExistenceInvariant.targetPath(ctx.root, ctx.path, shape.target, (p) => ctx.fs.exists(p));
|
|
1038
|
+
const content = ctx.fs.read(resolved);
|
|
1039
|
+
if (content === null)
|
|
1040
|
+
return undefined;
|
|
1041
|
+
return FrontMatterExtractor.split(content).head.docType;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
987
1044
|
/** slug-ref — a `slug-ref` value names an on-disk identity document by `slug:`
|
|
988
1045
|
* (the phase-spec's `program:` → an overall). The value is a SLUG, never a path,
|
|
989
1046
|
* so this face judges it by identity lookup alone (zero path resolution, zero
|
package/dist/contract/rules.js
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
//
|
|
24
24
|
// Module-level exports are types / the declared data — zero behavior-carrying bare
|
|
25
25
|
// functions.
|
|
26
|
-
import { ChangeHistoryVersionUniqueInvariant, ContinuityInvariant, CrossDocChainInvariant, CrosslinkInvariant, DomainInvariant, FileExistenceInvariant, FrontMatterVersionInLineageInvariant, HollowInvariant, LedgerLayeringRule, LedgerTaskSetRule, LinkShapeInvariant, ListMarkerInvariant, PhaseIdUniqueInvariant, PresenceInvariant, ResidueInvariant, RowHomeInvariant, SectionOrderInvariant, SectionScopedDomainInvariant, SiblingScanInvariant, SlugRefInvariant, TaskIdUniqueInvariant, WaveWidthInvariant, } from "./invariants.js";
|
|
27
|
-
/** The rule registry — doc scope
|
|
26
|
+
import { ChangeHistoryVersionUniqueInvariant, ContinuityInvariant, CrossDocChainInvariant, CrosslinkInvariant, DomainInvariant, FileExistenceInvariant, FrontMatterVersionInLineageInvariant, HollowInvariant, LedgerLayeringRule, LedgerTaskSetRule, LinkShapeInvariant, ListMarkerInvariant, PhaseDesignSpecIsPhaseSpecInvariant, PhaseIdUniqueInvariant, PresenceInvariant, ResidueInvariant, RowHomeInvariant, SectionOrderInvariant, SectionScopedDomainInvariant, SiblingScanInvariant, SlugRefInvariant, TaskIdUniqueInvariant, WaveWidthInvariant, } from "./invariants.js";
|
|
27
|
+
/** The rule registry — doc scope 21 rows + ledger scope 2 rows = 23. */
|
|
28
28
|
export const RULE_REGISTRY = [
|
|
29
29
|
{ scope: "doc", id: "presence", docKeys: "all", create: () => new PresenceInvariant() },
|
|
30
30
|
{
|
|
@@ -91,6 +91,12 @@ export const RULE_REGISTRY = [
|
|
|
91
91
|
docKeys: ["plan"],
|
|
92
92
|
create: () => new WaveWidthInvariant(),
|
|
93
93
|
},
|
|
94
|
+
{
|
|
95
|
+
scope: "doc",
|
|
96
|
+
id: "phase-design-spec-is-phase-spec",
|
|
97
|
+
docKeys: ["overall"],
|
|
98
|
+
create: () => new PhaseDesignSpecIsPhaseSpecInvariant(),
|
|
99
|
+
},
|
|
94
100
|
{
|
|
95
101
|
scope: "ledger",
|
|
96
102
|
id: "closed-wave-fits-depends-on-layers",
|
package/dist/face/board-view.js
CHANGED
|
@@ -98,14 +98,14 @@ export class BoardView {
|
|
|
98
98
|
* target (spec §5.2 · D33): a doc shape's class reads its DECLARED type (the
|
|
99
99
|
* front-matter `doc-type:` key — the ONE declaration reading face above), never
|
|
100
100
|
* the filename suffix or the `--type` spelling; the node shapes key by their own
|
|
101
|
-
* type. `blocked` — the key is missing (the renderer prints the BLOCKED face)
|
|
102
|
-
*
|
|
103
|
-
* `
|
|
104
|
-
* derivation: `session/next.ts` never imports a face class, and
|
|
105
|
-
* shares this ONE judgment. The basis is REQUIRED — an unrooted
|
|
106
|
-
* the target against `process.cwd()`, so an engine invoked from
|
|
107
|
-
* could report a declared line as `doc-class-blocked`; the root is
|
|
108
|
-
* object the read face holds. */
|
|
101
|
+
* type. `blocked` — the key is missing (the renderer prints the BLOCKED face).
|
|
102
|
+
* Every declared class is a pipeline key, a standalone `single-spec` included: its
|
|
103
|
+
* closure hands off to `cdd-plan`, never to a terminus. This is the injected seam
|
|
104
|
+
* of the ONE hop derivation: `session/next.ts` never imports a face class, and
|
|
105
|
+
* every read face shares this ONE judgment. The basis is REQUIRED — an unrooted
|
|
106
|
+
* resolve would read the target against `process.cwd()`, so an engine invoked from
|
|
107
|
+
* a subdirectory could report a declared line as `doc-class-blocked`; the root is
|
|
108
|
+
* always the value object the read face holds. */
|
|
109
109
|
static docClassOf(root, target) {
|
|
110
110
|
if (target.type === "plan")
|
|
111
111
|
return "plan";
|
|
@@ -114,7 +114,7 @@ export class BoardView {
|
|
|
114
114
|
if (target.type === "branch")
|
|
115
115
|
return "branch";
|
|
116
116
|
const declared = BoardView.readDocType(root, root.relativize(target.id));
|
|
117
|
-
return declared === null ? "blocked" : declared
|
|
117
|
+
return declared === null ? "blocked" : declared;
|
|
118
118
|
}
|
|
119
119
|
/** The doc file's raw text — an absent/unreadable file reads null (the reads
|
|
120
120
|
* above degrade to null facts, never a throw). */
|
package/dist/face/cli.js
CHANGED
|
@@ -60,7 +60,8 @@ import { Workspace, WorkspaceRoot } from "../infra/workspace.js";
|
|
|
60
60
|
import { BriefRenderer } from "../render/brief.js";
|
|
61
61
|
import { IssueBodyRenderer } from "../render/issue-body.js";
|
|
62
62
|
import { TemplateAssembler } from "../render/templates.js";
|
|
63
|
-
import {
|
|
63
|
+
import { DispatchAuthority, } from "../session/dispatch-authority.js";
|
|
64
|
+
import { TargetFaceTable, targetFaces, } from "../session/faces.js";
|
|
64
65
|
import { TaskGraph } from "../session/graph.js";
|
|
65
66
|
import { HoldingError, InFlight } from "../session/inflight.js";
|
|
66
67
|
import { Ledger } from "../session/ledger.js";
|
|
@@ -104,10 +105,14 @@ export class Cli {
|
|
|
104
105
|
#translator;
|
|
105
106
|
/** The pre-flight board face (the blocked-dispatch wave hint). */
|
|
106
107
|
#graphView;
|
|
107
|
-
/** The lifecycle pre-flight seam (P4.1 T1) — the
|
|
108
|
+
/** The lifecycle pre-flight seam (P4.1 T1) — the STRUCTURE gates the work
|
|
108
109
|
* commands consult before ANY child dispatch (tree-clean → in-flight → graph →
|
|
109
|
-
* plan-ledger →
|
|
110
|
+
* plan-ledger → doc-contract; the CLI orchestrates, never a re-type). */
|
|
110
111
|
#preflight;
|
|
112
|
+
/** The dispatch authority (P27 §2) — the ONE verdict over structure → upstream →
|
|
113
|
+
* line, and the ONE refusal line. The dispatch gate reads it before its first
|
|
114
|
+
* write; the capsule and the board read the same hop the refusal names. */
|
|
115
|
+
#authority;
|
|
111
116
|
/** The contract coordinator — the doc-contract judgment face the pre-flight's
|
|
112
117
|
* doc gate reads (the single interpreter entry; spec §12 · D34 retired the
|
|
113
118
|
* filename→type derivation — the doc type is now the declared header fact read
|
|
@@ -162,7 +167,8 @@ export class Cli {
|
|
|
162
167
|
contract: this.#contract,
|
|
163
168
|
words: this.#words,
|
|
164
169
|
});
|
|
165
|
-
this.#
|
|
170
|
+
this.#authority = opts.authority ?? new DispatchAuthority();
|
|
171
|
+
this.#gate = new CliGate({ brief: this.#brief, authority: this.#authority });
|
|
166
172
|
this.#artifacts = new CliArtifacts({
|
|
167
173
|
io: this.#io,
|
|
168
174
|
projector: this.#projector,
|
|
@@ -470,13 +476,14 @@ export class Cli {
|
|
|
470
476
|
const scene = await this.#sceneOf(verb, type, node, root, parsed);
|
|
471
477
|
if (scene === null)
|
|
472
478
|
return 1;
|
|
473
|
-
// THE pre-flight seam (P4.1 T1 · design §1): the
|
|
474
|
-
// tree-clean → in-flight → graph → plan-ledger →
|
|
475
|
-
//
|
|
476
|
-
// the call + the verdict render (zero re-implemented gate here).
|
|
477
|
-
//
|
|
478
|
-
//
|
|
479
|
-
//
|
|
479
|
+
// THE pre-flight seam (P4.1 T1 · design §1): the STRUCTURE gates —
|
|
480
|
+
// tree-clean → in-flight → graph → plan-ledger → doc-contract — ONE call, the
|
|
481
|
+
// whole sequence lives in the seam (session/preflight.ts), the CLI orchestrates
|
|
482
|
+
// the call + the verdict render (zero re-implemented gate here). The dispatch's
|
|
483
|
+
// own phase is the authority's verdict below (P27 §2), never a second seam. A
|
|
484
|
+
// refused verdict returns before any brief/lifecycle: no child dispatch ever
|
|
485
|
+
// runs. The dirty-tree / doc-contract refusals ride the CDD_BLOCKED channel; the
|
|
486
|
+
// graph / plan-ledger refusals keep the pre-existing refusal face. The doc-face read
|
|
480
487
|
// path is the repoRoot-relative branded `RepoPath` (T4 §2.2 — a bare `string`
|
|
481
488
|
// never reaches the read faces `BoardView.readDocType`/`PreFlightDoc.path`; the
|
|
482
489
|
// CLI feeds the funnel-shaped relative value, each read face erasing to the
|
|
@@ -491,11 +498,9 @@ export class Cli {
|
|
|
491
498
|
// only inspects it; the lifecycle's real dispatch path acquires it after the gate.
|
|
492
499
|
const inflight = new InFlight(scene.workspace.root, scene.workspace.slug);
|
|
493
500
|
const preflight = await this.#preflight.vet({
|
|
494
|
-
verb: verb,
|
|
495
501
|
type,
|
|
496
502
|
repoRoot: scene.workspace.root.repoRoot,
|
|
497
503
|
planText: scene.planText,
|
|
498
|
-
tasks: type === "wave" ? new Set(this.#gate.tasksOf(parsed)) : null,
|
|
499
504
|
ledger: scene.ledger,
|
|
500
505
|
doc: TargetFaceTable.isDocShape(type)
|
|
501
506
|
? {
|
|
@@ -513,19 +518,76 @@ export class Cli {
|
|
|
513
518
|
// preview still judges the same gate, sees the same holder facts, and exits 1.
|
|
514
519
|
stealStale: !parsed.dryRun && parsed.args.stealStale === "true",
|
|
515
520
|
});
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
521
|
+
// The per-invocation batch cursor: the in-memory done set mirrors the on-disk
|
|
522
|
+
// ledger's closed waves (the C5 closure single face) — NOT a "every non-group
|
|
523
|
+
// task pre-done" shortcut. The old shortcut made the frontier yield exactly the
|
|
524
|
+
// requested group, but it also emptied readyBatch() at every closure: a mid-run
|
|
525
|
+
// wave's fix rendered `next: done` instead of the next wave (the {16,22,24} →
|
|
526
|
+
// {25,26,27} bug — the closure routing judged a per-invocation cursor, not the
|
|
527
|
+
// plan's real remaining frontier). The ledger mirror keeps the progress face
|
|
528
|
+
// cross-invocation: the dispatched group's own closure marks in #markTerminal
|
|
529
|
+
// as the loop advances, and the next wave surfaces from the live closed set. The
|
|
530
|
+
// request's own validity (a task id absent from the plan) is a USAGE rejection,
|
|
531
|
+
// judged before any gate, write or child: nothing of the dispatch exists yet.
|
|
532
|
+
let group = null;
|
|
533
|
+
if (type === "wave") {
|
|
534
|
+
group = new Set(this.#gate.tasksOf(parsed));
|
|
535
|
+
const planIds = scene.planText !== null
|
|
536
|
+
? new PlanDocType("plan")
|
|
537
|
+
.parse(scene.planText.split("\n"))
|
|
538
|
+
.taskBlocks.map((block) => block.id)
|
|
539
|
+
: [];
|
|
540
|
+
for (const id of group) {
|
|
541
|
+
if (!planIds.includes(id)) {
|
|
542
|
+
this.#usage(node, `cdd ${verb}: task ${id} not found in the plan`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
for (const id of scene.ledger.closedWaves())
|
|
546
|
+
scene.state.markDone(id);
|
|
547
|
+
}
|
|
548
|
+
const expected = verb === "implement" ? "implement" : verb === "fix" ? "fix" : scene.face.product.reviewLead;
|
|
549
|
+
// THE dispatch verdict (P27 §2.2) — ONE authority over the three legs, in
|
|
550
|
+
// priority order: the structure leg (the pre-flight verdict just judged), the
|
|
551
|
+
// upstream station leg, then this line's own phase. A refusal is ONE verdict —
|
|
552
|
+
// the stderr face, the capsule's `next:` and the board's `next:` all read the
|
|
553
|
+
// same hop, so a command can never name a round another face refuses. The
|
|
554
|
+
// dispatch gate consults the verdict BEFORE its first write: a refused dispatch
|
|
555
|
+
// creates no workspace, no brief, no round.
|
|
556
|
+
const identity = this.#gate.lineIdentity(scene);
|
|
557
|
+
const verdict = this.#authority.verdict({
|
|
558
|
+
verb: verb,
|
|
559
|
+
type,
|
|
560
|
+
structure: preflight,
|
|
561
|
+
line: {
|
|
562
|
+
ledger: scene.ledger,
|
|
563
|
+
words: this.#words,
|
|
564
|
+
// The wave face's frontier source is the run state's own parsed graph (one
|
|
565
|
+
// plan read per invocation); the doc/branch faces carry none.
|
|
566
|
+
graph: scene.state instanceof TaskGraph ? scene.state : null,
|
|
567
|
+
tasks: group,
|
|
568
|
+
lineKey: identity.key,
|
|
569
|
+
doc: identity.doc,
|
|
570
|
+
pipeline: scene.pipeline,
|
|
571
|
+
docClassOf: (candidate) => BoardView.docClassOf(scene.workspace.root.basis, candidate),
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
if (!verdict.allowed) {
|
|
575
|
+
if (verdict.leg === "structure") {
|
|
576
|
+
if (parsed.dryRun && preflight.gate === "in-flight" && preflight.holding !== undefined) {
|
|
577
|
+
// The preview's read-only held face: the SAME gate verdict, rendered as the
|
|
578
|
+
// lock row + the takeover hint, exit 1. Zero write (the preview never
|
|
579
|
+
// acquires / steals / releases).
|
|
580
|
+
for (const line of new Preview({ scene, words: this.#words }).heldBlock(verb, preflight.holding))
|
|
581
|
+
this.#io.stdout(`${line}\n`);
|
|
582
|
+
// The checked face rides the SAME stdout stream here: every dry-run shape
|
|
583
|
+
// (pass / dirty / held / blocked) reports which gates ran.
|
|
584
|
+
this.#renderChecked(preflight, (text) => this.#io.stdout(text));
|
|
585
|
+
return 1;
|
|
586
|
+
}
|
|
587
|
+
this.#renderPreflightBlocked(verb, verdict, preflight);
|
|
526
588
|
return 1;
|
|
527
589
|
}
|
|
528
|
-
this.#
|
|
590
|
+
this.#renderLineRefusal(verb, expected, verdict, scene, preflight);
|
|
529
591
|
return 1;
|
|
530
592
|
}
|
|
531
593
|
// The approved path's checked face (P21 §3.4): the SAME rows the refusal path
|
|
@@ -552,32 +614,6 @@ export class Cli {
|
|
|
552
614
|
// preview names the same path through RoundNaming instead of rendering it.
|
|
553
615
|
if (!parsed.dryRun && type === "wave" && scene.planText !== null)
|
|
554
616
|
scene.briefPath = this.#gate.renderBrief(scene, parsed);
|
|
555
|
-
const expected = verb === "implement" ? "implement" : verb === "fix" ? "fix" : scene.face.product.reviewLead;
|
|
556
|
-
// The per-invocation batch cursor: the in-memory done set mirrors the on-disk
|
|
557
|
-
// ledger's closed waves (the C5 closure single face) — NOT a "every non-group
|
|
558
|
-
// task pre-done" shortcut. The old shortcut made the frontier yield exactly the
|
|
559
|
-
// requested group, but it also emptied readyBatch() at every closure: a mid-run
|
|
560
|
-
// wave's fix rendered `next: done` instead of the next wave (the {16,22,24} →
|
|
561
|
-
// {25,26,27} bug — the closure routing judged a per-invocation cursor, not the
|
|
562
|
-
// plan's real remaining frontier). The ledger mirror keeps the progress face
|
|
563
|
-
// cross-invocation: the dispatched group's own closure marks in #markTerminal
|
|
564
|
-
// as the loop advances, and the next wave surfaces from the live closed set.
|
|
565
|
-
let group = null;
|
|
566
|
-
if (type === "wave") {
|
|
567
|
-
group = new Set(this.#gate.tasksOf(parsed));
|
|
568
|
-
const planIds = scene.planText !== null
|
|
569
|
-
? new PlanDocType("plan")
|
|
570
|
-
.parse(scene.planText.split("\n"))
|
|
571
|
-
.taskBlocks.map((block) => block.id)
|
|
572
|
-
: [];
|
|
573
|
-
for (const id of group) {
|
|
574
|
-
if (!planIds.includes(id)) {
|
|
575
|
-
this.#usage(node, `cdd ${verb}: task ${id} not found in the plan`);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
for (const id of scene.ledger.closedWaves())
|
|
579
|
-
scene.state.markDone(id);
|
|
580
|
-
}
|
|
581
617
|
const statuses = [];
|
|
582
618
|
const dispatch = this.#dispatchOf(scene, parsed);
|
|
583
619
|
const run = new Lifecycle({
|
|
@@ -606,27 +642,6 @@ export class Cli {
|
|
|
606
642
|
// face class.
|
|
607
643
|
docClassOf: (candidate) => BoardView.docClassOf(scene.workspace.root.basis, candidate),
|
|
608
644
|
});
|
|
609
|
-
// The requested-phase gate — the line faces (branch/spec/plan) keep the
|
|
610
|
-
// line-phase readiness check; the task face needs no second gate (the WaveGate's
|
|
611
|
-
// wrong-phase verdict above IS the phase authority for the requested wave).
|
|
612
|
-
if (group === null) {
|
|
613
|
-
const { phase: open, verdict, reviewed } = this.#gate.lineGate(scene);
|
|
614
|
-
if (open !== expected) {
|
|
615
|
-
const pendingBlock = verdict === "pending-fix" ? this.#gate.pendingFixBlock(scene, reviewed) : null;
|
|
616
|
-
const docBlock = open === null ? this.#gate.docLineBlock(scene, reviewed) : null;
|
|
617
|
-
// The generic refusal renders this LINE's own hop (the line frontier's
|
|
618
|
-
// assembly): `<reason> · the next round is <hop>` · `<reason> · next:
|
|
619
|
-
// <station>` · the bare reason. The capsule and the board render the PIPELINE
|
|
620
|
-
// frontier's assembly — a different reader, a different object. The two
|
|
621
|
-
// identity-aware block messages above own their facts (`reviewed` has no
|
|
622
|
-
// Home in `NextHop`) and stay verbatim.
|
|
623
|
-
const reject = pendingBlock ??
|
|
624
|
-
docBlock ??
|
|
625
|
-
this.#gate.lineHopMessage(scene, this.#gate.lineHop(scene), this.#words);
|
|
626
|
-
this.#io.stderr(`cdd ${verb}: cannot dispatch a ${expected} round — ${reject}\n`);
|
|
627
|
-
return 1;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
645
|
// Advance the requested phase across the wave (one dispatch per frame — the
|
|
631
646
|
// lifecycle's "one dispatch, one advance" step), keeping only the LAST step's
|
|
632
647
|
// capsule for the invocation's single stdout face (the per-step intermediate
|
|
@@ -687,7 +702,11 @@ export class Cli {
|
|
|
687
702
|
// The dispatch-entry gate's refusal (the lifecycle's hard child zero-dispatch wiring —
|
|
688
703
|
// structurally unreachable here: the seam already returned above on refusal).
|
|
689
704
|
if (step.preflight !== undefined) {
|
|
690
|
-
|
|
705
|
+
// The lifecycle re-states the seam's refusal (structurally unreachable — the
|
|
706
|
+
// verdict above already returned on it): the structure leg's own line.
|
|
707
|
+
const rejection = this.#authority.structureRefusal(step.preflight);
|
|
708
|
+
if (rejection !== null)
|
|
709
|
+
this.#renderPreflightBlocked(verb, rejection, step.preflight);
|
|
691
710
|
return 1;
|
|
692
711
|
}
|
|
693
712
|
dispatched += 1;
|
|
@@ -770,38 +789,56 @@ export class Cli {
|
|
|
770
789
|
const artifact = read.kind === "ok" ? read.value : null;
|
|
771
790
|
return typeof artifact?.base === "string" ? artifact.base : "";
|
|
772
791
|
}
|
|
773
|
-
/** Render a refused
|
|
774
|
-
* The
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
*
|
|
779
|
-
#renderPreflightBlocked(verb,
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
792
|
+
/** Render a refused STRUCTURE-leg verdict — the work command's BLOCK face (P4.1
|
|
793
|
+
* T1). The structure leg's ONE line (§2.6) is `<reason> · <the seam's own
|
|
794
|
+
* wording>`: the dirty-tree / doc-contract rows ride the CDD_BLOCKED channel (the
|
|
795
|
+
* commit/discard guidance + the named structural findings), the graph /
|
|
796
|
+
* plan-ledger rows keep their refusal face. The leg names no hop — a refused
|
|
797
|
+
* structure carries no `next:` round. */
|
|
798
|
+
#renderPreflightBlocked(verb, rejection, preflight) {
|
|
799
|
+
const message = this.#authority.message(rejection, { detail: preflight.message });
|
|
800
|
+
if (preflight.gate === "tree-clean" ||
|
|
801
|
+
preflight.gate === "in-flight" ||
|
|
802
|
+
preflight.gate === "doc-contract") {
|
|
803
|
+
this.#io.stderr(`${this.#words.station("blocked")} ${message}\n`);
|
|
804
|
+
for (const detail of preflight.details ?? [])
|
|
785
805
|
this.#io.stderr(` ${detail}\n`);
|
|
786
|
-
this.#renderChecked(
|
|
806
|
+
this.#renderChecked(preflight);
|
|
787
807
|
return;
|
|
788
808
|
}
|
|
789
|
-
this.#io.stderr(`cdd ${verb}: ${
|
|
790
|
-
for (const detail of
|
|
809
|
+
this.#io.stderr(`cdd ${verb}: ${message}\n`);
|
|
810
|
+
for (const detail of preflight.details ?? [])
|
|
791
811
|
this.#io.stderr(` ${detail}\n`);
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
812
|
+
this.#renderChecked(preflight);
|
|
813
|
+
}
|
|
814
|
+
/** Render a refused LINE-leg verdict (§2.6) — ONE line, `<reason> · next: <the
|
|
815
|
+
* command the capsule and the board print>`. The wave face's split row keeps its
|
|
816
|
+
* wave-board hint (the graph the refusal is about — its done face rides the SAME
|
|
817
|
+
* closedWaves() read the gate judged, one closed set, one source), and the checked
|
|
818
|
+
* face reports the structure gates that passed. */
|
|
819
|
+
#renderLineRefusal(verb, expected, rejection, scene, preflight) {
|
|
820
|
+
const message = this.#authority.message(rejection, {
|
|
821
|
+
command: (hop) => this.#gate.hopCommand(scene, hop, this.#words),
|
|
822
|
+
});
|
|
823
|
+
this.#io.stderr(`cdd ${verb}: cannot dispatch a ${expected} round — ${message}\n`);
|
|
824
|
+
if (rejection.reason === "split" && scene.planText !== null) {
|
|
825
|
+
this.#renderWaveBoard(scene, scene.planText);
|
|
803
826
|
}
|
|
804
|
-
this.#renderChecked(
|
|
827
|
+
this.#renderChecked(preflight);
|
|
828
|
+
}
|
|
829
|
+
/** The wave-board hint of a split refusal — the derived graph the refusal is
|
|
830
|
+
* about, rendered on the stderr detail channel. */
|
|
831
|
+
#renderWaveBoard(scene, planText) {
|
|
832
|
+
const graph = new TaskGraph(new PlanDocType("plan").parse(planText.split("\n")));
|
|
833
|
+
const closed = scene.ledger.closedWaves();
|
|
834
|
+
// The graph title's plan path renders repoRoot-relative (D47 · the ONE shape;
|
|
835
|
+
// `scene.planPath` is argv-origin) — normalized through the scene's OWN basis
|
|
836
|
+
// value object (F2: never a per-call re-wrap).
|
|
837
|
+
const titlePlan = scene.workspace.root.basis.relativize(scene.planPath ?? "");
|
|
838
|
+
for (const line of this.#graphView
|
|
839
|
+
.render(graph.report(closed), `graph: ${titlePlan}`)
|
|
840
|
+
.split("\n"))
|
|
841
|
+
this.#io.stderr(` ${line}\n`);
|
|
805
842
|
}
|
|
806
843
|
/** Render the acquire race's held BLOCK — the in-flight gate's own message face
|
|
807
844
|
* (`Words.inFlightBlocked`, one filler for both call sites), exit 1 at the caller. */
|