forgedock 1.54.1 → 1.55.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/engine/events.mjs +1 -0
- package/bin/engine/events.test.mjs +5 -1
- package/bin/engine/outcome-codes.mjs +3 -0
- package/bin/engine-cli.mjs +126 -34
- package/bin/forgedock.mjs +54 -2
- package/bin/gc-schedule.mjs +83 -0
- package/bin/gc.mjs +56 -8
- package/bin/help-text.mjs +1 -1
- package/bin/hooks/pre-tool-use.mjs +1 -0
- package/bin/init-detect.mjs +73 -2
- package/bin/labels.json +5 -0
- package/bin/lean/admission.mjs +21 -1
- package/bin/lean/baselines.mjs +43 -0
- package/bin/lean/baselines.test.mjs +33 -0
- package/bin/lean/batch-health.mjs +43 -6
- package/bin/lean/batch-health.test.mjs +41 -1
- package/bin/lean/batch.mjs +41 -4
- package/bin/lean/batch.test.mjs +106 -3
- package/bin/lean/conformance.mjs +131 -12
- package/bin/lean/conformance.test.mjs +172 -3
- package/bin/lean/depcache.mjs +23 -2
- package/bin/lean/depcache.test.mjs +22 -0
- package/bin/lean/docsgate.mjs +137 -0
- package/bin/lean/docsgate.test.mjs +78 -0
- package/bin/lean/effects.mjs +31 -2
- package/bin/lean/enumerating.mjs +39 -13
- package/bin/lean/enumerating.test.mjs +20 -0
- package/bin/lean/execution.test.mjs +3 -3
- package/bin/lean/fastforward.mjs +93 -0
- package/bin/lean/fastforward.test.mjs +73 -0
- package/bin/lean/guardgate.mjs +38 -7
- package/bin/lean/guardgate.test.mjs +39 -0
- package/bin/lean/issuewatch-install.mjs +92 -0
- package/bin/lean/issuewatch-install.test.mjs +31 -0
- package/bin/lean/issuewatch-parity.mjs +33 -3
- package/bin/lean/issuewatch-parity.test.mjs +30 -5
- package/bin/lean/issuewatch-reconcile.mjs +123 -0
- package/bin/lean/issuewatch-reconcile.test.mjs +30 -0
- package/bin/lean/issuewatch-verify.mjs +51 -9
- package/bin/lean/issuewatch.mjs +153 -33
- package/bin/lean/issuewatch.test.mjs +243 -22
- package/bin/lean/lean.mjs +381 -75
- package/bin/lean/lean.test.mjs +437 -20
- package/bin/lean/light.mjs +11 -3
- package/bin/lean/light.test.mjs +27 -0
- package/bin/lean/lightlane.mjs +8 -3
- package/bin/lean/lightlane.test.mjs +20 -0
- package/bin/lean/mechfix.mjs +21 -2
- package/bin/lean/mechfix.test.mjs +28 -1
- package/bin/lean/orchestrate-children.test.mjs +10 -0
- package/bin/lean/orchestrate-owned.test.mjs +73 -0
- package/bin/lean/orchestrate.mjs +28 -4
- package/bin/lean/overlap.mjs +20 -0
- package/bin/lean/overlap.test.mjs +49 -0
- package/bin/lean/pagegate.mjs +152 -0
- package/bin/lean/pagegate.test.mjs +77 -0
- package/bin/lean/parked-relabel.mjs +32 -0
- package/bin/lean/parked-relabel.test.mjs +45 -0
- package/bin/lean/phaseledger.mjs +17 -2
- package/bin/lean/postdeploy-check.mjs +27 -0
- package/bin/lean/postdeploy-check.test.mjs +13 -1
- package/bin/lean/postrun.mjs +32 -0
- package/bin/lean/postrun.test.mjs +41 -0
- package/bin/lean/preflight.mjs +46 -0
- package/bin/lean/preflight.test.mjs +30 -1
- package/bin/lean/prompts.mjs +36 -6
- package/bin/lean/recovery.test.mjs +16 -0
- package/bin/lean/release.mjs +23 -2
- package/bin/lean/release.test.mjs +28 -1
- package/bin/lean/render.mjs +17 -6
- package/bin/lean/reproquality.mjs +116 -0
- package/bin/lean/reproquality.test.mjs +85 -0
- package/bin/lean/review-trigger.mjs +8 -3
- package/bin/lean/sandbox-budget.test.mjs +27 -0
- package/bin/lean/schedd.mjs +40 -11
- package/bin/lean/schedd.test.mjs +12 -1
- package/bin/lean/testadequacy.mjs +97 -0
- package/bin/lean/testadequacy.test.mjs +92 -0
- package/bin/lean/testsandbox.mjs +202 -0
- package/bin/lean/testsandbox.test.mjs +157 -0
- package/bin/lean/toolplace.mjs +5 -2
- package/bin/lean/toolplace.test.mjs +6 -0
- package/bin/lean/verify.mjs +6 -1
- package/bin/lean/verify.test.mjs +18 -2
- package/bin/lean/warmtree.mjs +77 -0
- package/bin/lean/warmtree.test.mjs +81 -0
- package/bin/stats/conformance-outcomes.mjs +12 -2
- package/bin/stats/depth.mjs +24 -1
- package/bin/stats/depth.test.mjs +21 -1
- package/bin/stats/index.mjs +5 -2
- package/bin/stats/query.mjs +2 -1
- package/commands/cleanup.md +18 -0
- package/commands/fd-introspect.md +19 -0
- package/commands/milestone.md +5 -1
- package/commands/pipeline-health/phase-2-metrics.md +4 -0
- package/commands/recover-orphans.md +31 -1
- package/commands/review-pr-staging.md +9 -0
- package/commands/review-pr.md +2 -0
- package/docs/CONFIG.md +26 -1
- package/docs/EVENTS.md +1 -0
- package/docs/ISSUE-WATCH.md +12 -3
- package/docs/eval/adversarial-bench.md +1 -1
- package/docs/eval/published/adversarial-2026-11-11.md +58 -0
- package/package.json +1 -1
- package/scripts/bench-lightlane.mjs +3 -2
- package/scripts/hotspots.sh +7 -4
- package/scripts/hotspots.test.sh +12 -0
- package/scripts/recover-orphans-stateless.test.sh +79 -0
- package/scripts/transition-label.sh +2 -0
- package/templates/workflows/forgedock-reopen-clean.yml +33 -0
|
@@ -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 { 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";
|
|
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";
|
|
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.";
|
|
@@ -278,8 +278,10 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
278
278
|
assert.equal(pc.failures[0].kind, "validate_env"); assert.equal(pc.failures[0].tool, "yaml");
|
|
279
279
|
assert.match(pc.failures[0].detail, /could not run: the host is missing Python module 'yaml'/);
|
|
280
280
|
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, validateRuns: { V1: { rc: 127, output: "bash: line 1: pytest: command not found" } } })), ["env.tool_missing"]);
|
|
281
|
-
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, ciVerified: true, validateRuns: { V1: { rc: 127, output: "bash: pytest: command not found" } } })), [], "CI-verified head
|
|
281
|
+
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, ciVerified: true, validateRuns: { V1: { rc: 127, output: "bash: pytest: command not found" } } })), ["env.tool_missing"], "#5447: a CI-verified head never covers a test the host could not run");
|
|
282
282
|
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, validateRuns: { V1: { rc: 0, output: "" } } })), [], "a passing rerun counts as passed");
|
|
283
|
+
{ const pc5447 = precheck({ contract: C, result: failed, changedFiles: files, ciVerified: true, validateRuns: { V1: { rc: 127, output: "bash: pytest: command not found" } } }); assert.deepEqual(pc5447.ciCovered, [], "#5447: validate_env is never ciCovered"); assert.equal(pc5447.failures[0].kind, "validate_env"); }
|
|
284
|
+
{ const un = precheck({ contract: C, result: { ...res, validation: [] }, changedFiles: files }); assert.ok(un.failures.length > 0 && un.ciCovered.length === 0, "#5447: a declared test with no executed result blocks"); }
|
|
283
285
|
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, validateRuns: { V1: { rc: 1, output: "AssertionError: 1 !== 2" } } })), ["conformance.unimplemented"]);
|
|
284
286
|
// #4906: a rerun that timed out (rc 124) is infrastructure, never conformance.unimplemented
|
|
285
287
|
assert.deepEqual(codes(precheck({ contract: C, result: failed, changedFiles: files, validateRuns: { V1: { rc: 124, output: "(timed out)" } } })), ["env.validate_timeout"]);
|
|
@@ -301,6 +303,11 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
301
303
|
assert.deepEqual(codes(carried), []);
|
|
302
304
|
assert.deepEqual(precheck({ contract: C, result: { ...res, validation: [] }, changedFiles: files }).failures.map((f) => f.kind), ["validate_missing"]);
|
|
303
305
|
});
|
|
306
|
+
it("#5446 reproQualityFailures: a mutation survivor fails only when enforced; patch_echo and behavioural never do", () => {
|
|
307
|
+
assert.equal(reproQualityFailures({ quality: "mutation_survivor", enforce: true })[0].kind, "repro_mutation_survivor");
|
|
308
|
+
assert.deepEqual(reproQualityFailures({ quality: "mutation_survivor", enforce: false }), []);
|
|
309
|
+
assert.deepEqual(reproQualityFailures({ quality: "patch_echo", enforce: true }), []);
|
|
310
|
+
});
|
|
304
311
|
it("#4323 missingTool: commands, python and node modules; paths, relative and repo-tracked names are not the environment", () => {
|
|
305
312
|
assert.deepEqual(missingTool({ rc: 127, output: "sh: 1: jq: not found" }), { tool: "jq", kind: "command" });
|
|
306
313
|
assert.deepEqual(missingTool({ rc: 127, output: "" }, { command: "uv run pytest -q" }), { tool: "uv", kind: "command" });
|
|
@@ -784,6 +791,10 @@ describe("hotspot growth precheck (forge#4195)", () => {
|
|
|
784
791
|
assert.equal(run(hs([big])).ok, false);
|
|
785
792
|
assert.equal(run(hs([{ ...big, generated: true }])).ok, true);
|
|
786
793
|
assert.equal(run(hs([{ ...big, generated: true, excluded: true }])).ok, true);
|
|
794
|
+
// #5470: a generated/ segment row (generated:true from hotspots.sh) grown by 6k lines passes; hand-written still flags
|
|
795
|
+
const seg = H({ path: "src/scrape.js", lines: 6607, base_lines: 0, growth: 6607 });
|
|
796
|
+
assert.equal(run(hs([{ ...seg, generated: true, excluded: true }])).ok, true);
|
|
797
|
+
assert.equal(run(hs([{ ...seg, generated: false }])).ok, false);
|
|
787
798
|
});
|
|
788
799
|
|
|
789
800
|
it("within the limit, under the threshold, excluded, unchanged, disabled or no facts: no failure", () => {
|
|
@@ -1485,7 +1496,7 @@ describe("#5020 freeze-time environment defects", () => {
|
|
|
1485
1496
|
assert.equal(reproEnvMiss({ rc: 0, output: "" }), null);
|
|
1486
1497
|
});
|
|
1487
1498
|
it("a post-deploy requirement with no check id is deferred to the orchestrator; one with a check is untouched", () => {
|
|
1488
|
-
const c = { requirements: [{ id: "R1", quote: "q", disposition: "post-deploy", why: "needs prod
|
|
1499
|
+
const c = { requirements: [{ id: "R1", quote: "q", disposition: "post-deploy", why: "needs prod credentials" }, { id: "R2", quote: "q", disposition: "post-deploy", check: "login-smoke", why: "w" }] };
|
|
1489
1500
|
const { contract, converted } = deferChecklessPostDeploy(c);
|
|
1490
1501
|
assert.deepEqual(converted, ["R1"]);
|
|
1491
1502
|
assert.equal(contract.requirements[0].disposition, "defer");
|
|
@@ -1493,6 +1504,26 @@ describe("#5020 freeze-time environment defects", () => {
|
|
|
1493
1504
|
assert.equal(contract.requirements[1].disposition, "post-deploy");
|
|
1494
1505
|
assert.deepEqual(bucketProblems(contract.requirements[0]), []);
|
|
1495
1506
|
});
|
|
1507
|
+
it("#5448: a check-less prod-only claim is not converted and freeze rejects it; local_infeasible_why is required", () => {
|
|
1508
|
+
const c = { requirements: [{ id: "R1", quote: "Listing returns results on prod.", disposition: "post-deploy", bucket: "post-deploy", why: "only measurable on prod after release" }], deliverables: [], validate: [{ id: "V1", command: "true" }] };
|
|
1509
|
+
const d = deferChecklessPostDeploy(c);
|
|
1510
|
+
assert.deepEqual(d.converted, []);
|
|
1511
|
+
const v = validateContract(d.contract, "Listing returns results on prod.");
|
|
1512
|
+
assert.ok(v.problems.some((p) => /needs a check id/.test(p)));
|
|
1513
|
+
assert.ok(v.problems.some((p) => /local_infeasible_why/.test(p)));
|
|
1514
|
+
const ok = validateContract({ ...c, requirements: [{ ...c.requirements[0], check: "listing-prod", local_infeasible_why: "needs live vendor traffic" }] }, "Listing returns results on prod.");
|
|
1515
|
+
assert.deepEqual(ok.problems, []);
|
|
1516
|
+
});
|
|
1517
|
+
it("#5448 replay of #40539: development work cannot be deferred as prod-only", () => {
|
|
1518
|
+
const q = "Find and fix the 403 signal for reddit listings.";
|
|
1519
|
+
const r = { id: "R3", quote: q, disposition: "post-deploy", bucket: "post-deploy", check: "reddit-403", why: "w", local_infeasible_why: "live" };
|
|
1520
|
+
const v = validateContract({ requirements: [r], deliverables: [], validate: [{ id: "V1", command: "true" }] }, q);
|
|
1521
|
+
assert.ok(v.problems.some((p) => /development work/.test(p)));
|
|
1522
|
+
});
|
|
1523
|
+
it("#5448: a malformed regression set is a contract problem", () => {
|
|
1524
|
+
const c = { requirements: [{ id: "R1", quote: "q q q q q q q q q q q q", disposition: "deliver" }], deliverables: [{ id: "D1", path: "a", change: "c" }], validate: [{ id: "V1", command: "true" }], regression: [{ id: "G1" }] };
|
|
1525
|
+
assert.ok(validateContract(c, "q q q q q q q q q q q q").problems.some((p) => /regression entry/.test(p)));
|
|
1526
|
+
});
|
|
1496
1527
|
it("a post-deploy amendment with no check becomes a tracked defer instead of a problem", () => {
|
|
1497
1528
|
const c = { requirements: [{ id: "R1", quote: "q", disposition: "deliver" }], deliverables: [], validate: [] };
|
|
1498
1529
|
const r = applyAmendments(c, [{ kind: "post-deploy", requirement: "R1", why: "manual prod action" }], "q");
|
|
@@ -1759,3 +1790,141 @@ describe("#5339 a faked or deferred e2e/manual requirement is not met", () => {
|
|
|
1759
1790
|
assert.deepEqual(codes(decide(rv({ status: "deferred", deferral_ok: false }), c2)), ["conformance.unjustified_deferral"]);
|
|
1760
1791
|
});
|
|
1761
1792
|
});
|
|
1793
|
+
|
|
1794
|
+
import { contractBriefProblems as pageBriefProblems, parsePagesConfig as parsePagesCfg } from "./pagegate.mjs";
|
|
1795
|
+
describe("page gate wiring (#5428)", () => {
|
|
1796
|
+
it("validateContract reports missing page_gate briefs and precheck carries pageFailures", () => {
|
|
1797
|
+
const pages = parsePagesCfg(undefined, { hasAppPages: true });
|
|
1798
|
+
const c = { requirements: [{ id: "R1", quote: "q", disposition: "deliver" }], deliverables: [{ id: "D1", path: "web/app/x/page.tsx", change: "c", requirements: ["R1"] }], validate: [] };
|
|
1799
|
+
assert.equal(pageBriefProblems(c, pages).length, 1);
|
|
1800
|
+
assert.ok(validateContract(c, "q", { pages }).problems.some((p) => /page_gate/.test(p)));
|
|
1801
|
+
assert.ok(!validateContract(c, "q").problems.some((p) => /page_gate/.test(p)));
|
|
1802
|
+
const pc = precheck({ contract: c, result: {}, changedFiles: [], pageFailures: [{ code: "x", kind: "page_sitemap_missing", detail: "d" }] });
|
|
1803
|
+
assert.ok(pc.failures.some((f) => f.kind === "page_sitemap_missing"));
|
|
1804
|
+
});
|
|
1805
|
+
});
|
|
1806
|
+
|
|
1807
|
+
describe("test plan frozen with the contract (#5445)", () => {
|
|
1808
|
+
const D = [{ id: "D1", path: "src/scrape.js", change: "rewrite the listing .json URL to old.reddit.com", requirements: ["R1"] }, { id: "D2", path: "src/search.js", requirements: ["R2"] }];
|
|
1809
|
+
const row = (r, o = {}) => ({ requirement: r, proof: "www.reddit.com listing .json returns 200 JSON instead of 403", level: "integration", level_reason: "a real HTTP fixture observes the status", repro: "test/x.test.js#403", regression: ["old.reddit.com listings"], env: ["http fixture"], command: "node --test test/x.test.js", ...o });
|
|
1810
|
+
const K = (plan) => ({ ...C, deliverables: D, test_plan: plan });
|
|
1811
|
+
const bug = (c) => validateContract(c, ISSUE, { testPlan: true }).problems.join("\n");
|
|
1812
|
+
it("a complete plan is valid; without the option an old contract stays valid", () => {
|
|
1813
|
+
assert.deepEqual(validateContract(K([row("R1"), row("R2")]), ISSUE, { testPlan: true }), { ok: true, problems: [] });
|
|
1814
|
+
assert.deepEqual(validateContract(C, ISSUE), { ok: true, problems: [] });
|
|
1815
|
+
});
|
|
1816
|
+
it("a bug requirement without a row, or without a repro, is rejected", () => {
|
|
1817
|
+
assert.match(bug(K([row("R1")])), /R2: test_plan needs a row/);
|
|
1818
|
+
assert.match(bug(C), /R1: test_plan needs a row/);
|
|
1819
|
+
assert.match(bug(K([row("R1", { repro: "" }), row("R2")])), /R1: test_plan repro must be a test id/);
|
|
1820
|
+
assert.match(bug(K([row("R1", { repro: "no-repro" }), row("R2")])), /R1: test_plan no-repro needs a reason/);
|
|
1821
|
+
assert.equal(bug(K([row("R1", { repro: "no-repro", reason: "spec-only change" }), row("R2")])), "");
|
|
1822
|
+
});
|
|
1823
|
+
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 only restates a deliverable/);
|
|
1825
|
+
assert.equal(proofEchoesDeliverable("the listing json URL is rewritten", D.slice(0, 1)), true);
|
|
1826
|
+
assert.equal(proofEchoesDeliverable("returns 200 JSON instead of 403", D.slice(0, 1)), false);
|
|
1827
|
+
});
|
|
1828
|
+
it("level, its reason and the command are checked; mocking the bug's component is rejected", () => {
|
|
1829
|
+
assert.match(testPlanProblems(K([row("R1", { level: "manual" })])).join(), /level must be one of/);
|
|
1830
|
+
assert.match(testPlanProblems(K([row("R1", { level_reason: "" })])).join(), /level_reason/);
|
|
1831
|
+
assert.match(testPlanProblems(K([row("R1", { level_reason: "mock the fetcher" })])).join(), /mocking the component/);
|
|
1832
|
+
assert.equal(testPlanProblems(K([row("R1", { level_reason: "no mocks needed, real fixture" })])).length, 0);
|
|
1833
|
+
assert.match(testPlanProblems(K([row("R1", { command: "" })])).join(), /exact command/);
|
|
1834
|
+
assert.match(testPlanProblems({ ...C, test_plan: "x" }).join(), /must be an array/);
|
|
1835
|
+
});
|
|
1836
|
+
it("applyValidateRecipes rewrites test_plan commands", () => {
|
|
1837
|
+
const r = applyValidateRecipes(K([row("R1")]), [{ match: "^node --test", replace: "npx node --test" }]);
|
|
1838
|
+
assert.equal(r.contract.test_plan[0].command, "npx node --test test/x.test.js");
|
|
1839
|
+
});
|
|
1840
|
+
});
|
|
1841
|
+
|
|
1842
|
+
import { pathCovers as cover5440 } from "./conformance.mjs";
|
|
1843
|
+
describe("#5440 pathCovers: directory without slash, renumbered sequence file", () => {
|
|
1844
|
+
it("#5440 directory deliverable without slash covers files beneath it", () => {
|
|
1845
|
+
assert.ok(cover5440("listings/official/travel", "listings/official/travel/agent.md"));
|
|
1846
|
+
assert.ok(cover5440("listings/official/travel", "listings/official/travel/a/b/page.md"));
|
|
1847
|
+
assert.ok(cover5440("listings/official/travel", "listings/official/travel"));
|
|
1848
|
+
});
|
|
1849
|
+
it("#5440 a sibling directory sharing the prefix is not covered", () => {
|
|
1850
|
+
assert.ok(!cover5440("listings/official/travel", "listings/official/travel2/agent.md"));
|
|
1851
|
+
assert.ok(!cover5440("listings/official/travel", "listings/official/jobs/agent.md"));
|
|
1852
|
+
});
|
|
1853
|
+
it("#5440 a renumbered migration is covered (exact and glob); other dirs and names are not", () => {
|
|
1854
|
+
assert.ok(cover5440("db/migrations/0637_add_x.sql", "db/migrations/0639_add_x.sql"));
|
|
1855
|
+
assert.ok(cover5440("db/migrations/0637_*", "db/migrations/0639_add_x.sql"));
|
|
1856
|
+
assert.ok(!cover5440("db/migrations/0637_add_x.sql", "db/migrations/0639_other.sql"));
|
|
1857
|
+
assert.ok(!cover5440("db/migrations/0637_*", "other/0639_add_x.sql"));
|
|
1858
|
+
assert.ok(!cover5440("src/a.js", "src/b.js"));
|
|
1859
|
+
});
|
|
1860
|
+
});
|
|
1861
|
+
|
|
1862
|
+
describe("#5449 test adequacy kinds are enforced by default", () => {
|
|
1863
|
+
it("test_missing and test_weak block in a shadow lane; other kinds still follow the lane", async () => {
|
|
1864
|
+
const { blockingFailures } = await import("./conformance.mjs");
|
|
1865
|
+
const f = [{ code: "x.a", kind: "test_missing" }, { code: "x.b", kind: "test_weak" }, { code: "x.c", kind: "other" }];
|
|
1866
|
+
const r = blockingFailures(f, { shadow: true });
|
|
1867
|
+
assert.deepEqual(r.block.map((x) => x.code), ["x.a", "x.b"]); assert.deepEqual(r.record.map((x) => x.code), ["x.c"]);
|
|
1868
|
+
});
|
|
1869
|
+
});
|
|
1870
|
+
|
|
1871
|
+
import { prodOnlyE2e, autoPostDeployE2e, loneE2eRows, sandboxedRun } from "./conformance.mjs";
|
|
1872
|
+
import { e2eCheckFor, mergeCheckEntries, parseChecks } from "./postdeploy-check.mjs";
|
|
1873
|
+
|
|
1874
|
+
describe("#5468 production-only e2e/manual criteria become post-deploy checks", () => {
|
|
1875
|
+
const PQ = "`https://store.alterlab.io/{slug}/agent.md` returns 200 for every published listing [type:e2e]";
|
|
1876
|
+
const LQ = "The signup page works against the local stack in a browser [type:e2e]";
|
|
1877
|
+
const mk = (quote) => {
|
|
1878
|
+
const contract = { ...C, requirements: [{ id: "R1", quote, disposition: "deliver" }, C.requirements[1]], validate: [{ id: "V1", command: "pytest tests/test_x.py" }] };
|
|
1879
|
+
return { contract, ctx: { ...ctx, contract, issueText: `${ISSUE}\n${quote}` } };
|
|
1880
|
+
};
|
|
1881
|
+
const decideRow = (quote) => { const m = mk(quote); const r = { ...good, issue_coverage: [{ quote, status: "covered" }, ...good.issue_coverage.slice(1)] }; return { m, d: decide(r, m.ctx) }; };
|
|
1882
|
+
it("classifies production-only versus pre-merge-runnable quotes", () => {
|
|
1883
|
+
assert.equal(prodOnlyE2e(PQ), true);
|
|
1884
|
+
assert.equal(prodOnlyE2e("Re-run the probe after deploy [type:manual]"), true);
|
|
1885
|
+
assert.equal(prodOnlyE2e(LQ), false);
|
|
1886
|
+
});
|
|
1887
|
+
it("freeze converts a prod-only row to post-deploy with a generated check that parses", () => {
|
|
1888
|
+
const { contract } = mk(PQ);
|
|
1889
|
+
const out = autoPostDeployE2e(contract);
|
|
1890
|
+
const r = out.contract.requirements[0];
|
|
1891
|
+
assert.equal(r.disposition, "post-deploy");
|
|
1892
|
+
assert.match(r.check, /^e2e-r1-[0-9a-f]+$/);
|
|
1893
|
+
assert.equal(out.contract.requirements[1].disposition, "deliver");
|
|
1894
|
+
assert.ok(parseChecks(mergeCheckEntries("", { [r.check]: out.converted[0].entry }))[r.check]);
|
|
1895
|
+
assert.equal(autoPostDeployE2e(mk(LQ).contract).converted.length, 0);
|
|
1896
|
+
});
|
|
1897
|
+
it("prod-only e2e_unverified converts instead of blocking", () => {
|
|
1898
|
+
const { m, d } = decideRow(PQ);
|
|
1899
|
+
assert.equal(d.state, "nonconforming");
|
|
1900
|
+
const ids = loneE2eRows(d.failures);
|
|
1901
|
+
assert.deepEqual(ids, ["R1"]);
|
|
1902
|
+
const cv = autoPostDeployE2e(m.contract, ids);
|
|
1903
|
+
assert.equal(cv.converted.length, ids.length);
|
|
1904
|
+
assert.equal(cv.contract.requirements[0].disposition, "post-deploy");
|
|
1905
|
+
});
|
|
1906
|
+
it("mixed failures, rows without a probeable URL and pre-merge rows still block", () => {
|
|
1907
|
+
assert.equal(loneE2eRows([{ code: "conformance.e2e_unverified", kind: "e2e_row", detail: "R1 is a x" }, { code: "conformance.unimplemented", detail: "R2 x" }]), null);
|
|
1908
|
+
assert.equal(loneE2eRows([{ code: "conformance.e2e_unverified", kind: "ui_browser_unverified", detail: "x" }]), null);
|
|
1909
|
+
assert.equal(e2eCheckFor("R1", "Operators restore after deploy [type:manual]"), null);
|
|
1910
|
+
const { m, d } = decideRow(LQ);
|
|
1911
|
+
assert.equal(autoPostDeployE2e(m.contract, loneE2eRows(d.failures)).converted.length, 0);
|
|
1912
|
+
});
|
|
1913
|
+
it("a pre-merge e2e row is verified by a validate declaring a configured test sandbox, never deferred (#5450 route)", () => {
|
|
1914
|
+
const m = mk(LQ);
|
|
1915
|
+
m.contract.validate = [{ id: "V1", command: "pytest tests/test_x.py", env: ["web"] }];
|
|
1916
|
+
const r = { ...good, issue_coverage: [{ quote: LQ, status: "covered" }, ...good.issue_coverage.slice(1)] };
|
|
1917
|
+
assert.equal(sandboxedRun(m.contract.validate[0], { sandboxes: ["web"] }), true);
|
|
1918
|
+
assert.equal(sandboxedRun(m.contract.validate[0], { sandboxes: [] }), false);
|
|
1919
|
+
assert.equal(decide(r, { ...m.ctx, contract: m.contract, e2e: { sandboxes: ["web"] } }).state, "conforms");
|
|
1920
|
+
const d = decide(r, { ...m.ctx, contract: m.contract, e2e: { sandboxes: ["db"] } });
|
|
1921
|
+
assert.match(d.failures[0].detail, /declare env: \[db\] on its validate to use the test sandbox/);
|
|
1922
|
+
const rd = { ...r, requirements: [{ ...r.requirements[0], status: "deferred", deferral_ok: true }, ...r.requirements.slice(1)] };
|
|
1923
|
+
const dd = decide(rd, { ...m.ctx, contract: { ...m.contract, requirements: [{ ...m.contract.requirements[0], disposition: "defer", bucket: "post-deploy" }, m.contract.requirements[1]] }, e2e: { sandboxes: ["web"] } });
|
|
1924
|
+
assert.ok(dd.failures.some((f) => f.code === "conformance.e2e_unverified"), "a deferred pre-merge e2e row still fails");
|
|
1925
|
+
});
|
|
1926
|
+
it("mergeCheckEntries keeps existing entries", () => {
|
|
1927
|
+
const o = JSON.parse(mergeCheckEntries(JSON.stringify({ a: { run: "x" } }), { a: { run: "y" }, b: { run: "z" } }));
|
|
1928
|
+
assert.equal(o.a.run, "x"); assert.equal(o.b.run, "z");
|
|
1929
|
+
});
|
|
1930
|
+
});
|
package/bin/lean/depcache.mjs
CHANGED
|
@@ -58,6 +58,27 @@ function detect(fs, wt) {
|
|
|
58
58
|
if (has("uv.lock")) out.push({ eco: "uv", lock: "uv.lock" });
|
|
59
59
|
else if (has("poetry.lock")) out.push({ eco: "poetry", lock: "poetry.lock" });
|
|
60
60
|
else out.push(...serviceLocks(fs, wt));
|
|
61
|
+
out.push(...nestedJsLocks(fs, wt));
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const JS_LOCKS = [["pnpm", "pnpm-lock.yaml"], ["npm", "package-lock.json"], ["yarn", "yarn.lock"]];
|
|
66
|
+
const JS_DIRS = ["web", "frontend", "client", "ui"];
|
|
67
|
+
/** #5423: JS lockfiles one level down (web/, frontend/, services|packages|apps/<name>/) with their own package.json; each is prepared in its own dir, so a sandbox has the vitest/vite a validate command calls. */
|
|
68
|
+
function nestedJsLocks(fs, wt) {
|
|
69
|
+
const dirs = [...JS_DIRS];
|
|
70
|
+
for (const root of SERVICE_ROOTS) {
|
|
71
|
+
try { for (const n of fs.readdirSync(join(wt, root)).sort()) dirs.push(`${root}/${n}`); } catch { /* absent */ }
|
|
72
|
+
}
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const dir of dirs) {
|
|
75
|
+
if (out.length >= SERVICE_CAP) break;
|
|
76
|
+
try {
|
|
77
|
+
if (!fs.existsSync(join(wt, dir, "package.json"))) continue;
|
|
78
|
+
const hit = JS_LOCKS.find(([, lock]) => fs.existsSync(join(wt, dir, lock)));
|
|
79
|
+
if (hit) out.push({ eco: hit[0], lock: hit[1], dir, ...(hit[0] === "yarn" ? { berry: fs.existsSync(join(wt, dir, ".yarnrc.yml")) } : {}) });
|
|
80
|
+
} catch { /* unreadable: skip */ }
|
|
81
|
+
}
|
|
61
82
|
return out;
|
|
62
83
|
}
|
|
63
84
|
|
|
@@ -304,8 +325,8 @@ export function makeDepCache({ root = depcacheRoot(), exec, fs = nodeFs, now = (
|
|
|
304
325
|
for (const d of found) {
|
|
305
326
|
try {
|
|
306
327
|
const r = await prepareOne(d.dir ? join(wt, d.dir) : wt, keyRoot, d, laneEnv && typeof laneEnv === "object" ? laneEnv : undefined);
|
|
307
|
-
out.push(
|
|
308
|
-
} catch (e) { out.push({ status: "failed", eco: d.eco, key: null, ms: 0, reason: msg(e) }); }
|
|
328
|
+
out.push({ ...r, dir: d.dir ?? "." });
|
|
329
|
+
} catch (e) { out.push({ status: "failed", eco: d.eco, key: null, ms: 0, reason: msg(e), dir: d.dir ?? "." }); }
|
|
309
330
|
}
|
|
310
331
|
return out;
|
|
311
332
|
}
|
|
@@ -137,6 +137,7 @@ describe("depcache (#4220): shared dependency installs keyed by lock hash", () =
|
|
|
137
137
|
assert.equal(ra.status, "miss-installed", JSON.stringify(ra));
|
|
138
138
|
assert.equal(ra.published, true);
|
|
139
139
|
assert.equal(ra.eco, eco);
|
|
140
|
+
assert.equal(ra.dir, ".", "#5447: every result row carries its project dir");
|
|
140
141
|
const [snap] = snapDirs(root, eco);
|
|
141
142
|
assert.ok(snap && existsSync(join(snap, "manifest.json")));
|
|
142
143
|
const fullInstalls = f.installs().length;
|
|
@@ -449,3 +450,24 @@ describe("depcache (#5331): per-service Python lockfiles", () => {
|
|
|
449
450
|
assert.equal(r.reason, "no lockfile");
|
|
450
451
|
});
|
|
451
452
|
});
|
|
453
|
+
|
|
454
|
+
describe("depcache (#5423): nested JS lockfiles", () => {
|
|
455
|
+
it("web/package-lock.json is prepared in web/ next to a root without a lockfile", async () => {
|
|
456
|
+
const { cache, base } = setup("npm");
|
|
457
|
+
const wt = join(base, "wt", "web");
|
|
458
|
+
mkdirSync(wt, { recursive: true });
|
|
459
|
+
FIXTURES.npm(join(wt, "web"));
|
|
460
|
+
const res = await cache.prepare({ wt, repoKey: "repo-web" });
|
|
461
|
+
assert.equal(res.length, 1, JSON.stringify(res));
|
|
462
|
+
assert.equal(res[0].eco, "npm");
|
|
463
|
+
assert.equal(res[0].dir, "web");
|
|
464
|
+
assert.ok(["miss-installed", "hit"].includes(res[0].status), JSON.stringify(res[0]));
|
|
465
|
+
});
|
|
466
|
+
it("a web/ without its own package.json is not prepared", async () => {
|
|
467
|
+
const { cache, base } = setup("npm");
|
|
468
|
+
const wt = join(base, "wt", "web2");
|
|
469
|
+
put(join(wt, "web/package-lock.json"), "{}");
|
|
470
|
+
const [r] = await cache.prepare({ wt, repoKey: "repo-web2" });
|
|
471
|
+
assert.equal(r.reason, "no lockfile");
|
|
472
|
+
});
|
|
473
|
+
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* #5419: user docs for user-facing surfaces. forge.yaml `docs: {required_for, paths, registries, surfaces, link_prefixes, link_check}`.
|
|
5
|
+
* Absent or empty `required_for` = off (library/CLI repos). A diff that touches a configured surface needs a docs change (a file under
|
|
6
|
+
* `paths`/`registries`) or a typed `docs: [{surface, justification}]` in the lane's result; every internal `/docs/...` link the diff adds
|
|
7
|
+
* must resolve (the repo's `link_check` command, else a docs file under `paths`). A milestone with user-facing children cannot close
|
|
8
|
+
* without a merged `docs` child. Deterministic, 0 LLM calls; core stays repo-agnostic (#1347), like routecheck.mjs and prodparity.mjs.
|
|
9
|
+
*/
|
|
10
|
+
import { OUTCOME_CODES } from "../engine/outcome-codes.mjs";
|
|
11
|
+
import { globToRegex } from "../../scripts/ci-local/lib.mjs";
|
|
12
|
+
import { routePathOf } from "./routecheck.mjs";
|
|
13
|
+
|
|
14
|
+
export const DOCS_KINDS = Object.freeze(["api", "mcp", "dashboard", "cli", "sdk"]);
|
|
15
|
+
const DEFAULT_PATHS = ["docs/**", "**/docs/**"];
|
|
16
|
+
const PAGE_RE = /(?:^|\/)app\/(?:.*\/)?page\.[cm]?[jt]sx?$/;
|
|
17
|
+
const TEST_RE = /(?:^|\/)(?:__tests__|tests?)\/|\.(?:test|spec)\.[cm]?[jt]sx?$/;
|
|
18
|
+
const norm = (p) => String(p ?? "").trim().replace(/^\.\//, "");
|
|
19
|
+
const sq = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
20
|
+
const list = (v) => (Array.isArray(v) ? v : typeof v === "string" ? v.replace(/^\[|\]$/g, "").split(",") : []).map((x) => String(x ?? "").trim().replace(/^(["'])(.*)\1$/, "$2").trim()).filter(Boolean);
|
|
21
|
+
|
|
22
|
+
/** forge.yaml docs: section -> {required_for, paths, registries, surfaces, link_prefixes, link_check} or null when off. */
|
|
23
|
+
export function parseDocsConfig(raw) {
|
|
24
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
25
|
+
const requiredFor = [...new Set(list(raw.required_for).map((k) => k.toLowerCase()).filter((k) => DOCS_KINDS.includes(k)))];
|
|
26
|
+
if (!requiredFor.length) return null;
|
|
27
|
+
const surfaces = {};
|
|
28
|
+
if (raw.surfaces && typeof raw.surfaces === "object" && !Array.isArray(raw.surfaces)) for (const [k, v] of Object.entries(raw.surfaces)) { const g = list(v); if (g.length && DOCS_KINDS.includes(k.toLowerCase())) surfaces[k.toLowerCase()] = g.map(norm); }
|
|
29
|
+
const prefixes = list(raw.link_prefixes);
|
|
30
|
+
const check = typeof raw.link_check === "string" ? raw.link_check.trim() : "";
|
|
31
|
+
return { required_for: requiredFor, paths: list(raw.paths).map(norm), registries: list(raw.registries).map(norm), surfaces, link_prefixes: prefixes.length ? prefixes : ["/docs"], link_check: check || null };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const anyGlob = (globs, f) => globs.some((g) => globToRegex(g).test(f));
|
|
35
|
+
|
|
36
|
+
/** Touched surfaces `{kind: [files]}` for the configured kinds: built-in Next route handlers (api) and dashboard pages, plus `surfaces` globs. */
|
|
37
|
+
export function userFacingSurfaces(files, cfg) {
|
|
38
|
+
const out = {};
|
|
39
|
+
if (!cfg) return out;
|
|
40
|
+
for (const f0 of files ?? []) {
|
|
41
|
+
const f = norm(f0);
|
|
42
|
+
if (!f || TEST_RE.test(f)) continue;
|
|
43
|
+
const kinds = new Set();
|
|
44
|
+
if (routePathOf(f)) kinds.add("api");
|
|
45
|
+
if (PAGE_RE.test(f) && /dashboard/i.test(f)) kinds.add("dashboard");
|
|
46
|
+
for (const [k, globs] of Object.entries(cfg.surfaces)) if (anyGlob(globs, f)) kinds.add(k);
|
|
47
|
+
for (const k of kinds) if (cfg.required_for.includes(k)) (out[k] ??= []).push(f);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Sorted unique internal docs links (`href="/docs/x"`, `docsHref="/docs/x"`, `docsHref={"/docs/x"}`) on the added lines of a unified diff. */
|
|
53
|
+
export function docsLinks(diff, prefixes = ["/docs"]) {
|
|
54
|
+
const found = new Set(), re = /(?:href|docsHref)\s*=\s*\{?\s*["'`](\/[^"'`#?\s{}$]*)/g;
|
|
55
|
+
for (const line of String(diff ?? "").split("\n")) {
|
|
56
|
+
if (!line.startsWith("+") || line.startsWith("+++")) continue;
|
|
57
|
+
for (const m of line.matchAll(re)) if (prefixes.some((p) => m[1] === p || m[1].startsWith(`${p}/`))) found.add(m[1].replace(/\/+$/, "") || "/");
|
|
58
|
+
}
|
|
59
|
+
return [...found].sort();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** True when some docs file under `paths` serves `link` (`rel.md|mdx`, `rel/index.*`, `rel/page.*`). */
|
|
63
|
+
export function linkResolves(link, cfg, files) {
|
|
64
|
+
const prefix = cfg.link_prefixes.find((p) => link === p || link.startsWith(`${p}/`)) ?? "";
|
|
65
|
+
const rel = link.slice(prefix.length).replace(/^\/+/, "");
|
|
66
|
+
const globs = cfg.paths.length ? cfg.paths : DEFAULT_PATHS;
|
|
67
|
+
const esc = rel.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
68
|
+
const re = new RegExp(`(?:^|/)${esc ? `${esc}(?:/(?:index|page|readme))?` : "(?:index|page|readme)"}\\.(?:mdx?|[jt]sx?)$`, "i");
|
|
69
|
+
return (files ?? []).some((f) => re.test(f) && anyGlob(globs, f));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Blocking failures (conformance.unimplemented): `docs_missing` (a touched surface with no docs change and no result.docs justification),
|
|
74
|
+
* `docs_link_broken` (a `/docs/...` link the diff adds that does not resolve). `run` is ({command}) => {rc, output}; `tracked` the repo's files.
|
|
75
|
+
*/
|
|
76
|
+
export async function docsFailures({ cfg, files = [], diff = "", result = null, run = null, tracked = null }) {
|
|
77
|
+
if (!cfg) return [];
|
|
78
|
+
const C = OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, out = [];
|
|
79
|
+
const surfaces = userFacingSurfaces(files, cfg);
|
|
80
|
+
const docGlobs = [...(cfg.paths.length ? cfg.paths : DEFAULT_PATHS), ...cfg.registries];
|
|
81
|
+
const changedDocs = files.map(norm).filter((f) => anyGlob(docGlobs, f));
|
|
82
|
+
const given = Array.isArray(result?.docs) ? result.docs : [];
|
|
83
|
+
for (const [kind, fs] of Object.entries(surfaces)) {
|
|
84
|
+
if (changedDocs.length || given.some((d) => String(d?.surface ?? "").trim().toLowerCase() === kind && String(d?.justification ?? "").trim())) continue;
|
|
85
|
+
out.push({ code: C, kind: "docs_missing", detail: `${fs.slice(0, 3).join(", ")} changes the user-facing ${kind} surface (forge.yaml docs.required_for) but no docs file changed: add the page(s) under ${(cfg.paths.length ? cfg.paths : DEFAULT_PATHS).join(", ")}${cfg.registries.length ? ` and register them (${cfg.registries.join(", ")})` : ""}, or record docs: [{"surface":"${kind}","justification":"<why none>"}] in the result file` });
|
|
86
|
+
}
|
|
87
|
+
const links = docsLinks(diff, cfg.link_prefixes);
|
|
88
|
+
if (!links.length) return out;
|
|
89
|
+
if (cfg.link_check && run) {
|
|
90
|
+
let r;
|
|
91
|
+
try { r = await run({ command: `${cfg.link_check} ${links.map(sq).join(" ")}` }); r = r?.r ?? r; } catch (e) { r = { rc: 127, output: String(e?.message ?? e) }; }
|
|
92
|
+
if (r?.rc !== 0) {
|
|
93
|
+
const tail = String(r?.output ?? "").trim().split("\n").slice(-12).join("\n").slice(0, 1500);
|
|
94
|
+
out.push({ code: C, kind: "docs_link_broken", detail: `forge.yaml docs.link_check (\`${cfg.link_check}\`) exited ${r?.rc ?? "?"} for the docs link(s) ${links.join(", ")} this diff adds: create the page or fix the link${tail ? `:\n${tail}` : ""}` });
|
|
95
|
+
}
|
|
96
|
+
} else if (!cfg.link_check && tracked) {
|
|
97
|
+
const known = [...new Set([...tracked, ...files].map(norm))];
|
|
98
|
+
const bad = links.filter((l) => !linkResolves(l, cfg, known));
|
|
99
|
+
if (bad.length) out.push({ code: C, kind: "docs_link_broken", detail: `the diff links to ${bad.join(", ")} but no docs file under ${(cfg.paths.length ? cfg.paths : DEFAULT_PATHS).join(", ")} serves it (forge.yaml docs): create the page or fix the link` });
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const names = (c) => (c.labels ?? []).map((l) => String(l?.name ?? l).toLowerCase());
|
|
105
|
+
/** Milestone children `{number, state, labels}` -> {ok, reasons}. User-facing = labelled `user-facing` or a configured kind; the docs child is labelled `docs`. */
|
|
106
|
+
export function milestoneDocsGate({ children = [], cfg }) {
|
|
107
|
+
if (!cfg) return { ok: true, gated: false, reasons: [] };
|
|
108
|
+
const kinds = new Set(["user-facing", ...cfg.required_for]);
|
|
109
|
+
const docs = children.filter((c) => names(c).includes("docs"));
|
|
110
|
+
const facing = children.filter((c) => !docs.includes(c) && names(c).some((n) => kinds.has(n)));
|
|
111
|
+
if (!facing.length) return { ok: true, gated: false, reasons: [] };
|
|
112
|
+
if (!docs.length) return { ok: false, gated: true, reasons: [`user-facing children (${facing.map((c) => `#${c.number}`).join(", ")}) have no docs child: create an issue labelled \`docs\` in the milestone`] };
|
|
113
|
+
const open = docs.filter((c) => String(c.state).toLowerCase() !== "closed");
|
|
114
|
+
return open.length ? { ok: false, gated: true, reasons: [`docs child ${open.map((c) => `#${c.number}`).join(", ")} is not merged yet`] } : { ok: true, gated: true, reasons: [] };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** `forgedock docs gate --milestone T --repo o/r`: exits 1 when the milestone's docs gate blocks; 0 when off or satisfied. */
|
|
118
|
+
export async function docsFromCli(argv, deps = {}) {
|
|
119
|
+
const val = (n) => { const i = argv.indexOf(n); return i >= 0 ? argv[i + 1] : null; };
|
|
120
|
+
const print = deps.print ?? ((t) => console.log(t));
|
|
121
|
+
const usage = "usage: forgedock docs gate --milestone T [--repo o/r]";
|
|
122
|
+
if (argv[0] !== "gate" || !val("--milestone")) throw new Error(usage);
|
|
123
|
+
const cfg = parseDocsConfig(deps.config ?? (await import("../engine-cli.mjs")).readEnvConfig(deps.cwd ?? process.cwd()).docsConfig);
|
|
124
|
+
if (!cfg) { print("docs: forge.yaml docs.required_for is not set; not gated"); return 0; }
|
|
125
|
+
const repo = val("--repo") ?? deps.repo;
|
|
126
|
+
if (!repo) throw new Error("docs gate needs the repo: pass --repo owner/repo");
|
|
127
|
+
const io = deps.io ?? (await import("./effects.mjs")).makeLeanIo({ repo });
|
|
128
|
+
const { findMilestone } = await import("./acceptance.mjs");
|
|
129
|
+
const ms = await findMilestone({ io, repo, title: val("--milestone") });
|
|
130
|
+
if (!ms) throw new Error(`no milestone titled ${val("--milestone")}`);
|
|
131
|
+
const children = JSON.parse(String(await io.gh(["api", `repos/${repo}/issues?milestone=${ms.number}&state=all&per_page=100`, "--jq", "[.[] | select(.pull_request == null) | {number, state, labels: [.labels[].name]}]"])) || "[]");
|
|
132
|
+
const g = milestoneDocsGate({ children, cfg });
|
|
133
|
+
if (!g.gated) print("docs: milestone has no user-facing children; not gated");
|
|
134
|
+
else if (g.ok) print(`docs: pass (${ms.title})`);
|
|
135
|
+
else for (const r of g.reasons) print(`docs: BLOCKED: ${r}`);
|
|
136
|
+
return g.ok ? 0 : 1;
|
|
137
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
import { describe, it } from "node:test";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { parseDocsConfig, userFacingSurfaces, docsLinks, docsFailures, milestoneDocsGate, docsFromCli } from "./docsgate.mjs";
|
|
6
|
+
import { docsPlanNote, domainChecksBlock } from "./prompts.mjs";
|
|
7
|
+
import { pathDomains } from "./review-trigger.mjs";
|
|
8
|
+
|
|
9
|
+
const cfg = parseDocsConfig({ required_for: "[api, dashboard]", paths: ["web/docs/**"], registries: ["web/public/llms.txt"] });
|
|
10
|
+
// The shape of the AlterLab Hands dashboard PR (#40276): a dashboard page linking a docs page that does not exist.
|
|
11
|
+
const handsFiles = ["web/app/dashboard/hands/page.tsx", "web/app/dashboard/hands/HandsDashPage.tsx"];
|
|
12
|
+
const handsDiff = "+++ b/web/app/dashboard/hands/page.tsx\n+<HandsDashPage docsHref=\"/docs/hands\" />\n+<a href=\"/docs/hands/credentials\">How it works</a>\n+<a href=\"/pricing\">x</a>\n";
|
|
13
|
+
|
|
14
|
+
describe("docs gate (#5419)", () => {
|
|
15
|
+
it("is off without required_for (library/CLI repos)", async () => {
|
|
16
|
+
assert.equal(parseDocsConfig(undefined), null);
|
|
17
|
+
assert.equal(parseDocsConfig({ paths: ["docs/**"] }), null);
|
|
18
|
+
assert.equal(parseDocsConfig({ required_for: "bogus" }), null);
|
|
19
|
+
assert.deepEqual(await docsFailures({ cfg: null, files: handsFiles, diff: handsDiff }), []);
|
|
20
|
+
assert.equal(docsPlanNote(null), "");
|
|
21
|
+
});
|
|
22
|
+
it("detects configured surfaces only, ignoring tests", () => {
|
|
23
|
+
assert.deepEqual(Object.keys(userFacingSurfaces(["web/app/api/x/route.ts", "web/app/dashboard/p/page.tsx", "web/app/api/x/route.test.ts"], cfg)).sort(), ["api", "dashboard"]);
|
|
24
|
+
assert.deepEqual(userFacingSurfaces(["src/cli.ts"], parseDocsConfig({ required_for: ["cli"], surfaces: { cli: ["src/cli.ts"] } })), { cli: ["src/cli.ts"] });
|
|
25
|
+
assert.deepEqual(userFacingSurfaces(["web/app/api/x/route.ts"], parseDocsConfig({ required_for: ["cli"] })), {});
|
|
26
|
+
});
|
|
27
|
+
it("extracts only added internal docs links", () => {
|
|
28
|
+
assert.deepEqual(docsLinks(handsDiff), ["/docs/hands", "/docs/hands/credentials"]);
|
|
29
|
+
assert.deepEqual(docsLinks("-<a href=\"/docs/old\">\n+<a href=\"https://x.io/docs/a\">"), []);
|
|
30
|
+
});
|
|
31
|
+
it("replay: the Hands dashboard diff fails docs_missing and the link gate, and its plan carries R-docs", async () => {
|
|
32
|
+
const f = await docsFailures({ cfg, files: handsFiles, diff: handsDiff, tracked: ["web/docs/api/index.mdx"] });
|
|
33
|
+
assert.deepEqual(f.map((x) => x.kind).sort(), ["docs_link_broken", "docs_missing"]);
|
|
34
|
+
assert.match(docsPlanNote(cfg), /R-docs/);
|
|
35
|
+
assert.match(docsPlanNote(cfg), /web\/docs\/\*\*/);
|
|
36
|
+
});
|
|
37
|
+
it("passes when the pages exist, or the repo link_check exits 0, or the change is justified", async () => {
|
|
38
|
+
const files = [...handsFiles, "web/docs/hands/index.mdx", "web/docs/hands/credentials.mdx"];
|
|
39
|
+
assert.deepEqual(await docsFailures({ cfg, files, diff: handsDiff, tracked: [] }), []);
|
|
40
|
+
const c2 = parseDocsConfig({ required_for: ["dashboard"], paths: ["web/docs/**"], link_check: "bash chk.sh" });
|
|
41
|
+
let ran; const run = async ({ command }) => { ran = command; return { rc: 0 }; };
|
|
42
|
+
assert.deepEqual(await docsFailures({ cfg: c2, files: [...handsFiles, "web/docs/x.mdx"], diff: handsDiff, run }), []);
|
|
43
|
+
assert.match(ran, /^bash chk\.sh '\/docs\/hands' '\/docs\/hands\/credentials'$/);
|
|
44
|
+
const bad = await docsFailures({ cfg: c2, files: ["web/docs/x.mdx"], diff: handsDiff, run: async () => ({ rc: 1, output: "404 /docs/hands" }) });
|
|
45
|
+
assert.equal(bad[0].kind, "docs_link_broken");
|
|
46
|
+
const crashed = await docsFailures({ cfg: c2, files: [], diff: handsDiff, run: async () => { throw new Error("nope"); } });
|
|
47
|
+
assert.match(crashed[0].detail, /exited 127/);
|
|
48
|
+
assert.deepEqual(await docsFailures({ cfg, files: handsFiles, result: { docs: [{ surface: "dashboard", justification: "internal page" }] }, diff: "" }), []);
|
|
49
|
+
});
|
|
50
|
+
it("adds the docs domain and its reviewer check only for a configured surface", () => {
|
|
51
|
+
assert.ok(pathDomains(handsFiles, { docs: cfg })?.includes("docs"));
|
|
52
|
+
assert.ok(!pathDomains(handsFiles)?.includes("docs"));
|
|
53
|
+
assert.match(domainChecksBlock(["docs"]), /docs that contradict the code/);
|
|
54
|
+
});
|
|
55
|
+
it("blocks milestone close until a docs child is merged", () => {
|
|
56
|
+
const ui = { number: 1, state: "closed", labels: ["dashboard"] };
|
|
57
|
+
assert.equal(milestoneDocsGate({ children: [ui], cfg: null }).ok, true);
|
|
58
|
+
assert.equal(milestoneDocsGate({ children: [{ number: 2, state: "open", labels: ["chore"] }], cfg }).gated, false);
|
|
59
|
+
assert.match(milestoneDocsGate({ children: [ui], cfg }).reasons[0], /no docs child/);
|
|
60
|
+
assert.match(milestoneDocsGate({ children: [ui, { number: 3, state: "open", labels: ["docs"] }], cfg }).reasons[0], /not merged/);
|
|
61
|
+
assert.equal(milestoneDocsGate({ children: [ui, { number: 3, state: "closed", labels: ["docs"] }], cfg }).ok, true);
|
|
62
|
+
});
|
|
63
|
+
it("docs gate CLI exits 1 on a blocked milestone and 0 when off", async () => {
|
|
64
|
+
const out = [], print = (t) => out.push(t);
|
|
65
|
+
assert.equal(await docsFromCli(["gate", "--milestone", "M", "--repo", "o/r"], { config: undefined, print }), 0);
|
|
66
|
+
assert.equal(await docsFromCli(["gate", "--milestone", "M", "--repo", "o/r"], { config: cfg, print, io: { gh: async (a) => { if (String(a[1]).includes("issues?milestone")) return JSON.stringify([{ number: 1, state: "closed", labels: ["dashboard"] }]); return JSON.stringify([{ number: 7, title: "M" }]); } } }), 1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
import { precheck } from "./conformance.mjs";
|
|
71
|
+
it("precheck: configured docs.paths files are authorized, others stay scope creep (#5419)", () => {
|
|
72
|
+
const contract = { requirements: [], deliverables: [{ id: "D1", path: "src/a.mjs" }], preserve: [], validate: [] };
|
|
73
|
+
const base = { contract, result: { status: "fixed", requirements: [], validation: [], tests: [] }, ignore: [] };
|
|
74
|
+
const withDocs = precheck({ ...base, changedFiles: ["src/a.mjs", "docs/api/x.md"], docsPaths: ["docs/**"] });
|
|
75
|
+
assert.ok(!withDocs.failures.some((f) => f.kind === "scope_creep"));
|
|
76
|
+
const without = precheck({ ...base, changedFiles: ["src/a.mjs", "docs/api/x.md"] });
|
|
77
|
+
assert.ok(without.failures.some((f) => f.kind === "scope_creep"));
|
|
78
|
+
});
|
package/bin/lean/effects.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { makeProjector } from "../engine/projector.mjs";
|
|
|
14
14
|
import { makeLedger, countLiveLanes, ledgerRoot } from "./ledger.mjs";
|
|
15
15
|
import { makeDepCache } from "./depcache.mjs";
|
|
16
16
|
import { makeHeavyIo } from "./heavy.mjs";
|
|
17
|
+
import { diskLow } from "./admission.mjs";
|
|
17
18
|
import { gatherContextFacts } from "./context.mjs";
|
|
18
19
|
import { makePitfallStore } from "./pitfalls.mjs";
|
|
19
20
|
import { enumeratingTests, missingEntries } from "./enumerating.mjs";
|
|
@@ -160,6 +161,11 @@ export const runTmpRoot = () => join(homedir(), ".forge", "tmp", "runs");
|
|
|
160
161
|
const OWNER = ".forge-run-owner";
|
|
161
162
|
const pidAlive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) { return e?.code !== "ESRCH"; } };
|
|
162
163
|
|
|
164
|
+
/** The run-owner marker (#5421): any scratch dir ForgeDock creates under ~/.forge/tmp carries it so gc can reclaim it once its owner is dead. */
|
|
165
|
+
export function markOwned(dir, { issue = null, now = () => Date.now(), host = hostname() } = {}) {
|
|
166
|
+
try { writeFileSync(join(dir, OWNER), JSON.stringify({ issue, pid: process.pid, host, created: now() })); } catch { /* best effort: unmarked dirs are only reported */ }
|
|
167
|
+
}
|
|
168
|
+
|
|
163
169
|
/** Per-run scratch dirs under ~/.forge/tmp/runs/<issue>-<run>/. Only dirs carrying our owner marker are ever removed. */
|
|
164
170
|
export function makeRunTmp({ root = runTmpRoot(), now = () => Date.now(), alive = pidAlive, host = hostname() } = {}) {
|
|
165
171
|
const inside = (d) => { const r = resolve(d); return r.startsWith(resolve(root) + sep) && !r.slice(resolve(root).length + 1).includes(sep); };
|
|
@@ -216,6 +222,27 @@ export function killLedgerPid(pid, marker, { kill = process.kill.bind(process),
|
|
|
216
222
|
try { kill(-n, "SIGTERM"); return true; } catch { try { kill(n, "SIGTERM"); return true; } catch (e) { return e?.code === "ESRCH"; } }
|
|
217
223
|
}
|
|
218
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Heavy-step gate on free disk (#5421): below `minFreeGb()` the guard runs `gc()` (owned GC) once, re-checks, and, if the
|
|
227
|
+
* disk is still low, refuses the step with a DISK_LOW error (an image build must not fill the host). Otherwise it passes
|
|
228
|
+
* through to `heavy.acquire`. A failed gc or probe never refuses.
|
|
229
|
+
*/
|
|
230
|
+
export function guardHeavyDisk(heavy, { host, minFreeGb = () => null, gc = async () => {} } = {}) {
|
|
231
|
+
if (!heavy) return heavy;
|
|
232
|
+
return {
|
|
233
|
+
...heavy,
|
|
234
|
+
async acquire(entry, cfg) {
|
|
235
|
+
const min = await minFreeGb();
|
|
236
|
+
if ((await diskLow({ host, minFreeGb: min })).low) {
|
|
237
|
+
try { await gc(); } catch { /* the re-check decides */ }
|
|
238
|
+
const again = await diskLow({ host, minFreeGb: min });
|
|
239
|
+
if (again.low) { const e = new Error(`host disk low: ${again.reasons.join(", ")}`); e.code = "DISK_LOW"; throw e; }
|
|
240
|
+
}
|
|
241
|
+
return heavy.acquire(entry, cfg);
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
219
246
|
/** Real host probes for admission (#4105). MemAvailable from /proc/meminfo (fallback os.freemem), statfs for tmp. */
|
|
220
247
|
export function makeHostProbe() {
|
|
221
248
|
return {
|
|
@@ -236,6 +263,8 @@ export function makeHostProbe() {
|
|
|
236
263
|
cores: () => cpus().length || 1,
|
|
237
264
|
/** Live lanes on this host from the ledger (#4182), this lane included once it registered. */
|
|
238
265
|
activeLanes: () => countLiveLanes({ root: ledgerRoot(), host: hostname() }),
|
|
266
|
+
/** Filesystems a lane fills (#5421): the worktree root and ~/.forge. */
|
|
267
|
+
hygienePaths: (cwd = process.cwd()) => [...new Set([join(cwd, ".claude", "worktrees"), join(homedir(), ".forge")])],
|
|
239
268
|
tmpPaths: () => [...new Set([join(homedir(), ".forge", "tmp"), tmpdir(), "/tmp"].filter((x) => existsSync(x) || x === join(homedir(), ".forge", "tmp")))],
|
|
240
269
|
};
|
|
241
270
|
}
|
|
@@ -306,7 +335,7 @@ export function makeGhCache({ root = null, tmp = tmpdir() } = {}) {
|
|
|
306
335
|
drop(dir);
|
|
307
336
|
if (disposed) return;
|
|
308
337
|
if (root) { dir = join(root, `gh-cache-${++n}`); return; }
|
|
309
|
-
try { dir = mkdtempSync(join(tmp, "forge-gh-cache-")); made.add(dir); } catch { dir = null; }
|
|
338
|
+
try { dir = mkdtempSync(join(tmp, "forge-gh-cache-")); made.add(dir); markOwned(dir); } catch { dir = null; }
|
|
310
339
|
},
|
|
311
340
|
dispose() { disposed = true; for (const d of [...made]) drop(d); },
|
|
312
341
|
};
|
|
@@ -326,7 +355,7 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
326
355
|
};
|
|
327
356
|
return {
|
|
328
357
|
ghCache: (root) => makeGhCache({ root }),
|
|
329
|
-
gh: run("gh"), git: run("git"), docker: run("docker"), killGroup: async (pid, marker) => killLedgerPid(pid, marker), ledger: (opts) => makeLedger(opts), runTmp: makeRunTmp(), host: makeHostProbe(), heavy: makeHeavyIo({ host: makeHostProbe() }), projector: makeProjector({ gh: base.gh }, { repo }), runner: makeLeanRunner({ subagentModel }), waitCiGreen: base.waitCiGreen,
|
|
358
|
+
gh: run("gh"), git: run("git"), docker: run("docker"), killGroup: async (pid, marker) => killLedgerPid(pid, marker), ledger: (opts) => makeLedger(opts), runTmp: makeRunTmp(), host: makeHostProbe(), heavy: guardHeavyDisk(makeHeavyIo({ host: makeHostProbe() }), { host: makeHostProbe(), minFreeGb: async () => (await import("../gc.mjs")).readHygiene(process.cwd()).min_free_gb, gc: async () => { const g = await import("../gc.mjs"); return g.runOwnedGc({ probes: g.makeGcProbes({ cwd: process.cwd() }), hygiene: g.readHygiene(process.cwd()), budgetMs: 60000 }); } }), projector: makeProjector({ gh: base.gh }, { repo }), runner: makeLeanRunner({ subagentModel }), waitCiGreen: base.waitCiGreen,
|
|
330
359
|
/** Shared dependency cache (#4220): the repo's own package manager, argv only, bounded by the cache's timeout. */
|
|
331
360
|
deps: makeDepCache({ exec: async (cmd, args, { cwd, env, timeoutMs } = {}) => String((await pexec(cmd, args, { cwd, env: { ...process.env, ...(env ?? {}) }, timeout: timeoutMs ?? 0, maxBuffer: 100 * 1024 * 1024 })).stdout) }),
|
|
332
361
|
/** Names of the checks the base branch requires: classic protection plus rulesets (#4158). [] when neither has any. */
|