@sdd-method/author-cli 0.13.0 → 0.14.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.
- package/README.md +1 -1
- package/dist/author-program.js +10 -2
- package/dist/lib/catalogue/build.js +58 -12
- package/dist/lib/catalogue/builders/adr-governs.js +1 -1
- package/dist/lib/catalogue/builders/adrs.js +2 -2
- package/dist/lib/catalogue/builders/contract-revisions.js +45 -7
- package/dist/lib/catalogue/builders/data-model.js +1 -1
- package/dist/lib/catalogue/builders/entity-archetype.js +121 -0
- package/dist/lib/catalogue/builders/quality-scores.js +1 -1
- package/dist/lib/catalogue/builders/requirements.js +1 -1
- package/dist/lib/catalogue/canonical-schema.yaml +41 -21
- package/dist/lib/catalogue/retired-catalogues.js +1 -1
- package/dist/lib/catalogue/rubric-coverage-map.yaml +7 -3
- package/dist/lib/catalogue/staleness-verdicts.js +3 -3
- package/dist/lib/structure/apply.js +71 -0
- package/dist/lib/structure/archive.js +330 -0
- package/dist/lib/structure/catalogue.js +31 -10
- package/dist/lib/structure/compose.js +1 -1
- package/dist/lib/structure/effects.js +1 -1
- package/dist/lib/structure/extract.js +123 -0
- package/dist/lib/structure/intended.js +199 -0
- package/dist/lib/structure/model.js +1 -1
- package/dist/lib/structure/render.js +1 -1
- package/dist/lib/structure/view.js +8 -3
- package/dist/lib/validate/agreement-evidence.js +2 -2
- package/dist/lib/validate/behaviour-store.js +49 -12
- package/dist/lib/validate/dispatch.js +1 -1
- package/dist/lib/validate/structural-model.js +48 -35
- package/dist/maintain-version.json +2 -2
- package/dist/verbs/change.js +15 -0
- package/dist/verbs/migrate-structure.js +36 -0
- package/dist/verify-version.json +2 -2
- package/package.json +2 -2
|
@@ -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.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Writing a change's structural deltas into the model files, and the record of what they did (M-ADR 0230 §4.6).
|
|
2
|
+
// The files are edited as YAML documents, so their comments and element order survive: a modified element
|
|
3
|
+
// is replaced where it stands, a removed one is deleted, an added one is appended to its catalogue's list, and a
|
|
4
|
+
// partition the model does not have yet gets a file. Writes files; the archive operation calls it in a scratch copy.
|
|
5
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { isMap, isSeq, parseDocument, stringify } from "yaml";
|
|
8
|
+
import { elementKey, FORMAT_VERSION, STRUCTURE_DIR } from "./model.js";
|
|
9
|
+
export { APPLIED_FILE } from "./model.js";
|
|
10
|
+
export { effectsOf, parseAppliedRecord } from "./effects.js";
|
|
11
|
+
export function appliedRecord(change, baseCommit, effects) {
|
|
12
|
+
return stringify({ schema_version: FORMAT_VERSION, change, base_commit: baseCommit, effects: effects.map((e) => ({ ...e })) });
|
|
13
|
+
}
|
|
14
|
+
function itemIndex(seq, id) {
|
|
15
|
+
return seq.items.findIndex((it) => isMap(it) && String(it.get("id")) === id);
|
|
16
|
+
}
|
|
17
|
+
function catalogueSeq(doc, catalogue) {
|
|
18
|
+
let elements = doc.get("elements");
|
|
19
|
+
if (!isMap(elements)) {
|
|
20
|
+
doc.set("elements", doc.createNode({}));
|
|
21
|
+
elements = doc.get("elements");
|
|
22
|
+
}
|
|
23
|
+
const map = elements;
|
|
24
|
+
let seq = map.get(catalogue);
|
|
25
|
+
if (!isSeq(seq)) {
|
|
26
|
+
map.set(catalogue, doc.createNode([]));
|
|
27
|
+
seq = map.get(catalogue);
|
|
28
|
+
}
|
|
29
|
+
return seq;
|
|
30
|
+
}
|
|
31
|
+
/** Apply the change's deltas to the model files under `sddPath`, partition by partition. Returns the files written. */
|
|
32
|
+
export async function applyToModel(sddPath, s) {
|
|
33
|
+
const written = [];
|
|
34
|
+
for (const d of s.deltas) {
|
|
35
|
+
const rel = join(STRUCTURE_DIR, `${d.partition}.yaml`);
|
|
36
|
+
const path = join(sddPath, rel);
|
|
37
|
+
let text;
|
|
38
|
+
try {
|
|
39
|
+
text = await readFile(path, "utf8");
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
text = stringify({ schema_version: FORMAT_VERSION, partition: d.partition, elements: {} });
|
|
43
|
+
}
|
|
44
|
+
const doc = parseDocument(text);
|
|
45
|
+
const node = (e) => doc.createNode({ id: e.id, ...e.columns });
|
|
46
|
+
for (const e of d.modified) {
|
|
47
|
+
const seq = catalogueSeq(doc, e.catalogue);
|
|
48
|
+
const i = itemIndex(seq, e.id);
|
|
49
|
+
if (i < 0)
|
|
50
|
+
throw new Error(`${rel}: MODIFIED ${elementKey(e.catalogue, e.id)} is not in this partition`);
|
|
51
|
+
seq.items[i] = node(e);
|
|
52
|
+
}
|
|
53
|
+
for (const r of d.removed) {
|
|
54
|
+
const seq = catalogueSeq(doc, r.catalogue);
|
|
55
|
+
const i = itemIndex(seq, r.id);
|
|
56
|
+
if (i < 0)
|
|
57
|
+
throw new Error(`${rel}: REMOVED ${elementKey(r.catalogue, r.id)} is not in this partition`);
|
|
58
|
+
seq.items.splice(i, 1);
|
|
59
|
+
}
|
|
60
|
+
for (const e of d.added) {
|
|
61
|
+
const seq = catalogueSeq(doc, e.catalogue);
|
|
62
|
+
if (itemIndex(seq, e.id) >= 0)
|
|
63
|
+
throw new Error(`${rel}: ADDED ${elementKey(e.catalogue, e.id)} is already in this partition`);
|
|
64
|
+
seq.add(node(e));
|
|
65
|
+
}
|
|
66
|
+
await writeFile(path, doc.toString(), "utf8");
|
|
67
|
+
written.push(rel);
|
|
68
|
+
}
|
|
69
|
+
return written;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=apply.js.map
|