forgedock 1.62.0 → 1.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/config-schema.mjs +5 -0
- package/bin/engine/outcome-codes.mjs +5 -0
- package/bin/engine-cli.mjs +109 -21
- package/bin/env/cli.mjs +18 -1
- package/bin/lean/basered.mjs +56 -11
- package/bin/lean/basered.test.mjs +58 -5
- package/bin/lean/batch-health.mjs +46 -4
- package/bin/lean/batch-health.test.mjs +55 -1
- package/bin/lean/batch.mjs +9 -1
- package/bin/lean/batch.test.mjs +74 -7
- package/bin/lean/ceiling.mjs +47 -3
- package/bin/lean/ceiling.test.mjs +32 -1
- package/bin/lean/conformance.e2e.test.mjs +32 -6
- package/bin/lean/conformance.mjs +57 -13
- package/bin/lean/conformance.test.mjs +93 -1
- package/bin/lean/execution.mjs +24 -12
- package/bin/lean/execution.test.mjs +59 -9
- package/bin/lean/forgedock-lane-workflow.test.mjs +62 -2
- package/bin/lean/issuewatch-reconcile.mjs +2 -0
- package/bin/lean/issuewatch-reconcile.test.mjs +25 -0
- package/bin/lean/issuewatch.mjs +3 -0
- package/bin/lean/lanecheck.test.mjs +13 -1
- package/bin/lean/lean.mjs +214 -32
- package/bin/lean/lean.test.mjs +406 -21
- package/bin/lean/live-execution.mjs +25 -0
- package/bin/lean/live-execution.test.mjs +35 -1
- package/bin/lean/merged-park.mjs +76 -0
- package/bin/lean/merged-park.test.mjs +64 -0
- package/bin/lean/mergetrain.mjs +357 -0
- package/bin/lean/mergetrain.test.mjs +348 -0
- package/bin/lean/orchestrate-envhold.test.mjs +62 -0
- package/bin/lean/orchestrate-stacking.test.mjs +144 -0
- package/bin/lean/orchestrate-train.test.mjs +130 -0
- package/bin/lean/orchestrate-transient-git.test.mjs +53 -0
- package/bin/lean/orchestrate.mjs +234 -17
- package/bin/lean/prompts.mjs +4 -3
- package/bin/lean/release-review.mjs +8 -1
- package/bin/lean/release-review.test.mjs +42 -2
- package/bin/lean/release-status.test.mjs +53 -1
- package/bin/lean/release.mjs +6 -3
- package/bin/lean/render.mjs +6 -1
- package/bin/lean/run-issue-placement.test.mjs +27 -3
- package/bin/lean/sandbox-provider.contract.test.mjs +6 -0
- package/bin/lean/sandbox-remote.mjs +12 -2
- package/bin/lean/sched.mjs +19 -2
- package/bin/lean/sched.test.mjs +33 -1
- package/bin/lean/schedd-health.mjs +2 -1
- package/bin/lean/schedd-health.test.mjs +7 -0
- package/bin/lean/schedd.mjs +55 -7
- package/bin/lean/schedd.test.mjs +42 -1
- package/bin/lean/stacking.mjs +140 -0
- package/bin/lean/stacking.test.mjs +98 -0
- package/bin/lean/statuscomment.mjs +14 -8
- package/bin/lean/statuscomment.test.mjs +18 -1
- package/bin/lean/validate-catalog.mjs +1 -1
- package/bin/lean/validate-catalog.test.mjs +3 -0
- package/bin/lean/worktree.mjs +8 -3
- package/bin/lean/worktree.test.mjs +18 -0
- package/bin/pool/agent.mjs +325 -46
- package/bin/pool/cache-sweep.mjs +2 -0
- package/bin/pool/cli.mjs +120 -6
- package/bin/pool/disk.mjs +43 -0
- package/bin/pool/docker.mjs +21 -5
- package/bin/pool/health.mjs +95 -0
- package/bin/pool/router.mjs +274 -27
- package/bin/runner.mjs +3 -1
- package/bin/stats/chains.mjs +101 -0
- package/bin/stats/chains.test.mjs +53 -0
- package/bin/stats/efficiency.mjs +7 -6
- package/bin/stats/efficiency.test.mjs +48 -7
- package/bin/stats/index.mjs +11 -3
- package/bin/stats/stats.test.mjs +9 -0
- package/docs/CONFIG.md +23 -1
- package/docs/OUTCOME-CODES.md +4 -0
- package/package.json +1 -1
- package/pool/README.md +10 -0
- package/pool/image/Dockerfile +2 -1
- package/pool/image/entrypoint.sh +6 -6
- package/pool/image/mirror.sh +71 -0
- package/pool/install/install-agent-linux.sh +57 -5
- package/pool/install/install-agent-macos.sh +148 -0
- package/pool/install/install-agent.ps1 +11 -0
- package/pool/install/install-agent.sh +59 -7
- package/pool/install/uninstall-agent-linux.sh +75 -0
- package/pool/install/uninstall-agent-macos.sh +60 -0
- package/pool/install/uninstall-agent.ps1 +1 -0
- package/scripts/transition-label.sh +11 -0
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
// #5748: the lane workflow's security shape, checked as text (zero LLM).
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
6
|
+
import { readFileSync, writeFileSync, chmodSync, existsSync, mkdirSync } from "node:fs";
|
|
7
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { tmpDir } from "../tests/_tmp.mjs";
|
|
7
10
|
import { fileURLToPath } from "node:url";
|
|
8
11
|
|
|
9
12
|
const text = readFileSync(fileURLToPath(new URL("../../.github/workflows/forgedock-lane.yml", import.meta.url)), "utf8");
|
|
@@ -13,7 +16,7 @@ describe("forgedock-lane.yml (#5748)", () => {
|
|
|
13
16
|
it("triggers on workflow_dispatch only, never pull_request or pull_request_target", () => {
|
|
14
17
|
const on = /^on:\n((?:[ ]+.*\n|\n)+)/m.exec(code)[1];
|
|
15
18
|
assert.deepEqual([...on.matchAll(/^ ([a-z_]+):/gm)].map((m) => m[1]), ["workflow_dispatch"]);
|
|
16
|
-
assert.doesNotMatch(code,
|
|
19
|
+
assert.doesNotMatch(code, /^\s*pull_request(_target)?:/m); // no such trigger key; ruleset type names in the #5899 guard are not triggers
|
|
17
20
|
});
|
|
18
21
|
it("has least-privilege permissions, an environment holding the credential, and a job limit under 6 h", () => {
|
|
19
22
|
assert.match(code, /^permissions:\n contents: write\n issues: write\n pull-requests: write\n/m);
|
|
@@ -33,3 +36,60 @@ describe("forgedock-lane.yml (#5748)", () => {
|
|
|
33
36
|
assert.match(code, /run-name: forgedock-lane \$\{\{ inputs\.lane_id \}\}/);
|
|
34
37
|
});
|
|
35
38
|
});
|
|
39
|
+
|
|
40
|
+
/** The guard step's shell body (#5899), dedented from the workflow text. */
|
|
41
|
+
function guardScript() {
|
|
42
|
+
const lines = text.split("\n"), i = lines.findIndex((l) => l.includes("id: guard"));
|
|
43
|
+
const r = lines.findIndex((l, k) => k > i && /^\s+run: \|$/.test(l));
|
|
44
|
+
const body = [];
|
|
45
|
+
for (let k = r + 1; k < lines.length && (lines[k].startsWith(" ") || lines[k] === ""); k++) body.push(lines[k].slice(10));
|
|
46
|
+
return body.join("\n");
|
|
47
|
+
}
|
|
48
|
+
const hasJq = spawnSync("jq", ["--version"]).status === 0;
|
|
49
|
+
|
|
50
|
+
/** Runs the guard against a stub gh answering `repos/o/r/<path>` from `api` (a path missing from `api` fails like a 404). */
|
|
51
|
+
function runGuard(api, { def = "main", ref = "staging" } = {}) {
|
|
52
|
+
const dir = tmpDir("lane-guard-"), bin = join(dir, "bin");
|
|
53
|
+
mkdirSync(bin, { recursive: true });
|
|
54
|
+
writeFileSync(join(dir, "api.json"), JSON.stringify(api));
|
|
55
|
+
writeFileSync(join(bin, "gh"), `#!/usr/bin/env node
|
|
56
|
+
const [, , cmd, path, flag, expr] = process.argv;
|
|
57
|
+
const api = JSON.parse(require("fs").readFileSync(${JSON.stringify(join(dir, "api.json"))}, "utf8"));
|
|
58
|
+
const key = path.replace(/^repos\\/o\\/r\\//, "");
|
|
59
|
+
if (cmd !== "api" || !(key in api)) { process.stderr.write("HTTP 404"); process.exit(1); }
|
|
60
|
+
process.stdout.write(require("child_process").execFileSync("jq", ["-r", expr], { input: JSON.stringify(api[key]) }));
|
|
61
|
+
`);
|
|
62
|
+
chmodSync(join(bin, "gh"), 0o755);
|
|
63
|
+
const out = join(dir, "out"), res = join(dir, "result.json");
|
|
64
|
+
writeFileSync(out, "");
|
|
65
|
+
const r = spawnSync("bash", ["-e", "-c", guardScript()], { env: { ...process.env, PATH: `${bin}:${process.env.PATH}`, GH_REPO: "o/r", DEFAULT_BRANCH: def, LANE_REF: ref, RESULT_FILE: res, GITHUB_OUTPUT: out }, encoding: "utf8" });
|
|
66
|
+
return { status: r.status, ok: /ok=true/.test(readFileSync(out, "utf8")), result: existsSync(res) ? JSON.parse(readFileSync(res, "utf8")) : null };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
describe("forgedock-lane.yml protection guard (#5899)", () => {
|
|
70
|
+
it("every step that checks out, installs or runs the lane is gated on the guard", () => {
|
|
71
|
+
const steps = code.split(/\n - /).slice(1);
|
|
72
|
+
const gi = steps.findIndex((t) => t.includes("id: guard"));
|
|
73
|
+
assert.ok(gi > 0 && gi < steps.findIndex((t) => t.startsWith("uses: actions/checkout")));
|
|
74
|
+
for (const t of steps.slice(gi + 1)) {
|
|
75
|
+
if (t.startsWith("name: Post result")) { assert.match(t, /if: always\(\)/); continue; }
|
|
76
|
+
assert.match(t, /if: steps\.guard\.outputs\.ok == 'true'/, t.split("\n")[0]);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
it("passes when both branches have a blocking ruleset or classic required status checks", { skip: !hasJq && "jq not installed" }, () => {
|
|
80
|
+
assert.ok(runGuard({ "rules/branches/main": [{ type: "pull_request" }], "rules/branches/staging": [{ type: "required_status_checks" }] }).ok);
|
|
81
|
+
const g = runGuard({ "rules/branches/main": [], "branches/main": { protected: true, protection: { required_status_checks: { enforcement_level: "non_admins", contexts: ["ci"] } } }, "rules/branches/staging": [{ type: "update" }] });
|
|
82
|
+
assert.equal(g.ok, true); assert.equal(g.result, null);
|
|
83
|
+
});
|
|
84
|
+
it("refuses, with a needs-human result naming the branch, when a branch is unprotected or protection is unreadable", { skip: !hasJq && "jq not installed" }, () => {
|
|
85
|
+
const g = runGuard({ "rules/branches/main": [{ type: "pull_request" }], "rules/branches/staging": [{ type: "non_fast_forward" }], "branches/staging": { protected: false } });
|
|
86
|
+
assert.equal(g.status, 0); assert.equal(g.ok, false);
|
|
87
|
+
assert.equal(g.result.terminalReason, "needs-human"); assert.equal(g.result.code, "sandbox.start_failed");
|
|
88
|
+
assert.match(g.result.detail, / staging have no server-side push protection/); assert.doesNotMatch(g.result.detail, /main/);
|
|
89
|
+
// classic protection without a required status check does not block a fast-forward push
|
|
90
|
+
assert.equal(runGuard({ "rules/branches/main": [{ type: "pull_request" }], "rules/branches/staging": [], "branches/staging": { protected: true, protection: { required_status_checks: { enforcement_level: "non_admins", contexts: [] } } } }).ok, false);
|
|
91
|
+
// the API failing (no answer) fails closed
|
|
92
|
+
const f = runGuard({});
|
|
93
|
+
assert.equal(f.ok, false); assert.match(f.result.detail, / main staging have/);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* FORGE:DECISION or a newer comment) is released so the next pass re-claims it. `status --stuck` lists the old claims. Gh, the clock and the
|
|
9
9
|
* lane launch are injected; the state callbacks (`fail`, `settle`, `release`) belong to the caller.
|
|
10
10
|
*/
|
|
11
|
+
import { mergedEvidence } from "./merged-park.mjs";
|
|
11
12
|
import { classifyNeedsHuman, REMEDIATION_QUEUE_LABEL } from "../engine/outcome-codes.mjs";
|
|
12
13
|
|
|
13
14
|
const HOUR_MS = 3600_000;
|
|
@@ -121,6 +122,7 @@ export async function remediateStep({ watch, repo, io, state, handles, lanes = {
|
|
|
121
122
|
r.status = "failed";
|
|
122
123
|
const reason = `remediation lane for \`${r.code}\` exited ${res.code}`;
|
|
123
124
|
state.outcomes[n] = { kind: "needs-human", code: r.code, at: now, reason };
|
|
125
|
+
if (await mergedEvidence({ gh: io.gh, repo, issue: Number(n) })) { fail(Number(n)); continue; } // #5759: a merged fix is not parked after the fact
|
|
124
126
|
try {
|
|
125
127
|
await io.gh(["issue", "edit", String(n), "-R", repo, "--add-label", NEEDS_HUMAN_LABEL, "--remove-label", REMEDIATION_QUEUE_LABEL]);
|
|
126
128
|
await io.gh(["issue", "comment", String(n), "-R", repo, "--body", `## Needs human\nissue-watch ${watch.name} remediated this parked issue once (${reason}); a person has to take it from here.`]);
|
|
@@ -79,3 +79,28 @@ test("remediateStep: a remediation exit 0 posts one FORGE:TRACKED hand-off while
|
|
|
79
79
|
await run({ outcomes: { 7: { kind: "parked", code: "x" } } });
|
|
80
80
|
assert.equal(comments.length, 0);
|
|
81
81
|
});
|
|
82
|
+
|
|
83
|
+
test("remediateStep: a failed remediation on a merged issue adds no needs-human; one reopened after the merge does (#5759)", async () => {
|
|
84
|
+
const { remediateStep } = await import("./issuewatch-reconcile.mjs");
|
|
85
|
+
const run = async (events) => {
|
|
86
|
+
const edits = [];
|
|
87
|
+
const io = {
|
|
88
|
+
remediate: () => ({ poll: () => ({ code: 1 }) }),
|
|
89
|
+
gh: async (a) => {
|
|
90
|
+
if (a[0] === "issue" && a[1] === "view") return JSON.stringify({ state: "OPEN", labels: [{ name: "workflow:merged" }] });
|
|
91
|
+
if (a[0] === "api") return events;
|
|
92
|
+
if (a[1] === "edit") edits.push(a.join(" "));
|
|
93
|
+
return "";
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const state = { outcomes: { 7: { kind: "parked", code: "ci.red" } } }, failed = [], handles = new Map();
|
|
97
|
+
const step = () => remediateStep({ watch: { name: "w" }, repo: "o/r", io, state, handles, now: 1, settle: () => {}, fail: (n) => failed.push(n) });
|
|
98
|
+
await step(); await step();
|
|
99
|
+
return { edits, failed };
|
|
100
|
+
};
|
|
101
|
+
const merged = await run("labeled\t2026-11-17T00:00:00.000Z\tworkflow:merged");
|
|
102
|
+
assert.deepEqual(merged.edits, []);
|
|
103
|
+
assert.deepEqual(merged.failed, [7]);
|
|
104
|
+
const reopened = await run("labeled\t2026-11-17T00:00:00.000Z\tworkflow:merged\nreopened\t2026-11-18T00:00:00.000Z\t");
|
|
105
|
+
assert.ok(reopened.edits.some((e) => e.includes("--add-label needs-human")));
|
|
106
|
+
});
|
package/bin/lean/issuewatch.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { triageTick } from "./issuewatch-triage.mjs";
|
|
|
23
23
|
import { releaseRoot } from "./release.mjs";
|
|
24
24
|
import { loadPolicy } from "./decision-engine.mjs";
|
|
25
25
|
import { decisionContext, decisionsActive, decisionStep, decisionCounts, formatDecisionDryRun, claimsUsed } from "./issuewatch-decisions.mjs";
|
|
26
|
+
import { repairMergedParked } from "./merged-park.mjs";
|
|
26
27
|
import { reconcileClaims, remediateStep, reclaimStep, redriveStep, claimCounts, stuckClaims, formatStuck } from "./issuewatch-reconcile.mjs";
|
|
27
28
|
import { APP_SLUG } from "../init-repo.mjs";
|
|
28
29
|
import { noComments } from "./render.mjs";
|
|
@@ -366,6 +367,8 @@ export async function tick({ watch, repo, io, state, dir, branches = {}, default
|
|
|
366
367
|
else if (r.code === 75 && (state.retries[n] = (state.retries[n] ?? 0) + 1) <= RETRIES) handles.set(n, io.launch(n, state.lanes[n]));
|
|
367
368
|
else fail(n);
|
|
368
369
|
}
|
|
370
|
+
// #5759: an open issue with workflow:merged still carrying park labels is inconsistent; clear them
|
|
371
|
+
try { for (const r of await repairMergedParked({ gh: io.gh, repo })) (state.repaired ??= []).push({ issue: r.issue, labels: r.flagged, at: now }); } catch { /* best effort */ }
|
|
369
372
|
if (watch.mode === "batch") {
|
|
370
373
|
await remediateStep({ watch, repo, io, state, handles, now, settle, fail });
|
|
371
374
|
await reclaimStep({ repo, io, state, trusted: (c) => TRUSTED.has(c?.authorAssociation), release: (n) => { releaseClaims(repoDir(repo, io.env), [n], watch.name); state.claimed = state.claimed.filter((x) => x !== n); delete state.lanes[n]; unsettle(state, n); } });
|
|
@@ -10,7 +10,7 @@ import { checkPoolAuth, checkPoolVersion, checkPathLoop, checkGhFields, availabl
|
|
|
10
10
|
import { which } from "./toolchain.mjs";
|
|
11
11
|
import { findShimLoops, heavyShimScript } from "./heavy.mjs";
|
|
12
12
|
import { orchestrate, deferPolicy } from "./orchestrate.mjs";
|
|
13
|
-
import { providerLanes, isCloneFailure } from "./execution.mjs";
|
|
13
|
+
import { providerLanes, isCloneFailure, isEgressTimeout } from "./execution.mjs";
|
|
14
14
|
|
|
15
15
|
const pool = { mode: "remote", provider: "pool", tokenEnv: null, endpoint: null };
|
|
16
16
|
const until = async (f, ms = 3000) => { const t = Date.now(); while (!f()) { if (Date.now() - t > ms) throw new Error("timeout"); await new Promise((r) => setTimeout(r, 5)); } };
|
|
@@ -187,6 +187,18 @@ describe("sandbox.clone", () => {
|
|
|
187
187
|
assert.equal(o.terminalReason, "engine-error");
|
|
188
188
|
assert.equal(isCloneFailure("clone of repo ok"), false);
|
|
189
189
|
});
|
|
190
|
+
it("#5923: an ls-remote/fetch timeout ends deferred sandbox.egress_timeout with retry-in; other failures stay engine-error", async () => {
|
|
191
|
+
for (const t of ["fatal: unable to access 'https://github.com/o/r/': Failed to connect to github.com port 443: Connection timed out", "git ls-remote timed out after 60s", "git fetch hung: timeout"]) {
|
|
192
|
+
const r = await lanes(prov(), { logTail: () => t }).runOne(7, {}, {});
|
|
193
|
+
assert.equal(r.terminalReason, "deferred", t); assert.equal(r.code, "sandbox.egress_timeout", t); assert.ok(r.retryInSeconds > 0);
|
|
194
|
+
}
|
|
195
|
+
const e = await lanes(prov({ fetchResult: async () => ({ terminalReason: "engine-error", detail: "git fetch failed: Connection timed out" }) })).runOne(7, {}, {});
|
|
196
|
+
assert.equal(e.code, "sandbox.egress_timeout");
|
|
197
|
+
const o = await lanes(prov(), { logTail: () => "npm ERR! build failed" }).runOne(7, {}, {});
|
|
198
|
+
assert.equal(o.terminalReason, "engine-error");
|
|
199
|
+
assert.equal(isEgressTimeout("fetch of cache ok"), false);
|
|
200
|
+
assert.equal(isEgressTimeout("git clone timed out after 300s"), false);
|
|
201
|
+
});
|
|
190
202
|
it("is requeued with its retry-in and is not an engine-error (breaker input)", () => {
|
|
191
203
|
const p = deferPolicy({ terminalReason: "deferred", code: "sandbox.clone", retryInSeconds: 120 }, { now: 0 });
|
|
192
204
|
assert.equal(p.delayMs, 120000);
|