@sdd-method/author-cli 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/behaviour-store/archive.js +13 -0
- package/dist/lib/catalogue/build.js +45 -2
- package/dist/lib/catalogue/builders/adr-governs.js +39 -0
- package/dist/lib/catalogue/builders/adrs.js +11 -0
- package/dist/lib/catalogue/builders/capability-spec.js +1 -0
- package/dist/lib/catalogue/builders/contract-revisions.js +126 -0
- package/dist/lib/catalogue/builders/data-model.js +316 -0
- package/dist/lib/catalogue/builders/entities-mermaid.js +18 -85
- package/dist/lib/catalogue/builders/feature-grounding.js +1 -0
- package/dist/lib/catalogue/builders/features.js +23 -2
- package/dist/lib/catalogue/builders/integration-components.js +49 -5
- package/dist/lib/catalogue/builders/journey-requirement.js +144 -0
- package/dist/lib/catalogue/builders/quality-scores.js +17 -0
- package/dist/lib/catalogue/builders/requirements.js +168 -32
- package/dist/lib/catalogue/canonical-schema.yaml +845 -28
- package/dist/lib/catalogue/manifest-loader.js +13 -0
- package/dist/lib/catalogue/retired-catalogues.js +25 -0
- package/dist/lib/catalogue/rubric-coverage-map.yaml +108 -2
- package/dist/lib/catalogue/schema-compat.js +1 -1
- package/dist/lib/catalogue/schema-loader.js +3 -0
- package/dist/lib/catalogue/staleness-verdicts.js +75 -6
- package/dist/lib/intents/migrate.js +35 -9
- package/dist/lib/metamodel/tql-subset-parser.js +35 -2
- package/dist/lib/structure/catalogue.js +183 -0
- package/dist/lib/structure/compose.js +174 -0
- package/dist/lib/structure/effects.js +36 -0
- package/dist/lib/structure/model.js +212 -0
- package/dist/lib/structure/render.js +242 -0
- package/dist/lib/structure/view.js +301 -0
- package/dist/lib/validate/agreement-evidence.js +216 -0
- package/dist/lib/validate/behaviour-store.js +516 -28
- package/dist/lib/validate/dispatch.js +21 -0
- package/dist/lib/validate/feature-spec-pointers.js +175 -0
- package/dist/lib/validate/journey-impact.js +193 -0
- package/dist/lib/validate/structural-model.js +265 -0
- package/dist/maintain-version.json +2 -2
- package/dist/verify-version.json +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// What an agreement binds and what a verdict must show (M-ADR 0222 §4.6, M-ADR 0223 §4.4-§4.6).
|
|
2
|
+
// Pure text helpers; behaviour-store.ts runs them against git.
|
|
3
|
+
//
|
|
4
|
+
// agreed content the change's proposal, deltas, Gate 0, design, tasks (checkboxes ignored), the test plan's
|
|
5
|
+
// scenario-to-test rows (its Before and After cells ignored) and its structural deltas with their
|
|
6
|
+
// base revisions (M-ADR 0230 §4.4, Proposed; report only until it is accepted) are what was approved. Each is compared
|
|
7
|
+
// with its state at the record's pinned commit: the latest amendment's commit, else sdd.commit.
|
|
8
|
+
// requirement a requirement's block in a spec: its heading to the next requirement or section heading. The
|
|
9
|
+
// stale check compares the blocks a change targets, not the whole file.
|
|
10
|
+
// scenario kind changed (a scenario of an ADDED requirement, or one of a MODIFIED requirement that is new or
|
|
11
|
+
// differs from the living spec's scenario of the same title) goes red then green; carried (identical
|
|
12
|
+
// to the living spec's) is regression and stays green.
|
|
13
|
+
// verdict line verdict.md's own verdict: `Verdict: PASS|FAIL` or a leading `**PASS**`/`**FAIL**`.
|
|
14
|
+
/** The files under a change directory that agreement binds, relative to the change directory. */
|
|
15
|
+
export function boundFile(rel) {
|
|
16
|
+
return /^(proposal|design|gate-0|tasks|test-plan)\.md$/.test(rel) || /^specs\/.+\/spec\.md$/.test(rel) || structuralFile(rel);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A change's structural artifact (M-ADR 0230 §4.4, Proposed): a partition delta or the no-op claim, both agreed
|
|
20
|
+
* content, so a delta's base revisions are pinned with it. The effect record (structure/applied.yaml) is written by
|
|
21
|
+
* the archive, after agreement, and is not.
|
|
22
|
+
*/
|
|
23
|
+
export function structuralFile(rel) {
|
|
24
|
+
return /^structure\/[^/]+\.yaml$/.test(rel) && rel !== "structure/applied.yaml";
|
|
25
|
+
}
|
|
26
|
+
/** A bound file's content as agreement compares it: all of it, with only the fields execution fills in masked. */
|
|
27
|
+
export function normaliseBound(rel, text) {
|
|
28
|
+
if (rel === "tasks.md")
|
|
29
|
+
return text.replace(/^(\s*-\s*\[)\s*[xX~]?\s*(\])/gm, "$1 $2").trimEnd();
|
|
30
|
+
if (rel === "test-plan.md")
|
|
31
|
+
return normaliseTestPlan(text);
|
|
32
|
+
return text.trimEnd();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The test plan as agreed. Masked, because execution fills them in: the last two cells (Before and After) of each
|
|
36
|
+
* row of the scenario table, and the whole Ledger and Mutants sections. Everything else, the stand-ins and any
|
|
37
|
+
* strategy or limitation stated, stays bound.
|
|
38
|
+
*/
|
|
39
|
+
export function normaliseTestPlan(text) {
|
|
40
|
+
const out = [];
|
|
41
|
+
let section = "";
|
|
42
|
+
for (const line of text.split("\n")) {
|
|
43
|
+
const h = /^##\s+(.+?)\s*$/.exec(line);
|
|
44
|
+
if (h) {
|
|
45
|
+
section = h[1].toLowerCase();
|
|
46
|
+
if (section !== "mutants")
|
|
47
|
+
out.push(line);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// The ledger and the mutants are what apply records: the mutants are written against guards that exist only once
|
|
51
|
+
// the change is applied, and the judge writes its own for any guard they miss (M-ADR 0228 §4.1, Proposed).
|
|
52
|
+
if (section === "ledger" || section === "mutants")
|
|
53
|
+
continue;
|
|
54
|
+
if (section === "" && /^\s*\|/.test(line)) {
|
|
55
|
+
const cells = line.trim().replace(/^\||\|$/g, "").split("|").map((c) => c.trim());
|
|
56
|
+
out.push(cells.slice(0, Math.max(0, cells.length - 2)).join(" | "));
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
out.push(line);
|
|
60
|
+
}
|
|
61
|
+
return out.join("\n").trimEnd();
|
|
62
|
+
}
|
|
63
|
+
/** A tasks file's repository groups (`## <n>. <repository>`) and the requirements each says it implements. */
|
|
64
|
+
export function taskGroups(tasks) {
|
|
65
|
+
const out = [];
|
|
66
|
+
let current = null;
|
|
67
|
+
for (const line of tasks.split("\n")) {
|
|
68
|
+
const g = /^##\s+\d+\.\s+`?([A-Za-z0-9][A-Za-z0-9._-]*)`?\s*$/.exec(line);
|
|
69
|
+
if (g) {
|
|
70
|
+
current = { repo: g[1], implements: [] };
|
|
71
|
+
out.push(current);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (/^##\s/.test(line)) {
|
|
75
|
+
current = null;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const m = /^\s*(?:[-*]\s+)?\**Implements:?\**:?\s*(.+)$/i.exec(line);
|
|
79
|
+
if (current && m)
|
|
80
|
+
current.implements.push(...m[1].split(",").map((x) => x.trim().replace(/^`|`$/g, "")).filter((x) => x && !/^none$/i.test(x)));
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
/** A pinned commit: 7 to 40 hex characters. */
|
|
85
|
+
export function isCommit(v) {
|
|
86
|
+
return typeof v === "string" && /^[0-9a-f]{7,40}$/i.test(v);
|
|
87
|
+
}
|
|
88
|
+
/** a >= b, for x.y.z versions; a missing or malformed version is lowest. */
|
|
89
|
+
export function versionAtLeast(a, b) {
|
|
90
|
+
const p = (v) => (v && /^\d+\.\d+\.\d+$/.test(v) ? v.split(".").map(Number) : [-1, -1, -1]);
|
|
91
|
+
const [x, y] = [p(a), p(b)];
|
|
92
|
+
for (let i = 0; i < 3; i++)
|
|
93
|
+
if (x[i] !== y[i])
|
|
94
|
+
return x[i] > y[i];
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
/** The test plan's scenario-to-test rows: every table row before `## Ledger`, as trimmed cells, with the first row (the header) and separator rows dropped. The template holds one table there; a second would be read as more rows. */
|
|
98
|
+
export function testPlanMapping(text) {
|
|
99
|
+
const head = text.split(/^##\s+Ledger\b/m)[0] ?? "";
|
|
100
|
+
const rows = head.split("\n").filter((l) => /^\s*\|/.test(l)).map((l) => l.trim().replace(/^\||\|$/g, "").split("|").map((c) => c.trim()));
|
|
101
|
+
return rows.filter((r, i) => i > 0 && !r.every((c) => /^:?-{3,}:?$/.test(c) || c === ""));
|
|
102
|
+
}
|
|
103
|
+
/** The test plan table's header cells, lower-cased. */
|
|
104
|
+
export function testPlanHeader(text) {
|
|
105
|
+
const head = text.split(/^##\s+Ledger\b/m)[0] ?? "";
|
|
106
|
+
const first = head.split("\n").find((l) => /^\s*\|/.test(l));
|
|
107
|
+
return first ? first.trim().replace(/^\||\|$/g, "").split("|").map((c) => c.trim().toLowerCase()) : [];
|
|
108
|
+
}
|
|
109
|
+
/** A requirement's block: `### Requirement: <name>` to the next requirement or `##` heading. Null when absent. */
|
|
110
|
+
export function requirementBlock(spec, name) {
|
|
111
|
+
const lines = spec.split("\n");
|
|
112
|
+
const start = lines.findIndex((l) => new RegExp(`^###\\s+Requirement:\\s*${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`).test(l));
|
|
113
|
+
if (start < 0)
|
|
114
|
+
return null;
|
|
115
|
+
let end = lines.length;
|
|
116
|
+
for (let i = start + 1; i < lines.length; i++) {
|
|
117
|
+
if (/^###\s+Requirement:/.test(lines[i]) || /^##\s/.test(lines[i])) {
|
|
118
|
+
end = i;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return lines.slice(start, end).join("\n").trimEnd();
|
|
123
|
+
}
|
|
124
|
+
/** Scenario title -> its block text, within one requirement block. */
|
|
125
|
+
export function scenarios(block) {
|
|
126
|
+
const out = new Map();
|
|
127
|
+
let title = null;
|
|
128
|
+
let buf = [];
|
|
129
|
+
const flush = () => {
|
|
130
|
+
if (title !== null)
|
|
131
|
+
out.set(title, buf.join("\n").trim());
|
|
132
|
+
};
|
|
133
|
+
for (const line of block.split("\n")) {
|
|
134
|
+
const m = /^####\s+Scenario:\s*(.+?)\s*$/.exec(line);
|
|
135
|
+
if (m) {
|
|
136
|
+
flush();
|
|
137
|
+
title = m[1];
|
|
138
|
+
buf = [];
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (title !== null)
|
|
142
|
+
buf.push(line);
|
|
143
|
+
}
|
|
144
|
+
flush();
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
147
|
+
/** The section a requirement sits under in a delta: ADDED, MODIFIED, REMOVED or RENAMED. */
|
|
148
|
+
export function deltaOperation(delta, name) {
|
|
149
|
+
let op = null;
|
|
150
|
+
for (const line of delta.split("\n")) {
|
|
151
|
+
const s = /^##\s+(ADDED|MODIFIED|REMOVED|RENAMED)\s+Requirements\b/.exec(line);
|
|
152
|
+
if (s)
|
|
153
|
+
op = s[1];
|
|
154
|
+
else if (/^##\s/.test(line))
|
|
155
|
+
op = null;
|
|
156
|
+
if (new RegExp(`^###\\s+Requirement:\\s*${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\s*$`).test(line))
|
|
157
|
+
return op;
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
/** changed or carried, for one scenario of a requirement in a delta, against the living spec (null when the delta has no such scenario). */
|
|
162
|
+
export function scenarioKind(delta, living, requirement, scenario) {
|
|
163
|
+
const op = deltaOperation(delta, requirement);
|
|
164
|
+
const block = requirementBlock(delta, requirement);
|
|
165
|
+
if (!op || !block)
|
|
166
|
+
return null;
|
|
167
|
+
const mine = scenarios(block).get(scenario);
|
|
168
|
+
if (mine === undefined)
|
|
169
|
+
return null;
|
|
170
|
+
if (op !== "MODIFIED")
|
|
171
|
+
return "changed";
|
|
172
|
+
const theirs = living === null ? null : requirementBlock(living, requirement);
|
|
173
|
+
const before = theirs === null ? undefined : scenarios(theirs).get(scenario);
|
|
174
|
+
return before !== undefined && before === mine ? "carried" : "changed";
|
|
175
|
+
}
|
|
176
|
+
/** verdict.md's own verdict, or null when it states none in a form this reads. */
|
|
177
|
+
export function verdictLine(text) {
|
|
178
|
+
const m = /^\s*(?:#+\s*)?Verdict:\s*\**\s*(PASS|FAIL)\b/im.exec(text) ?? /^\s*\*\*(PASS|FAIL)\*\*/m.exec(text);
|
|
179
|
+
return m?.[1] ?? null;
|
|
180
|
+
}
|
|
181
|
+
/** Two pins name one commit when one abbreviates the other. */
|
|
182
|
+
export function sameCommit(a, b) {
|
|
183
|
+
const [x, y] = [a.toLowerCase(), b.toLowerCase()];
|
|
184
|
+
return x.length >= 7 && y.length >= 7 && (x.startsWith(y) || y.startsWith(x));
|
|
185
|
+
}
|
|
186
|
+
function isoDate(v) {
|
|
187
|
+
if (v instanceof Date && !Number.isNaN(v.getTime()))
|
|
188
|
+
return v.toISOString().slice(0, 10);
|
|
189
|
+
if (typeof v === "string" && /^\d{4}-\d{2}-\d{2}$/.test(v))
|
|
190
|
+
return v;
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Problems with one agreement condition (M-ADR 0222 §4.6 as amended); `today` is YYYY-MM-DD. A withdrawn or
|
|
195
|
+
* superseded change has closed its obligations: its conditions are not overdue.
|
|
196
|
+
*/
|
|
197
|
+
export function conditionProblems(c, today, recordStatus = "agreed") {
|
|
198
|
+
const out = [];
|
|
199
|
+
for (const k of ["assumption", "owner", "how", "release_limit"]) {
|
|
200
|
+
if (typeof c[k] !== "string" || c[k].trim() === "")
|
|
201
|
+
out.push(`no ${k}`);
|
|
202
|
+
}
|
|
203
|
+
const by = isoDate(c.validate_by);
|
|
204
|
+
if (by === null)
|
|
205
|
+
out.push("validate_by is not a YYYY-MM-DD date");
|
|
206
|
+
const status = typeof c.status === "string" ? c.status : "";
|
|
207
|
+
if (!["open", "validated", "failed"].includes(status))
|
|
208
|
+
out.push(`status ${JSON.stringify(c.status)} is not open | validated | failed`);
|
|
209
|
+
if ((status === "validated" || status === "failed") && (typeof c.evidence !== "string" || c.evidence.trim() === ""))
|
|
210
|
+
out.push(`${status} without evidence`);
|
|
211
|
+
if (status === "open" && by !== null && by < today && recordStatus !== "withdrawn" && recordStatus !== "superseded")
|
|
212
|
+
out.push(`OVERDUE: open past its validate_by ${by}; validate it, extend it by a ruling, or withdraw the change`);
|
|
213
|
+
return out;
|
|
214
|
+
}
|
|
215
|
+
export { isoDate };
|
|
216
|
+
//# sourceMappingURL=agreement-evidence.js.map
|