create-cmp-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/package.json +6 -2
- package/packages/harness/package.json +38 -0
- package/packages/harness/src/approve.mjs +247 -0
- package/packages/harness/src/arch-doc.mjs +69 -0
- package/packages/harness/src/comment.mjs +76 -0
- package/packages/harness/src/lib/a11y.mjs +113 -0
- package/packages/harness/src/lib/affected-tests.mjs +147 -0
- package/packages/harness/src/lib/approvals.mjs +1403 -0
- package/packages/harness/src/lib/arch-doc.mjs +451 -0
- package/packages/harness/src/lib/audit-cadence.mjs +290 -0
- package/packages/harness/src/lib/comments.mjs +252 -0
- package/packages/harness/src/lib/component-stories.mjs +183 -0
- package/packages/harness/src/lib/determinism.mjs +179 -0
- package/packages/harness/src/lib/device-lease.mjs +249 -0
- package/packages/harness/src/lib/evidence-badge.mjs +158 -0
- package/packages/harness/src/lib/evidence-level.mjs +117 -0
- package/packages/harness/src/lib/feature-brief.mjs +324 -0
- package/packages/harness/src/lib/flight-recorder.mjs +332 -0
- package/packages/harness/src/lib/harness-lock.mjs +147 -0
- package/packages/harness/src/lib/harness-region.mjs +159 -0
- package/packages/harness/src/lib/inputs-hash.mjs +194 -0
- package/packages/harness/src/lib/reachability.mjs +211 -0
- package/packages/harness/src/lib/receipt-validate.mjs +234 -0
- package/packages/harness/src/lib/render.mjs +254 -0
- package/packages/harness/src/lib/spec-coverage.mjs +131 -0
- package/packages/harness/src/lib/step-cache.mjs +221 -0
- package/packages/harness/src/lib/token-drift.mjs +94 -0
- package/packages/harness/src/lib/tree.mjs +108 -0
- package/packages/harness/src/preview-gallery.mjs +122 -0
- package/packages/harness/src/receipt-check.mjs +96 -0
- package/packages/harness/src/record-audit.mjs +83 -0
- package/packages/harness/src/refusal-demo.mjs +498 -0
- package/packages/harness/src/retrospective.mjs +51 -0
- package/packages/harness/src/scaffold-feature.mjs +723 -0
- package/packages/harness/src/setup-hooks.mjs +33 -0
- package/packages/harness/src/verify.mjs +1723 -0
- package/packages/harness/src/walkthrough.mjs +499 -0
- package/packages/harness/src/watch.mjs +622 -0
- package/packages/receipts/package.json +36 -0
- package/packages/receipts/src/index.mjs +16 -0
- package/packages/receipts/src/inputs-hash.mjs +194 -0
- package/packages/receipts/src/receipt-validate.mjs +234 -0
- package/src/commands/upgrade.mjs +115 -1
- package/src/lib/harness-upgrade.mjs +193 -5
- package/src/scaffold.mjs +60 -1
- package/template/AGENTS.md +5 -0
- package/template/CLAUDE.md +30 -0
- package/template/gitignore +8 -0
- package/template/qa/lib/harness-lock.mjs +147 -0
- package/template/qa/lib/harness-region.mjs +159 -0
- package/template/qa/lib/inputs-hash.mjs +1 -1
- package/template/qa/lib/receipt-validate.mjs +1 -1
- package/template/qa/preview-gallery.mjs +17 -2
- package/template/qa/verify.mjs +110 -2
- package/template/.gradle/8.11.1/checksums/checksums.lock +0 -0
- package/template/.gradle/8.11.1/fileChanges/last-build.bin +0 -0
- package/template/.gradle/8.11.1/fileHashes/fileHashes.lock +0 -0
- package/template/.gradle/8.11.1/gc.properties +0 -0
- package/template/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/template/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/template/.gradle/vcs-1/gc.properties +0 -0
|
@@ -0,0 +1,1723 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The verify lane — this project's single verification gate.
|
|
3
|
+
//
|
|
4
|
+
// node qa/verify.mjs [--profile scaffold|local|ci|release] [--fast] [--json]
|
|
5
|
+
//
|
|
6
|
+
// Runs every verification step this project carries, aggregates a typed
|
|
7
|
+
// PASS/FAIL verdict, and writes the evidence receipt to qa/evidence/latest.json.
|
|
8
|
+
// `--fast` is the INNER LOOP: the resolved profile minus the device/release
|
|
9
|
+
// tier, with unchanged pure-Node steps reused from the step cache (CACHED)
|
|
10
|
+
// and unit tests scoped to the working-tree change — its receipt records
|
|
11
|
+
// mode "fast" and can never satisfy the done-gate.
|
|
12
|
+
// The receipt is COMMITTED with your change (see CLAUDE.md — a change is not
|
|
13
|
+
// done without it). Binary artifacts under qa-artifacts/ are never committed;
|
|
14
|
+
// the receipt references them by path + sha256.
|
|
15
|
+
//
|
|
16
|
+
// Verdicts per step: PASS | FAIL | SKIP. The lane verdict is PASS iff no step
|
|
17
|
+
// FAILed. SKIPs are recorded with reasons — green-with-gaps is visible, never
|
|
18
|
+
// silent. Exit code: 0 = PASS, 1 = FAIL.
|
|
19
|
+
//
|
|
20
|
+
// Profiles:
|
|
21
|
+
// scaffold — spec coverage + build + unit tests (what `create-cmp --verify` proves at stamp time)
|
|
22
|
+
// local — everything; device-dependent steps SKIP when no device is attached
|
|
23
|
+
// ci — everything; SKIPs are recorded so the pipeline stays honest
|
|
24
|
+
// release — everything ci proves PLUS the release-APK smoke (releaseSmoke): the
|
|
25
|
+
// ship-time profile, run before cutting a release, never per-change
|
|
26
|
+
|
|
27
|
+
import { execSync, spawnSync } from "node:child_process";
|
|
28
|
+
import { createHash } from "node:crypto";
|
|
29
|
+
import fs from "node:fs";
|
|
30
|
+
import path from "node:path";
|
|
31
|
+
import { fileURLToPath } from "node:url";
|
|
32
|
+
|
|
33
|
+
import { computeInputsHash } from "./lib/inputs-hash.mjs";
|
|
34
|
+
import { compareTokenDrift } from "./lib/token-drift.mjs";
|
|
35
|
+
import { evaluateApprovalsGate } from "./lib/approvals.mjs";
|
|
36
|
+
import { clauseTierCoverage, scanCitations, scanSpecClauses, walkFiles } from "./lib/spec-coverage.mjs";
|
|
37
|
+
import { evaluateComponentStoryParity } from "./lib/component-stories.mjs";
|
|
38
|
+
import { evaluateReachability } from "./lib/reachability.mjs";
|
|
39
|
+
import { evidenceLevel } from "./lib/evidence-level.mjs";
|
|
40
|
+
import { updateReadmeBadge, README_REL_PATH } from "./lib/evidence-badge.mjs";
|
|
41
|
+
import { memoizeStep } from "./lib/step-cache.mjs";
|
|
42
|
+
import { changedWorkingTreePaths, deriveAffectedFilter } from "./lib/affected-tests.mjs";
|
|
43
|
+
import { acquireDeviceLease, releaseDeviceLease, formatHolder } from "./lib/device-lease.mjs";
|
|
44
|
+
import { ARCH_DOC_REL_PATH, SECTION_IDS, regenerateArchDoc } from "./lib/arch-doc.mjs";
|
|
45
|
+
import { DETERMINISM_TIMEZONES, compareOutcomes, parseJUnitOutcomes } from "./lib/determinism.mjs";
|
|
46
|
+
import { evaluateAuditCadence } from "./lib/audit-cadence.mjs";
|
|
47
|
+
import { appendFlightRecord, buildFlightEntry } from "./lib/flight-recorder.mjs";
|
|
48
|
+
import { checkHarnessIntegrity, describeIntegrity, LOCK_PATH } from "./lib/harness-lock.mjs";
|
|
49
|
+
|
|
50
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
51
|
+
const EVIDENCE_DIR = path.join(ROOT, "qa", "evidence");
|
|
52
|
+
const ARTIFACTS_DIR = path.join(ROOT, "qa-artifacts");
|
|
53
|
+
|
|
54
|
+
// ── Argument parsing — strict, and first thing this file does ──────────────
|
|
55
|
+
// An unrecognized flag used to fall through silently and start the full
|
|
56
|
+
// multi-minute lane (`--help` ran the whole lane for ~2 minutes before being
|
|
57
|
+
// killed). Same refusal-over-fabrication stance as qa/approve.mjs, which
|
|
58
|
+
// refuses an unknown artifact by name rather than guessing: an unknown
|
|
59
|
+
// argument here is refused by name, not swallowed into "run everything".
|
|
60
|
+
const USAGE = `node qa/verify.mjs [--profile scaffold|local|ci|release] [--fast] [--json] [--help]
|
|
61
|
+
|
|
62
|
+
The verify lane — this project's single verification gate. Runs every
|
|
63
|
+
verification step this project carries, aggregates a typed PASS/FAIL
|
|
64
|
+
verdict, and writes the evidence receipt to qa/evidence/latest.json (commit
|
|
65
|
+
it with your change — see CLAUDE.md). Exit code: 0 = PASS, 1 = FAIL.
|
|
66
|
+
|
|
67
|
+
Flags:
|
|
68
|
+
--profile <scaffold|local|ci|release>
|
|
69
|
+
which step set to run (default: local)
|
|
70
|
+
--fast INNER LOOP ONLY — run the resolved profile
|
|
71
|
+
minus the device/release tier (releaseBuild,
|
|
72
|
+
tokenDrift, e2eSmoke, androidChecks,
|
|
73
|
+
releaseSmoke), unconditionally, device
|
|
74
|
+
attached or not. Also reuses the pure-Node
|
|
75
|
+
steps' last PASS when their inputs are
|
|
76
|
+
unchanged (verdict CACHED), lets Gradle's
|
|
77
|
+
up-to-date checks stand (no --rerun), and
|
|
78
|
+
scopes unit tests to the working-tree change
|
|
79
|
+
(broad-impact changes run everything). The
|
|
80
|
+
receipt records mode "fast", derives no
|
|
81
|
+
evidence rung, and can NEVER satisfy the
|
|
82
|
+
done-gate — run the full lane once before
|
|
83
|
+
you call it done
|
|
84
|
+
--determinism run the timezone determinism probe: the JVM
|
|
85
|
+
test tier (unit + golden + the other
|
|
86
|
+
desktop suites) executes TWICE, under
|
|
87
|
+
TZ=Etc/GMT+12 (UTC-12) and TZ=Etc/GMT-14
|
|
88
|
+
(UTC+14), and the probe FAILs naming every
|
|
89
|
+
test whose verdict or failure output
|
|
90
|
+
differs — a nondeterminism leak ARCH-13's
|
|
91
|
+
static net missed. Bare (no --profile) it
|
|
92
|
+
runs JUST the probe and writes no receipt;
|
|
93
|
+
with --profile ci (or release) it runs
|
|
94
|
+
inside the lane and lands on the receipt.
|
|
95
|
+
Never combinable with --fast
|
|
96
|
+
--no-journal skip the qa/flight-recorder.jsonl append.
|
|
97
|
+
qa/watch.mjs passes this on every
|
|
98
|
+
save-triggered run: journalling each save
|
|
99
|
+
would add hundreds of committed lines a day
|
|
100
|
+
and leave a permanently dirty tree inside
|
|
101
|
+
the loop the recorder exists to observe. The
|
|
102
|
+
gap is disclosed in the retrospective's own
|
|
103
|
+
output
|
|
104
|
+
--json print the receipt as JSON instead of the
|
|
105
|
+
human-readable step-by-step log
|
|
106
|
+
--help, -h print this usage and exit 0 without
|
|
107
|
+
running anything
|
|
108
|
+
|
|
109
|
+
Profiles:
|
|
110
|
+
scaffold spec coverage + build + unit tests (what \`create-cmp --verify\`
|
|
111
|
+
proves at stamp time)
|
|
112
|
+
local everything; device-dependent steps SKIP when no device is
|
|
113
|
+
attached
|
|
114
|
+
ci everything; SKIPs are recorded so the pipeline stays honest
|
|
115
|
+
release everything ci proves PLUS the release-APK smoke (releaseSmoke) —
|
|
116
|
+
the ship-time profile; run it before cutting a release, never
|
|
117
|
+
per-change
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
const rawArgs = process.argv.slice(2);
|
|
121
|
+
|
|
122
|
+
if (rawArgs.includes("--help") || rawArgs.includes("-h")) {
|
|
123
|
+
console.log(USAGE);
|
|
124
|
+
process.exit(0);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Every flag this file CONSUMES must be listed here, or the strict check below
|
|
128
|
+
// rejects it. `--no-journal` was consumed but unlisted in 0.13.0, which meant
|
|
129
|
+
// qa/watch.mjs — whose spawn passes exactly these flags — exited 2 on every
|
|
130
|
+
// save without ever running the lane. test/verify-flags.test.mjs now pins
|
|
131
|
+
// consumed ⊆ recognized and watch's spawn ⊆ recognized so the class cannot
|
|
132
|
+
// recur.
|
|
133
|
+
const RECOGNIZED_FLAGS = new Set(["--profile", "--json", "--fast", "--determinism", "--no-journal"]);
|
|
134
|
+
for (let i = 0; i < rawArgs.length; i += 1) {
|
|
135
|
+
const arg = rawArgs[i];
|
|
136
|
+
if (arg === "--profile") {
|
|
137
|
+
i += 1; // consume its value (missing/invalid value keeps the existing exit-2 behavior below)
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (RECOGNIZED_FLAGS.has(arg)) continue;
|
|
141
|
+
console.error(`unknown argument "${arg}" — run node qa/verify.mjs --help`);
|
|
142
|
+
process.exit(2);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const args = rawArgs;
|
|
146
|
+
const profile = args.includes("--profile") ? args[args.indexOf("--profile") + 1] : "local";
|
|
147
|
+
const asJson = args.includes("--json");
|
|
148
|
+
const fast = args.includes("--fast");
|
|
149
|
+
// --no-journal suppresses the flight-recorder append (qa/watch.mjs passes it).
|
|
150
|
+
// See the append site below for why the inner loop must not write here.
|
|
151
|
+
const noJournal = args.includes("--no-journal");
|
|
152
|
+
const mode = fast ? "fast" : "full";
|
|
153
|
+
|
|
154
|
+
// ── --determinism: the timezone double-run probe (roadmap §10 item 8) ───────
|
|
155
|
+
// Refusals up front, by name (same stance as unknown arguments above):
|
|
156
|
+
// - never with --fast: the probe deliberately runs the JVM test tier twice,
|
|
157
|
+
// and --fast is the inner loop that exists to not pay such costs — the
|
|
158
|
+
// combination is a contradiction, so it is refused rather than silently
|
|
159
|
+
// resolved either way.
|
|
160
|
+
// - only the ci profile (and release, which inherits ci) carries the probe's
|
|
161
|
+
// lane row; asking for it in local/scaffold is refused with the two ways
|
|
162
|
+
// that DO work, instead of silently running a step the requested profile
|
|
163
|
+
// does not own.
|
|
164
|
+
const determinism = args.includes("--determinism");
|
|
165
|
+
const profileExplicit = args.includes("--profile");
|
|
166
|
+
if (determinism && fast) {
|
|
167
|
+
console.error(
|
|
168
|
+
"--determinism cannot be combined with --fast: the probe runs the JVM test tier twice by design, and --fast is the inner loop. Run it alone (node qa/verify.mjs --determinism) or inside a full ci/release lane (--profile ci --determinism).",
|
|
169
|
+
);
|
|
170
|
+
process.exit(2);
|
|
171
|
+
}
|
|
172
|
+
if (determinism && profileExplicit && profile !== "ci" && profile !== "release") {
|
|
173
|
+
console.error(
|
|
174
|
+
`--determinism belongs to the ci profile (release inherits it), not "${profile}" — run --profile ci --determinism, or bare --determinism to run the probe alone.`,
|
|
175
|
+
);
|
|
176
|
+
process.exit(2);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const GRADLEW = process.platform === "win32" ? "gradlew.bat" : "./gradlew";
|
|
180
|
+
|
|
181
|
+
// ── `--rerun` is scoped to FULL mode ────────────────────────────────────────
|
|
182
|
+
// `--rerun` exists for evidence integrity (see stepUnitTests's comment): it
|
|
183
|
+
// stops Gradle's build cache replaying a PASS recorded against a different
|
|
184
|
+
// tree into a receipt that claims tests executed. That mechanism belongs to
|
|
185
|
+
// the runs that produce integrity-bearing artifacts — and a --fast run does
|
|
186
|
+
// not: its receipt already declares itself non-evidence (mode "fast", no
|
|
187
|
+
// evidence rung, refused by qa/receipt-check.mjs), so forcing execution there
|
|
188
|
+
// paid an integrity tax to protect an artifact with nothing to protect. Fast
|
|
189
|
+
// mode therefore omits the flag and lets Gradle's up-to-date/cache machinery
|
|
190
|
+
// do its job; full mode keeps it, byte-identical to before.
|
|
191
|
+
const RERUN = fast ? "" : " --rerun";
|
|
192
|
+
|
|
193
|
+
function sh(cmd, opts = {}) {
|
|
194
|
+
const started = Date.now();
|
|
195
|
+
// maxBuffer: first-run Gradle output easily exceeds spawnSync's 1MB default,
|
|
196
|
+
// which would surface as a bogus FAIL (status null / ENOBUFS).
|
|
197
|
+
const res = spawnSync(cmd, { shell: true, cwd: ROOT, encoding: "utf8", maxBuffer: 64 * 1024 * 1024, ...opts });
|
|
198
|
+
const ok = res.status === 0 && !res.error;
|
|
199
|
+
return { ok, status: res.status, error: res.error?.message, out: `${res.stdout ?? ""}${res.stderr ?? ""}`, durationMs: Date.now() - started };
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// ── Preview-daemon coexistence ──────────────────────────────────────────────
|
|
203
|
+
// The preview daemon (the eyes) and this lane both spawn Gradle against this
|
|
204
|
+
// project and share composeApp/build/kspCaches, whose KSP incremental storage
|
|
205
|
+
// is single-owner — two concurrent builds throw "Storage for [...] is already
|
|
206
|
+
// registered" and one side dies. Three defenses, all automatic:
|
|
207
|
+
// 1. COORDINATE (this lane -> the daemon): this lane stamps a marker file
|
|
208
|
+
// for its duration; the preview service defers renders while it exists
|
|
209
|
+
// (mtime-bounded, so a crashed lane never wedges the eyes for long).
|
|
210
|
+
// 2. COORDINATE (the daemon -> this lane), the symmetric half: the daemon
|
|
211
|
+
// stamps its OWN marker for the duration of a render's Gradle build;
|
|
212
|
+
// shGradle waits for it to clear (or go stale) before launching this
|
|
213
|
+
// lane's own Gradle command — same mtime-bounded shape, so a crashed
|
|
214
|
+
// daemon never wedges the lane for long either.
|
|
215
|
+
// 3. SELF-HEAL: a Gradle step that still hits the collision clears kspCaches
|
|
216
|
+
// and retries once — the manual recovery that always worked, automated.
|
|
217
|
+
const LANE_MARKER = path.join(ROOT, "composeApp", "build", ".cmp-lane-in-progress");
|
|
218
|
+
const KSP_COLLISION_RE = /Storage for \[[^\]]*\] is already registered/;
|
|
219
|
+
|
|
220
|
+
// Degraded-path activations observed during this run — self-heals and
|
|
221
|
+
// fallbacks that kept the lane moving without failing it. Collected for the
|
|
222
|
+
// flight recorder (qa/lib/flight-recorder.mjs): a degradation that fires
|
|
223
|
+
// once is a shrug, one that fires every run for a month is the tooling
|
|
224
|
+
// quietly rotting under a green lane — and only a journal can tell those
|
|
225
|
+
// two apart.
|
|
226
|
+
const DEGRADED_PATHS = [];
|
|
227
|
+
|
|
228
|
+
// The daemon's half of defense 2 above — pid + ISO timestamp, mirroring
|
|
229
|
+
// LANE_MARKER's own content shape (see where LANE_MARKER is stamped, below).
|
|
230
|
+
const RENDER_MARKER = path.join(ROOT, "composeApp", "build", ".cmp-render-in-progress");
|
|
231
|
+
const RENDER_MARKER_FRESH_MS = 5 * 60 * 1000; // older than this = a crashed daemon's stale marker, ignore it
|
|
232
|
+
const RENDER_WAIT_TIMEOUT_MS = 3 * 60 * 1000; // give up waiting after this long regardless
|
|
233
|
+
const RENDER_WAIT_POLL_MS = 2000;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Defer this lane's next Gradle command while the preview daemon's render
|
|
237
|
+
* marker is present AND fresh (mtime younger than RENDER_MARKER_FRESH_MS).
|
|
238
|
+
* Polls every RENDER_WAIT_POLL_MS; gives up and proceeds anyway after
|
|
239
|
+
* RENDER_WAIT_TIMEOUT_MS, or the moment the marker disappears or goes stale —
|
|
240
|
+
* whichever comes first. A missing/unreadable marker returns immediately:
|
|
241
|
+
* this is a coexistence courtesy, never a hard dependency on the daemon.
|
|
242
|
+
*/
|
|
243
|
+
function waitForRenderMarker() {
|
|
244
|
+
const deadline = Date.now() + RENDER_WAIT_TIMEOUT_MS;
|
|
245
|
+
for (;;) {
|
|
246
|
+
let stat;
|
|
247
|
+
try {
|
|
248
|
+
stat = fs.statSync(RENDER_MARKER);
|
|
249
|
+
} catch {
|
|
250
|
+
return; // no render in flight
|
|
251
|
+
}
|
|
252
|
+
if (Date.now() - stat.mtimeMs >= RENDER_MARKER_FRESH_MS) return; // gone stale
|
|
253
|
+
if (Date.now() >= deadline) return; // waited long enough — proceed regardless
|
|
254
|
+
sh(`sleep ${RENDER_WAIT_POLL_MS / 1000}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function shGradle(cmd, opts = {}) {
|
|
259
|
+
waitForRenderMarker();
|
|
260
|
+
const first = sh(cmd, opts);
|
|
261
|
+
if (first.ok || !KSP_COLLISION_RE.test(first.out)) return first;
|
|
262
|
+
console.error("· KSP cache collision (concurrent Gradle — the preview daemon?) — clearing kspCaches, retrying once");
|
|
263
|
+
fs.rmSync(path.join(ROOT, "composeApp", "build", "kspCaches"), { recursive: true, force: true });
|
|
264
|
+
const retry = sh(cmd, opts);
|
|
265
|
+
retry.durationMs += first.durationMs;
|
|
266
|
+
retry.selfHealed = "ksp-cache-collision";
|
|
267
|
+
DEGRADED_PATHS.push("ksp-cache-collision: cleared kspCaches and retried the Gradle step");
|
|
268
|
+
return retry;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function tryGit(cmd) {
|
|
272
|
+
try {
|
|
273
|
+
return execSync(`git ${cmd}`, { cwd: ROOT, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Line-oriented git output, WITHOUT [tryGit]'s trim. `git status --porcelain`
|
|
281
|
+
* has significant leading whitespace: an unstaged modification is `" M path"`,
|
|
282
|
+
* so trimming the whole blob eats the first line's leading space — and a fixed
|
|
283
|
+
* `slice(3)` then swallows that path's first character. The receipt would name
|
|
284
|
+
* a file that does not exist. Only trailing newlines are dropped here.
|
|
285
|
+
*/
|
|
286
|
+
function tryGitLines(cmd) {
|
|
287
|
+
try {
|
|
288
|
+
const out = execSync(`git ${cmd}`, { cwd: ROOT, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
289
|
+
return out.replace(/\n+$/, "").split("\n").filter(Boolean);
|
|
290
|
+
} catch {
|
|
291
|
+
return [];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Recursive: desktopTest writes TEST-*.xml flat, but connected (instrumented) results
|
|
296
|
+
// land one directory level down per device (build/outputs/androidTest-results/connected/
|
|
297
|
+
// debug/<device>/TEST-*.xml) — both shapes are summarized by the same walk.
|
|
298
|
+
function junitSummary(dir) {
|
|
299
|
+
if (!fs.existsSync(dir)) return null;
|
|
300
|
+
let tests = 0, failures = 0, errors = 0, skipped = 0;
|
|
301
|
+
const walk = (d) => {
|
|
302
|
+
for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
|
|
303
|
+
const p = path.join(d, entry.name);
|
|
304
|
+
if (entry.isDirectory()) {
|
|
305
|
+
walk(p);
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (!entry.name.startsWith("TEST-") || !entry.name.endsWith(".xml")) continue;
|
|
309
|
+
const xml = fs.readFileSync(p, "utf8");
|
|
310
|
+
const m = xml.match(/<testsuite[^>]*tests="(\d+)"[^>]*skipped="(\d+)"[^>]*failures="(\d+)"[^>]*errors="(\d+)"/);
|
|
311
|
+
if (m) {
|
|
312
|
+
tests += Number(m[1]);
|
|
313
|
+
skipped += Number(m[2]);
|
|
314
|
+
failures += Number(m[3]);
|
|
315
|
+
errors += Number(m[4]);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
walk(dir);
|
|
320
|
+
return { tests, failures, errors, skipped };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function deviceAttached() {
|
|
324
|
+
const res = sh("adb devices", { timeout: 10_000 });
|
|
325
|
+
if (!res.ok) return false;
|
|
326
|
+
return res.out.split("\n").slice(1).some((l) => /\tdevice$/.test(l.trim().replace(/\s+/g, "\t")));
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// ── The machine-global device lease (qa/lib/device-lease.mjs) ───────────────
|
|
330
|
+
// LANE_MARKER above is per-PROJECT; the device is machine-GLOBAL. A scratch app
|
|
331
|
+
// in /tmp and the real app each stamp their own marker and still share the one
|
|
332
|
+
// emulator — nothing stopped two lanes (or a lane and a live console session)
|
|
333
|
+
// driving it at once, which is the observed wedged-adbd / `device offline` /
|
|
334
|
+
// crossed-app-state failure class. Every device-touching step below takes the
|
|
335
|
+
// lease before touching the device.
|
|
336
|
+
//
|
|
337
|
+
// SCOPE DECISION — once per run, not per step: the lease is acquired lazily by
|
|
338
|
+
// the FIRST device step that actually reaches the device and held until the
|
|
339
|
+
// lane exits (released in the same `finally` as LANE_MARKER). A single run must
|
|
340
|
+
// not thrash acquire/release between adjacent device steps, and holding through
|
|
341
|
+
// the desktop steps interleaved among them (a11y sits between tokenDrift and
|
|
342
|
+
// e2eSmoke) costs nothing — nothing else should drive the device mid-lane
|
|
343
|
+
// anyway, which is the whole point.
|
|
344
|
+
//
|
|
345
|
+
// ON CONTENTION THE STEP RETURNS SKIP — NEVER FAIL: nothing is broken; another
|
|
346
|
+
// run legitimately holds the device. This composes with the evidence ladder
|
|
347
|
+
// (qa/lib/evidence-level.mjs): a SKIPped device step simply does not buy its
|
|
348
|
+
// rung, so contention visibly DEGRADES the evidence level (L2 falls back to L1)
|
|
349
|
+
// instead of corrupting the run with a false red — that degradation being
|
|
350
|
+
// honest and visible is exactly why SKIP is the right verdict.
|
|
351
|
+
let laneDeviceLease = null;
|
|
352
|
+
|
|
353
|
+
/** Serials of devices currently in `device` state (same parse as deviceAttached). */
|
|
354
|
+
function attachedDeviceSerials() {
|
|
355
|
+
const res = sh("adb devices", { timeout: 10_000 });
|
|
356
|
+
if (!res.ok) return [];
|
|
357
|
+
return res.out
|
|
358
|
+
.split("\n")
|
|
359
|
+
.slice(1)
|
|
360
|
+
.map((l) => l.trim())
|
|
361
|
+
.filter(Boolean)
|
|
362
|
+
.map((l) => l.split(/\s+/))
|
|
363
|
+
.filter(([, state]) => state === "device")
|
|
364
|
+
.map(([serial]) => serial);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Acquire (or confirm) the lane's device lease for a device step.
|
|
369
|
+
* Returns null when the lane holds the device; otherwise the SKIP result the
|
|
370
|
+
* step should return verbatim. The serial leased is the one the lane will
|
|
371
|
+
* actually drive: the single attached device, or ANDROID_SERIAL when several
|
|
372
|
+
* are attached (adb/Gradle/Maestro honor the same variable). Ambiguity is
|
|
373
|
+
* SKIPped by name — leasing a guess would protect the wrong device.
|
|
374
|
+
*/
|
|
375
|
+
function leaseDeviceForStep(stepName) {
|
|
376
|
+
if (laneDeviceLease) return null; // already held for this run
|
|
377
|
+
const serials = attachedDeviceSerials();
|
|
378
|
+
if (serials.length === 0) return null; // each step's own guard SKIPs "no device" with its precise reason
|
|
379
|
+
let serial = serials[0];
|
|
380
|
+
if (serials.length > 1) {
|
|
381
|
+
const chosen = process.env.ANDROID_SERIAL;
|
|
382
|
+
if (chosen && serials.includes(chosen)) {
|
|
383
|
+
serial = chosen;
|
|
384
|
+
} else {
|
|
385
|
+
return {
|
|
386
|
+
name: stepName,
|
|
387
|
+
verdict: "SKIP",
|
|
388
|
+
reason: `${serials.length} devices attached (${serials.join(", ")}) — the lane cannot tell which one it would drive, so it leases none rather than guessing. Set ANDROID_SERIAL to the device this lane should own, or detach the extras.`,
|
|
389
|
+
durationMs: 0,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
const res = acquireDeviceLease({ serial, holder: `verify lane ${stepName}`, root: ROOT });
|
|
394
|
+
if (!res.ok) {
|
|
395
|
+
return {
|
|
396
|
+
name: stepName,
|
|
397
|
+
verdict: "SKIP",
|
|
398
|
+
reason: `device ${serial} is held by ${formatHolder(res.heldBy)} — device evidence is batched, not concurrent; wait for it or run once when it finishes`,
|
|
399
|
+
durationMs: 0,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
if (res.reclaimed) {
|
|
403
|
+
console.error(`· reclaimed a dead device lease on ${serial} (was ${formatHolder(res.reclaimed)})`);
|
|
404
|
+
}
|
|
405
|
+
laneDeviceLease = res.handle;
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Settle adb before handing the device to whatever drives it next (Maestro, the
|
|
410
|
+
// instrumented runner). An install task returning 0 means the package manager accepted
|
|
411
|
+
// the APK — NOT that the device is ready to be driven: a reinstall over a running app
|
|
412
|
+
// briefly drops the emulator's adb transport. `adb devices` still says `device`, but a
|
|
413
|
+
// fresh adb client (Maestro's dadb, Gradle's ddmlib) gets `device offline` and dies
|
|
414
|
+
// before the first assertion (observed 4/4 when the live-inspector tier ran earlier in
|
|
415
|
+
// the lane — its port-forward traffic widens the window — and 0/4 when it was skipped).
|
|
416
|
+
// wait-for-device blocks only while the transport is actually down; the kill/start pair
|
|
417
|
+
// ahead of it clears a stale server-side transport entry that survives the device coming
|
|
418
|
+
// back. Neither weakens any assertion — every downstream check still passes on its own
|
|
419
|
+
// merits.
|
|
420
|
+
function settleAdb() {
|
|
421
|
+
sh("adb kill-server");
|
|
422
|
+
sh("adb start-server");
|
|
423
|
+
sh("adb wait-for-device");
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// ── Steps ──────────────────────────────────────────────────────────────────
|
|
427
|
+
// Each returns { name, verdict, reason?, durationMs, details? }. Failure
|
|
428
|
+
// reasons are worded for an AI collaborator to act on.
|
|
429
|
+
|
|
430
|
+
// Spec ↔ test drift gate — pure Node, no Gradle. The clause/citation scan
|
|
431
|
+
// itself lives in qa/lib/spec-coverage.mjs — the SAME scan feature-brief.mjs
|
|
432
|
+
// derives doneness from, so this gate and the Features view can never disagree
|
|
433
|
+
// about a clause. This step owns only the orphan decision + bookkeeping.
|
|
434
|
+
// The first question any verdict depends on: is the lane that is about to
|
|
435
|
+
// issue it the lane this app was given?
|
|
436
|
+
//
|
|
437
|
+
// Without this the receipt is unfalsifiable in one specific way — edit
|
|
438
|
+
// qa/verify.mjs to force every step PASS and the receipt still validates,
|
|
439
|
+
// because the edited file is simply part of the hashed input surface. Hashing
|
|
440
|
+
// the machine-owned region against qa/harness.lock.json closes that: the lane
|
|
441
|
+
// cannot vouch for itself while modified.
|
|
442
|
+
//
|
|
443
|
+
// DELIBERATELY NOT MEMOIZED. Every other pure-Node step can serve a cached
|
|
444
|
+
// PASS when its inputs are unchanged; a cached PASS on an integrity check is
|
|
445
|
+
// precisely the failure it exists to prevent, and 34 file reads are too cheap
|
|
446
|
+
// to be worth the risk.
|
|
447
|
+
//
|
|
448
|
+
// Three states, three verdicts:
|
|
449
|
+
// intact PASS
|
|
450
|
+
// modified FAIL — named files, with the command that restores them
|
|
451
|
+
// unlocked SKIP — an app stamped before locks existed. Nothing is known to
|
|
452
|
+
// be wrong, but nothing is proven either; recording the gap keeps
|
|
453
|
+
// the pipeline honest instead of quietly passing.
|
|
454
|
+
function stepHarnessIntegrity() {
|
|
455
|
+
const started = Date.now();
|
|
456
|
+
const r = checkHarnessIntegrity(ROOT);
|
|
457
|
+
const base = { name: "harnessIntegrity", durationMs: Date.now() - started, harness: r };
|
|
458
|
+
|
|
459
|
+
if (r.status === "intact") {
|
|
460
|
+
return { ...base, verdict: "PASS", note: describeIntegrity(r) };
|
|
461
|
+
}
|
|
462
|
+
if (r.status === "unlocked") {
|
|
463
|
+
return {
|
|
464
|
+
...base,
|
|
465
|
+
verdict: "SKIP",
|
|
466
|
+
reason: `no ${LOCK_PATH} — this app was stamped before harness locks existed. ` +
|
|
467
|
+
"`npx create-cmp-cli upgrade --harness` records one.",
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const named = [
|
|
472
|
+
...r.modified.map((f) => `modified ${f}`),
|
|
473
|
+
...r.missing.map((f) => `missing ${f}`),
|
|
474
|
+
...r.extra.map((f) => `unrecorded ${f}`),
|
|
475
|
+
];
|
|
476
|
+
return {
|
|
477
|
+
...base,
|
|
478
|
+
verdict: "FAIL",
|
|
479
|
+
reason:
|
|
480
|
+
`the verify lane has been modified since it was installed — ${describeIntegrity(r)}. ` +
|
|
481
|
+
"Lane code is machine-owned: it is byte-identical in every create-cmp app and carries " +
|
|
482
|
+
"no app content, so a local edit is either an accident, a half-applied upgrade, or an " +
|
|
483
|
+
"attempt to make this receipt say something the lane would not. Restore it with " +
|
|
484
|
+
"`npx create-cmp-cli upgrade --harness`, which also reports any genuine local patch " +
|
|
485
|
+
"instead of discarding it.",
|
|
486
|
+
files: named,
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function stepSpecCoverage() {
|
|
491
|
+
const started = Date.now();
|
|
492
|
+
const specsDir = path.join(ROOT, "specs");
|
|
493
|
+
if (!fs.existsSync(specsDir)) {
|
|
494
|
+
return { name: "specCoverage", verdict: "SKIP", reason: "no specs/ directory in this project", durationMs: Date.now() - started };
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const clauses = scanSpecClauses(ROOT);
|
|
498
|
+
const tags = scanCitations(ROOT);
|
|
499
|
+
const searchDirs = [path.join(ROOT, "composeApp/src"), path.join(ROOT, "qa/e2e")];
|
|
500
|
+
const files = searchDirs.flatMap((d) => walkFiles(d, [".kt", ".kts", ".yaml", ".yml"]));
|
|
501
|
+
|
|
502
|
+
const citedIds = new Set(tags.map((t) => t.id));
|
|
503
|
+
const orphanClauses = [...clauses.entries()].filter(([, c]) => !c.withdrawn).filter(([id]) => !citedIds.has(id));
|
|
504
|
+
const orphanTags = tags.filter((t) => !clauses.has(t.id) || clauses.get(t.id).withdrawn);
|
|
505
|
+
|
|
506
|
+
if (orphanClauses.length === 0 && orphanTags.length === 0) {
|
|
507
|
+
// Tier visibility, not a gate (industry rule: instrument before you police). A clause
|
|
508
|
+
// cited only from desktop-tier tests can still hide a platform-behavior bug — both
|
|
509
|
+
// production apps shipped alarm/notification defects behind clauses that were
|
|
510
|
+
// "covered" by JVM tests androidMain never ran under. The line names them; the
|
|
511
|
+
// instrumented seam (androidChecks) is where such clauses earn a citation.
|
|
512
|
+
const tiers = clauseTierCoverage(clauses, tags);
|
|
513
|
+
return {
|
|
514
|
+
name: "specCoverage",
|
|
515
|
+
verdict: "PASS",
|
|
516
|
+
durationMs: Date.now() - started,
|
|
517
|
+
details: {
|
|
518
|
+
clauses: [...clauses.values()].filter((c) => !c.withdrawn).length,
|
|
519
|
+
withdrawn: [...clauses.values()].filter((c) => c.withdrawn).length,
|
|
520
|
+
tags: tags.length,
|
|
521
|
+
files: files.length,
|
|
522
|
+
tierNote: tiers.summaryLine,
|
|
523
|
+
},
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
const lines = ["Spec coverage broken — the spec and the tests have drifted apart:"];
|
|
528
|
+
for (const [id, c] of orphanClauses) {
|
|
529
|
+
lines.push(` [${id}] ${c.file} — no durable test cites this clause. Write the test (tag it '// SPEC: ${id}') or withdraw the clause (strike it through).`);
|
|
530
|
+
}
|
|
531
|
+
for (const t of orphanTags) {
|
|
532
|
+
const known = clauses.get(t.id);
|
|
533
|
+
if (known?.withdrawn) {
|
|
534
|
+
lines.push(` // SPEC: ${t.id} at ${t.file}:${t.line} — the test verifies withdrawn behavior (clause ${t.id} in ${known.file} is struck through). Remove the test or un-withdraw the clause.`);
|
|
535
|
+
} else {
|
|
536
|
+
lines.push(` // SPEC: ${t.id} at ${t.file}:${t.line} — no such clause in specs/. Add the clause (AI proposes, human confirms) or fix the id.`);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
name: "specCoverage",
|
|
542
|
+
verdict: "FAIL",
|
|
543
|
+
reason: lines.join("\n"),
|
|
544
|
+
durationMs: Date.now() - started,
|
|
545
|
+
details: {
|
|
546
|
+
clauses: [...clauses.values()].filter((c) => !c.withdrawn).length,
|
|
547
|
+
withdrawn: [...clauses.values()].filter((c) => c.withdrawn).length,
|
|
548
|
+
tags: tags.length,
|
|
549
|
+
files: files.length,
|
|
550
|
+
},
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
// Human-approval gate (VERIFICATION-LAYER-DESIGN.md §2) — pure Node, no Gradle,
|
|
555
|
+
// same grouping as specCoverage. The decision itself lives in
|
|
556
|
+
// qa/lib/approvals.mjs (evaluateApprovalsGate); this step only adds the
|
|
557
|
+
// name/duration bookkeeping every step in this file carries.
|
|
558
|
+
function stepApprovals() {
|
|
559
|
+
const started = Date.now();
|
|
560
|
+
const { verdict, reason, statuses } = evaluateApprovalsGate(ROOT);
|
|
561
|
+
return {
|
|
562
|
+
name: "approvals",
|
|
563
|
+
verdict,
|
|
564
|
+
reason,
|
|
565
|
+
durationMs: Date.now() - started,
|
|
566
|
+
details: { artifacts: statuses.map((s) => ({ id: s.id, status: s.status, hash: s.hash })) },
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// There is deliberately NO feature-doneness step here (CHANGE-FLOW-DESIGN.md
|
|
571
|
+
// §7): a feature's doneness is DERIVED from gates this lane already runs —
|
|
572
|
+
// specCoverage fails an uncited clause, the test steps fail a broken promise,
|
|
573
|
+
// and the receipt's inputs.hash attests the tree. A second mechanism would be
|
|
574
|
+
// a second truth.
|
|
575
|
+
|
|
576
|
+
// Component ↔ story parity gate (STUDIO-REDESIGN.md §3.3) — pure Node, no
|
|
577
|
+
// Gradle, same grouping as specCoverage/approvals. The decision itself lives
|
|
578
|
+
// in qa/lib/component-stories.mjs (evaluateComponentStoryParity); this step
|
|
579
|
+
// only adds the name/duration bookkeeping every step in this file carries.
|
|
580
|
+
function stepComponentStories() {
|
|
581
|
+
const started = Date.now();
|
|
582
|
+
const { verdict, reason, details } = evaluateComponentStoryParity(ROOT);
|
|
583
|
+
return { name: "componentStories", verdict, reason, durationMs: Date.now() - started, details };
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
// Navigation-reachability gate (task FI-7, docs/AUTONOMY-GAPS.md §3) — pure
|
|
587
|
+
// Node, no Gradle, same grouping as specCoverage/approvals/componentStories.
|
|
588
|
+
// The decision itself lives in qa/lib/reachability.mjs (evaluateReachability);
|
|
589
|
+
// this step only adds the name/duration bookkeeping every step in this file
|
|
590
|
+
// carries. Closes the exact hole a real feature slipped through: every other
|
|
591
|
+
// gate PASSed while its screen was wired into nothing.
|
|
592
|
+
function stepReachability() {
|
|
593
|
+
const started = Date.now();
|
|
594
|
+
const { verdict, reason, details } = evaluateReachability(ROOT);
|
|
595
|
+
return { name: "reachability", verdict, reason, durationMs: Date.now() - started, details };
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Architecture-doc freshness gate (Wave B, docs/proposals/architecture-document-
|
|
599
|
+
// standard.md §6) — pure Node, no Gradle, same grouping as specCoverage/
|
|
600
|
+
// approvals. The decision itself lives in qa/lib/arch-doc.mjs
|
|
601
|
+
// (regenerateArchDoc); this step only adds the name/duration bookkeeping every
|
|
602
|
+
// step in this file carries, plus wording the FAIL reason for an AI
|
|
603
|
+
// collaborator (name the stale/missing section, name the fix command).
|
|
604
|
+
function stepArchDoc() {
|
|
605
|
+
const started = Date.now();
|
|
606
|
+
const elapsed = () => Date.now() - started;
|
|
607
|
+
|
|
608
|
+
const result = regenerateArchDoc(ROOT);
|
|
609
|
+
if (!result.ok) {
|
|
610
|
+
return { name: "archDoc", verdict: "SKIP", reason: `${result.reason} — nothing to check`, durationMs: elapsed() };
|
|
611
|
+
}
|
|
612
|
+
if (result.unknownSections.length > 0) {
|
|
613
|
+
return {
|
|
614
|
+
name: "archDoc",
|
|
615
|
+
verdict: "FAIL",
|
|
616
|
+
reason: `${ARCH_DOC_REL_PATH} has cmp:generated marker(s) with no registered generator: ${result.unknownSections.join(", ")} — add a generator in qa/lib/arch-doc.mjs or remove the marker.`,
|
|
617
|
+
durationMs: elapsed(),
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const stale = result.changed || result.missingSections.length > 0;
|
|
622
|
+
if (!stale) {
|
|
623
|
+
return { name: "archDoc", verdict: "PASS", durationMs: elapsed(), details: { sectionsChecked: SECTION_IDS.length } };
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
const lines = [`${ARCH_DOC_REL_PATH} is stale — a generated section no longer matches the tree:`];
|
|
627
|
+
for (const id of result.changedSections) {
|
|
628
|
+
lines.push(` [${id}] regenerating would change this section.`);
|
|
629
|
+
}
|
|
630
|
+
for (const id of result.missingSections) {
|
|
631
|
+
lines.push(` [${id}] marker missing from the doc entirely — never generated.`);
|
|
632
|
+
}
|
|
633
|
+
lines.push("Run: node qa/arch-doc.mjs");
|
|
634
|
+
return {
|
|
635
|
+
name: "archDoc",
|
|
636
|
+
verdict: "FAIL",
|
|
637
|
+
reason: lines.join("\n"),
|
|
638
|
+
durationMs: elapsed(),
|
|
639
|
+
details: { changedSections: result.changedSections, missingSections: result.missingSections },
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
// Schema-history gate — pure Node + git, no Gradle, same grouping as the other
|
|
644
|
+
// evidence checks. Room's exportSchema writes one <version>.json per database per
|
|
645
|
+
// target under composeApp/schemas/. Every version EXCEPT the current highest is a
|
|
646
|
+
// frozen historical record of a database that shipped: migrations are written and
|
|
647
|
+
// validated against those exact bytes, so a regeneration that rewrites them
|
|
648
|
+
// silently corrupts the baseline every future migration is proven against. Only
|
|
649
|
+
// the highest version is the live, in-progress schema — free to change or appear
|
|
650
|
+
// (that IS the current change). This gate exists because schema regeneration
|
|
651
|
+
// looks like harmless build output right up until a shipped user's upgrade fails.
|
|
652
|
+
function stepSchemaHistory() {
|
|
653
|
+
const started = Date.now();
|
|
654
|
+
const elapsed = () => Date.now() - started;
|
|
655
|
+
const schemasRel = path.join("composeApp", "schemas");
|
|
656
|
+
const schemasRoot = path.join(ROOT, schemasRel);
|
|
657
|
+
|
|
658
|
+
if (!fs.existsSync(schemasRoot)) {
|
|
659
|
+
return { name: "schemaHistory", verdict: "SKIP", reason: "no exported Room schemas (composeApp/schemas/ absent) — nothing frozen to guard", durationMs: elapsed() };
|
|
660
|
+
}
|
|
661
|
+
const gitTop = tryGit("rev-parse --show-toplevel");
|
|
662
|
+
if (!gitTop || !tryGit("rev-parse HEAD")) {
|
|
663
|
+
return { name: "schemaHistory", verdict: "SKIP", reason: "no git history yet — schema versions have no committed baseline to be frozen against", durationMs: elapsed() };
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Every directory holding versioned schema JSONs, with its highest version on disk.
|
|
667
|
+
const versionFile = /^(\d+)\.json$/;
|
|
668
|
+
const maxVersionByDir = new Map(); // absolute dir path -> highest N among its N.json files
|
|
669
|
+
const walkSchemas = (dir) => {
|
|
670
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
671
|
+
const p = path.join(dir, entry.name);
|
|
672
|
+
if (entry.isDirectory()) walkSchemas(p);
|
|
673
|
+
else {
|
|
674
|
+
const m = entry.name.match(versionFile);
|
|
675
|
+
if (m) maxVersionByDir.set(dir, Math.max(maxVersionByDir.get(dir) ?? 0, Number(m[1])));
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
walkSchemas(schemasRoot);
|
|
680
|
+
|
|
681
|
+
// Tracked schema files whose committed bytes no longer match the tree (staged or
|
|
682
|
+
// unstaged; deletions included). Paths come back relative to the git toplevel.
|
|
683
|
+
// Untracked files never appear here — a brand-new version file is by definition
|
|
684
|
+
// not yet frozen history.
|
|
685
|
+
const dirtyFiles = tryGitLines(`diff --name-only HEAD -- "${schemasRel.replace(/\\/g, "/")}"`);
|
|
686
|
+
|
|
687
|
+
const violations = [];
|
|
688
|
+
for (const rel of dirtyFiles) {
|
|
689
|
+
const abs = path.resolve(gitTop, rel);
|
|
690
|
+
const m = path.basename(abs).match(versionFile);
|
|
691
|
+
if (!m) continue; // not a versioned schema JSON
|
|
692
|
+
const version = Number(m[1]);
|
|
693
|
+
const dirMax = maxVersionByDir.get(path.dirname(abs));
|
|
694
|
+
// The highest version currently on disk is the live schema — dirty is fine.
|
|
695
|
+
// Anything else (a lower version, or a file whose whole directory is gone)
|
|
696
|
+
// is rewritten/deleted history.
|
|
697
|
+
if (dirMax !== undefined && version === dirMax) continue;
|
|
698
|
+
violations.push(rel);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
if (violations.length === 0) {
|
|
702
|
+
return { name: "schemaHistory", verdict: "PASS", durationMs: elapsed(), details: { schemaDirs: maxVersionByDir.size } };
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
const lines = [
|
|
706
|
+
"Historical Room schema files were modified or deleted — these are frozen records of shipped databases, and regeneration must never rewrite them (migrations are validated against these exact bytes). Only the current highest version may change. Restore each file:",
|
|
707
|
+
];
|
|
708
|
+
for (const rel of violations) lines.push(` git checkout -- ${rel}`);
|
|
709
|
+
lines.push("If you intended a schema change, bump the database version so a NEW <version>.json is exported instead of overwriting history.");
|
|
710
|
+
return {
|
|
711
|
+
name: "schemaHistory",
|
|
712
|
+
verdict: "FAIL",
|
|
713
|
+
reason: lines.join("\n"),
|
|
714
|
+
durationMs: elapsed(),
|
|
715
|
+
details: { schemaDirs: maxVersionByDir.size, violations },
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function stepBuild() {
|
|
720
|
+
const res = shGradle(`${GRADLEW} :composeApp:assembleDebug --console=plain`);
|
|
721
|
+
return {
|
|
722
|
+
name: "build",
|
|
723
|
+
verdict: res.ok ? "PASS" : "FAIL",
|
|
724
|
+
reason: res.ok ? undefined : `assembleDebug failed — fix the build before anything else:\n${res.out.split("\n").filter((l) => /error|FAILURE/i.test(l)).slice(0, 12).join("\n")}`,
|
|
725
|
+
durationMs: res.durationMs,
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// The build nobody runs until the day they need it.
|
|
730
|
+
//
|
|
731
|
+
// assembleDebug passing says nothing about assembleRelease: R8 and `lintVital` only run on
|
|
732
|
+
// the release variant, and BuildConfig is generated PER BUILD TYPE, so a constant declared
|
|
733
|
+
// in one and not the other is a compile error that only release ever sees. All three of
|
|
734
|
+
// those bit this template at once, and none of them were visible from a green debug lane —
|
|
735
|
+
// the first release build ever attempted (2026-07-29) failed three times over.
|
|
736
|
+
//
|
|
737
|
+
// So release is proven at the checkpoint, not discovered at launch. Unsigned: signing needs
|
|
738
|
+
// a keystore, which belongs to whoever ships the app, and this step is about the shrinker
|
|
739
|
+
// and the build graph rather than the signature.
|
|
740
|
+
function stepReleaseBuild() {
|
|
741
|
+
const res = shGradle(`${GRADLEW} :composeApp:assembleRelease --console=plain`);
|
|
742
|
+
return {
|
|
743
|
+
name: "releaseBuild",
|
|
744
|
+
verdict: res.ok ? "PASS" : "FAIL",
|
|
745
|
+
reason: res.ok
|
|
746
|
+
? undefined
|
|
747
|
+
: `assembleRelease failed — the shippable build is broken even though the debug one is fine:\n${res.out
|
|
748
|
+
.split("\n")
|
|
749
|
+
.filter((l) => /error|FAILURE|Missing class|Unresolved/i.test(l))
|
|
750
|
+
.slice(0, 12)
|
|
751
|
+
.join("\n")}`,
|
|
752
|
+
durationMs: res.durationMs,
|
|
753
|
+
};
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Runs a filtered slice of the JVM test tier and names the verdict after the gate it proves.
|
|
757
|
+
// The full suite already ran in unitTests; the filtered slices stay cheap (compilation is
|
|
758
|
+
// cached) while `--rerun` forces the tests themselves to EXECUTE — see stepUnitTests.
|
|
759
|
+
// In fast mode the flag is omitted (RERUN, defined with the mode flags above): the
|
|
760
|
+
// integrity mechanism belongs to the runs that produce integrity-bearing artifacts, and a
|
|
761
|
+
// fast receipt has already declared itself non-evidence.
|
|
762
|
+
function gradleTestStep(name, testsFilter, failHint) {
|
|
763
|
+
return () => {
|
|
764
|
+
const res = shGradle(`${GRADLEW} :composeApp:desktopTest${RERUN} --tests "${testsFilter}" --console=plain`);
|
|
765
|
+
return {
|
|
766
|
+
name,
|
|
767
|
+
verdict: res.ok ? "PASS" : "FAIL",
|
|
768
|
+
reason: res.ok
|
|
769
|
+
? undefined
|
|
770
|
+
: `${failHint}\n${res.out.split("\n").filter((l) => /FAILED|\[(ARCH|SHELL|HOME)-\d+\]|error:/i.test(l)).slice(0, 15).join("\n")}`,
|
|
771
|
+
durationMs: res.durationMs,
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
function stepUnitTests() {
|
|
777
|
+
// `--rerun` is EVIDENCE INTEGRITY, not pedantry: without it, Gradle's build cache can
|
|
778
|
+
// restore a PASS recorded against a *different* tree state (deterministic re-scaffolds
|
|
779
|
+
// produce byte-identical sources, and golden baselines aren't compile inputs), so the
|
|
780
|
+
// receipt would attest tests that never executed. Compilation stays cached — only the
|
|
781
|
+
// test execution is forced. Scoped to FULL mode (see RERUN above): the integrity
|
|
782
|
+
// mechanism belongs to the runs that produce integrity-bearing artifacts, and a fast
|
|
783
|
+
// receipt is already declared non-evidence.
|
|
784
|
+
//
|
|
785
|
+
// Fast mode additionally scopes the suite to tests plausibly affected by the
|
|
786
|
+
// working-tree change (qa/lib/affected-tests.mjs): changed .kt files map to
|
|
787
|
+
// `--tests "*<segment>*"` patterns, with a mandatory blast-radius escape hatch (build
|
|
788
|
+
// files, DI, theme, shared components, qa/, anything outside composeApp/src → full
|
|
789
|
+
// suite) and fail-open on every uncertain case (no git, unmappable change). FALSE
|
|
790
|
+
// NEGATIVES ARE ACCEPTABLE HERE AND ONLY HERE: the full, unfiltered suite runs at the
|
|
791
|
+
// checkpoint (the full lane), where done is actually decided. The filter that ran is
|
|
792
|
+
// reported in the step's note and recorded in the (fast-only) receipt, so a filtered
|
|
793
|
+
// run can never be mistaken for the full suite.
|
|
794
|
+
let note;
|
|
795
|
+
let testsArgs = "";
|
|
796
|
+
let affected = null;
|
|
797
|
+
if (fast) {
|
|
798
|
+
const changed = changedWorkingTreePaths(ROOT);
|
|
799
|
+
if (changed === null) {
|
|
800
|
+
note = "full suite — git unavailable, cannot derive the change (fail open)";
|
|
801
|
+
} else {
|
|
802
|
+
const filter = deriveAffectedFilter(changed);
|
|
803
|
+
if (filter.mode === "filtered") {
|
|
804
|
+
testsArgs = filter.patterns.map((p) => ` --tests "${p}"`).join("");
|
|
805
|
+
note = `affected: ${filter.patterns.join(", ")} — ${filter.sourcePaths.length} changed source file(s)`;
|
|
806
|
+
affected = { patterns: filter.patterns, changedFiles: filter.sourcePaths.length };
|
|
807
|
+
} else {
|
|
808
|
+
note = `full suite — ${filter.reason}`;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
let res = shGradle(`${GRADLEW} :composeApp:desktopTest${RERUN}${testsArgs} --console=plain`);
|
|
813
|
+
if (fast && testsArgs && !res.ok && /No tests found for given includes/.test(res.out)) {
|
|
814
|
+
// The heuristic filter matched no test class at all (e.g. a feature with no tests
|
|
815
|
+
// yet). That is the harness's guess being wrong, not the app — fall back to the
|
|
816
|
+
// full suite in-lane rather than false-redding on our own filter. (RERUN is empty
|
|
817
|
+
// here by construction — this branch only exists in fast mode.)
|
|
818
|
+
const retry = shGradle(`${GRADLEW} :composeApp:desktopTest${RERUN} --console=plain`);
|
|
819
|
+
retry.durationMs += res.durationMs;
|
|
820
|
+
res = retry;
|
|
821
|
+
note = "full suite — the affected-test filter matched no tests (fell back)";
|
|
822
|
+
affected = null;
|
|
823
|
+
DEGRADED_PATHS.push("affected-test filter matched no tests — fell back to the full desktopTest suite");
|
|
824
|
+
}
|
|
825
|
+
const summary = junitSummary(path.join(ROOT, "composeApp/build/test-results/desktopTest"));
|
|
826
|
+
let details = summary ?? undefined;
|
|
827
|
+
if (affected) details = { ...(summary ?? {}), affected };
|
|
828
|
+
return {
|
|
829
|
+
name: "unitTests",
|
|
830
|
+
verdict: res.ok ? "PASS" : "FAIL",
|
|
831
|
+
reason: res.ok
|
|
832
|
+
? undefined
|
|
833
|
+
: `desktopTest failed (${summary ? `${summary.failures + summary.errors} of ${summary.tests} tests` : "see output"}). Fix the failing behavior — do not delete or weaken tests to pass:\n${res.out.split("\n").filter((l) => /FAILED|error:/i.test(l)).slice(0, 12).join("\n")}`,
|
|
834
|
+
note,
|
|
835
|
+
durationMs: res.durationMs,
|
|
836
|
+
details,
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
const stepConformance = gradleTestStep(
|
|
841
|
+
"conformance",
|
|
842
|
+
"*ArchitectureConformanceTest",
|
|
843
|
+
"Architecture conformance violated (specs/app-base.spec.md ARCH clauses). The failing rule names the clause, files, and fix:",
|
|
844
|
+
);
|
|
845
|
+
const stepGoldenTrees = gradleTestStep(
|
|
846
|
+
"goldenTrees",
|
|
847
|
+
"*GoldenTreeTest",
|
|
848
|
+
"Golden-tree drift: a screen's rendered STRUCTURE no longer matches qa/golden/. Unintended → fix your change; intended → regenerate with UPDATE_GOLDEN=1 and declare it:",
|
|
849
|
+
);
|
|
850
|
+
const stepA11y = gradleTestStep(
|
|
851
|
+
"a11y",
|
|
852
|
+
"*A11yConformanceTest",
|
|
853
|
+
"A11y gate failed (SHELL-04): interactive nodes must expose a testTag, text, or contentDescription:",
|
|
854
|
+
);
|
|
855
|
+
|
|
856
|
+
// ── Determinism probe (roadmap §10 item 8) — opt-in, ci-profile ────────────
|
|
857
|
+
// ARCH-13 statically bans ambient time reads — in APP code. A library the
|
|
858
|
+
// app calls can still read the wall clock, and a golden can still depend on
|
|
859
|
+
// the machine's timezone through a seam the static net cannot see (a
|
|
860
|
+
// ViewModel constructed without its injected clock already caused one
|
|
861
|
+
// overnight golden-tree drift). This probe closes that gap DYNAMICALLY: it
|
|
862
|
+
// runs the JVM test tier twice, under two timezones whose local calendar
|
|
863
|
+
// dates never agree — the offsets are 26 hours apart, so any date-derived
|
|
864
|
+
// value differs between the legs at every instant (see DETERMINISM_TIMEZONES
|
|
865
|
+
// in qa/lib/determinism.mjs for why UTC-12/UTC+14 and not UTC/UTC+14) — and
|
|
866
|
+
// FAILs naming every test whose outcome differs between the legs.
|
|
867
|
+
//
|
|
868
|
+
// Mechanics that carry the honesty:
|
|
869
|
+
// - TZ reaches the test JVM through the environment: Gradle forwards the
|
|
870
|
+
// client's environment to the daemon on every build, and test workers
|
|
871
|
+
// fork from the daemon — so the child env below is inherited all the way
|
|
872
|
+
// down to the JVM whose default timezone the tests see.
|
|
873
|
+
// - BOTH legs force --rerun. Without it Gradle would mark the second leg
|
|
874
|
+
// up-to-date (TZ is not a declared build input) and replay the first
|
|
875
|
+
// leg's results — the probe would then compare a run against its own
|
|
876
|
+
// echo and certify a determinism it never tested (the build-cache-replay
|
|
877
|
+
// lesson, again). The legs use the mode-scoped RERUN like every other
|
|
878
|
+
// desktopTest invocation — and because --determinism is refused alongside
|
|
879
|
+
// --fast up front, RERUN is always " --rerun" by the time a leg runs.
|
|
880
|
+
// - Only verdicts and failure output are compared; durations are never even
|
|
881
|
+
// parsed (qa/lib/determinism.mjs), so a timing wobble is structurally
|
|
882
|
+
// unable to trip the probe.
|
|
883
|
+
function stepDeterminism() {
|
|
884
|
+
const started = Date.now();
|
|
885
|
+
const elapsed = () => Date.now() - started;
|
|
886
|
+
if (!determinism) {
|
|
887
|
+
return {
|
|
888
|
+
name: "determinism",
|
|
889
|
+
verdict: "SKIP",
|
|
890
|
+
reason: "determinism probe is opt-in (it runs the JVM test tier twice) — add --determinism to this lane, or run the probe alone: node qa/verify.mjs --determinism",
|
|
891
|
+
durationMs: elapsed(),
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
const resultsDir = path.join(ROOT, "composeApp/build/test-results/desktopTest");
|
|
896
|
+
const legs = [];
|
|
897
|
+
for (const { tz, label } of DETERMINISM_TIMEZONES) {
|
|
898
|
+
const res = shGradle(`${GRADLEW} :composeApp:desktopTest${RERUN} --console=plain`, { env: { ...process.env, TZ: tz } });
|
|
899
|
+
// Parsed NOW, before the next leg overwrites the same results directory.
|
|
900
|
+
const outcomes = parseJUnitOutcomes(resultsDir);
|
|
901
|
+
legs.push({ tz, label, ok: res.ok, outcomes, tail: res.out.split("\n").slice(-8).join("\n") });
|
|
902
|
+
}
|
|
903
|
+
const [a, b] = legs;
|
|
904
|
+
const labelA = `TZ=${a.tz} (${a.label})`;
|
|
905
|
+
const labelB = `TZ=${b.tz} (${b.label})`;
|
|
906
|
+
const countA = Object.keys(a.outcomes).length;
|
|
907
|
+
const countB = Object.keys(b.outcomes).length;
|
|
908
|
+
|
|
909
|
+
if (countA === 0 && countB === 0) {
|
|
910
|
+
// Neither leg produced a single test result: the suite failed before
|
|
911
|
+
// running anything (build error). The probe measured nothing — that is
|
|
912
|
+
// a FAIL that says so, never a PASS by absence of differences.
|
|
913
|
+
return {
|
|
914
|
+
name: "determinism",
|
|
915
|
+
verdict: "FAIL",
|
|
916
|
+
reason: `determinism probe could not execute: desktopTest produced no test results under either timezone — the suite fails before running (fix the build first; this is not a timezone difference):\n${a.tail}`,
|
|
917
|
+
durationMs: elapsed(),
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
if (countA === 0 || countB === 0) {
|
|
921
|
+
const ran = countA > 0 ? { label: labelA, n: countA } : { label: labelB, n: countB };
|
|
922
|
+
const empty = countA > 0 ? b : a;
|
|
923
|
+
return {
|
|
924
|
+
name: "determinism",
|
|
925
|
+
verdict: "FAIL",
|
|
926
|
+
reason: `Nondeterminism under timezone shift: desktopTest ran ${ran.n} test(s) under ${ran.label} but produced no results at all under TZ=${empty.tz} (${empty.label}) — the suite itself dies under that zone:\n${empty.tail}`,
|
|
927
|
+
durationMs: elapsed(),
|
|
928
|
+
details: { timezones: DETERMINISM_TIMEZONES.map((t) => t.tz) },
|
|
929
|
+
};
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const diffs = compareOutcomes(a.outcomes, b.outcomes, labelA, labelB);
|
|
933
|
+
if (diffs.length > 0) {
|
|
934
|
+
const lines = [
|
|
935
|
+
`Nondeterminism under timezone shift — the same tree produced different outcomes under ${labelA} vs ${labelB}. Something reads ambient time or zone past the ARCH-13 net (a library default, an uninjected clock, a golden that captures "today"):`,
|
|
936
|
+
];
|
|
937
|
+
for (const d of diffs.slice(0, 20)) lines.push(` [${d.step}] ${d.test} — ${d.detail}`);
|
|
938
|
+
if (diffs.length > 20) lines.push(` … and ${diffs.length - 20} more differing test(s)`);
|
|
939
|
+
return {
|
|
940
|
+
name: "determinism",
|
|
941
|
+
verdict: "FAIL",
|
|
942
|
+
reason: lines.join("\n"),
|
|
943
|
+
durationMs: elapsed(),
|
|
944
|
+
details: { timezones: DETERMINISM_TIMEZONES.map((t) => t.tz), diffs: diffs.slice(0, 50) },
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
const failedIdentically = Object.values(a.outcomes).filter((o) => o.status !== "pass" && o.status !== "skip").length;
|
|
949
|
+
return {
|
|
950
|
+
name: "determinism",
|
|
951
|
+
verdict: "PASS",
|
|
952
|
+
// Identical red is DETERMINISTIC red: the probe's claim ("no timezone
|
|
953
|
+
// dependence") holds, and the failing tests already belong to
|
|
954
|
+
// unitTests/goldenTrees, which fail the lane on their own merits — a
|
|
955
|
+
// second FAIL here would report the same defect twice under a wrong name.
|
|
956
|
+
note:
|
|
957
|
+
failedIdentically > 0
|
|
958
|
+
? `${failedIdentically} test(s) failed identically under both timezones — deterministic, but red (the owning test steps report it)`
|
|
959
|
+
: undefined,
|
|
960
|
+
durationMs: elapsed(),
|
|
961
|
+
details: { timezones: DETERMINISM_TIMEZONES.map((t) => t.tz), testsCompared: countA },
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
// Live tokenDrift tier (harness M4-D): when a debug app + device are available,
|
|
966
|
+
// fetches the declared catalog and the live semantics tree off the debug-only
|
|
967
|
+
// inspector server (127.0.0.1:9500, see composeApp/src/androidDebug/.../
|
|
968
|
+
// InspectorHttpServer.kt) and runs compareTokenDrift() over them — real runtime
|
|
969
|
+
// drift detection, embedded in the evidence receipt.
|
|
970
|
+
//
|
|
971
|
+
// Infrastructure absence (no device, app not running) is NEVER a FAIL — only
|
|
972
|
+
// actual drift is. curl (via the existing synchronous sh() helper) stands in for
|
|
973
|
+
// an HTTP client here because every step in this lane runs synchronously; a
|
|
974
|
+
// couple of short retries cover the debug app's cold start.
|
|
975
|
+
const INSPECTOR_PORT = 9500;
|
|
976
|
+
|
|
977
|
+
function curlJson(url, timeoutSec = 5) {
|
|
978
|
+
const res = sh(`curl -s -m ${timeoutSec} -w "\\n%{http_code}" "${url}"`);
|
|
979
|
+
if (!res.ok) return { ok: false };
|
|
980
|
+
const out = res.out;
|
|
981
|
+
const idx = out.lastIndexOf("\n");
|
|
982
|
+
const code = (idx >= 0 ? out.slice(idx + 1) : "").trim();
|
|
983
|
+
const bodyText = idx >= 0 ? out.slice(0, idx) : "";
|
|
984
|
+
if (code !== "200") return { ok: false };
|
|
985
|
+
try {
|
|
986
|
+
return { ok: true, body: JSON.parse(bodyText) };
|
|
987
|
+
} catch {
|
|
988
|
+
return { ok: false };
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
function pollHealth(port, attempts, delaySec) {
|
|
993
|
+
let health = curlJson(`http://127.0.0.1:${port}/inspect/health`);
|
|
994
|
+
for (let tries = 1; !health.ok && tries < attempts; tries += 1) {
|
|
995
|
+
sh(`sleep ${delaySec}`);
|
|
996
|
+
health = curlJson(`http://127.0.0.1:${port}/inspect/health`);
|
|
997
|
+
}
|
|
998
|
+
return health;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function stepTokenDrift() {
|
|
1002
|
+
const started = Date.now();
|
|
1003
|
+
const elapsed = () => Date.now() - started;
|
|
1004
|
+
|
|
1005
|
+
if (!deviceAttached()) {
|
|
1006
|
+
return {
|
|
1007
|
+
name: "tokenDrift",
|
|
1008
|
+
verdict: "SKIP",
|
|
1009
|
+
reason: "no Android device/emulator attached (adb) — runtime token drift needs the live inspector tier",
|
|
1010
|
+
durationMs: elapsed(),
|
|
1011
|
+
};
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
const unreachable = () => ({
|
|
1015
|
+
name: "tokenDrift",
|
|
1016
|
+
verdict: "SKIP",
|
|
1017
|
+
reason: "inspector endpoint not reachable on :9500 (debug app not running?) — launch the debug build to enable the live tier",
|
|
1018
|
+
durationMs: elapsed(),
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1021
|
+
// Machine-global lease before the first device touch (contention = SKIP).
|
|
1022
|
+
const leaseSkip = leaseDeviceForStep("tokenDrift");
|
|
1023
|
+
if (leaseSkip) return { ...leaseSkip, durationMs: elapsed() };
|
|
1024
|
+
|
|
1025
|
+
sh(`adb forward tcp:${INSPECTOR_PORT} tcp:${INSPECTOR_PORT}`);
|
|
1026
|
+
try {
|
|
1027
|
+
let health = curlJson(`http://127.0.0.1:${INSPECTOR_PORT}/inspect/health`);
|
|
1028
|
+
if (!health.ok) {
|
|
1029
|
+
// Debug app may not be running — try to launch it (best-effort: parse the
|
|
1030
|
+
// applicationId out of the Android build config), then give it a moment
|
|
1031
|
+
// to cold-start before giving up.
|
|
1032
|
+
let applicationId = null;
|
|
1033
|
+
try {
|
|
1034
|
+
const gradle = fs.readFileSync(path.join(ROOT, "composeApp/build.gradle.kts"), "utf8");
|
|
1035
|
+
applicationId = gradle.match(/applicationId\s*=\s*"([^"]+)"/)?.[1] ?? null;
|
|
1036
|
+
} catch {
|
|
1037
|
+
applicationId = null;
|
|
1038
|
+
}
|
|
1039
|
+
if (applicationId) {
|
|
1040
|
+
sh(`adb shell am start -n ${applicationId}/.MainActivity`);
|
|
1041
|
+
}
|
|
1042
|
+
health = pollHealth(INSPECTOR_PORT, 5, 2);
|
|
1043
|
+
}
|
|
1044
|
+
if (!health.ok) return unreachable();
|
|
1045
|
+
|
|
1046
|
+
const designSystem = curlJson(`http://127.0.0.1:${INSPECTOR_PORT}/inspect/design-system`);
|
|
1047
|
+
const tree = curlJson(`http://127.0.0.1:${INSPECTOR_PORT}/inspect/tree`);
|
|
1048
|
+
if (!designSystem.ok || !tree.ok) return unreachable();
|
|
1049
|
+
|
|
1050
|
+
const { checked, drifted } = compareTokenDrift(designSystem.body, tree.body);
|
|
1051
|
+
|
|
1052
|
+
if (drifted.length === 0) {
|
|
1053
|
+
return {
|
|
1054
|
+
name: "tokenDrift",
|
|
1055
|
+
verdict: "PASS",
|
|
1056
|
+
durationMs: elapsed(),
|
|
1057
|
+
details: { checked, drifted: 0 },
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
const lines = ["Runtime token drift — a component's resolved value contradicts the declared design-system catalog:"];
|
|
1062
|
+
for (const d of drifted) {
|
|
1063
|
+
lines.push(
|
|
1064
|
+
` [${d.node}] token '${d.token}' (${d.facet}) — expected ${d.expected}, resolved ${d.actual}. Update the component to use the token, or update the catalog if the token itself changed.`,
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
return {
|
|
1068
|
+
name: "tokenDrift",
|
|
1069
|
+
verdict: "FAIL",
|
|
1070
|
+
reason: lines.join("\n"),
|
|
1071
|
+
durationMs: elapsed(),
|
|
1072
|
+
details: { checked, drifted },
|
|
1073
|
+
};
|
|
1074
|
+
} finally {
|
|
1075
|
+
sh(`adb forward --remove tcp:${INSPECTOR_PORT}`);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
function maestroAvailable() {
|
|
1080
|
+
return sh("maestro --version", { timeout: 15_000 }).ok;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
// The e2e guard trio, shared by every step that drives the smoke flow on a device.
|
|
1084
|
+
// Returns null when the harness is fully available, else the SKIP result for [name].
|
|
1085
|
+
function maestroGuards(name) {
|
|
1086
|
+
if (!fs.existsSync(path.join(ROOT, "qa/e2e"))) {
|
|
1087
|
+
return { name, verdict: "SKIP", reason: "e2e harness not included in this project (--no-e2e)", durationMs: 0 };
|
|
1088
|
+
}
|
|
1089
|
+
if (!deviceAttached()) {
|
|
1090
|
+
return { name, verdict: "SKIP", reason: "no Android device/emulator attached (adb)", durationMs: 0 };
|
|
1091
|
+
}
|
|
1092
|
+
if (!maestroAvailable()) {
|
|
1093
|
+
return { name, verdict: "SKIP", reason: "maestro CLI not installed — curl -fsSL https://get.maestro.mobile.dev | bash", durationMs: 0 };
|
|
1094
|
+
}
|
|
1095
|
+
return null;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
// Drives qa/e2e/smoke.yaml against whatever build is installed, with the device hardened
|
|
1099
|
+
// for headless/CI automation. Shared by e2eSmoke (debug APK) and releaseSmoke (release
|
|
1100
|
+
// APK) so the hardening and the honesty sweep can never drift apart between variants.
|
|
1101
|
+
// Without the hardening, a slow or loaded emulator produces false reds that have nothing
|
|
1102
|
+
// to do with the app:
|
|
1103
|
+
// - hide_error_dialogs=1 stops Android popping ANR/crash dialogs (e.g. SystemUI under load)
|
|
1104
|
+
// that steal focus over the app — a Maestro assert would then see only the dialog;
|
|
1105
|
+
// - MAESTRO_DRIVER_STARTUP_TIMEOUT gives the UiAutomator2 driver a generous budget to come
|
|
1106
|
+
// up on a slow emulator (the built-in default gives up too early under load).
|
|
1107
|
+
// Both are benign, reversible, and only touch the device while the lane is driving it —
|
|
1108
|
+
// hide_error_dialogs is restored to its pre-run value (or deleted, returning the device
|
|
1109
|
+
// to its default) in the finally below, on every exit path.
|
|
1110
|
+
// hide_error_dialogs suppresses the OS dialog, NEVER the underlying event — so after the
|
|
1111
|
+
// run we grep the device log for ANR/crash lines the dialog would have shown, and FAIL on
|
|
1112
|
+
// them. The eyes must report what automation stability had to hide.
|
|
1113
|
+
function runMaestroSmoke(name, priorDurationMs) {
|
|
1114
|
+
const prevHideErrorDialogs = sh("adb shell settings get global hide_error_dialogs").out.trim();
|
|
1115
|
+
sh("adb shell settings put global hide_error_dialogs 1");
|
|
1116
|
+
sh("adb logcat -c"); // clear so the post-run dump only reflects this run
|
|
1117
|
+
try {
|
|
1118
|
+
const res = sh("maestro test qa/e2e/smoke.yaml", { env: { ...process.env, MAESTRO_DRIVER_STARTUP_TIMEOUT: "120000" } });
|
|
1119
|
+
if (!res.ok) {
|
|
1120
|
+
return {
|
|
1121
|
+
name,
|
|
1122
|
+
verdict: "FAIL",
|
|
1123
|
+
reason: `Maestro smoke failed (flow cites the SHELL spec clauses it proves):\n${res.out.split("\n").slice(-15).join("\n")}`,
|
|
1124
|
+
durationMs: priorDurationMs + res.durationMs,
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
const anrDump = sh("adb logcat -d -b system,crash,main");
|
|
1128
|
+
const anrRe = /ANR in |FATAL EXCEPTION/i;
|
|
1129
|
+
if (anrDump.ok && anrRe.test(anrDump.out)) {
|
|
1130
|
+
const anrLines = anrDump.out.split("\n").filter((l) => anrRe.test(l)).slice(0, 10).join("\n");
|
|
1131
|
+
return {
|
|
1132
|
+
name,
|
|
1133
|
+
verdict: "FAIL",
|
|
1134
|
+
reason: `Maestro smoke passed, but the device log shows an ANR/crash during the run (hide_error_dialogs only suppresses the OS dialog, never the underlying event):\n${anrLines}`,
|
|
1135
|
+
durationMs: priorDurationMs + res.durationMs,
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
return { name, verdict: "PASS", durationMs: priorDurationMs + res.durationMs };
|
|
1139
|
+
} finally {
|
|
1140
|
+
if (prevHideErrorDialogs && prevHideErrorDialogs !== "null") {
|
|
1141
|
+
sh(`adb shell settings put global hide_error_dialogs ${prevHideErrorDialogs}`);
|
|
1142
|
+
} else {
|
|
1143
|
+
sh("adb shell settings delete global hide_error_dialogs");
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
function stepE2eSmoke() {
|
|
1149
|
+
const guard = maestroGuards("e2eSmoke");
|
|
1150
|
+
if (guard) return guard;
|
|
1151
|
+
// Machine-global lease before the first device touch (contention = SKIP).
|
|
1152
|
+
const leaseSkip = leaseDeviceForStep("e2eSmoke");
|
|
1153
|
+
if (leaseSkip) return leaseSkip;
|
|
1154
|
+
const install = shGradle(`${GRADLEW} :composeApp:installDebug --console=plain`);
|
|
1155
|
+
if (!install.ok) {
|
|
1156
|
+
return { name: "e2eSmoke", verdict: "FAIL", reason: "installDebug failed — the APK could not be installed on the attached device", durationMs: install.durationMs };
|
|
1157
|
+
}
|
|
1158
|
+
settleAdb();
|
|
1159
|
+
return runMaestroSmoke("e2eSmoke", install.durationMs);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// Instrumented behavior tier (composeApp/src/androidInstrumentedTest) — the one step
|
|
1163
|
+
// whose evidence crosses the process boundary. Alarms, notification channels,
|
|
1164
|
+
// full-screen intents, PendingIntent identity, and audio routing are OS facts:
|
|
1165
|
+
// desktopTest is a JVM, golden trees are structure, the conformance suite is static,
|
|
1166
|
+
// and the Maestro smoke taps UI without asserting anything about the shade or the
|
|
1167
|
+
// alarm table. Nine escaped platform-semantics defects across two real apps trace to
|
|
1168
|
+
// exactly this blind spot; the hand-built precursor of this step caught two bugs the
|
|
1169
|
+
// week it landed. `connectedDebugAndroidTest` builds, installs, and runs the
|
|
1170
|
+
// instrumented suite in the app's real process on the attached device.
|
|
1171
|
+
//
|
|
1172
|
+
// SKIP (never FAIL) on missing infrastructure — no device, or no instrumented sources
|
|
1173
|
+
// yet — mirroring e2eSmoke's stance: absence of the tier is recorded honestly, only
|
|
1174
|
+
// broken behavior fails.
|
|
1175
|
+
function stepAndroidChecks() {
|
|
1176
|
+
const started = Date.now();
|
|
1177
|
+
const instrumentedDir = path.join(ROOT, "composeApp/src/androidInstrumentedTest");
|
|
1178
|
+
const hasSources = fs.existsSync(instrumentedDir) &&
|
|
1179
|
+
walkFiles(instrumentedDir, [".kt"]).length > 0;
|
|
1180
|
+
if (!hasSources) {
|
|
1181
|
+
return {
|
|
1182
|
+
name: "androidChecks",
|
|
1183
|
+
verdict: "SKIP",
|
|
1184
|
+
reason: "no instrumented tests (composeApp/src/androidInstrumentedTest has no Kotlin sources)",
|
|
1185
|
+
durationMs: Date.now() - started,
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
if (!deviceAttached()) {
|
|
1189
|
+
return {
|
|
1190
|
+
name: "androidChecks",
|
|
1191
|
+
verdict: "SKIP",
|
|
1192
|
+
reason: "no Android device/emulator attached (adb) — instrumented behavior needs the real process boundary",
|
|
1193
|
+
durationMs: Date.now() - started,
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
// Machine-global lease before the first device touch (contention = SKIP).
|
|
1197
|
+
const leaseSkip = leaseDeviceForStep("androidChecks");
|
|
1198
|
+
if (leaseSkip) return { ...leaseSkip, durationMs: Date.now() - started };
|
|
1199
|
+
// Settle before Gradle's own install+drive: earlier lane steps (tokenDrift's
|
|
1200
|
+
// port-forwards, e2eSmoke's reinstall) can leave the transport stale — see settleAdb.
|
|
1201
|
+
settleAdb();
|
|
1202
|
+
// `--rerun` for the same evidence-integrity reason as stepUnitTests: the receipt must
|
|
1203
|
+
// attest tests that EXECUTED on this tree, never a replayed up-to-date verdict.
|
|
1204
|
+
const res = shGradle(`${GRADLEW} :composeApp:connectedDebugAndroidTest --rerun --console=plain`);
|
|
1205
|
+
const summary = junitSummary(path.join(ROOT, "composeApp/build/outputs/androidTest-results/connected"));
|
|
1206
|
+
return {
|
|
1207
|
+
name: "androidChecks",
|
|
1208
|
+
verdict: res.ok ? "PASS" : "FAIL",
|
|
1209
|
+
reason: res.ok
|
|
1210
|
+
? undefined
|
|
1211
|
+
: `connectedDebugAndroidTest failed (${summary ? `${summary.failures + summary.errors} of ${summary.tests} tests` : "see output"}) — an on-device behavior claim is broken. Fix the behavior, not the test:\n${res.out.split("\n").filter((l) => /FAILED|error:|failed/i.test(l)).slice(0, 12).join("\n")}`,
|
|
1212
|
+
durationMs: Date.now() - started,
|
|
1213
|
+
details: summary ?? undefined,
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
// Release-APK smoke — the behavior half of stepReleaseBuild. assembleRelease proves R8
|
|
1218
|
+
// and the build graph COMPILE; two real bugs were only findable by *running* the release
|
|
1219
|
+
// variant (R8 behavior differs from debug). Installs the release APK and drives the same
|
|
1220
|
+
// Maestro smoke flow against it. Ship-time cost by design: this step exists only in the
|
|
1221
|
+
// `release` profile, never per-change.
|
|
1222
|
+
//
|
|
1223
|
+
// Honesty notes, both deliberate:
|
|
1224
|
+
// - A template-fresh app has NO release signingConfig (the keystore belongs to whoever
|
|
1225
|
+
// ships), and an unsigned APK cannot be installed. That is a SKIP naming what to
|
|
1226
|
+
// configure, never a FAIL — a fresh scaffold must not red-bar on a keystore it was
|
|
1227
|
+
// never given.
|
|
1228
|
+
// - This step reinstalls NOTHING afterwards: the release build stays on the device,
|
|
1229
|
+
// which is the honest state ("what is installed is what was last proven"). The next
|
|
1230
|
+
// debug install over it will hit INSTALL_FAILED_UPDATE_INCOMPATIBLE (release and debug
|
|
1231
|
+
// signatures differ) — run `adb uninstall <applicationId>` first; the same applies in
|
|
1232
|
+
// reverse here, so that raw Gradle error is translated into the actionable message.
|
|
1233
|
+
function stepReleaseSmoke() {
|
|
1234
|
+
const guard = maestroGuards("releaseSmoke");
|
|
1235
|
+
if (guard) return guard;
|
|
1236
|
+
|
|
1237
|
+
let gradleText = "";
|
|
1238
|
+
try {
|
|
1239
|
+
gradleText = fs.readFileSync(path.join(ROOT, "composeApp/build.gradle.kts"), "utf8");
|
|
1240
|
+
} catch {
|
|
1241
|
+
gradleText = "";
|
|
1242
|
+
}
|
|
1243
|
+
const applicationId = gradleText.match(/applicationId\s*=\s*"([^"]+)"/)?.[1] ?? "<applicationId>";
|
|
1244
|
+
if (!/signingConfig/.test(gradleText)) {
|
|
1245
|
+
return {
|
|
1246
|
+
name: "releaseSmoke",
|
|
1247
|
+
verdict: "SKIP",
|
|
1248
|
+
reason:
|
|
1249
|
+
"release APK is unsigned — no signingConfig in composeApp/build.gradle.kts. To enable the release smoke: create a keystore (keytool -genkeypair), declare android.signingConfigs { create(\"release\") { … } } from a gitignored keystore.properties, and set buildTypes.release.signingConfig. The keystore is yours to keep out of the repo.",
|
|
1250
|
+
durationMs: 0,
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// Machine-global lease before the first device touch (contention = SKIP).
|
|
1255
|
+
// After the signing check on purpose: an unsigned template SKIPs on the
|
|
1256
|
+
// keystore without ever needing the device.
|
|
1257
|
+
const leaseSkip = leaseDeviceForStep("releaseSmoke");
|
|
1258
|
+
if (leaseSkip) return leaseSkip;
|
|
1259
|
+
|
|
1260
|
+
const install = shGradle(`${GRADLEW} :composeApp:installRelease --console=plain`);
|
|
1261
|
+
if (!install.ok) {
|
|
1262
|
+
if (/INSTALL_FAILED_UPDATE_INCOMPATIBLE/.test(install.out)) {
|
|
1263
|
+
return {
|
|
1264
|
+
name: "releaseSmoke",
|
|
1265
|
+
verdict: "FAIL",
|
|
1266
|
+
reason: `installRelease refused: the device holds a build with a different signature (usually the debug build from an earlier lane step). Android never installs across signatures — run \`adb uninstall ${applicationId}\` and re-run the release profile. This is a device-state conflict, not a build defect.`,
|
|
1267
|
+
durationMs: install.durationMs,
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
if (/SigningConfig|not signed|INSTALL_PARSE_FAILED_NO_CERTIFICATES/i.test(install.out)) {
|
|
1271
|
+
return {
|
|
1272
|
+
name: "releaseSmoke",
|
|
1273
|
+
verdict: "SKIP",
|
|
1274
|
+
reason: "release APK is not installable — signing is not fully configured (see composeApp/build.gradle.kts signingConfigs). Configure a release keystore to enable the release smoke.",
|
|
1275
|
+
durationMs: install.durationMs,
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
return {
|
|
1279
|
+
name: "releaseSmoke",
|
|
1280
|
+
verdict: "FAIL",
|
|
1281
|
+
reason: `installRelease failed — the shippable APK could not be installed:\n${install.out.split("\n").filter((l) => /error|FAILURE|INSTALL_/i.test(l)).slice(0, 12).join("\n")}`,
|
|
1282
|
+
durationMs: install.durationMs,
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
settleAdb();
|
|
1286
|
+
return runMaestroSmoke("releaseSmoke", install.durationMs);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// ── Audit cadence (roadmap §10 item 9) — a REPORT, never a gate ────────────
|
|
1290
|
+
// cmp-audit (the adversarial platform-semantics audit) found six latent
|
|
1291
|
+
// defects the first time a human happened to ask for it — which is exactly
|
|
1292
|
+
// why it must not depend on someone remembering to ask. This step is the
|
|
1293
|
+
// cheapest honest replacement for that memory: at ship time (release
|
|
1294
|
+
// profile) the receipt lists which androidMain subsystems changed since
|
|
1295
|
+
// their last RECORDED audit (qa/audits.jsonl, appended by
|
|
1296
|
+
// node qa/record-audit.mjs). The derivation lives in
|
|
1297
|
+
// qa/lib/audit-cadence.mjs; this step adds only the bookkeeping every step
|
|
1298
|
+
// carries — and by construction it maps every outcome to PASS or SKIP,
|
|
1299
|
+
// never FAIL: audit debt is a judgment call (a rename is not six latent
|
|
1300
|
+
// defects), and a gate here would teach people to game the ledger, which
|
|
1301
|
+
// would destroy the only value it has.
|
|
1302
|
+
function stepAuditCadence() {
|
|
1303
|
+
const started = Date.now();
|
|
1304
|
+
const report = evaluateAuditCadence(ROOT);
|
|
1305
|
+
if (!report.ok) {
|
|
1306
|
+
return { name: "auditCadence", verdict: "SKIP", reason: report.reason, durationMs: Date.now() - started };
|
|
1307
|
+
}
|
|
1308
|
+
return {
|
|
1309
|
+
name: "auditCadence",
|
|
1310
|
+
verdict: "PASS",
|
|
1311
|
+
note: report.summary,
|
|
1312
|
+
durationMs: Date.now() - started,
|
|
1313
|
+
details: {
|
|
1314
|
+
packageRoot: report.packageRoot,
|
|
1315
|
+
subsystems: report.subsystems.map((s) => ({
|
|
1316
|
+
name: s.name,
|
|
1317
|
+
status: s.status,
|
|
1318
|
+
changedFiles: s.changedFiles,
|
|
1319
|
+
lastAudit: s.audit ? { sha: s.audit.sha, at: s.audit.at, by: s.audit.by } : null,
|
|
1320
|
+
})),
|
|
1321
|
+
lines: report.lines,
|
|
1322
|
+
},
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
// ── Lane ───────────────────────────────────────────────────────────────────
|
|
1327
|
+
|
|
1328
|
+
// Device-dependent steps, in lane order. Used twice: receipt STRENGTH (which
|
|
1329
|
+
// on-device steps actually PASSed — see below, where the receipt is built) and
|
|
1330
|
+
// the --fast exclusion (with releaseBuild added), so the "device/slow tier"
|
|
1331
|
+
// can never mean two different lists.
|
|
1332
|
+
const DEVICE_STEPS = ["e2eSmoke", "tokenDrift", "androidChecks", "releaseSmoke"];
|
|
1333
|
+
|
|
1334
|
+
// ── Fast-mode memoization of the pure-Node steps (qa/lib/step-cache.mjs) ────
|
|
1335
|
+
// These five steps run no Gradle, shell out to nothing, and are pure functions
|
|
1336
|
+
// of files on disk — so in FAST mode an unchanged input set reuses the last
|
|
1337
|
+
// PASS as verdict "CACHED" (rendered distinctly; only a PASS is ever reused,
|
|
1338
|
+
// a cached FAIL/SKIP always re-runs). THE FULL LANE NEVER CONSULTS THE CACHE —
|
|
1339
|
+
// deliberately: it keeps the integrity property absolute rather than "absolute
|
|
1340
|
+
// unless a cache says otherwise". A full run still WRITES entries so the next
|
|
1341
|
+
// fast run benefits. schemaHistory is NOT here even though it runs no Gradle:
|
|
1342
|
+
// it shells out to git and its verdict depends on HEAD state, not only file
|
|
1343
|
+
// bytes — memoizing it on a content hash could go silently stale.
|
|
1344
|
+
//
|
|
1345
|
+
// Each input set is the step's ACTUAL read surface, over-declared where cheap
|
|
1346
|
+
// (a too-broad set only costs cache misses; a too-narrow one is a
|
|
1347
|
+
// silently-stale gate — the worst possible bug here):
|
|
1348
|
+
// specCoverage reads specs/*.spec.md + citations under composeApp/src
|
|
1349
|
+
// and qa/e2e (qa/lib/spec-coverage.mjs)
|
|
1350
|
+
// approvals reads qa/approvals.json + every governed artifact file:
|
|
1351
|
+
// specs/, docs/features/, docs/ARCHITECTURE.md, and the
|
|
1352
|
+
// exemplar/theme/components Kotlin under composeApp/src
|
|
1353
|
+
// (qa/lib/approvals.mjs listGovernedArtifacts)
|
|
1354
|
+
// componentStories reads commonMain presentation/components and desktopMain
|
|
1355
|
+
// inspector sources — both under composeApp/src
|
|
1356
|
+
// reachability reads commonMain Kotlin (composeApp/src) + the unrouted
|
|
1357
|
+
// declarations in docs/features/
|
|
1358
|
+
// archDoc reads docs/ARCHITECTURE.md, docs/adr/, specs/intent.md
|
|
1359
|
+
// (over-declared to all of specs/), and every source-set's
|
|
1360
|
+
// Kotlin under composeApp/src (qa/lib/arch-doc.mjs)
|
|
1361
|
+
const MEMOIZED_STEP_INPUTS = {
|
|
1362
|
+
specCoverage: ["specs", "composeApp/src", "qa/e2e"],
|
|
1363
|
+
approvals: ["qa/approvals.json", "specs", "docs/features", "docs/ARCHITECTURE.md", "composeApp/src"],
|
|
1364
|
+
componentStories: ["composeApp/src"],
|
|
1365
|
+
reachability: ["composeApp/src", "docs/features"],
|
|
1366
|
+
archDoc: ["docs/ARCHITECTURE.md", "docs/adr", "specs", "composeApp/src"],
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
const memoized = (stepName, stepFn) => () =>
|
|
1370
|
+
memoizeStep({ fast, root: ROOT, stepName, inputs: MEMOIZED_STEP_INPUTS[stepName], run: stepFn });
|
|
1371
|
+
|
|
1372
|
+
const stepSpecCoverageMemo = memoized("specCoverage", stepSpecCoverage);
|
|
1373
|
+
const stepApprovalsMemo = memoized("approvals", stepApprovals);
|
|
1374
|
+
const stepComponentStoriesMemo = memoized("componentStories", stepComponentStories);
|
|
1375
|
+
const stepReachabilityMemo = memoized("reachability", stepReachability);
|
|
1376
|
+
const stepArchDocMemo = memoized("archDoc", stepArchDoc);
|
|
1377
|
+
|
|
1378
|
+
const stepsForProfile = {
|
|
1379
|
+
// scaffold: what `create-cmp --verify` proves at stamp time — specCoverage,
|
|
1380
|
+
// the full JVM tier (unit + conformance + golden + UI tests) plus the Android build.
|
|
1381
|
+
scaffold: [stepHarnessIntegrity, stepSpecCoverageMemo, stepApprovalsMemo, stepComponentStoriesMemo, stepReachabilityMemo, stepArchDocMemo, stepSchemaHistory, stepBuild, stepUnitTests],
|
|
1382
|
+
local: [
|
|
1383
|
+
// First, always: every verdict below is only worth what the lane issuing
|
|
1384
|
+
// it is worth.
|
|
1385
|
+
stepHarnessIntegrity,
|
|
1386
|
+
stepSpecCoverageMemo,
|
|
1387
|
+
stepApprovalsMemo,
|
|
1388
|
+
stepComponentStoriesMemo,
|
|
1389
|
+
stepReachabilityMemo,
|
|
1390
|
+
stepArchDocMemo,
|
|
1391
|
+
stepSchemaHistory,
|
|
1392
|
+
stepBuild,
|
|
1393
|
+
// Release stays OUT of `scaffold`: stamp-time --verify promises a green first build, and
|
|
1394
|
+
// an R8 pass would add minutes to every scaffold to re-prove what this step proves here.
|
|
1395
|
+
// local + ci is where release rot gets caught before it reaches anyone.
|
|
1396
|
+
stepReleaseBuild,
|
|
1397
|
+
stepUnitTests,
|
|
1398
|
+
stepConformance,
|
|
1399
|
+
stepGoldenTrees,
|
|
1400
|
+
stepTokenDrift,
|
|
1401
|
+
stepA11y,
|
|
1402
|
+
stepE2eSmoke,
|
|
1403
|
+
// androidChecks joins local BY the file's own convention, not despite it: local's
|
|
1404
|
+
// contract (see USAGE) is "everything; device-dependent steps SKIP when no device is
|
|
1405
|
+
// attached" — device presence is the opt-in, exactly as e2eSmoke and tokenDrift
|
|
1406
|
+
// already work. A developer with no device attached pays nothing here; one who
|
|
1407
|
+
// attached an emulator has already opted into the device tier's cost. Hiding this
|
|
1408
|
+
// step in ci-only would make local's documented contract a lie and re-open the gap
|
|
1409
|
+
// this tier closes (androidMain test-invisible in the profile people actually run).
|
|
1410
|
+
// Last on purpose: the cheap desktop verdicts and the smoke land first.
|
|
1411
|
+
stepAndroidChecks,
|
|
1412
|
+
],
|
|
1413
|
+
};
|
|
1414
|
+
// ci = local + the determinism probe's row — the first place ci diverges
|
|
1415
|
+
// from local. The probe is OPT-IN (the step SKIPs unless --determinism was
|
|
1416
|
+
// passed: it doubles the JVM test tier's cost), but its row lives in the ci
|
|
1417
|
+
// profile so a ci receipt always records whether the probe ran — an honest,
|
|
1418
|
+
// visible gap beats an invisible one ("SKIPs are recorded so the pipeline
|
|
1419
|
+
// stays honest", per the profile's own contract). local deliberately does
|
|
1420
|
+
// NOT carry the row: the per-change developer profile is not where a
|
|
1421
|
+
// deliberate double-run belongs.
|
|
1422
|
+
stepsForProfile.ci = [...stepsForProfile.local, stepDeterminism];
|
|
1423
|
+
// release = everything ci proves PLUS the audit-cadence report and the
|
|
1424
|
+
// release-APK behavior smoke. The expensive proofs are profile-tiered by
|
|
1425
|
+
// decision: per-change stays fast (local/ci pay for the release COMPILE via
|
|
1426
|
+
// releaseBuild, already in the set), and the release-variant *behavior* cost
|
|
1427
|
+
// lands once, at ship time. auditCadence (a report, never a gate) also
|
|
1428
|
+
// belongs to ship time — "what moved in androidMain since its last
|
|
1429
|
+
// adversarial audit?" is the question asked before shipping, not per edit.
|
|
1430
|
+
// releaseSmoke runs last so the device ends the run holding the exact build
|
|
1431
|
+
// that was proven.
|
|
1432
|
+
stepsForProfile.release = [...stepsForProfile.ci, stepAuditCadence, stepReleaseSmoke];
|
|
1433
|
+
|
|
1434
|
+
if (!stepsForProfile[profile]) {
|
|
1435
|
+
console.error(`Unknown profile "${profile}" — use scaffold | local | ci | release.`);
|
|
1436
|
+
process.exit(2);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
// ── Bare --determinism: the probe, nothing else, and NO receipt ─────────────
|
|
1440
|
+
// "Run it alone" means alone: no other steps, and deliberately no
|
|
1441
|
+
// qa/evidence/latest.json. The done-gate (qa/receipt-check.mjs) validates a
|
|
1442
|
+
// receipt by verdict + content hash — a receipt whose steps are one probe
|
|
1443
|
+
// would satisfy it while attesting almost nothing, so a probe-only run must
|
|
1444
|
+
// never mint one. The lane marker IS still stamped: the probe runs Gradle
|
|
1445
|
+
// and owes the preview daemon the same coexistence courtesy as the lane.
|
|
1446
|
+
if (determinism && !profileExplicit) {
|
|
1447
|
+
fs.mkdirSync(path.dirname(LANE_MARKER), { recursive: true });
|
|
1448
|
+
fs.writeFileSync(LANE_MARKER, `${process.pid} ${new Date().toISOString()}\n`);
|
|
1449
|
+
let probe;
|
|
1450
|
+
try {
|
|
1451
|
+
probe = stepDeterminism();
|
|
1452
|
+
} finally {
|
|
1453
|
+
fs.rmSync(LANE_MARKER, { force: true });
|
|
1454
|
+
}
|
|
1455
|
+
if (asJson) {
|
|
1456
|
+
console.log(JSON.stringify(probe, null, 2));
|
|
1457
|
+
} else {
|
|
1458
|
+
const mark = probe.verdict === "PASS" ? "✓" : "✗";
|
|
1459
|
+
console.log(`${mark} determinism: ${probe.verdict}${probe.note ? ` (${probe.note})` : ""}${probe.reason ? ` — ${probe.reason}` : ""}`);
|
|
1460
|
+
console.log("\n(probe-only run — no receipt written; the full lane is where evidence is earned)");
|
|
1461
|
+
}
|
|
1462
|
+
process.exit(probe.verdict === "FAIL" ? 1 : 0);
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
// ── --fast: the inner loop, mechanically unable to claim done ───────────────
|
|
1466
|
+
// The genuinely slow tier is device/release work — every DEVICE_STEPS entry
|
|
1467
|
+
// (Gradle install + emulator + Maestro + instrumented runner) plus
|
|
1468
|
+
// releaseBuild (R8 + lintVital, the slow release COMPILE). --fast filters
|
|
1469
|
+
// that tier out of whatever profile resolved, UNCONDITIONALLY — device
|
|
1470
|
+
// attached or not — so a small change gets its did-I-break-anything-obvious
|
|
1471
|
+
// signal in JVM time. The rest of the profile still runs — but cheaply: the
|
|
1472
|
+
// pure-Node steps reuse an unchanged PASS from the step cache (CACHED — see
|
|
1473
|
+
// the memoization block above), the Gradle test steps drop --rerun (see
|
|
1474
|
+
// RERUN above), and unitTests scopes itself to the working-tree change
|
|
1475
|
+
// (see stepUnitTests). The loophole is closed at the receipt, not by
|
|
1476
|
+
// convention: mode "fast" is
|
|
1477
|
+
// recorded, no evidence rung is derived (qa/lib/evidence-level.mjs), and
|
|
1478
|
+
// qa/receipt-check.mjs refuses a fast receipt as done evidence.
|
|
1479
|
+
const FAST_EXCLUDED_NAMES = [...DEVICE_STEPS, "releaseBuild"];
|
|
1480
|
+
const STEP_FN_BY_NAME = {
|
|
1481
|
+
e2eSmoke: stepE2eSmoke,
|
|
1482
|
+
tokenDrift: stepTokenDrift,
|
|
1483
|
+
androidChecks: stepAndroidChecks,
|
|
1484
|
+
releaseSmoke: stepReleaseSmoke,
|
|
1485
|
+
releaseBuild: stepReleaseBuild,
|
|
1486
|
+
};
|
|
1487
|
+
for (const name of FAST_EXCLUDED_NAMES) {
|
|
1488
|
+
if (!STEP_FN_BY_NAME[name]) {
|
|
1489
|
+
// Drift guard: a new device-tier step must be mapped here or --fast would silently run it.
|
|
1490
|
+
console.error(`internal: fast-excluded step "${name}" has no entry in STEP_FN_BY_NAME — fix qa/verify.mjs`);
|
|
1491
|
+
process.exit(2);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const FAST_EXCLUDED_FNS = new Set(FAST_EXCLUDED_NAMES.map((name) => STEP_FN_BY_NAME[name]));
|
|
1495
|
+
const laneSteps = fast
|
|
1496
|
+
? stepsForProfile[profile].filter((fn) => !FAST_EXCLUDED_FNS.has(fn))
|
|
1497
|
+
: stepsForProfile[profile];
|
|
1498
|
+
const fastExcluded = fast
|
|
1499
|
+
? FAST_EXCLUDED_NAMES.filter((name) => stepsForProfile[profile].includes(STEP_FN_BY_NAME[name]))
|
|
1500
|
+
: [];
|
|
1501
|
+
|
|
1502
|
+
if (fast) {
|
|
1503
|
+
console.error(
|
|
1504
|
+
[
|
|
1505
|
+
"⚡⚡ FAST MODE — INNER LOOP ONLY, NOT THE DONE-GATE ⚡⚡",
|
|
1506
|
+
` skipping the device/release tier: ${fastExcluded.join(", ") || "(none in this profile)"}`,
|
|
1507
|
+
' this run\'s receipt records mode "fast", earns no evidence rung, and can NEVER satisfy "done"',
|
|
1508
|
+
" run the full lane once (node qa/verify.mjs) before you finish",
|
|
1509
|
+
].join("\n"),
|
|
1510
|
+
);
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
// Stamp the lane marker for the run's duration (coexistence defense 1 above);
|
|
1514
|
+
// always removed, even on a failing step, so the eyes only ever defer briefly.
|
|
1515
|
+
fs.mkdirSync(path.dirname(LANE_MARKER), { recursive: true });
|
|
1516
|
+
fs.writeFileSync(LANE_MARKER, `${process.pid} ${new Date().toISOString()}\n`);
|
|
1517
|
+
const laneStartedAt = Date.now(); // for the flight-recorder entry's durationMs
|
|
1518
|
+
const steps = [];
|
|
1519
|
+
try {
|
|
1520
|
+
for (const step of laneSteps) {
|
|
1521
|
+
const result = step();
|
|
1522
|
+
steps.push(result);
|
|
1523
|
+
if (!asJson) {
|
|
1524
|
+
// CACHED (fast mode only — see the memoization block above) renders with
|
|
1525
|
+
// its own mark and "unchanged since" note so a reused verdict is never
|
|
1526
|
+
// mistakable for a fresh execution.
|
|
1527
|
+
const mark = result.verdict === "PASS" ? "✓" : result.verdict === "CACHED" ? "⚡" : result.verdict === "SKIP" ? "→" : "✗";
|
|
1528
|
+
console.log(`${mark} ${result.name}: ${result.verdict}${result.note ? ` (${result.note})` : ""}${result.reason ? ` — ${result.reason.split("\n")[0]}` : ""}`);
|
|
1529
|
+
}
|
|
1530
|
+
if (result.name === "build" && result.verdict === "FAIL") break; // nothing downstream is meaningful
|
|
1531
|
+
}
|
|
1532
|
+
} finally {
|
|
1533
|
+
fs.rmSync(LANE_MARKER, { force: true });
|
|
1534
|
+
// The device lease (if a device step took it) is held to the very end of the
|
|
1535
|
+
// run — see the scope decision at leaseDeviceForStep. Release is idempotent
|
|
1536
|
+
// and never deletes a foreign holder's lease.
|
|
1537
|
+
if (laneDeviceLease) releaseDeviceLease(laneDeviceLease);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
// CACHED counts as PASS for the lane verdict (it IS a prior PASS, reused only
|
|
1541
|
+
// in fast mode on an unchanged input set) — but it stays CACHED on the
|
|
1542
|
+
// receipt, visibly distinct, so a fast receipt can never be read as if every
|
|
1543
|
+
// step freshly executed.
|
|
1544
|
+
const verdict = steps.some((s) => s.verdict === "FAIL") ? "FAIL" : "PASS";
|
|
1545
|
+
|
|
1546
|
+
// Receipt STRENGTH — a desktop-only green and an on-device green are different
|
|
1547
|
+
// claims, and the difference should never live only in the SKIP lines. Device-
|
|
1548
|
+
// dependent steps that actually RAN (PASSed) are named on the receipt and in the
|
|
1549
|
+
// verdict line: "PASS (on-device: e2eSmoke)" vs "PASS (desktop-only)".
|
|
1550
|
+
// (DEVICE_STEPS itself is defined above the lane — it also drives --fast.)
|
|
1551
|
+
const onDeviceSteps = steps.filter((s) => DEVICE_STEPS.includes(s.name) && s.verdict === "PASS").map((s) => s.name);
|
|
1552
|
+
const strengthLabel = onDeviceSteps.length ? `on-device: ${onDeviceSteps.join("+")}` : "desktop-only";
|
|
1553
|
+
|
|
1554
|
+
// Receipt RUNG — the evidence ladder (qa/lib/evidence-level.mjs): the coarse,
|
|
1555
|
+
// named grade (L0 scaffold / L1 desktop / L2 device / L3 release) DERIVED from
|
|
1556
|
+
// which steps actually ran and PASSed. The strength string above stays as the
|
|
1557
|
+
// fine print; the rung is added alongside, never in place of it. null on FAIL —
|
|
1558
|
+
// a failed lane has no rung. null on a --fast run too: the inner loop is a
|
|
1559
|
+
// signal, never evidence, so a fast receipt derives NO rung at all.
|
|
1560
|
+
const level = evidenceLevel(steps, profile, { mode });
|
|
1561
|
+
|
|
1562
|
+
// Artifacts: hash whatever the run left under qa-artifacts/ (never committed).
|
|
1563
|
+
const artifacts = [];
|
|
1564
|
+
if (fs.existsSync(ARTIFACTS_DIR)) {
|
|
1565
|
+
const walk = (dir) => {
|
|
1566
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
1567
|
+
const p = path.join(dir, entry.name);
|
|
1568
|
+
if (entry.isDirectory()) walk(p);
|
|
1569
|
+
else artifacts.push({ path: path.relative(ROOT, p), sha256: createHash("sha256").update(fs.readFileSync(p)).digest("hex") });
|
|
1570
|
+
}
|
|
1571
|
+
};
|
|
1572
|
+
walk(ARTIFACTS_DIR);
|
|
1573
|
+
artifacts.sort((a, b) => a.path.localeCompare(b.path));
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
// Bind the receipt to the content of the verified surface (ADR-0005), NOT the
|
|
1577
|
+
// parent SHA (rebase/merge-fragile). Must be computed before latest.json is
|
|
1578
|
+
// written — the receipt is an output and must never hash itself.
|
|
1579
|
+
/**
|
|
1580
|
+
* The receipt's harness summary — compact by design. The per-file detail lives
|
|
1581
|
+
* on the harnessIntegrity step; this is the part a receipt-holder needs to
|
|
1582
|
+
* identify the lane, plus the names of any modified files (an auditor told
|
|
1583
|
+
* "not intact" and not told which files has been given a rumour, not a fact).
|
|
1584
|
+
*/
|
|
1585
|
+
function harnessForReceipt() {
|
|
1586
|
+
const row = steps.find((st) => st.name === "harnessIntegrity");
|
|
1587
|
+
const r = row?.harness ?? checkHarnessIntegrity(ROOT);
|
|
1588
|
+
const summary = {
|
|
1589
|
+
name: r.name,
|
|
1590
|
+
version: r.version,
|
|
1591
|
+
sha256: r.sha256,
|
|
1592
|
+
status: r.status,
|
|
1593
|
+
intact: r.status === "intact",
|
|
1594
|
+
};
|
|
1595
|
+
if (r.status === "modified") {
|
|
1596
|
+
summary.modified = r.modified;
|
|
1597
|
+
summary.missing = r.missing;
|
|
1598
|
+
summary.extra = r.extra;
|
|
1599
|
+
}
|
|
1600
|
+
return summary;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
const inputs = computeInputsHash(ROOT);
|
|
1604
|
+
|
|
1605
|
+
// The receipt. Deterministic key order; ONE volatile timestamp field.
|
|
1606
|
+
// commit.sha is the parent HEAD at run time (you cannot know the sha of the
|
|
1607
|
+
// commit the receipt will be part of); commit.dirty lists what was uncommitted.
|
|
1608
|
+
const receipt = {
|
|
1609
|
+
schema: "cmp-evidence/1",
|
|
1610
|
+
profile,
|
|
1611
|
+
// "full" is the done-gate; "fast" (--fast) excluded the device/release tier
|
|
1612
|
+
// and is REFUSED by qa/receipt-check.mjs — a fast run can never end a session
|
|
1613
|
+
// as "done". Receipts predating this field are treated as full.
|
|
1614
|
+
mode,
|
|
1615
|
+
verdict,
|
|
1616
|
+
commit: {
|
|
1617
|
+
sha: tryGit("rev-parse HEAD"),
|
|
1618
|
+
dirty: tryGitLines("status --porcelain").map((l) => l.slice(3)).sort(),
|
|
1619
|
+
},
|
|
1620
|
+
inputs: {
|
|
1621
|
+
hash: inputs.hash,
|
|
1622
|
+
fileCount: inputs.fileCount,
|
|
1623
|
+
},
|
|
1624
|
+
steps,
|
|
1625
|
+
// WHICH LANE issued this verdict. A receipt that cannot name its own harness
|
|
1626
|
+
// can only be checked against the tree it came from; naming the version and
|
|
1627
|
+
// the region digest lets a third party who holds the receipt ask the harder
|
|
1628
|
+
// question — was this the real published lane? — without the tree at all.
|
|
1629
|
+
//
|
|
1630
|
+
// `intact` is the LOCAL claim only: unmodified since installed. It is a
|
|
1631
|
+
// checksum, not a signature, and someone who edits the lane can edit this
|
|
1632
|
+
// too. What they cannot edit is what the registry published under that
|
|
1633
|
+
// version, which is why `version` + `sha256` travel together.
|
|
1634
|
+
harness: harnessForReceipt(),
|
|
1635
|
+
strength: { onDeviceSteps },
|
|
1636
|
+
evidenceLevel: level,
|
|
1637
|
+
artifacts,
|
|
1638
|
+
toolVersions: {
|
|
1639
|
+
node: process.version,
|
|
1640
|
+
platform: `${process.platform}-${process.arch}`,
|
|
1641
|
+
},
|
|
1642
|
+
generatedAt: new Date().toISOString(),
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
fs.mkdirSync(EVIDENCE_DIR, { recursive: true });
|
|
1646
|
+
fs.writeFileSync(path.join(EVIDENCE_DIR, "latest.json"), `${JSON.stringify(receipt, null, 2)}\n`);
|
|
1647
|
+
// latest.json is the single receipt-of-record. Commit it with your change: the
|
|
1648
|
+
// studio console's Evidence audit trail reconstructs the full history from the
|
|
1649
|
+
// git log of this file — every commit is one verified, attributed state.
|
|
1650
|
+
|
|
1651
|
+
// The README's evidence badge is DERIVED from the receipt just written — an
|
|
1652
|
+
// output, never a gate, so it runs after the verdict and cannot change it. It
|
|
1653
|
+
// renders the rung together with the commit it was attested against, so the
|
|
1654
|
+
// sentence stays true as the tree moves on (qa/lib/evidence-badge.mjs).
|
|
1655
|
+
const badge = updateReadmeBadge(ROOT);
|
|
1656
|
+
|
|
1657
|
+
// ── Flight recorder (roadmap §10 item 5) — the lane journals its own run ────
|
|
1658
|
+
// One JSON line per run into qa/flight-recorder.jsonl (committed, and
|
|
1659
|
+
// excluded from the receipt's hashed surface — qa/lib/flight-recorder.mjs
|
|
1660
|
+
// carries the whole rationale). Appended AFTER the receipt so the entry
|
|
1661
|
+
// records the final verdict and rung. A failed append must never fail the
|
|
1662
|
+
// lane — a recorder that breaks the thing it observes is worse than no
|
|
1663
|
+
// recorder — so the failure degrades to a note in the lane's own output,
|
|
1664
|
+
// which is itself the honest record of the degradation.
|
|
1665
|
+
//
|
|
1666
|
+
// --no-journal is the ONE exemption, and qa/watch.mjs passes it on every
|
|
1667
|
+
// save-triggered run. Same rule the README badge obeys, for the same reason:
|
|
1668
|
+
// THE INNER LOOP DOES NOT WRITE TO COMMITTED FILES. A watcher journaling every
|
|
1669
|
+
// save would add hundreds of lines a day to a committed file — turning the
|
|
1670
|
+
// app's history into keystroke noise and leaving a permanently-dirty tree in
|
|
1671
|
+
// the loop the recorder exists to observe. What survives is every full lane
|
|
1672
|
+
// and every DELIBERATE fast run, which is what the retrospective's questions
|
|
1673
|
+
// actually rest on (SKIP reasons, degraded paths, the longest stretch with no
|
|
1674
|
+
// full lane). qa/retrospective.mjs discloses the exemption in its own output
|
|
1675
|
+
// so the fast-vs-full ratio is never read as a complete census.
|
|
1676
|
+
const flight = noJournal
|
|
1677
|
+
? { ok: true, skipped: true }
|
|
1678
|
+
: appendFlightRecord(
|
|
1679
|
+
ROOT,
|
|
1680
|
+
buildFlightEntry({
|
|
1681
|
+
profile,
|
|
1682
|
+
mode,
|
|
1683
|
+
verdict,
|
|
1684
|
+
evidenceLevel: level,
|
|
1685
|
+
steps,
|
|
1686
|
+
sha: receipt.commit.sha,
|
|
1687
|
+
durationMs: Date.now() - laneStartedAt,
|
|
1688
|
+
onDeviceSteps,
|
|
1689
|
+
degraded: DEGRADED_PATHS,
|
|
1690
|
+
}),
|
|
1691
|
+
);
|
|
1692
|
+
if (!flight.ok) {
|
|
1693
|
+
console.error(`· flight recorder: journal append failed (${flight.reason}) — the lane verdict is unaffected, but this run is missing from qa/flight-recorder.jsonl`);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
if (asJson) {
|
|
1697
|
+
console.log(JSON.stringify(receipt, null, 2));
|
|
1698
|
+
if (fast) {
|
|
1699
|
+
console.error(`⚡⚡ FAST MODE verdict: ${verdict} — INNER LOOP ONLY, not done. Skipped: ${fastExcluded.join(", ") || "(none)"}. Run the full lane (node qa/verify.mjs) before you finish.`);
|
|
1700
|
+
}
|
|
1701
|
+
} else if (fast) {
|
|
1702
|
+
// Deliberately NOT the full lane's verdict-line shape: fast-green must never
|
|
1703
|
+
// be mistakable for done-green.
|
|
1704
|
+
console.log(
|
|
1705
|
+
`\n${verdict === "PASS" ? "⚡⚡" : "❌"} verify lane [FAST — INNER LOOP ONLY, NOT DONE]: ${verdict} (skipped device/release tier: ${fastExcluded.join(", ") || "none"}) — this fast receipt satisfies no done-gate; run the full lane (node qa/verify.mjs) once before you finish`,
|
|
1706
|
+
);
|
|
1707
|
+
} else {
|
|
1708
|
+
console.log(`\n${verdict === "PASS" ? "✅" : "❌"} verify lane: ${verdict}${level ? ` · ${level.rung} ${level.name}` : ""} (${strengthLabel}) — receipt written to qa/evidence/latest.json${badge.changed ? ` and ${README_REL_PATH}'s evidence badge refreshed` : ""} (commit ${badge.changed ? "them" : "it"} with your change)`);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
// The audit-cadence nudges print in the human path, not only inside the
|
|
1712
|
+
// receipt JSON — a ship-time report that lives only in a JSON field is a
|
|
1713
|
+
// report nobody reads at ship time. Nudges only; a gate this is not.
|
|
1714
|
+
if (!asJson) {
|
|
1715
|
+
const auditStep = steps.find((s) => s.name === "auditCadence");
|
|
1716
|
+
const auditLines = auditStep?.details?.lines ?? [];
|
|
1717
|
+
if (auditLines.length > 0) {
|
|
1718
|
+
console.log("\naudit cadence (report, never a gate):");
|
|
1719
|
+
for (const l of auditLines) console.log(` ${l}`);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
process.exit(verdict === "PASS" ? 0 : 1);
|