forgedock 1.52.0 → 1.54.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/.claude-plugin/marketplace.json +51 -0
- package/README.md +8 -2
- package/bin/auth/app-manifest.mjs +89 -0
- package/bin/auth/app-manifest.test.mjs +75 -0
- package/bin/auth/app-token.mjs +256 -0
- package/bin/auth/app-token.test.mjs +232 -0
- package/bin/brand.mjs +7 -0
- package/bin/config-history.mjs +151 -0
- package/bin/config-schema.mjs +115 -0
- package/bin/demo.mjs +65 -11
- package/bin/engine/outcome-codes.mjs +9 -3
- package/bin/engine/telemetry-seam.mjs +11 -3
- package/bin/engine/telemetry-seam.test.mjs +17 -0
- package/bin/engine-cli.mjs +110 -36
- package/bin/experiment.mjs +58 -6
- package/bin/first-run.mjs +122 -0
- package/bin/forge-utils.mjs +6 -2
- package/bin/forgedock.mjs +138 -142
- package/bin/help-text.mjs +144 -0
- package/bin/hooks/pre-tool-use.mjs +7 -0
- package/bin/journey.mjs +82 -83
- package/bin/lean/acceptance.mjs +313 -0
- package/bin/lean/acceptance.test.mjs +215 -0
- package/bin/lean/account-watch.mjs +28 -0
- package/bin/lean/account-watch.test.mjs +30 -0
- package/bin/lean/activation.mjs +38 -0
- package/bin/lean/activation.test.mjs +36 -1
- package/bin/lean/basered.mjs +115 -0
- package/bin/lean/basered.test.mjs +66 -0
- package/bin/lean/batch-health.mjs +114 -7
- package/bin/lean/batch-health.test.mjs +87 -1
- package/bin/lean/batch.mjs +41 -2
- package/bin/lean/batch.test.mjs +115 -11
- package/bin/lean/branchlock.mjs +54 -0
- package/bin/lean/branchlock.test.mjs +49 -0
- package/bin/lean/ceiling.mjs +72 -0
- package/bin/lean/ceiling.test.mjs +54 -0
- package/bin/lean/checkpoint-reconcile.mjs +43 -0
- package/bin/lean/checkpoint-reconcile.test.mjs +95 -0
- package/bin/lean/ci-budget.mjs +366 -0
- package/bin/lean/ci-budget.test.mjs +167 -0
- package/bin/lean/conformance.e2e.test.mjs +8 -1
- package/bin/lean/conformance.mjs +269 -38
- package/bin/lean/conformance.test.mjs +280 -7
- package/bin/lean/context.mjs +35 -6
- package/bin/lean/context.test.mjs +27 -1
- package/bin/lean/depcache.mjs +25 -1
- package/bin/lean/depcache.test.mjs +26 -0
- package/bin/lean/e2e.mjs +18 -2
- package/bin/lean/e2e.test.mjs +26 -1
- package/bin/lean/effects.mjs +47 -14
- package/bin/lean/execution.mjs +19 -3
- package/bin/lean/execution.test.mjs +63 -0
- package/bin/lean/facts.mjs +3 -3
- package/bin/lean/facts.test.mjs +5 -0
- package/bin/lean/findinglabel.mjs +16 -0
- package/bin/lean/findinglabel.test.mjs +39 -0
- package/bin/lean/fixround.mjs +14 -0
- package/bin/lean/fixround.test.mjs +25 -2
- package/bin/lean/gh-assoc.test.mjs +2 -1
- package/bin/lean/integration.mjs +100 -9
- package/bin/lean/integration.test.mjs +98 -0
- package/bin/lean/issuewatch-parity.mjs +64 -0
- package/bin/lean/issuewatch-parity.test.mjs +127 -0
- package/bin/lean/issuewatch-release.mjs +6 -2
- package/bin/lean/issuewatch-release.test.mjs +17 -1
- package/bin/lean/issuewatch.mjs +45 -6
- package/bin/lean/issuewatch.test.mjs +3 -2
- package/bin/lean/lanelock.mjs +14 -0
- package/bin/lean/lean.mjs +473 -100
- package/bin/lean/lean.test.mjs +686 -33
- package/bin/lean/light.mjs +48 -7
- package/bin/lean/light.test.mjs +37 -3
- package/bin/lean/limits.test.mjs +142 -9
- package/bin/lean/mechfix.mjs +124 -0
- package/bin/lean/mechfix.test.mjs +75 -0
- package/bin/lean/orchestrate-cancel.test.mjs +143 -0
- package/bin/lean/orchestrate.mjs +116 -28
- package/bin/lean/phaseledger.mjs +47 -5
- package/bin/lean/phaseledger.test.mjs +30 -1
- package/bin/lean/postdeploy-check.test.mjs +39 -0
- package/bin/lean/precheck.mjs +23 -4
- package/bin/lean/precheck.test.mjs +14 -1
- package/bin/lean/prereq.mjs +28 -0
- package/bin/lean/prereq.test.mjs +20 -0
- package/bin/lean/probe.mjs +4 -2
- package/bin/lean/prodparity.mjs +52 -0
- package/bin/lean/prodparity.test.mjs +67 -0
- package/bin/lean/prompts.mjs +77 -19
- package/bin/lean/quota.mjs +39 -0
- package/bin/lean/recovery.test.mjs +11 -1
- package/bin/lean/relaxation.mjs +73 -0
- package/bin/lean/relaxation.test.mjs +54 -0
- package/bin/lean/release-io.test.mjs +42 -0
- package/bin/lean/release-postmerge.mjs +125 -0
- package/bin/lean/release-preflight.mjs +58 -0
- package/bin/lean/release-preflight.test.mjs +114 -0
- package/bin/lean/release-rehearsal.mjs +64 -0
- package/bin/lean/release-rehearsal.test.mjs +93 -0
- package/bin/lean/release-review.e2e.test.mjs +77 -0
- package/bin/lean/release-review.mjs +254 -0
- package/bin/lean/release-review.test.mjs +307 -0
- package/bin/lean/release-snapshot.mjs +188 -0
- package/bin/lean/release-snapshot.test.mjs +190 -0
- package/bin/lean/release.mjs +296 -0
- package/bin/lean/release.test.mjs +387 -0
- package/bin/lean/render.mjs +1 -1
- package/bin/lean/replan.mjs +184 -0
- package/bin/lean/replan.test.mjs +110 -0
- package/bin/lean/resume.mjs +9 -7
- package/bin/lean/resume.test.mjs +16 -0
- package/bin/lean/rotator.mjs +150 -31
- package/bin/lean/rotator.test.mjs +105 -2
- package/bin/lean/sandbox-remote.mjs +9 -2
- package/bin/lean/schedd.mjs +83 -5
- package/bin/lean/schedd.test.mjs +108 -7
- package/bin/lean/selfreview.mjs +94 -0
- package/bin/lean/selfreview.test.mjs +58 -1
- package/bin/lean/selftest-gate.mjs +22 -0
- package/bin/lean/selftest-gate.test.mjs +18 -1
- package/bin/lean/selftest-journey.mjs +234 -0
- package/bin/lean/selftest-journey.test.mjs +130 -0
- package/bin/lean/selftest-live.mjs +2 -1
- package/bin/lean/seqlease.mjs +35 -1
- package/bin/lean/seqlease.test.mjs +15 -0
- package/bin/lean/seqreserve.e2e.test.mjs +135 -0
- package/bin/lean/seqreserve.mjs +73 -0
- package/bin/lean/seqreserve.test.mjs +134 -0
- package/bin/lean/sequence.mjs +35 -6
- package/bin/lean/seqversioned.mjs +147 -0
- package/bin/lean/stagestamp.mjs +28 -0
- package/bin/lean/stagestamp.test.mjs +32 -0
- package/bin/lean/surfaces.mjs +75 -0
- package/bin/lean/surfaces.test.mjs +59 -0
- package/bin/lean/toolplace.mjs +28 -0
- package/bin/lean/toolplace.test.mjs +24 -0
- package/bin/lean/toolstats.mjs +3 -1
- package/bin/lean/toolstats.test.mjs +11 -0
- package/bin/lean/validatebest.mjs +28 -0
- package/bin/lean/validatebest.test.mjs +27 -0
- package/bin/lean/verifier.mjs +3 -2
- package/bin/lean/verify.mjs +2 -1
- package/bin/lean/verify.test.mjs +6 -0
- package/bin/pool/agent.mjs +27 -4
- package/bin/pool/docker.mjs +5 -0
- package/bin/pool/router.mjs +74 -28
- package/bin/prereqs.mjs +111 -0
- package/bin/replay-timelapse.mjs +149 -0
- package/bin/review-staging.mjs +123 -16
- package/bin/review-staging.test.mjs +18 -0
- package/bin/runner.mjs +43 -6
- package/bin/splash-install.mjs +157 -0
- package/bin/stats/aggregate.mjs +8 -1
- package/bin/stats/conformance-outcomes.mjs +289 -0
- package/bin/stats/conformance-outcomes.test.mjs +274 -0
- package/bin/stats/depth.mjs +275 -0
- package/bin/stats/depth.test.mjs +158 -0
- package/bin/stats/efficiency.mjs +26 -5
- package/bin/stats/efficiency.test.mjs +45 -1
- package/bin/stats/experiment.mjs +7 -5
- package/bin/stats/first-review.mjs +77 -0
- package/bin/stats/first-review.test.mjs +36 -0
- package/bin/stats/firstmerge.mjs +40 -0
- package/bin/stats/firstmerge.test.mjs +41 -0
- package/bin/stats/github-source.mjs +53 -15
- package/bin/stats/index.mjs +147 -9
- package/bin/stats/local-source.mjs +12 -0
- package/bin/stats/origin.mjs +80 -0
- package/bin/stats/origin.test.mjs +58 -0
- package/bin/stats/query.mjs +69 -0
- package/bin/stats/render.mjs +3 -1
- package/bin/stats/scoreboard.mjs +137 -0
- package/bin/stats/scoreboard.test.mjs +87 -0
- package/bin/stats/selffiled.mjs +52 -0
- package/bin/stats/selffiled.test.mjs +71 -0
- package/bin/stats/stats.test.mjs +80 -0
- package/bin/tui.mjs +3 -2
- package/commands/bootstrap.md +15 -14
- package/commands/deploy-pr.md +18 -3
- package/commands/forge-stats.md +1 -1
- package/commands/forgedock-ci-setup.md +28 -0
- package/commands/forgedock-init.md +4 -5
- package/commands/issue.md +2 -0
- package/commands/milestone.md +9 -1
- package/commands/orchestrate.md +1 -1
- package/commands/replay.md +2 -0
- package/commands/review-pr-agents/security.md +4 -0
- package/commands/review-pr-staging.md +6 -1
- package/commands/work-on/build.md +4 -6
- package/commands/work-on/close.md +8 -0
- package/docs/CONFIG.md +170 -18
- package/docs/ISSUE-WATCH.md +25 -0
- package/docs/OUTCOME-CODES.md +4 -0
- package/docs/REPLAY.md +9 -0
- package/docs/SELFTEST.md +11 -0
- package/docs/STATS.md +61 -0
- package/docs/TELEMETRY.md +1 -1
- package/docs/eval/README.md +6 -0
- package/docs/eval/adversarial-bench.md +68 -0
- package/docs/eval/corpus/adversarial-v1.json +285 -0
- package/docs/eval/feature-bench.md +42 -0
- package/docs/eval/feature-specs/crud-auth/journeys/notes-crud-isolated.mjs +21 -0
- package/docs/eval/feature-specs/crud-auth/journeys/register-login.mjs +12 -0
- package/docs/eval/feature-specs/crud-auth/spec.md +15 -0
- package/docs/site/start-a-new-project.md +2 -1
- package/package.json +5 -2
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +10 -0
- package/plugins/forgedock-splash/README.md +27 -0
- package/plugins/forgedock-splash/hooks/hooks.json +1 -0
- package/plugins/forgedock-splash/hooks/register.tsx +74 -0
- package/plugins/forgedock-splash/hooks/scene.ts +222 -0
- package/plugins/forgedock-splash/types/index.d.ts +10 -0
- package/pool/README.md +1 -1
- package/pool/image/cs-cred +14 -1
- package/scripts/backfill-finding-labels.mjs +50 -0
- package/scripts/backfill-finding-labels.test.mjs +36 -0
- package/scripts/bench-adversarial.mjs +216 -0
- package/scripts/bench-feature.mjs +170 -0
- package/scripts/bench-lightlane.mjs +2 -2
- package/scripts/bootstrap-create.mjs +2 -2
- package/scripts/bootstrap-validate.mjs +35 -2
- package/scripts/check-spec-size.sh +4 -3
- package/scripts/check-spec-size.test.sh +3 -0
- package/scripts/doctor-pipeline-state.sh +21 -6
- package/scripts/file-deferred-followups.sh +59 -251
- package/scripts/file-deferred-followups.test.sh +85 -206
- package/scripts/followup-route.mjs +12 -0
- package/scripts/owner-route-parity.test.sh +17 -1
- package/scripts/plan-validate-live.mjs +40 -6
- package/scripts/review-pr-side-effects.test.sh +40 -0
- package/scripts/review-pr-staging-scope.test.sh +1 -1
- package/scripts/review-staging-post.sh +23 -0
- package/scripts/review-staging-post.test.sh +8 -0
|
@@ -4,7 +4,7 @@ import { describe, it } from "node:test";
|
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { phasesOf } from "./orchestrate.mjs";
|
|
6
6
|
import { aggregate } from "../stats/aggregate.mjs";
|
|
7
|
-
import { LANE_PHASES, createLedger, laneSum, withinWall, flattenPhases, unflattenPhases, summarizePhases, formatLedgerSummary } from "./phaseledger.mjs";
|
|
7
|
+
import { LANE_PHASES, createLedger, laneSum, withinWall, flattenPhases, unflattenPhases, summarizePhases, formatLedgerSummary, WAIT_CAUSES, summarizeWaits } from "./phaseledger.mjs";
|
|
8
8
|
|
|
9
9
|
const clock = () => { let t = 1000; const f = () => t; f.tick = (ms) => { t += ms; }; return f; };
|
|
10
10
|
|
|
@@ -69,4 +69,33 @@ describe("phase ledger (#4908)", () => {
|
|
|
69
69
|
assert.equal(t?.ledger.n, 1);
|
|
70
70
|
assert.equal(t.ledger.largest.phase, "implement");
|
|
71
71
|
});
|
|
72
|
+
|
|
73
|
+
it("attributes non-model time to named causes that close to the phase wall (#5349)", () => {
|
|
74
|
+
const now = clock(), L = createLedger(now);
|
|
75
|
+
L.enter("plan"); now.tick(100000);
|
|
76
|
+
L.addModel("plan", 30000, 0.1);
|
|
77
|
+
L.addWait("plan", "heavy_queue", 20000); L.addWait("plan", "rate_limit", 10000); L.addWait("plan", "bogus", 5); L.addWait("nope", "host_load", 1000);
|
|
78
|
+
L.enter("implement"); now.tick(50000);
|
|
79
|
+
const p = L.snapshot();
|
|
80
|
+
assert.deepEqual(p.plan.wait, { heavy_queue: 20000, rate_limit: 10000, host_load: 1000, command: 39000 });
|
|
81
|
+
assert.equal(p.plan.model_ms + Object.values(p.plan.wait).reduce((a, b) => a + b, 0), p.plan.ms);
|
|
82
|
+
assert.deepEqual(p.implement.wait, { command: 50000 });
|
|
83
|
+
assert.equal(createLedger(clock()).snapshot().plan, undefined);
|
|
84
|
+
const first = createLedger(now); now.tick(7000);
|
|
85
|
+
assert.deepEqual(first.snapshot().sandbox_start.wait, { sandbox: 7000 });
|
|
86
|
+
assert.ok(WAIT_CAUSES.includes("host_load"));
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("wait round-trips through the flattened telemetry keys and aggregates by cause; old rows stay n/a (#5349)", () => {
|
|
90
|
+
const p = { plan: { ms: 10, model_ms: 4, wait: { heavy_queue: 3, command: 3 } }, merge: { ms: 7 } };
|
|
91
|
+
const flat = flattenPhases(p);
|
|
92
|
+
assert.equal(flat.phase_plan_wait_heavy_queue_ms, 3);
|
|
93
|
+
assert.deepEqual(unflattenPhases(flat), p);
|
|
94
|
+
const s = summarizeWaits([p, { plan: { ms: 5 } }, null]);
|
|
95
|
+
assert.equal(s.n, 1);
|
|
96
|
+
assert.deepEqual(s.total, { ms: 17, model_ms: 4, wait: { heavy_queue: 3, command: 3 } });
|
|
97
|
+
assert.equal(summarizeWaits([{ plan: { ms: 5 } }]).n, 0);
|
|
98
|
+
const q = summarizeWaits([1, 2, 3, 4].map((n) => ({ plan: { ms: 10 * n, wait: { heavy_queue: n * 1000 } } })));
|
|
99
|
+
assert.deepEqual(q.phases.plan.pct.heavy_queue, { p50: 2500, p90: 4000 });
|
|
100
|
+
});
|
|
72
101
|
});
|
|
@@ -6,6 +6,10 @@ import { parseChecks, itemCheckIds, measureFollowup, monitorRecord, CHECK_ID_RE,
|
|
|
6
6
|
import { postDeployOnly } from "./prefilter.mjs";
|
|
7
7
|
import { validateContract, applyAmendments, precheck, followupItems } from "./conformance.mjs";
|
|
8
8
|
import { PROBE_MARKER } from "./probe.mjs";
|
|
9
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
10
|
+
import { tmpDir } from "../tests/_tmp.mjs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
9
13
|
|
|
10
14
|
const item = (id, why) => `- [ ] \`${id}: some quote here\` — post-deploy: ${why}`;
|
|
11
15
|
const body = (items) => `## Acceptance Criteria\n\n${items.join("\n")}\n\n<!-- FORGE:DEFERRED_FROM: #40 -->\n`;
|
|
@@ -284,3 +288,38 @@ describe("rollout-blocked rows raise one owner ask per flag (#4769)", () => {
|
|
|
284
288
|
assert.equal(r.state, "fail"); assert.equal(asks(w).length, 0);
|
|
285
289
|
});
|
|
286
290
|
});
|
|
291
|
+
|
|
292
|
+
describe("R2-remote-hotspot-config check command (#5198)", () => {
|
|
293
|
+
const cmd = JSON.parse(readFileSync(new URL("../../.forge/post-deploy-checks.json", import.meta.url), "utf8"))["R2-remote-hotspot-config"].run;
|
|
294
|
+
// Stub gh: applies the --jq filter's two selects to the comments in comments.json and prints the per-page count.
|
|
295
|
+
const runCheck = (comments) => {
|
|
296
|
+
const dir = tmpDir("r2chk-");
|
|
297
|
+
writeFileSync(join(dir, "comments.json"), JSON.stringify(comments));
|
|
298
|
+
writeFileSync(join(dir, "gh"), `#!/usr/bin/env node
|
|
299
|
+
const fs = require("fs"); const a = process.argv.slice(2);
|
|
300
|
+
fs.appendFileSync(${JSON.stringify(join(dir, "argv.log"))}, a.join(" ") + "\\n");
|
|
301
|
+
if (a[0] !== "api") process.exit(2);
|
|
302
|
+
const jq = a[a.indexOf("--jq") + 1];
|
|
303
|
+
const start = (jq.match(/startswith\\("([^"]*)"\\)/) || [])[1];
|
|
304
|
+
const has = (jq.match(/contains\\("([^"]*)"\\)/) || [])[1];
|
|
305
|
+
const cs = JSON.parse(fs.readFileSync(${JSON.stringify(join(dir, "comments.json"))}, "utf8"));
|
|
306
|
+
console.log(cs.filter((c) => c.body.startsWith(start) && c.body.includes(has)).length);
|
|
307
|
+
`, { mode: 0o755 });
|
|
308
|
+
const r = spawnSync("bash", ["-c", cmd], { env: { ...process.env, PATH: `${dir}:${process.env.PATH}` }, encoding: "utf8" });
|
|
309
|
+
return { code: r.status, argv: readFileSync(join(dir, "argv.log"), "utf8") };
|
|
310
|
+
};
|
|
311
|
+
const traj = (anoms) => ({ id: 1, body: `<!-- FORGE:TRAJECTORY -->\n## Pipeline Trajectory\n\n**Anomalies**\n${anoms}\n` });
|
|
312
|
+
|
|
313
|
+
it("is repo-scoped (comments API, no gh search)", () => {
|
|
314
|
+
assert.doesNotMatch(cmd, /gh search/);
|
|
315
|
+
const r = runCheck([]);
|
|
316
|
+
assert.match(r.argv, /^api repos\/\{owner\}\/\{repo\}\/issues\/comments\?since=\d{4}-\d\d-\d\dT/);
|
|
317
|
+
});
|
|
318
|
+
it("passes with no comments", () => assert.equal(runCheck([]).code, 0));
|
|
319
|
+
it("fails on a trajectory comment carrying the anomaly bullet", () => {
|
|
320
|
+
assert.equal(runCheck([traj("- hotspot_config_missing: no forge.yaml readable")]).code, 1);
|
|
321
|
+
});
|
|
322
|
+
it("ignores prose that quotes the token", () => {
|
|
323
|
+
assert.equal(runCheck([{ id: 2, body: "Release notes: the `hotspot_config_missing` anomaly is recorded" }, traj("- none")]).code, 0);
|
|
324
|
+
});
|
|
325
|
+
});
|
package/bin/lean/precheck.mjs
CHANGED
|
@@ -14,6 +14,23 @@ import { loadavg, cpus } from "node:os";
|
|
|
14
14
|
import { scopeChecks, selectCommands, mergeChecks } from "./testmap.mjs";
|
|
15
15
|
import { LOG_CAP } from "./verify.mjs";
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* #5332: a check that hit its own timeout even after the one longer retry (rc 124) is host load, not a failing check.
|
|
19
|
+
* `failed` are the real failures (builder-visible, ci.red); `timedOut` are left to CI or end a recoverable timeout code.
|
|
20
|
+
*/
|
|
21
|
+
export function splitPrecheckResults(results) {
|
|
22
|
+
const list = Array.isArray(results) ? results : [];
|
|
23
|
+
return { failed: list.filter((r) => r.rc !== 0 && r.rc !== TIMEOUT_RC), timedOut: list.filter((r) => r.rc === TIMEOUT_RC) };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** #5332: names each timed-out command and its limit (the `(timed out after Ns)` the run reported, i.e. the retry's, else `limitMs`). */
|
|
27
|
+
export function timedOutDetail(timedOut, limitMs) {
|
|
28
|
+
return (timedOut ?? []).map((t) => {
|
|
29
|
+
const m = /\(timed out after (\d+)s\)/.exec(String(t.output ?? "")), s = m ? Number(m[1]) : Number(limitMs) > 0 && Number.isFinite(Number(limitMs)) ? Math.round(Number(limitMs) / 1000) : null;
|
|
30
|
+
return `\`${t.command}\` (timed out${s ? ` after ${s} s` : ""}, exit 124)`;
|
|
31
|
+
}).join(", ");
|
|
32
|
+
}
|
|
33
|
+
|
|
17
34
|
/** #4364: the engine's check plan for `forgedock check` (written beside contract.json) and the CLI's last run record. */
|
|
18
35
|
export const CHECK_PLAN_FILE = ".forge-lean/check-plan.json";
|
|
19
36
|
export const SELF_CHECK_FILE = ".forge-lean/self-check.json";
|
|
@@ -176,7 +193,7 @@ export function selfCheckState(record, fingerprint) {
|
|
|
176
193
|
* heavy binaries. ok = every command that ran exited 0 (deferred and `ci` are not failures, as in the engine).
|
|
177
194
|
* @param {{contract:object, plan:{mode?:string, commands:string[], budgetMs:number, perCommandMs:number}, parallelism?:number, now?:() => number, run:Function}} p
|
|
178
195
|
*/
|
|
179
|
-
export async function selfCheck({ contract, plan, parallelism = 1, now = () => Date.now(), run }) {
|
|
196
|
+
export async function selfCheck({ contract, plan, parallelism = 1, now = () => Date.now(), run, review = [] }) {
|
|
180
197
|
const vals = (Array.isArray(contract?.validate) ? contract.validate : []).filter((v) => v && String(v.command ?? "").trim());
|
|
181
198
|
const ci = plan?.mode === "ci", per = Number(plan?.perCommandMs) > 0 ? Number(plan.perCommandMs) : 300000;
|
|
182
199
|
const validate = [];
|
|
@@ -190,8 +207,9 @@ export async function selfCheck({ contract, plan, parallelism = 1, now = () => D
|
|
|
190
207
|
}
|
|
191
208
|
const pre = await runChecks({ commands: plan?.commands ?? [], parallelism, budgetMs: plan?.budgetMs ?? 0, perCommandMs: per, now, run });
|
|
192
209
|
const commands = [...pre.results];
|
|
193
|
-
|
|
194
|
-
|
|
210
|
+
// #5345: the reviewer's deterministic findings (selfreview.mjs) are failures of the check, so a red tree is never sent to review
|
|
211
|
+
const ok = [...validate, ...commands].every((x) => x.status || x.rc === 0) && review.length === 0;
|
|
212
|
+
return { ok, validate, commands, deferred: pre.deferred, ...(review.length ? { review } : {}) };
|
|
195
213
|
}
|
|
196
214
|
|
|
197
215
|
/** #4390: summary lines naming a failing test, as common runners print them (pytest, TAP/node --test, jest/vitest, go, cargo). */
|
|
@@ -225,6 +243,7 @@ export function formatCheckTable(r, cap = LOG_CAP) {
|
|
|
225
243
|
const failed = rows.filter((x) => !x.status && x.rc !== 0);
|
|
226
244
|
const per = Math.max(500, Math.floor(cap / Math.max(1, failed.length))); // verify.mjs capLogs share
|
|
227
245
|
for (const f of failed) out.push("", `--- ${f.label} (exit ${f.rc})`, quietFailure(f.output, { maxChars: per, logPath: f.logPath ?? null }));
|
|
228
|
-
|
|
246
|
+
for (const f of r.review ?? []) out.push(`FAIL review ${f.code}: ${f.detail}`);
|
|
247
|
+
out.push("", r.ok ? "check: PASS" : `check: FAIL (${failed.length + (r.review?.length ?? 0)} failing)`);
|
|
229
248
|
return out.join("\n");
|
|
230
249
|
}
|
|
@@ -6,7 +6,7 @@ import { writeFileSync } from "node:fs";
|
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
8
8
|
import { formatFirstPassSummary } from "./fixround.mjs";
|
|
9
|
-
import { runChecks, retryTimeoutMs, runWithTimeoutRetry, formatPrecheckSummary, planPrecheck, selfCheck, selfCheckState, formatCheckTable, worktreeFingerprint, quietFailure } from "./precheck.mjs";
|
|
9
|
+
import { runChecks, retryTimeoutMs, runWithTimeoutRetry, formatPrecheckSummary, planPrecheck, selfCheck, selfCheckState, formatCheckTable, worktreeFingerprint, quietFailure, splitPrecheckResults, timedOutDetail } from "./precheck.mjs";
|
|
10
10
|
import { execFileSync } from "node:child_process";
|
|
11
11
|
import { readPrecheckBudget } from "../engine-cli.mjs";
|
|
12
12
|
import { orchestrate } from "./orchestrate.mjs";
|
|
@@ -282,3 +282,16 @@ describe("check timeout is infrastructure (#4589)", () => {
|
|
|
282
282
|
assert.deepEqual([x.retried, x.r.rc, x.r.output], [true, 0, "2000"]);
|
|
283
283
|
});
|
|
284
284
|
});
|
|
285
|
+
|
|
286
|
+
describe("#5332 timed-out checks are not failing checks", () => {
|
|
287
|
+
it("splitPrecheckResults separates rc 124 from real failures", () => {
|
|
288
|
+
const r = [{ command: "a", rc: 0 }, { command: "b", rc: 124 }, { command: "c", rc: 1 }];
|
|
289
|
+
const { failed, timedOut } = splitPrecheckResults(r);
|
|
290
|
+
assert.deepEqual(failed.map((x) => x.command), ["c"]); assert.deepEqual(timedOut.map((x) => x.command), ["b"]);
|
|
291
|
+
assert.deepEqual(splitPrecheckResults(undefined), { failed: [], timedOut: [] });
|
|
292
|
+
});
|
|
293
|
+
it("timedOutDetail names the command and its limit", () => {
|
|
294
|
+
assert.equal(timedOutDetail([{ command: "make t", rc: 124, output: "x\n(timed out after 900s)" }], 300000), "`make t` (timed out after 900 s, exit 124)");
|
|
295
|
+
assert.equal(timedOutDetail([{ command: "make t", rc: 124, output: "" }], 300000), "`make t` (timed out after 300 s, exit 124)");
|
|
296
|
+
});
|
|
297
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* Dependency-ordered admission (#5340): a declared prerequisite (`Depends on #N`) outside the batch is open on GitHub, so
|
|
5
|
+
* a run of the dependent can only end `dependency-open` and is retried. Orchestrate pulls such a prerequisite into the
|
|
6
|
+
* batch up front, so its DAG orders it first, instead of discovering it after a wasted run. A closed prerequisite is
|
|
7
|
+
* satisfied; a `needs-human` one is parked and not pulled in (the engine's own admission still refuses the dependent).
|
|
8
|
+
* Fail-open: an unreadable state or label adds nothing. Probes are injected.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {{deps:number[], inBatch:(n:number)=>boolean, results?:Map<number,object>, issueState?:Function, issueLabels?:Function}} p
|
|
13
|
+
* @returns {Promise<{pull:number[], parked:number[]}>} open prerequisites to add to the batch, and parked ones left out
|
|
14
|
+
*/
|
|
15
|
+
export async function openPrerequisites({ deps = [], inBatch, results = new Map(), issueState = null, issueLabels = null }) {
|
|
16
|
+
const pull = [], parked = [];
|
|
17
|
+
if (typeof issueState !== "function") return { pull, parked }; // no state probe: nothing is known to be open
|
|
18
|
+
for (const d of [...new Set(deps)]) {
|
|
19
|
+
if (inBatch(d) || results.has(d)) continue;
|
|
20
|
+
let st = "";
|
|
21
|
+
try { st = String((await issueState(d)) ?? "").toUpperCase(); } catch { st = ""; }
|
|
22
|
+
if (st !== "OPEN") continue; // closed (satisfied) or unreadable (fail-open)
|
|
23
|
+
let names = [];
|
|
24
|
+
try { names = typeof issueLabels === "function" ? ((await issueLabels(d)) ?? []) : []; } catch { names = []; }
|
|
25
|
+
(Array.isArray(names) && names.includes("needs-human") ? parked : pull).push(d);
|
|
26
|
+
}
|
|
27
|
+
return { pull, parked };
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// Prerequisite pull-in (#5340).
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { openPrerequisites } from "./prereq.mjs";
|
|
7
|
+
|
|
8
|
+
const states = { 2: "OPEN", 3: "CLOSED", 4: "OPEN", 5: "OPEN", 6: "boom" };
|
|
9
|
+
const issueState = async (n) => { if (n === 6) throw new Error("gh down"); return states[n]; };
|
|
10
|
+
const issueLabels = async (n) => (n === 4 ? ["needs-human"] : []);
|
|
11
|
+
|
|
12
|
+
describe("openPrerequisites (#5340)", () => {
|
|
13
|
+
it("pulls open out-of-batch prerequisites; skips closed, in-batch, finished, parked and unreadable ones", async () => {
|
|
14
|
+
const r = await openPrerequisites({ deps: [2, 3, 4, 5, 6, 7, 2], inBatch: (d) => d === 5, results: new Map([[7, {}]]), issueState, issueLabels });
|
|
15
|
+
assert.deepEqual(r, { pull: [2], parked: [4] });
|
|
16
|
+
});
|
|
17
|
+
it("without a state probe nothing is known to be open", async () => {
|
|
18
|
+
assert.deepEqual(await openPrerequisites({ deps: [2], inBatch: () => false }), { pull: [], parked: [] });
|
|
19
|
+
});
|
|
20
|
+
});
|
package/bin/lean/probe.mjs
CHANGED
|
@@ -41,13 +41,13 @@ const isForgeMarker = (body) => /^\s*<!--\s*FORGE:/.test(String(body ?? ""));
|
|
|
41
41
|
* a line of its own character at least as long; anything inside another fence (a quoted sample) or indented 4+ columns
|
|
42
42
|
* (an indented code block) is content, never a declaration. An unclosed fence yields nothing.
|
|
43
43
|
*/
|
|
44
|
-
function
|
|
44
|
+
export function fencedBlocks(text, tag = "forge-probe") {
|
|
45
45
|
const blocks = [];
|
|
46
46
|
let open = null;
|
|
47
47
|
for (const line of text.split("\n")) {
|
|
48
48
|
const m = FENCE_RE.exec(line);
|
|
49
49
|
if (!open) {
|
|
50
|
-
if (m && !(m[1][0] === "`" && m[2].includes("`"))) open = { ch: m[1][0], len: m[1].length, lines: m[2].trim() ===
|
|
50
|
+
if (m && !(m[1][0] === "`" && m[2].includes("`"))) open = { ch: m[1][0], len: m[1].length, lines: m[2].trim() === tag ? [] : null };
|
|
51
51
|
} else if (m && m[1][0] === open.ch && m[1].length >= open.len && !m[2].trim()) {
|
|
52
52
|
if (open.lines) blocks.push(open.lines.join("\n"));
|
|
53
53
|
open = null;
|
|
@@ -56,6 +56,8 @@ function probeBlocks(text) {
|
|
|
56
56
|
return blocks;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
const probeBlocks = (text) => fencedBlocks(text, "forge-probe");
|
|
60
|
+
|
|
59
61
|
/** The last top-level ```forge-probe block of `text`: {run, pass, timeoutS}, or null when absent or malformed. */
|
|
60
62
|
export function parseProbe(text) {
|
|
61
63
|
const blocks = probeBlocks(noComments(String(text ?? ""), " ").replace(/\r\n?/g, "\n"));
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* #5284: production parity beyond ingress. forge.yaml `topology.prod_parity` is a block map `{path glob: command | "note: how to verify"}`
|
|
5
|
+
* of production-only facts (runtime build mode, migration role vs app role, env scope, ingress). A lane that changes a file matching a
|
|
6
|
+
* glob needs that surface's evidence: a command rule runs once with the matching paths as arguments (non-zero blocks); a note rule needs
|
|
7
|
+
* `parity: [{surface: <glob>, justification}]` in the lane's result file. Deterministic, 0 LLM calls; core stays repo-agnostic (#1347).
|
|
8
|
+
*/
|
|
9
|
+
import { OUTCOME_CODES } from "../engine/outcome-codes.mjs";
|
|
10
|
+
import { globToRegex } from "../../scripts/ci-local/lib.mjs";
|
|
11
|
+
|
|
12
|
+
const NOTE = /^note:\s*/i;
|
|
13
|
+
const norm = (p) => String(p ?? "").trim().replace(/^\.\//, "");
|
|
14
|
+
const sq = (s) => `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
15
|
+
|
|
16
|
+
/** Rules `{glob, command|note}` from the config map; entries with no glob or value are dropped. */
|
|
17
|
+
export function parseProdParity(map) {
|
|
18
|
+
if (!map || typeof map !== "object" || Array.isArray(map)) return [];
|
|
19
|
+
const rules = [];
|
|
20
|
+
for (const [key, val] of Object.entries(map)) {
|
|
21
|
+
const glob = norm(key), v = String(val ?? "").trim().replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
22
|
+
if (!glob || !v) continue;
|
|
23
|
+
rules.push(NOTE.test(v) ? { glob, note: v.replace(NOTE, "") } : { glob, command: v });
|
|
24
|
+
}
|
|
25
|
+
return rules;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Declared surfaces with the changed files they match: [{rule, files}]. */
|
|
29
|
+
export function touchedSurfaces(rules, changedFiles) {
|
|
30
|
+
const changed = (changedFiles ?? []).map(norm);
|
|
31
|
+
return (rules ?? []).map((rule) => { const re = globToRegex(rule.glob); return { rule, files: changed.filter((f) => re.test(f)) }; }).filter((s) => s.files.length);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Blocking failures (conformance.unimplemented) for touched surfaces lacking evidence. `run` is ({command}) => {rc, output}
|
|
36
|
+
* (a `{r: {rc, output}}` wrapper is unwrapped). A command that cannot start (rc 127) is reported: a declared check that never ran is no evidence.
|
|
37
|
+
*/
|
|
38
|
+
export async function prodParityFailures({ rules, changedFiles, result, run }) {
|
|
39
|
+
const out = [], given = Array.isArray(result?.parity) ? result.parity : [];
|
|
40
|
+
for (const { rule, files } of touchedSurfaces(rules, changedFiles)) {
|
|
41
|
+
if (rule.command) {
|
|
42
|
+
let r;
|
|
43
|
+
try { r = await run({ command: `${rule.command} ${files.map(sq).join(" ")}` }); r = r?.r ?? r; } catch (e) { r = { rc: 127, output: String(e?.message ?? e) }; }
|
|
44
|
+
if (r?.rc === 0) continue;
|
|
45
|
+
const tail = String(r?.output ?? "").trim().split("\n").slice(-12).join("\n").slice(0, 1500);
|
|
46
|
+
out.push({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, kind: "prod_parity_failed", detail: `forge.yaml topology.prod_parity \`${rule.glob}\` (\`${rule.command}\`) exited ${r?.rc ?? "?"} for ${files.slice(0, 3).join(", ")}${tail ? `:\n${tail}` : ""}` });
|
|
47
|
+
} else if (!given.some((p) => norm(p?.surface) === rule.glob && String(p?.justification ?? "").trim())) {
|
|
48
|
+
out.push({ code: OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, kind: "prod_parity_unjustified", detail: `${files.slice(0, 3).join(", ")} touches the production-only surface \`${rule.glob}\` (forge.yaml topology.prod_parity): verify "${rule.note}" and record parity: [{"surface":"${rule.glob}","justification":"<evidence>"}] in the result file` });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { spawnSync } from "node:child_process";
|
|
6
|
+
import { writeFileSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { parseProdParity, prodParityFailures, touchedSurfaces } from "./prodparity.mjs";
|
|
9
|
+
import { readEnvConfig } from "../engine-cli.mjs";
|
|
10
|
+
import { tmpDir } from "../tests/_tmp.mjs";
|
|
11
|
+
|
|
12
|
+
const run = async ({ command }) => { const r = spawnSync("bash", ["-c", command], { encoding: "utf8" }); return { rc: r.status ?? 127, output: `${r.stdout}${r.stderr}` }; };
|
|
13
|
+
const dir = tmpDir("prodparity-");
|
|
14
|
+
const fail = join(dir, "fail.sh"); writeFileSync(fail, "echo \"parity: $*\" >&2; exit 1\n");
|
|
15
|
+
const pass = join(dir, "pass.sh"); writeFileSync(pass, "exit 0\n");
|
|
16
|
+
|
|
17
|
+
// The four AlterLab defects (2026-10-11..11-10): each prod-only surface is declared; the PR's files touch it.
|
|
18
|
+
const RULES = parseProdParity({
|
|
19
|
+
"web/app/**": "note: exercise the page under the production ISR runtime (next start), including the not-found path",
|
|
20
|
+
"infra/traefik/**": `bash ${fail}`,
|
|
21
|
+
"db/migrations/**": `bash ${fail}`,
|
|
22
|
+
".env.production": `bash ${fail}`,
|
|
23
|
+
});
|
|
24
|
+
const REPLAYS = [
|
|
25
|
+
["#38270 /blog ISR", ["web/app/blog/[slug]/page.tsx"], "prod_parity_unjustified"],
|
|
26
|
+
["#38241 Traefik routing", ["infra/traefik/api-router.yml"], "prod_parity_failed"],
|
|
27
|
+
["#39108 migration role", ["db/migrations/0042_feedback.sql"], "prod_parity_failed"],
|
|
28
|
+
["#36906 shared env", [".env.production"], "prod_parity_failed"],
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
describe("prod_parity (#5284)", () => {
|
|
32
|
+
for (const [name, files, kind] of REPLAYS) {
|
|
33
|
+
it(`replay ${name} is flagged`, async () => {
|
|
34
|
+
const f = await prodParityFailures({ rules: RULES, changedFiles: files, result: {}, run });
|
|
35
|
+
assert.equal(f.length, 1);
|
|
36
|
+
assert.equal(f[0].kind, kind);
|
|
37
|
+
assert.equal(f[0].code, "conformance.unimplemented");
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
it("a passing command or a recorded justification clears the surface", async () => {
|
|
41
|
+
const ok = parseProdParity({ "db/migrations/**": `bash ${pass}` });
|
|
42
|
+
assert.deepEqual(await prodParityFailures({ rules: ok, changedFiles: ["db/migrations/1.sql"], result: {}, run }), []);
|
|
43
|
+
const result = { parity: [{ surface: "web/app/**", justification: "ran next start; /blog renders" }] };
|
|
44
|
+
assert.deepEqual(await prodParityFailures({ rules: RULES, changedFiles: ["web/app/blog/page.tsx"], result, run }), []);
|
|
45
|
+
const blank = { parity: [{ surface: "web/app/**", justification: " " }] };
|
|
46
|
+
assert.equal((await prodParityFailures({ rules: RULES, changedFiles: ["web/app/blog/page.tsx"], result: blank, run })).length, 1);
|
|
47
|
+
});
|
|
48
|
+
it("untouched surfaces and no rules are silent; the command gets only matching paths", async () => {
|
|
49
|
+
assert.deepEqual(await prodParityFailures({ rules: RULES, changedFiles: ["README.md"], result: {}, run }), []);
|
|
50
|
+
assert.deepEqual(await prodParityFailures({ rules: [], changedFiles: [".env.production"], result: {}, run }), []);
|
|
51
|
+
const f = await prodParityFailures({ rules: RULES, changedFiles: [".env.production", "README.md"], result: {}, run });
|
|
52
|
+
assert.match(f[0].detail, /parity: \.env\.production\b/);
|
|
53
|
+
assert.deepEqual(touchedSurfaces(RULES, ["README.md"]), []);
|
|
54
|
+
});
|
|
55
|
+
it("a command that cannot run is reported, not swallowed", async () => {
|
|
56
|
+
const f = await prodParityFailures({ rules: parseProdParity({ "a/**": "x" }), changedFiles: ["a/b"], result: {}, run: async () => { throw new Error("boom"); } });
|
|
57
|
+
assert.equal(f[0].kind, "prod_parity_failed");
|
|
58
|
+
assert.match(f[0].detail, /exited 127/);
|
|
59
|
+
});
|
|
60
|
+
it("forge.yaml topology.prod_parity is read; repos without it get no key", () => {
|
|
61
|
+
const withKey = tmpDir("pp-yaml-"), without = tmpDir("pp-yaml-");
|
|
62
|
+
writeFileSync(join(withKey, "forge.yaml"), "topology:\n prod_parity:\n \"db/migrations/**\": \"bash scripts/check-role.sh\"\n \".env.production\": \"note: confirm service env scope\"\n");
|
|
63
|
+
writeFileSync(join(without, "forge.yaml"), "project: x/y\n");
|
|
64
|
+
assert.deepEqual(parseProdParity(readEnvConfig(withKey).prodParity).map((r) => r.glob), ["db/migrations/**", ".env.production"]);
|
|
65
|
+
assert.equal("prodParity" in readEnvConfig(without), false);
|
|
66
|
+
});
|
|
67
|
+
});
|