forgedock 1.63.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 +3 -0
- package/bin/engine/outcome-codes.mjs +5 -0
- package/bin/engine-cli.mjs +88 -12
- 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 +6 -1
- package/bin/lean/batch.test.mjs +71 -6
- 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 +15 -6
- package/bin/lean/execution.test.mjs +44 -3
- 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 +157 -28
- package/bin/lean/lean.test.mjs +289 -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 +23 -1
- package/bin/lean/orchestrate-train.test.mjs +130 -0
- package/bin/lean/orchestrate-transient-git.test.mjs +53 -0
- package/bin/lean/orchestrate.mjs +159 -13
- 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/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 +45 -0
- package/bin/lean/stacking.test.mjs +25 -1
- 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 +296 -31
- package/bin/pool/cli.mjs +120 -6
- package/bin/pool/disk.mjs +43 -0
- package/bin/pool/docker.mjs +10 -0
- 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 +8 -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
package/bin/stats/efficiency.mjs
CHANGED
|
@@ -183,7 +183,7 @@ export function efficiencyMetrics({ entries = [], logs = new Map(), issues = nul
|
|
|
183
183
|
const info = issues?.get(row.issue) ?? null;
|
|
184
184
|
const term = [...slices].reverse().find((s) => s.terminal?.reason === "merged")?.terminal;
|
|
185
185
|
merged.push({ issue: row.issue, slices: slices.length, cost: sum(atts.map((a) => a.cost)), implCost: sum(impl.map((a) => a.cost)),
|
|
186
|
-
reviewCost: sum(atts.filter((a) => a.phase === "review").map((a) => a.cost)), implTurns: sum(impl.map((a) => a.turns)), implCache: sum(impl.map((a) => a.cacheRead)),
|
|
186
|
+
reviewCost: sum(atts.filter((a) => a.phase === "review").map((a) => a.cost)), implTurns: sum(impl.map((a) => a.turns)), ctxRestarts: impl.filter((a) => a.trigger === "context_restart").length, implCache: sum(impl.map((a) => a.cacheRead)),
|
|
187
187
|
size: term?.size ?? laneSize({ labels: info?.labels ?? [] }) ?? "unknown", impl, retries, info, tools: laneTools(impl), shape: slices.at(-1)?.shape ?? null, implWall: laneWall(impl), phases: term?.phases ?? null });
|
|
188
188
|
}
|
|
189
189
|
const all = group(merged);
|
|
@@ -226,7 +226,7 @@ export function efficiencyMetrics({ entries = [], logs = new Map(), issues = nul
|
|
|
226
226
|
}
|
|
227
227
|
return {
|
|
228
228
|
merged: merged.length, cost_usd: all.cost_usd, implement_usd: r(sum(merged.map((m) => m.implCost)), 1e6), review_usd: r(sum(merged.map((m) => m.reviewCost)), 1e6),
|
|
229
|
-
usd_per_merge: all.usd_per_merge, turns_per_merge: all.turns_per_merge, context_per_turn: all.context_per_turn,
|
|
229
|
+
usd_per_merge: all.usd_per_merge, turns_per_merge: all.turns_per_merge, context_restarts_per_merge: r(per(sum(merged.map((m) => m.ctxRestarts)), merged.length), 100), context_per_turn: all.context_per_turn,
|
|
230
230
|
implement_turns: sum(merged.map((m) => m.implTurns)), implement_cache_read: sum(merged.map((m) => m.implCache)),
|
|
231
231
|
implement_wall_p50_min: all.implement_wall_p50_min, merge_rate: r(per(merged.length, rows.length)),
|
|
232
232
|
conformance_pass_rate: r(per(verdicts.filter((v) => v === "conforms").length, verdicts.length)),
|
|
@@ -238,7 +238,7 @@ export function efficiencyMetrics({ entries = [], logs = new Map(), issues = nul
|
|
|
238
238
|
by_kind: Object.fromEntries(Object.entries(noAction).map(([k, g]) => [k, { ...g, cost_usd: r(g.cost_usd, 1e6) }])) },
|
|
239
239
|
quality, acceptance, lanes, baseline_by_profile: baselineByProfile, wait: summarizeWaits(merged.map((m) => m.phases)), // #5349: non-model time by phase and cause
|
|
240
240
|
tool_calls_per_turn_p50: median(withTools.map((m) => m.tools.per_turn)), tool_calls_per_turn_n: withTools.length, rereads_per_merge: withTools.length ? r(per(sum(withTools.map((m) => m.tools.rereads)), withTools.length), 100) : null,
|
|
241
|
-
per_issue: merged.map((m) => ({ issue: m.issue, slices: m.slices, cost_usd: r(m.cost, 1e6), implement_usd: r(m.implCost, 1e6), implement_turns: m.implTurns,
|
|
241
|
+
per_issue: merged.map((m) => ({ issue: m.issue, slices: m.slices, cost_usd: r(m.cost, 1e6), implement_usd: r(m.implCost, 1e6), implement_turns: m.implTurns, context_restarts: m.ctxRestarts,
|
|
242
242
|
implement_cache_read: m.implCache, size: m.size, retries: m.retries, ...(m.shape ? { shape: m.shape } : {}), ...(m.info ? { quality: issueQuality(m.info.body).tag } : {}),
|
|
243
243
|
...(m.tools ? { implement_tool_calls_per_turn: m.tools.per_turn, implement_rereads: m.tools.rereads } : {}),
|
|
244
244
|
...(m.implWall != null ? { implement_wall_min: m.implWall } : {}) })),
|
|
@@ -327,7 +327,7 @@ export async function windowEfficiency({ batchRoot, runsDir, repo = null, gh = n
|
|
|
327
327
|
return out;
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
export const COMPARE_KEYS = Object.freeze(["turns_per_merge", "implement_wall_p50_min", "tool_calls_per_turn_p50", "rereads_per_merge", "merge_rate", "conformance_pass_rate"]);
|
|
330
|
+
export const COMPARE_KEYS = Object.freeze(["turns_per_merge", "context_restarts_per_merge", "usd_per_merge", "implement_wall_p50_min", "tool_calls_per_turn_p50", "rereads_per_merge", "merge_rate", "conformance_pass_rate"]);
|
|
331
331
|
const delta = (a, b) => Object.fromEntries(COMPARE_KEYS.map((k) => [k, num(a?.[k]) == null || num(b?.[k]) == null ? null : r(b[k] - a[k], 100)]));
|
|
332
332
|
|
|
333
333
|
/**
|
|
@@ -341,6 +341,7 @@ function matchedCohorts(pre, post) {
|
|
|
341
341
|
const g = (xs) => {
|
|
342
342
|
const tools = xs.filter((x) => x.implement_tool_calls_per_turn != null);
|
|
343
343
|
return { n: xs.length, turns_per_merge: r(per(sum(xs.map((x) => x.implement_turns)), xs.length), 10),
|
|
344
|
+
context_restarts_per_merge: r(per(sum(xs.map((x) => x.context_restarts ?? 0)), xs.length), 100), usd_per_merge: r(per(sum(xs.map((x) => x.cost_usd ?? 0)), xs.length)),
|
|
344
345
|
implement_wall_p50_min: median(xs.map((x) => x.implement_wall_min).filter((w) => w != null)),
|
|
345
346
|
tool_calls_per_turn_p50: median(tools.map((x) => x.implement_tool_calls_per_turn)),
|
|
346
347
|
rereads_per_merge: tools.length ? r(per(sum(tools.map((x) => x.implement_rereads)), tools.length), 100) : null };
|
|
@@ -428,9 +429,9 @@ function waitLines(w) {
|
|
|
428
429
|
const pct = (x) => (num(x) == null ? "n/a" : `${Math.round(x * 100)}%`);
|
|
429
430
|
const rates = (m) => `implement wall p50 ${m.implement_wall_p50_min == null ? "n/a" : `${f(m.implement_wall_p50_min, 1)} min`}, merge rate ${pct(m.merge_rate)}, conformance pass ${pct(m.conformance_pass_rate)}`;
|
|
430
431
|
const sign = (x, d, unit = "") => (num(x) == null ? "n/a" : `${x > 0 ? "+" : ""}${x.toFixed(d)}${unit}`);
|
|
431
|
-
const deltaLine = (d, withRates = true) => `turns/merge ${sign(d.turns_per_merge, 1)}, implement wall p50 ${sign(d.implement_wall_p50_min, 1, " min")}, calls/turn p50 ${sign(d.tool_calls_per_turn_p50, 2)}, `
|
|
432
|
+
const deltaLine = (d, withRates = true) => `turns/merge ${sign(d.turns_per_merge, 1)}, restarts/merge ${sign(d.context_restarts_per_merge, 2)}, $/merge ${sign(d.usd_per_merge, 2)}, implement wall p50 ${sign(d.implement_wall_p50_min, 1, " min")}, calls/turn p50 ${sign(d.tool_calls_per_turn_p50, 2)}, `
|
|
432
433
|
+ `re-reads/merge ${sign(d.rereads_per_merge, 2)}${withRates ? `, merge rate ${sign(d.merge_rate == null ? null : d.merge_rate * 100, 0, " pts")}, conformance pass ${sign(d.conformance_pass_rate == null ? null : d.conformance_pass_rate * 100, 0, " pts")}` : ""}`;
|
|
433
|
-
const cohortLine = (k, m) => `compare ${k}: n=${m.n ?? m.merged} turns/merge ${f(m.turns_per_merge, 1)}, implement wall p50 ${m.implement_wall_p50_min == null ? "n/a" : `${f(m.implement_wall_p50_min, 1)} min`}, `
|
|
434
|
+
const cohortLine = (k, m) => `compare ${k}: n=${m.n ?? m.merged} turns/merge ${f(m.turns_per_merge, 1)}, restarts/merge ${f(m.context_restarts_per_merge, 2)}, $/merge ${usd(m.usd_per_merge)}, implement wall p50 ${m.implement_wall_p50_min == null ? "n/a" : `${f(m.implement_wall_p50_min, 1)} min`}, `
|
|
434
435
|
+ `calls/turn p50 ${f(m.tool_calls_per_turn_p50)}, re-reads/merge ${f(m.rereads_per_merge)}${"merge_rate" in m ? `, merge rate ${pct(m.merge_rate)}, conformance pass ${pct(m.conformance_pass_rate)}` : ""}`;
|
|
435
436
|
|
|
436
437
|
/** #4491: the `--compare` report: pre/post cohorts, their delta, then the full-shape per-size matched cohorts. */
|
|
@@ -9,7 +9,7 @@ import { tmpDir } from "../tests/_tmp.mjs";
|
|
|
9
9
|
import { TRIGGERS } from "../lean/fixround.mjs";
|
|
10
10
|
import {
|
|
11
11
|
TRIGGER_CAUSE, RETRY_CAUSES, WEEK_MS, codeCause, issueSlices, sliceRetries, issueQuality, acceptanceOf, efficiencyMetrics,
|
|
12
|
-
batchEfficiency, windowEfficiency, formatEfficiencyLines, parseWindows, compareEfficiency, formatCompareLines,
|
|
12
|
+
COMPARE_KEYS, batchEfficiency, windowEfficiency, formatEfficiencyLines, parseWindows, compareEfficiency, formatCompareLines,
|
|
13
13
|
} from "./efficiency.mjs";
|
|
14
14
|
import { comparePivot, parseArgs, runStats } from "./index.mjs";
|
|
15
15
|
import { runLogPath } from "../engine/runlog.mjs";
|
|
@@ -319,8 +319,9 @@ describe("#4491 before/after compare", () => {
|
|
|
319
319
|
const { root, runs } = setup();
|
|
320
320
|
const c = await compareEfficiency({ batchRoot: root, runsDir: runs, repo: SLUG, pivot: PIVOT, now: PIVOT + 3 * DAY });
|
|
321
321
|
assert.deepEqual(Object.keys(c.matched), ["M"]); // issues 7 and 8 (no log, size unknown) are in no bucket
|
|
322
|
-
assert.
|
|
323
|
-
assert.deepEqual(c.matched.M.
|
|
322
|
+
assert.equal(c.matched.M.pre.context_restarts_per_merge, 0); assert.equal(typeof c.matched.M.pre.usd_per_merge, "number");
|
|
323
|
+
assert.deepEqual((({ usd_per_merge, context_restarts_per_merge, ...x }) => x)(c.matched.M.pre), { n: 2, turns_per_merge: 50, implement_wall_p50_min: 40, tool_calls_per_turn_p50: 1, rereads_per_merge: 3 });
|
|
324
|
+
assert.deepEqual((({ usd_per_merge, context_restarts_per_merge, ...x }) => x)(c.matched.M.post), { n: 1, turns_per_merge: 20, implement_wall_p50_min: 20, tool_calls_per_turn_p50: 1.5, rereads_per_merge: 0 });
|
|
324
325
|
assert.equal(c.matched.M.delta.tool_calls_per_turn_p50, 0.5);
|
|
325
326
|
assert.equal(c.matched.M.delta.turns_per_merge, -30);
|
|
326
327
|
});
|
|
@@ -328,9 +329,9 @@ describe("#4491 before/after compare", () => {
|
|
|
328
329
|
const { root, runs } = setup();
|
|
329
330
|
const lines = formatCompareLines(await compareEfficiency({ batchRoot: root, runsDir: runs, repo: SLUG, pivot: PIVOT, now: PIVOT + 3 * DAY }));
|
|
330
331
|
assert.equal(lines[0], "compare: pivot 2026-10-20T00:00:00.000Z, 3.0 days each side (pre 1 batches, post 1 batches)");
|
|
331
|
-
assert.match(lines[1], /^compare pre: n=3 turns\/merge 33\.3, implement wall p50 40\.0 min, calls\/turn p50 1\.00, re-reads\/merge 3\.00, merge rate 75%, conformance pass 33%$/);
|
|
332
|
-
assert.match(lines[3], /^compare delta: turns\/merge -?\d+\.\d, implement wall p50 -20\.0 min, .*merge rate \+25 pts, conformance pass \+67 pts$/);
|
|
333
|
-
assert.match(lines[4], /^compare matched M: pre n=2 post n=1; delta turns\/merge -30\.0, implement wall p50 -20\.0 min, calls\/turn p50 \+0\.50, re-reads\/merge -3\.00$/);
|
|
332
|
+
assert.match(lines[1], /^compare pre: n=3 turns\/merge 33\.3, restarts\/merge 0\.00, \$\/merge \$0\.67, implement wall p50 40\.0 min, calls\/turn p50 1\.00, re-reads\/merge 3\.00, merge rate 75%, conformance pass 33%$/);
|
|
333
|
+
assert.match(lines[3], /^compare delta: turns\/merge -?\d+\.\d, restarts\/merge [-+]?0\.00, .*implement wall p50 -20\.0 min, .*merge rate \+25 pts, conformance pass \+67 pts$/);
|
|
334
|
+
assert.match(lines[4], /^compare matched M: pre n=2 post n=1; delta turns\/merge -30\.0, restarts\/merge [-+]?0\.00, \$\/merge [-+]?\d+\.\d\d, implement wall p50 -20\.0 min, calls\/turn p50 \+0\.50, re-reads\/merge -3\.00$/);
|
|
334
335
|
assert.ok(!lines.some((l) => /NaN|undefined/.test(l)), lines.join("\n"));
|
|
335
336
|
});
|
|
336
337
|
it("case-insensitive repo: a lowercase --repo matches the plans and reads the run logs under their spelling", async () => {
|
|
@@ -343,7 +344,7 @@ describe("#4491 before/after compare", () => {
|
|
|
343
344
|
it("compare rejects a pivot in the future and prints a bare n/a delta for empty cohorts", async () => {
|
|
344
345
|
await assert.rejects(compareEfficiency({ batchRoot: tmpDir("eff-cmp-x-"), runsDir: tmpDir("eff-cmp-y-"), pivot: NOW + DAY, now: NOW }), /pivot/);
|
|
345
346
|
const empty = formatCompareLines(await compareEfficiency({ batchRoot: tmpDir("eff-cmp-x-"), runsDir: tmpDir("eff-cmp-y-"), pivot: NOW - DAY, now: NOW }));
|
|
346
|
-
assert.equal(empty[3], "compare delta: turns/merge n/a, implement wall p50 n/a, calls/turn p50 n/a, re-reads/merge n/a, merge rate n/a, conformance pass n/a");
|
|
347
|
+
assert.equal(empty[3], "compare delta: turns/merge n/a, restarts/merge n/a, $/merge n/a, implement wall p50 n/a, calls/turn p50 n/a, re-reads/merge n/a, merge rate n/a, conformance pass n/a");
|
|
347
348
|
});
|
|
348
349
|
it("compare and offline flags: parsing, pivot resolution and the offline CLI skips gh", async () => {
|
|
349
350
|
const o = parseArgs(["--efficiency", "--compare", "v1.32.0", "--offline"]);
|
|
@@ -410,3 +411,43 @@ describe("#5349 wait attribution in the efficiency report", () => {
|
|
|
410
411
|
assert.ok(formatEfficiencyLines(m).includes("wait (non-model time): n/a"));
|
|
411
412
|
});
|
|
412
413
|
});
|
|
414
|
+
|
|
415
|
+
describe("#5829 context restarts per merge", () => {
|
|
416
|
+
it("counts context_restart builder attempts per merged lane and compares them with $/merge", () => {
|
|
417
|
+
const logs = new Map([[1, [start("2026-10-01T00:00:00Z"), att("implement", { trigger: "build", cost_usd: 2 }), att("implement", { trigger: "context_restart", cost_usd: 1 }),
|
|
418
|
+
att("implement", { trigger: "context_restart", cost_usd: 1 }), term("merged", "completed", { turns: { size: "S" } })]]]);
|
|
419
|
+
const m = efficiencyMetrics({ entries: [{ row: { issue: 1, outcome: "merged" }, settleAt: null }], logs, issues: new Map([[1, { body: "x", labels: [], comments: [] }]]), repo: "o/r", now: NOW });
|
|
420
|
+
assert.equal(m.context_restarts_per_merge, 2);
|
|
421
|
+
assert.equal(m.per_issue[0].context_restarts, 2);
|
|
422
|
+
assert.ok(COMPARE_KEYS.includes("context_restarts_per_merge") && COMPARE_KEYS.includes("usd_per_merge"));
|
|
423
|
+
});
|
|
424
|
+
it("a lane with no restart reports 0", () => {
|
|
425
|
+
const logs = new Map([[1, [start("2026-10-01T00:00:00Z"), att("implement", { trigger: "build" }), term("merged", "completed")]]]);
|
|
426
|
+
const m = efficiencyMetrics({ entries: [{ row: { issue: 1, outcome: "merged" }, settleAt: null }], logs, issues: new Map(), repo: "o/r", now: NOW });
|
|
427
|
+
assert.equal(m.context_restarts_per_merge, 0);
|
|
428
|
+
});
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
describe("#5829 restarts and turns per build, before and after, on a sample", () => {
|
|
432
|
+
// sample: three builds on the old fixed 120K ceiling (two kill-and-restarts each, 60 turns, $4) vs three on the model-aware ceiling (none, 45 turns, $3)
|
|
433
|
+
const PIVOT = Date.parse("2026-10-20T00:00:00Z"), SLUG = "Own/Repo";
|
|
434
|
+
const lane = (turns, restarts, cost) => [start("2026-10-01T00:00:00Z", SLUG), att("implement", { trigger: "build", turns, cost_usd: cost - restarts * 0.5 }),
|
|
435
|
+
...Array.from({ length: restarts }, () => att("implement", { trigger: "context_restart", turns: 0, cost_usd: 0.5 })), term("merged", "merged", { turns: { size: "M" } })];
|
|
436
|
+
it("the compare report shows restarts/merge, turns/merge and $/merge falling after the change", async () => {
|
|
437
|
+
const root = tmpDir("eff-5829-root-"), runs = tmpDir("eff-5829-runs-");
|
|
438
|
+
const batch = (id, created, rows) => { mkdirSync(join(root, id), { recursive: true }); writeFileSync(join(root, id, "plan.json"), JSON.stringify({ v: 1, id, repo: SLUG, created })); writeFileSync(join(root, id, "report.json"), JSON.stringify({ rows })); };
|
|
439
|
+
batch("pre", "2026-10-18T00:00:00Z", [1, 2, 3].map((issue) => ({ issue, outcome: "merged" })));
|
|
440
|
+
batch("post", "2026-10-21T00:00:00Z", [4, 5, 6].map((issue) => ({ issue, outcome: "merged" })));
|
|
441
|
+
const logs = { 1: lane(60, 2, 4), 2: lane(60, 2, 4), 3: lane(60, 2, 4), 4: lane(45, 0, 3), 5: lane(45, 0, 3), 6: lane(45, 0, 3) };
|
|
442
|
+
for (const [n, evs] of Object.entries(logs)) writeFileSync(runLogPath(runs, Number(n), SLUG), evs.map((e) => JSON.stringify(e)).join("\n") + "\n");
|
|
443
|
+
const c = await compareEfficiency({ batchRoot: root, runsDir: runs, repo: SLUG, pivot: PIVOT, now: PIVOT + 3 * DAY });
|
|
444
|
+
assert.deepEqual([c.pre.context_restarts_per_merge, c.post.context_restarts_per_merge], [2, 0]);
|
|
445
|
+
assert.deepEqual([c.pre.turns_per_merge, c.post.turns_per_merge], [60, 45]);
|
|
446
|
+
assert.deepEqual([c.pre.usd_per_merge, c.post.usd_per_merge], [4, 3]);
|
|
447
|
+
assert.deepEqual([c.delta.context_restarts_per_merge, c.delta.turns_per_merge, c.delta.usd_per_merge], [-2, -15, -1]);
|
|
448
|
+
const lines = formatCompareLines(c);
|
|
449
|
+
assert.match(lines[1], /restarts\/merge 2\.00, \$\/merge \$4\.00/);
|
|
450
|
+
assert.match(lines[2], /restarts\/merge 0\.00, \$\/merge \$3\.00/);
|
|
451
|
+
assert.match(lines[3], /restarts\/merge -2\.00, \$\/merge -1\.00/);
|
|
452
|
+
});
|
|
453
|
+
});
|
package/bin/stats/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { experimentReport, renderExperiment } from "./experiment.mjs";
|
|
|
22
22
|
import { readExperiment } from "../experiment.mjs";
|
|
23
23
|
import { compoundingReport, gatherCompounding, renderCompounding, DEFAULT_BUCKETS, DEFAULT_WINDOW_MS } from "./compounding.mjs";
|
|
24
24
|
import { poolUtilisation, formatPoolLines } from "./pool.mjs";
|
|
25
|
+
import { chainsReport, formatChainLines } from "./chains.mjs";
|
|
25
26
|
import { ciAwarenessReport, readCiLogs, renderCiAwareness } from "./ci-awareness.mjs";
|
|
26
27
|
import { gatherIssues, selfFiledReport, renderSelfFiled } from "./selffiled.mjs";
|
|
27
28
|
import { firstReviewReport, renderFirstReview } from "./first-review.mjs";
|
|
@@ -41,6 +42,7 @@ export const HELP = `Usage: forgedock stats [--since <version|date>] [--repo <ow
|
|
|
41
42
|
forgedock stats --experiment <id> [--require-met] [--min-n N] [--repo <owner/repo>] [--json]
|
|
42
43
|
forgedock stats --by version [--post-metrics <pr>] [--min-n N] [--repo <owner/repo>] [--json]
|
|
43
44
|
forgedock stats --pool [--window 7d,30d] [--repo <owner/repo>] [--json]
|
|
45
|
+
forgedock stats --chains [--window 7d,30d] [--repo <owner/repo>] [--json]
|
|
44
46
|
forgedock stats --ci-awareness [--repo <owner/repo>] [--since <date>] [--json]
|
|
45
47
|
forgedock stats --first-review [--repo <owner/repo>] [--since <date>] [--min-n 20] [--json]
|
|
46
48
|
forgedock stats --first-merge [--repo <owner/repo>[,<owner/repo>...]] [--json]
|
|
@@ -103,6 +105,7 @@ Pool (forge#4549; local batch reports, no gh):
|
|
|
103
105
|
--ci-awareness median/p90 CI awareness latency, CI rounds per PR and wall per round, per engine version, from local run logs (#5692);
|
|
104
106
|
--since <date> keeps only the lanes started on/after that date
|
|
105
107
|
--pool remote lane minutes, lanes and share per pool agent over --window (default 7d,30d)
|
|
108
|
+
--chains stacked-lane chains from local batch reports: wall time p50 by depth, per-link overlap, cascade rework rate (#5834)
|
|
106
109
|
|
|
107
110
|
Efficiency (forge#4402; local batch dirs and run logs, gh only for merged issues' bodies, labels and probes):
|
|
108
111
|
--efficiency $/merge, turns/merge, context/turn per size and model, retries/merge by cause, no-action
|
|
@@ -171,7 +174,7 @@ Lane profile baseline (forge#4436; local run logs only, every run of each issue,
|
|
|
171
174
|
export function experimentExit(opts, report) { return opts.requireMet && report.targets_met !== true ? 1 : 0; }
|
|
172
175
|
|
|
173
176
|
export function parseArgs(argv) {
|
|
174
|
-
const o = { card: false, week: false, month: false, includeRepoNames: false, publicRepo: false, out: null, depth: false, conformanceOutcomes: false, windowDays: null, since: null, repo: null, edge: null, milestone: null, contextAb: false, exploreAb: false, tiers: false, compounding: false, selfFiled: false, origin: false, firstMerge: false, bucket: null, laneProfile: false, issues: null, efficiency: false, pool: false, ciAwareness: false, batch: null, windows: null, compare: null, by: null, experiment: null, emitEvent: false, requireMet: false, postMetrics: null, offline: false, json: false, refresh: false, compact: false, local: true, cache: true, minN: DEFAULT_MIN_N, releaseTimes: null, help: false };
|
|
177
|
+
const o = { card: false, week: false, month: false, includeRepoNames: false, publicRepo: false, out: null, depth: false, conformanceOutcomes: false, windowDays: null, since: null, repo: null, edge: null, milestone: null, contextAb: false, exploreAb: false, tiers: false, compounding: false, selfFiled: false, origin: false, firstMerge: false, bucket: null, laneProfile: false, issues: null, efficiency: false, pool: false, chains: false, ciAwareness: false, batch: null, windows: null, compare: null, by: null, experiment: null, emitEvent: false, requireMet: false, postMetrics: null, offline: false, json: false, refresh: false, compact: false, local: true, cache: true, minN: DEFAULT_MIN_N, releaseTimes: null, help: false };
|
|
175
178
|
const val = (i, name) => {
|
|
176
179
|
const v = argv[i + 1];
|
|
177
180
|
if (v == null || v.startsWith("--")) throw new Error(`${name} needs a value`);
|
|
@@ -206,6 +209,7 @@ export function parseArgs(argv) {
|
|
|
206
209
|
else if (name === "--efficiency") o.efficiency = true;
|
|
207
210
|
else if (name === "--depth") o.depth = true;
|
|
208
211
|
else if (name === "--pool") o.pool = true;
|
|
212
|
+
else if (name === "--chains") o.chains = true;
|
|
209
213
|
else if (name === "--release-ledger") o.releaseLedger = true;
|
|
210
214
|
else if (name === "--baseline") { const v = take(); if (v !== "save" && v !== "compare") throw new Error("--baseline must be save or compare"); o.baseline = v; }
|
|
211
215
|
else if (name === "--baseline-file") o.baselineFile = take();
|
|
@@ -242,10 +246,10 @@ export function parseArgs(argv) {
|
|
|
242
246
|
}
|
|
243
247
|
if ((o.week || o.month || o.includeRepoNames || o.publicRepo || o.out) && !o.card) throw new Error("--week, --month, --include-repo-names, --public-repo and --out need --card");
|
|
244
248
|
if (o.week && o.month) throw new Error("--week and --month are mutually exclusive");
|
|
245
|
-
if (o.card && (o.depth || o.pool || o.ciAwareness || o.efficiency || o.compounding || o.selfFiled || o.conformanceOutcomes || o.contextAb || o.exploreAb || o.tiers || o.laneProfile || o.edge || o.milestone || o.experiment || o.by)) throw new Error("--card cannot be combined with another query mode");
|
|
249
|
+
if (o.card && (o.depth || o.pool || o.chains || o.ciAwareness || o.efficiency || o.compounding || o.selfFiled || o.conformanceOutcomes || o.contextAb || o.exploreAb || o.tiers || o.laneProfile || o.edge || o.milestone || o.experiment || o.by)) throw new Error("--card cannot be combined with another query mode");
|
|
246
250
|
if (o.card && (o.week || o.month) && o.since) throw new Error("--week/--month and --since are mutually exclusive");
|
|
247
251
|
if (o.batch && !o.efficiency) throw new Error("--batch and --window need --efficiency");
|
|
248
|
-
if (o.windows && !o.efficiency && !o.pool && !o.compounding) throw new Error("--batch and --window need --efficiency");
|
|
252
|
+
if (o.windows && !o.efficiency && !o.pool && !o.chains && !o.compounding) throw new Error("--batch and --window need --efficiency");
|
|
249
253
|
if (o.bucket && !o.compounding) throw new Error("--bucket needs --compounding");
|
|
250
254
|
if (o.compare && !o.efficiency) throw new Error("--compare and --offline need --efficiency");
|
|
251
255
|
if (o.offline && !o.efficiency && !o.depth) throw new Error("--compare and --offline need --efficiency (--offline also works with --depth)");
|
|
@@ -425,6 +429,9 @@ export async function buildReport(opts, deps = {}) {
|
|
|
425
429
|
const pool = poolUtilisation({ batchRoot: deps.batchRoot ?? batchRoot(env), repo, windows: opts.windows ?? parseWindows("7d,30d"), now: deps.now?.() ?? Date.now() });
|
|
426
430
|
return { repo, query: { pool } };
|
|
427
431
|
}
|
|
432
|
+
if (opts.chains) { // #5834: local batch reports only
|
|
433
|
+
return { repo, query: { chains: chainsReport({ batchRoot: deps.batchRoot ?? batchRoot(env), repo, windows: opts.windows ?? parseWindows("7d,30d"), now: deps.now?.() ?? Date.now() }) } };
|
|
434
|
+
}
|
|
428
435
|
if (opts.depth) { // forge#5209: run logs; gh only for post-merge defect signals
|
|
429
436
|
const st = sinceToTimestamp(opts.since, releaseTimes), nowMs = deps.now?.() ?? Date.now();
|
|
430
437
|
let sinceMs = st.since ? Date.parse(st.since) : null;
|
|
@@ -576,6 +583,7 @@ export async function runStats(argv, deps = {}) {
|
|
|
576
583
|
if (report.query?.self_filed && !opts.json) { process.stdout.write(`${renderSelfFiled(report.query.self_filed)}\n`); return 0; }
|
|
577
584
|
if (report.query?.depth && !opts.json) { process.stdout.write(`${renderDepth(report.query.depth, { repo: report.repo, since: opts.since })}\n`); return 0; }
|
|
578
585
|
if (report.query?.ci_awareness && !opts.json) { process.stdout.write(`${renderCiAwareness(report.query.ci_awareness)}\n`); return 0; }
|
|
586
|
+
if (report.query?.chains && !opts.json) { process.stdout.write(`${formatChainLines(report.query.chains).join("\n")}\n`); return 0; }
|
|
579
587
|
if (report.query?.pool && !opts.json) { process.stdout.write(`${formatPoolLines(report.query.pool).join("\n")}\n`); return 0; }
|
|
580
588
|
if (report.query?.efficiency && !opts.json) {
|
|
581
589
|
const e = report.query.efficiency;
|
package/bin/stats/stats.test.mjs
CHANGED
|
@@ -1117,3 +1117,12 @@ describe("stats --ci-awareness (#5692)", () => {
|
|
|
1117
1117
|
assert.equal(ciAwarenessReport(logs).total.lanes, 2);
|
|
1118
1118
|
});
|
|
1119
1119
|
});
|
|
1120
|
+
|
|
1121
|
+
describe("stats --chains (#5834)", () => {
|
|
1122
|
+
it("parses, takes --window, and is rejected with --card", () => {
|
|
1123
|
+
const o = parseArgs(["--chains", "--window", "7d"]);
|
|
1124
|
+
assert.equal(o.chains, true); assert.equal(o.windows.length, 1);
|
|
1125
|
+
assert.throws(() => parseArgs(["--card", "--chains"]), /cannot be combined/);
|
|
1126
|
+
assert.equal(parseArgs(["--pool"]).chains, false, "--pool is unchanged");
|
|
1127
|
+
});
|
|
1128
|
+
});
|
package/docs/CONFIG.md
CHANGED
|
@@ -328,6 +328,10 @@ orchestration:
|
|
|
328
328
|
# is PR-ready (review passed, precheck green) builds on that lane head and opens a stacked PR
|
|
329
329
|
# on the dependency's branch. The merge step (guard merge.stacked_base) refuses while the PR
|
|
330
330
|
# base is not the lane or the dependency is unmerged; after it merged the PR moves onto the lane.
|
|
331
|
+
# Cascades (#5833): while it waits, a moved dependency head is rebased onto and re-verified (a conflict
|
|
332
|
+
# restarts the dependent from its frozen contract), a dependency closed without merging drops the
|
|
333
|
+
# stacked PR/branch and re-plans the dependent on the lane base, and after the merge only the checks
|
|
334
|
+
# the dependency's diff touches re-run. Rows carry `cascade`; the batch report counts cascades per dependent.
|
|
331
335
|
# A plan lane's other ends do not count toward the breaker, relaunch or requeue budgets.
|
|
332
336
|
stacking: off
|
|
333
337
|
|
|
@@ -1731,7 +1735,7 @@ execution:
|
|
|
1731
1735
|
| Key | Type | Required | Description |
|
|
1732
1736
|
|-----|------|----------|-------------|
|
|
1733
1737
|
| `mode` | string | No | `local` (default): lanes are detached host processes, as before. `remote`: lanes run in sandboxes of `provider`. `hybrid`: each lane is placed from facts (forge#4256, below). |
|
|
1734
|
-
| `max_remote` | integer | No | Remote lanes of the batch that may run at once. They take no slot of the host lane cap (`orchestration.global_parallel`, `forgedock sched cap`); the batch `--parallel` still applies. `0` (default) keeps lanes local. |
|
|
1738
|
+
| `max_remote` | integer | No | Remote lanes of the batch that may run at once. They take no slot of the host lane cap (`orchestration.global_parallel`, `forgedock sched cap`); the batch `--parallel` still applies. `0` (default) keeps lanes local. The pool router's per-agent lane ceiling (`forgedock pool limit <agent> --lanes N`) caps lane sandboxes on a host across all batches and defers the rest. |
|
|
1735
1739
|
| `heavy` | boolean | No | Hybrid placement override (forge#4523). `true`: every lane that passes rules 1-3 is placed remote. `false`: the detected validation weight is ignored (rule 5 still applies). Unset: detect. It changes placement only: no pre-PR commands run, and host admission (`max_load_per_core`) is unchanged. |
|
|
1736
1740
|
| `provider` | string | No | `container` (reference: an ephemeral local container), `remote` (a runner pool or remote session over HTTP, forge#4254), `pool` (the built-in pool router on this host, forge#4546: `remote` with `endpoint` and `token_env` defaulted from the router config, `COMPUTESHARE_CONFIG` or `~/.config/computeshare/router.json`, and its `forgedock.token`; the repo's `forge.yaml` is sent to every sandbox, so no router `repos` map is needed; missing router config and no `endpoint` fails with `execution.provider.misconfigured`) or `local`. The default is `container` off `local` mode; `remote` and `pool` are used only when named. Unknown names fail the batch start. |
|
|
1737
1741
|
| `image` | string | No | Container provider image; it must provide `git` and `forgedock`. Started with `--pull never`. |
|
|
@@ -2949,6 +2953,9 @@ Keys of the pool agent's JSON config (`forgedock pool agent`), not of `forge.yam
|
|
|
2949
2953
|
| `cache_idle_days` | number | `30` | A volume with no launch for this long and no referencing sandbox is removed. Evicted only when its last use is known (`/cache/.last-used`, written by the lane entrypoint). |
|
|
2950
2954
|
| `cache_never_evict` | list of volume names | `[]` | Volumes (e.g. `cs-cache-marcode`) that are never swept or evicted. |
|
|
2951
2955
|
| `cache_sweep_interval_s` | number | `3600` | Gap between cache sweeps. |
|
|
2956
|
+
| `lane_disk_cap_gb` | number | unset (off) | #5884: hard cap on lane disk (running sandbox dirs plus this agent's cache volumes). At or over it `/capacity` has `disk_capped: true`, a launch answers 503 `pool.disk_cap` (a deferral, like `pool.disk_low`) and the router skips the host. Fields `lane_disk_used_gb`/`lane_disk_cap_gb` appear only when set. A dedicated volume or filesystem quota for the state dir is the operator-side alternative. |
|
|
2957
|
+
| `disk_prune_at_pct` | number | `80` | From this percent of `lane_disk_cap_gb` each reap prunes this agent's stopped containers, dangling images and build cache (agent-label scoped) and runs a cache sweep, then an fstrim. |
|
|
2958
|
+
| `fstrim_interval_s` | number | `21600` | Gap between best-effort `fstrim -v <docker root>` runs (`sudo -n` when not root; failure is a log line). `fstrim: false` turns it off; `docker_root` overrides `/var/lib/docker`. The WSL installer also enables `sparseVhd=true` in `.wslconfig` and `wsl --manage --set-sparse`. |
|
|
2952
2959
|
| `agent_id` | string | `name` | Owner label `computeshare.agent=<id>` (#5881) on every container and cache volume the agent creates. Reap, orphan-volume, cache and work sweeps touch only resources carrying it, so a co-resident agent or foreign containers are never removed; unlabelled pre-existing items are left alone. Setting it also namespaces the cache volume (`cs-cache-<id>-<key>`) so two agents never share `/cache/work`. |
|
|
2953
2960
|
|
|
2954
2961
|
A failed or timed-out sweep (10 min limit) shows as `cache_sweep_error` in the agent's `/capacity`, next to `cache_volumes` (size per volume).
|
package/docs/OUTCOME-CODES.md
CHANGED
|
@@ -66,6 +66,10 @@ An absent or unknown code is recorded as `unclassified`, with the raw reason kep
|
|
|
66
66
|
| `sandbox.transient` | The remote sandbox provider answered HTTP 500/502/504 on launch: a router or agent infrastructure failure, not a code or human problem (forge#5095). `deferred`, requeued after `Retry-After` when sent, else 60s; counted toward `orchestration.max_deferrals` (so a broken pool ends `deferred`, never `needs-human`); not counted by the engine-error circuit breaker | orchestrate | `bin/lean/execution.mjs` `providerLanes` `startFailed`: `provider.start` threw with `err.status` 5xx (not retryable) or `err.transient` |
|
|
67
67
|
| `sandbox.auth` | The remote sandbox provider refused the lane's credential (HTTP 401/403) at start (forge#4685). `deferred`, retried after 300s, never `needs-human`; the pool token resolves from the env, the keychain, then `~/.config/computeshare/forgedock.token` | orchestrate | `provider.start` threw with `err.status` 401/403 |
|
|
68
68
|
| `sandbox.unreachable` | The remote sandbox provider stayed unreachable (connection refused/reset, `fetch failed`, timeout, 502/503/504) for `execution.unreachable_window_min` while a lane polled or adopted its sandbox (forge#4672). `deferred`, requeued after 60s; not counted by the engine-error circuit breaker. The sandbox is NOT torn down: the next attempt or `--resume` adopts it | orchestrate | `bin/lean/execution.mjs` `providerLanes` poll guard |
|
|
69
|
+
| `sandbox.disk_pressure` | The pool agent stopped a lane's sandbox because its host drive fell below half the disk floor and every sandbox on the host was about to be lost (forge#5891). The agent reports it as `code` on the stopped sandbox; its branch, worktree and cache volume are kept, so the requeued lane adopts them instead of starting over. | orchestrate | `bin/pool/agent.mjs` `diskPressure`: host free space below `host_disk_floor_gb / 2` after reclaim and pause |
|
|
70
|
+
| `sandbox.lost` | Three or more sandboxes on the same pool agent ended without a result within 60s: the agent or its VM restarted (forge#5859). `deferred`, requeued once after 60s; not counted by the engine-error circuit breaker and does not use the per-issue engine-error relaunch. One batch event (`agent <name> restarted at <ts>; N lanes requeued`) is recorded and shown by `forgedock status --batch` | orchestrate | `bin/lean/orchestrate.mjs` `settleLane` |
|
|
71
|
+
| `sandbox.repo_missing` | The claimed sandbox repo directory is missing, not a git repository, or git could not spawn there (`ENOENT`/`EACCES`) (forge#5890). `deferred`, requeued after 120s; not counted by the engine-error circuit breaker and does not use the per-issue engine-error relaunch | lean | `bin/lean/lean.mjs` `runCore` precheck, `bin/lean/worktree.mjs` `addLaneWorktree` |
|
|
72
|
+
| `net.transient` | A git clone/fetch hit a transport failure (curl 56/28, early EOF, `RPC failed`, invalid index-pack output, unexpected disconnect, a half-built mirror) (forge#5947). `deferred` with transient backoff (30s, 2m, 8m, 15m); not counted by the engine-error circuit breaker and does not use the engine-error relaunch | lean | `bin/lean/orchestrate.mjs` `settleLane` |
|
|
69
73
|
| `lease.held` | Another live agent holds the issue lease | engine | Foreign live lease on acquire |
|
|
70
74
|
| `dependency.open` | A dependency is still open: a trusted `**Depends on**: #N` line refused the run before any state write, or the core builder reported `block.kind: "dependency"` naming an issue that is open. Carries `dependencies`; never `needs-human`. `forgedock orchestrate` adds the edge and requeues the issue behind it, without skipping dependents | engine, lean | Trusted `**Depends on**` line, or `result.json` `block.issues`, + the dependency issue's live open state |
|
|
71
75
|
| `design.invalidated` | Core work-on: the builder reported `block.kind: "design-invalidated"` (a decision or interface no longer holds). The engine files one spike-amendment issue, holds the affected open siblings behind it with `**Depends on**` edges, and requeues the lane. Carries `dependencies`, `amendment`, `epic`; never `needs-human`. The rework-share rollup counts it | lean | `result.json` `block` + the `FORGE:REPLAN` comment |
|
package/package.json
CHANGED
package/pool/README.md
CHANGED
|
@@ -6,6 +6,16 @@ ForgeDock's built-in remote compute pool (imported from computeshare; AGPL-3.0-o
|
|
|
6
6
|
- `pool/image/` lane image recipe (Dockerfile, shims, entrypoint, `cs-cred` credential relay, `cs-relay` read-only capability relay: allowlisted commands executed on the dispatching host, #4778).
|
|
7
7
|
- `pool/install/` agent installers (Windows/WSL, native Linux, router).
|
|
8
8
|
Native Linux agent (root, systemd): `pool/install/install-agent-linux.sh --router URL --token CODE [--name N --cpus N --mem GB --dry-run]`.
|
|
9
|
+
One command on Linux or macOS (#5883, outbound, no inbound port): `forgedock pool enroll --one-liner` prints
|
|
10
|
+
`curl -fsSL '<router>/install' | sh -s -- --code '<code>' [--cpus N --mem GB]` (run as root, e.g. `| sudo sh -s -- ...`). Rerunning is safe:
|
|
11
|
+
an enrolled host reuses its code and agent token. macOS needs a running Docker Desktop or colima and installs a LaunchDaemon.
|
|
12
|
+
Uninstall: `curl -fsSL '<router>/install' | sh -s -- --uninstall` (or `pool/install/uninstall-agent-linux.sh` / `uninstall-agent-macos.sh`,
|
|
13
|
+
`--dry-run` to preview). It removes the service, this agent's labelled containers, volumes and lane images and its files; docker and node
|
|
14
|
+
only when `/etc/computeshare/installed-by` records that the installer added them. Never a `docker system prune`.
|
|
15
|
+
Device login (#5886): `install-agent-linux.sh --router URL --device` prints a user code and polls; on your ForgeDock machine run
|
|
16
|
+
`forgedock pool link <user_code> [--account A]` and the box enrolls itself, stamped with that account. `forgedock pool status --account A`
|
|
17
|
+
shows one account's boxes; `forgedock pool policy <agent> [--cpus N --mem GB --idle-only --pause]` sets a per-box policy the router pushes
|
|
18
|
+
(the box owner's own `pool pause` always wins). A launch spec with `account` is placed only on that account's boxes.
|
|
9
19
|
- `pool/services/` opt-in caching proxies (npm, PyPI, apt) and a read-only git mirror (`docker-compose.yml`); nothing starts them. See `docs/ENV-LIBRARY.md`.
|
|
10
20
|
- Tests: `bin/tests/computeshare.test.mjs`.
|
|
11
21
|
|
package/pool/image/Dockerfile
CHANGED
|
@@ -39,10 +39,11 @@ RUN curl -LsSf "https://astral.sh/uv/${UV_VERSION}/install.sh" | env UV_INSTALL_
|
|
|
39
39
|
|
|
40
40
|
COPY entrypoint.sh /usr/local/bin/cs-entrypoint
|
|
41
41
|
COPY warm-refresh.sh /usr/local/bin/cs-warm-refresh
|
|
42
|
+
COPY mirror.sh /usr/local/bin/cs-mirror
|
|
42
43
|
COPY cs-cred /usr/local/bin/cs-cred
|
|
43
44
|
COPY cs-relay /usr/local/bin/cs-relay
|
|
44
45
|
COPY gh-shim /opt/cs/bin/gh
|
|
45
46
|
COPY claude-shim /opt/cs/bin/claude
|
|
46
|
-
RUN chmod 0755 /usr/local/bin/cs-entrypoint /usr/local/bin/cs-warm-refresh /usr/local/bin/cs-cred /usr/local/bin/cs-relay /opt/cs/bin/gh /opt/cs/bin/claude
|
|
47
|
+
RUN chmod 0755 /usr/local/bin/cs-entrypoint /usr/local/bin/cs-warm-refresh /usr/local/bin/cs-mirror /usr/local/bin/cs-cred /usr/local/bin/cs-relay /opt/cs/bin/gh /opt/cs/bin/claude
|
|
47
48
|
WORKDIR /work
|
|
48
49
|
ENTRYPOINT ["/usr/local/bin/cs-entrypoint"]
|
package/pool/image/entrypoint.sh
CHANGED
|
@@ -45,14 +45,14 @@ checkout_repo() {
|
|
|
45
45
|
if [ -n "${CS_REPO_URL:-}" ]; then
|
|
46
46
|
# Shared bare mirror in the cache volume: later lanes fetch a delta instead of a full clone.
|
|
47
47
|
mirror="/cache/git/$(echo "${CS_REPO_SLUG:-repo}" | tr '/' '_').git"
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
# #5947: mirror.sh validates (refs, no empty objects), quarantines a bad one, builds under a lock; `direct` = no --reference.
|
|
49
|
+
use="$(/usr/local/bin/cs-mirror prepare "$CS_REPO_URL" "$mirror" 2>/dev/null || echo direct)"
|
|
50
|
+
rm -rf /work/repo
|
|
51
|
+
if [ "$use" = "ok" ]; then
|
|
52
|
+
git clone --quiet --reference "$mirror" ${CS_REPO_REF:+--branch "$CS_REPO_REF"} "$CS_REPO_URL" /work/repo
|
|
50
53
|
else
|
|
51
|
-
|
|
52
|
-
git clone --mirror --quiet "$CS_REPO_URL" "$mirror"
|
|
54
|
+
git clone --quiet ${CS_REPO_REF:+--branch "$CS_REPO_REF"} "$CS_REPO_URL" /work/repo
|
|
53
55
|
fi
|
|
54
|
-
rm -rf /work/repo
|
|
55
|
-
git clone --quiet --reference "$mirror" ${CS_REPO_REF:+--branch "$CS_REPO_REF"} "$CS_REPO_URL" /work/repo
|
|
56
56
|
cd "$(readlink -f /work/repo)"
|
|
57
57
|
fi
|
|
58
58
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
3
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
|
+
# Shared bare-mirror hygiene for checkout_repo (#5947). Usage: mirror.sh prepare <repo-url> <mirror-dir>
|
|
5
|
+
# Prints `ok` (the mirror is valid: clone with --reference) or `direct` (clone straight from the URL; the mirror is
|
|
6
|
+
# quarantined, missing or being rebuilt). Never exits non-zero for a mirror problem: a bad mirror must not fail a lane.
|
|
7
|
+
# A mirror is valid when it has refs and no zero-length file under objects/ (and, with MIRROR_FSCK=1, passes
|
|
8
|
+
# `git fsck --connectivity-only`). Builds go into <mirror>.tmp-<pid> under a per-repo flock and are renamed into place
|
|
9
|
+
# only after a successful clone with refs, so a timed-out clone never leaves a half mirror behind.
|
|
10
|
+
# Env: MIRROR_FETCH_RETRIES (3), MIRROR_RETRY_SLEEP (5s), MIRROR_LOCK_WAIT (900s), MIRROR_FSCK, MIRROR_BUILD_LOG (one line per build attempt).
|
|
11
|
+
|
|
12
|
+
mirror_valid() {
|
|
13
|
+
local m="$1"
|
|
14
|
+
[ -d "$m/objects" ] || return 1
|
|
15
|
+
[ -n "$(git -C "$m" for-each-ref --count=1 2>/dev/null)" ] || return 1
|
|
16
|
+
[ -z "$(find "$m/objects" -type f -size 0 -print -quit 2>/dev/null)" ] || return 1
|
|
17
|
+
if [ "${MIRROR_FSCK:-}" = "1" ]; then git -C "$m" fsck --connectivity-only --no-dangling >/dev/null 2>&1 || return 1; fi
|
|
18
|
+
return 0
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
mirror_quarantine() {
|
|
22
|
+
local m="$1" dest
|
|
23
|
+
dest="$m.corrupt-$(date +%s)-$$"
|
|
24
|
+
mv "$m" "$dest" 2>/dev/null || rm -rf "$m"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Caller holds the lock. Returns 0 only when a valid mirror now sits at $2.
|
|
28
|
+
mirror_build() {
|
|
29
|
+
local url="$1" m="$2" tmp="$2.tmp-$$" i=1 n="${MIRROR_FETCH_RETRIES:-3}"
|
|
30
|
+
rm -rf "$m".tmp-* 2>/dev/null # leftovers of a killed build (the lock makes us the only builder)
|
|
31
|
+
while [ "$i" -le "$n" ]; do
|
|
32
|
+
[ -z "${MIRROR_BUILD_LOG:-}" ] || echo "build $i $$" >> "$MIRROR_BUILD_LOG"
|
|
33
|
+
if git clone --mirror --quiet "$url" "$tmp" >/dev/null 2>&1 && mirror_valid "$tmp"; then
|
|
34
|
+
mv "$tmp" "$m" && return 0
|
|
35
|
+
fi
|
|
36
|
+
rm -rf "$tmp"
|
|
37
|
+
[ "$i" -lt "$n" ] && sleep "${MIRROR_RETRY_SLEEP:-5}"
|
|
38
|
+
i=$((i + 1))
|
|
39
|
+
done
|
|
40
|
+
return 1
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mirror_prepare() {
|
|
44
|
+
local url="$1" m="$2" lock
|
|
45
|
+
mkdir -p "$(dirname "$m")" 2>/dev/null
|
|
46
|
+
lock="$m.lock"
|
|
47
|
+
if [ -d "$m" ] && ! mirror_valid "$m"; then
|
|
48
|
+
# Bad mirror: set it aside for everyone, rebuild once in the background, this lane clones directly.
|
|
49
|
+
( flock -w "${MIRROR_LOCK_WAIT:-900}" 9 || exit 0
|
|
50
|
+
if [ -d "$m" ] && ! mirror_valid "$m"; then mirror_quarantine "$m"; fi
|
|
51
|
+
[ -d "$m" ] || mirror_build "$url" "$m" ) 9>"$lock" >/dev/null 2>&1 </dev/null &
|
|
52
|
+
echo direct; return 0
|
|
53
|
+
fi
|
|
54
|
+
(
|
|
55
|
+
flock -w "${MIRROR_LOCK_WAIT:-900}" 9 || { echo direct; exit 0; }
|
|
56
|
+
if [ -d "$m" ]; then
|
|
57
|
+
git -C "$m" fetch --prune --quiet origin '+refs/heads/*:refs/heads/*' >/dev/null 2>&1 || true
|
|
58
|
+
if mirror_valid "$m"; then echo ok; else echo direct; fi
|
|
59
|
+
elif mirror_build "$url" "$m"; then echo ok
|
|
60
|
+
else echo direct; fi
|
|
61
|
+
) 9>"$lock"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
65
|
+
case "${1:-}" in
|
|
66
|
+
prepare) [ -n "${2:-}" ] && [ -n "${3:-}" ] || { echo "usage: mirror.sh prepare <url> <mirror-dir>" >&2; exit 2; }
|
|
67
|
+
mirror_prepare "$2" "$3" ;;
|
|
68
|
+
valid) mirror_valid "${2:?mirror dir}" ;;
|
|
69
|
+
*) echo "usage: mirror.sh prepare <url> <mirror-dir> | valid <mirror-dir>" >&2; exit 2 ;;
|
|
70
|
+
esac
|
|
71
|
+
fi
|
|
@@ -3,10 +3,16 @@
|
|
|
3
3
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
# Native Linux (systemd) agent install: the Windows installer without the VM layer. Resolves host settings, then runs install-agent.sh,
|
|
5
5
|
# which installs docker, node, enrolls the agent, builds the lane image and installs the computeshare-agent systemd unit.
|
|
6
|
-
# Usage: install-agent-linux.sh --router URL --token CODE [--name N] [--port P] [--cpus N] [--mem GB] [--bundle FILE] [--dry-run]
|
|
7
|
-
#
|
|
6
|
+
# Usage: install-agent-linux.sh --router URL --token CODE [--name N] [--port P] [--cpus N] [--mem GB] [--bundle FILE] [--outbound] [--dry-run]
|
|
7
|
+
# install-agent-linux.sh --router URL --device [same options] (device login, #5886: no --token)
|
|
8
|
+
# Env equivalents: ROUTER_URL ENROLL_TOKEN AGENT_NAME AGENT_PORT ALLOW_CPUS ALLOW_MEM_GB BUNDLE AGENT_URL OUTBOUND
|
|
9
|
+
# Rerun (#5883): with /etc/computeshare/agent.token present and no --bundle, the installed /opt/computeshare is reused (no download, so a used
|
|
10
|
+
# code works) and nothing is re-enrolled. Uninstall: uninstall-agent-linux.sh (removes only what /etc/computeshare/installed-by records).
|
|
11
|
+
# --device (#5886): prints a user code, waits while `forgedock pool link CODE [--account A]` approves it on the operator's machine, then enrolls with the one-time code the router returns (always outbound); the agent record carries the account.
|
|
12
|
+
# --outbound (OUTBOUND=1): the agent dials the router (no Tailscale, no inbound port); it enrolls without a URL and listens only on the docker bridge.
|
|
8
13
|
set -euo pipefail
|
|
9
14
|
DRY=0
|
|
15
|
+
DEVICE=0
|
|
10
16
|
while [ $# -gt 0 ]; do
|
|
11
17
|
case "$1" in
|
|
12
18
|
--router) ROUTER_URL="${2:?}"; shift 2 ;;
|
|
@@ -16,10 +22,37 @@ while [ $# -gt 0 ]; do
|
|
|
16
22
|
--cpus) ALLOW_CPUS="${2:?}"; shift 2 ;;
|
|
17
23
|
--mem) ALLOW_MEM_GB="${2:?}"; shift 2 ;;
|
|
18
24
|
--bundle) BUNDLE="${2:?}"; shift 2 ;;
|
|
25
|
+
--outbound) OUTBOUND=1; shift ;;
|
|
26
|
+
--device) DEVICE=1; shift ;;
|
|
19
27
|
--dry-run) DRY=1; shift ;;
|
|
20
28
|
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
|
21
29
|
esac
|
|
22
30
|
done
|
|
31
|
+
if [ "$DEVICE" = 1 ]; then
|
|
32
|
+
: "${ROUTER_URL:?--router or ROUTER_URL required}"
|
|
33
|
+
OUTBOUND=1
|
|
34
|
+
if [ "$DRY" = 1 ]; then ENROLL_TOKEN="<device-code>"; else
|
|
35
|
+
json_field() { sed -n "s/.*\"$1\":\"\{0,1\}\([^\",}]*\).*/\1/p" | head -1; }
|
|
36
|
+
DEV="$(curl -fsS -X POST "${ROUTER_URL}/device/code")" || { echo "could not reach ${ROUTER_URL}/device/code" >&2; exit 1; }
|
|
37
|
+
DEVICE_CODE="$(printf %s "$DEV" | json_field device_code)"; USER_CODE="$(printf %s "$DEV" | json_field user_code)"
|
|
38
|
+
INTERVAL="$(printf %s "$DEV" | json_field interval)"; INTERVAL="${INTERVAL:-5}"
|
|
39
|
+
[ -n "$DEVICE_CODE" ] && [ -n "$USER_CODE" ] || { echo "router returned no device code" >&2; exit 1; }
|
|
40
|
+
echo "[computeshare] to link this box, run on your ForgeDock machine: forgedock pool link $USER_CODE [--account NAME]"
|
|
41
|
+
ENROLL_TOKEN=""
|
|
42
|
+
while [ -z "$ENROLL_TOKEN" ]; do
|
|
43
|
+
sleep "$INTERVAL"
|
|
44
|
+
RES="$(curl -sS -X POST -H 'content-type: application/json' -d "{\"device_code\":\"$DEVICE_CODE\"}" "${ROUTER_URL}/device/token" || true)"
|
|
45
|
+
ENROLL_TOKEN="$(printf %s "$RES" | json_field enroll_code)"
|
|
46
|
+
[ -n "$ENROLL_TOKEN" ] && break
|
|
47
|
+
case "$RES" in
|
|
48
|
+
*authorization_pending*) ;;
|
|
49
|
+
*slow_down*) INTERVAL=$((INTERVAL + 5)) ;;
|
|
50
|
+
*) echo "device login failed or expired: $RES" >&2; exit 1 ;;
|
|
51
|
+
esac
|
|
52
|
+
done
|
|
53
|
+
echo "[computeshare] linked; enrolling"
|
|
54
|
+
fi
|
|
55
|
+
fi
|
|
23
56
|
: "${ROUTER_URL:?--router or ROUTER_URL required}" "${ENROLL_TOKEN:?--token or ENROLL_TOKEN required}"
|
|
24
57
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
25
58
|
PORT="${AGENT_PORT:-7711}"
|
|
@@ -29,7 +62,10 @@ CPUS="${ALLOW_CPUS:-0}"
|
|
|
29
62
|
if [ "$CPUS" -le 0 ]; then CPUS=$(( $(nproc) - 4 )); [ "$CPUS" -ge 2 ] || CPUS=2; fi
|
|
30
63
|
MEM="${ALLOW_MEM_GB:-0}"
|
|
31
64
|
if [ "$MEM" -le 0 ]; then MEM=$(( $(awk '/MemTotal/ {print int($2/1024/1024)}' /proc/meminfo) / 2 )); [ "$MEM" -ge 4 ] || MEM=4; fi
|
|
32
|
-
|
|
65
|
+
OUTBOUND="${OUTBOUND:-0}"
|
|
66
|
+
if [ "$OUTBOUND" = 1 ]; then
|
|
67
|
+
AGENT_URL=""
|
|
68
|
+
elif [ -z "${AGENT_URL:-}" ]; then
|
|
33
69
|
if [ "$DRY" = 1 ] && ! command -v tailscale >/dev/null; then TS_IP="<tailscale-ip>"; else
|
|
34
70
|
TS_IP="$(tailscale ip -4 | head -1)"
|
|
35
71
|
[[ "$TS_IP" == 100.* ]] || { echo "no Tailscale IPv4 found (got '$TS_IP')" >&2; exit 1; }
|
|
@@ -46,8 +82,24 @@ fi
|
|
|
46
82
|
if [ -z "${BUNDLE:-}" ]; then
|
|
47
83
|
BUNDLE="$(mktemp /tmp/computeshare-bundle.XXXXXX.tar.gz)"
|
|
48
84
|
trap 'rm -f "$BUNDLE"' EXIT
|
|
49
|
-
|
|
85
|
+
if [ -s /etc/computeshare/agent.token ] && [ -f /opt/computeshare/package.json ]; then
|
|
86
|
+
echo "[computeshare] already enrolled: reinstalling from /opt/computeshare (no bundle download)"
|
|
87
|
+
tar -czf "$BUNDLE" -C /opt/computeshare .
|
|
88
|
+
else
|
|
89
|
+
curl -fsS "${ROUTER_URL}/bootstrap/bundle.tar.gz?token=${ENROLL_TOKEN}" -o "$BUNDLE"
|
|
90
|
+
fi
|
|
50
91
|
fi
|
|
51
|
-
export ROUTER_URL ENROLL_TOKEN AGENT_NAME AGENT_URL BUNDLE
|
|
92
|
+
export ROUTER_URL ENROLL_TOKEN AGENT_NAME AGENT_URL BUNDLE OUTBOUND
|
|
52
93
|
export AGENT_PORT="$PORT" ALLOW_CPUS="$CPUS" ALLOW_MEM_GB="$MEM"
|
|
53
94
|
bash "$HERE/install-agent.sh"
|
|
95
|
+
|
|
96
|
+
# #5884: periodic discard so freed lane blocks return to the thin disk / VHDX (best effort: absent timer, no systemd or an unsupported fs is not an install failure).
|
|
97
|
+
if command -v systemctl >/dev/null 2>&1 && systemctl list-unit-files fstrim.timer >/dev/null 2>&1; then
|
|
98
|
+
if ! systemctl is-enabled fstrim.timer >/dev/null 2>&1; then # #5883: recorded only when this install enabled it, so uninstall leaves an owner's timer alone
|
|
99
|
+
if systemctl enable --now fstrim.timer >/dev/null 2>&1; then
|
|
100
|
+
grep -qx fstrim.timer /etc/computeshare/installed-by 2>/dev/null || echo fstrim.timer >> /etc/computeshare/installed-by
|
|
101
|
+
else
|
|
102
|
+
echo "note: could not enable fstrim.timer (the agent also runs fstrim itself)" >&2
|
|
103
|
+
fi
|
|
104
|
+
fi
|
|
105
|
+
fi
|