forgedock 1.61.1 → 1.62.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 +10 -1
- package/bin/engine/outcome-codes.mjs +4 -0
- package/bin/engine-cli.mjs +160 -18
- package/bin/env/env.mjs +6 -4
- package/bin/forge-home-check.mjs +91 -0
- package/bin/forgedock.mjs +50 -7
- package/bin/gc.mjs +2 -0
- package/bin/hooks/pre-tool-use.mjs +4 -0
- package/bin/journey.mjs +55 -5
- package/bin/lean/admission.mjs +16 -5
- package/bin/lean/batch-health.mjs +55 -16
- package/bin/lean/batch-health.test.mjs +67 -1
- package/bin/lean/batch.mjs +8 -0
- package/bin/lean/batch.test.mjs +5 -0
- package/bin/lean/ceiling.mjs +20 -0
- package/bin/lean/ceiling.test.mjs +33 -2
- package/bin/lean/ci-gate.mjs +240 -0
- package/bin/lean/ci-gate.test.mjs +227 -0
- package/bin/lean/ci-precheck.mjs +178 -0
- package/bin/lean/ci-precheck.test.mjs +149 -0
- package/bin/lean/conformance.mjs +118 -20
- package/bin/lean/conformance.test.mjs +193 -3
- package/bin/lean/context.test.mjs +7 -6
- package/bin/lean/dag.mjs +128 -0
- package/bin/lean/dag.test.mjs +131 -0
- package/bin/lean/decisions.mjs +5 -4
- package/bin/lean/decisions.test.mjs +11 -0
- package/bin/lean/delguard.mjs +84 -0
- package/bin/lean/delguard.test.mjs +104 -0
- package/bin/lean/depcache.mjs +125 -17
- package/bin/lean/depcache.test.mjs +111 -0
- package/bin/lean/design-gate.mjs +5 -5
- package/bin/lean/design-gate.test.mjs +14 -0
- package/bin/lean/effects.mjs +81 -7
- package/bin/lean/execution.mjs +81 -15
- package/bin/lean/execution.test.mjs +156 -3
- package/bin/lean/forgedock-lane-workflow.test.mjs +35 -0
- package/bin/lean/guardgate.mjs +30 -7
- package/bin/lean/guardgate.test.mjs +44 -1
- package/bin/lean/guards.test.mjs +1 -1
- package/bin/lean/heavy.test.mjs +87 -0
- package/bin/lean/hotarea.mjs +73 -0
- package/bin/lean/hotarea.test.mjs +73 -0
- package/bin/lean/issuewatch-reconcile.mjs +20 -1
- package/bin/lean/issuewatch-reconcile.test.mjs +30 -0
- package/bin/lean/lanecheck.mjs +27 -3
- package/bin/lean/lanecheck.test.mjs +47 -5
- package/bin/lean/laneconfine.mjs +83 -0
- package/bin/lean/laneconfine.test.mjs +113 -0
- package/bin/lean/lean.mjs +398 -91
- package/bin/lean/lean.test.mjs +792 -26
- package/bin/lean/live-reconcile.mjs +169 -0
- package/bin/lean/live-reconcile.test.mjs +176 -0
- package/bin/lean/orchestrate-envhold.test.mjs +245 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +39 -0
- package/bin/lean/orchestrate.mjs +207 -17
- package/bin/lean/outcomeevidence.mjs +104 -0
- package/bin/lean/outcomeevidence.test.mjs +78 -0
- package/bin/lean/page-capture.mjs +68 -0
- package/bin/lean/page-capture.test.mjs +44 -0
- package/bin/lean/pagegate.mjs +46 -7
- package/bin/lean/pagegate.test.mjs +66 -1
- package/bin/lean/postdeploy-check.mjs +18 -4
- package/bin/lean/postdeploy-check.test.mjs +32 -1
- package/bin/lean/prefilter.mjs +36 -4
- package/bin/lean/prefilter.test.mjs +31 -1
- package/bin/lean/preflight.mjs +22 -0
- package/bin/lean/preflight.test.mjs +19 -1
- package/bin/lean/probe.mjs +18 -0
- package/bin/lean/probe.test.mjs +40 -0
- package/bin/lean/prompts.mjs +41 -4
- package/bin/lean/recovery.test.mjs +20 -0
- package/bin/lean/recurrence.mjs +133 -0
- package/bin/lean/recurrence.test.mjs +99 -0
- package/bin/lean/release-config.mjs +2 -1
- package/bin/lean/release-config.test.mjs +18 -0
- package/bin/lean/release-control.mjs +4 -2
- package/bin/lean/release-control.test.mjs +15 -0
- package/bin/lean/release-merge-hold.mjs +65 -0
- package/bin/lean/release-merge-hold.test.mjs +69 -0
- package/bin/lean/release-review.mjs +26 -9
- package/bin/lean/release-review.test.mjs +53 -0
- package/bin/lean/release-status.mjs +3 -1
- package/bin/lean/release-status.test.mjs +11 -0
- package/bin/lean/release.test.mjs +26 -1
- package/bin/lean/render.mjs +8 -7
- package/bin/lean/repro-output.test.mjs +45 -0
- package/bin/lean/routing.mjs +49 -0
- package/bin/lean/routing.test.mjs +54 -1
- package/bin/lean/run-issue-placement.test.mjs +30 -1
- package/bin/lean/sandbox-actions.mjs +121 -0
- package/bin/lean/sandbox-actions.test.mjs +94 -0
- package/bin/lean/sandbox-provider.contract.test.mjs +22 -1
- package/bin/lean/sandbox-remote.mjs +3 -1
- package/bin/lean/schedd-health.mjs +14 -2
- package/bin/lean/schedd-health.test.mjs +13 -0
- package/bin/lean/schedd.mjs +43 -17
- package/bin/lean/schedd.test.mjs +61 -1
- package/bin/lean/toolchain.mjs +16 -6
- package/bin/lean/toolplace.mjs +12 -0
- package/bin/lean/weakguard.mjs +105 -0
- package/bin/lean/weakguard.test.mjs +59 -0
- package/bin/lean/winspawn.mjs +61 -0
- package/bin/lean/winspawn.test.mjs +45 -0
- package/bin/lean/worktree.mjs +3 -1
- package/bin/lean/worktree.test.mjs +11 -0
- package/bin/pool/agent.mjs +215 -15
- package/bin/pool/cache-sweep.mjs +74 -0
- package/bin/pool/cli.mjs +11 -3
- package/bin/pool/docker.mjs +33 -2
- package/bin/pool/health.mjs +38 -0
- package/bin/pool/lane-tools.mjs +23 -4
- package/bin/pool/lane-tools.test.mjs +12 -1
- package/bin/pool/router.mjs +21 -3
- package/bin/runner.mjs +37 -0
- package/bin/splash-scene.mjs +356 -0
- package/bin/win-hide-children.mjs +114 -0
- package/commands/orchestrate.md +18 -27
- package/commands/review-pr-agents/infra.md +1 -0
- package/commands/review-pr-staging.md +2 -2
- package/docs/CONFIG.md +60 -3
- package/docs/OUTCOME-CODES.md +3 -0
- package/package.json +1 -1
- package/plugins/forgedock-splash/.claude-plugin/plugin.json +1 -1
- package/plugins/forgedock-splash/README.md +1 -1
- package/plugins/forgedock-splash/hooks/scene.ts +142 -8
- package/pool/README.md +6 -0
- package/pool/image/entrypoint.sh +1 -0
- package/scripts/acceptance-red-green.sh +8 -3
- package/scripts/acceptance-red-green.test.sh +8 -0
- package/scripts/check-spec-size.sh +3 -1
- package/scripts/gen-splash-scene.mjs +24 -0
- package/scripts/review-staging-pre.sh +8 -3
- package/scripts/review-staging-pre.test.sh +2 -0
package/bin/config-schema.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export const TOP_LEVEL = [
|
|
|
13
13
|
"hygiene", "pipeline", "execution", "engine", "prod_watch", "selftest", "release", "issue_watch", "followups", "rollouts",
|
|
14
14
|
"post_deploy", "events", "lean", "stats", "verify", "ci", "env", "build", "decomposition", "services", "review", "devdocs",
|
|
15
15
|
"verification", "billing", "adaptive_scripts", "branding", "marketing", "acceptance_probe", "attribution", "autopilot",
|
|
16
|
-
"deploy", "design", "gate", "experiment", "learned", "maintenance", "milestones", "pattern_feeds", "topology", "validate",
|
|
16
|
+
"deploy", "design", "gate", "experiment", "learned", "maintenance", "milestones", "pattern_feeds", "topology", "validate", "outcome_evidence",
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
/** Sections whose direct children are a closed set: another child is an unknown key. */
|
|
@@ -23,6 +23,8 @@ export const CLOSED = {
|
|
|
23
23
|
"env.proxies": ["npm", "pypi", "apt", "git"],
|
|
24
24
|
// #5710 test engine. The one-level parser flattens these under `ci`, so every name is unique within `ci`.
|
|
25
25
|
"ci.tests": ["selection", "suites", "run_all", "ignore", "test_globs", "full_branches", "graduate_after", "graduate_min_failing", "shards", "shard_target_s", "quarantine", "quarantine_after", "quarantine_window_days", "recall_ledger"],
|
|
26
|
+
// #5760 CI budget gate (bin/lean/ci-gate.mjs). Flattened under `ci` too: monthly_minutes is the same key as #5278's ci.monthly_minutes.
|
|
27
|
+
"ci.budget": ["max_workflows", "max_ci_jobs", "monthly_minutes", "shared_regression_job"],
|
|
26
28
|
// #5712: the deploy stage engine (bin/lean/deploy-stages.mjs); the stage entries themselves are checked by validateEngine
|
|
27
29
|
"deploy.engine": ["enabled", "live_release_command", "stage_timeout_s", "colour", "services", "canary", "rollback", "stages"],
|
|
28
30
|
"deploy.engine.colour": ["active_command", "names"],
|
|
@@ -59,6 +61,13 @@ export const TYPES = {
|
|
|
59
61
|
"ci.tests.shard_target_s": "number",
|
|
60
62
|
"ci.tests.quarantine_after": "number",
|
|
61
63
|
"ci.tests.quarantine_window_days": "number",
|
|
64
|
+
"ci.budget.max_workflows": "number",
|
|
65
|
+
"ci.budget.max_ci_jobs": "number",
|
|
66
|
+
"ci.budget.monthly_minutes": "number",
|
|
67
|
+
"ci.budget.shared_regression_job": "scalar",
|
|
68
|
+
"execution.provider": { enum: ["local", "container", "remote", "pool", "actions"] }, // #5748
|
|
69
|
+
"execution.ci_reserve": "number",
|
|
70
|
+
"execution.job_limit": "number",
|
|
62
71
|
"engine.path": { enum: ["core", "full", "lean", "auto"] },
|
|
63
72
|
"deploy.engine.enabled": "bool",
|
|
64
73
|
"deploy.engine.stage_timeout_s": "number",
|
|
@@ -37,6 +37,7 @@ export const OUTCOME_CODES = Object.freeze({
|
|
|
37
37
|
BASE_CONFLICT: "base.conflict",
|
|
38
38
|
RATE_LIMITED: "rate_limited",
|
|
39
39
|
BACKEND_AUTH: "backend.auth", // forge#5168: the claude CLI login failed ("Failed to authenticate"); deferred under the account hold, never engine-error, never the breaker
|
|
40
|
+
BACKEND_CLI_FAILED: "backend.cli_failed", // forge#5762: the claude CLI exited 1 without reaching the API and it was no login failure; a transient retry, never the account hold
|
|
40
41
|
QUOTA_EXHAUSTED: "quota.exhausted", // forge#5236: no account has capacity (every login at its ceiling); deferred until the earliest reset, never backend.auth
|
|
41
42
|
HOST_BUSY: "host.busy",
|
|
42
43
|
GH_UNAVAILABLE: "gh.unavailable", // forge#4157: `gh` unreachable after retries during the --repo identity check; run deferred, nothing posted
|
|
@@ -104,6 +105,8 @@ export const OUTCOME_CODES = Object.freeze({
|
|
|
104
105
|
STRUCTURE_UNDECLARED_EDGE: "structure.undeclared_edge", // forge#4159: a workspace package.json edge the contract does not name
|
|
105
106
|
DOCS_STALE: "docs.stale", // the target repo's devdocs freshness rule still fails after one builder resume
|
|
106
107
|
MAINTENANCE_HOTSPOT_GROWTH: "maintenance.hotspot_growth", // forge#4195: an over-threshold file grew past growth_lines without hotspot-exempt
|
|
108
|
+
MAINTENANCE_COUNTER_GROWTH: "maintenance.counter_growth", // forge#5751: a forge.yaml recurrence.counters count grew without a "counter-ok: <name>" decision
|
|
109
|
+
RECURRENCE_DESIGN_MISSING: "recurrence.design_missing", // forge#5751: a recurring issue's design lane contract lacks why_failed, delete/replace and a measurable outcome
|
|
107
110
|
FOLLOWUP_UNAVAILABLE: "followup.unavailable",
|
|
108
111
|
MERGE_HEAD_MISMATCH: "merge.head_mismatch",
|
|
109
112
|
// refactor:split lane (forge#4211): deterministic refusals and the move proof; every one leaves no edit behind.
|
|
@@ -156,6 +159,7 @@ export function codeForRunnerError(err) {
|
|
|
156
159
|
if (err.usageLimit === true || (typeof err.resetAtEpochMs === "number" && Number.isFinite(err.resetAtEpochMs)))
|
|
157
160
|
return OUTCOME_CODES.RATE_LIMITED;
|
|
158
161
|
if (err.authFailure === true) return OUTCOME_CODES.BACKEND_AUTH; // forge#5168
|
|
162
|
+
if (err.cliFailed === true) return OUTCOME_CODES.BACKEND_CLI_FAILED; // forge#5762
|
|
159
163
|
switch (err.code) {
|
|
160
164
|
case "CLI_SPAWN_TRANSIENT":
|
|
161
165
|
return OUTCOME_CODES.INFRA_CLI_SPAWN_TRANSIENT;
|
package/bin/engine-cli.mjs
CHANGED
|
@@ -6,17 +6,19 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { validateForgeYaml, formatFinding } from "./config-schema.mjs";
|
|
8
8
|
import { parseDocsConfig } from "./lean/docsgate.mjs";
|
|
9
|
+
import { parseOutcomeEvidenceConfig } from "./lean/outcomeevidence.mjs";
|
|
9
10
|
import { parsePagesConfig, PAGE_RE, designHold } from "./lean/pagegate.mjs";
|
|
10
11
|
import { parseDesignConfig } from "./lean/design-gate.mjs";
|
|
11
12
|
import { execFileSync } from "node:child_process";
|
|
12
13
|
import { mapLimit } from "./lean/pmap.mjs";
|
|
13
14
|
import { execFile, spawn } from "node:child_process";
|
|
14
15
|
import { promisify } from "node:util";
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
15
17
|
const RECOVERING_LABEL = "workflow:recovering";
|
|
16
|
-
import { readdirSync, statSync, readFileSync } from "node:fs";
|
|
18
|
+
import { readdirSync, statSync, readFileSync, existsSync } from "node:fs";
|
|
17
19
|
import { fileURLToPath } from "node:url";
|
|
18
20
|
import { homedir, hostname, cpus } from "node:os";
|
|
19
|
-
import { localLaneCap } from "./lean/admission.mjs";
|
|
21
|
+
import { localLaneCap, ADMISSION_DEFAULTS } from "./lean/admission.mjs";
|
|
20
22
|
import { memAvailableMb } from "./lean/heavy.mjs";
|
|
21
23
|
import { liveOverload, formatOverload, formatHostLoad } from "./lean/hostload.mjs";
|
|
22
24
|
import { join, resolve as resolvePath } from "node:path";
|
|
@@ -26,6 +28,7 @@ import { decomposedSubissues, isDecomposedRecord, isTrustedActor, parseDependsOn
|
|
|
26
28
|
import { readLog, readLogFile, deriveState, runLogPath, migrateRunLogs, attachRunLog } from "./engine/runlog.mjs";
|
|
27
29
|
import { assertOpenCodeNativeRuntime } from "./runner.mjs";
|
|
28
30
|
import { parseForgeYaml } from "./forge-utils.mjs";
|
|
31
|
+
import { parseRecurrenceConfig } from "./lean/recurrence.mjs"; // #5751
|
|
29
32
|
import { makeEmitTelemetry } from "./engine/telemetry-seam.mjs";
|
|
30
33
|
import { makeEventEmitter, probeSweepEvents, experimentEvent } from "./engine/events.mjs";
|
|
31
34
|
import { readExperiment } from "./experiment.mjs";
|
|
@@ -36,13 +39,15 @@ import { normalizeKindModes } from "./lean/conformance.mjs";
|
|
|
36
39
|
import { parseEnforceDomains } from "./lean/review-trigger.mjs";
|
|
37
40
|
import { viewIssue } from "./lean/gh-assoc.mjs";
|
|
38
41
|
import { otherLaneOwner, clearLease } from "./lean/lanelock.mjs";
|
|
39
|
-
import { parseExecution,
|
|
42
|
+
import { parseExecution, placementNeeds, hostFallbackAllowed } from "./lean/execution.mjs";
|
|
40
43
|
import { openRotator, rotatorKind } from "./lean/rotator.mjs";
|
|
41
44
|
import { relayPrefetchCommands } from "./lean/relay.mjs";
|
|
42
45
|
import { parseCeilingBySize } from "./lean/ceiling.mjs";
|
|
43
46
|
import { parseTurnBudgets, formatTurnSummary, TURN_BUDGET_DEFAULTS } from "./lean/budget.mjs";
|
|
44
47
|
import { writeAtomic as writeResultAtomic } from "./lean/batch.mjs";
|
|
45
48
|
import { parseLightConfig, LIGHT_DEFAULTS } from "./lean/light.mjs";
|
|
49
|
+
import { parseCiBudget } from "./lean/ci-gate.mjs";
|
|
50
|
+
import { parseCiPrecheckConfig } from "./lean/ci-precheck.mjs";
|
|
46
51
|
import { OUTCOME_CODES } from "./engine/outcome-codes.mjs";
|
|
47
52
|
import { USER_ERRORS } from "./help-text.mjs";
|
|
48
53
|
import * as batchHealth from "./lean/batch-health.mjs";
|
|
@@ -384,7 +389,7 @@ function readLeanSetting(key, cwd = process.cwd()) {
|
|
|
384
389
|
export function liveLaneCap(globalParallel, { cfg = readAdmission(), host = { cores: () => cpus().length, memAvailableMb } } = {}) {
|
|
385
390
|
return () => {
|
|
386
391
|
let derived = null;
|
|
387
|
-
try { derived = localLaneCap({ cfg, cores: host.cores(), memAvailableMb: host.memAvailableMb() }); } catch { derived = null; }
|
|
392
|
+
try { derived = localLaneCap({ cfg, cores: host.cores(), memAvailableMb: host.memAvailableMb(), rampingMb: (() => { try { return host.rampingMb?.(cfg?.ramp_s ?? ADMISSION_DEFAULTS.ramp_s) ?? 0; } catch { return 0; } })() }); } catch { derived = null; }
|
|
388
393
|
return derived === null ? globalParallel : globalParallel === null ? derived : Math.min(globalParallel, derived);
|
|
389
394
|
};
|
|
390
395
|
}
|
|
@@ -398,6 +403,7 @@ export function readAdmission(cwd = process.cwd()) {
|
|
|
398
403
|
min_free_mem_mb: num(e.min_free_mem_mb ?? e.admission_min_free_mem_mb), min_free_tmp_mb: num(e.min_free_tmp_mb ?? e.admission_min_free_tmp_mb),
|
|
399
404
|
max_load_per_core: num(e.max_load_per_core ?? e.admission_max_load_per_core),
|
|
400
405
|
lane_cpu_reservation: pos(e.lane_cpu_reservation ?? e.admission_lane_cpu_reservation), lane_mem_mb: pos(e.lane_mem_mb ?? e.admission_lane_mem_mb),
|
|
406
|
+
ramp_s: pos(e.ramp_s ?? e.admission_ramp_s), max_new_per_ramp: num(e.max_new_per_ramp ?? e.admission_max_new_per_ramp), // #5845: 0 = no rate limit
|
|
401
407
|
overload_load_per_core: num(e.overload_load_per_core ?? e.admission_overload_load_per_core) }; // #5174: hostload.mjs overload hold
|
|
402
408
|
|
|
403
409
|
} catch { return {}; }
|
|
@@ -423,6 +429,7 @@ export function readHeavy(cwd = process.cwd()) {
|
|
|
423
429
|
* `engine.cli_busy_minutes` (default 45, #4405): extra silence allowed while the builder has a live heavy step or heavy-queue entry.
|
|
424
430
|
* #4390: `engine.context_ceiling_tokens` (default 120000 in runCore; 0 = off).
|
|
425
431
|
* #5346: `engine.context_ceiling_by_size` ("S=..,M=..,L=.."; a size without an entry uses context_ceiling_tokens).
|
|
432
|
+
* #5812: `engine.route_handoff_tokens` (default 40000 in runCore; 0 = always resume): a planning session above it is not resumed by the build, which starts from a digest.
|
|
426
433
|
* #4392: `engine.turn_budget_s|m|l` (implement turn budget per lane size; defaults 25/60/100, always returned; 0 = off).
|
|
427
434
|
*/
|
|
428
435
|
export function readCoreLimits(cwd = process.cwd()) {
|
|
@@ -439,6 +446,7 @@ export function readCoreLimits(cwd = process.cwd()) {
|
|
|
439
446
|
...(posNum(y.engine?.cli_busy_minutes) ? { cliBusyMinutes: posNum(y.engine.cli_busy_minutes) } : {}),
|
|
440
447
|
...(/^\d+$/.test(String(y.engine?.context_ceiling_tokens ?? "").trim()) ? { contextCeilingTokens: Number(y.engine.context_ceiling_tokens) } : {}),
|
|
441
448
|
...(parseCeilingBySize(y.engine) ? { contextCeilingBySize: parseCeilingBySize(y.engine) } : {}), // #5346
|
|
449
|
+
...(/^\d+$/.test(String(y.engine?.route_handoff_tokens ?? "").trim()) ? { routeHandoffTokens: Number(y.engine.route_handoff_tokens) } : {}), // #5812
|
|
442
450
|
turnBudgets: parseTurnBudgets(y.engine) ?? { ...TURN_BUDGET_DEFAULTS }, // #4392: lanes are budgeted by default
|
|
443
451
|
};
|
|
444
452
|
} catch { return { laneLimits: {}, turnBudgets: { ...TURN_BUDGET_DEFAULTS } }; }
|
|
@@ -496,6 +504,23 @@ export function readExecution(cwd = process.cwd()) {
|
|
|
496
504
|
return sec && typeof sec === "object" ? parseExecution(sec) : undefined;
|
|
497
505
|
} catch { return undefined; }
|
|
498
506
|
}
|
|
507
|
+
/** #5748: forge.yaml sets a valid `execution.mode` (even `local`): the explicit opt-out from the public-repo default. */
|
|
508
|
+
export function executionModeExplicit(cwd = process.cwd()) {
|
|
509
|
+
try { return ["local", "remote", "hybrid"].includes(String(parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.execution?.mode ?? "").trim()); } catch { return false; }
|
|
510
|
+
}
|
|
511
|
+
/** #5748: `exec` with the public-repo default (actions provider) applied; visibility is read once per repo and fails closed to private. */
|
|
512
|
+
const visibilityCache = new Map();
|
|
513
|
+
export async function withPublicDefault(exec, { repo, gh, deps = {}, cwd = process.cwd() } = {}) {
|
|
514
|
+
if (executionModeExplicit(cwd)) return exec;
|
|
515
|
+
const execMod = await import("./lean/execution.mjs");
|
|
516
|
+
const key = String(repo ?? "");
|
|
517
|
+
let isPublic = deps.repoPublic;
|
|
518
|
+
if (isPublic === undefined) {
|
|
519
|
+
if (!visibilityCache.has(key)) visibilityCache.set(key, await execMod.repoIsPublic({ repo, gh }));
|
|
520
|
+
isPublic = visibilityCache.get(key);
|
|
521
|
+
}
|
|
522
|
+
return execMod.resolveDefaultExecution(exec, { isPublic });
|
|
523
|
+
}
|
|
499
524
|
/**
|
|
500
525
|
* forge.yaml `learned.test_commands` (#4240): the repo's declared check commands, run by the core path in the lane
|
|
501
526
|
* worktree before the PR. A block list (` test_commands:` then ` - "cmd"` or ` - cmd`); parseForgeYaml reads
|
|
@@ -570,10 +595,17 @@ export function readPrecheckBudget(cwd = process.cwd()) {
|
|
|
570
595
|
return raw !== "" && Number.isFinite(n) && n >= 1 && n <= 120 ? n : undefined;
|
|
571
596
|
} catch { return undefined; }
|
|
572
597
|
}
|
|
573
|
-
/**
|
|
598
|
+
/** #5820: forge.yaml `lean.ci_precheck*` (flat keys) -> {mode, include, exclude, maxJobs}; null when none is set or unreadable. */
|
|
599
|
+
export function readCiPrecheck(cwd = process.cwd()) {
|
|
600
|
+
try {
|
|
601
|
+
const l = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.lean ?? {};
|
|
602
|
+
return Object.keys(l).some((k) => k.startsWith("ci_precheck")) ? parseCiPrecheckConfig(l) : null;
|
|
603
|
+
} catch { return null; }
|
|
604
|
+
}
|
|
605
|
+
/** runCore `precheck` option: {commands, maxMinutes, ci} from learned.test_commands, lean.precheck.max_minutes and lean.ci_precheck*; {} when none is set. */
|
|
574
606
|
function readPrecheckOptions(cwd = process.cwd()) {
|
|
575
|
-
const commands = readPrecheckCommands(cwd), maxMinutes = readPrecheckBudget(cwd);
|
|
576
|
-
return commands || maxMinutes ? { precheck: { ...(commands ? { commands } : {}), ...(maxMinutes ? { maxMinutes } : {}) } } : {};
|
|
607
|
+
const commands = readPrecheckCommands(cwd), maxMinutes = readPrecheckBudget(cwd), ci = readCiPrecheck(cwd);
|
|
608
|
+
return commands || maxMinutes || ci ? { precheck: { ...(commands ? { commands } : {}), ...(maxMinutes ? { maxMinutes } : {}), ...(ci ? { ci } : {}) } } : {};
|
|
577
609
|
}
|
|
578
610
|
/**
|
|
579
611
|
* forge.yaml `env` for core lanes (#4163): `env.toolchain` ("<pm>@<x.y.z>" or "off") and `env.setup` (a command run once
|
|
@@ -593,13 +625,16 @@ export function readEnvConfig(cwd = process.cwd()) {
|
|
|
593
625
|
const s = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
|
|
594
626
|
const rr = s(y?.topology?.route_reachability); // #5087: repo-supplied command: exits non-zero when the ingress does not deliver the added route paths (args) to their service
|
|
595
627
|
const dc = parseDocsConfig(y?.docs); // #5419: forge.yaml docs: (off unless required_for is set)
|
|
628
|
+
const oe = parseOutcomeEvidenceConfig(y?.outcome_evidence); // #5752: forge.yaml outcome_evidence: (off unless paths declares an area)
|
|
629
|
+
const cb = ["max_workflows", "max_ci_jobs", "monthly_minutes", "shared_regression_job"].some((k) => y?.ci?.[k] !== undefined) ? parseCiBudget(y.ci) : null; // #5760: forge.yaml ci.budget (flattened into ci)
|
|
596
630
|
let appPages = false; // #5428: default-on trigger: the repo tracks Next app/**/page.* files
|
|
597
631
|
try { appPages = String(execFileSync("git", ["ls-files", "--", "*page.*"], { cwd, encoding: "utf8", timeout: 10000, stdio: ["ignore", "pipe", "ignore"] })).split("\n").some((f) => PAGE_RE.test(f)); } catch { /* not a git checkout: off */ }
|
|
598
632
|
const pg = parsePagesConfig(y?.pages, { hasAppPages: appPages }); // #5428: forge.yaml pages: (off for repos without pages)
|
|
633
|
+
const rc = y?.recurrence && typeof y.recurrence === "object" ? parseRecurrenceConfig({ ...y.recurrence, hot_areas: readYamlMap(cwd, "recurrence", "hot_areas"), counters: readYamlMap(cwd, "recurrence", "counters") }) : null; // #5751: forge.yaml recurrence: (absent: the engine defaults)
|
|
599
634
|
const dg = parseDesignConfig(y?.design); // #5330: forge.yaml design: (system always read; routes/gate opt in the design gate)
|
|
600
635
|
const kb = typeof e.sparse_max_kb === "string" && /^\d+$/.test(e.sparse_max_kb.trim()) ? Number(e.sparse_max_kb) : e.sparse_max_kb;
|
|
601
636
|
return { ...(s(e.toolchain) ? { toolchainOverride: s(e.toolchain) } : {}), ...(s(e.setup) ? { envSetup: s(e.setup) } : {}),
|
|
602
|
-
...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(s(y?.validate?.regenerate) ? { validateRegenerate: s(y.validate.regenerate) } : {}), ...(catalog.length ? { validateCatalogSources: catalog } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}), ...(dc ? { docsConfig: dc } : {}), ...(pg ? { pagesConfig: pg } : {}), ...(dg ? { designConfig: dg } : {}), ...(pp && Object.keys(pp).length ? { prodParity: pp } : {}) };
|
|
637
|
+
...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(s(y?.validate?.regenerate) ? { validateRegenerate: s(y.validate.regenerate) } : {}), ...(catalog.length ? { validateCatalogSources: catalog } : {}), ...(cf && Object.keys(cf).length ? { coupledFiles: cf } : {}), ...(rr ? { routeReachability: rr } : {}), ...(dc ? { docsConfig: dc } : {}), ...(oe ? { outcomeEvidenceConfig: oe } : {}), ...(cb ? { ciBudget: cb } : {}), ...(pg ? { pagesConfig: pg } : {}), ...(dg ? { designConfig: dg } : {}), ...(rc ? { recurrenceConfig: rc } : {}), ...(pp && Object.keys(pp).length ? { prodParity: pp } : {}) };
|
|
603
638
|
} catch { return {}; }
|
|
604
639
|
}
|
|
605
640
|
export const ENGINE_PATHS = ["core", "full", "lean", "auto"];
|
|
@@ -1000,8 +1035,9 @@ export async function runFromCli(argv, deps = {}) {
|
|
|
1000
1035
|
// #5542: placement. A lane already placed (--placement, a batch lane, --adopt, --recover) or forced local runs here; otherwise a
|
|
1001
1036
|
// remote or hybrid `execution:` hands the single issue to the same batch placement `orchestrate` uses.
|
|
1002
1037
|
if (enginePath !== "full") {
|
|
1003
|
-
const exec = deps.execution !== undefined ? deps.execution : readExecution();
|
|
1004
1038
|
const placed = placementWhere || argv.includes("--adopt") || recover || (deps.env ?? process.env).FORGEDOCK_BATCH_ID;
|
|
1039
|
+
const exec0 = deps.execution !== undefined ? deps.execution : readExecution();
|
|
1040
|
+
const exec = deps.execution === undefined && !placed && !argv.includes("--local") ? await withPublicDefault(exec0, { repo, gh: (a) => io.gh(a), deps }) : exec0; // #5748: no visibility lookup for a lane already placed
|
|
1005
1041
|
const wantsRemote = exec && (exec.mode === "remote" || (exec.mode === "hybrid" && Number.isInteger(exec.maxRemote) && exec.maxRemote >= 1));
|
|
1006
1042
|
if (argv.includes("--local")) console.log("placement: local (--local)");
|
|
1007
1043
|
else if (!placed && wantsRemote) {
|
|
@@ -1792,6 +1828,13 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1792
1828
|
const scheddMod = await import("./lean/schedd.mjs");
|
|
1793
1829
|
const kept = plan?.env ?? (resumeId ? null : daemon || callerEnv !== process.env ? scheddMod.batchEnv(callerEnv, readPinnedEnvConfig(plan?.cwd ?? callerCwd)) : null);
|
|
1794
1830
|
const env = kept ? scheddMod.mergeEnv(process.env, kept) : process.env;
|
|
1831
|
+
// #5806: a pinned env whose PATH cannot resolve gh/git/node left the batch in `phase: setup` with no error; fail here instead
|
|
1832
|
+
const probeEnv = deps.probeEnv !== undefined ? deps.probeEnv : (deps.leanIo || deps.leanModule || deps.laneScript) ? null : (await import("./lean/lanecheck.mjs")).probeBatchEnv;
|
|
1833
|
+
const envProbe = kept && probeEnv ? probeEnv(env) : null;
|
|
1834
|
+
if (envProbe && !envProbe.ok) {
|
|
1835
|
+
throw new Error(resumeId ? `batch ${resumeId} cannot resume: ${envProbe.detail}; fix its pin with forgedock orchestrate --set-env ${resumeId} PATH=<dirs holding gh, git and node>, then --resume ${resumeId}`
|
|
1836
|
+
: `batch not started: ${envProbe.detail}; run forgedock orchestrate from a shell where gh, git and node resolve (or adjust orchestration.path_exclude)`);
|
|
1837
|
+
}
|
|
1795
1838
|
const lane = flag(argv, "--lane");
|
|
1796
1839
|
const laneOverride = argv.includes("--lane-override");
|
|
1797
1840
|
const model = flag(argv, "--model");
|
|
@@ -1953,7 +1996,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1953
1996
|
return l.runOne(n, ln, ctx);
|
|
1954
1997
|
}, adopt: l.adopt });
|
|
1955
1998
|
const execMod = await import("./lean/execution.mjs");
|
|
1956
|
-
const exec = deps.execution !== undefined ? deps.execution : readExecution(cwd);
|
|
1999
|
+
const exec = deps.execution !== undefined ? deps.execution : await withPublicDefault(readExecution(cwd), { cwd, repo, gh: (a) => leanIo.gh(a, { cwd }), deps }); // #5748
|
|
1957
2000
|
execForNeeds = exec ?? null;
|
|
1958
2001
|
hybrid = exec?.mode === "hybrid" && Number.isInteger(exec.maxRemote) && exec.maxRemote >= 1;
|
|
1959
2002
|
let remoteStop = null; // #4612: the sandbox provider's checkpoint stop, used only when the cancel asks for it
|
|
@@ -1961,7 +2004,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1961
2004
|
// #4253: lanes run in sandboxes, ledger-tracked per lane, admitted against max_remote instead of the host cap.
|
|
1962
2005
|
let gitDir = null;
|
|
1963
2006
|
try { gitDir = resolvePath(cwd, String(await leanIo.git(["rev-parse", "--git-common-dir"], { cwd })).trim()); } catch { gitDir = null; }
|
|
1964
|
-
const provider = deps.sandboxProvider ?? execMod.providerByName(exec.provider, { batch, repo, cwd, image: exec.image, gitDir, script: laneScript, bin: deps.laneBin, exec, env, prefetch: (n) => prefetchOf.get(n) ?? [], ...(deps.sandboxFetch ? { fetchFn: deps.sandboxFetch } : {}) });
|
|
2007
|
+
const provider = deps.sandboxProvider ?? execMod.providerByName(exec.provider, { batch, repo, cwd, ...(deps.actionsApi ? { actionsApi: deps.actionsApi } : {}), image: exec.image, gitDir, script: laneScript, bin: deps.laneBin, exec, env, prefetch: (n) => prefetchOf.get(n) ?? [], ...(deps.sandboxFetch ? { fetchFn: deps.sandboxFetch } : {}) });
|
|
1965
2008
|
const { makeLedger } = await import("./lean/ledger.mjs");
|
|
1966
2009
|
const ledgerFor = deps.sandboxLedger ?? ((n) => makeLedger({ batch: batch.id, lane: `sandbox-${n}`, owner: `orch_${process.pid}`, issue: n }));
|
|
1967
2010
|
const bud = exec.budget ?? {};
|
|
@@ -2157,6 +2200,39 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2157
2200
|
const hostIo = await laneCheck.hostLaneIo({ env });
|
|
2158
2201
|
preflight = async () => (await laneCheck.runLaneChecks({ exec: execForNeeds, env, io: hostIo })).filter((c) => !c.ok);
|
|
2159
2202
|
}
|
|
2203
|
+
const { hostMissingTools } = await import("./lean/toolplace.mjs");
|
|
2204
|
+
const envHold = deps.envHold !== undefined ? deps.envHold : testDeps ? null : {
|
|
2205
|
+
version: () => scheddMod.readInstalledVersion() ?? ENGINE_VERSION,
|
|
2206
|
+
envFingerprint: () => batchMod.envFingerprint(batch.readPlan()?.env),
|
|
2207
|
+
missingTools: async (tools) => { const p = batch.readPlan()?.env, e = p ? scheddMod.mergeEnv(process.env, p) : env; return hostMissingTools(tools, { path: e.PATH ?? e.Path ?? "" }); },
|
|
2208
|
+
};
|
|
2209
|
+
// #4785: decisions and the frozen contract's validate commands too. #5824: one view per issue; the plan pass's view is
|
|
2210
|
+
// used once by the runner's first read (no second gh call), later reads (requeue, --add) see the live body.
|
|
2211
|
+
const planViews = new Map();
|
|
2212
|
+
const viewOf = async (n) => {
|
|
2213
|
+
const v = await viewIssue(leanIo.gh, repo, n, maint || registry || hybrid ? "title,body,labels,comments,author,milestone" : "title,body,comments,author,milestone");
|
|
2214
|
+
if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null);
|
|
2215
|
+
trustedOf.set(n, bodyTrusted(v));
|
|
2216
|
+
if (maint || registry || hybrid) labelsOf.set(n, (v.labels ?? []).map((x) => x.name));
|
|
2217
|
+
needsOf.set(n, placementNeeds(v, execForNeeds));
|
|
2218
|
+
if (execForNeeds?.relay) prefetchOf.set(n, relayPrefetchCommands(v, execForNeeds.relay));
|
|
2219
|
+
return v;
|
|
2220
|
+
};
|
|
2221
|
+
const readBody = async (n) => { const v = planViews.get(n); planViews.delete(n); return (v ?? await viewOf(n)).body; };
|
|
2222
|
+
// #5824: the dependency DAG is built in code and printed as the plan table at a fresh start; a resume keeps the planned one.
|
|
2223
|
+
const dagMod = await import("./lean/dag.mjs");
|
|
2224
|
+
let dag = plan?.dag ?? null;
|
|
2225
|
+
if (!resumeId && deps.planDag !== false) {
|
|
2226
|
+
try {
|
|
2227
|
+
const views = new Map();
|
|
2228
|
+
await (await import("./lean/pmap.mjs")).mapLimit(issues, 6, async (n) => {
|
|
2229
|
+
try { const v = await viewOf(n); planViews.set(n, v); views.set(n, dagMod.planView(v, { trusted: trustedOf.get(n) === true })); } catch { /* unreadable: no edges; the runner reads it again */ }
|
|
2230
|
+
});
|
|
2231
|
+
dag = dagMod.buildDag(issues, views, { exists: (p) => existsSync(join(cwd, p)) });
|
|
2232
|
+
for (const l of dagMod.formatPlan(issues, views, dag, { parallel, parallelFrom: flag(argv, "--parallel") != null ? "--parallel" : "default" })) sink.line(l);
|
|
2233
|
+
batch.writePlan({ ...batch.readPlan(), dag: { edges: dag.edges, overlaps: dag.overlaps } });
|
|
2234
|
+
} catch (e) { sink.line(`plan: n/a (${String(e?.message ?? e).split("\n")[0].slice(0, 160)})`); }
|
|
2235
|
+
}
|
|
2160
2236
|
let rows, childFields = null; // #4965: the host gh's accepted `issue list --json` fields, read once from its help
|
|
2161
2237
|
const healthCheck = (checkpoint) => batchHealth.runCheck({ batch, checkpoint, config: healthConf, repo, now: healthNow,
|
|
2162
2238
|
resolve: (cands) => batchHealth.resolvedOnGithub(cands, (a) => leanIo.gh(a), repo),
|
|
@@ -2164,6 +2240,8 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2164
2240
|
alert: (text, health) => batchHealth.deliverAlert({ text, batchId: batch.id, health, sink, gh: (a) => leanIo.gh(a), repo, config: healthConf, epics: epicsOf(argv), ...(deps.notify ? { notify: deps.notify } : {}) }) });
|
|
2165
2241
|
let healthTimers = { cancel: () => {} };
|
|
2166
2242
|
try { healthTimers = batchHealth.scheduleChecks({ batch, created: healthCreated, config: healthConf, now: healthNow, ...(deps.healthTimer ? { setTimer: deps.healthTimer.set, clearTimer: deps.healthTimer.clear } : {}), check: healthCheck }); } catch { /* health is advisory */ }
|
|
2243
|
+
let rampProbe = {};
|
|
2244
|
+
try { rampProbe = (deps.host ?? (await import("./lean/effects.mjs")).makeHostProbe()); } catch { rampProbe = {}; } // #5845: the live cap subtracts lanes still ramping
|
|
2167
2245
|
try {
|
|
2168
2246
|
rows = await orchestrate({
|
|
2169
2247
|
...(estimate ? { estimate } : {}),
|
|
@@ -2175,7 +2253,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2175
2253
|
...(autoMod.addsEpicChildren(autoChildren.mode) ? { getChildren: async () => ({ list: await autoMod.readChildList({ gh: (a) => leanIo.gh(a), repo, fields: childFields ??= await autoMod.hostListFields((a) => leanIo.gh(a)) }), elsewhere: autoMod.liveElsewhere({ batchMod, root, self: batch.id, repo }) }) } : {}),
|
|
2176
2254
|
issues, parallel, prefilter, resolveLane: laneOf, store: batch.store, getParallel: batch.readParallel, getAdded: batch.readAdded, getRequeued: batch.readRequeued, getCancelled: batch.readCancel, getHeld: batch.readHeld, expireHolds: batch.expireHolds, getHoldInfo: batch.readHoldInfo, getGates: batch.readGates, baseWait: baseWaits.size ? baseWaitOf(baseWaits, { io, leanIo, cwd }) : null, ...lanes,
|
|
2177
2255
|
breaker: orch.breaker, maxDeferrals: orch.maxDeferrals, ...(Number.isInteger(orch.transientRetries) ? { transientRetries: orch.transientRetries } : {}), ...(deps.pollMs ? { pollMs: deps.pollMs } : {}), ...budget, limits, identity, rotator, batchId: batch.id, drift, lifecycle, integration,
|
|
2178
|
-
...(registry ? { sched: { registry, batch: batch.id, repo, cap: liveLaneCap(orch.globalParallel ?? null, { cfg: readAdmission(cwd) }), exclusive: true }, priorityOf: async (n) => schedMod.priorityFromLabels(await labelNames(n)) } : {}),
|
|
2256
|
+
...(registry ? { sched: { registry, batch: batch.id, repo, cap: liveLaneCap(orch.globalParallel ?? null, { cfg: readAdmission(cwd), host: { cores: () => cpus().length, memAvailableMb, rampingMb: rampProbe.rampingMb } }), exclusive: true }, priorityOf: async (n) => schedMod.priorityFromLabels(await labelNames(n)) } : {}),
|
|
2179
2257
|
// #5174: hold new local admissions while loadavg/cores is above engine.overload_load_per_core (host-wide batches only)
|
|
2180
2258
|
...(overload ? { overload } : {}),
|
|
2181
2259
|
...(remote ? { remote } : {}),
|
|
@@ -2194,6 +2272,11 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2194
2272
|
dispatchCheck: deps.dispatchCheck !== undefined ? deps.dispatchCheck : makeDispatchCheck({ gh: (a) => leanIo.gh(a), repo, batchId: batch.id, owner: plan?.forced ? null : (n) => batchMod.dispatchOwner(root, repo, n, batch.id) }),
|
|
2195
2273
|
// #5204: the engine version is saved with the batch state, so a resume after an upgrade names it on each interrupted lane
|
|
2196
2274
|
version: ENGINE_VERSION,
|
|
2275
|
+
// #5805: engine/env-caused failures that would repeat are held and re-admitted on an install version change, a --set-env, or the
|
|
2276
|
+
// missing tool appearing on the lanes' PATH (the batch's pinned env over the daemon's); off under the test seams
|
|
2277
|
+
...(envHold ? { envHold } : {}),
|
|
2278
|
+
// #5755: one env issue per env.* signature; the affected product issues wait on it (off under the test seams)
|
|
2279
|
+
...((deps.envIssue !== undefined ? deps.envIssue : testDeps ? null : makeEnvIssue({ gh: (a) => leanIo.gh(a), repo })) ? { envIssue: deps.envIssue !== undefined ? deps.envIssue : makeEnvIssue({ gh: (a) => leanIo.gh(a), repo }) } : {}),
|
|
2197
2280
|
// #5204: an interrupted, requeued lane runs nothing until it is dispatched again: workflow:building comes off (best effort)
|
|
2198
2281
|
onInterrupted: deps.onInterrupted ?? (async (n) => leanIo.gh(["issue", "edit", String(n), "-R", repo, "--remove-label", "workflow:building"]).catch(() => {})),
|
|
2199
2282
|
// #4387: an out-of-set dependency labelled needs-human is not pulled into the batch
|
|
@@ -2227,9 +2310,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2227
2310
|
crossLane.push(e);
|
|
2228
2311
|
sink.line(`cross-lane: #${e.issue} (${e.lane}) depends on #${e.dependency} (${e.dependencyLane}); its fix will not be on ${e.lane}: re-milestone #${e.dependency} or wait for a milestone sync`);
|
|
2229
2312
|
},
|
|
2230
|
-
readBody:
|
|
2231
|
-
? async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,labels,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); labelsOf.set(n, (v.labels ?? []).map((x) => x.name)); needsOf.set(n, detectNeeds(placementText(v), execForNeeds)); if (execForNeeds?.relay) prefetchOf.set(n, relayPrefetchCommands(v, execForNeeds.relay)); return v.body; }
|
|
2232
|
-
: async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); needsOf.set(n, detectNeeds(placementText(v), execForNeeds)); if (execForNeeds?.relay) prefetchOf.set(n, relayPrefetchCommands(v, execForNeeds.relay)); return v.body; }, // #4785: decisions and the frozen contract's validate commands too
|
|
2313
|
+
readBody, logicalDeps: (n) => dagMod.logicalDepsOf(dag, n), // #5824: the plan's logical edges
|
|
2233
2314
|
onUpdate: (r) => sink.row(r),
|
|
2234
2315
|
});
|
|
2235
2316
|
} finally { for (const [sig, f] of Object.entries(handlers)) off(sig, f); healthTimers.cancel(); }
|
|
@@ -2266,6 +2347,11 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2266
2347
|
try { day = execBudget ? execBudget.dayTotals() : null; } catch { day = null; }
|
|
2267
2348
|
const sbxLine = formatSandboxSummary(rows, { budget: execConf?.budget ?? null, day });
|
|
2268
2349
|
if (sbxLine) report.push(sbxLine);
|
|
2350
|
+
let removedEdges = [];
|
|
2351
|
+
if (dag?.edges?.length) try { // #5824: planned edges an operator removed (body edited) before the batch ended
|
|
2352
|
+
removedEdges = await dagMod.falseHolds(dag, async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,author"); return dagMod.declaredDeps(n, { body: v.body, trusted: bodyTrusted(v) }); });
|
|
2353
|
+
report.push(dagMod.formatFalseHolds(dag, removedEdges));
|
|
2354
|
+
} catch { report.push("false holds: n/a"); }
|
|
2269
2355
|
if (crossLane.length) report.push(`cross-lane edges: ${crossLane.map((e) => `#${e.issue} (${e.lane}) → #${e.dependency} (${e.dependencyLane})`).join(", ")}`);
|
|
2270
2356
|
if (rows.some((r) => r.outcome === "held")) report.push(`held issues stay pending: forgedock orchestrate --resume ${batch.id}`);
|
|
2271
2357
|
report.push(formatReclaimed(reclaimed));
|
|
@@ -2278,7 +2364,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2278
2364
|
// #4917: a batch with any pending issue is not finished: no report, so a resume or the daemon picks it up
|
|
2279
2365
|
let unfinished = false;
|
|
2280
2366
|
try { unfinished = (batch.pendingIssues().length > 0 || batch.unrunAdds().length > 0 || batch.unrunRequeues().length > 0) && !batch.readCancel(); } catch { unfinished = false; } // a cancel ends the batch for good
|
|
2281
|
-
if (!unfinished) try { batch.writeReport({ rows, crossLane, ok, reclaimed, report: report.join("\n") }); } catch { /* the report is a cache of the rows */ }
|
|
2367
|
+
if (!unfinished) try { batch.writeReport({ rows, crossLane, ok, reclaimed, ...(dag?.edges ? { dag: { planned: dag.edges.length, falseHolds: removedEdges } } : {}), report: report.join("\n") }); } catch { /* the report is a cache of the rows */ }
|
|
2282
2368
|
try { await healthCheck("end"); } catch { /* #5167: health never fails a batch */ }
|
|
2283
2369
|
return { rows, crossLane, batch: batch.id, reclaimed, ok };
|
|
2284
2370
|
}
|
|
@@ -2434,6 +2520,35 @@ export function makeMarkRecovering({ gh, repo }) {
|
|
|
2434
2520
|
};
|
|
2435
2521
|
}
|
|
2436
2522
|
|
|
2523
|
+
/**
|
|
2524
|
+
* #5755: one env issue per failure signature. `ensure` finds the open issue carrying the signature marker (or files it) and comments the
|
|
2525
|
+
* newly affected product issues, which get `waiting-dependency`; `isClosed` reads its state. Best effort per call; ensure returns the number or throws.
|
|
2526
|
+
*/
|
|
2527
|
+
export function makeEnvIssue({ gh, repo }) {
|
|
2528
|
+
const mark = (sig) => `<!-- FORGE:ENVSIG ${createHash("sha256").update(sig).digest("hex").slice(0, 16)} -->`;
|
|
2529
|
+
const list = (issues) => issues.map((i) => `#${i}`).join(", ");
|
|
2530
|
+
return {
|
|
2531
|
+
ensure: async ({ sig, code, issues = [], evidence = "", number = null }) => {
|
|
2532
|
+
const m = mark(sig);
|
|
2533
|
+
let no = Number.isInteger(number) ? number : null;
|
|
2534
|
+
if (!no) {
|
|
2535
|
+
const found = JSON.parse(await gh(["issue", "list", "-R", repo, "--state", "open", "--search", `"${m.slice(5, -4).trim()}" in:body`, "--json", "number,body", "--limit", "10"]) || "[]");
|
|
2536
|
+
no = found.find((x) => String(x.body ?? "").includes(m))?.number ?? null;
|
|
2537
|
+
}
|
|
2538
|
+
if (!no) {
|
|
2539
|
+
const out = await gh(["issue", "create", "-R", repo, "--title", `fix(env): ${code} (${sig.split("|")[1] ?? ""})`.slice(0, 120),
|
|
2540
|
+
"--body", `Environment defect \`${code}\` (engine/env, not product code). Affected: ${list(issues)}. They wait on this issue and are requeued when it closes.\n\n\`\`\`\n${String(evidence).slice(0, 3000)}\n\`\`\`\n\n${m}`]);
|
|
2541
|
+
no = Number(/\/issues\/(\d+)/.exec(String(out))?.[1]) || null;
|
|
2542
|
+
} else {
|
|
2543
|
+
try { await gh(["issue", "comment", String(no), "-R", repo, "--body", `Affects ${list(issues)}.`]); } catch { /* best effort */ }
|
|
2544
|
+
}
|
|
2545
|
+
for (const i of issues) { try { await gh(["issue", "edit", String(i), "-R", repo, "--add-label", "waiting-dependency"]); } catch { /* best effort */ } }
|
|
2546
|
+
return no;
|
|
2547
|
+
},
|
|
2548
|
+
isClosed: async (number) => JSON.parse(await gh(["issue", "view", String(number), "-R", repo, "--json", "state"]))?.state === "CLOSED",
|
|
2549
|
+
};
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2437
2552
|
/** The batch report's "reclaimed" line (#4183). */
|
|
2438
2553
|
export function formatReclaimed(r) {
|
|
2439
2554
|
if (!r?.enabled) return "reclaimed: off (hygiene.auto_gc: false)";
|
|
@@ -2513,7 +2628,11 @@ export async function scheddFromCli(argv, deps = {}) {
|
|
|
2513
2628
|
const health = await import("./lean/schedd-health.mjs");
|
|
2514
2629
|
const i = argv.indexOf("--stall-sec"), sec = i >= 0 ? Number(argv[i + 1]) : NaN;
|
|
2515
2630
|
if (i >= 0 && !(sec > 0)) throw new Error("usage: forgedock schedd watchdog [--stall-sec N]");
|
|
2516
|
-
|
|
2631
|
+
// #5806: a down daemon with unfinished daemon batches (pending, no report/cancel, breaker not tripped) is started again (systemd unit when installed, else a detached daemon)
|
|
2632
|
+
const bm = await import("./lean/batch.mjs");
|
|
2633
|
+
const unfinished = () => { const root = bm.batchRoot(); return bm.listBatches(root).filter((id) => { try { const b = bm.openBatch(root, id); const br = b.store.peek()?.breaker; return !!b.readPlan()?.daemon && !b.isTerminal() && b.pendingIssues().length > 0 && !(br && !br.transport); } catch { return false; } }); };
|
|
2634
|
+
const start = () => { if (schedd.unitState() === null) schedd.defaultSpawn({ dir }); else schedd.startUnit(); };
|
|
2635
|
+
return (deps.watchdog ?? health.watchdog)({ dir, ...(sec > 0 ? { stallMs: sec * 1000 } : {}), unfinished, start });
|
|
2517
2636
|
}
|
|
2518
2637
|
if (argv.length) throw new Error("usage: forgedock schedd [status | watchdog [--stall-sec N]]");
|
|
2519
2638
|
(deps.renice ?? (await import("./lean/schedd-health.mjs")).bestEffortRenice)(); // #4780: lanes must not starve the scheduler
|
|
@@ -2971,6 +3090,26 @@ export function readIntegration(cwd = process.cwd()) {
|
|
|
2971
3090
|
return import("./lean/integration.mjs").then((m) => m.parseIntegration(ci));
|
|
2972
3091
|
}
|
|
2973
3092
|
|
|
3093
|
+
/** #5704: run the live reconcile and print its rows and summary. */
|
|
3094
|
+
async function runLiveReconcile({ repo, io, dryRun, spawn }) {
|
|
3095
|
+
const { reconcileLive, formatReconcileSummary } = await import("./lean/live-reconcile.mjs");
|
|
3096
|
+
const res = await reconcileLive({ repo, io, cwd: process.cwd(), dryRun, ...(spawn ? { spawn } : {}) });
|
|
3097
|
+
for (const r of res.rows) console.log(`#${r.issue} → ${r.outcome}${r.detail ? ` (${r.detail})` : ""}`);
|
|
3098
|
+
console.log(formatReconcileSummary(res) || "live reconcile: no merged issues open");
|
|
3099
|
+
return res;
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
/** #5704: `forgedock close reconcile [--repo R] [--dry-run]`: reconcile merged issues against the live SHA (fail closed when unknown). */
|
|
3103
|
+
export async function closeReconcileFromCli(argv, deps = {}) {
|
|
3104
|
+
const [sub] = argv.filter((a, i) => !a.startsWith("--") && argv[i - 1] !== "--repo");
|
|
3105
|
+
if (sub !== "reconcile") throw new Error("usage: forgedock close reconcile [--repo owner/name] [--dry-run]");
|
|
3106
|
+
const io = deps.io ?? makeIo();
|
|
3107
|
+
const repo = flag(argv, "--repo") ?? (await resolveDefaultRepo(io));
|
|
3108
|
+
if (!repo) throw new Error("close reconcile needs the repo: pass --repo or run inside a checkout with a GitHub remote");
|
|
3109
|
+
const leanIo = deps.leanIo ?? (await import("./lean/effects.mjs")).makeLeanIo({ repo });
|
|
3110
|
+
return runLiveReconcile({ repo, io: leanIo, dryRun: argv.includes("--dry-run"), spawn: deps.spawn });
|
|
3111
|
+
}
|
|
3112
|
+
|
|
2974
3113
|
export async function probeFromCli(argv, deps = {}) {
|
|
2975
3114
|
const valued = ["--repo", "--limit"];
|
|
2976
3115
|
const issues = [];
|
|
@@ -2996,7 +3135,10 @@ export async function probeFromCli(argv, deps = {}) {
|
|
|
2996
3135
|
console.log(formatParkedSweepSummary(parkedRows) || "parked: nothing released");
|
|
2997
3136
|
const orphanRows = await sweepOrphanPrFollowups({ repo, io: leanIo, dryRun: argv.includes("--dry-run") }); // #5505
|
|
2998
3137
|
console.log((await import("./lean/orphan-pr.mjs")).formatOrphanSummary(orphanRows) || "orphan PRs: none");
|
|
2999
|
-
|
|
3138
|
+
// #5704: the post-release pass: merged issues now in the live SHA are checked, then closed or reported
|
|
3139
|
+
let live = null;
|
|
3140
|
+
try { live = await runLiveReconcile({ repo, io: leanIo, dryRun: argv.includes("--dry-run"), spawn: deps.spawn }); } catch (e) { console.log(`live reconcile: error (${String(e?.message ?? e).split("\n")[0]})`); }
|
|
3141
|
+
return { rows, parkedRows, live };
|
|
3000
3142
|
}
|
|
3001
3143
|
const { sweepProbes, formatProbeSummary } = await import("./lean/probe.mjs");
|
|
3002
3144
|
const rows = await sweepProbes({ repo, cwd: process.cwd(), io: leanIo, issues: [...new Set(issues)], limit, dryRun: argv.includes("--dry-run"), onResult: probeEventSink(repo), ...(deps.spawn ? { spawn: deps.spawn } : {}) });
|
package/bin/env/env.mjs
CHANGED
|
@@ -136,9 +136,10 @@ const STALE_TMP_MS = 6 * 3600 * 1000;
|
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
138
|
* Local-directory store. `linkTree(src, dst)` and `readOnly(dir)` are depcache's (hardlink, copy on EXDEV, writable
|
|
139
|
-
* copies of package-manager state files).
|
|
139
|
+
* copies of package-manager state files). `safeRm(path, protect)` is depcache's too (#5819: never through a link, never a worktree
|
|
140
|
+
* path outside a dependency tree); without it a plain recursive rm.
|
|
140
141
|
*/
|
|
141
|
-
export function makeEnvStore({ root = envRoot(), fs = nodeFs, now = () => Date.now(), pid = process.pid, linkTree, readOnly } = {}) {
|
|
142
|
+
export function makeEnvStore({ root = envRoot(), fs = nodeFs, now = () => Date.now(), pid = process.pid, linkTree, readOnly, safeRm = null } = {}) {
|
|
142
143
|
const dirOf = (key) => { if (!KEY_RE.test(String(key))) throw new Error(`invalid env key ${JSON.stringify(key)}`); return join(root, key); };
|
|
143
144
|
const present = (p) => { try { fs.lstatSync(p); return true; } catch { return false; } };
|
|
144
145
|
const names = (d) => { try { return fs.readdirSync(d); } catch { return []; } };
|
|
@@ -191,6 +192,7 @@ export function makeEnvStore({ root = envRoot(), fs = nodeFs, now = () => Date.n
|
|
|
191
192
|
const t0 = now(), man = manifest(key);
|
|
192
193
|
if (!man || !Array.isArray(man.trees) || !man.trees.length) return null;
|
|
193
194
|
if (man.trees.some((t) => present(join(wt, t)))) return null;
|
|
195
|
+
if (man.trees.some((t) => !String(t).split("/").some((x) => x === "node_modules" || x === ".venv"))) return null; // #5819: only dependency trees enter (or leave) a worktree
|
|
194
196
|
if (man.prefix !== wt) {
|
|
195
197
|
// The trees name man.prefix in absolute paths: it must resolve to this worktree.
|
|
196
198
|
if (!prefix || prefix !== man.prefix) return null;
|
|
@@ -206,7 +208,7 @@ export function makeEnvStore({ root = envRoot(), fs = nodeFs, now = () => Date.n
|
|
|
206
208
|
const dir = dirOf(key);
|
|
207
209
|
const dev = (p) => { try { return fs.statSync(p).dev; } catch { return undefined; } };
|
|
208
210
|
const plan = planClaim({ storeDev: dev(dir), worktreeDev: dev(wt), ready: readyIds(key).length });
|
|
209
|
-
const undo = () => { for (const t of man.trees) { try { fs.rmSync(join(wt, t), { recursive: true, force: true }); } catch { /* best effort */ } } };
|
|
211
|
+
const undo = () => { for (const t of man.trees) { try { if (safeRm) safeRm(join(wt, t), wt); else fs.rmSync(join(wt, t), { recursive: true, force: true }); } catch { /* best effort */ } } };
|
|
210
212
|
if (plan.mode === "rename") {
|
|
211
213
|
for (const id of readyIds(key)) {
|
|
212
214
|
const mine = join(dir, `.claim-${pid}-${id}`);
|
|
@@ -287,7 +289,7 @@ export async function claimForLane({ wt, deps, fs = nodeFs, env = process.env, n
|
|
|
287
289
|
const t0 = now();
|
|
288
290
|
const desc = await describeEnv({ wt, deps, fs, laneTools: String(env.FORGE_ENV_LANE_TOOLS ?? "").split(",").filter(Boolean), image: env.FORGE_ENV_IMAGE ?? "" });
|
|
289
291
|
if (!desc.components.length) return null;
|
|
290
|
-
const store = makeEnvStore({ root: envRoot(env), fs, now, linkTree: deps.linkTree, readOnly: deps.readOnly });
|
|
292
|
+
const store = makeEnvStore({ root: envRoot(env), fs, now, linkTree: deps.linkTree, readOnly: deps.readOnly, safeRm: deps.safeRm });
|
|
291
293
|
const got = store.claim({ key: desc.key, wt, prefix: String(env.FORGE_ENV_PREFIX ?? "").trim() || null });
|
|
292
294
|
return got ? { key: desc.key, mode: got.mode, ms: now() - t0 } : null;
|
|
293
295
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
/**
|
|
4
|
+
* Stale FORGE_HOME detection (#5796).
|
|
5
|
+
*
|
|
6
|
+
* `FORGE_HOME` is a legacy variable: current installs never export it, but `scripts/lib/forge-resolve.sh`
|
|
7
|
+
* still ranks it *above* the install symlink and `~/.forge`. A value left over from an old dev checkout
|
|
8
|
+
* therefore silently wins, so specs and scripts run from a tree that can be dozens of versions behind the CLI.
|
|
9
|
+
* Doctor used to report any set value as ✔.
|
|
10
|
+
*
|
|
11
|
+
* `assessForgeHome` classifies the value against the running install. On Windows the value usually lives in
|
|
12
|
+
* the user environment (HKCU\Environment), which the shell-profile cleanup in `uninstall` never touched, so
|
|
13
|
+
* this module also reads and clears that.
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
16
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
17
|
+
import { spawnSync } from "node:child_process";
|
|
18
|
+
|
|
19
|
+
const norm = (p, real) => {
|
|
20
|
+
try { p = real(resolve(p)); } catch { p = resolve(p); }
|
|
21
|
+
return process.platform === "win32" ? p.toLowerCase() : p;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param {object} o
|
|
26
|
+
* @param {string|undefined} o.value FORGE_HOME as seen by this process
|
|
27
|
+
* @param {string} o.sourceDir the running install's root
|
|
28
|
+
* @param {string} o.sourceVersion the running install's version
|
|
29
|
+
* @param {string} [o.persistedHome] ~/.forge
|
|
30
|
+
* @returns {{ state: "unset"|"current"|"missing"|"not-forgedock"|"stale"|"same-version", version?: string }}
|
|
31
|
+
*/
|
|
32
|
+
export function assessForgeHome({ value, sourceDir, sourceVersion, persistedHome,
|
|
33
|
+
exists = existsSync, read = (p) => readFileSync(p, "utf8"), real = realpathSync }) {
|
|
34
|
+
if (!value) return { state: "unset" };
|
|
35
|
+
const v = norm(value, real);
|
|
36
|
+
if (v === norm(sourceDir, real) || (persistedHome && v === norm(persistedHome, real))) return { state: "current" };
|
|
37
|
+
if (!exists(value)) return { state: "missing" };
|
|
38
|
+
let pkg;
|
|
39
|
+
try { pkg = JSON.parse(read(join(value, "package.json"))); } catch { pkg = null; }
|
|
40
|
+
if (!pkg || pkg.name !== "forgedock") {
|
|
41
|
+
// ~/.forge-style persisted homes carry a bare `version` file instead of package.json
|
|
42
|
+
try { const ver = read(join(value, "version")).trim(); if (ver) return ver === sourceVersion ? { state: "same-version", version: ver } : { state: "stale", version: ver }; } catch { /* not a toolset */ }
|
|
43
|
+
return { state: "not-forgedock" };
|
|
44
|
+
}
|
|
45
|
+
const version = String(pkg.version ?? "");
|
|
46
|
+
return version && version === sourceVersion ? { state: "same-version", version } : { state: "stale", version: version || "unknown" };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Which tree a registered hook script lives in: 'current' when it sits under the running install
|
|
51
|
+
* or the persisted ~/.forge, 'foreign' for any other (e.g. an old checkout that still exists on disk).
|
|
52
|
+
* Segment-wise containment, so `src-old` is not inside `src`.
|
|
53
|
+
*/
|
|
54
|
+
export function hookScriptTree({ scriptPath, sourceDir, persistedHome, real = realpathSync }) {
|
|
55
|
+
const s = norm(scriptPath, real);
|
|
56
|
+
const inside = (root) => {
|
|
57
|
+
if (!root) return false;
|
|
58
|
+
const rel = relative(norm(root, real), s);
|
|
59
|
+
return rel === "" || (!rel.startsWith("..") && !isAbsolute(rel));
|
|
60
|
+
};
|
|
61
|
+
return inside(sourceDir) || inside(persistedHome) ? "current" : "foreign";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** True when the assessment means FORGE_HOME points somewhere other than the running install's toolset. */
|
|
65
|
+
export const isProblem = (a) => ["missing", "not-forgedock", "stale"].includes(a.state);
|
|
66
|
+
|
|
67
|
+
/** Human-readable reason for a problem state. */
|
|
68
|
+
export function describe(a, value, sourceVersion) {
|
|
69
|
+
if (a.state === "missing") return `points at "${value}", which does not exist`;
|
|
70
|
+
if (a.state === "not-forgedock") return `points at "${value}", which is not a ForgeDock toolset`;
|
|
71
|
+
if (a.state === "stale") return `points at "${value}" (v${a.version}) but the running install is v${sourceVersion} — scripts resolve FORGE_HOME before ~/.forge, so the old tree wins`;
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Windows: FORGE_HOME stored in the user environment (HKCU\Environment), or null. */
|
|
76
|
+
export function readUserForgeHomeWin({ run = spawnSync } = {}) {
|
|
77
|
+
const r = run("reg", ["query", "HKCU\\Environment", "/v", "FORGE_HOME"], { encoding: "utf8", windowsHide: true });
|
|
78
|
+
if (r.status !== 0) return null;
|
|
79
|
+
const m = /FORGE_HOME\s+REG_(?:EXPAND_)?SZ\s+(.*)$/m.exec(r.stdout ?? "");
|
|
80
|
+
return m ? m[1].trim() : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Windows: delete FORGE_HOME from the user environment. Returns true on success. */
|
|
84
|
+
export function clearUserForgeHomeWin({ run = spawnSync } = {}) {
|
|
85
|
+
const r = run("reg", ["delete", "HKCU\\Environment", "/v", "FORGE_HOME", "/f"], { encoding: "utf8", windowsHide: true });
|
|
86
|
+
if (r.status !== 0) return false;
|
|
87
|
+
// Broadcast WM_SETTINGCHANGE so new shells pick it up without a logoff; best-effort.
|
|
88
|
+
run("powershell", ["-NoProfile", "-NonInteractive", "-Command",
|
|
89
|
+
"[Environment]::SetEnvironmentVariable('FORGE_HOME', $null, 'User')"], { encoding: "utf8", windowsHide: true, timeout: 15000 });
|
|
90
|
+
return true;
|
|
91
|
+
}
|