forgedock 1.66.0 → 1.68.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 +3 -0
- package/bin/engine/outcome-codes.mjs +2 -0
- package/bin/engine-cli.mjs +193 -27
- package/bin/engine.mjs +10 -0
- package/bin/forgedock.mjs +24 -1
- package/bin/help-text.mjs +4 -3
- package/bin/introspect-schedule.mjs +98 -0
- package/bin/introspect-schedule.test.mjs +67 -0
- package/bin/lean/admission.mjs +21 -0
- package/bin/lean/admission.test.mjs +30 -0
- package/bin/lean/advisory.test.mjs +64 -0
- package/bin/lean/amendment-schema.mjs +30 -0
- package/bin/lean/attempts.mjs +162 -0
- package/bin/lean/attempts.test.mjs +141 -0
- package/bin/lean/basered.mjs +81 -0
- package/bin/lean/basered.test.mjs +68 -1
- package/bin/lean/batch-health.mjs +20 -12
- package/bin/lean/batch-health.test.mjs +55 -11
- package/bin/lean/batch.mjs +45 -0
- package/bin/lean/batch.test.mjs +105 -5
- package/bin/lean/capwait.mjs +14 -3
- package/bin/lean/capwait.test.mjs +20 -0
- package/bin/lean/ci-gate.mjs +2 -90
- package/bin/lean/ci-gate.test.mjs +1 -127
- package/bin/lean/ci-precheck.mjs +25 -8
- package/bin/lean/ci-precheck.test.mjs +24 -0
- package/bin/lean/clear-breaker.mjs +14 -0
- package/bin/lean/clear-breaker.test.mjs +4 -3
- package/bin/lean/commentstate.mjs +46 -0
- package/bin/lean/commentstate.test.mjs +43 -0
- package/bin/lean/concurrency.mjs +89 -0
- package/bin/lean/concurrency.test.mjs +113 -0
- package/bin/lean/conformance.e2e.test.mjs +13 -8
- package/bin/lean/conformance.mjs +73 -181
- package/bin/lean/conformance.test.mjs +61 -345
- package/bin/lean/depcache.mjs +100 -10
- package/bin/lean/depcache.test.mjs +105 -0
- package/bin/lean/docsgate.mjs +0 -32
- package/bin/lean/docsgate.test.mjs +2 -23
- package/bin/lean/effects-cap.test.mjs +9 -1
- package/bin/lean/effects-killtree.test.mjs +35 -0
- package/bin/lean/effects.mjs +42 -24
- package/bin/lean/efficiency.mjs +162 -0
- package/bin/lean/efficiency.test.mjs +79 -0
- package/bin/lean/engine-readmit.test.mjs +35 -0
- package/bin/lean/envgap.mjs +93 -0
- package/bin/lean/envgap.test.mjs +53 -0
- package/bin/lean/execution.mjs +41 -17
- package/bin/lean/execution.test.mjs +58 -0
- package/bin/lean/failure-census.mjs +170 -0
- package/bin/lean/failure-census.test.mjs +59 -0
- package/bin/lean/failure-stop.mjs +46 -0
- package/bin/lean/failure-stop.test.mjs +45 -0
- package/bin/lean/fixtures/capacity-storm.json +609 -0
- package/bin/lean/guardgate.test.mjs +2 -3
- package/bin/lean/heavy.mjs +33 -4
- package/bin/lean/heavy.test.mjs +38 -6
- package/bin/lean/hotarea.mjs +0 -36
- package/bin/lean/hotarea.test.mjs +1 -22
- package/bin/lean/issuewatch-verify.mjs +19 -4
- package/bin/lean/issuewatch.mjs +21 -4
- package/bin/lean/issuewatch.test.mjs +48 -1
- package/bin/lean/lane-audit-gap.mjs +66 -0
- package/bin/lean/lane-audit-gap.test.mjs +59 -0
- package/bin/lean/lane-audit-llm.mjs +5 -0
- package/bin/lean/lane-audit-query.mjs +47 -0
- package/bin/lean/lane-audit-query.test.mjs +44 -0
- package/bin/lean/lane-audit-signatures.mjs +33 -0
- package/bin/lean/lane-audit.mjs +110 -0
- package/bin/lean/lane-audit.test.mjs +97 -0
- package/bin/lean/lane-recovery.test.mjs +33 -0
- package/bin/lean/lanecheck.mjs +5 -3
- package/bin/lean/lanecheck.test.mjs +6 -0
- package/bin/lean/lean.mjs +311 -154
- package/bin/lean/lean.test.mjs +530 -223
- package/bin/lean/limits.mjs +17 -0
- package/bin/lean/limits.test.mjs +15 -1
- package/bin/lean/live-execution.mjs +21 -2
- package/bin/lean/live-execution.test.mjs +39 -0
- package/bin/lean/liveness.mjs +37 -0
- package/bin/lean/liveness.test.mjs +33 -0
- package/bin/lean/orchestrate-attempts.test.mjs +82 -0
- package/bin/lean/orchestrate-envhold.test.mjs +47 -0
- package/bin/lean/orchestrate-heldroot.test.mjs +72 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +59 -1
- package/bin/lean/orchestrate-overload-recovery.test.mjs +37 -0
- package/bin/lean/orchestrate-pause.test.mjs +76 -1
- package/bin/lean/orchestrate-reconcile.test.mjs +164 -0
- package/bin/lean/orchestrate-relaunch-gates.test.mjs +57 -0
- package/bin/lean/orchestrate-stacking.test.mjs +10 -0
- package/bin/lean/orchestrate.mjs +344 -45
- package/bin/lean/phaseledger.mjs +6 -0
- package/bin/lean/phaseledger.test.mjs +13 -1
- package/bin/lean/postdeploy-check.test.mjs +1 -3
- package/bin/lean/precheck.mjs +20 -0
- package/bin/lean/preflight.mjs +100 -11
- package/bin/lean/preflight.test.mjs +44 -4
- package/bin/lean/prompts.mjs +13 -28
- package/bin/lean/reconcile.mjs +90 -0
- package/bin/lean/recurrence.mjs +6 -112
- package/bin/lean/recurrence.test.mjs +11 -92
- package/bin/lean/release-flakes.mjs +14 -2
- package/bin/lean/release-flakes.test.mjs +17 -1
- package/bin/lean/release-ledger.mjs +19 -1
- package/bin/lean/release-ledger.test.mjs +23 -0
- package/bin/lean/release-preflight.mjs +28 -0
- package/bin/lean/release-preflight.test.mjs +42 -1
- package/bin/lean/release-review.mjs +40 -5
- package/bin/lean/release-review.test.mjs +43 -2
- package/bin/lean/release.mjs +43 -14
- package/bin/lean/release.test.mjs +32 -0
- package/bin/lean/retry.mjs +1 -1
- package/bin/lean/retry.test.mjs +6 -1
- package/bin/lean/rotator.mjs +9 -0
- package/bin/lean/rotator.test.mjs +11 -1
- package/bin/lean/sandbox-remote.mjs +49 -11
- package/bin/lean/sched.mjs +19 -0
- package/bin/lean/sched.test.mjs +11 -1
- package/bin/lean/schedd-health.mjs +4 -4
- package/bin/lean/schedd-health.test.mjs +8 -4
- package/bin/lean/schedd.mjs +45 -8
- package/bin/lean/schedd.test.mjs +120 -7
- package/bin/lean/selfreview.mjs +1 -1
- package/bin/lean/slo.mjs +126 -0
- package/bin/lean/slo.test.mjs +112 -0
- package/bin/lean/statuscomment.mjs +40 -0
- package/bin/lean/statuscomment.test.mjs +48 -1
- package/bin/lean/validate-catalog.mjs +108 -0
- package/bin/lean/validate-catalog.test.mjs +46 -1
- package/bin/lean/verify.mjs +3 -2
- package/bin/pool/affinity.test.mjs +91 -0
- package/bin/pool/agent.mjs +144 -10
- package/bin/pool/cache-sweep.mjs +31 -10
- package/bin/pool/ci-autoscale.mjs +160 -0
- package/bin/pool/cli.mjs +53 -9
- package/bin/pool/docker.mjs +3 -0
- package/bin/pool/engine-placement.test.mjs +94 -0
- package/bin/pool/lane-target.mjs +41 -0
- package/bin/pool/lane-tools.mjs +26 -0
- package/bin/pool/lane-tools.test.mjs +9 -0
- package/bin/pool/mirror-seed.mjs +15 -11
- package/bin/pool/router.mjs +88 -32
- package/bin/pool/version.mjs +29 -2
- package/bin/review-staging.mjs +11 -3
- package/bin/runner.mjs +59 -11
- package/bin/stats/attempts.mjs +54 -0
- package/bin/stats/attempts.test.mjs +30 -0
- package/bin/stats/churn.mjs +49 -0
- package/bin/stats/churn.test.mjs +31 -0
- package/bin/stats/index.mjs +11 -3
- package/bin/stats/release.mjs +7 -0
- package/bin/stats/release.test.mjs +20 -0
- package/bin/stats/scorecard.mjs +187 -0
- package/bin/stats/scorecard.test.mjs +89 -0
- package/commands/orchestrate.md +21 -18
- package/docs/CONFIG.md +41 -0
- package/docs/OUTCOME-CODES.md +2 -0
- package/docs/STATS.md +17 -0
- package/package.json +1 -1
- package/pool/image/Dockerfile +14 -2
- package/pool/image/manifest.json +25 -0
- package/pool/image/mirror.sh +11 -2
- package/pool/install/install-agent.ps1 +11 -4
- package/scripts/check-devdocs-freshness.sh +1 -1
- package/scripts/ci-local/adapters/github-actions.mjs +8 -0
- package/scripts/ci-local/cli.mjs +1 -1
- package/scripts/ci-local/plan.mjs +3 -2
- package/scripts/ci-local.test.sh +11 -0
- package/scripts/failure-census.mjs +67 -0
- package/scripts/review-finalize.sh +5 -5
- package/scripts/review-finalize.test.sh +8 -1
- package/scripts/verify-phase-trail.sh +11 -0
- package/scripts/verify-phase-trail.test.sh +9 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// FORGE:LANE_AUDIT (#6076, child of #6072): at an unhappy lane terminal, bundle the evidence, classify it against the signature table
|
|
2
|
+
// (no LLM), and post one version-stamped, idempotent JSON comment. Never throws: an audit must not change how a lane ends.
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { SIGNATURES } from "./lane-audit-signatures.mjs";
|
|
7
|
+
import { auditGap } from "./lane-audit-gap.mjs";
|
|
8
|
+
import { classifyWithLlm } from "./lane-audit-llm.mjs";
|
|
9
|
+
|
|
10
|
+
export const LANE_AUDIT_MARKER = "FORGE:LANE_AUDIT";
|
|
11
|
+
const TAIL = 4000;
|
|
12
|
+
const ROW_RE = /<!--\s*(FORGE:(?:PARKED|NEEDS_HUMAN))\s*-->/;
|
|
13
|
+
const ACTIVE_CLASSES = ["pipeline", "env", "pool"]; // classes whose active findings go to the gap audit
|
|
14
|
+
|
|
15
|
+
const semver = (v) => { const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(String(v ?? "")); return m ? [+m[1], +m[2], +m[3]] : null; };
|
|
16
|
+
/** -1 | 0 | 1, or null when either side is not a version. */
|
|
17
|
+
export function compareAuditVersions(a, b) {
|
|
18
|
+
const x = semver(a), y = semver(b);
|
|
19
|
+
if (!x || !y) return null;
|
|
20
|
+
for (let i = 0; i < 3; i++) if (x[i] !== y[i]) return x[i] < y[i] ? -1 : 1;
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Hash of the repo's forge.yaml (null when absent). */
|
|
25
|
+
export function forgeYamlHash(dir) {
|
|
26
|
+
try { return createHash("sha256").update(readFileSync(join(dir, "forge.yaml"))).digest("hex").slice(0, 12); } catch { return null; }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The version stamp: engine version + build sha, agent version, image tag, forge.yaml hash, batch id, attempt. */
|
|
30
|
+
export function buildStamp({ engineVersion = null, buildSha = null, agentVersion = null, imageTag = null, forgeYamlHash: fy = null, batchId = null, attempt = null, env = process.env } = {}) {
|
|
31
|
+
return {
|
|
32
|
+
engine_version: engineVersion ?? null,
|
|
33
|
+
build_sha: buildSha ?? env.FORGE_BUILD_SHA ?? null,
|
|
34
|
+
agent_version: agentVersion ?? env.FORGE_AGENT_VERSION ?? null,
|
|
35
|
+
image_tag: imageTag ?? env.FORGE_IMAGE_TAG ?? null,
|
|
36
|
+
forge_yaml_hash: fy ?? null,
|
|
37
|
+
batch_id: batchId ?? null,
|
|
38
|
+
attempt: attempt ?? null,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const tail = (s, n = TAIL) => String(s ?? "").slice(-n);
|
|
43
|
+
|
|
44
|
+
/** The evidence bundle: park rows, stderr, run-log tail, phase timings, prior attempts, contract vs trusted decisions. */
|
|
45
|
+
export function buildEvidence({ issue, reason, code = null, detail = "", comments = [], stderr = "", runLogTail = "", phases = null, contractDecisions = [], trustedDecisions = [], stamp = {} } = {}) {
|
|
46
|
+
const bodies = (comments ?? []).map((c) => (typeof c === "string" ? c : String(c?.body ?? "")));
|
|
47
|
+
const parkRows = bodies.filter((b) => ROW_RE.test(b)).map((b) => ({ marker: ROW_RE.exec(b)[1], text: tail(b, 600) }));
|
|
48
|
+
const priorAttempts = bodies.map(parseAudit).filter((a) => a && a.issue === issue).length;
|
|
49
|
+
const ev = { issue, reason, code, detail: String(detail ?? ""), parkRows, stderr: tail(stderr), runLogTail: tail(runLogTail), phases, priorAttempts, contractDecisions, trustedDecisions, stamp };
|
|
50
|
+
ev.text = [ev.detail, ...parkRows.map((r) => r.text), ev.stderr, ev.runLogTail].filter(Boolean).join("\n");
|
|
51
|
+
return ev;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Classify against the table. A match whose fixed_in is later than the engine that ran is `fixed_in_later` (not active).
|
|
56
|
+
* @returns {{signature, class, owner, action, active, fixed_in_later}|null}
|
|
57
|
+
*/
|
|
58
|
+
export function classifyAudit(evidence, table = SIGNATURES) {
|
|
59
|
+
for (const s of table) {
|
|
60
|
+
let hit = false;
|
|
61
|
+
try { hit = Boolean(s.match(evidence)); } catch { hit = false; }
|
|
62
|
+
if (!hit) continue;
|
|
63
|
+
const later = s.fixed_in != null && compareAuditVersions(evidence.stamp?.engine_version, s.fixed_in) === -1;
|
|
64
|
+
return { signature: s.id, class: s.class, owner: s.owner, action: s.action, introduced_in: s.introduced_in ?? null, fixed_in: s.fixed_in ?? null, fixed_in_later: later, active: !later };
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const auditKey = (issue, attempt, signature) => `${issue}:${attempt ?? 0}:${signature}`;
|
|
70
|
+
|
|
71
|
+
export function renderAudit(audit) {
|
|
72
|
+
const j = JSON.stringify(audit, null, 2);
|
|
73
|
+
const head = `## Lane audit\n**Class**: ${audit.class}${audit.fixed_in_later ? " (fixed in a later engine)" : ""}\n**Signature**: ${audit.signature}\n**Owner**: ${audit.owner ?? "-"}\n**Action**: ${audit.action ?? "-"}\n**Status**: ${audit.status}`;
|
|
74
|
+
return `${head}\n\n\`\`\`json\n${j}\n\`\`\`\n<!-- LANE_AUDIT_KEY ${audit.key} -->`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The audit object of a FORGE:LANE_AUDIT comment body, or null. */
|
|
78
|
+
export function parseAudit(body) {
|
|
79
|
+
const s = String(body ?? "");
|
|
80
|
+
if (!s.includes(`<!-- ${LANE_AUDIT_MARKER}`)) return null;
|
|
81
|
+
const m = /```json\n([\s\S]*?)\n```/.exec(s);
|
|
82
|
+
if (!m) return null;
|
|
83
|
+
try { const a = JSON.parse(m[1]); return a && typeof a === "object" ? a : null; } catch { return null; }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Audit one unhappy terminal. Posts at most one comment per (issue, attempt, signature). Never throws.
|
|
88
|
+
* @param {object} o {issue, reason, code, detail, comments, post(marker, body), trusted(comment), stamp, ...evidence fields, table, gap, llm}
|
|
89
|
+
* @returns {Promise<{posted:boolean, audit?:object, skipped?:string}>}
|
|
90
|
+
*/
|
|
91
|
+
export async function runLaneAudit(o = {}) {
|
|
92
|
+
try {
|
|
93
|
+
const { post, trusted = () => true, table = SIGNATURES, gap = auditGap, llm = classifyWithLlm } = o;
|
|
94
|
+
if (typeof post !== "function") return { posted: false, skipped: "no-post" };
|
|
95
|
+
const ev = buildEvidence(o);
|
|
96
|
+
let c = classifyAudit(ev, table);
|
|
97
|
+
let gapFinding = null, llmFinding = null;
|
|
98
|
+
if (c && c.active && ACTIVE_CLASSES.includes(c.class)) gapFinding = await gap(ev, c);
|
|
99
|
+
if (!c) { llmFinding = await llm(ev); c = llmFinding && typeof llmFinding === "object" ? { signature: llmFinding.signature ?? "llm", class: llmFinding.class ?? "unclassified", owner: llmFinding.owner ?? null, action: llmFinding.action ?? null, introduced_in: null, fixed_in: null, fixed_in_later: false, active: true } : null; }
|
|
100
|
+
if (!c) c = { signature: "unclassified", class: "unclassified", owner: null, action: null, introduced_in: null, fixed_in: null, fixed_in_later: false, active: true };
|
|
101
|
+
const key = auditKey(ev.issue, ev.stamp?.attempt, c.signature);
|
|
102
|
+
const seen = (o.comments ?? []).some((cm) => (typeof cm === "string" || trusted(cm)) && parseAudit(typeof cm === "string" ? cm : cm?.body)?.key === key);
|
|
103
|
+
if (seen) return { posted: false, skipped: "already-audited" };
|
|
104
|
+
const audit = { key, issue: ev.issue, terminal: { reason: ev.reason, code: ev.code }, ...c, status: "proposed", stamp: ev.stamp, prior_attempts: ev.priorAttempts, ...(gapFinding ? { gap: gapFinding } : {}) };
|
|
105
|
+
await post(LANE_AUDIT_MARKER, renderAudit(audit));
|
|
106
|
+
return { posted: true, audit };
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return { posted: false, skipped: `error: ${String(e?.message ?? e).slice(0, 120)}` };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { runLaneAudit, buildEvidence, buildStamp, classifyAudit, parseAudit, compareAuditVersions, LANE_AUDIT_MARKER } from "./lane-audit.mjs";
|
|
4
|
+
import { SIGNATURES } from "./lane-audit-signatures.mjs";
|
|
5
|
+
import { auditGap } from "./lane-audit-gap.mjs";
|
|
6
|
+
import { classifyWithLlm } from "./lane-audit-llm.mjs";
|
|
7
|
+
|
|
8
|
+
const FIXTURES = { // recorded evidence text per seeded signature
|
|
9
|
+
"gh-network-text": "gh: error connecting to api.github.com",
|
|
10
|
+
"unguarded-status-post": "TypeError: status post failed: boom",
|
|
11
|
+
"no-status-rows": "parked after repeats: no status rows were written",
|
|
12
|
+
"contract-deferred-judged-omission": "reviewer: omission of the CLI flag, which the contract deferred per frozen decision K2",
|
|
13
|
+
"decision-not-reaching-reviewer": "the free-text decision did not reach the reviewer",
|
|
14
|
+
"amendment-syntax": "unknown amendment kind \"type\"",
|
|
15
|
+
"remote-sandbox-tool-gap": "bash: jq: command not found in the remote sandbox",
|
|
16
|
+
"mirror-seed-conflict": "mirror seed failed with HTTP 422",
|
|
17
|
+
"genuine-credentials": "block: need creds for the payment API",
|
|
18
|
+
"genuine-spend": "requires approval of the spend",
|
|
19
|
+
"genuine-product-decision": "this is a product decision for the owner",
|
|
20
|
+
"genuine-customer": "waiting for the customer to confirm",
|
|
21
|
+
"genuine-prod-access": "requires access to prod",
|
|
22
|
+
"spec-two-features": "the issue asks for two separate features",
|
|
23
|
+
};
|
|
24
|
+
const NEGATIVES = ["tests failed: 3 assertions", "merge conflict in lean.mjs", "gh: HTTP 404 not found", "the command ran fine"];
|
|
25
|
+
const ev = (text, stamp = { engine_version: "1.2.0", attempt: 1 }) => buildEvidence({ issue: 7, reason: "needs-human", detail: text, stamp });
|
|
26
|
+
const world = (comments = []) => { const posts = []; return { posts, o: { issue: 7, reason: "needs-human", code: "x", comments, post: async (m, b) => { posts.push([m, b]); comments.push(`<!-- ${m} -->\n${b}`); }, stamp: buildStamp({ engineVersion: "1.2.0", attempt: 1, batchId: "b1", imageTag: "img", buildSha: "abc", agentVersion: "a1", forgeYamlHash: "ff" }) } }; };
|
|
27
|
+
|
|
28
|
+
describe("lane audit signatures", () => {
|
|
29
|
+
for (const s of SIGNATURES) {
|
|
30
|
+
it(`classifies ${s.id} from recorded evidence without an LLM`, () => {
|
|
31
|
+
assert.ok(FIXTURES[s.id], "fixture exists");
|
|
32
|
+
const c = classifyAudit(ev(FIXTURES[s.id]));
|
|
33
|
+
assert.equal(c.signature, s.id);
|
|
34
|
+
assert.equal(c.class, s.class);
|
|
35
|
+
assert.equal(c.active, true);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
it("covers every seeded class and does not match unrelated text", () => {
|
|
39
|
+
assert.deepEqual([...new Set(SIGNATURES.map((s) => s.class))].sort(), ["env", "genuine", "pipeline", "pool", "spec"]);
|
|
40
|
+
for (const n of NEGATIVES) assert.equal(classifyAudit(ev(n)), null, n);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("lane audit run", () => {
|
|
45
|
+
it("posts one stamped JSON audit and a rerun posts nothing", async () => {
|
|
46
|
+
const w = world();
|
|
47
|
+
const r = await runLaneAudit({ ...w.o, detail: FIXTURES["gh-network-text"] });
|
|
48
|
+
assert.equal(r.posted, true);
|
|
49
|
+
assert.equal(w.posts.length, 1);
|
|
50
|
+
assert.equal(w.posts[0][0], LANE_AUDIT_MARKER);
|
|
51
|
+
const a = parseAudit(`<!-- ${LANE_AUDIT_MARKER} -->\n${w.posts[0][1]}`);
|
|
52
|
+
assert.equal(a.status, "proposed");
|
|
53
|
+
assert.equal(a.signature, "gh-network-text");
|
|
54
|
+
assert.deepEqual(Object.keys(a.stamp).sort(), ["agent_version", "attempt", "batch_id", "build_sha", "engine_version", "forge_yaml_hash", "image_tag"]);
|
|
55
|
+
assert.equal(a.stamp.batch_id, "b1");
|
|
56
|
+
const again = await runLaneAudit({ ...w.o, detail: FIXTURES["gh-network-text"] });
|
|
57
|
+
assert.equal(again.posted, false);
|
|
58
|
+
assert.equal(w.posts.length, 1);
|
|
59
|
+
});
|
|
60
|
+
it("an old engine is fixed_in_later: not active, gap seam not called", async () => {
|
|
61
|
+
const table = [{ ...SIGNATURES[0], fixed_in: "2.0.0" }];
|
|
62
|
+
const w = world();
|
|
63
|
+
let gapCalls = 0;
|
|
64
|
+
const r = await runLaneAudit({ ...w.o, detail: FIXTURES["gh-network-text"], table, gap: async () => { gapCalls++; return null; } });
|
|
65
|
+
assert.equal(r.audit.fixed_in_later, true);
|
|
66
|
+
assert.equal(r.audit.active, false);
|
|
67
|
+
assert.equal(gapCalls, 0);
|
|
68
|
+
const w2 = world();
|
|
69
|
+
const r2 = await runLaneAudit({ ...w2.o, detail: FIXTURES["gh-network-text"], table: [{ ...table[0], fixed_in: "1.0.0" }], gap: async () => { gapCalls++; return { x: 1 }; } });
|
|
70
|
+
assert.equal(r2.audit.active, true);
|
|
71
|
+
assert.equal(gapCalls, 1, "an active pipeline failure reaches the gap seam");
|
|
72
|
+
assert.deepEqual(r2.audit.gap, { x: 1 });
|
|
73
|
+
});
|
|
74
|
+
it("genuine class does not call the gap seam; unclassified evidence still gets an audit", async () => {
|
|
75
|
+
let gapCalls = 0;
|
|
76
|
+
const w = world();
|
|
77
|
+
await runLaneAudit({ ...w.o, detail: FIXTURES["genuine-spend"], gap: async () => { gapCalls++; } });
|
|
78
|
+
assert.equal(gapCalls, 0);
|
|
79
|
+
const u = world();
|
|
80
|
+
const r = await runLaneAudit({ ...u.o, detail: "something new" });
|
|
81
|
+
assert.equal(r.audit.signature, "unclassified");
|
|
82
|
+
});
|
|
83
|
+
it("the stubs are no-ops", async () => {
|
|
84
|
+
assert.equal(await auditGap({}), null);
|
|
85
|
+
assert.equal(await classifyWithLlm({}), null);
|
|
86
|
+
});
|
|
87
|
+
it("never throws, whatever fails", async () => {
|
|
88
|
+
const r = await runLaneAudit({ issue: 1, reason: "needs-human", post: async () => { throw new Error("gh down"); } });
|
|
89
|
+
assert.equal(r.posted, false);
|
|
90
|
+
assert.match(r.skipped, /gh down/);
|
|
91
|
+
assert.equal((await runLaneAudit()).posted, false);
|
|
92
|
+
});
|
|
93
|
+
it("compares versions", () => {
|
|
94
|
+
assert.equal(compareAuditVersions("1.2.0", "2.0.0"), -1);
|
|
95
|
+
assert.equal(compareAuditVersions("1.2.0", null), null);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { conformanceResumePrompt } from "./prompts.mjs";
|
|
6
|
+
import { checkFailureTail, redactSecrets } from "./precheck.mjs";
|
|
7
|
+
|
|
8
|
+
describe("#6058 conformanceResumePrompt names skipped requirements", () => {
|
|
9
|
+
it("lists each no-status id with its quote and asks for the work and a row; other failures follow", () => {
|
|
10
|
+
const p = conformanceResumePrompt([
|
|
11
|
+
{ code: "conformance.unimplemented", kind: "requirement_no_status", reqId: "R4", quote: "the cap is 40 lines", detail: 'R4 reported "no status"' },
|
|
12
|
+
{ code: "conformance.unimplemented", kind: "requirement_no_status", reqId: "R5", quote: "secrets are redacted", detail: 'R5 reported "no status"' },
|
|
13
|
+
{ code: "conformance.unimplemented", kind: "validate_failed", detail: "validate V1 failed (exit 1)" },
|
|
14
|
+
], "local");
|
|
15
|
+
assert.match(p, /no status row for R4, R5/); assert.match(p, /- R4: "the cap is 40 lines"/); assert.match(p, /- R5: "secrets are redacted"/);
|
|
16
|
+
assert.match(p, /Also:\n- conformance\.unimplemented: validate V1 failed/);
|
|
17
|
+
assert.doesNotMatch(p, /R4 reported/);
|
|
18
|
+
});
|
|
19
|
+
it("without a no-status failure the prompt is the generic one", () => {
|
|
20
|
+
assert.match(conformanceResumePrompt([{ code: "conformance.unimplemented", kind: "requirement_unimplemented", detail: 'R1 reported "partial"' }]), /^The change does not conform/);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("#6107 checkFailureTail", () => {
|
|
25
|
+
it("names the check, keeps the last 40 lines and redacts secrets", () => {
|
|
26
|
+
const out = Array.from({ length: 80 }, (_, i) => `line ${i}`).join("\n") + "\nDB_PASSWORD=swordfish99\npostgres://u:pw12345@host/db";
|
|
27
|
+
const t = checkFailureTail({ command: "npm test", rc: 2, output: out }, { name: "unit job" });
|
|
28
|
+
assert.match(t, /Failing check unit job \(`npm test`\), exit 2, last 40 lines/);
|
|
29
|
+
assert.match(t, /line 79/); assert.doesNotMatch(t, /line 10\b/);
|
|
30
|
+
assert.doesNotMatch(t, /swordfish99|pw12345/);
|
|
31
|
+
assert.equal(redactSecrets("token ghp_abcdefghijklmnopqrstuv"), "token [redacted]");
|
|
32
|
+
});
|
|
33
|
+
});
|
package/bin/lean/lanecheck.mjs
CHANGED
|
@@ -13,7 +13,9 @@ import { which } from "./toolchain.mjs";
|
|
|
13
13
|
|
|
14
14
|
/** The running CLI's package version. */
|
|
15
15
|
export const cliVersion = () => JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8")).version;
|
|
16
|
-
export const UPGRADE_COMMAND = "npx forgedock pool upgrade";
|
|
16
|
+
export const UPGRADE_COMMAND = "npx forgedock pool upgrade --wait";
|
|
17
|
+
/** The pool host is shared with other projects: an upgrade restarts it, so the hint waits for idle (#5726). */
|
|
18
|
+
const SHARED_HOST_NOTE = "the pool host is shared, so upgrade only when idle";
|
|
17
19
|
/** The `gh <cmd> --json` fields the engine reads (keep next to the call sites' lists in engine-cli.mjs and lean/*.mjs). */
|
|
18
20
|
export const GH_FIELDS = Object.freeze({
|
|
19
21
|
"issue view": ["number", "title", "body", "state", "stateReason", "labels", "comments", "milestone", "author", "createdAt", "updatedAt"],
|
|
@@ -90,8 +92,8 @@ export function checkPoolVersion({ exec, agents = null, cliVersion }) {
|
|
|
90
92
|
const skewed = agents.filter((a) => a?.ok !== false && typeof a?.version === "string" && a.version !== cliVersion);
|
|
91
93
|
if (!skewed.length) return pass(code, `${agents.length} agent(s) at ${cliVersion}`, "remote");
|
|
92
94
|
const bad = skewed.filter((a) => !sameMajor(a.version, cliVersion));
|
|
93
|
-
if (!bad.length) return pass(code, skewed.map((a) => `agent ${a.name ?? "?"} runs ${a.version}, CLI is ${cliVersion} (compatible, same major)`).join("; ") + `; upgrade: ${UPGRADE_COMMAND}`, "remote");
|
|
94
|
-
return fail(code, bad.map((a) => `agent ${a.name ?? "?"} runs image version ${a.version}, CLI is ${cliVersion}`).join("; ") + `; upgrade: ${UPGRADE_COMMAND}`, "remote");
|
|
95
|
+
if (!bad.length) return pass(code, skewed.map((a) => `agent ${a.name ?? "?"} runs ${a.version}, CLI is ${cliVersion} (compatible, same major)`).join("; ") + `; upgrade: ${UPGRADE_COMMAND} (${SHARED_HOST_NOTE})`, "remote");
|
|
96
|
+
return fail(code, bad.map((a) => `agent ${a.name ?? "?"} runs image version ${a.version}, CLI is ${cliVersion}`).join("; ") + `; upgrade: ${UPGRADE_COMMAND} (${SHARED_HOST_NOTE})`, "remote");
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
/** No PATH wrapper dir resolves a heavy-shimmed tool back to the shim. */
|
|
@@ -56,6 +56,12 @@ describe("pool_auth shared resolver (#5131)", () => {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
describe("pool_version", () => {
|
|
59
|
+
it("pool_version detail recommends pool upgrade --wait on a shared host", () => {
|
|
60
|
+
for (const [a, cli] of [["0.37.0", "1.39.0"], ["1.60.1", "1.61.1"]]) {
|
|
61
|
+
const c = checkPoolVersion({ exec: pool, cliVersion: cli, agents: [{ name: "a1", ok: true, version: a }] });
|
|
62
|
+
assert.match(c.detail, /pool upgrade --wait/); assert.match(c.detail, /shared/);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
59
65
|
const ver = (agentVersion, cli = "1.39.0") => checkPoolVersion({ exec: pool, cliVersion: cli, agents: [{ name: "a1", ok: true, version: agentVersion }, { name: "a2", ok: true, version: cli }] });
|
|
60
66
|
it("a different major fails, naming the agent, image version, CLI version and upgrade command", () => {
|
|
61
67
|
const c = ver("0.37.0", "1.39.0");
|