@sdd-method/sdd-cli 1.8.0 → 1.10.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.
@@ -62,9 +62,38 @@
62
62
  # Builder contract: see docs/method/methods/guides/catalogue-builder-specification.md.
63
63
  # Category taxonomy: see docs/method/methods/standards/product-category-taxonomy.md.
64
64
 
65
- schema_version: "3.3.0"
65
+ schema_version: "3.4.0"
66
66
  schema_owner: "sdd-method"
67
67
  schema_status: "canonical"
68
+ # Bump rationale (3.4.0 — additive minor, 2026-08-08, per M-ADR 0207): the
69
+ # forward scaffold declaration joins the metamodel. Two new derived catalogues
70
+ # (`scaffolds`, `scaffold_items`) and three new bound enums (`scaffold_status`,
71
+ # `scaffold_item_kind`, `scaffold_item_state`); no existing column, catalogue
72
+ # or enum changes meaning.
73
+ #
74
+ # The authored surface is the scaffold manifest (`orchestration/scaffolds/
75
+ # *.yaml`, M-ADR 0207 §4.1) — a declaration of the catalogue shape a unit of
76
+ # work will comprise, authored where the work is scoped. These rows are
77
+ # DERIVED from it by the builder, never edited (M-ADR 0205 §4.0 governs).
78
+ #
79
+ # THE POLYMORPHIC TARGET DELIBERATELY DECLARES NO FOREIGN KEY, exactly as
80
+ # `quality_scores.target_ref` declares none: a scaffold's whole point is
81
+ # referencing targets BEFORE they exist, so FK truth is conditional on
82
+ # realisation state — a `declared` item's target MUST NOT resolve (if it
83
+ # does, the builder should have flipped it, and the delta instrument reports
84
+ # the disagreement), a `realised` item's target MUST. That conditionality is
85
+ # enforced by the builder's resolution pass and the M-ADR 0207 §4.8 delta
86
+ # instrument, not by schema-level FK DDL, which cannot express it.
87
+ #
88
+ # STALENESS IS A VERDICT, NOT A ROW STATE. `scaffolds.corpus_ref` carries the
89
+ # anchor (the `quality_scores.corpus_ref` idiom, M-ADR 0207 §4.6); whether
90
+ # the anchor is stale against the targets is computed at coverage time, like
91
+ # every scores staleness verdict. Baking a git-derived verdict into a derived
92
+ # row would make rebuilds non-deterministic against unchanged authored inputs
93
+ # — the byte-identity property migrations are proved by.
94
+ # ACTIVATION (M-ADR 0200 §4.6): additive only. Estates with no manifests emit
95
+ # both catalogues headers-only and no findings — silence is the designed
96
+ # zero-adoption state. Backward-compatible; SCHEMA_COMPAT "^3.0.0".
68
97
  # 3.3.0 also DEPRECATES the `products` maturity triplet (`synthesis_quality`,
69
98
  # `synthesis_band`, `last_assessed`) for removal at 4.0.0, resolving the
70
99
  # two-sources-for-one-fact that D-B0.7 committed to settling in this change-set.
@@ -854,6 +883,41 @@ enums:
854
883
  - { value: estate-owned-unmodelled, description: "Operated by this estate but with no SDD or container home yet — the row is an accounted-for stand-in, and this population is the estate's modelling backlog, countable (F16, 2.32.0). Not an assertion of externality: an assertion of accountability for a boundary row." }
855
884
  - { value: organisation-internal, description: "Owned elsewhere in the same organisation, outside this estate's modelling boundary (F16, 2.32.0)." }
856
885
 
886
+ scaffold_status:
887
+ description: >
888
+ Lifecycle of a scaffold declaration, in `scaffolds.status`. AUTHORED in
889
+ the manifest, copied by the builder: closing a scaffold is a recorded
890
+ act of the unit of work finishing (M-ADR 0207 §4.3), not a computed
891
+ consequence — the delta instrument reports a closed scaffold whose
892
+ delta is not zero as a finding, it never closes one itself.
893
+ values:
894
+ - { value: open, description: "The unit of work is in flight. `declared` items are a state, not a defect (M-ADR 0207 §4.2)." }
895
+ - { value: closed, description: "The author has recorded the unit of work as done. A `declared` item under a closed scaffold presumes the scaffold right — the work is incomplete — and is reported (M-ADR 0207 §4.3)." }
896
+
897
+ scaffold_item_kind:
898
+ description: >
899
+ The grain of a scaffold declaration item, in
900
+ `scaffold_items.item_kind`. Declares which family of catalogue surface
901
+ the item promises; `target_kind` names the specific catalogue.
902
+ values:
903
+ - { value: entity, description: "A node catalogue row the work will add (a service, capability, feature, screen, …). target_ref is the declared id in that catalogue's vocabulary." }
904
+ - { value: edge, description: "An edge catalogue row the work will add. Endpoints are declared in edge_source_ref/edge_target_ref, mapped to the edge catalogue's FK columns in schema declaration order." }
905
+ - { value: contract, description: "A contract artefact the work will introduce or amend. target_ref is the repo-relative spec path, matching `contracts.spec_path`." }
906
+
907
+ scaffold_item_state:
908
+ description: >
909
+ Realisation state of a scaffold item, in `scaffold_items.state`.
910
+ DERIVED by the builder's resolution pass against the same build's
911
+ catalogue rows — never authored. The manifest declares intent; this
912
+ column records whether the intent is realised in the corpus the build
913
+ read. Staleness is deliberately NOT a value here: it is a coverage-time
914
+ verdict against `scaffolds.corpus_ref` (M-ADR 0207 §4.6), because a
915
+ git-derived value in a derived row would break rebuild determinism
916
+ against unchanged authored inputs.
917
+ values:
918
+ - { value: declared, description: "The target does not (yet) resolve in the built catalogues. Under an open scaffold this is the computable backlog; under a closed one it is a reported finding (M-ADR 0207 §4.2/§4.3)." }
919
+ - { value: realised, description: "The target resolves in the built catalogues. The declaration is met for this item." }
920
+
857
921
  catalogues:
858
922
 
859
923
  domains:
@@ -2181,3 +2245,81 @@ catalogues:
2181
2245
  - { name: dimension_score, type: number, nullable: true, description: "Score on that dimension. Empty for an unscored entry (the templates author explicit nulls)." }
2182
2246
  - { name: dimension_weight, type: number, nullable: true, description: "Weight the rubric assigns the dimension, where discoverable. Usually EMPTY: weights live in the rubric document and the registry header comment, not per entry — so this column is honest about the fact that a weighted_score cannot currently be recomputed from these rows alone." }
2183
2247
  - { name: source_sdd_id, type: string, nullable: true, description: "Originating SDD slug. Populated by the aggregator per M-ADR 0134." }
2248
+
2249
+ scaffolds:
2250
+ primary_key: id
2251
+ description: >
2252
+ Forward scaffold declaration, one row per unit of work, per M-ADR 0207
2253
+ §4.1. Source: `orchestration/scaffolds/*.yaml` — the authored surface
2254
+ stays YAML because a scaffold is a declaration of intent, authored where
2255
+ the work is scoped; these rows are DERIVED and never edited (M-ADR 0205
2256
+ §4.0 governs unchanged).
2257
+
2258
+ The scaffold states the catalogue shape a unit of work will comprise —
2259
+ its items are `scaffold_items` rows — and the declared-vs-derived delta
2260
+ against the built catalogues is the unit's definition of done: delta
2261
+ zero (structural) AND every realised artefact score-current (content,
2262
+ via `quality_scores`), per M-ADR 0207 §4.5. The unit is the
2263
+ change-set's declared delta; estate-level scaffold totality is an
2264
+ explicit non-goal (M-ADR 0207 §4.4), so an estate region no scaffold
2265
+ covers produces no finding.
2266
+
2267
+ `corpus_ref` is REQUIRED — a scaffold without an anchor cannot carry a
2268
+ staleness verdict, and M-ADR 0207 §4.6 makes the anchor part of the
2269
+ declaration, not an optional refinement. Staleness itself is computed
2270
+ at coverage time (the scores idiom), never stored here.
2271
+ foreign_keys:
2272
+ - { column: sdd_id, references: products.id, nullable: true }
2273
+ columns:
2274
+ - { name: id, type: string, nullable: false, description: "PK: the manifest's declared unit id (kebab-case slug). Unique per SDD; the aggregator namespaces cross-SDD ids exactly as for every other catalogue." }
2275
+ - { name: name, type: string, nullable: false, description: "Human-readable name of the unit of work, from the manifest." }
2276
+ - { name: status, type: string, nullable: false, description: "Authored lifecycle — see the scaffold_status enum. `closed` is a recorded act of the author (M-ADR 0207 §4.3); the delta instrument reports a closed scaffold whose delta is not zero, it never closes one." }
2277
+ - { name: source_path, type: string, nullable: false, description: "Repo-relative path of the manifest this row derives from, e.g. orchestration/scaffolds/payments-settlement.yaml." }
2278
+ - { name: corpus_ref, type: string, nullable: false, description: "The commit the scaffold was declared against — the staleness anchor, mirroring quality_scores.corpus_ref (M-ADR 0207 §4.6: one staleness idiom, not two). Required: a manifest without one fails validation rather than emitting an unanchorable row." }
2279
+ - { name: manifest_schema, type: string, nullable: false, description: "The scaffold manifest format version the file declared (scaffold_schema field), so format evolution is diffable and a future migration can state its denominator." }
2280
+ - { name: sdd_id, type: string, nullable: true, description: "SDD whose manifest authored this row. Soft FK to products.id — nullable because a scaffold can be declared in an SDD that emits no product row." }
2281
+ - { name: source_sdd_id, type: string, nullable: true, description: "Originating SDD slug. Populated by the aggregator per M-ADR 0134; left empty by per-SDD builders." }
2282
+ column_enums:
2283
+ status: enums.scaffold_status
2284
+
2285
+ scaffold_items:
2286
+ primary_key: id
2287
+ description: >
2288
+ One declared item of a scaffold — an entity, edge, or contract the unit
2289
+ of work promises — per M-ADR 0207 §4.1. Derived from the manifest's
2290
+ item list; `state` is the builder's resolution verdict against the same
2291
+ build's catalogue rows.
2292
+
2293
+ THE POLYMORPHIC TARGET DECLARES NO FOREIGN KEY, by design (the
2294
+ quality_scores.target_ref precedent, taken further): a scaffold exists
2295
+ to reference targets BEFORE they exist. FK truth here is CONDITIONAL ON
2296
+ STATE — a `declared` item's (target_kind, target_ref) MUST NOT resolve
2297
+ in the built catalogues, a `realised` item's MUST — and the builder's
2298
+ resolution pass is what enforces it: it computes `state` FROM
2299
+ resolution, so a disagreement between state and resolution cannot be
2300
+ emitted by a conforming builder. The M-ADR 0207 §4.8 delta instrument
2301
+ re-derives the same verdict on the engine as its self-check.
2302
+
2303
+ `target_kind` is the CATALOGUE NAME the target should appear in
2304
+ (services, capabilities, repo_contract, contracts, …) — bound to the
2305
+ schema's own catalogue list by the builder: an unknown target_kind is a
2306
+ loud convention finding, never a silently-dropped item (M-ADR 0207
2307
+ §4.1). For `edge` items the endpoints are declared in
2308
+ edge_source_ref/edge_target_ref, mapped to the edge catalogue's FK
2309
+ columns in schema declaration order; target_ref then carries the
2310
+ builder-computed endpoint slug so the PK stays single-column.
2311
+ foreign_keys:
2312
+ - { column: scaffold_id, references: scaffolds.id, nullable: false }
2313
+ columns:
2314
+ - { name: id, type: string, nullable: false, description: "PK: {scaffold_id}__{item_kind}__{target_kind}__{target_ref}. Composite in one slug because the natural key is a quadruple and the rest of this schema keys on a single `id`." }
2315
+ - { name: scaffold_id, type: string, nullable: false, description: "The scaffold this item belongs to." }
2316
+ - { name: item_kind, type: string, nullable: false, description: "Grain of the declaration — see the scaffold_item_kind enum." }
2317
+ - { name: target_kind, type: string, nullable: false, description: "Catalogue the target should appear in, in the schema's own catalogue vocabulary. Validated against the schema by the builder; unknown values are convention findings carrying file, item and value." }
2318
+ - { name: target_ref, type: string, nullable: false, description: "Identifier of the declared target in the vocabulary of its catalogue: the declared id for entity items, the repo-relative spec path for contract items (matching contracts.spec_path), the builder-computed {source}__{target} endpoint slug for edge items." }
2319
+ - { name: edge_source_ref, type: string, nullable: true, description: "For edge items: the declared source endpoint, in the vocabulary of the edge catalogue's first FK column (schema declaration order). Empty for entity and contract items." }
2320
+ - { name: edge_target_ref, type: string, nullable: true, description: "For edge items: the declared target endpoint, second FK column. Empty for entity and contract items." }
2321
+ - { name: state, type: string, nullable: false, description: "Resolution verdict — see the scaffold_item_state enum. Derived, never authored; recomputed on every build, so realisation flips rows exactly when the target lands." }
2322
+ - { name: source_sdd_id, type: string, nullable: true, description: "Originating SDD slug. Populated by the aggregator per M-ADR 0134." }
2323
+ column_enums:
2324
+ item_kind: enums.scaffold_item_kind
2325
+ state: enums.scaffold_item_state
@@ -1 +1 @@
1
- {"version":3,"file":"coverage-run.d.ts","sourceRoot":"","sources":["../../../src/lib/catalogue/coverage-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAiClC,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GACzB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA+G/B"}
1
+ {"version":3,"file":"coverage-run.d.ts","sourceRoot":"","sources":["../../../src/lib/catalogue/coverage-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAQH,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,0BAA0B,CAAC;AAkClC,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,iBAAiB,EACzB,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GACzB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA2H/B"}
@@ -26,6 +26,7 @@ import { loadCanonicalSchema } from "./schema-loader.js";
26
26
  import { runContractCoverage, runEventCoverage, runRepoCapabilityCoverage, runServiceCapabilityCoverage, } from "./coverage-predicates.js";
27
27
  import { runCapabilityEventCheck, runDataModelEntitiesCheck, runEventCatalogueCheck, runFeatureEventCheck, runFeatureSpecPromotionCheck, runFeatureSurfaceDuplicationCheck, runGlossaryXrefCheck, runPlatformDependenciesCheck, runRelationshipCoherenceCheck, runRepoEdgesCheck, } from "./gate-checks.js";
28
28
  import { runScoresCoverage } from "./scores-coverage.js";
29
+ import { renderScaffoldDelta, runScaffoldDelta } from "./scaffold-delta.js";
29
30
  import { renderStalenessVerdicts, runStalenessVerdicts } from "./staleness-verdicts.js";
30
31
  import { renderCapabilityEventCheck, renderContractCoverage, renderDataModelEntitiesCheck, renderEventCatalogueCheck, renderEventCoverage, renderFeatureEventCheck, renderFeatureSpecPromotionCheck, renderFeatureSurfaceDuplicationCheck, renderGlossaryXrefCheck, renderPlatformDependenciesCheck, renderRelationshipCoherenceCheck, renderRepoCapability, renderRepoEdgesCheck, renderScoresCoverage, renderServiceCapability, } from "./coverage-render.js";
31
32
  export async function runCatalogueCoverage(inputs, write) {
@@ -97,6 +98,12 @@ export async function runCatalogueCoverage(inputs, write) {
97
98
  // features, publisher-projection drift, supersession drift. Reporting-only
98
99
  // at both tiers; newest last in the block order, same as scores was.
99
100
  lines.push(...renderRelationshipCoherenceCheck(await runRelationshipCoherenceCheck(session)));
101
+ // The sixteenth check (M-ADR 0207 §4.8): the scaffold declared-vs-derived
102
+ // delta, its resolution self-check, and the §4.6 staleness verdict.
103
+ // Reporting-only at both tiers per §4.9 — nothing here gates until the
104
+ // pilot's stated-in-advance figures land. Newest last in the block order,
105
+ // same as scores and coherence were.
106
+ lines.push(...renderScaffoldDelta(await runScaffoldDelta(session, { tier, available, schema, sddRoot }), tier));
100
107
  }
101
108
  finally {
102
109
  session.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"coverage-run.js","sourceRoot":"","sources":["../../../src/lib/catalogue/coverage-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,yBAAyB,EACzB,4BAA4B,GAE7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,oBAAoB,EACpB,4BAA4B,EAC5B,iCAAiC,EACjC,oBAAoB,EACpB,4BAA4B,EAC5B,6BAA6B,EAC7B,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,0BAA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AAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EACrE,IAAI,CACL,CACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;IAC7C,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AACzB,CAAC"}
@@ -277,3 +277,23 @@ coverage:
277
277
  score_selection_method: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
278
278
  staleness_basis: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
279
279
  scoring_form: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
280
+ scaffolds:
281
+ kind: entity
282
+ scoring: predicate
283
+ instrument: "the declaration record itself — scoring it with a rubric would be circular. Its GOVERNANCE is the M-ADR 0207 §4.8 delta instrument plus the scaffold-coverage predicate (every non-closed scaffold carries a current anchor and a computable delta; a closed scaffold sits at delta zero), run by sdd-cli catalogue validate --coverage."
284
+ relationships:
285
+ # flow none, same ruling shape as quality_scores.sdd_id: a scaffold is a
286
+ # governance record ABOUT work, not a structural path of the estate —
287
+ # "is this declaration still current after the change" is owned by the
288
+ # scaffold instruments (corpus_ref staleness + the delta), and answering
289
+ # it through reachability answers it worse.
290
+ sdd_id: { class: membership, impact_flow: none }
291
+ scaffold_items:
292
+ kind: edge
293
+ class: traceability
294
+ impact_flow: none
295
+ scoring: derived-edge
296
+ reason: "derived from the authored scaffold manifest (M-ADR 0207 §4.1); the polymorphic target deliberately declares no FK — resolution is conditional on state — so the row is a governance trace, not an impact path"
297
+ scaffold_status: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
298
+ scaffold_item_kind: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
299
+ scaffold_item_state: { kind: enum, scoring: not-applicable, reason: "closed vocabulary, not an artefact" }
@@ -0,0 +1,34 @@
1
+ import type { EngineSession } from "./engine-validator.js";
2
+ import type { CanonicalSchema } from "./schema-loader.js";
3
+ export type ScaffoldFindingKind = "declared-unrealised" | "realised-undeclared" | "resolution-disagreement" | "scaffold-stale";
4
+ export interface ScaffoldDeltaFinding {
5
+ readonly kind: ScaffoldFindingKind;
6
+ readonly scaffoldId: string;
7
+ readonly detail: string;
8
+ }
9
+ export interface ScaffoldMetric {
10
+ readonly scaffoldId: string;
11
+ readonly status: string;
12
+ readonly declared: number;
13
+ readonly realised: number;
14
+ }
15
+ export interface ScaffoldDeltaResult {
16
+ readonly findings: readonly ScaffoldDeltaFinding[];
17
+ readonly metrics: readonly ScaffoldMetric[];
18
+ /** Staleness accounting — verdicts attempted, and the stated remainders. */
19
+ readonly staleness: {
20
+ readonly assessedPaths: number;
21
+ readonly unknownAnchor: number;
22
+ readonly pathlessItems: number;
23
+ readonly skipped?: string;
24
+ };
25
+ }
26
+ export declare function runScaffoldDelta(session: EngineSession, options: {
27
+ readonly tier: "member" | "aggregate";
28
+ readonly available: ReadonlySet<string>;
29
+ readonly schema: CanonicalSchema;
30
+ /** SDD root for the member-tier staleness verdict. */
31
+ readonly sddRoot: string;
32
+ }): Promise<ScaffoldDeltaResult>;
33
+ export declare function renderScaffoldDelta(res: ScaffoldDeltaResult, tier: "member" | "aggregate"): string[];
34
+ //# sourceMappingURL=scaffold-delta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold-delta.d.ts","sourceRoot":"","sources":["../../../src/lib/catalogue/scaffold-delta.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,oBAAoB,CAAC;AAIxE,MAAM,MAAM,mBAAmB,GAC3B,qBAAqB,GACrB,qBAAqB,GACrB,yBAAyB,GACzB,gBAAgB,CAAC;AAEr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 // Scaffold delta — M-ADR 0207 §4.8: the declared-vs-derived delta computed on
2
+ // the engine, plus the scaffold-coverage predicate (every non-closed scaffold
3
+ // carries a current anchor and a computable delta; a closed scaffold sits at
4
+ // delta zero). REPORTING-ONLY at both tiers per §4.9 — no gating tier ships
5
+ // until the pilot's stated-in-advance figures land, and promotion is a
6
+ // deliberate later act (change the class in one place, say so in the
7
+ // change-set — the scores-coverage precedent, word for word).
8
+ //
9
+ // Finding classes:
10
+ // declared-unrealised — a `declared` item under a CLOSED scaffold. §4.3's
11
+ // first presumption: the scaffold is right, the work is incomplete.
12
+ // Under an OPEN scaffold the same state is the computable backlog and
13
+ // lands in the per-scaffold metric, never as a finding (§4.2).
14
+ // realised-undeclared — an edge row whose BOTH endpoints are this
15
+ // scaffold's own realised entity targets, with no declaring item. The
16
+ // unit's scope is the entity set it declares (§4.2/§4.4): work fully
17
+ // inside that set that was never declared is scope drift made loud;
18
+ // edges to the rest of the estate are integration, not drift.
19
+ // resolution-disagreement — the builder's derived `state` disagrees with
20
+ // the engine's own re-derivation. Conforming builds cannot produce it
21
+ // (resolution is what computes state), so any instance is an
22
+ // instrument defect, adjudicated per M-ADR 0205 §4.4 — never smoothed.
23
+ // scaffold-stale — the §4.6 verdict. MEMBER TIER ONLY, stated not silent
24
+ // (the staleness-verdicts precedent): a per-target verdict needs the
25
+ // target's git history, which only contract items carry a path for.
26
+ // Entity/edge items are counted as pathless rather than guessed at;
27
+ // an anchor the repo does not know is UNKNOWN, never presumed stale.
28
+ import { execFile as execFileCb } from "node:child_process";
29
+ import { promisify } from "node:util";
30
+ const execFile = promisify(execFileCb);
31
+ const EMPTY = {
32
+ findings: [],
33
+ metrics: [],
34
+ staleness: { assessedPaths: 0, unknownAnchor: 0, pathlessItems: 0 },
35
+ };
36
+ const sqlStr = (s) => `'${s.replace(/'/g, "''")}'`;
37
+ async function rows(session, sql) {
38
+ const reader = await session.conn.runAndReadAll(sql);
39
+ return reader.getRows();
40
+ }
41
+ function refCatalogue(reference) {
42
+ return reference.split(".")[0] ?? "";
43
+ }
44
+ /**
45
+ * Re-derive one item's realisation on the engine — the §4.8 self-check. A
46
+ * target whose catalogue is absent from the session cannot resolve.
47
+ */
48
+ async function engineResolves(session, available, catalogue, item) {
49
+ if (!available.has(item.targetKind))
50
+ return false;
51
+ if (item.itemKind === "edge") {
52
+ const [srcFk, dstFk] = [catalogue.foreignKeys[0], catalogue.foreignKeys[1]];
53
+ if (!srcFk || !dstFk)
54
+ return false;
55
+ const n = await rows(session, `SELECT COUNT(*) FROM "${item.targetKind}" WHERE "${srcFk.column}" = ${sqlStr(item.edgeSourceRef)} AND "${dstFk.column}" = ${sqlStr(item.edgeTargetRef)};`);
56
+ return Number(n[0][0]) > 0;
57
+ }
58
+ const matchCol = item.itemKind === "contract" ? "spec_path" : catalogue.primaryKey;
59
+ const n = await rows(session, `SELECT COUNT(*) FROM "${item.targetKind}" WHERE "${matchCol}" = ${sqlStr(item.targetRef)};`);
60
+ return Number(n[0][0]) > 0;
61
+ }
62
+ async function gitKnowsCommit(sddRoot, ref) {
63
+ try {
64
+ await execFile("git", ["-C", sddRoot, "cat-file", "-e", `${ref}^{commit}`]);
65
+ return true;
66
+ }
67
+ catch {
68
+ return false;
69
+ }
70
+ }
71
+ async function pathChangedSince(sddRoot, anchor, path) {
72
+ try {
73
+ const { stdout } = await execFile("git", [
74
+ "-C",
75
+ sddRoot,
76
+ "log",
77
+ "-1",
78
+ "--format=%h %ad",
79
+ "--date=short",
80
+ `${anchor}..HEAD`,
81
+ "--",
82
+ path,
83
+ ]);
84
+ const line = stdout.trim();
85
+ return line === "" ? null : line;
86
+ }
87
+ catch {
88
+ return null;
89
+ }
90
+ }
91
+ export async function runScaffoldDelta(session, options) {
92
+ const { tier, available, schema, sddRoot } = options;
93
+ if (!available.has("scaffolds") || !available.has("scaffold_items"))
94
+ return EMPTY;
95
+ const scaffoldRows = await rows(session, `SELECT id, status, corpus_ref FROM "scaffolds" ORDER BY id;`);
96
+ if (scaffoldRows.length === 0)
97
+ return EMPTY;
98
+ const itemRows = (await rows(session, `SELECT scaffold_id, item_kind, target_kind, target_ref, edge_source_ref, edge_target_ref, state
99
+ FROM "scaffold_items" ORDER BY id;`)).map((r) => ({
100
+ scaffoldId: String(r[0]),
101
+ itemKind: String(r[1]),
102
+ targetKind: String(r[2]),
103
+ targetRef: String(r[3]),
104
+ edgeSourceRef: String(r[4] ?? ""),
105
+ edgeTargetRef: String(r[5] ?? ""),
106
+ state: String(r[6]),
107
+ }));
108
+ const catalogueByName = new Map(schema.catalogues.map((c) => [c.name, c]));
109
+ const findings = [];
110
+ const metrics = [];
111
+ const staleness = { assessedPaths: 0, unknownAnchor: 0, pathlessItems: 0 };
112
+ if (tier === "aggregate") {
113
+ staleness.skipped =
114
+ "aggregate tier — sibling repos' git histories are not local, and a verdict there would be a guess";
115
+ }
116
+ for (const s of scaffoldRows) {
117
+ const scaffoldId = String(s[0]);
118
+ const status = String(s[1]);
119
+ const corpusRef = String(s[2]);
120
+ const items = itemRows.filter((i) => i.scaffoldId === scaffoldId);
121
+ const declared = items.filter((i) => i.state === "declared");
122
+ const realised = items.filter((i) => i.state === "realised");
123
+ metrics.push({ scaffoldId, status, declared: declared.length, realised: realised.length });
124
+ // declared-unrealised — only a finding once the scaffold is closed (§4.2/§4.3).
125
+ if (status === "closed") {
126
+ for (const item of declared) {
127
+ findings.push({
128
+ kind: "declared-unrealised",
129
+ scaffoldId,
130
+ detail: `${item.itemKind} ${item.targetKind}/${item.targetRef} is declared but unrealised under a closed scaffold — the scaffold presumes right: the work is incomplete, or the scaffold needs a recorded amendment (M-ADR 0207 §4.3)`,
131
+ });
132
+ }
133
+ }
134
+ // resolution self-check (§4.8) — the engine re-derives every item's state.
135
+ for (const item of items) {
136
+ const cat = catalogueByName.get(item.targetKind);
137
+ if (!cat)
138
+ continue; // builder already reported unknown target_kind
139
+ const resolves = await engineResolves(session, available, cat, item);
140
+ const expected = resolves ? "realised" : "declared";
141
+ if (item.state !== expected) {
142
+ findings.push({
143
+ kind: "resolution-disagreement",
144
+ scaffoldId,
145
+ detail: `${item.itemKind} ${item.targetKind}/${item.targetRef} carries state '${item.state}' but the engine derives '${expected}' — an instrument defect in one side, adjudicated, never smoothed (M-ADR 0205 §4.4)`,
146
+ });
147
+ }
148
+ }
149
+ // realised-undeclared — edges wholly inside the scaffold's own realised
150
+ // entity set that no item declares (§4.2).
151
+ const realisedEntityRefs = new Map();
152
+ for (const item of realised) {
153
+ if (item.itemKind !== "entity")
154
+ continue;
155
+ const set = realisedEntityRefs.get(item.targetKind) ?? new Set();
156
+ set.add(item.targetRef);
157
+ realisedEntityRefs.set(item.targetKind, set);
158
+ }
159
+ const declaredEdgePairs = new Set(items
160
+ .filter((i) => i.itemKind === "edge")
161
+ .map((i) => `${i.targetKind}|${i.edgeSourceRef}|${i.edgeTargetRef}`));
162
+ if (realisedEntityRefs.size > 0) {
163
+ for (const cat of schema.catalogues) {
164
+ const [srcFk, dstFk] = [cat.foreignKeys[0], cat.foreignKeys[1]];
165
+ if (!srcFk || !dstFk || !available.has(cat.name))
166
+ continue;
167
+ const srcRefs = realisedEntityRefs.get(refCatalogue(srcFk.references));
168
+ const dstRefs = realisedEntityRefs.get(refCatalogue(dstFk.references));
169
+ if (!srcRefs?.size || !dstRefs?.size)
170
+ continue;
171
+ const inList = (vals) => [...vals].sort().map(sqlStr).join(", ");
172
+ const pairs = await rows(session, `SELECT "${srcFk.column}", "${dstFk.column}" FROM "${cat.name}"
173
+ WHERE "${srcFk.column}" IN (${inList(srcRefs)})
174
+ AND "${dstFk.column}" IN (${inList(dstRefs)})
175
+ ORDER BY 1, 2;`);
176
+ for (const [a, b] of pairs) {
177
+ const key = `${cat.name}|${String(a)}|${String(b)}`;
178
+ if (declaredEdgePairs.has(key))
179
+ continue;
180
+ findings.push({
181
+ kind: "realised-undeclared",
182
+ scaffoldId,
183
+ detail: `edge ${cat.name} ${String(a)} -> ${String(b)} joins two of this scaffold's declared entities but is not itself declared — scope drift made loud; amend the scaffold in the same change-set (M-ADR 0207 §4.3)`,
184
+ });
185
+ }
186
+ }
187
+ }
188
+ // scaffold-stale (§4.6) — member tier, per-path verdicts only.
189
+ if (tier === "member") {
190
+ if (!(await gitKnowsCommit(sddRoot, corpusRef))) {
191
+ staleness.unknownAnchor += 1;
192
+ }
193
+ else {
194
+ for (const item of items) {
195
+ if (item.itemKind !== "contract") {
196
+ staleness.pathlessItems += 1;
197
+ continue;
198
+ }
199
+ staleness.assessedPaths += 1;
200
+ const moved = await pathChangedSince(sddRoot, corpusRef, item.targetRef);
201
+ if (moved !== null) {
202
+ findings.push({
203
+ kind: "scaffold-stale",
204
+ scaffoldId,
205
+ detail: `anchor ${corpusRef} predates a change to ${item.targetRef} (${moved}) — re-declare against the current corpus before acting on this scaffold's delta (M-ADR 0207 §4.6/§4.3)`,
206
+ });
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
212
+ findings.sort((a, b) => a.scaffoldId.localeCompare(b.scaffoldId) ||
213
+ a.kind.localeCompare(b.kind) ||
214
+ a.detail.localeCompare(b.detail));
215
+ return { findings, metrics, staleness };
216
+ }
217
+ /**
218
+ * The delta's DEFECT classes are gate-acting (`divergence`), PROMOTED by a
219
+ * recorded governance act after the M-ADR 0207 §4.9 pilot completed with no
220
+ * surprise in any gated figure (2026-08-08) — the deliberate later act the
221
+ * scores-coverage precedent reserves, performed. `scaffold-stale` stays
222
+ * `coverage` with its staleness family: a stale anchor is a re-declare
223
+ * prompt, and gating on git-history movement would alarm, not measure.
224
+ */
225
+ const PROMOTED = new Set([
226
+ "declared-unrealised",
227
+ "realised-undeclared",
228
+ "resolution-disagreement",
229
+ ]);
230
+ export function renderScaffoldDelta(res, tier) {
231
+ // Silent only when there is genuinely nothing measured: no scaffolds is the
232
+ // designed zero-adoption state (M-ADR 0207 §4.4), not a suppressed report.
233
+ if (res.metrics.length === 0)
234
+ return [];
235
+ const out = [];
236
+ for (const f of res.findings) {
237
+ const cls = PROMOTED.has(f.kind) ? "divergence" : "coverage";
238
+ out.push(`[finding] ${cls}: scaffold ${f.scaffoldId}: [${f.kind}] ${f.detail}`);
239
+ }
240
+ for (const m of res.metrics) {
241
+ // The line carries the TOTAL, not just the outstanding count: the first
242
+ // pilot's checkpoint log read like a shrinking denominator because
243
+ // "N declared" meant outstanding. "M outstanding of T declared" cannot
244
+ // be misread that way.
245
+ const delta = m.declared;
246
+ const total = m.declared + m.realised;
247
+ out.push(`[metric] scaffold_delta (${tier}): ${m.scaffoldId} (${m.status}) — ` +
248
+ `${m.realised} realised, ${m.declared} outstanding of ${total} declared; delta ${delta}` +
249
+ (m.status === "closed" && delta > 0 ? " (closed scaffold, delta not zero)" : ""));
250
+ }
251
+ const s = res.staleness;
252
+ if (s.skipped) {
253
+ out.push(`[metric] scaffold_staleness: skipped — ${s.skipped}`);
254
+ }
255
+ else if (s.assessedPaths + s.unknownAnchor + s.pathlessItems > 0) {
256
+ out.push(`[metric] scaffold_staleness: ${s.assessedPaths} path verdict(s) attempted, ` +
257
+ `${s.unknownAnchor} unknown anchor(s), ${s.pathlessItems} pathless item(s) (no per-target verdict possible — stated, not guessed)`);
258
+ }
259
+ return out;
260
+ }
261
+ //# sourceMappingURL=scaffold-delta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold-delta.js","sourceRoot":"","sources":["../../../src/lib/catalogue/scaffold-delta.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,4EAA4E;AAC5E,uEAAuE;AACvE,qEAAqE;AACrE,8DAA8D;AAC9D,EAAE;AACF,mBAAmB;AACnB,4EAA4E;AAC5E,0EAA0E;AAC1E,4EAA4E;AAC5E,qEAAqE;AACrE,oEAAoE;AACpE,4EAA4E;AAC5E,2EAA2E;AAC3E,0EAA0E;AAC1E,oEAAoE;AACpE,2EAA2E;AAC3E,4EAA4E;AAC5E,mEAAmE;AACnE,6EAA6E;AAC7E,2EAA2E;AAC3E,2EAA2E;AAC3E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