forgedock 1.56.0 → 1.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +1 -1
- package/bin/engine/outcome-codes.mjs +1 -0
- package/bin/engine/phases.mjs +4 -3
- package/bin/engine-cli.mjs +46 -10
- package/bin/forgedock.mjs +52 -3
- package/bin/gc.mjs +43 -6
- package/bin/help-text.mjs +3 -1
- package/bin/lean/batch-health.mjs +5 -1
- package/bin/lean/batch-health.test.mjs +7 -1
- package/bin/lean/batch.mjs +7 -2
- package/bin/lean/batch.test.mjs +45 -0
- package/bin/lean/conformance.e2e.test.mjs +3 -2
- package/bin/lean/conformance.mjs +88 -17
- package/bin/lean/conformance.test.mjs +98 -3
- package/bin/lean/decisions.mjs +86 -1
- package/bin/lean/decisions.test.mjs +21 -1
- package/bin/lean/depcache.mjs +124 -13
- package/bin/lean/depcache.test.mjs +121 -3
- package/bin/lean/design-gate.mjs +144 -0
- package/bin/lean/design-gate.test.mjs +169 -0
- package/bin/lean/effects-cap.test.mjs +17 -0
- package/bin/lean/effects.mjs +58 -13
- package/bin/lean/heavy.mjs +25 -8
- package/bin/lean/hostload.test.mjs +28 -0
- package/bin/lean/intake.mjs +97 -0
- package/bin/lean/intake.test.mjs +105 -0
- package/bin/lean/interfaces.mjs +181 -0
- package/bin/lean/interfaces.test.mjs +192 -0
- package/bin/lean/issuewatch-install.mjs +52 -12
- package/bin/lean/issuewatch-install.test.mjs +50 -0
- package/bin/lean/issuewatch-parity.mjs +12 -2
- package/bin/lean/issuewatch-parity.test.mjs +26 -0
- package/bin/lean/issuewatch-reconcile.mjs +29 -1
- package/bin/lean/issuewatch-reconcile.test.mjs +21 -0
- package/bin/lean/issuewatch.mjs +34 -3
- package/bin/lean/issuewatch.test.mjs +49 -1
- package/bin/lean/lanecheck.test.mjs +15 -4
- package/bin/lean/lean.mjs +72 -21
- package/bin/lean/lean.test.mjs +149 -3
- package/bin/lean/orchestrate-blocked.test.mjs +18 -2
- package/bin/lean/orchestrate-owned.test.mjs +14 -5
- package/bin/lean/orchestrate.mjs +26 -4
- package/bin/lean/orphan-pr.mjs +3 -2
- package/bin/lean/orphan-pr.test.mjs +8 -1
- package/bin/lean/pagegate.mjs +35 -12
- package/bin/lean/pagegate.test.mjs +39 -1
- package/bin/lean/preflight.mjs +35 -1
- package/bin/lean/preflight.test.mjs +27 -1
- package/bin/lean/prompts.mjs +2 -1
- package/bin/lean/reap.test.mjs +39 -0
- package/bin/lean/recovery.test.mjs +25 -0
- package/bin/lean/release-config.mjs +158 -0
- package/bin/lean/release-config.test.mjs +109 -0
- package/bin/lean/release-control.mjs +148 -0
- package/bin/lean/release-control.test.mjs +143 -0
- package/bin/lean/release-fence.mjs +50 -0
- package/bin/lean/release-fence.test.mjs +105 -0
- package/bin/lean/release-flakes.mjs +139 -0
- package/bin/lean/release-flakes.test.mjs +116 -0
- package/bin/lean/release-ledger.mjs +160 -0
- package/bin/lean/release-ledger.test.mjs +226 -0
- package/bin/lean/release-minutes.mjs +92 -0
- package/bin/lean/release-minutes.test.mjs +99 -0
- package/bin/lean/release-nightly.mjs +75 -0
- package/bin/lean/release-nightly.test.mjs +48 -0
- package/bin/lean/release-postmerge.mjs +8 -2
- package/bin/lean/release-review.e2e.test.mjs +1 -0
- package/bin/lean/release-review.mjs +54 -7
- package/bin/lean/release-review.test.mjs +76 -7
- package/bin/lean/release-unitmap.mjs +35 -0
- package/bin/lean/release-unitmap.test.mjs +41 -0
- package/bin/lean/release.mjs +177 -19
- package/bin/lean/release.test.mjs +40 -0
- package/bin/lean/render.mjs +3 -1
- package/bin/lean/run-issue-placement.test.mjs +82 -0
- package/bin/lean/sandbox-remote.mjs +16 -0
- package/bin/lean/schedd.mjs +1 -1
- package/bin/lean/seam.mjs +115 -0
- package/bin/lean/seam.test.mjs +118 -0
- package/bin/lean/selftest-journey.mjs +40 -2
- package/bin/lean/selftest-journey.test.mjs +43 -3
- package/bin/lean/statuscomment.mjs +168 -0
- package/bin/lean/statuscomment.test.mjs +133 -0
- package/bin/lean/ui-quality.mjs +57 -0
- package/bin/lean/ui-quality.test.mjs +55 -0
- package/bin/lean/visual-gate.test.mjs +63 -0
- package/bin/pool/agent.mjs +16 -2
- package/bin/pool/router.mjs +5 -1
- package/bin/review-staging.mjs +5 -3
- package/bin/stats/card.mjs +117 -0
- package/bin/stats/card.test.mjs +109 -0
- package/bin/stats/conformance-outcomes.test.mjs +2 -1
- package/bin/stats/depth.mjs +1 -1
- package/bin/stats/gh-retry.test.mjs +152 -0
- package/bin/stats/github-source.mjs +147 -14
- package/bin/stats/index.mjs +35 -2
- package/bin/stats/stats.test.mjs +31 -3
- package/bin/vendor/js-yaml/LICENSE +21 -0
- package/bin/vendor/js-yaml/PIN.md +7 -0
- package/bin/vendor/js-yaml/js-yaml.mjs +3851 -0
- package/commands/design-render-critique-loop.md +2 -0
- package/commands/design.md +2 -0
- package/commands/issue.md +1 -1
- package/commands/milestone.md +1 -1
- package/commands/review-pr-agents/frontend.md +1 -0
- package/commands/review-pr-staging.md +5 -0
- package/docs/CONFIG.md +75 -1
- package/docs/ISSUE-WATCH.md +7 -0
- package/docs/OUTCOME-CODES.md +1 -0
- package/docs/STATS.md +10 -0
- package/docs/design/visual-gate.md +25 -0
- package/docs/eval/adversarial-bench.md +2 -2
- package/docs/eval/corpus/adversarial-v1.json +3 -3
- package/docs/site/start-a-new-project.md +7 -0
- package/docs/spec/forge-protocol-v1.md +31 -0
- package/package.json +1 -1
- package/pool/README.md +2 -0
- package/scripts/acceptance-red-green.sh +15 -1
- package/scripts/acceptance-red-green.test.sh +12 -0
- package/scripts/bench-adversarial.mjs +4 -0
- package/scripts/bench-lightlane.mjs +4 -1
- package/scripts/bootstrap-create.mjs +8 -2
- package/scripts/ci-local.test.sh +3 -3
- package/scripts/fixtures/ci-local/gha-dorny/.github/workflows/ci.yml +4 -0
- package/scripts/plan-validate-live.mjs +9 -6
- package/scripts/review-prepare.sh +7 -1
- package/scripts/review-roster.sh +5 -2
- package/scripts/review-roster.test.sh +9 -0
- package/scripts/visual-gate.mjs +64 -0
- package/templates/bootstrap/technical-spike.md +17 -0
- package/templates/contracts/seam-check.mjs +236 -0
package/bin/lean/conformance.mjs
CHANGED
|
@@ -473,13 +473,52 @@ export function weakenedE2eDecisions(c) {
|
|
|
473
473
|
|
|
474
474
|
const TEST_LEVELS = ["unit", "integration", "e2e", "live"];
|
|
475
475
|
const planWords = (t) => new Set(String(t ?? "").toLowerCase().match(/[a-z0-9]{3,}/g)?.map((w) => w.slice(0, 5)) ?? []);
|
|
476
|
-
const
|
|
476
|
+
const NEG_MOCK_PLAN_RE = /\b(?:no|not|never|without|non|avoid\w*)[ -]+(?:\w+[ -]+)?(?:mock|stub|fake)\w*/gi;
|
|
477
|
+
const deliverableWords = (d) => planWords(`${d?.change ?? ""} ${d?.path ?? ""}`);
|
|
478
|
+
/** #5445: the deliverable whose words cover the largest share of the proof's, as {id, pct, ratio}, or null. Pure. */
|
|
479
|
+
export function proofEchoDetail(proof, deliverables) {
|
|
480
|
+
// #5592: code identifiers (`name`, camelCase, snake_case, name()) only name the thing under test; they never count towards an echo,
|
|
481
|
+
// and a proof with fewer than 3 words left says too little to be a restatement.
|
|
482
|
+
const pw = planWords(String(proof ?? "").replace(/`[^`]*`|\b\w+\(\)|\b[a-z]+[A-Z]\w*|\b\w+_\w+/g, " "));
|
|
483
|
+
if (pw.size < 3) return null;
|
|
484
|
+
let best = null;
|
|
485
|
+
for (const d of deliverables) { const dw = deliverableWords(d); let n = 0; for (const w of pw) if (dw.has(w)) n++; const ratio = n / pw.size; if (!best || ratio > best.ratio) best = { id: d?.id ?? d?.path ?? "?", pct: Math.round(ratio * 100), ratio }; }
|
|
486
|
+
return best;
|
|
487
|
+
}
|
|
477
488
|
/** #5445: a proof whose words are (almost) all in the deliverable text of its requirement only restates the fix. Pure. */
|
|
478
489
|
export function proofEchoesDeliverable(proof, deliverables) {
|
|
479
|
-
|
|
480
|
-
if (!pw.size) return false;
|
|
481
|
-
return deliverables.some((d) => { const dw = planWords(`${d?.change ?? ""} ${d?.path ?? ""}`); let n = 0; for (const w of pw) if (dw.has(w)) n++; return n / pw.size >= 0.7; });
|
|
490
|
+
return (proofEchoDetail(proof, deliverables)?.ratio ?? 0) >= 0.7;
|
|
482
491
|
}
|
|
492
|
+
const MOCK_STOP = new Set(["only", "the", "and", "out", "with", "for", "its", "that", "this", "any", "all", "are", "was", "were", "been", "being", "than", "then", "also", "real"]);
|
|
493
|
+
/**
|
|
494
|
+
* #5587: the first non-negated mock/stub/fake mention in `reason` whose target (up to 4 words after the mock word, or up to 3 words
|
|
495
|
+
* before it, inside the same clause) shares a word stem with a deliverable path/change, as {phrase, id}; else null. Fake clocks and
|
|
496
|
+
* a stub aimed at something outside the deliverables (an I/O boundary) are fine. Pure.
|
|
497
|
+
*/
|
|
498
|
+
export function mockedDeliverable(reason, deliverables) {
|
|
499
|
+
const text = String(reason ?? "").replace(NEG_MOCK_PLAN_RE, " ").replace(FAKE_CLOCK_RE, " ");
|
|
500
|
+
const re = /\b(?:mock|stub|fake)\w*/gi;
|
|
501
|
+
for (let m; (m = re.exec(text));) {
|
|
502
|
+
const clauseStart = Math.max(text.lastIndexOf(".", m.index), text.lastIndexOf(";", m.index), text.lastIndexOf(",", m.index), text.lastIndexOf("\n", m.index)) + 1;
|
|
503
|
+
const after = text.slice(m.index + m[0].length).split(/[.;,\n]/)[0].split(/\s+/).filter(Boolean).slice(0, 4);
|
|
504
|
+
const before = text.slice(clauseStart, m.index).split(/\s+/).filter(Boolean).slice(-3);
|
|
505
|
+
const words = [...before, ...after].filter((w) => !MOCK_STOP.has(w.toLowerCase().replace(/[^a-z0-9]/g, "")));
|
|
506
|
+
const tw = planWords(words.join(" "));
|
|
507
|
+
for (const d of deliverables) { const dw = deliverableWords(d); if ([...tw].some((w) => dw.has(w))) return { phrase: `${m[0]} ${after.join(" ")}`.trim(), id: d?.id ?? d?.path ?? "?" }; }
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
const TEST_PLAN_RULES = [["test_plan.mock", /level_reason mocks /], ["test_plan.echo", /proof restates a deliverable/], ["test_plan.proof", /test_plan proof /], ["test_plan.level", /test_plan level/], ["test_plan.repro", /test_plan (?:repro|no-repro)/], ["test_plan.command", /test_plan (?:needs the exact command|command)/], ["test_plan.row", /test_plan (?:needs a row|row |must be an array)/]];
|
|
512
|
+
/** #5587: the rule id of a contract problem for `contract.invalid` telemetry: a test_plan rule, else "other". Pure. */
|
|
513
|
+
export const contractRuleId = (problem) => TEST_PLAN_RULES.find(([, re]) => re.test(String(problem)))?.[0] ?? "other";
|
|
514
|
+
/** #5587: {ruleId: count} over contract problems. Pure. */
|
|
515
|
+
export function contractRuleCounts(problems) {
|
|
516
|
+
const out = {};
|
|
517
|
+
for (const p of problems ?? []) { const k = contractRuleId(p); out[k] = (out[k] ?? 0) + 1; }
|
|
518
|
+
return out;
|
|
519
|
+
}
|
|
520
|
+
/** #5587: true when every problem is a test_plan rule (not scope or safety), so a second correction round is allowed. Pure. */
|
|
521
|
+
export const onlyTestPlanProblems = (problems) => (problems ?? []).length > 0 && problems.every((p) => contractRuleId(p) !== "other");
|
|
483
522
|
/**
|
|
484
523
|
* #5445: problems with the frozen test plan `test_plan: [{requirement, proof, level, level_reason, repro, reason, regression, env, command}]`.
|
|
485
524
|
* Shape is checked whenever present; `required` (a bug lane with repro on) also needs one row per deliver requirement.
|
|
@@ -494,11 +533,17 @@ export function testPlanProblems(c, { required = false } = {}) {
|
|
|
494
533
|
const id = t?.requirement ?? "test_plan row";
|
|
495
534
|
if (!t || typeof t !== "object" || !t.requirement) { problems.push("test_plan row without a requirement id"); continue; }
|
|
496
535
|
if (blank(t.proof)) problems.push(`${id}: test_plan proof must name the root-cause observable that shows the cause is fixed`);
|
|
497
|
-
else
|
|
536
|
+
else {
|
|
537
|
+
const echo = proofEchoDetail(t.proof, dels.filter((d) => (d?.requirements ?? []).includes(t.requirement)));
|
|
538
|
+
if (echo && echo.ratio >= 0.7) problems.push(`${id}: test_plan proof restates a deliverable: ≥70% of the proof's words repeat deliverable ${echo.id} (${echo.pct}%); phrase it as the wrong behaviour observed on base (symptom observed today → assertion that fails on base and passes on head, e.g. \"www.reddit.com listing .json returns 403 today → assert the fetch returns 200 JSON\")`);
|
|
539
|
+
}
|
|
498
540
|
if (!TEST_LEVELS.includes(t.level)) problems.push(`${id}: test_plan level must be one of ${TEST_LEVELS.join("|")}`);
|
|
499
541
|
if (blank(t.level_reason)) problems.push(`${id}: test_plan level needs a level_reason (why the cheapest level that observes the cause)`);
|
|
500
|
-
else
|
|
501
|
-
|
|
542
|
+
else {
|
|
543
|
+
const mocked = mockedDeliverable(t.level_reason, dels.filter((d) => (d?.requirements ?? []).includes(t.requirement)));
|
|
544
|
+
if (mocked) problems.push(`${id}: test_plan level_reason mocks \"${mocked.phrase}\", which is in deliverable ${mocked.id}; level_reason must not contain the words mock/stub/fake unless negated or aimed outside the deliverables; describe the real component exercised and where the I/O boundary is; allowed: a real instance of ${mocked.id}'s component, with stubs only at its I/O boundary (clock, network, browser factory) and, for DB code, a real database session`);
|
|
545
|
+
}
|
|
546
|
+
if (blank(t.repro)) problems.push(`${id}: test_plan repro must be a test id (red on base, green on head) or "no-repro" with a reason; a test id is a file path plus test name, e.g. \`tests/test_scrape.py::test_listing_returns_json\` or \`test/scrape.test.js#listing returns json\`, not a sentence`);
|
|
502
547
|
else if (/^no-repro$/i.test(String(t.repro).trim()) && blank(t.reason)) problems.push(`${id}: test_plan no-repro needs a reason the reviewer can reject`);
|
|
503
548
|
if (blank(t.command)) problems.push(`${id}: test_plan needs the exact command validate runs`);
|
|
504
549
|
else {
|
|
@@ -513,7 +558,7 @@ export function testPlanProblems(c, { required = false } = {}) {
|
|
|
513
558
|
|
|
514
559
|
/** #5448: a requirement that starts as an imperative build verb is development work, not a prod-only measurement. */
|
|
515
560
|
const DEV_WORK_RE = /^\W*(?:\w+\s+){0,2}?(?:find|fix|implement|develop|build|write|patch|add|change)\b/i;
|
|
516
|
-
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false } = {}) {
|
|
561
|
+
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null } = {}) {
|
|
517
562
|
const problems = [];
|
|
518
563
|
if (!c || typeof c !== "object" || Array.isArray(c)) return { ok: false, problems: ["contract.json is missing or not a JSON object"] };
|
|
519
564
|
const reqs = Array.isArray(c.requirements) ? c.requirements : [];
|
|
@@ -570,7 +615,7 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
|
|
|
570
615
|
if (repro) {
|
|
571
616
|
const t = c.repro_test;
|
|
572
617
|
if (t === "none") { if (blank(c.repro_test_reason)) problems.push(`repro_test "none" needs a one-line repro_test_reason`); }
|
|
573
|
-
else if (!t || typeof t !== "object" || Array.isArray(t) || blank(t.path) || blank(t.command)) problems.push(`this is a bug: repro_test must be {"path","id","command"} (a test that fails on the base and passes after the fix) or "none" with a repro_test_reason`);
|
|
618
|
+
else if (!t || typeof t !== "object" || Array.isArray(t) || blank(t.path) || blank(t.command)) problems.push(`this is a bug: repro_test must be {"path","id","command"} (a test that fails on the base and passes after the fix), e.g. {"path":"tests/test_scrape.py","id":"test_listing_returns_json","command":"pytest tests/test_scrape.py::test_listing_returns_json"}, or "none" with a repro_test_reason; free text is not a test id`);
|
|
574
619
|
else {
|
|
575
620
|
for (const p of tmpdirInputs(t.command)) problems.push(tmpInputProblem("repro_test", p));
|
|
576
621
|
if (guessedUvEnv(t.command)) problems.push(guessedUvProblem("repro_test"));
|
|
@@ -583,7 +628,7 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
|
|
|
583
628
|
}
|
|
584
629
|
problems.push(...testPlanProblems(c, { required: testPlan }));
|
|
585
630
|
if (JSON.stringify(c).length > MAX_CONTRACT_CHARS) problems.push(`the contract is over ${MAX_CONTRACT_CHARS} characters; keep quotes to the requirement sentence and descriptions short`);
|
|
586
|
-
if (pages) problems.push(...contractBriefProblems(c, pages)); // #5428: page deliverables need page_gate briefs
|
|
631
|
+
if (pages) problems.push(...contractBriefProblems(c, pages, { readFile })); // #5428: page deliverables need page_gate briefs
|
|
587
632
|
return { ok: problems.length === 0, problems };
|
|
588
633
|
}
|
|
589
634
|
|
|
@@ -810,8 +855,8 @@ const ENV_SIGNATURES = [
|
|
|
810
855
|
[/\bENOTFOUND\b|\bEAI_AGAIN\b|npm (?:ERR!|error) network|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)/i, "network access for npm"],
|
|
811
856
|
];
|
|
812
857
|
const envSignature = (out) => { const hit = ENV_SIGNATURES.find(([re]) => re.test(out)); return hit ? { tool: hit[1], kind: "environment" } : null; };
|
|
813
|
-
const SECRET_PAIR_RE = /\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|CREDENTIAL)[A-Za-z0-9_]*\s*[=:]\s*)\S+/gi;
|
|
814
|
-
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;
|
|
858
|
+
export const SECRET_PAIR_RE = /\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|CREDENTIAL)[A-Za-z0-9_]*\s*[=:]\s*)\S+/gi;
|
|
859
|
+
export 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;
|
|
815
860
|
/** #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). */
|
|
816
861
|
export function outputTail(output, lines = 40) {
|
|
817
862
|
const t = String(output ?? "").replace(/\x1b\[[0-9;]*[A-Za-z]/g, "").split("\n").map((l) => l.trimEnd());
|
|
@@ -1017,6 +1062,23 @@ export function repoTracks(paths) {
|
|
|
1017
1062
|
return (name) => segs.has(name) || segs.has(`${name}.py`);
|
|
1018
1063
|
}
|
|
1019
1064
|
|
|
1065
|
+
/**
|
|
1066
|
+
* #5338: a changed file under the anchors of an active decision row (architecture choice or spike `Interfaces` row,
|
|
1067
|
+
* engine-authored preserve row) needs the builder's `result.preserve` row for it with status "intact"; a lane that really
|
|
1068
|
+
* changes the interface amends {kind:"decision", decision:{..., supersedes:"<id>"}}, which removes the row. Pure.
|
|
1069
|
+
*/
|
|
1070
|
+
export function interfaceDecisionFailures(contract, result, changedFiles) {
|
|
1071
|
+
const out = [];
|
|
1072
|
+
for (const p of contract?.preserve ?? []) {
|
|
1073
|
+
if (p?.source !== "decision" || !Array.isArray(p.anchors)) continue;
|
|
1074
|
+
const hit = (changedFiles ?? []).filter((f) => p.anchors.some((a) => anchorMatches(a, f)));
|
|
1075
|
+
if (!hit.length) continue;
|
|
1076
|
+
const ack = (result?.preserve ?? []).find((x) => x?.id === p.id);
|
|
1077
|
+
if (ack?.status !== "intact") out.push({ code: C.CONFORMANCE_PRESERVE_VIOLATED, kind: "decision_unsuperseded", detail: `${p.id} (decision ${p.decision}): ${hit.slice(0, 3).join(", ")} changed under its anchors without a supersedes decision; report preserve ${p.id} intact, or amend {kind:"decision", decision:{choice, anchors, supersedes:"${p.decision}"}, why}` });
|
|
1078
|
+
}
|
|
1079
|
+
return out;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1020
1082
|
/**
|
|
1021
1083
|
* Deterministic checks before any reviewer tokens are spent: unauthorized files, failed or missing validation,
|
|
1022
1084
|
* requirements not implemented, deferrals without a tracking issue, and unexempted hotspot growth. Returns {ok, failures[], superseded[]}; each failure carries a
|
|
@@ -1032,7 +1094,7 @@ export function repoTracks(paths) {
|
|
|
1032
1094
|
* `ciCovered` (#4527): the validate ids accepted only because the head is CI-verified (no local result, or a missing host
|
|
1033
1095
|
* tool), for the trajectory; always an array.
|
|
1034
1096
|
*/
|
|
1035
|
-
export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, baselineFailures = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, docsFailures = null, pageFailures = null, docsPaths = null, prodParityFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [], uiBrowser = null }) {
|
|
1097
|
+
export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, baselineFailures = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, docsFailures = null, pageFailures = null, docsPaths = null, prodParityFailures = null, seamFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [], uiBrowser = null }) {
|
|
1036
1098
|
const failures = [], superseded = [], ciCovered = [];
|
|
1037
1099
|
// #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)
|
|
1038
1100
|
if (checkIds) for (const r of contract.requirements ?? []) {
|
|
@@ -1110,6 +1172,8 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1110
1172
|
failures.push(...(docsFailures ?? [])); // #5419: forge.yaml docs
|
|
1111
1173
|
failures.push(...(pageFailures ?? [])); // #5428: forge.yaml pages
|
|
1112
1174
|
failures.push(...(prodParityFailures ?? [])); // #5284: topology.prod_parity
|
|
1175
|
+
failures.push(...interfaceDecisionFailures(contract, result, changedFiles)); // #5338
|
|
1176
|
+
failures.push(...(seamFailures ?? [])); // #5338: a declared interface's provider and consumer no longer agree
|
|
1113
1177
|
return { ok: failures.length === 0, failures, superseded, ciCovered };
|
|
1114
1178
|
}
|
|
1115
1179
|
|
|
@@ -1132,8 +1196,10 @@ function frozenAmendedFiles(frozen, contract, outside, creep) {
|
|
|
1132
1196
|
* #4334: HEAD=UNRUNNABLE or no words (the harness could not run the test) is env.repro_unrunnable, kind repro_env: an
|
|
1133
1197
|
* environment error, never a builder resume.
|
|
1134
1198
|
*/
|
|
1135
|
-
export function reproFailures(contract, { base, head } = {}) {
|
|
1199
|
+
export function reproFailures(contract, { base, head, pristine } = {}) {
|
|
1136
1200
|
if (head === "RAN" && base === "FAILED") return [];
|
|
1201
|
+
// #5544: head's test passes on base source but the base's own version of it fails: a test-only fix, not already fixed
|
|
1202
|
+
if (head === "RAN" && base === "RAN" && pristine === "FAILED") return [];
|
|
1137
1203
|
const t = contract?.repro_test ?? {};
|
|
1138
1204
|
const name = [t.path, t.id].filter((x) => !blank(x)).join(" ") || "repro_test";
|
|
1139
1205
|
if (!head || head === "UNRUNNABLE") {
|
|
@@ -1387,18 +1453,23 @@ export function isE2eCommand(command, e2e = null) {
|
|
|
1387
1453
|
export function prodOnlyE2e(quote) {
|
|
1388
1454
|
const q = String(quote ?? "");
|
|
1389
1455
|
if (/\b(?:localhost|127\.0\.0\.1|local stack|playwright|browser|sandbox|staging)\b/i.test(q)) return false;
|
|
1390
|
-
return /https?:\/\//i.test(q) || /\b(?:after (?:the )?deploy|production|prod probe|live (?:domain|site)|prod)\b/i.test(q);
|
|
1456
|
+
return /https?:\/\//i.test(q) || /\b(?:after (?:the )?deploy|production|prod probe|live (?:domain|site)|prod)\b/i.test(q) || PROD_WINDOW_RE.test(q);
|
|
1391
1457
|
}
|
|
1458
|
+
/** #5524: production observation windows without a URL: a metric/alert window, "at the next <weekday>", current volume, a prod host. */
|
|
1459
|
+
const PROD_WINDOW_RE = /\b(?:over|for|within|across)\s+(?:the\s+(?:last|next)\s+)?\d+\s*(?:h|hrs?|hours?|d|days?|w|weeks?|min|minutes?)\b|\bat the next (?:mon|tues?|wednes|thurs?|fri|sat(?:ur)?|sun)(?:day)?\b|\bat current (?:volume|traffic|load)\b|\bon (?:OVH|prod(?:uction)?)\b|\b\w*Slo\w*Burn\w*\b|\bSLO\b|\b(?:does not|doesn't|did not) fire\b/i;
|
|
1392
1460
|
/**
|
|
1393
1461
|
* #5468: rewrite production-only e2e/manual rows (deliver or defer; only `only` ids when given) to `post-deploy` with a generated
|
|
1394
|
-
* check id. Pure; returns {contract, converted:[{id, check, entry}]}. A row
|
|
1462
|
+
* check id. Pure; returns {contract, converted:[{id, check, entry}]}. A row with no probeable URL becomes a checkless post-deploy row (check: null).
|
|
1395
1463
|
*/
|
|
1396
1464
|
export function autoPostDeployE2e(contract, only = null) {
|
|
1397
1465
|
const converted = [];
|
|
1398
1466
|
const requirements = (Array.isArray(contract?.requirements) ? contract.requirements : []).map((r) => {
|
|
1399
1467
|
if (!["deliver", "defer"].includes(r?.disposition) || !wantsE2e(r) || (only && !only.includes(r.id)) || isOutOfBand(r) || !prodOnlyE2e(r.quote)) return r;
|
|
1400
1468
|
const g = e2eCheckFor(r.id, r.quote);
|
|
1401
|
-
if (!g)
|
|
1469
|
+
if (!g) { // #5524: no probeable URL: a checkless post-deploy row; deferChecklessPostDeploy routes it to the orchestrator
|
|
1470
|
+
converted.push({ id: r.id, check: null, entry: null });
|
|
1471
|
+
return { ...r, disposition: "post-deploy", bucket: "post-deploy", local_infeasible_why: "the observable is a production observation window with no probeable URL", why: "production observation window: read-only production telemetry, no probeable URL (#5524)" };
|
|
1472
|
+
}
|
|
1402
1473
|
converted.push({ id: r.id, check: g.id, entry: g.entry });
|
|
1403
1474
|
return { ...r, disposition: "post-deploy", bucket: "post-deploy", check: g.id, local_infeasible_why: "the observable exists only in production (live domain or deploy), so no local fixture can check it", why: "production-only e2e/manual criterion: converted by the engine to a post-deploy check (#5468)" };
|
|
1404
1475
|
});
|
|
@@ -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 { testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, 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";
|
|
6
|
+
import { testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, 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, mockedDeliverable, proofEchoDetail, contractRuleCounts, onlyTestPlanProblems } 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.";
|
|
@@ -842,6 +842,14 @@ describe("repro_test on bug lanes (#4271)", () => {
|
|
|
842
842
|
assert.match(reproFailures(k, { base: "SKIPPED", head: "FAILED" })[0].detail, /HEAD=FAILED \(base not run: head did not pass\)$/);
|
|
843
843
|
assert.doesNotMatch(reproFailures(k, { base: "RAN", head: "RAN" })[0].detail, /base not run/);
|
|
844
844
|
});
|
|
845
|
+
it("#5544 BASE=RAN HEAD=RAN PRISTINE=FAILED is a test-only fix: no repro_base_green, not already fixed", () => {
|
|
846
|
+
const k = { ...C, repro_test: RT };
|
|
847
|
+
const testOnly = ["test/leak.test.js"];
|
|
848
|
+
const pc = precheck({ contract: k, result: res, changedFiles: testOnly, repro: { base: "RAN", head: "RAN", pristine: "FAILED" } });
|
|
849
|
+
assert.equal(pc.failures.some((f) => f.kind === "repro_base_green"), false);
|
|
850
|
+
assert.equal(alreadyFixedOnBase(pc.failures, testOnly), false);
|
|
851
|
+
assert.deepEqual(reproFailures(k, { base: "RAN", head: "RAN", pristine: "RAN" }).map((f) => f.kind), ["repro_base_green"]);
|
|
852
|
+
});
|
|
845
853
|
it("#5080 repro_base_green: BASE=RAN HEAD=RAN is its own kind, and a test-only diff with a source deliverable is never the fix", () => {
|
|
846
854
|
const k = { ...C, repro_test: RT };
|
|
847
855
|
const green = precheck({ contract: k, result: res, changedFiles: files, repro: { base: "RAN", head: "RAN" } });
|
|
@@ -1821,18 +1829,40 @@ describe("test plan frozen with the contract (#5445)", () => {
|
|
|
1821
1829
|
assert.equal(bug(K([row("R1", { repro: "no-repro", reason: "spec-only change" }), row("R2")])), "");
|
|
1822
1830
|
});
|
|
1823
1831
|
it("a proof that echoes a deliverable is rejected; one about the 403 is accepted", () => {
|
|
1824
|
-
assert.match(bug(K([row("R1", { proof: "the listing .json URL is rewritten to old.reddit.com" }), row("R2")])), /R1: test_plan proof
|
|
1832
|
+
assert.match(bug(K([row("R1", { proof: "the listing .json URL is rewritten to old.reddit.com" }), row("R2")])), /R1: test_plan proof restates a deliverable: ≥70% of the proof's words repeat deliverable D1 \(\d+%\); phrase it as the wrong behaviour observed on base/);
|
|
1825
1833
|
assert.equal(proofEchoesDeliverable("the listing json URL is rewritten", D.slice(0, 1)), true);
|
|
1826
1834
|
assert.equal(proofEchoesDeliverable("returns 200 JSON instead of 403", D.slice(0, 1)), false);
|
|
1835
|
+
assert.equal(proofEchoDetail("the listing json URL is rewritten", D.slice(0, 1)).id, "D1");
|
|
1836
|
+
});
|
|
1837
|
+
it("#5592: naming the function under test does not make a proof an echo; a blank repro gets a literal test id example", () => {
|
|
1838
|
+
const d = [{ id: "D1", path: "src/scrape.js", change: "fix fetchListing so the listing url uses old.reddit.com", requirements: ["R1"] }];
|
|
1839
|
+
assert.equal(proofEchoesDeliverable("`fetchListing` returns 403 for www.reddit.com", d), false);
|
|
1840
|
+
assert.equal(proofEchoesDeliverable("fetchListing() fetch_listing listing", d), false, "fewer than 3 prose words left: nothing to judge");
|
|
1841
|
+
assert.equal(proofEchoesDeliverable("the listing url uses old.reddit.com", d), true);
|
|
1842
|
+
assert.match(testPlanProblems(K([row("R1", { repro: "" })])).join(), /e\.g\. `tests\/test_scrape\.py::test_listing_returns_json`/);
|
|
1827
1843
|
});
|
|
1828
1844
|
it("level, its reason and the command are checked; mocking the bug's component is rejected", () => {
|
|
1829
1845
|
assert.match(testPlanProblems(K([row("R1", { level: "manual" })])).join(), /level must be one of/);
|
|
1830
1846
|
assert.match(testPlanProblems(K([row("R1", { level_reason: "" })])).join(), /level_reason/);
|
|
1831
|
-
assert.match(testPlanProblems(K([row("R1", { level_reason: "mock the
|
|
1847
|
+
assert.match(testPlanProblems(K([row("R1", { level_reason: "mock the listing URL rewrite" })])).join(), /level_reason mocks "mock the listing URL rewrite", which is in deliverable D1; level_reason must not contain the words mock\/stub\/fake unless negated/);
|
|
1848
|
+
for (const ok of ["real AsyncSession; stub only the Umami HTTP endpoint", "fake clock drives the expiry", "no mocks needed, real fixture"]) assert.equal(testPlanProblems(K([row("R1", { level_reason: ok })])).length, 0, ok);
|
|
1849
|
+
assert.equal(mockedDeliverable("stub the search handler", D.slice(0, 1)), null);
|
|
1850
|
+
assert.equal(mockedDeliverable("the scrape module is mocked", D.slice(0, 1)).id, "D1");
|
|
1832
1851
|
assert.equal(testPlanProblems(K([row("R1", { level_reason: "no mocks needed, real fixture" })])).length, 0);
|
|
1833
1852
|
assert.match(testPlanProblems(K([row("R1", { command: "" })])).join(), /exact command/);
|
|
1834
1853
|
assert.match(testPlanProblems({ ...C, test_plan: "x" }).join(), /must be an array/);
|
|
1835
1854
|
});
|
|
1855
|
+
it("#5587: rule ids are counted, the corrections carry the allowed level and the worked example, and only test-plan problems earn a second round", () => {
|
|
1856
|
+
const mock = testPlanProblems(K([row("R1", { level_reason: "mock the listing URL rewrite" }), row("R2", { proof: "the listing json URL is rewritten", command: "" })]));
|
|
1857
|
+
assert.match(mock.join("\n"), /real instance of D1's component, with stubs only at its I\/O boundary \(clock, network, browser factory\) and, for DB code, a real database session/);
|
|
1858
|
+
assert.deepEqual(contractRuleCounts(mock), { "test_plan.mock": 1, "test_plan.command": 1 });
|
|
1859
|
+
const echo = testPlanProblems(K([row("R1", { proof: "the listing json URL is rewritten to old.reddit.com" })]));
|
|
1860
|
+
assert.match(echo.join(), /symptom observed today → assertion that fails on base and passes on head, e\.g\./);
|
|
1861
|
+
assert.deepEqual(contractRuleCounts(echo), { "test_plan.echo": 1 });
|
|
1862
|
+
assert.equal(onlyTestPlanProblems(mock), true);
|
|
1863
|
+
assert.equal(onlyTestPlanProblems([...mock, "R1: quote is not verbatim"]), false);
|
|
1864
|
+
assert.equal(onlyTestPlanProblems([]), false);
|
|
1865
|
+
});
|
|
1836
1866
|
it("applyValidateRecipes rewrites test_plan commands", () => {
|
|
1837
1867
|
const r = applyValidateRecipes(K([row("R1")]), [{ match: "^node --test", replace: "npx node --test" }]);
|
|
1838
1868
|
assert.equal(r.contract.test_plan[0].command, "npx node --test test/x.test.js");
|
|
@@ -1928,3 +1958,68 @@ describe("#5468 production-only e2e/manual criteria become post-deploy checks",
|
|
|
1928
1958
|
assert.equal(o.a.run, "x"); assert.equal(o.b.run, "z");
|
|
1929
1959
|
});
|
|
1930
1960
|
});
|
|
1961
|
+
|
|
1962
|
+
import { interfaceDecisionFailures } from "./conformance.mjs";
|
|
1963
|
+
describe("interface decisions at precheck (#5338)", () => {
|
|
1964
|
+
const row = { id: "H1", what: "Interface api -> worker", source: "decision", decision: "i7-2", anchors: ["worker/refund.py", "api/"] };
|
|
1965
|
+
const c = { requirements: [], preserve: [row] };
|
|
1966
|
+
it("flags a changed anchored file without an intact preserve report", () => {
|
|
1967
|
+
const f = interfaceDecisionFailures(c, {}, ["worker/refund.py"]);
|
|
1968
|
+
assert.deepEqual(f.map((x) => x.kind), ["decision_unsuperseded"]);
|
|
1969
|
+
assert.match(f[0].detail, /supersedes:"i7-2"/);
|
|
1970
|
+
assert.equal(interfaceDecisionFailures(c, { preserve: [{ id: "H1", status: "violated" }] }, ["api/x.py"]).length, 1);
|
|
1971
|
+
});
|
|
1972
|
+
it("passes when acknowledged, superseded (row removed), or no anchored file changed", () => {
|
|
1973
|
+
assert.deepEqual(interfaceDecisionFailures(c, { preserve: [{ id: "H1", status: "intact" }] }, ["api/x.py"]), []);
|
|
1974
|
+
assert.deepEqual(interfaceDecisionFailures({ preserve: [] }, {}, ["api/x.py"]), []);
|
|
1975
|
+
assert.deepEqual(interfaceDecisionFailures(c, {}, ["web/a.ts"]), []);
|
|
1976
|
+
assert.deepEqual(interfaceDecisionFailures({ preserve: [{ ...row, anchors: ["db/"] }] }, {}, ["api/x.py"]), []);
|
|
1977
|
+
});
|
|
1978
|
+
it("precheck surfaces it and stays ok without interface rows", () => {
|
|
1979
|
+
const res = { requirements: [], validation: [] };
|
|
1980
|
+
assert.equal(precheck({ contract: { requirements: [], deliverables: [], preserve: [row] }, result: res, changedFiles: ["api/x.py"], ignore: ["api/x.py"] }).failures.some((x) => x.kind === "decision_unsuperseded"), true);
|
|
1981
|
+
assert.equal(precheck({ contract: { requirements: [], deliverables: [], preserve: [] }, result: res, changedFiles: [] }).failures.some((x) => x.kind === "decision_unsuperseded"), false);
|
|
1982
|
+
});
|
|
1983
|
+
});
|
|
1984
|
+
describe("#5524 URL-less production-only e2e/manual rows", () => {
|
|
1985
|
+
const Q40655 = "On OVH after deploy, a Monday report closed during the day is not re-created (verified at the next Monday) [type:manual]";
|
|
1986
|
+
const Q40662 = "T1 succeeded slow ratio < 0.05 over 24h, and `JobTurnaroundSloSlowBurn` does not fire at current volume for 7 days [type:manual]";
|
|
1987
|
+
const Q40486 = "Re-run the #38833 R3 probe after deploy [type:manual]";
|
|
1988
|
+
const LQ = "The signup page works against the local stack in a browser over 24h [type:e2e]";
|
|
1989
|
+
const mk = (quote) => ({ ...C, requirements: [{ id: "R1", quote, disposition: "deliver" }, C.requirements[1]] });
|
|
1990
|
+
it("#5524 prodOnlyE2e recognises observation windows", () => {
|
|
1991
|
+
for (const q of [Q40655, Q40662, Q40486, "ratio stays low over 24h [type:manual]", "no alert for 7 days [type:manual]", "restored at the next Tuesday [type:manual]", "holds at current volume [type:manual]", "runs on OVH [type:manual]"]) assert.equal(prodOnlyE2e(q), true, q);
|
|
1992
|
+
for (const q of [LQ, "works on staging for 7 days [type:e2e]", "sandbox run over 24h [type:e2e]"]) assert.equal(prodOnlyE2e(q), false, q);
|
|
1993
|
+
});
|
|
1994
|
+
it("#5524 URL-less production-only rows convert to checkless post-deploy", () => {
|
|
1995
|
+
for (const q of [Q40655, Q40662, Q40486]) {
|
|
1996
|
+
const out = autoPostDeployE2e(mk(q));
|
|
1997
|
+
assert.equal(out.converted.length, 1);
|
|
1998
|
+
assert.equal(out.converted[0].check, null);
|
|
1999
|
+
assert.equal(out.contract.requirements[0].disposition, "post-deploy");
|
|
2000
|
+
const d = deferChecklessPostDeploy(out.contract);
|
|
2001
|
+
assert.deepEqual(d.converted, ["R1"]);
|
|
2002
|
+
assert.equal(d.contract.requirements[0].disposition, "defer");
|
|
2003
|
+
assert.equal(d.contract.requirements[0].bucket, "owner:orchestrator");
|
|
2004
|
+
assert.equal(d.contract.requirements[1].disposition, "deliver");
|
|
2005
|
+
}
|
|
2006
|
+
});
|
|
2007
|
+
it("#5524 replay: URL rows keep a check id and a local-only quote stays deliver", () => {
|
|
2008
|
+
const out = autoPostDeployE2e(mk("`https://store.alterlab.io/x` returns 200 after deploy [type:e2e]"));
|
|
2009
|
+
assert.match(out.contract.requirements[0].check, /^e2e-r1-/);
|
|
2010
|
+
assert.equal(autoPostDeployE2e(mk(LQ)).converted.length, 0);
|
|
2011
|
+
assert.equal(autoPostDeployE2e(mk(LQ)).contract.requirements[0].disposition, "deliver");
|
|
2012
|
+
});
|
|
2013
|
+
it("#5524 review converts URL-less lone e2e_unverified", () => {
|
|
2014
|
+
const contract = { ...mk(Q40655), validate: [{ id: "V1", command: "pytest tests/test_x.py" }] };
|
|
2015
|
+
const lctx = { ...ctx, contract, issueText: `${ISSUE}\n${Q40655}` };
|
|
2016
|
+
const r = { ...good, issue_coverage: [{ quote: Q40655, status: "covered" }, ...good.issue_coverage.slice(1)] };
|
|
2017
|
+
const d = decide(r, lctx);
|
|
2018
|
+
assert.equal(d.state, "nonconforming");
|
|
2019
|
+
const ids = loneE2eRows(d.failures);
|
|
2020
|
+
assert.deepEqual(ids, ["R1"]);
|
|
2021
|
+
const cv = autoPostDeployE2e(contract, ids);
|
|
2022
|
+
assert.equal(cv.converted.length, ids.length);
|
|
2023
|
+
assert.equal(deferChecklessPostDeploy(cv.contract).contract.requirements[0].disposition, "defer");
|
|
2024
|
+
});
|
|
2025
|
+
});
|
package/bin/lean/decisions.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import * as nodeFs from "node:fs";
|
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { join } from "node:path";
|
|
15
15
|
import { noComments } from "./render.mjs";
|
|
16
|
+
import { parseSeamForm, roleAnchors, buildSeam, SEAM_KINDS } from "./seam.mjs";
|
|
16
17
|
|
|
17
18
|
export const DECISION_MARKER = "FORGE:DECISION";
|
|
18
19
|
/** Preserve rows the engine adds from history per lane; guards (#4694) share this cap. */
|
|
@@ -28,6 +29,19 @@ const one = (v, max = TEXT_MAX) => {
|
|
|
28
29
|
const strs = (v, max = ANCHORS_MAX, len = 200) => [...new Set((Array.isArray(v) ? v : []).map((x) => one(x, len)).filter(Boolean))].slice(0, max);
|
|
29
30
|
const cleanAnchor = (a) => String(a).replace(/^\.\//, "").replace(/^\/+/, "");
|
|
30
31
|
|
|
32
|
+
/** #5338: a stored seam (machine form of an interface) bounded and validated, or null. */
|
|
33
|
+
function cleanSeam(v) {
|
|
34
|
+
if (!v || typeof v !== "object" || !SEAM_KINDS.includes(v.kind) || !v[v.kind] || typeof v[v.kind] !== "object") return null;
|
|
35
|
+
const provider = strs(v.provider).map(cleanAnchor), consumer = strs(v.consumer).map(cleanAnchor);
|
|
36
|
+
if (!provider.length || !consumer.length) return null;
|
|
37
|
+
const form = v[v.kind];
|
|
38
|
+
const body = v.kind === "route" ? { method: one(form.method, 10), path: one(form.path, 200) }
|
|
39
|
+
: v.kind === "symbol" ? { name: one(form.name, 80), params: (Array.isArray(form.params) ? form.params : []).slice(0, 20).map((p) => ({ name: one(p?.name, 60), optional: Boolean(p?.optional), variadic: Boolean(p?.variadic) })).filter((p) => p.name) }
|
|
40
|
+
: { fields: strs(form.fields, 30, 60) };
|
|
41
|
+
if ((v.kind === "route" && (!body.method || !body.path)) || (v.kind === "symbol" && !body.name) || (v.kind === "payload" && !body.fields.length)) return null;
|
|
42
|
+
return { kind: v.kind, auth: one(v.auth, 160), provider, consumer, [v.kind]: body };
|
|
43
|
+
}
|
|
44
|
+
|
|
31
45
|
/** A bounded decision record from raw input, or null when it has no choice or no anchor. `issue` is the register issue. */
|
|
32
46
|
export function normaliseDecision(raw, { issue = null, n = 1 } = {}) {
|
|
33
47
|
const r = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
@@ -38,6 +52,10 @@ export function normaliseDecision(raw, { issue = null, n = 1 } = {}) {
|
|
|
38
52
|
const rec = { v: 1, id: one(r.id, 60) || `d${iss ?? 0}-${n}`, choice, why: one(r.why), anchors, issue: iss, status };
|
|
39
53
|
const symbols = strs(r.symbols, ANCHORS_MAX, 80);
|
|
40
54
|
if (symbols.length) rec.symbols = symbols;
|
|
55
|
+
const consumers = strs(r.consumers, ANCHORS_MAX, 120); // #5338: issues (#N) or names of the code that builds against an interface
|
|
56
|
+
if (consumers.length) rec.consumers = consumers;
|
|
57
|
+
const seam = cleanSeam(r.seam);
|
|
58
|
+
if (seam) rec.seam = seam;
|
|
41
59
|
if (one(r.supersedes, 60)) rec.supersedes = one(r.supersedes, 60);
|
|
42
60
|
if (status === "superseded" && one(r.superseded_by, 60)) rec.superseded_by = one(r.superseded_by, 60);
|
|
43
61
|
return rec;
|
|
@@ -112,6 +130,7 @@ export function historyRows(records, deliverablePaths, { cap = HISTORY_ROWS_MAX,
|
|
|
112
130
|
what: `${d.choice}${d.why ? ` (${d.why})` : ""} [decision ${d.id}${d.issue ? `, #${d.issue}` : ""}; to change it, amend {kind:"decision", decision:{choice, anchors, supersedes:"${d.id}"}, why}]`,
|
|
113
131
|
source: "decision",
|
|
114
132
|
decision: d.id,
|
|
133
|
+
anchors: d.anchors,
|
|
115
134
|
}));
|
|
116
135
|
}
|
|
117
136
|
|
|
@@ -127,7 +146,8 @@ export function withDecisionRows(contract, records) {
|
|
|
127
146
|
|
|
128
147
|
/** {old, next}: the old record marked superseded by the new id, the new one linked back with `supersedes`. */
|
|
129
148
|
export function supersede(old, next) {
|
|
130
|
-
|
|
149
|
+
const inherit = !next.consumers?.length && old.consumers?.length ? { consumers: old.consumers } : {}; // #5338: the consumers of the old interface still consume the new one
|
|
150
|
+
return { old: { ...old, status: "superseded", superseded_by: next.id }, next: { ...next, ...inherit, supersedes: old.id } };
|
|
131
151
|
}
|
|
132
152
|
|
|
133
153
|
export const decisionsDir = () => process.env.FORGEDOCK_DECISIONS_DIR || join(homedir(), ".forge", "decisions");
|
|
@@ -179,3 +199,68 @@ export async function recordDecisions(list, { issue, repo, post, fs = nodeFs })
|
|
|
179
199
|
if (out.length) writeDecisionIndex(repo, index, { fs });
|
|
180
200
|
return out;
|
|
181
201
|
}
|
|
202
|
+
|
|
203
|
+
const cells = (line) => line.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
|
|
204
|
+
const anchorList = (s) => [...String(s ?? "").matchAll(/`([^`]+)`/g)].map((m) => m[1]);
|
|
205
|
+
const placeholder = (s) => /^\{.*\}$/.test(String(s ?? "").trim());
|
|
206
|
+
const consumerList = (s) => String(s ?? "").split(/[,;]/).map((x) => x.replace(/`/g, "").trim()).filter((x) => x && !placeholder(x) && !/^(none|n\/a|-)$/i.test(x));
|
|
207
|
+
|
|
208
|
+
const sectionsOf = (text) => {
|
|
209
|
+
const secs = [];
|
|
210
|
+
let fence = null;
|
|
211
|
+
for (const line of String(text ?? "").replace(/\r\n/g, "\n").split("\n")) {
|
|
212
|
+
const f = /^[ \t]*(`{3,}|~{3,})/.exec(line);
|
|
213
|
+
if (f) { fence = fence ? (f[1][0] === fence ? null : fence) : f[1][0]; if (secs.length) secs.at(-1).lines.push(line); continue; }
|
|
214
|
+
const h = fence ? null : /^##(?!#)[ \t]+(.+?)[ \t]*$/.exec(line);
|
|
215
|
+
if (h) secs.push({ heading: h[1], lines: [] });
|
|
216
|
+
else if (secs.length) secs.at(-1).lines.push(line);
|
|
217
|
+
}
|
|
218
|
+
return secs;
|
|
219
|
+
};
|
|
220
|
+
const COLS = { boundary: /^boundary|^seam|^interface/i, signature: /^signature|^schema|^contract/i, auth: /^auth/i, owner: /^owner/i, anchors: /^anchors?/i, consumers: /^consumers?/i };
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* #5338: the rows of the `## Interfaces` section of a spike or epic body: [{boundary, signature, auth, owner, anchors,
|
|
224
|
+
* consumers, roles, seam}]. Columns are matched by header name (Boundary | Signature or schema | Auth mode | Owner issue |
|
|
225
|
+
* Anchors | Consumers?), a five-column table without Consumers is valid. `{...}` template rows and rows with no anchor
|
|
226
|
+
* are skipped. `anchors` are the backticked paths (`provider:`/`consumer:` prefixes are roles, see seam.mjs). Pure.
|
|
227
|
+
*/
|
|
228
|
+
export const interfaceRows = (text) => rowsOfSection(sectionsOf(text).find((x) => /^interfaces\b/i.test(x.heading)));
|
|
229
|
+
function rowsOfSection(sec) {
|
|
230
|
+
const rows = (sec?.lines ?? []).filter((l) => l.trim().startsWith("|"));
|
|
231
|
+
if (rows.length < 3) return [];
|
|
232
|
+
const head = cells(rows[0]), idx = {};
|
|
233
|
+
for (const [k, re] of Object.entries(COLS)) idx[k] = head.findIndex((h) => re.test(h));
|
|
234
|
+
for (const [k, d] of Object.entries({ boundary: 0, signature: 1, auth: 2, owner: 3, anchors: 4 })) if (idx[k] < 0) idx[k] = d;
|
|
235
|
+
const out = [];
|
|
236
|
+
for (const l of rows.slice(2)) {
|
|
237
|
+
const c = cells(l), get = (k) => (idx[k] >= 0 ? c[idx[k]] ?? "" : "");
|
|
238
|
+
const boundary = get("boundary"), signature = get("signature");
|
|
239
|
+
if (!boundary || [boundary, signature, get("anchors")].some(placeholder)) continue;
|
|
240
|
+
const roles = roleAnchors(anchorList(get("anchors")));
|
|
241
|
+
if (!roles.all.length) continue;
|
|
242
|
+
const form = parseSeamForm(signature);
|
|
243
|
+
out.push({ boundary, signature, auth: get("auth"), owner: get("owner"), anchors: roles.all, consumers: consumerList(get("consumers")), roles, seam: buildSeam(form, roles, get("auth")) });
|
|
244
|
+
}
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* #5338: decision records from a technical spike or a feature epic. Each row of the `## Interfaces` table becomes
|
|
250
|
+
* "Interface <boundary>: <signature>; auth <mode>; owner <issue>" (carrying its consumers and, when the signature is a
|
|
251
|
+
* route, function or payload, its machine-form `seam`), and any other `## ` section that has both a `**Rationale**:` and
|
|
252
|
+
* an `**Anchors**:` line becomes "<heading>: <rationale>". Ids are `i<issue>-<n>`; pure, no LLM.
|
|
253
|
+
*/
|
|
254
|
+
export function interfaceDecisions(spikeText, { issue = null } = {}) {
|
|
255
|
+
const raw = [];
|
|
256
|
+
for (const s of sectionsOf(spikeText)) {
|
|
257
|
+
if (/^interfaces\b/i.test(s.heading)) {
|
|
258
|
+
for (const r of rowsOfSection(s)) raw.push({ choice: `Interface ${r.boundary}: ${r.signature}; auth ${r.auth}; owner ${r.owner}`, why: "Interfaces", anchors: r.anchors, consumers: r.consumers, seam: r.seam });
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const why = s.lines.map((l) => /\*\*Rationale\*\*:\s*(.+)/.exec(l)?.[1]).find(Boolean);
|
|
262
|
+
const anchors = anchorList(s.lines.map((l) => /\*\*Anchors\*\*:\s*(.+)/.exec(l)?.[1]).find(Boolean));
|
|
263
|
+
if (why && anchors.length && !placeholder(why)) raw.push({ choice: `${s.heading}: ${why}`, why: "architecture choice", anchors });
|
|
264
|
+
}
|
|
265
|
+
return raw.map((r, i) => normaliseDecision({ ...r, id: `i${issue ?? 0}-${i + 1}` }, { issue, n: i + 1 })).filter(Boolean);
|
|
266
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
6
|
-
import { normaliseDecision, renderDecision, parseDecisionComment, foldDecisions, anchorMatches, deadAnchors, staleDecisions, historyRows, withDecisionRows, supersede, readDecisionIndex, recordDecisions, HISTORY_ROWS_MAX } from "./decisions.mjs";
|
|
6
|
+
import { normaliseDecision, interfaceDecisions, renderDecision, parseDecisionComment, foldDecisions, anchorMatches, deadAnchors, staleDecisions, historyRows, withDecisionRows, supersede, readDecisionIndex, recordDecisions, HISTORY_ROWS_MAX } from "./decisions.mjs";
|
|
7
7
|
|
|
8
8
|
const D = (o) => normaliseDecision({ choice: "use A not B", why: "B leaks", anchors: ["src/a/**"], ...o }, { issue: 10, n: 1 });
|
|
9
9
|
|
|
@@ -68,4 +68,24 @@ describe("decisions (#4695)", () => {
|
|
|
68
68
|
assert.equal(idx.find((d) => d.id === "d10-1").status, "superseded");
|
|
69
69
|
assert.equal(idx.find((d) => d.id === "d11-1").supersedes, "d10-1");
|
|
70
70
|
});
|
|
71
|
+
it("interface decisions (#5338): spike rows and anchored choices become records; lanes on the anchors get H-rows; supersedes retires one", () => {
|
|
72
|
+
const spike = [
|
|
73
|
+
"## Stack", "next", "**Rationale**: one framework", "**Anchors**: `web/`", "",
|
|
74
|
+
"## Interfaces", "| Boundary | Signature or schema | Auth mode | Owner issue | Anchors |", "|---|---|---|---|---|",
|
|
75
|
+
"| api -> worker | refund(id: str, amount: int) | internal key | WORKER | `worker/refund.py`, `api/` |",
|
|
76
|
+
"| {x} | {y} | {z} | {o} | `{p}` |", "| no anchor | sig | key | O | |", "",
|
|
77
|
+
].join("\n");
|
|
78
|
+
const recs = interfaceDecisions(spike, { issue: 7 });
|
|
79
|
+
assert.deepEqual(recs.map((r) => r.id), ["i7-1", "i7-2"]);
|
|
80
|
+
assert.deepEqual(recs.map((r) => r.anchors), [["web/"], ["worker/refund.py", "api/"]]);
|
|
81
|
+
assert.equal(recs[1].choice, "Interface api -> worker: refund(id: str, amount: int); auth internal key; owner WORKER");
|
|
82
|
+
const lane = withDecisionRows({ deliverables: [{ id: "D1", path: "worker/refund.py" }], preserve: [] }, recs);
|
|
83
|
+
assert.equal(lane.preserve.length, 1);
|
|
84
|
+
assert.equal(lane.preserve[0].source, "decision");
|
|
85
|
+
assert.match(lane.preserve[0].what, /Interface api -> worker.*supersedes:"i7-2"/);
|
|
86
|
+
const { old, next } = supersede(recs[1], D({ id: "n" }));
|
|
87
|
+
const gone = withDecisionRows({ deliverables: [{ id: "D1", path: "worker/refund.py" }], preserve: [] }, [...recs, old, next]);
|
|
88
|
+
assert.ok(gone.preserve.every((p) => p.decision !== "i7-2"));
|
|
89
|
+
assert.deepEqual(interfaceDecisions("## Interfaces\nnone", { issue: 1 }), []);
|
|
90
|
+
});
|
|
71
91
|
});
|