create-cmp-cli 0.19.0 → 0.21.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/package.json +1 -1
- package/packages/harness/src/approve.mjs +23 -2
- package/packages/harness/src/lib/affected-tests.mjs +9 -1
- package/packages/harness/src/lib/approvals.mjs +42 -4
- package/packages/harness/src/lib/evidence-badge.mjs +11 -0
- package/packages/harness/src/lib/evidence-level.mjs +33 -2
- package/packages/harness/src/lib/inputs-hash.mjs +97 -3
- package/packages/harness/src/lib/lane-runner.mjs +7 -0
- package/packages/harness/src/lib/receipt-validate.mjs +52 -0
- package/packages/harness/src/lib/spec-coverage.mjs +76 -1
- package/packages/harness/src/lib/steps-cmp.mjs +37 -0
- package/packages/harness/src/lib/walk.mjs +1 -1
- package/packages/harness/src/receipt-check.mjs +24 -1
- package/packages/harness/src/verify.mjs +27 -7
- package/packages/receipts/src/index.mjs +1 -0
- package/packages/receipts/src/inputs-hash.mjs +97 -3
- package/packages/receipts/src/receipt-validate.mjs +52 -0
- package/template/CLAUDE.md +8 -0
- package/template/composeApp/src/desktopTest/kotlin/com/example/app/conformance/ArchitectureConformanceTest.kt +1 -1
- package/template/qa/approve.mjs +23 -2
- package/template/qa/evidence/schema.json +6 -1
- package/template/qa/lib/affected-tests.mjs +9 -1
- package/template/qa/lib/approvals.mjs +42 -4
- package/template/qa/lib/evidence-badge.mjs +11 -0
- package/template/qa/lib/evidence-level.mjs +33 -2
- package/template/qa/lib/inputs-hash.mjs +97 -3
- package/template/qa/lib/lane-runner.mjs +7 -0
- package/template/qa/lib/receipt-validate.mjs +52 -0
- package/template/qa/lib/spec-coverage.mjs +76 -1
- package/template/qa/lib/steps-cmp.mjs +37 -0
- package/template/qa/lib/walk.mjs +1 -1
- package/template/qa/receipt-check.mjs +24 -1
- package/template/qa/verify.mjs +27 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-cmp-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Create production mobile apps (Android + iOS, one Kotlin codebase) with AI — the delivery harness for Compose Multiplatform, the current generation of cross-platform (Google-backed KMP, iOS stable since May 2025). A deterministic, non-interactive generator that scaffolds a green-building app in minutes, then holds AI-driven changes to a machine-enforced verify lane with a committed evidence receipt. Every app carries a device-free UI preview loop (real screens rendered headlessly on save; changed-screen attribution and compile-error surfacing for coding agents, a live gallery for humans) plus agent-first docs (CLAUDE.md + AGENTS.md). Installs the `create-cmp` command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -134,7 +134,13 @@ function refuseIfUnresolvable() {
|
|
|
134
134
|
|
|
135
135
|
if (args.includes("--accept-defaults")) {
|
|
136
136
|
refuseIfUnresolvable();
|
|
137
|
-
const
|
|
137
|
+
const expressAsIdx = args.indexOf("--as");
|
|
138
|
+
const expressSigner = expressAsIdx >= 0 ? args[expressAsIdx + 1] : undefined;
|
|
139
|
+
if (!expressSigner || expressSigner.startsWith("--")) {
|
|
140
|
+
console.error('--accept-defaults needs a signer: node qa/approve.mjs --accept-defaults --as "Your Name <you@example.com>"');
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
const { approved, skipped } = approveAllDefaults(ROOT, expressSigner);
|
|
138
144
|
for (const id of approved) {
|
|
139
145
|
console.log(`✓ approved ${id} [defaults-accepted]`);
|
|
140
146
|
}
|
|
@@ -246,7 +252,22 @@ if (args.length === 0) {
|
|
|
246
252
|
refuseIfUnresolvable();
|
|
247
253
|
|
|
248
254
|
const artifactId = args[0];
|
|
249
|
-
|
|
255
|
+
// The signer is REQUIRED, not optional: see approveArtifact's refusal. Parsed
|
|
256
|
+
// here rather than defaulted from git config on purpose — `git config user.name`
|
|
257
|
+
// is whatever the machine says, and an agent running on a developer's laptop
|
|
258
|
+
// would sign with that developer's name. An approval must be typed by whoever
|
|
259
|
+
// is answerable for it.
|
|
260
|
+
const asIndex = args.indexOf("--as");
|
|
261
|
+
const approvedBy = asIndex >= 0 ? args[asIndex + 1] : undefined;
|
|
262
|
+
if (!approvedBy || approvedBy.startsWith("--")) {
|
|
263
|
+
console.error(
|
|
264
|
+
'approve needs a signer: node qa/approve.mjs <artifact> --as "Your Name <you@example.com>"\n' +
|
|
265
|
+
"An approval is a signature on a hash; a row that records no signer cannot tell a human's\n" +
|
|
266
|
+
"sign-off from an agent's.",
|
|
267
|
+
);
|
|
268
|
+
process.exit(1);
|
|
269
|
+
}
|
|
270
|
+
const result = approveArtifact(ROOT, artifactId, { via: "cli", approvedBy });
|
|
250
271
|
if (!result.ok) {
|
|
251
272
|
console.error(`error: ${result.reason}`);
|
|
252
273
|
process.exit(1);
|
|
@@ -35,7 +35,15 @@ import path from "node:path";
|
|
|
35
35
|
* principle as inputs-hash.mjs's EXCLUDED_PREFIXES: lane outputs are not
|
|
36
36
|
* verdict inputs).
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
// qa/flight-recorder.jsonl is a lane output in the strictest sense: the lane
|
|
39
|
+
// appends one line to it AFTER the receipt is written, on every run. It is
|
|
40
|
+
// committed (the journal is the cost record), so after the first run it sits
|
|
41
|
+
// in the changed set as a modified tracked file under qa/ — and qa/** is the
|
|
42
|
+
// "harness itself" escape hatch. Uncounted here, every --fast run after the
|
|
43
|
+
// first fell open to the full suite, visible only in one parenthetical.
|
|
44
|
+
// Found by payment-blueprint's spine adoption (2026-09-03), where the same
|
|
45
|
+
// line also landed in their locked region.
|
|
46
|
+
export const LANE_OUTPUT_PREFIXES = ["qa/evidence", "qa-artifacts", "qa/flight-recorder.jsonl"];
|
|
39
47
|
|
|
40
48
|
function isLaneOutput(p) {
|
|
41
49
|
return LANE_OUTPUT_PREFIXES.some((prefix) => p === prefix || p.startsWith(`${prefix}/`));
|
|
@@ -781,6 +781,7 @@ export function resolveArtifactStatus(root, artifact, storedRecord) {
|
|
|
781
781
|
hash: recomputed.hash,
|
|
782
782
|
storedHash: storedRecord.hash ?? null,
|
|
783
783
|
approvedAt: storedRecord.approvedAt ?? null,
|
|
784
|
+
approvedBy: storedRecord.approvedBy ?? null,
|
|
784
785
|
fileCount: recomputed.fileCount,
|
|
785
786
|
missing: recomputed.missing,
|
|
786
787
|
resolvable,
|
|
@@ -801,6 +802,7 @@ export function resolveArtifactStatus(root, artifact, storedRecord) {
|
|
|
801
802
|
hash: recomputed.hash,
|
|
802
803
|
storedHash: null,
|
|
803
804
|
approvedAt: null,
|
|
805
|
+
approvedBy: null,
|
|
804
806
|
fileCount: recomputed.fileCount,
|
|
805
807
|
missing: recomputed.missing,
|
|
806
808
|
resolvable,
|
|
@@ -834,6 +836,10 @@ export function resolveArtifactStatus(root, artifact, storedRecord) {
|
|
|
834
836
|
hash: recomputed.hash,
|
|
835
837
|
storedHash: storedRecord.hash,
|
|
836
838
|
approvedAt: storedRecord.approvedAt,
|
|
839
|
+
// WHO signed. Null on rows written before signers were recorded; the gate
|
|
840
|
+
// treats a signed-by-nobody approval as FAIL, because that row cannot tell
|
|
841
|
+
// a human's sign-off from an agent's.
|
|
842
|
+
approvedBy: storedRecord.approvedBy ?? null,
|
|
837
843
|
fileCount: recomputed.fileCount,
|
|
838
844
|
missing: recomputed.missing,
|
|
839
845
|
resolvable,
|
|
@@ -920,7 +926,23 @@ export function approveArtifact(root, artifactId, options = {}) {
|
|
|
920
926
|
const state = loadApprovals(root);
|
|
921
927
|
const others = state.artifacts.filter((a) => a.artifact !== artifactId);
|
|
922
928
|
const approvedAt = new Date().toISOString();
|
|
923
|
-
|
|
929
|
+
if (!options.approvedBy || !String(options.approvedBy).trim()) {
|
|
930
|
+
return {
|
|
931
|
+
ok: false,
|
|
932
|
+
reason:
|
|
933
|
+
`cannot approve "${artifactId}" — no signer was given. An approval is a person's ` +
|
|
934
|
+
"signature on a hash; a row that records no signer cannot distinguish a human's sign-off " +
|
|
935
|
+
"from an agent's, and an agent that invalidates an approval can clear it by re-approving. " +
|
|
936
|
+
"Pass the signer: `node qa/approve.mjs <artifact> --as \"Name <email>\"`.",
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
const record = {
|
|
940
|
+
artifact: artifactId,
|
|
941
|
+
status: "approved",
|
|
942
|
+
hash: resolved.hash,
|
|
943
|
+
approvedAt,
|
|
944
|
+
approvedBy: String(options.approvedBy).trim(),
|
|
945
|
+
};
|
|
924
946
|
if (options.mode) record.mode = options.mode;
|
|
925
947
|
if (options.via) record.via = options.via;
|
|
926
948
|
others.push(record);
|
|
@@ -929,10 +951,11 @@ export function approveArtifact(root, artifactId, options = {}) {
|
|
|
929
951
|
verb: "approve",
|
|
930
952
|
artifact: artifactId,
|
|
931
953
|
hash: resolved.hash,
|
|
954
|
+
approvedBy: String(options.approvedBy).trim(),
|
|
932
955
|
...(options.via ? { via: options.via } : {}),
|
|
933
956
|
...(options.mode ? { mode: options.mode } : {}),
|
|
934
957
|
});
|
|
935
|
-
return { ok: true, artifact: artifactId, hash: resolved.hash, approvedAt, ...(options.mode ? { mode: options.mode } : {}) };
|
|
958
|
+
return { ok: true, artifact: artifactId, hash: resolved.hash, approvedAt, approvedBy: record.approvedBy, ...(options.mode ? { mode: options.mode } : {}) };
|
|
936
959
|
}
|
|
937
960
|
|
|
938
961
|
/**
|
|
@@ -945,7 +968,7 @@ export function approveArtifact(root, artifactId, options = {}) {
|
|
|
945
968
|
* @param {string} root
|
|
946
969
|
* @returns {{ok: true, approved: string[], skipped: Array<{id: string, reason: string}>}}
|
|
947
970
|
*/
|
|
948
|
-
export function approveAllDefaults(root) {
|
|
971
|
+
export function approveAllDefaults(root, approvedBy) {
|
|
949
972
|
const registry = listGovernedArtifacts(root);
|
|
950
973
|
const state = loadApprovals(root);
|
|
951
974
|
const byId = new Map(state.artifacts.map((a) => [a.artifact, a]));
|
|
@@ -954,7 +977,7 @@ export function approveAllDefaults(root) {
|
|
|
954
977
|
for (const artifact of registry) {
|
|
955
978
|
const live = resolveArtifactStatus(root, artifact, byId.get(artifact.id));
|
|
956
979
|
if (live.status === "approved") continue; // already settled — never overwritten by the express lane
|
|
957
|
-
const result = approveArtifact(root, artifact.id, { mode: "defaults-accepted" });
|
|
980
|
+
const result = approveArtifact(root, artifact.id, { mode: "defaults-accepted", approvedBy });
|
|
958
981
|
if (result.ok) approved.push(artifact.id);
|
|
959
982
|
else skipped.push({ id: artifact.id, reason: result.reason });
|
|
960
983
|
}
|
|
@@ -1143,6 +1166,21 @@ export function evaluateApprovalsGate(root) {
|
|
|
1143
1166
|
const statuses = getApprovalStatuses(root);
|
|
1144
1167
|
const mismatched = statuses.filter((s) => s.status === "changed-since-approval");
|
|
1145
1168
|
const pending = statuses.filter((s) => s.status === "unreviewed" || s.status === "reopened");
|
|
1169
|
+
// An "approved" row with no signer attests nothing about WHO signed, which is
|
|
1170
|
+
// the one fact an approval exists to record. It cannot distinguish a human's
|
|
1171
|
+
// sign-off from an agent's, and an agent that invalidates an approval can
|
|
1172
|
+
// clear it by re-approving — the gate then guards only against accident, not
|
|
1173
|
+
// against the population it is pointed at. Rows written before signers were
|
|
1174
|
+
// recorded land here; the fix is one re-approval each, and the message says so.
|
|
1175
|
+
const unsigned = statuses.filter((s) => s.status === "approved" && !s.approvedBy);
|
|
1176
|
+
|
|
1177
|
+
if (unsigned.length > 0) {
|
|
1178
|
+
const lines = ["Approval recorded without a signer — re-approve to say who signed:"];
|
|
1179
|
+
for (const s of unsigned) {
|
|
1180
|
+
lines.push(` [${s.id}] ${s.label} — approved ${shortHash(s.storedHash)} by nobody. Re-approve: node qa/approve.mjs ${s.id} --as "Your Name <you@example.com>"`);
|
|
1181
|
+
}
|
|
1182
|
+
return { verdict: "FAIL", reason: lines.join("\n"), statuses };
|
|
1183
|
+
}
|
|
1146
1184
|
|
|
1147
1185
|
if (mismatched.length > 0) {
|
|
1148
1186
|
const lines = ["Approval invalidated — a governed artifact changed after sign-off:"];
|
|
@@ -146,6 +146,17 @@ export function updateReadmeBadge(root) {
|
|
|
146
146
|
if (receipt && receipt.mode === "fast") {
|
|
147
147
|
return { changed: false, reason: "fast run — the inner loop bears no evidence, so the badge is left as it stands" };
|
|
148
148
|
}
|
|
149
|
+
// The same rule for the two other receipts qa/receipt-check.mjs refuses as
|
|
150
|
+
// done-evidence: smoke (Rule 0 — proves the framework, never the change) and
|
|
151
|
+
// nightly (proves the harness and the tree's invariants). Both derive no
|
|
152
|
+
// rung, and a smoke run — scripts/framework-check.mjs runs one on every
|
|
153
|
+
// scaffold — was rewriting a true L1 badge to "rung unrecorded". Found on
|
|
154
|
+
// 2026-09-03 by deriving the affected filter on a fresh app: README.md was
|
|
155
|
+
// the dirty file. Receipts predating `stage` are read by profile.
|
|
156
|
+
const stage = receipt && (typeof receipt.stage === "string" ? receipt.stage : receipt.profile);
|
|
157
|
+
if (stage === "smoke" || stage === "nightly") {
|
|
158
|
+
return { changed: false, reason: `${stage} run — refused as done-evidence, so the badge is left as it stands` };
|
|
159
|
+
}
|
|
149
160
|
|
|
150
161
|
const body = `${renderEvidenceBadge(receipt)}\n`;
|
|
151
162
|
const next = readme.replace(
|
|
@@ -65,6 +65,27 @@ const RELEASE_EXECUTION = "releaseSmoke";
|
|
|
65
65
|
|
|
66
66
|
const RUNG_NAMES = { L0: "scaffold", L1: "desktop", L2: "device", L3: "release" };
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The Compose Multiplatform pack's ladder — the step names above, as one
|
|
70
|
+
* object a pack hands to the spine. THE LADDER IS THE PACK'S, NOT THE SPINE'S
|
|
71
|
+
* (2026-09-03): vendored into a Kotlin backend, these names graded its
|
|
72
|
+
* strongest run — detekt, Konsist, mutation, gitleaks — as L0 "scaffold" and
|
|
73
|
+
* made L1 unreachable by construction. A fixed-amount understatement is not
|
|
74
|
+
* conservative, it is wrong, and receipts are where labels get quoted. So a
|
|
75
|
+
* pack declares its ladder (`evidenceLadder` on createXSteps' return); a pack
|
|
76
|
+
* that declares none earns no rung at all, which is the honest grade for a
|
|
77
|
+
* ladder nobody has calibrated. Every field is a list of step names except
|
|
78
|
+
* `release`, one name. `names` maps rung → label.
|
|
79
|
+
*/
|
|
80
|
+
export const CMP_LADDER = Object.freeze({
|
|
81
|
+
scaffoldCore: Object.freeze(SCAFFOLD_CORE),
|
|
82
|
+
l0Required: Object.freeze(L0_REQUIRED),
|
|
83
|
+
l1Required: Object.freeze(L1_REQUIRED),
|
|
84
|
+
deviceExecution: Object.freeze(DEVICE_EXECUTION),
|
|
85
|
+
release: RELEASE_EXECUTION,
|
|
86
|
+
names: Object.freeze(RUNG_NAMES),
|
|
87
|
+
});
|
|
88
|
+
|
|
68
89
|
/**
|
|
69
90
|
* Derive the receipt's evidence rung from the lane's step results.
|
|
70
91
|
*
|
|
@@ -81,8 +102,18 @@ const RUNG_NAMES = { L0: "scaffold", L1: "desktop", L2: "device", L3: "release"
|
|
|
81
102
|
* was not earned. `satisfiedBy` lists the PASSed steps the rung counts as
|
|
82
103
|
* its evidence, in lane order.
|
|
83
104
|
*/
|
|
84
|
-
export function evidenceLevel(stepResults, profile, { mode } = {}) { // eslint-disable-line no-unused-vars
|
|
105
|
+
export function evidenceLevel(stepResults, profile, { mode, ladder } = {}) { // eslint-disable-line no-unused-vars
|
|
85
106
|
if (mode === "fast") return null; // the inner loop derives no rung — ever
|
|
107
|
+
// `ladder` absent → the Compose ladder (every caller before packs declared
|
|
108
|
+
// one). `ladder: null` → the pack declares none: no rung, by decision.
|
|
109
|
+
if (ladder === null) return null;
|
|
110
|
+
const L = ladder ?? CMP_LADDER;
|
|
111
|
+
const SCAFFOLD_CORE = L.scaffoldCore ?? [];
|
|
112
|
+
const L0_REQUIRED = L.l0Required ?? [];
|
|
113
|
+
const L1_REQUIRED = L.l1Required ?? [];
|
|
114
|
+
const DEVICE_EXECUTION = L.deviceExecution ?? [];
|
|
115
|
+
const RELEASE_EXECUTION = L.release ?? null;
|
|
116
|
+
const RUNG_NAMES = L.names ?? CMP_LADDER.names;
|
|
86
117
|
const steps = Array.isArray(stepResults) ? stepResults.filter((s) => s && typeof s.name === "string") : [];
|
|
87
118
|
// A failed lane has no rung — and a lane with a step that could not run
|
|
88
119
|
// (ERROR) has none either: a rung is evidence, and "could not check" is not.
|
|
@@ -108,7 +139,7 @@ export function evidenceLevel(stepResults, profile, { mode } = {}) { // eslint-d
|
|
|
108
139
|
|
|
109
140
|
// Only a PASSed releaseSmoke lifts to L3 — a SKIP (unsigned keystore,
|
|
110
141
|
// no device) never does.
|
|
111
|
-
if (passed.has(RELEASE_EXECUTION)) {
|
|
142
|
+
if (RELEASE_EXECUTION && passed.has(RELEASE_EXECUTION)) {
|
|
112
143
|
rung = "L3";
|
|
113
144
|
counted.add(RELEASE_EXECUTION);
|
|
114
145
|
}
|
|
@@ -17,8 +17,19 @@ import { createHash } from "node:crypto";
|
|
|
17
17
|
import fs from "node:fs";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
|
|
20
|
-
// Directories / files
|
|
20
|
+
// Directories / files included in the verified surface (relative to project ROOT).
|
|
21
21
|
// Principle: every tracked file whose content can change the lane's verdict.
|
|
22
|
+
//
|
|
23
|
+
// THIS IS A DEFAULT, NOT A LAW (evidence-economics S8, 2026-09-03). It is the
|
|
24
|
+
// surface of a Compose Multiplatform app, and it used to be hardcoded inside
|
|
25
|
+
// this module — which is the SPINE, shared by every adopter. A repo whose code
|
|
26
|
+
// lives in services/ or src/ that vendored this file had its verified surface
|
|
27
|
+
// silently shrink to whatever happened to match: no error, no failed step, a
|
|
28
|
+
// receipt that still validated and still looked identical, and a hash that had
|
|
29
|
+
// quietly stopped covering the application. A gate that attests less while
|
|
30
|
+
// looking the same is the worst failure this harness can have, so the surface
|
|
31
|
+
// is now resolved per project (see resolveVerifiedSurface) and an empty one is
|
|
32
|
+
// refused rather than hashed.
|
|
22
33
|
export const VERIFIED_SURFACE = [
|
|
23
34
|
"composeApp",
|
|
24
35
|
"specs",
|
|
@@ -147,9 +158,52 @@ function walkAllFiles(dir) {
|
|
|
147
158
|
return out;
|
|
148
159
|
}
|
|
149
160
|
|
|
161
|
+
/** Where a project may declare its own verified surface (see resolveVerifiedSurface). */
|
|
162
|
+
export const SURFACE_CONFIG_REL = "qa/verified-surface.json";
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The surface THIS project attests — its own declaration when it has one, the
|
|
166
|
+
* Compose Multiplatform default otherwise.
|
|
167
|
+
*
|
|
168
|
+
* Read from a file rather than passed as an argument on purpose: qa/verify.mjs
|
|
169
|
+
* (which writes inputs.hash) and qa/receipt-check.mjs (which recomputes it)
|
|
170
|
+
* must never disagree about what was hashed, and two call sites taking a
|
|
171
|
+
* parameter is two places to get it wrong. The file lives under qa/, so it is
|
|
172
|
+
* itself inside the surface — changing the definition invalidates receipts,
|
|
173
|
+
* which is correct: the tree's coverage changed.
|
|
174
|
+
*
|
|
175
|
+
* Shape: {"surface": ["services", "docs", "build-logic", ".github", "qa"]}.
|
|
176
|
+
* Malformed or empty content is REFUSED, never silently defaulted — a project
|
|
177
|
+
* that tried to declare a surface and failed must not fall back to a smaller
|
|
178
|
+
* one behind the operator's back.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} root project root
|
|
181
|
+
* @returns {string[]} surface entries, relative to root
|
|
182
|
+
*/
|
|
183
|
+
export function resolveVerifiedSurface(root) {
|
|
184
|
+
const p = path.join(root, SURFACE_CONFIG_REL);
|
|
185
|
+
let raw;
|
|
186
|
+
try {
|
|
187
|
+
raw = fs.readFileSync(p, "utf8");
|
|
188
|
+
} catch {
|
|
189
|
+
return VERIFIED_SURFACE; // no declaration — the CMP default, unchanged
|
|
190
|
+
}
|
|
191
|
+
let parsed;
|
|
192
|
+
try {
|
|
193
|
+
parsed = JSON.parse(raw);
|
|
194
|
+
} catch (err) {
|
|
195
|
+
throw new Error(`${SURFACE_CONFIG_REL} is not valid JSON (${err.message}) — refusing to hash a surface this project failed to declare.`);
|
|
196
|
+
}
|
|
197
|
+
const list = parsed && Array.isArray(parsed.surface) ? parsed.surface.filter((x) => typeof x === "string" && x.trim() !== "") : null;
|
|
198
|
+
if (!list || list.length === 0) {
|
|
199
|
+
throw new Error(`${SURFACE_CONFIG_REL} declares no surface — expected {"surface": ["dir", …]}. Refusing to hash nothing.`);
|
|
200
|
+
}
|
|
201
|
+
return list;
|
|
202
|
+
}
|
|
203
|
+
|
|
150
204
|
// Resolve the verified surface to a flat, sorted list of paths (relative to
|
|
151
205
|
// root, POSIX-style `/` separators) that currently exist on disk.
|
|
152
|
-
function resolveSurfaceFiles(root) {
|
|
206
|
+
function resolveSurfaceFiles(root, VERIFIED_SURFACE) {
|
|
153
207
|
const gitFiles = tryGitLsFiles(root);
|
|
154
208
|
|
|
155
209
|
if (gitFiles) {
|
|
@@ -178,6 +232,33 @@ function resolveSurfaceFiles(root) {
|
|
|
178
232
|
return collected.filter((relPath) => !isExcluded(relPath));
|
|
179
233
|
}
|
|
180
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Top-level entries (first path segment of every file git would commit) that
|
|
237
|
+
* NO surface entry covers — the files the receipt does not attest. An
|
|
238
|
+
* allowlist is silent about what it omits: a new top-level directory is simply
|
|
239
|
+
* unmatched, no error, unattested (payment-blueprint, 2026-09-03). This names
|
|
240
|
+
* the omission so the receipt can carry it and a reader can decide whether
|
|
241
|
+
* it belongs in qa/verified-surface.json. Sorted; [] when git is unavailable
|
|
242
|
+
* (the walk fallback has no notion of "what git sees") or everything is
|
|
243
|
+
* covered. Lane outputs (EXCLUDED_PREFIXES) are not "undeclared" — they are
|
|
244
|
+
* excluded by decision.
|
|
245
|
+
* @param {string} root
|
|
246
|
+
* @param {string[]} [surface] defaults to resolveVerifiedSurface(root)
|
|
247
|
+
* @returns {string[]}
|
|
248
|
+
*/
|
|
249
|
+
export function undeclaredTopLevel(root, surface = resolveVerifiedSurface(root)) {
|
|
250
|
+
const gitFiles = tryGitLsFiles(root);
|
|
251
|
+
if (!gitFiles) return [];
|
|
252
|
+
const covered = (relPath) => surface.some((entry) => relPath === entry || relPath.startsWith(`${entry}/`)) || isExcluded(relPath);
|
|
253
|
+
const out = new Set();
|
|
254
|
+
for (const raw of gitFiles) {
|
|
255
|
+
const relPath = raw.split(path.sep).join("/");
|
|
256
|
+
if (covered(relPath)) continue;
|
|
257
|
+
out.add(relPath.includes("/") ? relPath.slice(0, relPath.indexOf("/")) : relPath);
|
|
258
|
+
}
|
|
259
|
+
return [...out].sort();
|
|
260
|
+
}
|
|
261
|
+
|
|
181
262
|
/**
|
|
182
263
|
* Compute the sha256 hash of the verified surface for the project rooted at `root`.
|
|
183
264
|
* Deterministic: same tree (same file paths + same file bytes) → same hash.
|
|
@@ -189,7 +270,20 @@ export function computeInputsHash(root) {
|
|
|
189
270
|
// on iteration order, and ICU collation varies with the machine's locale
|
|
190
271
|
// (e.g. a da_DK machine orders "aa" after "z"; en orders case-insensitively
|
|
191
272
|
// where code units do not) — the same tree must hash identically everywhere.
|
|
192
|
-
const
|
|
273
|
+
const surface = resolveVerifiedSurface(root);
|
|
274
|
+
const files = [...new Set(resolveSurfaceFiles(root, surface))].sort();
|
|
275
|
+
|
|
276
|
+
// A surface that matches NOTHING is a misconfiguration, not a valid hash.
|
|
277
|
+
// Hashing zero files yields a stable, confident-looking digest that attests
|
|
278
|
+
// the empty set — the silent shrink this whole change exists to prevent, in
|
|
279
|
+
// its most extreme form. Refuse, and name what was looked for.
|
|
280
|
+
if (files.length === 0) {
|
|
281
|
+
throw new Error(
|
|
282
|
+
`the verified surface matched no files under ${root} — nothing would be attested. ` +
|
|
283
|
+
`Surface: ${surface.join(", ")}. ` +
|
|
284
|
+
`A project whose code lives elsewhere declares its own in ${SURFACE_CONFIG_REL}: {"surface": ["services", "qa", …]}.`,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
193
287
|
|
|
194
288
|
const overall = createHash("sha256");
|
|
195
289
|
for (const relPath of files) {
|
|
@@ -145,6 +145,13 @@ export function runLane(ctx) {
|
|
|
145
145
|
} catch (err) {
|
|
146
146
|
result = stepErrorResult(name, err, Date.now() - stepStarted);
|
|
147
147
|
}
|
|
148
|
+
// Layer tag: a pack may mark a step function with the layer of the
|
|
149
|
+
// stack it proves (`fn.layer = "backend"`). The runner stamps it onto
|
|
150
|
+
// the row so the receipt carries it and the console can group by it —
|
|
151
|
+
// a step that set its own `layer` in the result keeps its word.
|
|
152
|
+
if (result && typeof result === "object" && typeof step.layer === "string" && step.layer && typeof result.layer !== "string") {
|
|
153
|
+
result.layer = step.layer;
|
|
154
|
+
}
|
|
148
155
|
results.push(result);
|
|
149
156
|
if (print) {
|
|
150
157
|
print(
|
|
@@ -45,6 +45,51 @@ export function readReceipt(root, relPath = RECEIPT_REL_PATH) {
|
|
|
45
45
|
* FAIL verdict), so callers don't pay for a hash they don't need.
|
|
46
46
|
* @returns {{valid: boolean, reason: string, profile: (string|undefined), recomputed?: {hash: string, fileCount: number}}}
|
|
47
47
|
*/
|
|
48
|
+
/**
|
|
49
|
+
* Does this receipt's own row-level evidence support its PASS?
|
|
50
|
+
*
|
|
51
|
+
* The receipt is necessarily excluded from the inputs hash it carries — a file
|
|
52
|
+
* cannot hash itself — so steps[] is the only thing between this gate and a text
|
|
53
|
+
* editor, and the top-level verdict is the most editable field on it.
|
|
54
|
+
*
|
|
55
|
+
* Two failures this catches, both observed downstream (payment-blueprint F2/F3):
|
|
56
|
+
* a receipt whose verdict was hand-edited from FAIL to PASS while its rows still
|
|
57
|
+
* said otherwise, and a lane made green by DELETING harness.lock.json, which
|
|
58
|
+
* downgraded harnessIntegrity from FAIL to SKIP and took the lane's verdict with
|
|
59
|
+
* it — a lane vouching for a tree with nothing vouching for the lane.
|
|
60
|
+
*
|
|
61
|
+
* @param {{verdict?: string, steps?: Array<{name?: string, verdict?: string}>}} receipt
|
|
62
|
+
* @returns {{ok: boolean, detail: string}}
|
|
63
|
+
*/
|
|
64
|
+
export function checkLaneVouching(receipt) {
|
|
65
|
+
const steps = Array.isArray(receipt?.steps) ? receipt.steps : null;
|
|
66
|
+
if (!steps || steps.length === 0) {
|
|
67
|
+
return { ok: false, detail: "receipt lists no verify-lane steps — a PASS over nothing attests nothing" };
|
|
68
|
+
}
|
|
69
|
+
const failed = steps.filter((s) => s && (s.verdict === "FAIL" || s.verdict === "ERROR"));
|
|
70
|
+
if (failed.length > 0) {
|
|
71
|
+
const names = failed.map((s) => `${s.name ?? "?"} (${s.verdict})`).join(", ");
|
|
72
|
+
return {
|
|
73
|
+
ok: false,
|
|
74
|
+
detail: `the receipt's verdict is PASS but ${failed.length} step(s) did not pass: ${names} — the row is the more specific truth`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const integrity = steps.find((s) => s && s.name === "harnessIntegrity");
|
|
78
|
+
if (!integrity) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
detail: "receipt has no harnessIntegrity row — nothing vouches that the lane's own code is the code that ran",
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (integrity.verdict !== "PASS") {
|
|
85
|
+
return {
|
|
86
|
+
ok: false,
|
|
87
|
+
detail: `harnessIntegrity is ${integrity.verdict}, not PASS — the lane did not vouch for itself, so its PASS over the tree cannot be trusted`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return { ok: true, detail: "lane vouched for itself (harnessIntegrity PASS, no failing rows)" };
|
|
91
|
+
}
|
|
92
|
+
|
|
48
93
|
export function evaluateReceipt(receipt, recompute) {
|
|
49
94
|
const profile = receipt.profile;
|
|
50
95
|
|
|
@@ -83,6 +128,13 @@ export function evaluateReceipt(receipt, recompute) {
|
|
|
83
128
|
};
|
|
84
129
|
}
|
|
85
130
|
|
|
131
|
+
// Did the lane vouch for ITSELF? See checkLaneVouching — the top-level verdict
|
|
132
|
+
// is the most editable field on a file the hash cannot cover.
|
|
133
|
+
const vouching = checkLaneVouching(receipt);
|
|
134
|
+
if (!vouching.ok) {
|
|
135
|
+
return { valid: false, reason: `${vouching.detail} (attesting profile: ${profile ?? "unknown"})`, profile, recomputed };
|
|
136
|
+
}
|
|
137
|
+
|
|
86
138
|
return { valid: true, reason: `receipt is valid — PASS, attesting profile: ${profile ?? "unknown"}`, profile, recomputed };
|
|
87
139
|
}
|
|
88
140
|
|
|
@@ -30,6 +30,78 @@ export const TIERS_SATISFYING = Object.freeze({
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
const TAG_LINE_RE = /^(?:\/\/|#)\s*SPEC:/;
|
|
33
|
+
|
|
34
|
+
// A citation is a claim that a TEST covers a clause, so it has to sit on one.
|
|
35
|
+
// Counting the tag wherever it appears makes a red specCoverage curable with a
|
|
36
|
+
// comment and zero assertions — the one escape this gate exists to close. It is
|
|
37
|
+
// not hypothetical: payment-blueprint hit a citation that had drifted onto a
|
|
38
|
+
// class declaration, where it counted for the whole file while testing nothing.
|
|
39
|
+
//
|
|
40
|
+
// So a tag counts only when a test declaration follows it within
|
|
41
|
+
// BINDING_WINDOW non-blank lines. The window is small enough that the tag must
|
|
42
|
+
// be attached to the test, and loose enough for the @DisplayName / annotation
|
|
43
|
+
// stack that idiomatically sits between them.
|
|
44
|
+
export const BINDING_WINDOW = 5;
|
|
45
|
+
|
|
46
|
+
// Kotlin @Test, a backticked test function, and the node:test / Maestro-adjacent
|
|
47
|
+
// `test(` / `it(` call forms. Deliberately syntactic: a citation's binding must
|
|
48
|
+
// be readable without compiling anything.
|
|
49
|
+
const TEST_DECL_RE = /@Test\b|\bfun\s+`[^`]+`\s*\(|\b(?:test|it)\s*\(/;
|
|
50
|
+
|
|
51
|
+
// A tag whose first meaningful line declares a TYPE is documenting that type,
|
|
52
|
+
// not claiming a test — and it must be refused structurally rather than by
|
|
53
|
+
// distance, because a short class body puts a real @Test inside the window and
|
|
54
|
+
// would otherwise launder the citation. This is exactly payment-blueprint's
|
|
55
|
+
// drift: `// SPEC: PP-07` sat on `class PaymentWorkerTest`, three properties
|
|
56
|
+
// above a genuine @Test, and vouched for the whole file.
|
|
57
|
+
const TYPE_DECL_RE = /^(?:@\w+\s+)*(?:public\s+|internal\s+|private\s+|abstract\s+|open\s+|sealed\s+|data\s+|enum\s+)*(?:class|object|interface)\b/;
|
|
58
|
+
|
|
59
|
+
// A YAML flow's own shape counts as its test: a Maestro file IS the test, so a
|
|
60
|
+
// tag in one binds to the flow rather than to a declaration inside it.
|
|
61
|
+
const FLOW_EXTS = [".yaml", ".yml"];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Does a test declaration follow `index` within BINDING_WINDOW non-blank lines,
|
|
65
|
+
* skipping block-comment bodies (a tag inside one is documentation, not a claim)?
|
|
66
|
+
* @param {string[]} lines
|
|
67
|
+
* @param {number} index line the tag sits on
|
|
68
|
+
* @returns {boolean}
|
|
69
|
+
*/
|
|
70
|
+
export function citationIsBound(lines, index) {
|
|
71
|
+
let seen = 0;
|
|
72
|
+
let inBlockComment = false;
|
|
73
|
+
for (let i = index + 1; i < lines.length && seen < BINDING_WINDOW; i += 1) {
|
|
74
|
+
const line = lines[i].trim();
|
|
75
|
+
if (line === "") continue;
|
|
76
|
+
if (inBlockComment) {
|
|
77
|
+
if (line.includes("*/")) inBlockComment = false;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (line.startsWith("/*")) {
|
|
81
|
+
if (!line.includes("*/")) inBlockComment = true;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (line.startsWith("//") || line.startsWith("*")) continue;
|
|
85
|
+
seen += 1;
|
|
86
|
+
// The FIRST meaningful line decides whether this tag is on a test at all.
|
|
87
|
+
if (seen === 1 && TYPE_DECL_RE.test(line)) return false;
|
|
88
|
+
if (TEST_DECL_RE.test(line)) return true;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Is this tag inside a block comment that began earlier in the file? */
|
|
94
|
+
function insideBlockComment(lines, index) {
|
|
95
|
+
let open = false;
|
|
96
|
+
for (let i = 0; i < index; i += 1) {
|
|
97
|
+
const line = lines[i];
|
|
98
|
+
for (let c = 0; c < line.length - 1; c += 1) {
|
|
99
|
+
if (!open && line[c] === "/" && line[c + 1] === "*") open = true;
|
|
100
|
+
else if (open && line[c] === "*" && line[c + 1] === "/") open = false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return open;
|
|
104
|
+
}
|
|
33
105
|
const TAG_IDS_RE = /SPEC:\s*([A-Z0-9,\s-]+)/;
|
|
34
106
|
const CLAUSE_ID_RE = /^[A-Z][A-Z0-9]*-\d{2,}$/;
|
|
35
107
|
|
|
@@ -105,11 +177,14 @@ export function scanCitations(root) {
|
|
|
105
177
|
const tier = tierForFile(rel);
|
|
106
178
|
fs.readFileSync(f, "utf8")
|
|
107
179
|
.split("\n")
|
|
108
|
-
.forEach((line, i) => {
|
|
180
|
+
.forEach((line, i, lines) => {
|
|
109
181
|
const trimmed = line.trim();
|
|
110
182
|
if (!TAG_LINE_RE.test(trimmed)) return;
|
|
111
183
|
const m = trimmed.match(TAG_IDS_RE);
|
|
112
184
|
if (!m) return;
|
|
185
|
+
// A flow file IS its test; anything else must have a test under the tag.
|
|
186
|
+
const isFlow = FLOW_EXTS.some((ext) => rel.endsWith(ext));
|
|
187
|
+
if (!isFlow && (insideBlockComment(lines, i) || !citationIsBound(lines, i))) return;
|
|
113
188
|
const ids = m[1]
|
|
114
189
|
.split(/[,\s]+/)
|
|
115
190
|
.map((s) => s.trim())
|
|
@@ -32,6 +32,8 @@ import { DETERMINISM_TIMEZONES, compareOutcomes, parseJUnitOutcomes } from "./de
|
|
|
32
32
|
import { evaluateAuditCadence } from "./audit-cadence.mjs";
|
|
33
33
|
import { androidChecksOutcome } from "./step-outcomes.mjs";
|
|
34
34
|
import { checkHarnessIntegrity, describeIntegrity, LOCK_PATH } from "./harness-lock.mjs";
|
|
35
|
+
import { stepDisplayName } from "./lane-runner.mjs";
|
|
36
|
+
import { CMP_LADDER } from "./evidence-level.mjs";
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* @param {object} ctx
|
|
@@ -1177,6 +1179,15 @@ const stepsForProfile = {
|
|
|
1177
1179
|
// scaffold: what `create-cmp --verify` proves at stamp time — specCoverage,
|
|
1178
1180
|
// the full JVM tier (unit + conformance + golden + UI tests) plus the Android build.
|
|
1179
1181
|
scaffold: [stepHarnessIntegrity, stepSpecCoverageMemo, stepApprovalsMemo, stepComponentStoriesMemo, stepReachabilityMemo, stepArchDocMemo, stepSchemaHistory, stepBuild, stepUnitTests],
|
|
1182
|
+
// smoke (docs/GATE-RULES.md Rule 0, docs/PRINCIPLES.md #2): the smallest
|
|
1183
|
+
// end-to-end lane — every pure-Node step through the REAL runner, marker,
|
|
1184
|
+
// receipt and journal, and NO Gradle, no device, no network. Its job is to
|
|
1185
|
+
// prove the framework RETURNS, fast, in both directions, before any real
|
|
1186
|
+
// work is pointed at it. scripts/framework-check.mjs drives it: PASS on a
|
|
1187
|
+
// fresh scaffold, then FAIL BY NAME on one planted spec edit, each bounded
|
|
1188
|
+
// in seconds. Its receipt is refused as done-evidence (qa/receipt-check.mjs)
|
|
1189
|
+
// exactly like --fast: it proves the instrument, never the change.
|
|
1190
|
+
smoke: [stepHarnessIntegrity, stepSpecCoverageMemo, stepApprovalsMemo, stepComponentStoriesMemo, stepReachabilityMemo, stepArchDocMemo, stepSchemaHistory],
|
|
1180
1191
|
local: [
|
|
1181
1192
|
// First, always: every verdict below is only worth what the lane issuing
|
|
1182
1193
|
// it is worth.
|
|
@@ -1244,6 +1255,28 @@ stepsForProfile.release = [...stepsForProfile.ci, stepAuditCadence, stepReleaseS
|
|
|
1244
1255
|
// what differs is what is forced, and what the receipt is allowed to mean.
|
|
1245
1256
|
stepsForProfile.nightly = [...stepsForProfile.ci];
|
|
1246
1257
|
|
|
1258
|
+
// Which layer of the stack each step proves — stamped onto the receipt row by
|
|
1259
|
+
// the runner (lane-runner.mjs) so the Evidence pane can group by it and a
|
|
1260
|
+
// multi-pack lane (a Compose app over a Kotlin backend) reads as one lane
|
|
1261
|
+
// with per-layer tallies. Three layers for this pack: `spine` — the harness
|
|
1262
|
+
// proving itself and the governed record (integrity, spec coverage,
|
|
1263
|
+
// approvals, the architecture doc, the schema history, the audit cadence);
|
|
1264
|
+
// `compose` — the JVM tier of the app (build, tests, conformance, goldens,
|
|
1265
|
+
// a11y, release compile); `device` — anything that needs an emulator or a
|
|
1266
|
+
// physical device. Layer names are free-form strings on the wire; these are
|
|
1267
|
+
// this pack's. Derived by NAME after the lists are built so a step listed in
|
|
1268
|
+
// two profiles is tagged once, and a step nobody listed is never tagged.
|
|
1269
|
+
const SPINE_STEP_NAMES = new Set(["harnessIntegrity", "specCoverage", "approvals", "componentStories", "reachability", "archDoc", "schemaHistory", "auditCadence", "determinism"]);
|
|
1270
|
+
function layerForStep(name) {
|
|
1271
|
+
if (DEVICE_STEPS.includes(name)) return "device";
|
|
1272
|
+
if (SPINE_STEP_NAMES.has(name)) return "spine";
|
|
1273
|
+
return "compose";
|
|
1274
|
+
}
|
|
1275
|
+
for (const fn of new Set(Object.values(stepsForProfile).flat())) {
|
|
1276
|
+
const name = stepDisplayName(fn);
|
|
1277
|
+
if (name) fn.layer = layerForStep(name);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1247
1280
|
const FAST_EXCLUDED_NAMES = [...DEVICE_STEPS, "releaseBuild"];
|
|
1248
1281
|
const STEP_FN_BY_NAME = {
|
|
1249
1282
|
e2eSmoke: stepE2eSmoke,
|
|
@@ -1266,6 +1299,10 @@ for (const name of FAST_EXCLUDED_NAMES) {
|
|
|
1266
1299
|
FAST_EXCLUDED_NAMES,
|
|
1267
1300
|
STEP_FN_BY_NAME,
|
|
1268
1301
|
stepDeterminism,
|
|
1302
|
+
// The ladder this pack's steps can earn (evidence-level.mjs). A pack that
|
|
1303
|
+
// returns none earns no rung — the spine never grades a pack by another
|
|
1304
|
+
// pack's step names.
|
|
1305
|
+
evidenceLadder: CMP_LADDER,
|
|
1269
1306
|
// The device lease is held to the very end of the run (see the scope
|
|
1270
1307
|
// decision above); the spine releases it in the runner's finally.
|
|
1271
1308
|
releaseLease: () => {
|
|
@@ -512,7 +512,7 @@ export function renderInject(data) {
|
|
|
512
512
|
for (const a of arrivals)
|
|
513
513
|
parts.push(`▲ ARRIVED, UNPLANNED — ${a.label} (${a.status}): ${a.reason ?? "no recorded reason"}. Offer: handle now, or after the current walk lands (recommended: after).`);
|
|
514
514
|
parts.push(
|
|
515
|
-
"Protocol: open every reply with the chat header line above, verbatim. Speak stages as Decide·Design·Contract·Build·Prove·Sign-off — with their plain-words gloss on first mention — and clauses as promises. Declare the chain at kickoff and advance it as you go; if the studio line above says DOWN or not running, restore it (preview tool) or surface it before proceeding. Quiet between headers (one line per stage transition). At any human gate, render the full stop card: stage, what it is in plain words, then the easiest act first (the studio console when it is up; the CLI as fallback), then what comes after. Quote the lane's cost only from the measured figure in the card — never estimate it. Never open a second walk silently.",
|
|
515
|
+
"Protocol: open every reply with the chat header line above, verbatim. Speak stages as Decide·Design·Contract·Build·Prove·Sign-off — with their plain-words gloss on first mention — and clauses as promises. Declare the chain at kickoff and advance it as you go; if the studio line above says DOWN or not running, restore it (preview tool) or surface it before proceeding. Quiet between headers (one line per stage transition). At any human gate, render the full stop card: stage, what it is in plain words, then the easiest act first (the studio console when it is up; the CLI as fallback), then what comes after. Quote the lane's cost only from the measured figure in the card — never estimate it. Never open a second walk silently. Principles that bind THIS turn (docs/PRINCIPLES.md): derived, never claimed — name the command behind any claim; the layer you changed cannot certify itself — run its consumers, stamp a fresh app for a template or harness change; never wait on nothing — every wait is bounded, and if you are blocked, say on what and stop.",
|
|
516
516
|
);
|
|
517
517
|
return parts.join("\n\n");
|
|
518
518
|
}
|