@oscaner-skills/cdd-engine 4.12.0 → 4.13.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 +22 -0
- package/README.zh-CN.md +22 -0
- package/dist/contract/invariants.js +11 -6
- package/dist/face/artifacts.js +13 -4
- package/dist/face/board-view.js +326 -58
- package/dist/face/cli.js +180 -63
- package/dist/face/declare.js +10 -6
- package/dist/face/lifecycle.js +119 -102
- package/dist/face/preview.js +9 -0
- package/dist/face/route-render.js +23 -7
- package/dist/face/words.js +53 -7
- package/dist/infra/carrier-seal.js +47 -24
- package/dist/infra/plan-source.js +180 -78
- package/dist/infra/slug-index.js +58 -27
- package/dist/infra/workspace.js +19 -1
- package/dist/render/templates.js +11 -2
- package/dist/session/artifact-reads.js +108 -0
- package/dist/session/carrier-rulings.js +98 -45
- package/dist/session/dispatch-authority.js +2 -3
- package/dist/session/inflight.js +5 -2
- package/dist/session/ledger.js +171 -239
- package/dist/session/next.js +62 -15
- package/dist/session/round-artifacts.js +635 -0
- package/dist/session/round-naming.js +16 -81
- package/dist/session/run.js +14 -13
- package/package.json +1 -1
package/dist/render/templates.js
CHANGED
|
@@ -110,6 +110,11 @@ const IMPLEMENT_SHELL = [
|
|
|
110
110
|
...LICENSE_ITEMS,
|
|
111
111
|
...SCHEMA_SECTION,
|
|
112
112
|
];
|
|
113
|
+
/** The fix face's ONE rulings reading instruction (spec §2.10) — the fixed prefix
|
|
114
|
+
* names where the orchestrator's rulings live and what they outrank; the SIDECAR PATH
|
|
115
|
+
* itself rides the round context (`INPUT_RULINGS`), never this sentence. Both fix
|
|
116
|
+
* shells carry the same words: one reading, one meaning. */
|
|
117
|
+
const RULINGS_READING = "**Rulings:** read the orchestrator's ruling file named by `INPUT_RULINGS` before touching a finding — each ruling answers one finding id and overrides that finding's own suggestion (`REJECTED` = do not adopt that finding's fix); the carrier itself is read-only, never rewritten.";
|
|
113
118
|
/** The fix row's fixed prefix — header + instructions + the shared work tail. */
|
|
114
119
|
const FIX_TYPED_INSTRUCTIONS = [
|
|
115
120
|
"**Verify-then-apply:** verify each finding against the codebase's actual state before changing anything — apply a finding only when it is technically sound; a finding that does not hold up stays open with a note (never blind adoption). Apply findings one at a time and test each one before moving on.",
|
|
@@ -126,6 +131,7 @@ const FIX_SHELL = [
|
|
|
126
131
|
...FIX_TYPED_INSTRUCTIONS,
|
|
127
132
|
"**fix:** read `INPUT_REVIEWS` (open findings) + the plan context (`INPUT_WAVE_BRIEF` on a wave line — the complete plan mirror; `INPUT_PLAN` on the branch line — the plan document; `INPUT_SPEC` on the branch line — the design spec, a conformance reference, never the judged 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).",
|
|
128
133
|
'**Dispositions:** every requested finding needs a disposition keyed by its `id` exactly as the requesting carrier prints it (`F1`, `F2`, … — the summary is description only), valued `{ "status": "fixed" | "rejected", "reason"?: "…" }` — a missing or mis-keyed disposition fails the round.',
|
|
134
|
+
RULINGS_READING,
|
|
129
135
|
EVIDENCE_ITEM,
|
|
130
136
|
...LICENSE_ITEMS,
|
|
131
137
|
// T5 (v0.3) — The work plane's ONE strict-schema sentence: every top-level draft
|
|
@@ -152,6 +158,7 @@ const DOCS_FIX_SHELL = [
|
|
|
152
158
|
"**Table cells:** never hard-wrap a table cell — a wrapped continuation parses as a row whose cell count disagrees with the header, and the lineage row it was meant to be stops registering.",
|
|
153
159
|
"**Escaped pipes:** a `## Change history` summary cell that needs a literal vertical bar carries `\\|` — a bare `|` splits the cell in two and the row stops matching the declared header.",
|
|
154
160
|
'**Dispositions:** every requested finding needs a disposition keyed by its `id` exactly as the requesting carrier prints it (`F1`, `F2`, … — the summary is description only), valued `{ "status": "fixed" | "rejected", "reason"?: "…" }` — a missing or mis-keyed disposition fails the round.',
|
|
161
|
+
RULINGS_READING,
|
|
155
162
|
...LICENSE_ITEMS,
|
|
156
163
|
// The generic strict-schema sentence — the SAME one the work shells carry: the
|
|
157
164
|
// injected declaration is the draft's single field source, zero per-mode field
|
|
@@ -396,8 +403,10 @@ const TOKENS = [
|
|
|
396
403
|
{ name: "INPUT_SPEC", zone: "round-context" },
|
|
397
404
|
{ name: "INPUT_OVERALL", zone: "round-context" },
|
|
398
405
|
{ name: "INPUT_REVIEWS", zone: "round-context" },
|
|
399
|
-
// P31 — the fix round's ruling sidecar
|
|
400
|
-
//
|
|
406
|
+
// P31 — the fix round's ruling sidecar; the path is the matrix's `rulings` row
|
|
407
|
+
// rendered from the REVIEWED round's identity (P36 §2.10), so it moves with that
|
|
408
|
+
// cycle, never with the carrier's own spelling. A review writes its own draft, so its
|
|
409
|
+
// round context never carries it.
|
|
401
410
|
{ name: "INPUT_RULINGS", zone: "round-context" },
|
|
402
411
|
{ name: "INPUT_WAVE_BRIEF", zone: "round-context" },
|
|
403
412
|
// find #5 — the prescribed artifact write paths (the {family}-{key}-{artifact}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// packages/cdd-engine/src-next/session/artifact-reads.ts
|
|
2
|
+
// P36 T7 — the artifact read SEAM: the ONE composition of the matrix's judgment
|
|
3
|
+
// (names · presence · `misplaced` · `absent`) with the strict sidecar schema
|
|
4
|
+
// (`CarrierRulings#verdict`). Design spec §2.3 puts the two levels in one function so
|
|
5
|
+
// the prompt cell and the dispatch gate read one value; this file is that function's
|
|
6
|
+
// home, and it holds NO frame: the workspace arrives with the construction, so the
|
|
7
|
+
// frame-holding lifecycle and the frame-free board are two consumers of ONE seam
|
|
8
|
+
// instead of two composers.
|
|
9
|
+
//
|
|
10
|
+
// The seam's other half is the coordinate: a `rulings` sidecar belongs to the REVIEWED
|
|
11
|
+
// round, so its identity is always `attribute(basename(carrier))` with `op` fixed to
|
|
12
|
+
// `review` — never this dispatch's own `(line, op)`. That second expression would mint
|
|
13
|
+
// a name no gate ever sees.
|
|
14
|
+
//
|
|
15
|
+
// Module-level exports are the value type, the absent value and the class — zero
|
|
16
|
+
// behavior-carrying bare functions (the plan's zero-bare-function discipline).
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
import { CarrierIntegrity, CarrierMismatchError } from "./carrier-integrity.js";
|
|
19
|
+
import { CarrierRulings } from "./carrier-rulings.js";
|
|
20
|
+
/** The no-sidecar read — nothing for the matrix to judge, nothing for the schema to
|
|
21
|
+
* parse. */
|
|
22
|
+
export const ABSENT_READ = { read: { kind: "absent" }, rulings: [] };
|
|
23
|
+
/**
|
|
24
|
+
* ArtifactReads — the frame-free artifact read seam: one workspace, one matrix, one
|
|
25
|
+
* method. `read(kind, carrier, digest)` answers the composed judgment for the kind a
|
|
26
|
+
* caller resolved, with `carrier` the round's carrier path and `digest` the digest its
|
|
27
|
+
* record remembered (`null` = a record that predates the column — a present-facts read,
|
|
28
|
+
* never a second-grade judgment).
|
|
29
|
+
*
|
|
30
|
+
* A carrier that attributes to no round identity (a matrix-external spelling, a P34-era
|
|
31
|
+
* legacy name) reads `absent`: the seam judges the kind it was asked for, and a name the
|
|
32
|
+
* matrix cannot place is an observation, not a refusal. A carrier whose bytes no longer
|
|
33
|
+
* digest to the recorded value THROWS (`CarrierMismatchError`) — a tampered carrier's id
|
|
34
|
+
* set is not a fact any round may read.
|
|
35
|
+
*/
|
|
36
|
+
export class ArtifactReads {
|
|
37
|
+
#artifacts;
|
|
38
|
+
#base;
|
|
39
|
+
constructor(artifacts, base) {
|
|
40
|
+
this.#artifacts = artifacts;
|
|
41
|
+
this.#base = base;
|
|
42
|
+
}
|
|
43
|
+
/** The ONE read of this `kind` — matrix `read` × schema `verdict`, composed once. */
|
|
44
|
+
read(kind, carrier, digest) {
|
|
45
|
+
const identity = this.#identityOf(carrier);
|
|
46
|
+
if (identity === null)
|
|
47
|
+
return ABSENT_READ;
|
|
48
|
+
const read = this.#artifacts.read(identity, kind, this.#base);
|
|
49
|
+
if (read.kind !== "ok")
|
|
50
|
+
return { read, rulings: [] };
|
|
51
|
+
return this.#compose(read, carrier, digest);
|
|
52
|
+
}
|
|
53
|
+
/** The schema level over a matrix `ok` — `ok` carries the rulings, `invalid` the
|
|
54
|
+
* schema's own reason verbatim, and a second-level `absent` is a read RACE (the file
|
|
55
|
+
* left between the two levels), never "there is no sidecar" (spec §4.5). */
|
|
56
|
+
#compose(read, carrier, digest) {
|
|
57
|
+
const verdict = CarrierRulings.verdict(read.path, this.#carrierPathOf(carrier), this.#findingIdsOf(carrier, digest));
|
|
58
|
+
switch (verdict.kind) {
|
|
59
|
+
case "ok":
|
|
60
|
+
return { read, rulings: verdict.rulings };
|
|
61
|
+
case "absent":
|
|
62
|
+
return { read: { kind: "invalid", path: read.path, reason: "unreadable" }, rulings: [] };
|
|
63
|
+
case "invalid":
|
|
64
|
+
return { read: { kind: "invalid", path: read.path, reason: verdict.reason }, rulings: [] };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/** The reviewed round's identity — delegated to the matrix's ONE entry
|
|
68
|
+
* (`ArtifactRegistry#reviewedIdentityOf`: `attribute(basename(carrier))` with `op`
|
|
69
|
+
* fixed to `review`), or null when the carrier attributes to no round coordinate at
|
|
70
|
+
* all. The seam owns the COMPOSITION, the matrix owns the identity: neither spelling
|
|
71
|
+
* is repeated here. */
|
|
72
|
+
#identityOf(carrier) {
|
|
73
|
+
return this.#artifacts.reviewedIdentityOf(carrier);
|
|
74
|
+
}
|
|
75
|
+
/** The carrier's absolute path — the ONE erasure from the repo-relative carrier
|
|
76
|
+
* faces onto the syscall form both the sidecar judgment and the digest read use. */
|
|
77
|
+
#carrierPathOf(carrier) {
|
|
78
|
+
return path.resolve(this.#base.root.repoRoot, carrier);
|
|
79
|
+
}
|
|
80
|
+
/** The carrier's engine-written finding ids (`F1`, `F2` …) — the id set a ruling must
|
|
81
|
+
* name, read through the ONE checked carrier read. An absent or unparseable carrier
|
|
82
|
+
* declares no ids, so any ruling beside it is refused by the strict schema rather
|
|
83
|
+
* than accepted against an empty set. */
|
|
84
|
+
#findingIdsOf(carrier, digest) {
|
|
85
|
+
const ids = new Set();
|
|
86
|
+
let carrierJson;
|
|
87
|
+
try {
|
|
88
|
+
const bytes = CarrierIntegrity.read(this.#carrierPathOf(carrier), digest);
|
|
89
|
+
if (bytes === null)
|
|
90
|
+
return ids;
|
|
91
|
+
carrierJson = JSON.parse(bytes);
|
|
92
|
+
}
|
|
93
|
+
catch (raw) {
|
|
94
|
+
if (raw instanceof CarrierMismatchError)
|
|
95
|
+
throw raw;
|
|
96
|
+
return ids;
|
|
97
|
+
}
|
|
98
|
+
const findings = carrierJson?.findings;
|
|
99
|
+
if (!Array.isArray(findings))
|
|
100
|
+
return ids;
|
|
101
|
+
for (const finding of findings) {
|
|
102
|
+
const id = finding?.id;
|
|
103
|
+
if (typeof id === "string")
|
|
104
|
+
ids.add(id);
|
|
105
|
+
}
|
|
106
|
+
return ids;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -1,76 +1,89 @@
|
|
|
1
1
|
// packages/cdd-engine/src-next/session/carrier-rulings.ts
|
|
2
2
|
// P31 T2 — the orchestrator's RULINGS sidecar: the one supported landing point for a
|
|
3
3
|
// ruling on an engine-persisted carrier (design spec §2.1/§2.6). The engine's carrier
|
|
4
|
-
// bytes are frozen at persist time, so a ruling never edits them: it is
|
|
5
|
-
//
|
|
6
|
-
// back through the strict schema below. The file is the
|
|
7
|
-
// is the engine's — a sidecar the schema refuses is a hard
|
|
8
|
-
// spawned, so a written ruling can never be silently
|
|
9
|
-
// consumes it.
|
|
4
|
+
// bytes are frozen at persist time, so a ruling never edits them: it is its own file,
|
|
5
|
+
// rendered by the artifact matrix's `rulings` row from the REVIEWED round's identity
|
|
6
|
+
// (P36 §2.10), and read back through the strict schema below. The file is the
|
|
7
|
+
// orchestrator's; the judgment is the engine's — a sidecar the schema refuses is a hard
|
|
8
|
+
// stop BEFORE the fix child is spawned, so a written ruling can never be silently
|
|
9
|
+
// invisible to the round that consumes it.
|
|
10
10
|
//
|
|
11
11
|
// Two levels, both strict (unknown keys are refused, never ignored): the top level
|
|
12
12
|
// carries `carrier` (optional; when present it must name the carrier file) and
|
|
13
|
-
// `rulings` (required array); each ruling carries
|
|
14
|
-
//
|
|
15
|
-
// the
|
|
13
|
+
// `rulings` (required array); each ruling carries ONE identifier — `finding`, or its
|
|
14
|
+
// `id` alias, normalized to `finding` on the way in — plus `ruling` (both required
|
|
15
|
+
// strings) and the optional `at` / `by`. A ruling's identifier must name a finding of
|
|
16
|
+
// the carrier it answers — the id set is the caller's fact, injected.
|
|
17
|
+
//
|
|
18
|
+
// The sidecar PATH is not minted here: it is the artifact matrix's `rulings` row
|
|
19
|
+
// rendered from the reviewed round's identity and resolved by the caller's workspace
|
|
20
|
+
// (`render(identity, "rulings")`). Only the NAME is the matrix's; the `carrier` key's
|
|
21
|
+
// comparison still reads the carrier's own basename, so neither direction of the
|
|
22
|
+
// relationship is derived from the other side's string.
|
|
16
23
|
//
|
|
17
24
|
// The sidecar is NEVER sealed by the engine: only the engine's own carriers are.
|
|
18
25
|
import { existsSync, readFileSync } from "node:fs";
|
|
19
26
|
import path from "node:path";
|
|
27
|
+
import { ArtifactRegistry } from "./round-artifacts.js";
|
|
20
28
|
/** The top-level keys the schema declares — anything else is refused. */
|
|
21
29
|
const TOP_KEYS = new Set(["carrier", "rulings"]);
|
|
22
|
-
/** The
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*
|
|
26
|
-
|
|
30
|
+
/** The ruling schema's NON-identifier fields — the verdict text and the orchestrator's
|
|
31
|
+
* optional stamp. The identifier field is deliberately absent from this list: its
|
|
32
|
+
* acceptance set is the artifact matrix's `rulings` row declaration alone (§2.8), so
|
|
33
|
+
* `finding` / `id` are never enumerated a second time here. */
|
|
34
|
+
const RULING_FIELDS = ["ruling", "at", "by"];
|
|
35
|
+
/** CarrierRulings — the lenient read and the strict judgment of a rulings sidecar.
|
|
36
|
+
* Stateless: every call takes the sidecar's own path AND the carrier it answers (the
|
|
37
|
+
* strict schema's `carrier` key speaks the carrier's fact; the id set is the caller's).
|
|
38
|
+
* The path itself is the artifact matrix's render — this class never derives one. */
|
|
27
39
|
// biome-ignore lint/complexity/noStaticOnlyClass: the plan-mandated sidecar read surface — the zero-bare-function discipline admits no standalone predicate functions.
|
|
28
40
|
export class CarrierRulings {
|
|
29
|
-
/** The sidecar
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
* does not carry a rulings array. The lenient read is for callers that render a
|
|
38
|
-
* ruling, never for the gate: the dispatch gate judges through `verdict`. */
|
|
39
|
-
static read(carrierPath) {
|
|
40
|
-
const parsed = CarrierRulings.#parse(CarrierRulings.pathFor(carrierPath));
|
|
41
|
+
/** The sidecar's rulings as recorded — null when the file is absent, unparsable, does
|
|
42
|
+
* not carry a rulings array, or carries a `carrier` key naming another file. The
|
|
43
|
+
* lenient side is the TOLERANCE of unknown keys / unknown finding ids; the carrier
|
|
44
|
+
* fact is judged here too, so neither consumer can read a sidecar that answers a
|
|
45
|
+
* different carrier. The dispatch gate judges through `verdict`; the read face that
|
|
46
|
+
* renders the ruling bodies takes this one. */
|
|
47
|
+
static read(sidecarPath, carrierPath) {
|
|
48
|
+
const parsed = CarrierRulings.#parse(sidecarPath);
|
|
41
49
|
if (parsed.kind !== "ok")
|
|
42
50
|
return null;
|
|
43
|
-
|
|
51
|
+
const record = CarrierRulings.#recordOf(parsed.value);
|
|
52
|
+
if (record === null)
|
|
53
|
+
return null;
|
|
54
|
+
if (CarrierRulings.#carrierRefusal(record, carrierPath) !== null)
|
|
55
|
+
return null;
|
|
56
|
+
return CarrierRulings.#lenientRulings(record);
|
|
44
57
|
}
|
|
45
58
|
/** The strict judgment — the fix dispatch's pre-spawn gate. `findingIds` is the
|
|
46
59
|
* carrier's own finding-id set: a ruling on a finding the carrier does not carry is
|
|
47
60
|
* refused, never carried into the round as a phantom. */
|
|
48
|
-
static verdict(carrierPath, findingIds) {
|
|
49
|
-
const
|
|
50
|
-
const parsed = CarrierRulings.#parse(sidecar);
|
|
61
|
+
static verdict(sidecarPath, carrierPath, findingIds) {
|
|
62
|
+
const parsed = CarrierRulings.#parse(sidecarPath);
|
|
51
63
|
if (parsed.kind !== "ok")
|
|
52
64
|
return parsed;
|
|
53
65
|
const record = CarrierRulings.#recordOf(parsed.value);
|
|
54
66
|
if (record === null) {
|
|
55
|
-
return CarrierRulings.#invalid(
|
|
67
|
+
return CarrierRulings.#invalid(sidecarPath, "the sidecar is not a JSON object");
|
|
56
68
|
}
|
|
57
69
|
if (!CarrierRulings.#keysWithin(record, TOP_KEYS)) {
|
|
58
|
-
return CarrierRulings.#invalid(
|
|
70
|
+
return CarrierRulings.#invalid(sidecarPath, `unknown top-level key(s) — the schema declares ${[...TOP_KEYS].join(" / ")}`);
|
|
59
71
|
}
|
|
60
72
|
const carrierRefusal = CarrierRulings.#carrierRefusal(record, carrierPath);
|
|
61
73
|
if (carrierRefusal !== null)
|
|
62
|
-
return CarrierRulings.#invalid(
|
|
74
|
+
return CarrierRulings.#invalid(sidecarPath, carrierRefusal);
|
|
63
75
|
if (!("rulings" in record)) {
|
|
64
|
-
return CarrierRulings.#invalid(
|
|
76
|
+
return CarrierRulings.#invalid(sidecarPath, "the sidecar carries no `rulings` array");
|
|
65
77
|
}
|
|
66
78
|
if (!Array.isArray(record.rulings)) {
|
|
67
|
-
return CarrierRulings.#invalid(
|
|
79
|
+
return CarrierRulings.#invalid(sidecarPath, "`rulings` is not an array");
|
|
68
80
|
}
|
|
69
81
|
const rulings = [];
|
|
82
|
+
const vocabulary = CarrierRulings.#identifier();
|
|
70
83
|
for (const [index, entry] of record.rulings.entries()) {
|
|
71
|
-
const ruling = CarrierRulings.#rulingOf(entry, index, findingIds);
|
|
84
|
+
const ruling = CarrierRulings.#rulingOf(entry, index, findingIds, vocabulary);
|
|
72
85
|
if (typeof ruling === "string")
|
|
73
|
-
return CarrierRulings.#invalid(
|
|
86
|
+
return CarrierRulings.#invalid(sidecarPath, ruling);
|
|
74
87
|
rulings.push(ruling);
|
|
75
88
|
}
|
|
76
89
|
return { kind: "ok", rulings };
|
|
@@ -111,18 +124,27 @@ export class CarrierRulings {
|
|
|
111
124
|
}
|
|
112
125
|
return null;
|
|
113
126
|
}
|
|
114
|
-
/** One ruling entry — the narrowed record
|
|
115
|
-
|
|
127
|
+
/** One ruling entry — the narrowed record with its identifier NORMALIZED to the
|
|
128
|
+
* canonical spelling, or the refusal's reason string. The accepted spellings are the
|
|
129
|
+
* matrix row's declaration (`finding` · `id`), so a sidecar written either way is one
|
|
130
|
+
* ruling, and an unknown key is still a whole-file refusal. */
|
|
131
|
+
static #rulingOf(entry, index, findingIds, vocabulary) {
|
|
116
132
|
const record = CarrierRulings.#recordOf(entry);
|
|
117
133
|
if (record === null)
|
|
118
134
|
return `ruling #${index + 1} is not a JSON object`;
|
|
119
|
-
const
|
|
135
|
+
const declared = new Set([...vocabulary.accepts, ...RULING_FIELDS]);
|
|
136
|
+
const unknown = Object.keys(record).filter((key) => !declared.has(key));
|
|
120
137
|
if (unknown.length > 0) {
|
|
121
138
|
return `ruling #${index + 1} carries unknown key(s) — ${unknown.join(", ")}`;
|
|
122
139
|
}
|
|
123
|
-
const
|
|
124
|
-
if (typeof
|
|
125
|
-
return
|
|
140
|
+
const spelling = CarrierRulings.#identifierKeyOf(record, index, vocabulary);
|
|
141
|
+
if (typeof spelling !== "string")
|
|
142
|
+
return spelling.reason;
|
|
143
|
+
const finding = record[spelling];
|
|
144
|
+
const { ruling, at, by } = record;
|
|
145
|
+
if (typeof finding !== "string") {
|
|
146
|
+
return `ruling #${index + 1} carries no string \`${vocabulary.canonical}\``;
|
|
147
|
+
}
|
|
126
148
|
if (typeof ruling !== "string")
|
|
127
149
|
return `ruling #${index + 1} carries no string \`ruling\``;
|
|
128
150
|
if (at !== undefined && typeof at !== "string") {
|
|
@@ -141,18 +163,49 @@ export class CarrierRulings {
|
|
|
141
163
|
...(by === undefined ? {} : { by }),
|
|
142
164
|
};
|
|
143
165
|
}
|
|
166
|
+
/** The identifier key ONE ruling carries — exactly one of the accepted spellings
|
|
167
|
+
* (`finding` · `id`). None is a refusal naming the canonical spelling; two is an
|
|
168
|
+
* ambiguity the schema settles by refusing the file, never by picking a winner. */
|
|
169
|
+
static #identifierKeyOf(record, index, vocabulary) {
|
|
170
|
+
const present = vocabulary.accepts.filter((key) => key in record);
|
|
171
|
+
if (present.length === 1)
|
|
172
|
+
return present[0];
|
|
173
|
+
if (present.length === 0) {
|
|
174
|
+
return { reason: `ruling #${index + 1} carries no string \`${vocabulary.canonical}\`` };
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
reason: `ruling #${index + 1} carries both ${present.map((key) => `\`${key}\``).join(" and ")} — one identifier per ruling`,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** The `rulings` row's identifier vocabulary — the matrix's OWN declaration (§2.8).
|
|
181
|
+
* A matrix that lost the row refuses loudly here: a second hand-written acceptance
|
|
182
|
+
* set is exactly the double expression this consumes away. */
|
|
183
|
+
static #identifier() {
|
|
184
|
+
const declared = ArtifactRegistry.identifierOf("rulings");
|
|
185
|
+
if (declared === null) {
|
|
186
|
+
throw new Error("the artifact matrix's `rulings` row declares no identifier vocabulary");
|
|
187
|
+
}
|
|
188
|
+
return declared;
|
|
189
|
+
}
|
|
144
190
|
/** The lenient rulings read — null unless every entry carries the two required
|
|
145
|
-
* strings (an unknown key is tolerated here; the strict gate owns that refusal).
|
|
191
|
+
* strings (an unknown key is tolerated here; the strict gate owns that refusal). The
|
|
192
|
+
* identifier is read through the SAME acceptance set, so both faces accept `id` and
|
|
193
|
+
* both hand back the canonical `finding`. */
|
|
146
194
|
static #lenientRulings(value) {
|
|
147
195
|
const record = CarrierRulings.#recordOf(value);
|
|
148
196
|
if (record === null || !Array.isArray(record.rulings))
|
|
149
197
|
return null;
|
|
198
|
+
const vocabulary = CarrierRulings.#identifier();
|
|
150
199
|
const rulings = [];
|
|
151
200
|
for (const entry of record.rulings) {
|
|
152
201
|
const row = CarrierRulings.#recordOf(entry);
|
|
153
202
|
if (row === null)
|
|
154
203
|
return null;
|
|
155
|
-
const
|
|
204
|
+
const spelling = CarrierRulings.#identifierKeyOf(row, rulings.length, vocabulary);
|
|
205
|
+
if (typeof spelling !== "string")
|
|
206
|
+
return null;
|
|
207
|
+
const finding = row[spelling];
|
|
208
|
+
const { ruling, at, by } = row;
|
|
156
209
|
if (typeof finding !== "string" || typeof ruling !== "string")
|
|
157
210
|
return null;
|
|
158
211
|
rulings.push({
|
|
@@ -260,7 +260,7 @@ export class DispatchAuthority {
|
|
|
260
260
|
* carries its document in `plan`, every other shape in `id`. */
|
|
261
261
|
static #docDriftPair(target, facts) {
|
|
262
262
|
const doc = target.type === "branch" ? (target.plan ?? null) : target.id;
|
|
263
|
-
return doc === null ? null : facts.ledger.docDriftHashes(target.type, doc
|
|
263
|
+
return doc === null ? null : facts.ledger.docDriftHashes(target.type, doc);
|
|
264
264
|
}
|
|
265
265
|
/** The refusal line's reason head — the token alone, or the token plus the mandatory
|
|
266
266
|
* diagnosis (§2.5): `layer=` · `line=` · `recorded=` · `current=` with a stable hash
|
|
@@ -431,8 +431,7 @@ export class DispatchAuthority {
|
|
|
431
431
|
* holds no station: the request face is the pipeline's own first entry. */
|
|
432
432
|
static #docEntered(ledger, line) {
|
|
433
433
|
const lead = targetFaces[line.type].product.reviewLead;
|
|
434
|
-
return
|
|
435
|
-
ledger.roundCount(line.key, "fix", line.type) > 0);
|
|
434
|
+
return ledger.roundCount(line.key, lead) > 0 || ledger.roundCount(line.key, "fix") > 0;
|
|
436
435
|
}
|
|
437
436
|
}
|
|
438
437
|
_a = DispatchAuthority;
|
package/dist/session/inflight.js
CHANGED
|
@@ -35,6 +35,7 @@ import path from "node:path";
|
|
|
35
35
|
import lockfile from "proper-lockfile";
|
|
36
36
|
import { AtomicWriter } from "../infra/atomic.js";
|
|
37
37
|
import { ProcessFacts } from "../infra/proc.js";
|
|
38
|
+
import { ArtifactRegistry } from "./round-artifacts.js";
|
|
38
39
|
/** The acquire refusal — another dispatch holds the record (or the lock) already. The
|
|
39
40
|
* carrier keeps the holder's facts so the CLI renders the held BLOCK from them; a
|
|
40
41
|
* corrupt record yields a null `record`. */
|
|
@@ -54,8 +55,10 @@ export class HoldingError extends Error {
|
|
|
54
55
|
*/
|
|
55
56
|
export class InFlight {
|
|
56
57
|
/** The record's file name inside the workspace-root namespace — the tree-level
|
|
57
|
-
* `.kairos/cdd/in-flight.json` under the default configuration.
|
|
58
|
-
|
|
58
|
+
* `.kairos/cdd/in-flight.json` under the default configuration. The spelling lives
|
|
59
|
+
* in the artifact matrix (`WorkspaceDomain`'s `in-flight` row); this constant is the
|
|
60
|
+
* read face's answer, never a second home. */
|
|
61
|
+
static FILE = ArtifactRegistry.nameOf("in-flight", null);
|
|
59
62
|
/** The lock's stale window (ms) — a FINITE value larger than the longest dispatch
|
|
60
63
|
* budget (implement, 6 h). Finiteness is deliberate: `stale: Infinity` pushes the
|
|
61
64
|
* default `update` to `Infinity`, which Node clamps to 1 ms of lock-touch churn
|