forgedock 1.53.0 → 1.54.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/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +258 -0
- package/bin/auth/app-token.test.mjs +240 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +6 -3
- package/bin/engine/telemetry-seam.mjs +8 -2
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +57 -20
- package/bin/first-run.mjs +122 -0
- package/bin/forgedock.mjs +128 -146
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/activation.mjs +18 -0
- package/bin/lean/activation.test.mjs +23 -1
- package/bin/lean/batch-health.mjs +74 -1
- package/bin/lean/batch-health.test.mjs +54 -1
- package/bin/lean/batch.test.mjs +11 -9
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +7 -0
- package/bin/lean/conformance.mjs +77 -19
- package/bin/lean/conformance.test.mjs +129 -3
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +40 -11
- package/bin/lean/execution.test.mjs +24 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.test.mjs +1 -1
- package/bin/lean/issuewatch.mjs +34 -5
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lean.mjs +316 -74
- package/bin/lean/lean.test.mjs +397 -24
- package/bin/lean/mechfix.mjs +136 -0
- package/bin/lean/mechfix.test.mjs +95 -0
- package/bin/lean/orchestrate.mjs +20 -2
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +69 -12
- package/bin/lean/recovery.test.mjs +1 -1
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +6 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +8 -7
- package/bin/lean/release-review.mjs +67 -11
- package/bin/lean/release-review.test.mjs +128 -1
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +87 -13
- package/bin/lean/release.test.mjs +104 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/schedd.mjs +34 -1
- package/bin/lean/schedd.test.mjs +21 -1
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/pool/agent.mjs +9 -0
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +8 -4
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +100 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +49 -7
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +100 -19
- package/bin/stats/conformance-outcomes.test.mjs +87 -1
- package/bin/stats/depth.mjs +88 -31
- package/bin/stats/depth.test.mjs +63 -38
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +51 -13
- package/bin/stats/index.mjs +91 -15
- package/bin/stats/local-source.mjs +1 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-staging.md +4 -1
- package/commands/work-on/close.md +8 -0
- package/docs/CI.md +1 -1
- package/docs/CONFIG.md +105 -10
- package/docs/ISSUE-WATCH.md +23 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +19 -2
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { test } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { writeFileSync, readFileSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { tmpDir } from "../tests/_tmp.mjs";
|
|
8
|
+
import { parseForgeYaml } from "../forge-utils.mjs";
|
|
9
|
+
import { parseIntegration } from "./integration.mjs";
|
|
10
|
+
import {
|
|
11
|
+
parseCiPolicy, sumUsage, project, detectBudget, resolveCiMode, formatBudgetLine, coerceVerify, writeEffective, hitRates, remoteSuites,
|
|
12
|
+
attestPayload, recordHostCheck, budgetAlerts, formatDigest, writeCiBlock, ciFromCli, budgetReportLine, effectiveModeSync, readParity,
|
|
13
|
+
} from "./ci-budget.mjs";
|
|
14
|
+
|
|
15
|
+
const tmp = () => tmpDir("cib-");
|
|
16
|
+
const NOW = Date.parse("2026-11-10T12:00:00Z"); // day 10 of 30
|
|
17
|
+
const item = (q, o = {}) => ({ product: "actions", unitType: "Minutes", sku: "actions_linux", quantity: q, repositoryName: "AlterLab", ...o });
|
|
18
|
+
/** gh stub: repo meta, billing usage, org plan. */
|
|
19
|
+
const ghFor = ({ priv = true, org = true, items = [item(15000)], plan = "enterprise", usageFails = false } = {}) => async (a) => {
|
|
20
|
+
const u = a.join(" ");
|
|
21
|
+
if (/^api repos\/[^/]+\/[^/]+$/.test(u)) return JSON.stringify({ private: priv, owner: { login: "Acme", type: org ? "Organization" : "User" } });
|
|
22
|
+
if (/settings\/billing\/usage/.test(u)) { if (usageFails) throw new Error("HTTP 403"); return JSON.stringify({ usageItems: items }); }
|
|
23
|
+
if (/^api (orgs\/|user$)/.test(u)) return JSON.stringify({ plan: { name: plan } });
|
|
24
|
+
throw new Error(`unexpected ${u}`);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
test("parseCiPolicy: defaults, flat keys, junk ignored", () => {
|
|
28
|
+
assert.deepEqual(parseCiPolicy(null), { mode: "auto", monthlyMinutes: null, reservePct: 10, includedMinutes: null, plan: null });
|
|
29
|
+
const p = parseCiPolicy({ mode: "local-first", monthly_minutes: "2000", reserve_pct: "20", plan: "Free" });
|
|
30
|
+
assert.equal(p.mode, "local-first"); assert.equal(p.monthlyMinutes, 2000); assert.equal(p.reservePct, 20); assert.equal(p.plan, "free");
|
|
31
|
+
assert.equal(parseCiPolicy({ mode: "bogus", monthly_minutes: "-3", reserve_pct: "99" }).mode, "auto");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("usage sums actions minutes with OS rates; projection is linear", () => {
|
|
35
|
+
const u = sumUsage({ usageItems: [item(100), item(10, { sku: "actions_macos", repositoryName: "B" }), { product: "copilot", quantity: 999 }] });
|
|
36
|
+
assert.equal(u.total, 200); assert.equal(u.byRepo.B, 100);
|
|
37
|
+
assert.equal(project(15000, NOW).projected, 45000);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("private Enterprise repo: over budget in auto switches to local-first and the report says so", async () => {
|
|
41
|
+
const policy = parseCiPolicy({ monthly_minutes: "40000" });
|
|
42
|
+
const facts = await detectBudget({ gh: ghFor(), repo: "Acme/AlterLab", policy, now: NOW });
|
|
43
|
+
assert.equal(facts.mtd, 15000); assert.equal(facts.projected, 45000); assert.equal(facts.plan, "enterprise");
|
|
44
|
+
const res = resolveCiMode({ policy, facts });
|
|
45
|
+
assert.equal(res.effective, "local-first"); assert.equal(res.switched, true);
|
|
46
|
+
const line = formatBudgetLine({ res, facts, release: { runs: 1, minutes: 78 } });
|
|
47
|
+
assert.match(line, /this release: 1 CI run, 78 min/); assert.match(line, /auto -> local-first/); assert.match(line, /month: 15k\/40k, projected 45k/); assert.match(line, /SWITCHED/);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("under budget stays remote; plan table supplies the included minutes", async () => {
|
|
51
|
+
const policy = parseCiPolicy(null);
|
|
52
|
+
const facts = await detectBudget({ gh: ghFor({ items: [item(5000)] }), repo: "Acme/x", policy, now: NOW });
|
|
53
|
+
assert.equal(facts.budget, 50000);
|
|
54
|
+
assert.equal(resolveCiMode({ policy, facts }).effective, "remote");
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test("public repo: free hosted minutes, never auto-switched even over any budget", async () => {
|
|
58
|
+
const policy = parseCiPolicy({ monthly_minutes: "10" });
|
|
59
|
+
const facts = await detectBudget({ gh: ghFor({ priv: false }), repo: "Acme/pub", policy, now: NOW });
|
|
60
|
+
const res = resolveCiMode({ policy, facts });
|
|
61
|
+
assert.equal(res.effective, "remote"); assert.equal(res.switched, false); assert.equal(res.free, true);
|
|
62
|
+
assert.match(formatBudgetLine({ res, facts }), /free hosted minutes/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("billing API failure is fail-soft: remote, usage unknown", async () => {
|
|
66
|
+
const policy = parseCiPolicy(null);
|
|
67
|
+
const facts = await detectBudget({ gh: ghFor({ usageFails: true }), repo: "Acme/x", policy, now: NOW });
|
|
68
|
+
const res = resolveCiMode({ policy, facts });
|
|
69
|
+
assert.equal(facts.usage, null); assert.equal(res.effective, "remote"); assert.match(res.reason, /unknown/);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("configured local-attested is honoured as is", () => {
|
|
73
|
+
const res = resolveCiMode({ policy: parseCiPolicy({ mode: "local-attested" }), facts: null });
|
|
74
|
+
assert.equal(res.effective, "local-attested");
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("local-first coerces verify.mode ci|hybrid to local; remote leaves it", () => {
|
|
78
|
+
const cwd = tmp(), dir = tmp();
|
|
79
|
+
writeFileSync(join(cwd, "forge.yaml"), "ci:\n mode: local-first\n");
|
|
80
|
+
assert.equal(coerceVerify({ mode: "ci" }, { cwd, dir }).mode, "local");
|
|
81
|
+
assert.equal(coerceVerify({ mode: "hybrid" }, { cwd, dir }).mode, "local");
|
|
82
|
+
assert.equal(coerceVerify({ mode: "local" }, { cwd, dir }).mode, "local");
|
|
83
|
+
writeFileSync(join(cwd, "forge.yaml"), "ci:\n mode: remote\n");
|
|
84
|
+
assert.equal(coerceVerify({ mode: "ci" }, { cwd, dir }).mode, "ci");
|
|
85
|
+
writeFileSync(join(cwd, "forge.yaml"), "verify:\n mode: ci\n"); // no ci block: auto with no cache = remote (unchanged default)
|
|
86
|
+
assert.equal(coerceVerify({ mode: "ci" }, { cwd, dir }).mode, "ci");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test("auto uses the cached resolution of the budget check", () => {
|
|
90
|
+
const cwd = tmp(), dir = tmp();
|
|
91
|
+
writeFileSync(join(cwd, "forge.yaml"), "ci:\n mode: auto\n");
|
|
92
|
+
assert.equal(effectiveModeSync({ cwd, dir, now: NOW }), "remote");
|
|
93
|
+
writeEffective({ cwd, dir, now: NOW, res: { effective: "local-first", configured: "auto", switched: true, reason: "x" } });
|
|
94
|
+
assert.equal(coerceVerify({ mode: "ci" }, { cwd, dir, now: NOW }).mode, "local");
|
|
95
|
+
assert.equal(effectiveModeSync({ cwd, dir, now: NOW + 3 * 86400000 }), "remote"); // stale cache ignored
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("parity: hit rate counts local green -> remote red per suite", () => {
|
|
99
|
+
const rows = [
|
|
100
|
+
{ local: { unit: "pass", lint: "pass" }, remote: { unit: "fail", lint: "pass" } },
|
|
101
|
+
{ local: { unit: "pass" }, remote: { unit: "pass" } },
|
|
102
|
+
{ local: { unit: "fail" }, remote: { unit: "fail" } },
|
|
103
|
+
];
|
|
104
|
+
const r = hitRates(rows);
|
|
105
|
+
assert.deepEqual([r.unit.greenLocal, r.unit.redRemote, r.lint.redRemote], [2, 1, 0]);
|
|
106
|
+
assert.deepEqual(remoteSuites({ check_runs: [{ name: "a", conclusion: "success" }, { name: "b", conclusion: "failure" }, { name: "c", conclusion: null }] }), { a: "pass", b: "fail" });
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
test("recordHostCheck appends a parity row and posts the attested status only in local-attested", async () => {
|
|
110
|
+
const dir = tmp(), calls = [];
|
|
111
|
+
const gh = async (a) => { calls.push(a.join(" ")); return JSON.stringify({ nameWithOwner: "Acme/x" }); };
|
|
112
|
+
await recordHostCheck({ cwd: dir, head: "abc123", ok: true, suites: [{ name: "unit", ok: true }], gh, dir, mode: "local-first" });
|
|
113
|
+
assert.equal(calls.length, 0); assert.deepEqual(readParity(dir)[0].local, { unit: "pass" });
|
|
114
|
+
await recordHostCheck({ cwd: dir, head: "abc123", ok: false, suites: [{ name: "unit", ok: false }], gh, dir, mode: "local-attested" });
|
|
115
|
+
assert.ok(calls.some((c) => /api repos\/Acme\/x\/statuses\/abc123 .*state=failure .*context=forgedock\/ci-local/.test(c)));
|
|
116
|
+
assert.equal(attestPayload({ ok: true, suites: [] }).state, "success");
|
|
117
|
+
await recordHostCheck({ cwd: dir, head: "h", ok: true, suites: [], gh: async () => { throw new Error("boom"); }, dir, mode: "local-attested" }); // fail-soft
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test("alerts: projected overage and a new burn source; digest lists repos", () => {
|
|
121
|
+
const usage = sumUsage({ usageItems: [item(9000), item(4000, { repositoryName: "Flipped" })] });
|
|
122
|
+
const facts = { budget: 20000, projected: 39000, usage, mtd: 13000, owner: "Acme" };
|
|
123
|
+
const alerts = budgetAlerts({ facts, seen: ["AlterLab"] });
|
|
124
|
+
assert.ok(alerts.some((a) => /projected overage/.test(a))); assert.ok(alerts.some((a) => /new burn source: Flipped/.test(a)));
|
|
125
|
+
assert.equal(budgetAlerts({ facts, seen: null }).some((a) => /new burn/.test(a)), false);
|
|
126
|
+
assert.match(formatDigest(facts), /AlterLab: 9\.0k min/);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("writeCiBlock: plain-language setup writes a valid ci block, keeping milestone_integration keys", () => {
|
|
130
|
+
const raw = "project:\n name: x\nci:\n milestone_integration:\n workflow: e2e.yml\n interval_hours: 12\nverify:\n mode: local\n";
|
|
131
|
+
const out = writeCiBlock(raw, { mode: "local-first", monthly_minutes: 2000, reserve_pct: 15 });
|
|
132
|
+
const p = parseForgeYaml(out);
|
|
133
|
+
assert.equal(parseCiPolicy(p.ci).mode, "local-first"); assert.equal(parseCiPolicy(p.ci).monthlyMinutes, 2000); assert.equal(parseCiPolicy(p.ci).reservePct, 15);
|
|
134
|
+
assert.equal(parseIntegration(p.ci).workflow, "e2e.yml"); assert.equal(parseIntegration(p.ci).intervalHours, 12);
|
|
135
|
+
assert.equal(p.verify.mode, "local");
|
|
136
|
+
assert.equal(parseCiPolicy(parseForgeYaml(writeCiBlock("a: b\n", { mode: "auto" })).ci).mode, "auto"); // creates the block
|
|
137
|
+
const again = parseForgeYaml(writeCiBlock(out, { mode: "remote" }));
|
|
138
|
+
assert.equal(again.ci.mode, "remote"); assert.equal(again.ci.monthly_minutes, "2000");
|
|
139
|
+
assert.throws(() => writeCiBlock(raw, { mode: "fast" }), /ci.mode/);
|
|
140
|
+
assert.throws(() => writeCiBlock(raw, { monthly_minutes: "abc" }), /positive integer/);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test("forgedock ci budget prints plan, included, month-to-date, projection and the active mode; flags write forge.yaml", async () => {
|
|
144
|
+
const cwd = tmp(), dir = tmp(), lines = [];
|
|
145
|
+
writeFileSync(join(cwd, "forge.yaml"), "project:\n name: x\n");
|
|
146
|
+
const gh = async (a) => (a[0] === "repo" ? JSON.stringify({ nameWithOwner: "Acme/AlterLab" }) : ghFor({ items: [item(40000)] })(a));
|
|
147
|
+
const code = await ciFromCli(["budget", "--set-mode", "auto", "--budget", "40000"], { cwd, dir, gh, now: NOW, out: (l) => lines.push(l) });
|
|
148
|
+
const text = lines.join("\n");
|
|
149
|
+
assert.equal(code, 0);
|
|
150
|
+
assert.match(text, /plan: enterprise; included minutes: 50000; budget: 40000/);
|
|
151
|
+
assert.match(text, /month-to-date \(all repos of Acme\): 40000 min; burn 4000\/day; projected 120000/);
|
|
152
|
+
assert.match(text, /mode: auto -> local-first/);
|
|
153
|
+
assert.match(readFileSync(join(cwd, "forge.yaml"), "utf8"), /ci:\n {2}mode: auto\n {2}monthly_minutes: 40000/);
|
|
154
|
+
const j = []; await ciFromCli(["budget", "--json"], { cwd, dir, gh, now: NOW, out: (l) => j.push(l) });
|
|
155
|
+
assert.equal(JSON.parse(j.join("")).mode, "local-first");
|
|
156
|
+
await assert.rejects(() => ciFromCli(["budget", "--nope"], { cwd, dir, gh }), /unknown option/);
|
|
157
|
+
await assert.rejects(() => ciFromCli(["other"], { cwd, dir, gh }), /usage/);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
test("budgetReportLine never throws and caches the effective mode for the next lane", async () => {
|
|
161
|
+
const cwd = tmp(), dir = tmp();
|
|
162
|
+
writeFileSync(join(cwd, "forge.yaml"), "ci:\n monthly_minutes: 1000\n");
|
|
163
|
+
const line = await budgetReportLine({ cwd, dir, repo: "Acme/x", gh: ghFor(), now: NOW });
|
|
164
|
+
assert.match(line, /auto -> local-first/);
|
|
165
|
+
assert.equal(effectiveModeSync({ cwd, dir, now: NOW }), "local-first");
|
|
166
|
+
assert.match(await budgetReportLine({ cwd, dir, repo: "Acme/x", gh: async () => { throw new Error("no gh"); }, now: NOW }), /^ci: auto \(remote\) \(usage unknown/);
|
|
167
|
+
});
|
|
@@ -267,6 +267,13 @@ describe("conformance gate end-to-end (real git, disposable repo)", { skip: !HAV
|
|
|
267
267
|
assert.ok(o.log.some((e) => e.event === "PRECHECK" && e.failures.includes("conformance.unimplemented")));
|
|
268
268
|
assert.match(o.ret.detail, /topology\.route_reachability[\s\S]*\/api\/v1\/agent\/signup\/pending[\s\S]*unreachable: \/api\/v1\/agent\/signup\/pending -> api/);
|
|
269
269
|
});
|
|
270
|
+
it("#5284 a declared topology.prod_parity surface touched without a check result or justification blocks before merge", async () => {
|
|
271
|
+
const o = await runCase({ contract: ROUTED, impl: addRoute }, "enforce", { runCommand: runCheckCommand, opts: { prodParity: { "web/src/app/**": "note: exercise the page under the production runtime" }, verify: { maxRounds: 0 } } });
|
|
272
|
+
assert.equal(o.staging.search, false, "staging untouched");
|
|
273
|
+
assert.equal(o.ret.terminalReason, "needs-human"); assert.equal(o.pr, undefined, "no PR");
|
|
274
|
+
assert.ok(o.log.some((e) => e.event === "PRECHECK" && e.failures.includes("conformance.unimplemented")));
|
|
275
|
+
assert.match(o.ret.detail, /topology\.prod_parity/);
|
|
276
|
+
});
|
|
270
277
|
it("6 a generic PASS over an incomplete implementation never merges (review.incomplete)", async () => {
|
|
271
278
|
const o = await runCase({ contract: FULL, impl: (t) => fix(t, ["scrape", "export"]), generic: true });
|
|
272
279
|
blocked(o, "review.incomplete"); assert.deepEqual([o.counts.builder, o.counts.reviewer], [2, 2]);
|
package/bin/lean/conformance.mjs
CHANGED
|
@@ -188,12 +188,16 @@ export function pathCovers(d, f) {
|
|
|
188
188
|
if (/[*?]/.test(p)) return globRe(p).test(file);
|
|
189
189
|
return p === file;
|
|
190
190
|
}
|
|
191
|
+
/** #5365: explicit coupling map: editing `when` (a deliverable) also puts `also` in scope (a test asserts parity between them). */
|
|
192
|
+
const COUPLED_PATHS = [{ when: "bin/engine/outcome-codes.mjs", also: ["docs/OUTCOME-CODES.md"] }];
|
|
191
193
|
/** The deliverable id that authorizes `f`, "test", "incidental", or null. */
|
|
192
194
|
export function authorizationOf(contract, f) {
|
|
193
195
|
const d = (contract.deliverables ?? []).find((x) => pathCovers(x.path, f));
|
|
194
196
|
if (d) return d.id;
|
|
195
197
|
if (isTestPath(f)) return "test";
|
|
196
198
|
if (isIncidentalPath(f)) return "incidental";
|
|
199
|
+
// #5365: a file a parity test reads alongside a changed deliverable is in scope with it
|
|
200
|
+
if (COUPLED_PATHS.some((c) => c.also.some((g) => pathCovers(g, f)) && (contract.deliverables ?? []).some((x) => pathCovers(x.path, c.when) || pathCovers(c.when, x.path)))) return "coupled";
|
|
197
201
|
return null;
|
|
198
202
|
}
|
|
199
203
|
// A doc a freshness rule can demand: a prose file under a docs directory. Build and dependency files (`requirements.txt`,
|
|
@@ -651,7 +655,12 @@ export function applyAmendments(frozen, amendments, issueText = null, { generate
|
|
|
651
655
|
applied.push({ kind: a.kind, target: r.id, why: String(a.why).trim() });
|
|
652
656
|
continue;
|
|
653
657
|
} else if (a.kind === "add-requirement" && a.requirement?.id && !blank(a.requirement?.quote)) {
|
|
654
|
-
if (c.requirements.some((r) => r.id === a.requirement.id)) {
|
|
658
|
+
if (c.requirements.some((r) => r.id === a.requirement.id)) {
|
|
659
|
+
// #5365: a taken id is renumbered to the next free R<n>, never a failure; the remap is recorded in `applied`
|
|
660
|
+
const was = a.requirement.id, free = `R${Math.max(0, ...c.requirements.map((r) => Number(/^R(\d+)$/.exec(String(r.id))?.[1] ?? 0))) + 1}`;
|
|
661
|
+
a = { ...a, requirement: { ...a.requirement, id: free } };
|
|
662
|
+
applied.push({ kind: "add-requirement", target: `${was} -> ${free}`, why: `id ${was} already in the contract; renumbered to ${free}` });
|
|
663
|
+
}
|
|
655
664
|
let snapTo = null;
|
|
656
665
|
if (issueText != null && !inIssue(a.requirement.quote, issueText)) {
|
|
657
666
|
snapTo = snapQuote(a.requirement.quote, issueText);
|
|
@@ -721,6 +730,24 @@ const PY_MISSING_RE = /ModuleNotFoundError: No module named '([^']+)'|ImportErro
|
|
|
721
730
|
const NODE_MISSING_RE = /Cannot find (?:module|package) '([^']+)'/;
|
|
722
731
|
const POETRY_NOT_FOUND_RE = /^\s*Command not found: (\S+)/m;
|
|
723
732
|
const CMD_NOT_FOUND_RE = /([^\s:'"`]+): command not found/, SH_NOT_FOUND_RE = /([^\s:'"`]+): not found\b/;
|
|
733
|
+
// #5371: exit-1 failures that are the executor's environment (no Docker daemon, a bind-mount source that is absent where the step runs,
|
|
734
|
+
// no Playwright browser, no network for npm), never a failing assertion of the change
|
|
735
|
+
const ENV_SIGNATURES = [
|
|
736
|
+
[/Cannot connect to the Docker daemon|docker\.sock|error during connect|Is the docker daemon running/i, "Docker daemon"],
|
|
737
|
+
[/invalid mount config for type "bind"|bind source path does not exist|error while creating mount source path|mounts denied/i, "Docker bind-mount source"],
|
|
738
|
+
[/Executable doesn't exist at|npx playwright install|browserType\.launch: Executable/i, "Playwright browser"],
|
|
739
|
+
[/\bENOTFOUND\b|\bEAI_AGAIN\b|npm (?:ERR!|error) network|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)/i, "network access for npm"],
|
|
740
|
+
];
|
|
741
|
+
const envSignature = (out) => { const hit = ENV_SIGNATURES.find(([re]) => re.test(out)); return hit ? { tool: hit[1], kind: "environment" } : null; };
|
|
742
|
+
const SECRET_PAIR_RE = /\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|CREDENTIAL)[A-Za-z0-9_]*\s*[=:]\s*)\S+/gi;
|
|
743
|
+
const SECRET_SHAPE_RE = /\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,}|sk-[A-Za-z0-9_-]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16})\b|Bearer\s+[A-Za-z0-9._~+/=-]{12,}/g;
|
|
744
|
+
/** #5371: the last `lines` lines of a command's output with secret-looking values redacted, as an indented block for a failure detail ("" when empty). */
|
|
745
|
+
export function outputTail(output, lines = 40) {
|
|
746
|
+
const t = String(output ?? "").replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").split("\n").map((l) => l.trimEnd());
|
|
747
|
+
while (t.length && !t[t.length - 1]) t.pop();
|
|
748
|
+
const tail = t.slice(-lines).join("\n").replace(SECRET_PAIR_RE, "$1[redacted]").replace(SECRET_SHAPE_RE, "[redacted]").slice(-4000);
|
|
749
|
+
return tail ? `\n output tail (last ${Math.min(lines, t.length)} lines):\n${tail.split("\n").map((l) => ` ${l}`).join("\n")}` : "";
|
|
750
|
+
}
|
|
724
751
|
/** #4857: why a command is not valid bash (`bash -n`), or null when it parses (or bash is unavailable). Catches prose left on a command. */
|
|
725
752
|
export function shellSyntaxError(command) {
|
|
726
753
|
const r = spawnSync("bash", ["-n", "-c", String(command ?? "")], { encoding: "utf8", timeout: 5000 });
|
|
@@ -882,7 +909,7 @@ export function resolveForgedockPaths(command, { exists = () => true, checksCli,
|
|
|
882
909
|
return here && !exists(tok) ? here : tok;
|
|
883
910
|
});
|
|
884
911
|
}
|
|
885
|
-
const KIND_NAME = { command: "command", "python-module": "Python module", "node-module": "Node package" };
|
|
912
|
+
const KIND_NAME = { command: "command", "python-module": "Python module", "node-module": "Node package", environment: "environment service" };
|
|
886
913
|
/**
|
|
887
914
|
* forge#4323: the host tool or module a failed command could not find, from its {rc, output}: bash/sh "X: command not found"
|
|
888
915
|
* (or rc 127), python "No module named x" (top-level package), node "Cannot find module|package 'x'" (bare specifiers only).
|
|
@@ -905,7 +932,7 @@ export function missingTool({ rc, output } = {}, { repoHas = () => false, comman
|
|
|
905
932
|
const po = POETRY_NOT_FOUND_RE.exec(out)?.[1]; // #5020: `poetry run pytest` in an env that was never installed
|
|
906
933
|
if (po) return local(po) ? null : { tool: po, kind: "command" };
|
|
907
934
|
const cmd = CMD_NOT_FOUND_RE.exec(out)?.[1] ?? (rc === 127 ? SH_NOT_FOUND_RE.exec(out)?.[1] ?? String(command).trim().split(/\s+/)[0] : null);
|
|
908
|
-
if (!cmd || cmd.includes("/") || local(cmd)) return
|
|
935
|
+
if (!cmd || cmd.includes("/") || local(cmd)) return envSignature(out); // #5371
|
|
909
936
|
return { tool: cmd, kind: "command" };
|
|
910
937
|
}
|
|
911
938
|
|
|
@@ -931,7 +958,7 @@ export function repoTracks(paths) {
|
|
|
931
958
|
* `ciCovered` (#4527): the validate ids accepted only because the head is CI-verified (no local result, or a missing host
|
|
932
959
|
* tool), for the trajectory; always an array.
|
|
933
960
|
*/
|
|
934
|
-
export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [] }) {
|
|
961
|
+
export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, prodParityFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [], uiBrowser = null }) {
|
|
935
962
|
const failures = [], superseded = [], ciCovered = [];
|
|
936
963
|
// #4626: a post-deploy check id must be on the default branch or added by this PR (`checkIds`: ids of both checks files; null = not resolved)
|
|
937
964
|
if (checkIds) for (const r of contract.requirements ?? []) {
|
|
@@ -939,6 +966,8 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
939
966
|
}
|
|
940
967
|
// #4769: a default-off rollout entry added by the diff needs an activation row
|
|
941
968
|
if (newOffKeys?.length) for (const f of activationFailures(contract, newOffKeys)) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, ...f });
|
|
969
|
+
// #5285: interactive UI changed on a high-risk surface with no real-browser check configured: a recorded skip that blocks
|
|
970
|
+
if (uiBrowser?.files?.length && uiBrowser.highRisk && !uiBrowser.ran) failures.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, kind: "ui_browser_unverified", detail: `interactive UI changed (${uiBrowser.files.slice(0, 5).join(", ")}) on a high-risk surface but no real-browser check runs (${uiBrowser.reason}); configure verify.e2e_label/e2e_workflow or add a Playwright spec` });
|
|
942
971
|
const outside = (k) => changedFiles.filter((f) => !ignore.some((p) => f.startsWith(p)) && !authorizationOf(k, f));
|
|
943
972
|
const creep = outside(contract);
|
|
944
973
|
const amendedOnly = frozenAmendedFiles(frozen, contract, outside, creep);
|
|
@@ -955,7 +984,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
955
984
|
const verdict = substituteVerdict(substitutedRuns?.[v.id], { repoHas, command: v.substituted.from });
|
|
956
985
|
const from = `validate ${v.id} substituted \`${v.command}\` for the frozen \`${v.substituted.from}\``;
|
|
957
986
|
if (verdict === "unverified") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "substitute_unverified", detail: `${from}, but the engine has no rerun of the frozen command to show it cannot run` }); continue; }
|
|
958
|
-
if (verdict === "runs") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `${from}, but the frozen command runs and fails (exit ${substitutedRuns[v.id].rc}): a substitute-validate replaces only a command that cannot run, never a failing check` }); continue; }
|
|
987
|
+
if (verdict === "runs") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `${from}, but the frozen command runs and fails (exit ${substitutedRuns[v.id].rc}): a substitute-validate replaces only a command that cannot run, never a failing check${outputTail(substitutedRuns[v.id].output)}` }); continue; }
|
|
959
988
|
if (verdict === "timeout" && !ciVerified) { failures.push({ code: ENV_VALIDATE_TIMEOUT, kind: "validate_timeout", detail: `${from}, and the frozen command timed out (exit 124) on the engine's rerun, so its substitution cannot be judged: infrastructure (host load)` }); continue; }
|
|
960
989
|
}
|
|
961
990
|
const r = runs.find((x) => x?.id === v.id);
|
|
@@ -976,9 +1005,9 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
976
1005
|
}
|
|
977
1006
|
const miss = rerun ? missingTool(rerun, { repoHas, command: v.command }) : null;
|
|
978
1007
|
if (miss && ciVerified) { ciCovered.push(v.id); continue; }
|
|
979
|
-
if (miss) failures.push({ code: C.ENV_TOOL_MISSING, kind: "validate_env", tool: miss.tool, detail: `validate ${v.id} (\`${v.command}\`) could not run: the host is missing ${KIND_NAME[miss.kind]} '${miss.tool}' (environment, not the change)` });
|
|
1008
|
+
if (miss) failures.push({ code: C.ENV_TOOL_MISSING, kind: "validate_env", tool: miss.tool, detail: `validate ${v.id} (\`${v.command}\`) could not run: the host is missing ${KIND_NAME[miss.kind]} '${miss.tool}' (environment, not the change)${outputTail(rerun.output)}` });
|
|
980
1009
|
else if (amendedOnly && isScopeCheck(v.command)) superseded.push({ id: v.id, files: amendedOnly });
|
|
981
|
-
else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${r.exit})` });
|
|
1010
|
+
else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${r.exit})${outputTail(rerun?.output)}` });
|
|
982
1011
|
}
|
|
983
1012
|
}
|
|
984
1013
|
const st = Array.isArray(result?.requirements) ? result.requirements : [];
|
|
@@ -1003,6 +1032,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1003
1032
|
for (const f of coupledFailures ?? []) failures.push(f); // #5079
|
|
1004
1033
|
for (const f of relaxationFailures ?? []) failures.push(f); // #5237
|
|
1005
1034
|
failures.push(...(routeFailures ?? [])); // #5087: topology.route_reachability, blocking when declared
|
|
1035
|
+
failures.push(...(prodParityFailures ?? [])); // #5284: topology.prod_parity
|
|
1006
1036
|
return { ok: failures.length === 0, failures, superseded, ciCovered };
|
|
1007
1037
|
}
|
|
1008
1038
|
|
|
@@ -1163,10 +1193,13 @@ export function evidencePathOnly(problems = []) {
|
|
|
1163
1193
|
}
|
|
1164
1194
|
/**
|
|
1165
1195
|
* #5164: true when every problem of an incomplete review is a reviewer slip a targeted re-ask can fix: an evidence path that
|
|
1166
|
-
* did not resolve (#4327) or an issue_coverage misquote.
|
|
1196
|
+
* did not resolve (#4327) or an issue_coverage misquote. #5345: so is any single missing or invalid row (requirement, preserve,
|
|
1197
|
+
* scope, issue_coverage, verdict): the reply is repaired in place for those ids, never a new review round. A whole absent
|
|
1198
|
+
* `requirements` section is not a slip: it keeps the two-run limit. A real coverage gap is a failure, not an incompleteness.
|
|
1167
1199
|
*/
|
|
1200
|
+
const ROW_GAP_RE = /needs exactly one row|status invalid|needs deferral_ok|needs instrumented|needs path:line evidence|needs validated_by|has no scope row|needs a row with status|issue_coverage is missing or empty|verdict must be|regressions must be/;
|
|
1168
1201
|
export function reaskable(problems = []) {
|
|
1169
|
-
return problems.length > 0 && problems.every((p) => MISSING_PATH_RE.test(String(p)) || String(p).startsWith(MISQUOTE_PREFIX));
|
|
1202
|
+
return problems.length > 0 && problems.every((p) => MISSING_PATH_RE.test(String(p)) || String(p).startsWith(MISQUOTE_PREFIX) || ROW_GAP_RE.test(String(p)));
|
|
1170
1203
|
}
|
|
1171
1204
|
const reviewedFiles = (changedFiles, ignore) => changedFiles.filter((x) => !ignore.some((pre) => x.startsWith(pre)));
|
|
1172
1205
|
|
|
@@ -1249,8 +1282,10 @@ export function checkCompleteness(rv, { contract, changedFiles, issueText, pathE
|
|
|
1249
1282
|
}
|
|
1250
1283
|
|
|
1251
1284
|
|
|
1252
|
-
/** #4726: a requirement quote that carries a `[type:e2e]` criterion. */
|
|
1253
|
-
const wantsE2e = (r) => /\[type:e2e\]/i.test(String(r?.quote ?? ""));
|
|
1285
|
+
/** #4726, #5339: a requirement quote that carries a `[type:e2e]` or `[type:manual]` criterion. */
|
|
1286
|
+
const wantsE2e = (r) => /\[type:(?:e2e|manual)\]/i.test(String(r?.quote ?? ""));
|
|
1287
|
+
/** #5339: failure kinds enforced without an `engine.conformance_kinds` entry (the entry still overrides). */
|
|
1288
|
+
const DEFAULT_ENFORCED_KINDS = ["e2e_row"];
|
|
1254
1289
|
const E2E_CMD_RE = /\b(?:playwright|cypress|e2e|live[- ]stack|wdio)\b/i;
|
|
1255
1290
|
/**
|
|
1256
1291
|
* #4726: whether a validate command runs a real end-to-end check: an entry of `verify.e2e_checks`, a file of the e2e spec set
|
|
@@ -1259,6 +1294,7 @@ const E2E_CMD_RE = /\b(?:playwright|cypress|e2e|live[- ]stack|wdio)\b/i;
|
|
|
1259
1294
|
export function isE2eCommand(command, e2e = null) {
|
|
1260
1295
|
const cmd = String(command ?? "");
|
|
1261
1296
|
if ((e2e?.checks ?? []).some((c) => c && cmd.includes(c))) return true;
|
|
1297
|
+
if ((e2e?.faked ?? []).some((f) => f && cmd.includes(f))) return false; // #5339: names a test that fakes the real path
|
|
1262
1298
|
if (typeof e2e?.isSpec === "function" && cmd.split(/\s+/).some((t) => t && e2e.isSpec(t.replace(/^["']+|["']+$/g, "")))) return true;
|
|
1263
1299
|
return E2E_CMD_RE.test(cmd);
|
|
1264
1300
|
}
|
|
@@ -1278,7 +1314,7 @@ export function decide(raw, ctx) {
|
|
|
1278
1314
|
const rv = fillEngineRows(raw, ctx);
|
|
1279
1315
|
const comp = checkCompleteness(rv, ctx);
|
|
1280
1316
|
if (!comp.complete) return { state: "review.incomplete", failures: comp.problems.map((d) => ({ code: C.REVIEW_INCOMPLETE, detail: d })), missing: comp.missing, review: rv };
|
|
1281
|
-
const f = [];
|
|
1317
|
+
const f = [], converted = [];
|
|
1282
1318
|
const amendedOf = (ids) => (ctx.contract.requirements ?? []).find((r) => r.amendment?.text && (ids ?? []).includes(r.id));
|
|
1283
1319
|
const notAccepted = (r) => (r ? `amendment not accepted (${r.id} amended to "${String(r.amendment.text).slice(0, 200)}"): ` : "");
|
|
1284
1320
|
for (const c of rv.issue_coverage) if (c.status !== "covered") f.push({ code: C.CONFORMANCE_OMISSION, detail: `${notAccepted(amendedOf(c.contract_ids))}issue requirement ${c.status}: "${c.quote}"${c.note ? ` (${c.note})` : ""}` });
|
|
@@ -1290,24 +1326,29 @@ export function decide(raw, ctx) {
|
|
|
1290
1326
|
} else if (r.disposition === "deliver" && row.status !== "implemented") {
|
|
1291
1327
|
f.push({ code: ["deferred", "post-deploy"].includes(row.status) ? C.CONFORMANCE_UNTRACKED_DEFERRAL : C.CONFORMANCE_UNIMPLEMENTED, detail: `${r.amendment?.text ? `${r.id} amendment not accepted (amended to "${String(r.amendment.text).slice(0, 200)}"): ` : `${r.id} `}${row.status}${row.note ? `: ${row.note}` : ""}${row.evidence ? ` (${row.evidence})` : ""}` });
|
|
1292
1328
|
} else if (r.disposition === "deliver" && wantsE2e(r) && !e2eVerified(row, ctx.contract, ctx.e2e)) {
|
|
1293
|
-
|
|
1329
|
+
const faked = (ctx.e2e?.faked ?? []).length ? `; faked or mocked components in ${ctx.e2e.faked.slice(0, 3).join(", ")}` : "";
|
|
1330
|
+
f.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, kind: "e2e_row", detail: `${r.id} is a [type:e2e]/[type:manual] criterion but ${row.validated_by || "its validated_by"} is not a real end-to-end check (the repo's e2e set, Playwright/browser/live stack${faked}); run one, or mark ${r.id} post-deploy so it is transferred to the epic's acceptance` });
|
|
1331
|
+
} else if (r.disposition === "defer" && wantsE2e(r)) {
|
|
1332
|
+
// #5339: a deferred e2e/manual requirement is not met; only a post-deploy one is transferred to the epic (the lane closes partial)
|
|
1333
|
+
f.push({ code: C.CONFORMANCE_E2E_UNVERIFIED, kind: "e2e_row", detail: `${r.id} is a [type:e2e]/[type:manual] criterion deferred without a run; run the real path, or mark ${r.id} post-deploy so it is transferred to the epic's acceptance` });
|
|
1294
1334
|
}
|
|
1295
1335
|
// #5207: in-lane engineering work is never deferrable, whatever the reviewer says; one failure per row.
|
|
1296
|
-
if (inLaneDeferral(r))
|
|
1336
|
+
if (TRACKED.includes(r.disposition) && row.status === "implemented" && (inLaneDeferral(r) || row.deferral_ok === false)) converted.push({ id: r.id, evidence: String(row.evidence ?? "") }); // #5365: delivered in the diff
|
|
1337
|
+
else if (inLaneDeferral(r)) f.push({ code: C.CONFORMANCE_UNJUSTIFIED_DEFERRAL, detail: `${r.id} is in-lane engineering work (bucket ${r.bucket ?? "none"}): deliver it (amend-requirement to deliver); only post-deploy, owner and external items may be deferred (#5207)` });
|
|
1297
1338
|
else if (TRACKED.includes(r.disposition) && row.deferral_ok === false) f.push({ code: C.CONFORMANCE_UNJUSTIFIED_DEFERRAL, detail: `${r.id} ${r.disposition} is not justified${row.note ? `: ${row.note}` : ""}; implement it` });
|
|
1298
1339
|
}
|
|
1299
1340
|
for (const s of rv.scope) {
|
|
1300
1341
|
if (!blank(s.authorized_by)) continue;
|
|
1301
1342
|
const engine = authorizationOf(ctx.contract, s.file);
|
|
1302
|
-
if (engine === "test" || engine === "incidental") continue; // always allowed; a reviewer "none" here is a misreading, not creep
|
|
1343
|
+
if (engine === "test" || engine === "incidental" || engine === "coupled") continue; // always allowed; a reviewer "none" here is a misreading, not creep
|
|
1303
1344
|
f.push({ code: C.CONFORMANCE_SCOPE_CREEP, detail: `${s.file}: ${s.note || "not authorized by the contract"}` });
|
|
1304
1345
|
}
|
|
1305
1346
|
for (const p of rv.preserve ?? []) if (p.status !== "intact") f.push({ code: C.CONFORMANCE_PRESERVE_VIOLATED, detail: `${p.id} ${p.status}${p.evidence ? ` (${p.evidence})` : ""}${p.note ? `: ${p.note}` : ""}` });
|
|
1306
1347
|
for (const r of rv.regressions ?? []) f.push({ code: C.CONFORMANCE_REGRESSION, detail: `${r?.at ?? "?"}: ${r?.failure ?? ""}` });
|
|
1307
|
-
if (f.length) return { state: "nonconforming", failures: f, inconsistent: rv.verdict === "CONFORMS", review: rv };
|
|
1348
|
+
if (f.length) return { state: "nonconforming", failures: f, inconsistent: rv.verdict === "CONFORMS", review: rv, converted };
|
|
1308
1349
|
// A NONCONFORMING verdict with every row passing gives the builder nothing to fix: re-ask the reviewer.
|
|
1309
1350
|
if (rv.verdict !== "CONFORMS") return { state: "review.inconsistent", failures: [{ code: C.REVIEW_INCONSISTENT, detail: "verdict NONCONFORMING with no failing row" }], missing: ["verdict"], review: rv };
|
|
1310
|
-
return { state: "conforms", failures: [], review: rv };
|
|
1351
|
+
return { state: "conforms", failures: [], review: rv, converted };
|
|
1311
1352
|
}
|
|
1312
1353
|
|
|
1313
1354
|
/** The ids (or sections) a targeted re-ask must fill: requirement ids without a valid row, issue_coverage problems, ...; [] when complete. */
|
|
@@ -1355,6 +1396,15 @@ export function reviewSkeleton(contract, changedFiles = [], ignore = []) {
|
|
|
1355
1396
|
}
|
|
1356
1397
|
|
|
1357
1398
|
/** Requirements the reviewer accepted as deferred or post-deploy that still need a tracking issue. */
|
|
1399
|
+
/** #5365: flips the requirements `converted` names (decide) to deliver, keeping the original row in amended_from; returns a new contract. */
|
|
1400
|
+
export function convertDelivered(contract, converted) {
|
|
1401
|
+
const by = new Map((converted ?? []).map((x) => [x.id, x.evidence]));
|
|
1402
|
+
return { ...contract, requirements: (contract.requirements ?? []).map((r) => {
|
|
1403
|
+
if (!by.has(r.id) || !TRACKED.includes(r.disposition)) return r;
|
|
1404
|
+
const { bucket, why, check, tracked, class: cls, ...rest } = r;
|
|
1405
|
+
return { ...rest, disposition: "deliver", amended: true, amended_from: r.amended_from ?? Object.fromEntries(["quote", "disposition", "why", "bucket", "check", "tracked", "class"].filter((k) => r[k] != null).map((k) => [k, r[k]])), amendment: { text: `delivered in the diff (${by.get(r.id) || "reviewer evidence"})`, why: "reviewer found the deferred requirement delivered" } };
|
|
1406
|
+
}) };
|
|
1407
|
+
}
|
|
1358
1408
|
/** #5207: in-lane engineering deferrals are never filed (decide() sends them back to the builder). */
|
|
1359
1409
|
export const pendingTracking = (contract) => (contract.requirements ?? []).filter((r) => TRACKED.includes(r.disposition) && !r.tracked && !inLaneDeferral(r));
|
|
1360
1410
|
|
|
@@ -1366,9 +1416,17 @@ export const isInvestigation = (title) => /^\s*investigate[(:]/i.test(String(tit
|
|
|
1366
1416
|
* post-deploy requirement, or a deliver requirement whose review row is not implemented, closes "partial" instead; `open`
|
|
1367
1417
|
* holds those requirements (the open question, carried forward). A null review (reviewer skipped) judges dispositions only.
|
|
1368
1418
|
*/
|
|
1369
|
-
export function closePlan(contract, { title = null, review = null, issueText = null } = {}) {
|
|
1419
|
+
export function closePlan(contract, { title = null, review = null, issueText = null, liveBlocks = [] } = {}) {
|
|
1370
1420
|
const reqs = contract.requirements ?? [];
|
|
1371
1421
|
const tracked = [...new Set(reqs.filter((r) => TRACKED.includes(r.disposition)).map((r) => r.tracked).filter(Boolean))];
|
|
1422
|
+
// #5339: an e2e/manual requirement that was not run in the lane is transferred to the epic, not met: the issue stays partial
|
|
1423
|
+
const transferred = reqs.filter((r) => r.disposition === "post-deploy" && wantsE2e(r));
|
|
1424
|
+
// #5285: a default-on change whose live acceptance is deferred is not closed as completed; #5382: it still transfers its e2e/manual rows
|
|
1425
|
+
if (liveBlocks.length) {
|
|
1426
|
+
const live = reqs.filter((r) => liveBlocks.some((b) => b.id === r.id));
|
|
1427
|
+
return { reason: "partial", tracked, liveBlocked: true, blocks: liveBlocks, open: live, ...(transferred.length ? { transferred: true, transfer: transferred } : {}) };
|
|
1428
|
+
}
|
|
1429
|
+
if (transferred.length) return { reason: "partial", tracked, transferred: true, open: transferred };
|
|
1372
1430
|
const rows = Array.isArray(review?.requirements) ? review.requirements : null;
|
|
1373
1431
|
if (!isInvestigation(title)) {
|
|
1374
1432
|
const unticked = unmetChecklist(reqs, rows, issueText);
|
|
@@ -1595,7 +1653,7 @@ export function normalizeKindModes(raw) {
|
|
|
1595
1653
|
export function blockingFailures(failures, { shadow = false, kinds = null, allow = [] } = {}) {
|
|
1596
1654
|
const block = [], record = [];
|
|
1597
1655
|
for (const f of failures ?? []) {
|
|
1598
|
-
const own = kinds?.[f?.code];
|
|
1656
|
+
const own = kinds?.[f?.code] ?? (DEFAULT_ENFORCED_KINDS.includes(f?.kind) ? "enforce" : undefined);
|
|
1599
1657
|
(own ? own === "enforce" : !shadow || allow.includes(f?.code)) ? block.push(f) : record.push(f);
|
|
1600
1658
|
}
|
|
1601
1659
|
return { block, record };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import { removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, projectDirPathMiss, rewriteProjectDirCommand } from "./conformance.mjs";
|
|
6
|
+
import { outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered } from "./conformance.mjs";
|
|
7
7
|
|
|
8
8
|
const ISSUE = "## Requirements\n1. The scrape route must release the spend reservation on 429.\n2. The search route must release the spend reservation on 429.\n\n- [ ] Billing pricing is unchanged.";
|
|
9
9
|
const Q1 = "The scrape route must release the spend reservation on 429.";
|
|
@@ -313,6 +313,31 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
313
313
|
assert.equal(missingTool({ rc: 1, output: "ModuleNotFoundError: No module named 'app'" }, { repoHas: repoTracks(["app.py"]) }), null);
|
|
314
314
|
assert.equal(missingTool({ rc: 1, output: "1 test failed: expected not found" }), null, "rc != 127 needs command not found");
|
|
315
315
|
});
|
|
316
|
+
it("#5371 substituteVerdict treats docker daemon, playwright browser and npm network failures as not runs", () => {
|
|
317
|
+
const sigs = [
|
|
318
|
+
"docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?",
|
|
319
|
+
"docker: Error response from daemon: invalid mount config for type \"bind\": bind source path does not exist: /x/infra",
|
|
320
|
+
"browserType.launch: Executable doesn't exist at /root/.cache/ms-playwright/chromium-1/chrome\nRun npx playwright install",
|
|
321
|
+
"npm ERR! code EAI_AGAIN\nnpm ERR! network request to https://registry.npmjs.org/x failed",
|
|
322
|
+
"npm error code ENOTFOUND",
|
|
323
|
+
];
|
|
324
|
+
for (const output of sigs) {
|
|
325
|
+
assert.equal(substituteVerdict({ rc: 1, output }, { command: "x" }), "ok", output);
|
|
326
|
+
assert.equal(missingTool({ rc: 1, output })?.kind, "environment", output);
|
|
327
|
+
}
|
|
328
|
+
assert.equal(substituteVerdict({ rc: 1, output: "AssertionError: expected 1 to equal 2" }, { command: "x" }), "runs");
|
|
329
|
+
});
|
|
330
|
+
it("#5371 a failed validate detail carries a redacted last-40-line output tail; an env signature is env.tool_missing", () => {
|
|
331
|
+
const C = { requirements: [], validate: [{ id: "V1", command: "bash t.sh" }], deliverables: [{ id: "D1", path: "a.mjs", change: "x" }] };
|
|
332
|
+
const failed = { validation: [{ id: "V1", exit: 1 }], requirements: [] };
|
|
333
|
+
const out = Array.from({ length: 60 }, (_, i) => `line${i}`).join("\n") + "\nGITHUB_TOKEN=ghp_abcdefghijklmnopqrstuvwxyz0123\nAuthorization: Bearer abcdefghijklmnop1234";
|
|
334
|
+
const pc = precheck({ contract: C, result: failed, changedFiles: ["a.mjs"], validateRuns: { V1: { rc: 1, output: out } } });
|
|
335
|
+
const d = pc.failures.find((f) => f.kind === "validate_failed").detail;
|
|
336
|
+
assert.match(d, /line59/); assert.doesNotMatch(d, /line5\b/); assert.doesNotMatch(d, /ghp_abcdef|abcdefghijklmnop1234/); assert.match(d, /\[redacted\]/);
|
|
337
|
+
const env = precheck({ contract: C, result: failed, changedFiles: ["a.mjs"], validateRuns: { V1: { rc: 1, output: "Cannot connect to the Docker daemon" } } });
|
|
338
|
+
assert.deepEqual(env.failures.map((f) => f.code), ["env.tool_missing"]); assert.match(env.failures[0].detail, /Cannot connect/);
|
|
339
|
+
assert.equal(outputTail(""), "");
|
|
340
|
+
});
|
|
316
341
|
it("#5005 a missing forgedock install is env.tool_missing, not conformance; other absolute paths stay code defects", () => {
|
|
317
342
|
const out = "node:internal/modules/cjs/loader\nError: Cannot find module '/opt/node/lib/node_modules/forgedock/bin/lean/checks.mjs'\n code: 'MODULE_NOT_FOUND'";
|
|
318
343
|
assert.deepEqual(missingTool({ rc: 1, output: out }), { tool: "forgedock", kind: "command" });
|
|
@@ -580,8 +605,10 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
580
605
|
assert.match(problems[0], /nearest criterion line: "The scrape route must release/);
|
|
581
606
|
assert.ok(reaskable(problems));
|
|
582
607
|
assert.ok(reaskable(["R1: evidence path /layout.tsx does not exist"]), "#4327 evidence paths stay re-askable");
|
|
583
|
-
assert.ok(
|
|
584
|
-
assert.ok(
|
|
608
|
+
assert.ok(reaskable([...problems, "requirement R1 needs exactly one row (has 0)"]), "#5345 a missing row is repaired in place");
|
|
609
|
+
assert.ok(reaskable(["issue_coverage is missing or empty"]));
|
|
610
|
+
assert.ok(!reaskable(["requirements rows are missing"]), "a whole absent section keeps the two-run limit");
|
|
611
|
+
assert.ok(!reaskable([...problems, "something else is wrong"]));
|
|
585
612
|
assert.ok(!reaskable([]));
|
|
586
613
|
assert.deepEqual(fillEngineRows(good, ctx).issue_coverage, good.issue_coverage, "verbatim rows are untouched");
|
|
587
614
|
});
|
|
@@ -642,6 +669,31 @@ describe("conformance review: the engine computes the verdict from complete rows
|
|
|
642
669
|
});
|
|
643
670
|
|
|
644
671
|
describe("close plan and follow-up items", () => {
|
|
672
|
+
it("#5285: a live default-on change with live acceptance deferred closes partial and names the blocker", () => {
|
|
673
|
+
const k = { requirements: [{ id: "R3", disposition: "defer", bucket: "post-deploy" }] };
|
|
674
|
+
const p = closePlan(k, { liveBlocks: [{ id: "R3", flag: "pool" }] });
|
|
675
|
+
assert.equal(p.reason, "partial");
|
|
676
|
+
assert.equal(p.liveBlocked, true);
|
|
677
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R3"]);
|
|
678
|
+
assert.equal(closePlan(k).reason, "completed");
|
|
679
|
+
});
|
|
680
|
+
it("#5382: a default-on live-blocked lane still transfers its e2e/manual post-deploy rows to the epic", () => {
|
|
681
|
+
const k = { requirements: [{ id: "R3", disposition: "defer", bucket: "post-deploy" }, { id: "R4", quote: "[type:e2e] checkout works", disposition: "post-deploy" }] };
|
|
682
|
+
const p = closePlan(k, { liveBlocks: [{ id: "R3", flag: "pool" }] });
|
|
683
|
+
assert.equal(p.liveBlocked, true);
|
|
684
|
+
assert.equal(p.transferred, true);
|
|
685
|
+
assert.deepEqual(p.transfer.map((r) => r.id), ["R4"]);
|
|
686
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R3"]);
|
|
687
|
+
assert.equal(closePlan({ requirements: [k.requirements[0]] }, { liveBlocks: [{ id: "R3", flag: "pool" }] }).transferred, undefined);
|
|
688
|
+
});
|
|
689
|
+
it("#5285: interactive UI on a high-risk surface with no browser check fails precheck; with one, or off a risk surface, it passes", () => {
|
|
690
|
+
const k = { requirements: [{ id: "R1", disposition: "deliver" }], deliverables: [{ id: "D1", path: "web/Cta.tsx" }] };
|
|
691
|
+
const res = { requirements: [{ id: "R1", status: "implemented" }], validation: [] };
|
|
692
|
+
const run = (uiBrowser) => precheck({ contract: k, result: res, changedFiles: ["web/Cta.tsx"], uiBrowser }).failures.filter((f) => f.kind === "ui_browser_unverified");
|
|
693
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: false, highRisk: true, reason: "no e2e_label or e2e_workflow configured" }).length, 1);
|
|
694
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: true, highRisk: true, reason: "x" }).length, 0);
|
|
695
|
+
assert.equal(run({ files: ["web/Cta.tsx"], ran: false, highRisk: false, reason: "x" }).length, 0);
|
|
696
|
+
});
|
|
645
697
|
it("links every tracking issue once; nothing tracked when everything is delivered", () => {
|
|
646
698
|
assert.deepEqual(closePlan(C), { reason: "completed", tracked: [] });
|
|
647
699
|
const k = { requirements: [{ id: "R1", disposition: "deliver" }, { id: "R2", disposition: "defer", tracked: "#9" }, { id: "R3", disposition: "post-deploy", tracked: "#9" }] };
|
|
@@ -1633,3 +1685,77 @@ describe("contract quote snapping (#5244)", () => {
|
|
|
1633
1685
|
assert.equal(snapQuotes({ requirements: [{ id: "R1", quote: "totally unrelated words about something else here" }] }, ISS).snapped.length, 0);
|
|
1634
1686
|
});
|
|
1635
1687
|
});
|
|
1688
|
+
|
|
1689
|
+
describe("#5345 an incomplete reviewer reply is repaired in place", () => {
|
|
1690
|
+
it("every row-level gap is re-askable and the repaired rows merge into the first reply (no new review round)", () => {
|
|
1691
|
+
for (const p of ["R2: status invalid: maybe", "R1: a defer requirement needs deferral_ok true|false (is deferring it justified?)", "changed file a.js has no scope row", "preserve P1 needs a row with status intact|violated|unverified", "verdict must be CONFORMS or NONCONFORMING"]) assert.ok(reaskable([p]), p);
|
|
1692
|
+
const merged = mergeReviewRows({ verdict: "CONFORMS", requirements: [{ id: "R1", status: "implemented" }] }, { requirements: [{ id: "R2", status: "implemented" }] });
|
|
1693
|
+
assert.deepEqual(merged.requirements.map((r) => r.id), ["R1", "R2"]);
|
|
1694
|
+
});
|
|
1695
|
+
});
|
|
1696
|
+
|
|
1697
|
+
describe("#5339 a faked or deferred e2e/manual requirement is not met", () => {
|
|
1698
|
+
const Q = "Users can render the launch film end to end [type:e2e]";
|
|
1699
|
+
const mk = (cmd, quote, extra = {}, disposition = "deliver") => {
|
|
1700
|
+
const contract = { ...C, requirements: [{ id: "R1", quote, disposition, ...extra }, C.requirements[1]], validate: [{ id: "V1", command: cmd }] };
|
|
1701
|
+
return { contract, ctx: { ...ctx, contract } };
|
|
1702
|
+
};
|
|
1703
|
+
const rv = (contract) => ({ ...good, issue_coverage: [{ quote: contract.requirements[0].quote, status: "covered" }, ...good.issue_coverage.slice(1)] });
|
|
1704
|
+
const run = (cmd, quote, e2e, disposition, row = {}) => { const m = mk(cmd, quote, {}, disposition); const r = rv(m.contract); r.requirements = [{ ...r.requirements[0], ...row }, ...r.requirements.slice(1)]; return decide(r, { ...m.ctx, issueText: `${ISSUE}\n${quote}`, e2e }); };
|
|
1705
|
+
it("a validate that names a faked test is not an e2e run, even with e2e in its name (spectracut #63 replay)", () => {
|
|
1706
|
+
const d = run("node --test tests/e2e/film.e2e.test.mjs", Q, { faked: ["tests/e2e/film.e2e.test.mjs"] });
|
|
1707
|
+
assert.equal(d.state, "nonconforming");
|
|
1708
|
+
assert.deepEqual(codes(d), ["conformance.e2e_unverified"]);
|
|
1709
|
+
assert.equal(d.failures[0].kind, "e2e_row");
|
|
1710
|
+
assert.equal(run("node --test tests/e2e/film.e2e.test.mjs", Q, { faked: [] }).state, "conforms");
|
|
1711
|
+
assert.equal(run("make film", Q, { checks: ["make film"], faked: ["make film"] }).state, "conforms", "a configured e2e check is always real");
|
|
1712
|
+
});
|
|
1713
|
+
it("[type:manual] is judged like [type:e2e]; a deferred e2e row fails, a post-deploy one is transferred", () => {
|
|
1714
|
+
assert.deepEqual(codes(run("pytest tests/test_x.py", "Operators can restore a backup [type:manual]")), ["conformance.e2e_unverified"]);
|
|
1715
|
+
assert.equal(codes(run("pytest tests/test_x.py", Q, undefined, "defer", { status: "deferred", deferral_ok: true })).includes("conformance.e2e_unverified"), true);
|
|
1716
|
+
assert.equal(codes(run("pytest tests/test_x.py", Q, undefined, "post-deploy", { status: "post-deploy" })).includes("conformance.e2e_unverified"), false);
|
|
1717
|
+
});
|
|
1718
|
+
it("e2e_unverified of the e2e row blocks by default; forge.yaml conformance_kinds overrides; other kinds follow the lane", () => {
|
|
1719
|
+
const fs = [{ code: "conformance.e2e_unverified", kind: "e2e_row" }, { code: "conformance.e2e_unverified", kind: "ui_browser_unverified" }];
|
|
1720
|
+
assert.deepEqual(blockingFailures(fs, { shadow: true }).block.map((f) => f.kind), ["e2e_row"]);
|
|
1721
|
+
assert.deepEqual(blockingFailures(fs, { shadow: true, kinds: { "conformance.e2e_unverified": "shadow" } }).block, []);
|
|
1722
|
+
});
|
|
1723
|
+
it("closePlan: a transferred e2e/manual requirement closes partial, never completed", () => {
|
|
1724
|
+
const k = { requirements: [{ id: "R1", quote: Q, disposition: "post-deploy", tracked: "#9" }] };
|
|
1725
|
+
const p = closePlan(k);
|
|
1726
|
+
assert.equal(p.reason, "partial");
|
|
1727
|
+
assert.equal(p.transferred, true);
|
|
1728
|
+
assert.deepEqual(p.open.map((r) => r.id), ["R1"]);
|
|
1729
|
+
assert.equal(closePlan({ requirements: [{ id: "R1", quote: "A plain thing [type:unit]", disposition: "post-deploy" }] }).reason, "completed");
|
|
1730
|
+
});
|
|
1731
|
+
it("#5365 add-requirement id collision is renumbered to the next free R<n> and recorded, never a problem", () => {
|
|
1732
|
+
const add = (id) => ({ kind: "add-requirement", requirement: { id, quote: "Billing pricing is unchanged.", disposition: "deliver" }, why: "missed" });
|
|
1733
|
+
const a = applyAmendments(C, [add("R2"), add("R2")], ISSUE);
|
|
1734
|
+
assert.deepEqual(a.problems, []);
|
|
1735
|
+
assert.deepEqual(a.contract.requirements.map((r) => r.id), ["R1", "R2", "R3", "R4"]);
|
|
1736
|
+
assert.ok(a.applied.some((x) => x.target === "R2 -> R3") && a.applied.some((x) => x.target === "R2 -> R4"));
|
|
1737
|
+
assert.equal(applyAmendments(C, [add("R9")], ISSUE).applied[0].target, "R9");
|
|
1738
|
+
});
|
|
1739
|
+
it("#5365 a file coupled to a deliverable (outcome-codes.mjs <-> docs/OUTCOME-CODES.md) is not scope creep; an unrelated doc still is", () => {
|
|
1740
|
+
const k = { ...C, deliverables: [{ id: "D1", path: "bin/engine/outcome-codes.mjs" }] };
|
|
1741
|
+
const run = (f) => precheck({ contract: k, result: { requirements: [], validation: [{ id: "V1", exit: 0 }] }, changedFiles: ["bin/engine/outcome-codes.mjs", f] }).failures.map((x) => x.kind);
|
|
1742
|
+
assert.equal(run("docs/OUTCOME-CODES.md").includes("scope_creep"), false);
|
|
1743
|
+
assert.ok(run("docs/OTHER.md").includes("scope_creep"));
|
|
1744
|
+
const none = precheck({ contract: C, result: { requirements: [], validation: [] }, changedFiles: ["docs/OUTCOME-CODES.md"] }).failures.map((x) => x.kind);
|
|
1745
|
+
assert.ok(none.includes("scope_creep"), "coupling needs the paired deliverable");
|
|
1746
|
+
const dctx = { ...ctx, contract: k, changedFiles: ["bin/engine/outcome-codes.mjs", "docs/OUTCOME-CODES.md"] };
|
|
1747
|
+
const kr = { ...good, requirements: [good.requirements[0], good.requirements[1]], scope: [{ file: "bin/engine/outcome-codes.mjs", authorized_by: "D1" }, { file: "docs/OUTCOME-CODES.md", authorized_by: "none" }] };
|
|
1748
|
+
assert.ok(!decide(kr, dctx).failures.some((f) => f.code === "conformance.scope_creep"));
|
|
1749
|
+
});
|
|
1750
|
+
it("#5365 a defer row the review finds implemented converts to deliver instead of unjustified_deferral; an undelivered one still fails", () => {
|
|
1751
|
+
const k = { ...C, requirements: [C.requirements[0], { ...C.requirements[1], disposition: "defer", why: "w", bucket: "owner:rotate the key" }] };
|
|
1752
|
+
const c2 = { ...ctx, contract: k };
|
|
1753
|
+
const rv = (extra) => ({ ...good, requirements: [good.requirements[0], { id: "R2", ...extra }] });
|
|
1754
|
+
const d = decide(rv({ status: "implemented", evidence: "src/search.js:7", validated_by: "V1", deferral_ok: false, note: "replay already ships" }), c2);
|
|
1755
|
+
assert.deepEqual(codes(d), []);
|
|
1756
|
+
assert.deepEqual(d.converted, [{ id: "R2", evidence: "src/search.js:7" }]);
|
|
1757
|
+
const conv = convertDelivered(k, d.converted).requirements[1];
|
|
1758
|
+
assert.equal(conv.disposition, "deliver"); assert.equal(conv.bucket, undefined); assert.equal(conv.amended_from.disposition, "defer");
|
|
1759
|
+
assert.deepEqual(codes(decide(rv({ status: "deferred", deferral_ok: false }), c2)), ["conformance.unjustified_deferral"]);
|
|
1760
|
+
});
|
|
1761
|
+
});
|