@sdd-method/maintain-cli 0.14.0 → 0.15.1

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.
@@ -7,7 +7,7 @@
7
7
  # Emitted by sdd-cli's YAML emitter with no line folding; the three header scalars are quoted for the
8
8
  # textual readers downstream. The one deliberate difference from the authored form is schema_status:
9
9
  # the authored form says canonical; a projection never does.
10
- schema_version: "7.0.0"
10
+ schema_version: "7.1.0"
11
11
  schema_owner: "sdd-method"
12
12
  schema_status: "generated"
13
13
  enums:
@@ -645,7 +645,7 @@ enums:
645
645
  description: Its change archived on a passing judge, with this repository's work order implementing it.
646
646
  - value: observed
647
647
  description: Independent evidence from this repository's code matches (a baseline's characterization tests or a reverse snapshot).
648
- description: The kind of evidence an assertion is about one revision, in one repository (M-ADR 0230 §4.7, Proposed).
648
+ description: The kind of evidence an assertion is about one revision, in one repository (M-ADR 0230 §4.7).
649
649
  change_status:
650
650
  values:
651
651
  - value: proposed
@@ -714,14 +714,14 @@ enums:
714
714
  description: Observations, scores and findings, about a named revision.
715
715
  - value: execution
716
716
  description: "The change records and the build itself: changes, work orders, lineage, and the provenance the build or aggregation stamps."
717
- description: Where a catalogue's facts, or a column's, are authored (M-ADR 0230 §4.1, Proposed). Each catalogue carries one; a column carries one only where it differs.
717
+ description: Where a catalogue's facts, or a column's, are authored (M-ADR 0230 §4.1). Each catalogue carries one; a column carries one only where it differs.
718
718
  relationship_end_cardinality:
719
719
  values:
720
720
  - value: exactly-one
721
721
  - value: zero-or-one
722
722
  - value: one-or-more
723
723
  - value: zero-or-more
724
- description: "How many entities one end of a relationship holds for one entity at the other end (M-ADR 0230 §4.3, Proposed): a Mermaid ER end marker (|| exactly one, |o or o| zero or one, }| or |{ one or more, }o or o{ zero or more). A TypeQL relationship is zero-or-more at both ends, because the subset admits no participation cardinality; a role's @card is a cardinality invariant (domain_invariants). Replaced entity_relationship_cardinality in schema 6.0.0."
724
+ description: "How many entities one end of a relationship holds for one entity at the other end (M-ADR 0230 §4.3): a Mermaid ER end marker (|| exactly one, |o or o| zero or one, }| or |{ one or more, }o or o{ zero or more). A TypeQL relationship is zero-or-more at both ends, because the subset admits no participation cardinality; a role's @card is a cardinality invariant (domain_invariants). Replaced entity_relationship_cardinality in schema 6.0.0."
725
725
  domain_invariant_kind:
726
726
  values:
727
727
  - value: unique
@@ -732,7 +732,7 @@ enums:
732
732
  description: A bound on how many entities the named relationship relates, stated in the statement.
733
733
  - value: rule
734
734
  description: Any other rule, stated in the statement.
735
- description: The type of a domain invariant (M-ADR 0230 §4.3, Proposed).
735
+ description: The type of a domain invariant (M-ADR 0230 §4.3).
736
736
  revision_state:
737
737
  values:
738
738
  - value: current
@@ -741,14 +741,14 @@ enums:
741
741
  description: An agreed open change states it.
742
742
  - value: history
743
743
  description: Once published or stated, and no longer current.
744
- description: Which view a revision belongs to (M-ADR 0230 §4.7, Proposed).
744
+ description: Which view a revision belongs to (M-ADR 0230 §4.7).
745
745
  change_effect_element_kind:
746
746
  values:
747
747
  - value: requirement
748
748
  description: A requirement, written by a behaviour delta.
749
749
  - value: structure
750
750
  description: An element of the structural model, written by a structural delta.
751
- description: What kind of element a change effect writes (M-ADR 0230 §4.7, Proposed).
751
+ description: What kind of element a change effect writes (M-ADR 0230 §4.7).
752
752
  adr_governs:
753
753
  values:
754
754
  - value: current
@@ -757,7 +757,7 @@ enums:
757
757
  description: "The system as the agreed changes will leave it: the decision applies from its change's archive."
758
758
  - value: none
759
759
  description: "Neither: proposed, rejected, deprecated, superseded by a decision now in force, or its change withdrawn."
760
- description: Which view a decision governs (M-ADR 0230 §4.2, Proposed).
760
+ description: Which view a decision governs (M-ADR 0230 §4.2).
761
761
  contract_revision_state:
762
762
  values:
763
763
  - value: agreed
@@ -768,7 +768,22 @@ enums:
768
768
  description: Applicable, with a sunset.
769
769
  - value: retired
770
770
  description: "No longer applicable: an archived change's revision the file no longer holds."
771
- description: A contract revision's applicability in the published specification (M-ADR 0230 §4.2, Proposed).
771
+ description: A contract revision's applicability in the published specification (M-ADR 0230 §4.2).
772
+ ppt_archetype:
773
+ values:
774
+ - value: party
775
+ description: A person or an organisation.
776
+ - value: place
777
+ description: A location where things happen or are kept.
778
+ - value: thing
779
+ description: An object that is tracked individually.
780
+ - value: role
781
+ description: A way a party, place or thing takes part in something.
782
+ - value: moment-interval
783
+ description: Something that happens at a moment or over an interval, and is recorded.
784
+ - value: description
785
+ description: A catalogue-entry description that many things share.
786
+ description: An entity's Party-Place-Thing archetype, as the capability spec template classifies it (schema 7.1.0).
772
787
  catalogues:
773
788
  domains:
774
789
  primary_key: id
@@ -1220,7 +1235,7 @@ catalogues:
1220
1235
  - name: effective_change
1221
1236
  type: string
1222
1237
  nullable: true
1223
- description: "From the ADR's **Effective:** line (M-ADR 0230 §4.2, Proposed): the change whose archive makes the decision apply, by its undated name; empty when it applies on acceptance. Added in schema 6.0.0."
1238
+ description: "From the ADR's **Effective:** line (M-ADR 0230 §4.2): the change whose archive makes the decision apply, by its undated name; empty when it applies on acceptance. Added in schema 6.0.0."
1224
1239
  - name: governs
1225
1240
  type: string
1226
1241
  nullable: true
@@ -1503,7 +1518,7 @@ catalogues:
1503
1518
  - name: source
1504
1519
  type: string
1505
1520
  nullable: false
1506
- description: "capability-tree | product-map | capability-spec | structural-model. As of schema 6.0.0, source: structural-model is emitted for a capability only the structural model holds (M-ADR 0230 §4.3, Proposed)."
1521
+ description: "capability-tree | product-map | capability-spec | structural-model. As of schema 6.0.0, source: structural-model is emitted for a capability only the structural model holds (M-ADR 0230 §4.3)."
1507
1522
  source_of_truth: derived
1508
1523
  - name: runway_classification
1509
1524
  type: string
@@ -1637,7 +1652,7 @@ catalogues:
1637
1652
  - name: source
1638
1653
  type: string
1639
1654
  nullable: false
1640
- description: "feature-tree | feature-set | capability-spec | feature-spec | feature-grounding | structural-model. As of schema 6.0.0, source: structural-model is emitted for a feature only the structural model holds (M-ADR 0230 §4.3, Proposed). NOTE: feature-tree-group source removed in 1.3.0 — groups are now first-class in feature_groups.csv. As of schema 2.2.0, source: feature-tree is emitted by the canonical builder for rows derived from feature-tree.md bullets. As of schema 2.5.0, source: feature-grounding is emitted for rows derived from `docs/domains/<dom>/design/<capability>/feature-grounding.md` markdown tables (per M-ADR 0143). As of schema 2.7.0, source: capability-spec is emitted by the canonical builder for rows derived from `## Feature Grounding (code-path trace)` tables in `docs/domains/<dom>/product/<capability>.md` capability spec markdown (per M-ADR 0145). Feature-grounding and capability-spec rows are both capability-owned: product_id is empty; capability_id resolves from the file path."
1655
+ description: "feature-tree | feature-set | capability-spec | feature-spec | feature-grounding | structural-model. As of schema 6.0.0, source: structural-model is emitted for a feature only the structural model holds (M-ADR 0230 §4.3). NOTE: feature-tree-group source removed in 1.3.0 — groups are now first-class in feature_groups.csv. As of schema 2.2.0, source: feature-tree is emitted by the canonical builder for rows derived from feature-tree.md bullets. As of schema 2.5.0, source: feature-grounding is emitted for rows derived from `docs/domains/<dom>/design/<capability>/feature-grounding.md` markdown tables (per M-ADR 0143). As of schema 2.7.0, source: capability-spec is emitted by the canonical builder for rows derived from `## Feature Grounding (code-path trace)` tables in `docs/domains/<dom>/product/<capability>.md` capability spec markdown (per M-ADR 0145). Feature-grounding and capability-spec rows are both capability-owned: product_id is empty; capability_id resolves from the file path."
1641
1656
  source_of_truth: derived
1642
1657
  - name: runway
1643
1658
  type: string
@@ -2255,6 +2270,10 @@ catalogues:
2255
2270
  nullable: true
2256
2271
  description: The platform this row belongs to — sdd_id of its platform-root. Stamped by the aggregator per M-ADR 0208 §4.4 (preserve-if-set, fill rule by pull path); left empty by per-SDD builders. Added in 3.7.0.
2257
2272
  source_of_truth: execution
2273
+ - name: ppt_archetype
2274
+ type: string
2275
+ nullable: true
2276
+ description: "The entity's Party-Place-Thing archetype (ppt_archetype). A structure fact: where the SDD has a structural model, the model holds it, and a change states it in its deltas. In an SDD without a model it is read from the capability specs' Entity Classification tables: the first archetype a row's archetype cell names, colour labels and qualifiers aside (Moment alone is moment-interval, PartyRole is role); a cell naming none, an entity no table row resolves to, and two tables disagreeing are reported. Added in schema 7.1.0 (M-ADR 0230)."
2258
2277
  description: "Data-model entity (a structural realisation of a concept inside a domain's data model). Distinct from glossary_items (vocabulary-level) and from domain_models (file-level). Added in schema 2.13.0 per M-ADR 0159. Forward source: `models[].entities[]` in glossary-alignment-manifest.yaml. Reverse source: `EntityName { ... }` declarations inside `erDiagram` fences in `docs/domains/{domain}/architecture/data-model.mermaid.md`. PK uses an entity-aware slug that normalises across UPPER_SNAKE and PascalCase authoring styles."
2259
2278
  foreign_keys:
2260
2279
  - column: domain_id
@@ -2268,6 +2287,7 @@ catalogues:
2268
2287
  nullable: true
2269
2288
  column_enums:
2270
2289
  persistence_kind: enums.persistence_kind
2290
+ ppt_archetype: enums.ppt_archetype
2271
2291
  repo_capability:
2272
2292
  primary_key: id
2273
2293
  source_of_truth: derived
@@ -3933,7 +3953,7 @@ catalogues:
3933
3953
  - name: input_paths
3934
3954
  type: string
3935
3955
  nullable: true
3936
- description: "';'-separated paths of the review's other assessed inputs (its `inputs:` list, M-ADR 0230 §4.9, Proposed), beside target_path: a feature's UX evidence, say. Each is read at corpus_ref, so a later edit to any of them makes the score stale, as an edit to the target does. Added in schema 6.0.0."
3956
+ description: "';'-separated paths of the review's other assessed inputs (its `inputs:` list, M-ADR 0230 §4.9), beside target_path: a feature's UX evidence, say. Each is read at corpus_ref, so a later edit to any of them makes the score stale, as an edit to the target does. Added in schema 6.0.0."
3937
3957
  - name: staleness_basis
3938
3958
  type: string
3939
3959
  nullable: false
@@ -4752,7 +4772,7 @@ catalogues:
4752
4772
  nullable: true
4753
4773
  description: The platform SDD the row belongs to (stamped at aggregation).
4754
4774
  source_of_truth: execution
4755
- description: "Edge: evidence about one revision of a requirement, in one repository that implements it (M-ADR 0230 §4.7, Proposed; replaces requirement_status in schema 6.0.0). Derived, never authored: observed from a baseline's **Observed in:** line, declared-shipped from an archived change's PASS verdict through its work orders' implements lists, each about the revision that change's delta states. An assertion is current while its revision is, and history once a later change moves the requirement, so evidence about one revision is never read as proof of another. An agreed change is not an assertion: it is an intended revision (requirement_revisions) and a change effect (change_effects). Per (revision, repository), the latest assertion wins."
4775
+ description: "Edge: evidence about one revision of a requirement, in one repository that implements it (M-ADR 0230 §4.7; replaces requirement_status in schema 6.0.0). Derived, never authored: observed from a baseline's **Observed in:** line, declared-shipped from an archived change's PASS verdict through its work orders' implements lists, each about the revision that change's delta states. An assertion is current while its revision is, and history once a later change moves the requirement, so evidence about one revision is never read as proof of another. An agreed change is not an assertion: it is an intended revision (requirement_revisions) and a change effect (change_effects). Per (revision, repository), the latest assertion wins."
4756
4776
  natural_key:
4757
4777
  - revision_id
4758
4778
  - repo_id
@@ -4955,7 +4975,7 @@ catalogues:
4955
4975
  nullable: true
4956
4976
  description: The platform SDD the row belongs to (stamped at aggregation).
4957
4977
  source_of_truth: execution
4958
- description: "An attribute of a domain-model entity, an element of its own (M-ADR 0230 §4.3, Proposed): adding a field to an entity adds an attribute and does not modify the entity. Built from the domain model: a Mermaid ER diagram's attribute lines, or a TypeQL entity's owned attributes. Authored in the structural model (openspec/structure/) where an SDD has one. Added in schema 5.1.0; built from domain models since 6.0.0."
4978
+ description: "An attribute of a domain-model entity, an element of its own (M-ADR 0230 §4.3): adding a field to an entity adds an attribute and does not modify the entity. Built from the domain model: a Mermaid ER diagram's attribute lines, or a TypeQL entity's owned attributes. Authored in the structural model (openspec/structure/) where an SDD has one. Added in schema 5.1.0; built from domain models since 6.0.0."
4959
4979
  natural_key:
4960
4980
  - entity_id
4961
4981
  - name
@@ -5012,7 +5032,7 @@ catalogues:
5012
5032
  nullable: true
5013
5033
  description: The platform SDD the row belongs to (stamped at aggregation).
5014
5034
  source_of_truth: execution
5015
- description: "A named relationship from one domain-model entity to another, an element of its own (M-ADR 0230 §4.3, Proposed). Built from the domain model: a Mermaid ER diagram's relationship lines, or a TypeQL binary relation, with each end's cardinality and role. Authored in the structural model (openspec/structure/) where an SDD has one. Added in schema 5.1.0; built from domain models since 6.0.0, when one cardinality became two, one per end."
5035
+ description: "A named relationship from one domain-model entity to another, an element of its own (M-ADR 0230 §4.3). Built from the domain model: a Mermaid ER diagram's relationship lines, or a TypeQL binary relation, with each end's cardinality and role. Authored in the structural model (openspec/structure/) where an SDD has one. Added in schema 5.1.0; built from domain models since 6.0.0, when one cardinality became two, one per end."
5016
5036
  natural_key:
5017
5037
  - from_entity_id
5018
5038
  - to_entity_id
@@ -5065,7 +5085,7 @@ catalogues:
5065
5085
  nullable: true
5066
5086
  description: The platform SDD the row belongs to (stamped at aggregation).
5067
5087
  source_of_truth: execution
5068
- description: "A domain invariant, a typed element of the domain model (M-ADR 0230 §4.3, Proposed): a rule the entity's data always satisfies. It is structure, not intent, wherever it is first written. Built from the domain model's keys: a primary key (PK, or a TypeQL @key) or a unique key (UK) is a unique invariant over its attributes, and a TypeQL role's @card is a cardinality invariant on its relationship. Authored in the structural model (openspec/structure/) where an SDD has one, which can state every kind. Added in schema 5.1.0; built from domain models since 6.0.0."
5088
+ description: "A domain invariant, a typed element of the domain model (M-ADR 0230 §4.3): a rule the entity's data always satisfies. It is structure, not intent, wherever it is first written. Built from the domain model's keys: a primary key (PK, or a TypeQL @key) or a unique key (UK) is a unique invariant over its attributes, and a TypeQL role's @card is a cardinality invariant on its relationship. Authored in the structural model (openspec/structure/) where an SDD has one, which can state every kind. Added in schema 5.1.0; built from domain models since 6.0.0."
5069
5089
  foreign_keys:
5070
5090
  - column: entity_id
5071
5091
  references: entities.id
@@ -5111,7 +5131,7 @@ catalogues:
5111
5131
  nullable: true
5112
5132
  description: The platform SDD the row belongs to (stamped at aggregation).
5113
5133
  source_of_truth: execution
5114
- description: "One row per distinct text of a requirement (M-ADR 0230 §4.7, Proposed; schema 6.0.0). Derived from the behaviour store: the living spec's text is current; an agreed open change's ADDED or MODIFIED block is intended; an archived change's block the living spec no longer holds is history. A revision is identified by its digest, so the same text is one revision wherever it appears."
5134
+ description: "One row per distinct text of a requirement (M-ADR 0230 §4.7; schema 6.0.0). Derived from the behaviour store: the living spec's text is current; an agreed open change's ADDED or MODIFIED block is intended; an archived change's block the living spec no longer holds is history. A revision is identified by its digest, so the same text is one revision wherever it appears."
5115
5135
  foreign_keys:
5116
5136
  - column: requirement_id
5117
5137
  references: requirements.id
@@ -5160,7 +5180,7 @@ catalogues:
5160
5180
  type: string
5161
5181
  nullable: true
5162
5182
  description: The platform SDD the row belongs to (stamped at aggregation).
5163
- description: "One row per element a change writes (M-ADR 0230 §4.7, Proposed; schema 6.0.0): a requirement from its behaviour deltas, a structural element from its structural deltas (an archived change's from its effect record, structure/applied.yaml). Base and target are the revisions it moves the element between; a requirement's are revision ids (<requirement>@<12 hex digits of its digest>), catalogued in requirement_revisions except the target of a change not yet agreed; a structural element's are sha256 digests."
5183
+ description: "One row per element a change writes (M-ADR 0230 §4.7; schema 6.0.0): a requirement from its behaviour deltas, a structural element from its structural deltas (an archived change's from its effect record, structure/applied.yaml). Base and target are the revisions it moves the element between; a requirement's are revision ids (<requirement>@<12 hex digits of its digest>), catalogued in requirement_revisions except the target of a change not yet agreed; a structural element's are sha256 digests."
5164
5184
  natural_key:
5165
5185
  - change_id
5166
5186
  - element_kind
@@ -5196,7 +5216,7 @@ catalogues:
5196
5216
  - name: sunset_date
5197
5217
  type: string
5198
5218
  nullable: true
5199
- description: "For a deprecated revision, the date it is retired. Not yet populated: the builder does not yet read a version's sunset date (BASELINE.md's optional sunset_date)."
5219
+ description: "For a deprecated revision, the date it is retired: the sunset an archived change's agreement record states for the version (contracts[].deprecates.sunset, agreement-record schema 1.3.0). Empty for a version deprecated only in BASELINE.md, whose sunset is not read."
5200
5220
  - name: change_id
5201
5221
  type: string
5202
5222
  nullable: true
@@ -5212,7 +5232,7 @@ catalogues:
5212
5232
  nullable: true
5213
5233
  description: The platform SDD the row belongs to (stamped at aggregation).
5214
5234
  source_of_truth: execution
5215
- description: A contract version's content revisions, each identified by its content digest (M-ADR 0230 §4.2, Proposed; schema 6.0.0). The contract file's current content is active (deprecated where the contract is); a revision an agreed open change pins as the one it agrees (agreement record 1.2.0, contracts[].agrees) is agreed; one an archived change agreed that the file no longer holds is retired. A compatible amendment is a new revision at the same path, so an agreed revision and the active one coexist, both checked. Active is a claim about the published specification, not about deployment.
5235
+ description: A contract version's content revisions, each identified by its content digest (M-ADR 0230 §4.2; schema 6.0.0). The contract file's current content is active (deprecated where the contract is); a revision an agreed open change pins as the one it agrees (agreement record 1.2.0, contracts[].agrees) is agreed; one an archived change agreed that the file no longer holds is retired. A compatible amendment is a new revision at the same path, so an agreed revision and the active one coexist, both checked. Active is a claim about the published specification, not about deployment.
5216
5236
  foreign_keys:
5217
5237
  - column: contract_id
5218
5238
  references: contracts.id
@@ -7,7 +7,7 @@ import { rm, stat } from "node:fs/promises";
7
7
  import { join } from "node:path";
8
8
  /** name -> why it went, and what replaced it. */
9
9
  export const RETIRED_CATALOGUES = new Map([
10
- ["requirement_status", "retired in catalogue schema 6.0.0: evidence about one revision of a requirement is requirement_assertions (M-ADR 0230 §4.7, Proposed)"],
10
+ ["requirement_status", "retired in catalogue schema 6.0.0: evidence about one revision of a requirement is requirement_assertions (M-ADR 0230 §4.7)"],
11
11
  ]);
12
12
  /** Remove each retired catalogue's file from `dir`. Returns the file names removed. */
13
13
  export async function removeRetiredCatalogues(dir, findings, label) {
@@ -954,7 +954,7 @@ coverage:
954
954
  entity_attributes:
955
955
  kind: entity
956
956
  scoring: scored-at-source
957
- instrument: an element of the structural model (M-ADR 0230, Proposed); scored with its domain model by rubrics/domain-architecture-rubric.md
957
+ instrument: an element of the structural model (M-ADR 0230); scored with its domain model by rubrics/domain-architecture-rubric.md
958
958
  relationships:
959
959
  entity_id:
960
960
  class: membership
@@ -962,7 +962,7 @@ coverage:
962
962
  entity_relationships:
963
963
  kind: entity
964
964
  scoring: scored-at-source
965
- instrument: an element of the structural model (M-ADR 0230, Proposed); scored with its domain model by rubrics/domain-architecture-rubric.md
965
+ instrument: an element of the structural model (M-ADR 0230); scored with its domain model by rubrics/domain-architecture-rubric.md
966
966
  relationships:
967
967
  from_entity_id:
968
968
  class: membership
@@ -973,7 +973,7 @@ coverage:
973
973
  domain_invariants:
974
974
  kind: entity
975
975
  scoring: scored-at-source
976
- instrument: an element of the structural model (M-ADR 0230, Proposed); scored with its domain model by rubrics/domain-architecture-rubric.md
976
+ instrument: an element of the structural model (M-ADR 0230); scored with its domain model by rubrics/domain-architecture-rubric.md
977
977
  relationships:
978
978
  entity_id:
979
979
  class: membership
@@ -1039,3 +1039,7 @@ coverage:
1039
1039
  kind: enum
1040
1040
  scoring: not-applicable
1041
1041
  reason: closed vocabulary, not an artefact
1042
+ ppt_archetype:
1043
+ kind: enum
1044
+ scoring: not-applicable
1045
+ reason: closed vocabulary, not an artefact
@@ -40,7 +40,7 @@
40
40
  // none — already reported by scores-coverage as unknown currency; not
41
41
  // re-reported here.
42
42
  //
43
- // ASSESSED INPUTS (M-ADR 0230 §4.9, Proposed): a review that names its other inputs (`input_paths`) is read with
43
+ // ASSESSED INPUTS (M-ADR 0230 §4.9): a review that names its other inputs (`input_paths`) is read with
44
44
  // each of them, once its target is current. An input that moved stales the score, with the input named. So does an
45
45
  // input gone from HEAD, and one the corpus did not hold at the anchor: unlike a missing target, the score can still
46
46
  // be re-reviewed against its target, and a review cannot have read an input that was not there, so both prescribe a
@@ -171,7 +171,7 @@ export async function runStalenessVerdicts(session, options) {
171
171
  };
172
172
  }
173
173
  const asStr = (v) => v === null || v === undefined ? "" : String(v).trim();
174
- // input_paths (schema 6.0.0, M-ADR 0230 §4.9, Proposed): a catalogue built before it has no such column, and its
174
+ // input_paths (schema 6.0.0, M-ADR 0230 §4.9): a catalogue built before it has no such column, and its
175
175
  // scores are read as naming no other input.
176
176
  const query = (inputs) => `SELECT rubric_id, target_ref, target_path, corpus_ref, scored_at, staleness_basis, ${inputs}
177
177
  FROM "quality_scores"
@@ -191,7 +191,7 @@ export async function runStalenessVerdicts(session, options) {
191
191
  const rubricId = asStr(rubricIdRaw);
192
192
  const targetRef = asStr(targetRefRaw);
193
193
  const basis = asStr(basisRaw);
194
- // The review's other assessed inputs (M-ADR 0230 §4.9, Proposed): read with the target, so an edit to any of
194
+ // The review's other assessed inputs (M-ADR 0230 §4.9): read with the target, so an edit to any of
195
195
  // them makes the score stale as an edit to the target does.
196
196
  const inputs = asStr(inputPathsRaw).split(";").map((x) => x.trim()).filter((x) => x !== "");
197
197
  // Counted for BOTH bases, before the branch. The first cut of this counter
@@ -1,13 +1,15 @@
1
- // The catalogue from the structural model, and the model a built catalogue implies (M-ADR 0230 §4.3, §5.3,
2
- // Proposed). Where an SDD has a model, it is the record of structure, so every structure catalogue is built from it whole:
1
+ // The catalogue from the structural model, and the model a built catalogue implies (M-ADR 0230 §4.3, §5.3).
2
+ // Where an SDD has a model, it is the record of structure, so every structure catalogue is built from it whole:
3
3
  // a row per element of the current view, with the model's structure columns;
4
4
  // its other columns (every class but structure: derived, declaration, evidence, intent, execution) from the
5
5
  // source-built row with the same id;
6
6
  // for an element only the model holds, the derived columns the model itself settles (MODEL_DERIVED).
7
7
  // What the sources hold and the model does not, and a structure column where they disagree, is reported once per
8
- // catalogue. The model wins: either finding means the sources moved outside a change. Pure: no file is read or written.
8
+ // catalogue. The model wins: either finding means the sources moved outside a change. A source row that states an
9
+ // element as an agreed open change adds or modifies it is that change's intended element, not a disagreement: it is
10
+ // listed apart, and catalogued once the change archives. Pure: no file is read or written.
9
11
  import { stringify } from "yaml";
10
- import { FORMAT_VERSION } from "./model.js";
12
+ import { elementKey, FORMAT_VERSION } from "./model.js";
11
13
  import { STRUCTURE } from "./view.js";
12
14
  /** The view each generated file renders, for a derived path column of an element only the model holds. */
13
15
  export const VIEW_PATHS = {
@@ -44,8 +46,10 @@ function sample(ids) {
44
46
  /**
45
47
  * Replace every structure catalogue's rows with the view's. Rows of other catalogues are returned as they are. Source
46
48
  * rows sharing an id are merged first, later values filling earlier gaps, as the keyed-table dedupe would.
49
+ * `intended` holds the elements agreed open changes add or modify (intendedWrites); a source row agreeing with one is
50
+ * pushed to `intendedOut` as `<key> (<change>)` instead of being reported.
47
51
  */
48
- export function overlayModel(schema, view, rows, findings) {
52
+ export function overlayModel(schema, view, rows, findings, intended = new Map(), intendedOut = []) {
49
53
  const out = new Map(rows);
50
54
  for (const cat of schema.catalogues) {
51
55
  if (cat.sourceOfTruth !== STRUCTURE)
@@ -66,6 +70,20 @@ export function overlayModel(schema, view, rows, findings) {
66
70
  const elements = view.get(cat.name) ?? new Map();
67
71
  const built = [];
68
72
  const differ = [];
73
+ const disagree = (from, e) => structural.filter((c) => cell(from[c]) !== "" && cell(from[c]) !== cell(e.columns[c]));
74
+ // The source row states the element as an agreed open change does; one stating it otherwise is reported as such.
75
+ const differIntended = [];
76
+ const asIntended = (id, from) => {
77
+ const w = intended.get(elementKey(cat.name, id));
78
+ if (w === undefined)
79
+ return false;
80
+ const cols = disagree(from, w.element);
81
+ if (cols.length > 0)
82
+ differIntended.push(`${id} (${cols.join(", ")}; ${w.change})`);
83
+ else
84
+ intendedOut.push(`${elementKey(cat.name, id)} (${w.change})`);
85
+ return true;
86
+ };
69
87
  for (const e of elements.values()) {
70
88
  const from = source.get(e.id);
71
89
  const row = {};
@@ -73,8 +91,8 @@ export function overlayModel(schema, view, rows, findings) {
73
91
  for (const [k, v] of Object.entries(from))
74
92
  if (!structural.includes(k))
75
93
  row[k] = v;
76
- const cols = structural.filter((c) => cell(from[c]) !== "" && cell(from[c]) !== cell(e.columns[c]));
77
- if (cols.length > 0)
94
+ const cols = disagree(from, e);
95
+ if (cols.length > 0 && !asIntended(e.id, from))
78
96
  differ.push(`${e.id} (${cols.join(", ")})`);
79
97
  }
80
98
  else {
@@ -85,12 +103,15 @@ export function overlayModel(schema, view, rows, findings) {
85
103
  row[c] = e.columns[c];
86
104
  built.push(row);
87
105
  }
88
- const missing = [...source.keys()].filter((id) => id !== "" && !elements.has(id)).sort();
106
+ const missing = [...source.keys()].filter((id) => id !== "" && !elements.has(id) && !asIntended(id, source.get(id))).sort();
89
107
  if (missing.length > 0) {
90
- findings.add("divergence", `${cat.name}: the sources hold ${missing.length} row(s) the structural model does not (${sample(missing)}); the model is the record of structure, so they are not catalogued. Add them through a change's structural deltas, or remove them from the sources (M-ADR 0230 §4.3, Proposed)`, "warn", `catalogue:${cat.name}`);
108
+ findings.add("divergence", `${cat.name}: the sources hold ${missing.length} row(s) the structural model does not (${sample(missing)}); the model is the record of structure, so they are not catalogued. Add them through a change's structural deltas, or remove them from the sources (M-ADR 0230 §4.3)`, "warn", `catalogue:${cat.name}`);
109
+ }
110
+ if (differIntended.length > 0) {
111
+ findings.add("divergence", `${cat.name}: ${differIntended.length} source row(s) state an element an agreed open change adds or modifies, and disagree with it: ${sample(differIntended.sort())}. The change's delta is what archives; bring the source into line with it, or the delta with the source (M-ADR 0230 §4.3, §4.7)`, "warn", `catalogue:${cat.name}`);
91
112
  }
92
113
  if (differ.length > 0) {
93
- findings.add("divergence", `${cat.name}: ${differ.length} element(s) where the sources and the structural model disagree, catalogued as the model states them: ${sample(differ.sort())}. A source that is a generated view is rendered again; any other is brought into line through a change (M-ADR 0230 §4.3, Proposed)`, "warn", `catalogue:${cat.name}`);
114
+ findings.add("divergence", `${cat.name}: ${differ.length} element(s) where the sources and the structural model disagree, catalogued as the model states them: ${sample(differ.sort())}. A source that is a generated view is rendered again; any other is brought into line through a change (M-ADR 0230 §4.3)`, "warn", `catalogue:${cat.name}`);
94
115
  }
95
116
  out.set(cat.name, built);
96
117
  }
@@ -1,4 +1,4 @@
1
- // Views over the structural model, and how changes compose (M-ADR 0230 §4.5, §4.7, Proposed).
1
+ // Views over the structural model, and how changes compose (M-ADR 0230 §4.5, §4.7).
2
2
  // current the model as published
3
3
  // at a change current with that change's deltas and those of its dependency closure, dependencies first
4
4
  // intended current with every agreed change's deltas
@@ -1,4 +1,4 @@
1
- // A change's structural effect, and the effect record an archive leaves (M-ADR 0230 §4.6, §4.7, Proposed). Pure reads,
1
+ // A change's structural effect, and the effect record an archive leaves (M-ADR 0230 §4.6, §4.7). Pure reads,
2
2
  // so the catalogue builder and the verify-only CLI can carry them; writing the record is apply.ts's.
3
3
  import { parseDocument } from "yaml";
4
4
  import { elementKey, revision } from "./model.js";
@@ -0,0 +1,199 @@
1
+ // What an open change adds, for the references its own content makes (M-ADR 0230 §4.7, §4.11 proof 3).
2
+ // A reference made by an open change resolves against the current view plus that change's additions: the elements its
3
+ // structural deltas ADD, those of the changes in its depends_on closure, and the contracts its agreement record agrees
4
+ // as new files. A reference made by anything else resolves against the current view only, so a current reference that
5
+ // resolves only against an addition is still refused.
6
+ // What ties content to a change is never the reference being resolved:
7
+ // a model element the change's own delta (validateDeltas, viewAt)
8
+ // a source-built row with a change_id that change
9
+ // a contract row the change whose record agrees its file as new
10
+ // a row naming such a contract that change
11
+ // a row built from the change's files that change (its spec_path lies in openspec/changes/<change>/, as a
12
+ // requirement the change ADDS does)
13
+ // Pure but for reading agreement records.
14
+ import { readdir, readFile } from "node:fs/promises";
15
+ import { join } from "node:path";
16
+ import { parseDocument } from "yaml";
17
+ import { closure } from "./compose.js";
18
+ import { elementKey, loadChangeStructure } from "./model.js";
19
+ export const CONTRACTS = "contracts";
20
+ const LIFECYCLES = ["proposed", "agreed", "withdrawn", "superseded"];
21
+ /** The change's agreement record (docs/agreements/<change>.yaml): its status, or `unrecorded`, and its new contract files. */
22
+ export async function readAgreement(repo, change) {
23
+ let text;
24
+ try {
25
+ text = await readFile(join(repo, "docs", "agreements", `${change}.yaml`), "utf8");
26
+ }
27
+ catch {
28
+ return { status: "unrecorded", newContracts: [] };
29
+ }
30
+ let record;
31
+ try {
32
+ record = parseDocument(text).toJS()?.agreement_record;
33
+ }
34
+ catch {
35
+ return { status: "unrecorded", newContracts: [] };
36
+ }
37
+ const status = LIFECYCLES.find((s) => s === String(record?.["status"] ?? "")) ?? "unrecorded";
38
+ const newContracts = [];
39
+ const entries = Array.isArray(record?.["contracts"]) ? record["contracts"] : [];
40
+ for (const raw of entries) {
41
+ if (raw === null || typeof raw !== "object")
42
+ continue;
43
+ const e = raw;
44
+ if (e["amended_by_this_change"] !== true)
45
+ continue;
46
+ const files = Array.isArray(e["files"]) ? e["files"].map(String) : e["file"] !== undefined ? [String(e["file"])] : [];
47
+ // agreement-record schema 1.2.0 and later: a file the change relies on carries relies_on, so an agreed file
48
+ // without one is new (1.3.0 states it). An entry with no agrees predates the digests and says nothing either way.
49
+ const digest = (field, f) => {
50
+ const v = e[field];
51
+ return v !== null && typeof v === "object" ? String(v[f] ?? "") : String(v ?? "");
52
+ };
53
+ for (const f of files)
54
+ if (digest("agrees", f) !== "" && digest("relies_on", f) === "")
55
+ newContracts.push(`${String(e["repo"] ?? "")}/${f}`);
56
+ }
57
+ return { status, newContracts };
58
+ }
59
+ /** The open changes (openspec/changes/<change>, not archive/), with their agreement records. */
60
+ export async function loadOpenChanges(repo, problems) {
61
+ let names;
62
+ try {
63
+ names = (await readdir(join(repo, "openspec", "changes"), { withFileTypes: true }))
64
+ .filter((e) => e.isDirectory() && e.name !== "archive")
65
+ .map((e) => e.name)
66
+ .sort();
67
+ }
68
+ catch {
69
+ names = [];
70
+ }
71
+ const open = new Map();
72
+ const newContracts = new Map();
73
+ for (const name of names) {
74
+ const agreement = await readAgreement(repo, name);
75
+ open.set(name, { structure: await loadChangeStructure(repo, name, problems), status: agreement.status });
76
+ newContracts.set(name, agreement.newContracts);
77
+ }
78
+ return { open, newContracts };
79
+ }
80
+ const cell = (v) => (v === null || v === undefined ? "" : String(v));
81
+ /**
82
+ * Each open change's additions, and the change that adds each. A contract is identified by its built row: the row
83
+ * whose spec_path is `<repo>/<file>` as the record names it. A new contract with no built row adds nothing, and a
84
+ * reference to it stays unresolved.
85
+ */
86
+ export class Additions {
87
+ open;
88
+ own = new Map();
89
+ adder = new Map();
90
+ constructor(open, newContracts, contractRows) {
91
+ this.open = open;
92
+ const idByPath = new Map();
93
+ for (const r of contractRows)
94
+ if (cell(r["spec_path"]) !== "")
95
+ idByPath.set(cell(r["spec_path"]), cell(r["id"]));
96
+ for (const [name, oc] of open) {
97
+ const keys = new Set();
98
+ for (const d of oc.structure.deltas)
99
+ for (const e of d.added)
100
+ keys.add(elementKey(e.catalogue, e.id));
101
+ for (const p of newContracts.get(name) ?? []) {
102
+ const id = idByPath.get(p);
103
+ if (id !== undefined && id !== "")
104
+ keys.add(elementKey(CONTRACTS, id));
105
+ }
106
+ this.own.set(name, keys);
107
+ for (const k of keys)
108
+ if (!this.adder.has(k))
109
+ this.adder.set(k, name);
110
+ }
111
+ }
112
+ /** The open change that adds the element or contract, if one does. */
113
+ addedBy(catalogue, id) {
114
+ return this.adder.get(elementKey(catalogue, id));
115
+ }
116
+ /** Whether the element or contract is the change's own addition or one of its dependency closure's. */
117
+ within(change, catalogue, id) {
118
+ const key = elementKey(catalogue, id);
119
+ return closure(change, this.open).some((c) => this.own.get(c)?.has(key) ?? false);
120
+ }
121
+ /** The contracts the given changes add. */
122
+ contracts(changes) {
123
+ const out = new Set();
124
+ for (const c of changes)
125
+ for (const k of this.own.get(c) ?? [])
126
+ if (k.startsWith(`${CONTRACTS}/`))
127
+ out.add(k.slice(CONTRACTS.length + 1));
128
+ return out;
129
+ }
130
+ /** The open changes a source-built row belongs to: its change_id, the change whose files it is built from, or a new contract it is or names. */
131
+ ownersOf(schema, catalogue, row, sddId) {
132
+ const out = new Set();
133
+ const changeId = cell(row["change_id"]);
134
+ if (changeId !== "") {
135
+ const name = changeId.startsWith(`${sddId}::`) ? changeId.slice(sddId.length + 2) : changeId;
136
+ if (this.open.has(name))
137
+ out.add(name);
138
+ }
139
+ const from = /^openspec\/changes\/([^/]+)\//.exec(cell(row["spec_path"]))?.[1];
140
+ if (from !== undefined && this.open.has(from))
141
+ out.add(from);
142
+ const contractOwner = (id) => {
143
+ const by = this.adder.get(elementKey(CONTRACTS, id));
144
+ if (by !== undefined)
145
+ out.add(by);
146
+ };
147
+ const cat = schema.catalogues.find((c) => c.name === catalogue);
148
+ if (catalogue === CONTRACTS && cat)
149
+ contractOwner(cell(row[cat.primaryKey]));
150
+ for (const fk of cat?.foreignKeys ?? [])
151
+ if (fk.references === `${CONTRACTS}.id` && cell(row[fk.column]) !== "")
152
+ contractOwner(cell(row[fk.column]));
153
+ return [...out].sort();
154
+ }
155
+ }
156
+ /**
157
+ * Sort a build's dangling references: a row an open change owns, naming that change's addition, resolves in that
158
+ * change's view. Every other stays dangling, including a row nothing ties to the change that adds its target.
159
+ */
160
+ export function splitDangling(schema, rowsByCatalogue, failures, additions, sddId) {
161
+ const intended = [];
162
+ const dangling = [];
163
+ const index = new Map();
164
+ const rowOf = (catalogue, pk) => {
165
+ let byPk = index.get(catalogue);
166
+ if (!byPk) {
167
+ const key = schema.catalogues.find((c) => c.name === catalogue)?.primaryKey ?? "id";
168
+ byPk = new Map((rowsByCatalogue.get(catalogue) ?? []).map((r) => [cell(r[key]), r]));
169
+ index.set(catalogue, byPk);
170
+ }
171
+ return byPk.get(pk);
172
+ };
173
+ for (const f of failures) {
174
+ const [target, column] = f.target.split(".");
175
+ const targetPk = schema.catalogues.find((c) => c.name === target)?.primaryKey;
176
+ const row = rowOf(f.catalogue, f.referencingRow);
177
+ const owner = f.value === "" || column !== targetPk || row === undefined
178
+ ? undefined
179
+ : additions.ownersOf(schema, f.catalogue, row, sddId).find((c) => additions.within(c, target, f.value));
180
+ if (owner !== undefined)
181
+ intended.push({ failure: f, change: owner });
182
+ else {
183
+ const by = f.value === "" ? undefined : additions.addedBy(target, f.value);
184
+ dangling.push(by === undefined ? { failure: f } : { failure: f, addedBy: by });
185
+ }
186
+ }
187
+ return { intended, dangling };
188
+ }
189
+ /** Element key -> the agreed change that adds or modifies it, and the element as that change states it. */
190
+ export function intendedWrites(open, agreed) {
191
+ const out = new Map();
192
+ for (const c of agreed) {
193
+ for (const d of open.get(c)?.structure.deltas ?? [])
194
+ for (const e of [...d.added, ...d.modified])
195
+ out.set(elementKey(e.catalogue, e.id), { change: c, element: e });
196
+ }
197
+ return out;
198
+ }
199
+ //# sourceMappingURL=intended.js.map
@@ -1,4 +1,4 @@
1
- // The structural model and a change's structural deltas (M-ADR 0230 §4.3, §4.4, Proposed). Pure reads, so the
1
+ // The structural model and a change's structural deltas (M-ADR 0230 §4.3, §4.4). Pure reads, so the
2
2
  // verify-only CLI can carry them. The format is docs/method/methods/guides/structural-model-format.md:
3
3
  // openspec/structure/<partition>.yaml the model, one file per partition
4
4
  // openspec/changes/<change>/structure/<partition>.yaml a change's delta for that partition
@@ -1,4 +1,4 @@
1
- // The generated views of the structural model (M-ADR 0230 §4.3, Proposed): projections, never edited. Each file is
1
+ // The generated views of the structural model (M-ADR 0230 §4.3): projections, never edited. Each file is
2
2
  // rendered from the current view alone, in id order, so the same model renders the same bytes. Its first line names
3
3
  // the generator and the digest of the body below it, which tells three states apart:
4
4
  // missing the file is absent