forgedock 1.59.1 → 1.60.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/engine/outcome-codes.mjs +3 -3
- package/bin/engine-cli.mjs +50 -10
- package/bin/labels.json +5 -0
- package/bin/lean/batch.mjs +21 -2
- package/bin/lean/batch.test.mjs +116 -1
- package/bin/lean/conformance.mjs +12 -5
- package/bin/lean/conformance.test.mjs +30 -2
- package/bin/lean/depcache.mjs +34 -15
- package/bin/lean/depcache.test.mjs +100 -1
- package/bin/lean/design-gate.mjs +15 -10
- package/bin/lean/design-gate.test.mjs +21 -0
- package/bin/lean/effects.mjs +18 -2
- package/bin/lean/execution.mjs +23 -5
- package/bin/lean/execution.test.mjs +81 -1
- package/bin/lean/gatewatch.test.mjs +5 -5
- package/bin/lean/issuewatch-triage.mjs +68 -0
- package/bin/lean/issuewatch-triage.test.mjs +98 -0
- package/bin/lean/issuewatch.mjs +34 -6
- package/bin/lean/issuewatch.test.mjs +11 -0
- package/bin/lean/lanelock.mjs +5 -4
- package/bin/lean/lean.mjs +123 -17
- package/bin/lean/lean.test.mjs +154 -6
- package/bin/lean/orchestrate-cancel.test.mjs +33 -0
- package/bin/lean/orchestrate-hostfallback.test.mjs +41 -0
- package/bin/lean/orchestrate-recovering.test.mjs +42 -0
- package/bin/lean/orchestrate.mjs +23 -10
- package/bin/lean/pagegate.mjs +50 -12
- package/bin/lean/pagegate.test.mjs +38 -1
- package/bin/lean/phaseledger.mjs +65 -2
- package/bin/lean/phaseledger.test.mjs +70 -2
- package/bin/lean/preflight.mjs +5 -2
- package/bin/lean/preflight.test.mjs +7 -0
- package/bin/lean/prompts.mjs +2 -1
- package/bin/lean/recovery.test.mjs +11 -6
- package/bin/lean/release-classify.mjs +143 -0
- package/bin/lean/release-classify.test.mjs +130 -0
- package/bin/lean/release-conductor.mjs +163 -0
- package/bin/lean/release-conductor.test.mjs +194 -0
- package/bin/lean/release-config.mjs +60 -8
- package/bin/lean/release-config.test.mjs +43 -1
- package/bin/lean/release-control.mjs +22 -5
- package/bin/lean/release-control.test.mjs +22 -0
- package/bin/lean/release-credentials.mjs +40 -0
- package/bin/lean/release-credentials.test.mjs +42 -0
- package/bin/lean/release-deploy.mjs +3 -3
- package/bin/lean/release-deploy.test.mjs +8 -0
- package/bin/lean/release-docs.test.mjs +93 -0
- package/bin/lean/release-fence.mjs +2 -0
- package/bin/lean/release-gate.mjs +88 -0
- package/bin/lean/release-gate.test.mjs +116 -0
- package/bin/lean/release-gates.mjs +5 -1
- package/bin/lean/release-ledger.mjs +47 -1
- package/bin/lean/release-ledger.test.mjs +33 -1
- package/bin/lean/release-mergeback.mjs +148 -0
- package/bin/lean/release-mergeback.test.mjs +129 -0
- package/bin/lean/release-p0.mjs +193 -0
- package/bin/lean/release-p0.test.mjs +127 -0
- package/bin/lean/release-plan.mjs +267 -0
- package/bin/lean/release-plan.test.mjs +202 -0
- package/bin/lean/release-preflight.mjs +16 -0
- package/bin/lean/release-regate.mjs +141 -0
- package/bin/lean/release-regate.test.mjs +149 -0
- package/bin/lean/release-review.mjs +5 -3
- package/bin/lean/release-rollback.mjs +277 -0
- package/bin/lean/release-rollback.test.mjs +245 -0
- package/bin/lean/release-snapshot.mjs +48 -9
- package/bin/lean/release-snapshot.test.mjs +43 -1
- package/bin/lean/release-start.mjs +164 -0
- package/bin/lean/release-start.test.mjs +171 -0
- package/bin/lean/release-status.mjs +6 -2
- package/bin/lean/release-train.mjs +159 -0
- package/bin/lean/release-train.test.mjs +139 -0
- package/bin/lean/release.mjs +127 -5
- package/bin/lean/release.test.mjs +80 -0
- package/bin/lean/sandbox-remote.mjs +2 -0
- package/bin/lean/schedd-load.test.mjs +82 -0
- package/bin/lean/schedd.mjs +67 -31
- package/bin/lean/schedd.test.mjs +80 -1
- package/bin/lean/validate-catalog.mjs +94 -0
- package/bin/lean/validate-catalog.test.mjs +42 -0
- package/bin/pool/agent.mjs +4 -1
- package/bin/pool/lane-tools.mjs +115 -0
- package/bin/pool/lane-tools.test.mjs +26 -0
- package/bin/pool/warm.mjs +1 -1
- package/docs/CONFIG.md +225 -1
- package/docs/ISSUE-WATCH.md +1 -0
- package/docs/design/visual-gate.md +10 -0
- package/docs/eval/adversarial-bench.md +1 -0
- package/package.json +5 -2
- package/pool/README.md +2 -0
- package/scripts/bench-adversarial.mjs +4 -0
- package/scripts/bench-lightlane.mjs +2 -1
- package/templates/github-actions/forge-conductor.scopes.json +7 -0
- package/templates/github-actions/forge-conductor.yml +57 -0
|
@@ -63,7 +63,7 @@ export const OUTCOME_CODES = Object.freeze({
|
|
|
63
63
|
SANDBOX_START_FAILED: "sandbox.start_failed", // forge#4254: a lane sandbox could not start (a non-auth 4xx/config error or a non-HTTP start failure); needs-human, not relaunched
|
|
64
64
|
BASE_RED: "base.red", // forge#5239: a verify.invariants guard fails on the base too; the lane is deferred behind the introducing issue, never needs-human
|
|
65
65
|
SANDBOX_CAPACITY: "sandbox.capacity", // forge#4254: the sandbox provider had no capacity; deferred with backoff
|
|
66
|
-
SANDBOX_TRANSIENT: "sandbox.transient", // forge#5095: the sandbox provider answered a 5xx on launch (router/agent infrastructure); deferred with backoff, capped by max_deferrals, never needs-human
|
|
66
|
+
SANDBOX_TRANSIENT: "sandbox.transient", // forge#5095: the sandbox provider answered a 5xx on launch (router/agent infrastructure) or the launch hit a status-less transport error (forge#5656: fetch failed, ECONNRESET, ETIMEDOUT); deferred with backoff, capped by max_deferrals, never needs-human
|
|
67
67
|
SANDBOX_AUTH: "sandbox.auth", // forge#4685: the sandbox provider refused or lacked the credential (HTTP 401/403, no token); deferred, never needs-human
|
|
68
68
|
SANDBOX_UNREACHABLE: "sandbox.unreachable", // forge#4672: the sandbox provider stayed unreachable past execution.unreachable_window_min; deferred, the sandbox is kept for adopt
|
|
69
69
|
LEASE_HELD: "lease.held",
|
|
@@ -209,13 +209,13 @@ export const ENV_VALIDATE_PLACEMENT = "env.validate_placement";
|
|
|
209
209
|
* Batch recovery classes of a lane result (forge#4267). The batch runner recovers `recoverable` rows once
|
|
210
210
|
* (`orchestration.recovery.max_attempts`) and re-queues them; only `human` rows are escalations.
|
|
211
211
|
*/
|
|
212
|
-
export const RECOVERABLE_CODES = Object.freeze([OUTCOME_CODES.CI_RED, OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.BUILDER_BLOCK_UNTYPED, OUTCOME_CODES.CONTRACT_INVALID, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.BUDGET_EXCEEDED, OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CONFORMANCE_OMISSION, OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL]);
|
|
212
|
+
export const RECOVERABLE_CODES = Object.freeze([OUTCOME_CODES.CI_RED, OUTCOME_CODES.BASE_CONFLICT, OUTCOME_CODES.BUILDER_BLOCK_UNTYPED, OUTCOME_CODES.CONTRACT_INVALID, OUTCOME_CODES.CONTRACT_INVALID_COMMAND, OUTCOME_CODES.ENV_TOOL_MISSING, OUTCOME_CODES.ENV_REPRO_UNRUNNABLE, ENV_VALIDATE_TIMEOUT, ENV_VALIDATE_PLACEMENT, OUTCOME_CODES.ENV_CAPABILITY_REMOTE, OUTCOME_CODES.BUDGET_EXCEEDED, OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CONFORMANCE_OMISSION, OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL, OUTCOME_CODES.CONFORMANCE_REGRESSION, OUTCOME_CODES.CONFORMANCE_SCOPE_CREEP]); // #5644: regression and scope creep are builder-fixable
|
|
213
213
|
/** `builder.blocked` is only reached by a typed human block: credentials, spend, promotion, customer, product-decision. */
|
|
214
214
|
export const HUMAN_CODES = Object.freeze([OUTCOME_CODES.BUILDER_BLOCKED]);
|
|
215
215
|
|
|
216
216
|
/**
|
|
217
217
|
* `recoverable` | `human` | `terminal` for a lane result row ({outcome|terminalReason, code, issueEdited?, conflicting?}).
|
|
218
|
-
* Recoverable: needs-human `ci.red`, `base.conflict`, `builder.block_untyped`, `env.tool_missing`, `env.repro_unrunnable`, `env.validate_timeout`, `env.capability_remote`, `budget.exceeded`, `conformance.unimplemented` / `conformance.omission` / `conformance.unjustified_deferral` (#5035
|
|
218
|
+
* Recoverable: needs-human `ci.red`, `base.conflict`, `builder.block_untyped`, `env.tool_missing`, `env.repro_unrunnable`, `env.validate_timeout`, `env.capability_remote`, `budget.exceeded`, `conformance.unimplemented` / `conformance.omission` / `conformance.unjustified_deferral` (#5035), `conformance.regression` / `conformance.scope_creep` (#5644; guard_broken and e2e_unverified stay terminal), `contract.invalid` after a mid-run issue
|
|
219
219
|
* edit (`issueEdited`) or when every problem was an unmatched quote (`quoteMismatch`), `ci-pending` on a conflicting PR (`conflicting`), and the non-human `budget-exceeded` turn-overrun end (forge#4505). Human: `builder.blocked`. Anything else
|
|
220
220
|
* (another code, or not a needs-human/ci-pending row) is terminal. Pure, never throws.
|
|
221
221
|
*/
|
package/bin/engine-cli.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { execFileSync } from "node:child_process";
|
|
|
12
12
|
import { mapLimit } from "./lean/pmap.mjs";
|
|
13
13
|
import { execFile, spawn } from "node:child_process";
|
|
14
14
|
import { promisify } from "node:util";
|
|
15
|
+
const RECOVERING_LABEL = "workflow:recovering";
|
|
15
16
|
import { readdirSync, statSync, readFileSync } from "node:fs";
|
|
16
17
|
import { fileURLToPath } from "node:url";
|
|
17
18
|
import { homedir, hostname, cpus } from "node:os";
|
|
@@ -35,7 +36,7 @@ import { normalizeKindModes } from "./lean/conformance.mjs";
|
|
|
35
36
|
import { parseEnforceDomains } from "./lean/review-trigger.mjs";
|
|
36
37
|
import { viewIssue } from "./lean/gh-assoc.mjs";
|
|
37
38
|
import { otherLaneOwner, clearLease } from "./lean/lanelock.mjs";
|
|
38
|
-
import { parseExecution, detectNeeds, placementText } from "./lean/execution.mjs";
|
|
39
|
+
import { parseExecution, detectNeeds, placementText, hostFallbackAllowed } from "./lean/execution.mjs";
|
|
39
40
|
import { openRotator, rotatorKind } from "./lean/rotator.mjs";
|
|
40
41
|
import { relayPrefetchCommands } from "./lean/relay.mjs";
|
|
41
42
|
import { parseCeilingBySize } from "./lean/ceiling.mjs";
|
|
@@ -479,6 +480,12 @@ export function readRelayCaps(env = process.env) {
|
|
|
479
480
|
* ` day_budget_usd`, ` on_budget: stop|local`, ` cost_per_minute`) for `orchestrate`; undefined when the section is
|
|
480
481
|
* absent or unreadable.
|
|
481
482
|
*/
|
|
483
|
+
/** #5652: whether a remote lane's host-capability / tool-missing recovery may run on this host (execution.host_fallback, host.role). */
|
|
484
|
+
export function readHostFallback(cwd = process.cwd()) {
|
|
485
|
+
let hostRole = null;
|
|
486
|
+
try { hostRole = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.host?.role ?? null; } catch { /* unreadable: role unset */ }
|
|
487
|
+
return hostFallbackAllowed({ hostFallback: readExecution(cwd)?.hostFallback ?? null, hostRole });
|
|
488
|
+
}
|
|
482
489
|
export function readExecution(cwd = process.cwd()) {
|
|
483
490
|
try {
|
|
484
491
|
const sec = parseForgeYaml(readFileSync(join(cwd, "forge.yaml"), "utf8"))?.execution;
|
|
@@ -576,6 +583,7 @@ export function readEnvConfig(cwd = process.cwd()) {
|
|
|
576
583
|
const runners = tr && typeof tr === "object" && !Array.isArray(tr) ? Object.fromEntries(Object.entries(tr).filter(([k, v]) => k && typeof v === "string" && v.trim())) : {};
|
|
577
584
|
const rm = readYamlMap(cwd, "validate", "recipes"); // #5020: y?.validate?.recipes, a block map {match regex: replacement} applied to frozen validate and repro commands
|
|
578
585
|
const recipes = Object.entries(rm ?? {}).map(([match, replace]) => ({ match, replace }));
|
|
586
|
+
const catalog = String(typeof y?.validate?.catalog === "string" ? y.validate.catalog : "").split(",").map((x) => x.trim()).filter(Boolean); // #5653: CI files the derived command catalogue reads (default .github/workflows/ci.yml, scripts/ci-local.sh)
|
|
579
587
|
const cf = readYamlMap(cwd, "verification", "coupled_files"); // #5079: {when glob: required glob[, glob]}
|
|
580
588
|
const pp = readYamlMap(cwd, "topology", "prod_parity"); // #5284: {path glob: command | "note: how to verify"} production-only facts
|
|
581
589
|
const s = (v) => (typeof v === "string" && v.trim() ? v.trim() : undefined);
|
|
@@ -587,7 +595,7 @@ export function readEnvConfig(cwd = process.cwd()) {
|
|
|
587
595
|
const dg = parseDesignConfig(y?.design); // #5330: forge.yaml design: (system always read; routes/gate opt in the design gate)
|
|
588
596
|
const kb = typeof e.sparse_max_kb === "string" && /^\d+$/.test(e.sparse_max_kb.trim()) ? Number(e.sparse_max_kb) : e.sparse_max_kb;
|
|
589
597
|
return { ...(s(e.toolchain) ? { toolchainOverride: s(e.toolchain) } : {}), ...(s(e.setup) ? { envSetup: s(e.setup) } : {}),
|
|
590
|
-
...(Number.isInteger(kb) && kb >= 0 ? { sparseMaxKb: kb } : {}), ...(Object.keys(runners).length ? { testRunners: runners } : {}), ...(recipes.length ? { validateRecipes: recipes } : {}), ...(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 } : {}) };
|
|
598
|
+
...(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 } : {}) };
|
|
591
599
|
} catch { return {}; }
|
|
592
600
|
}
|
|
593
601
|
export const ENGINE_PATHS = ["core", "full", "lean", "auto"];
|
|
@@ -1062,7 +1070,7 @@ export async function runFromCli(argv, deps = {}) {
|
|
|
1062
1070
|
...(rotatorKind({ execution: readExecution(process.cwd()), env }) ? { accountRotator: rotatorKind({ execution: readExecution(process.cwd()), env }) } : {}), // #5094, #5205: detected
|
|
1063
1071
|
onTeardown: (fn) => { teardown = fn; }, ...(env.FORGEDOCK_BATCH_ID ? { batchId: env.FORGEDOCK_BATCH_ID } : {}), ...(placement ? { placement } : {}), ...(recover ? { recover } : {}),
|
|
1064
1072
|
emitTelemetry: deps.emitTelemetry ?? composeEmit(makeEmitTelemetry({ repo: leanRepo }), makeEventEmitter({ repo: leanRepo, config: readEvents() }).emit),
|
|
1065
|
-
admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readSequenceVersioned() ? { sequenceVersioned: readSequenceVersioned() } : {}), ...(readSharedSurfaces() ? { sharedSurfaces: readSharedSurfaces() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readReproQuality() ? { reproQuality: readReproQuality() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections"))) && Number(readLeanSetting("contract_max_corrections")) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections")) } : {}) });
|
|
1073
|
+
admission: readAdmission(), heavy: readHeavy(), ...readCoreLimits(), ...readEnvConfig(), ...(readMergeWait() ? { mergeWait: readMergeWait() } : {}), ...(readConformanceMode() ? { conformance: readConformanceMode() } : {}), ...(readConformanceKinds() ? { conformanceKinds: readConformanceKinds() } : {}), ...(readConformanceMutation() ? { conformanceMutation: "report" } : {}), ...(readContextPack() ? { contextPack: readContextPack() } : {}), ...(readSequenceVersioned() ? { sequenceVersioned: readSequenceVersioned() } : {}), ...(readSharedSurfaces() ? { sharedSurfaces: readSharedSurfaces() } : {}), ...(readReviewIncomplete() ? { reviewIncomplete: readReviewIncomplete() } : {}), ...(readLaneInstructions() ? { laneInstructions: readLaneInstructions() } : {}), ...(readReproTest() ? { reproTest: readReproTest() } : {}), ...(readReproQuality() ? { reproQuality: readReproQuality() } : {}), ...(readExplore() ? { explore: readExplore() } : {}), ...(readExperiment() ? { experiment: readExperiment() } : {}), light: readLight(), ...(readCloseParent() ? { closeParent: true } : {}), ...(readReviewTrigger() ? { reviewTrigger: readReviewTrigger() } : {}), ...(readVerify() ? { verify: readVerify() } : {}), ...readPrecheckOptions(), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model") ? { reviewerModel: readLeanSetting("reviewer_model") } : {}), ...(readFixModel() ? { fixModel: readFixModel() } : {}), ...(readBuilderRouting() ? { builderRouting: readBuilderRouting() } : {}), ...(readVerifier() ? { verifier: readVerifier() } : {}), ...(readHostCaps() ? { hostCaps: readHostCaps() } : {}), hostFallback: readHostFallback(), ...readRelayCaps(), ...(readSequenceRegenerate() ? { sequenceRegenerate: readSequenceRegenerate() } : {}), ...(readBaseMerge() ? { baseMerge: readBaseMerge() } : {}), ...(readFollowupsDefaultMilestone() ? { followupsDefaultMilestone: readFollowupsDefaultMilestone() } : {}), ...(readFollowupsRollupLabel() ? { followupsRollupLabel: readFollowupsRollupLabel() } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections"))) && Number(readLeanSetting("contract_max_corrections")) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections")) } : {}), ...(Number.isInteger(Number(readLeanSetting("review_max_resumes"))) && Number(readLeanSetting("review_max_resumes")) >= 1 ? { reviewMaxResumes: Number(readLeanSetting("review_max_resumes")) } : {}) });
|
|
1066
1074
|
} catch (e) { if (!interrupted) report({ terminalReason: "engine-error", detail: String(e?.message ?? e).slice(0, 500) }); throw e; }
|
|
1067
1075
|
finally { if (!interrupted) for (const [sig, f] of Object.entries(handlers)) off(sig, f); }
|
|
1068
1076
|
if (interrupted) return lres; // the signal handler reported and exits
|
|
@@ -1876,7 +1884,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1876
1884
|
migrateRunLogs(dir); // #4432: split legacy per-issue logs by repo before any lane runs (best effort, never throws)
|
|
1877
1885
|
const { orchestrate, formatTable, formatWaitSummary, formatSandboxSummary, formatOutcomeLists, formatAlertLines, estimateLaneMinutes, laneHistory, formatEstimateSummary } = await import("./lean/orchestrate.mjs");
|
|
1878
1886
|
const { formatPrecheckSummary } = await import("./lean/precheck.mjs");
|
|
1879
|
-
const { formatLedgerSummary } = await import("./lean/phaseledger.mjs");
|
|
1887
|
+
const { formatLedgerSummary, formatPhaseComparison, readBaselineRows } = await import("./lean/phaseledger.mjs");
|
|
1880
1888
|
const { formatFirstPassSummary } = await import("./lean/fixround.mjs");
|
|
1881
1889
|
const { formatDecompositionSummary } = await import("./lean/decompose.mjs");
|
|
1882
1890
|
const { formatShadowSummary } = await import("./lean/conformance.mjs");
|
|
@@ -1915,7 +1923,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1915
1923
|
lanes = { adopt: null, runOne: (n, ln, ctx = {}) => runCore({ issue: n, repo, lane: ln, deferPostRun: true, // #5437: orchestrate runs result.postRun once the slot is free
|
|
1916
1924
|
laneOverride, ...(ctx.placement ? { placement: { ...ctx.placement, mode: execMode() } } : {}), ...(ctx.recover ? { recover: ctx.recover } : {}), branches, cwd, dir, io: leanIo, agentId: `orch_${process.pid}_${n}`, emitTelemetry, batchId: batch.id,
|
|
1917
1925
|
...(rotatorKind({ execution: readExecution(cwd), env }) ? { accountRotator: rotatorKind({ execution: readExecution(cwd), env }) } : {}), // #5094, #5205: detected
|
|
1918
|
-
admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readSequenceVersioned(cwd) ? { sequenceVersioned: readSequenceVersioned(cwd) } : {}), ...(readSharedSurfaces(cwd) ? { sharedSurfaces: readSharedSurfaces(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readReproQuality(cwd) ? { reproQuality: readReproQuality(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections", cwd))) && Number(readLeanSetting("contract_max_corrections", cwd)) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections", cwd)) } : {}) }) };
|
|
1926
|
+
admission: readAdmission(cwd), heavy: readHeavy(cwd), ...readCoreLimits(cwd), ...readEnvConfig(cwd), ...(readMergeWait(cwd) ? { mergeWait: readMergeWait(cwd) } : {}), ...(readConformanceMode(cwd) ? { conformance: readConformanceMode(cwd) } : {}), ...(readConformanceKinds(cwd) ? { conformanceKinds: readConformanceKinds(cwd) } : {}), ...(readConformanceMutation(cwd) ? { conformanceMutation: "report" } : {}), ...(readContextPack(cwd) ? { contextPack: readContextPack(cwd) } : {}), ...(readSequenceVersioned(cwd) ? { sequenceVersioned: readSequenceVersioned(cwd) } : {}), ...(readSharedSurfaces(cwd) ? { sharedSurfaces: readSharedSurfaces(cwd) } : {}), ...(readReviewIncomplete(cwd) ? { reviewIncomplete: readReviewIncomplete(cwd) } : {}), ...(readLaneInstructions(cwd) ? { laneInstructions: readLaneInstructions(cwd) } : {}), ...(readReproTest(cwd) ? { reproTest: readReproTest(cwd) } : {}), ...(readReproQuality(cwd) ? { reproQuality: readReproQuality(cwd) } : {}), ...(readExplore(cwd) ? { explore: readExplore(cwd) } : {}), ...(readExperiment(cwd) ? { experiment: readExperiment(cwd) } : {}), light: readLight(cwd), ...(readCloseParent(cwd) ? { closeParent: true } : {}), ...(readReviewTrigger(cwd) ? { reviewTrigger: readReviewTrigger(cwd) } : {}), ...(readVerify(cwd) ? { verify: readVerify(cwd) } : {}), ...readPrecheckOptions(cwd), ...(model ? { builderModel: model } : {}), ...(readLeanSetting("reviewer_model", cwd) ? { reviewerModel: readLeanSetting("reviewer_model", cwd) } : {}), ...(readFixModel(cwd) ? { fixModel: readFixModel(cwd) } : {}), ...(readBuilderRouting(cwd) ? { builderRouting: readBuilderRouting(cwd) } : {}), ...(readVerifier(cwd) ? { verifier: readVerifier(cwd) } : {}), ...(readHostCaps(cwd) ? { hostCaps: readHostCaps(cwd) } : {}), hostFallback: readHostFallback(cwd), ...readRelayCaps(), ...(readSequenceRegenerate(cwd) ? { sequenceRegenerate: readSequenceRegenerate(cwd) } : {}), ...(readBaseMerge(cwd) ? { baseMerge: readBaseMerge(cwd) } : {}), ...(readFollowupsDefaultMilestone(cwd) ? { followupsDefaultMilestone: readFollowupsDefaultMilestone(cwd) } : {}), ...(readFollowupsRollupLabel(cwd) ? { followupsRollupLabel: readFollowupsRollupLabel(cwd) } : {}), ...(Number.isInteger(Number(readLeanSetting("contract_max_corrections", cwd))) && Number(readLeanSetting("contract_max_corrections", cwd)) >= 1 ? { contractMaxCorrections: Number(readLeanSetting("contract_max_corrections", cwd)) } : {}), ...(Number.isInteger(Number(readLeanSetting("review_max_resumes", cwd))) && Number(readLeanSetting("review_max_resumes", cwd)) >= 1 ? { reviewMaxResumes: Number(readLeanSetting("review_max_resumes", cwd)) } : {}) }) };
|
|
1919
1927
|
} else {
|
|
1920
1928
|
const laneScript = deps.laneScript ?? fileURLToPath(new URL("./forgedock.mjs", import.meta.url));
|
|
1921
1929
|
// #4690: lanes learn K (the default MemoryMax is derived from it); one line says so when no scope caps them.
|
|
@@ -1995,7 +2003,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
1995
2003
|
return capSample === null && onlineSample === null ? null : { free: capSample, online: onlineSample, at: capAt };
|
|
1996
2004
|
};
|
|
1997
2005
|
remote = liveExec.liveRemote({
|
|
1998
|
-
capacity, isRemote: () => true, identity: () => holdId, ...(exec.fallbackLocal ? { offlineFallback: true, headroom: hostHeadroom, ...(exec.capacityFallbackAfter ? { capacityFallbackAfter: exec.capacityFallbackAfter } : {}) } : {}), onBudget: bud.onBudget ?? "stop", costPerMinute: bud.costPerMinute ?? 0,
|
|
2006
|
+
hostFallback: readHostFallback(), capacity, isRemote: () => true, identity: () => holdId, ...(exec.fallbackLocal ? { offlineFallback: true, headroom: hostHeadroom, ...(exec.capacityFallbackAfter ? { capacityFallbackAfter: exec.capacityFallbackAfter } : {}) } : {}), onBudget: bud.onBudget ?? "stop", costPerMinute: bud.costPerMinute ?? 0,
|
|
1999
2007
|
admit: (u) => execBudget.admit(u),
|
|
2000
2008
|
onUsage: (n, sb, rec) => {
|
|
2001
2009
|
const startedAt = rec?.handle?.startedAt ?? rec?.startedAt ?? "?";
|
|
@@ -2176,8 +2184,9 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2176
2184
|
}),
|
|
2177
2185
|
// A recovery that ended for good without the lane relabelling it (engine-error, deferred): needs-human back, one comment.
|
|
2178
2186
|
relabelNeedsHuman: deps.relabelNeedsHuman ?? makeRelabelNeedsHuman({ gh: (a) => leanIo.gh(a), repo }),
|
|
2187
|
+
markRecovering: deps.markRecovering ?? makeMarkRecovering({ gh: (a) => leanIo.gh(a), repo }), // #5647
|
|
2179
2188
|
// #4481: a requeued or resumed issue that was closed or whose lane PR merged meanwhile is not run again
|
|
2180
|
-
dispatchCheck: deps.dispatchCheck !== undefined ? deps.dispatchCheck : makeDispatchCheck({ gh: (a) => leanIo.gh(a), repo, owner: plan?.forced ? null : (n) => batchMod.dispatchOwner(root, repo, n, batch.id) }),
|
|
2189
|
+
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) }),
|
|
2181
2190
|
// #5204: the engine version is saved with the batch state, so a resume after an upgrade names it on each interrupted lane
|
|
2182
2191
|
version: ENGINE_VERSION,
|
|
2183
2192
|
// #5204: an interrupted, requeued lane runs nothing until it is dispatched again: workflow:building comes off (best effort)
|
|
@@ -2228,6 +2237,7 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2228
2237
|
const waitLine = formatWaitSummary(rows, heavyStats);
|
|
2229
2238
|
if (waitLine) report.push(waitLine);
|
|
2230
2239
|
report.push(formatLedgerSummary(rows)); // #4908: per-phase wall time, n/a without ledger rows
|
|
2240
|
+
try { report.push(...formatPhaseComparison(rows, readBaselineRows({ excludeId: batch.id }))); } catch { report.push("phases vs prev7d: n/a"); } // #5649: read-only baseline, never fails the report
|
|
2231
2241
|
const precheckLine = formatPrecheckSummary(rows); // #4331
|
|
2232
2242
|
if (precheckLine) report.push(precheckLine);
|
|
2233
2243
|
const firstPassLine = formatFirstPassSummary(rows); // #4362
|
|
@@ -2299,7 +2309,7 @@ export async function closedScope({ gh, repo, issue, labels }) {
|
|
|
2299
2309
|
* Release review #4500: an OPEN issue reopened after that PR merged (a failed acceptance probe, #4399, or an operator
|
|
2300
2310
|
* reopening it for rework) is new work, so the lane runs; an unreadable reopen history also runs the lane.
|
|
2301
2311
|
*/
|
|
2302
|
-
export function makeDispatchCheck({ gh, repo, owner: batchOwner = null }) {
|
|
2312
|
+
export function makeDispatchCheck({ gh, repo, owner: batchOwner = null, batchId = null }) {
|
|
2303
2313
|
const json = async (args) => { try { return JSON.parse(String(await gh(args))); } catch { return null; } };
|
|
2304
2314
|
/** Latest `reopened` event time (ms) on the issue, 0 when never reopened, null when unreadable. */
|
|
2305
2315
|
const lastReopen = async (n) => {
|
|
@@ -2337,7 +2347,7 @@ export function makeDispatchCheck({ gh, repo, owner: batchOwner = null }) {
|
|
|
2337
2347
|
// #5471: another live batch of the repo runs / holds the issue: no lane here (--force on the batch lifts it)
|
|
2338
2348
|
const other = state === "OPEN" && batchOwner ? batchOwner(n) : null;
|
|
2339
2349
|
if (other) return { outcome: "deferred", code: "batch.owned", detail: `owned by ${other}` };
|
|
2340
|
-
const owner = state === "OPEN" ? await otherLaneOwner({ gh, repo, issue: n, checkPr: false }).catch(() => null) : null;
|
|
2350
|
+
const owner = state === "OPEN" ? await otherLaneOwner({ gh, repo, issue: n, checkPr: false, selfBatch: batchId }).catch(() => null) : null;
|
|
2341
2351
|
if (owner) return { outcome: "deferred", code: "lease.held", detail: owner.detail };
|
|
2342
2352
|
return null;
|
|
2343
2353
|
};
|
|
@@ -2381,7 +2391,7 @@ export function makeRelabelNeedsHuman({ gh, repo, now = () => Date.now() }) {
|
|
|
2381
2391
|
if (predicate && await prem.evalPredicate(predicate, { repo, io: { gh, pkgVersion: prem.registryPkgVersion }, now: now() }) === true) return "skipped";
|
|
2382
2392
|
const reg = await prem.registerAsk({ repo, io: { gh }, issue, ask: String(evidence ?? "") });
|
|
2383
2393
|
const extra = [prem.premiseAnnotation(predicate), reg.existing ? `Same owner ask as #${reg.existing} (one ask, linked): answering it unblocks this issue too.` : ""].filter(Boolean).join("\n");
|
|
2384
|
-
try { await gh(["issue", "edit", String(issue), "-R", repo, "--add-label", `needs-human,${NEEDS_HUMAN_EXTERNAL_LABEL}
|
|
2394
|
+
try { await gh(["issue", "edit", String(issue), "-R", repo, "--add-label", `needs-human,${NEEDS_HUMAN_EXTERNAL_LABEL}`, "--remove-label", RECOVERING_LABEL]); } catch { return "failed"; } // #5647: needs-human and recovering never coexist
|
|
2385
2395
|
try {
|
|
2386
2396
|
const { capComment } = await import("./lean/render.mjs");
|
|
2387
2397
|
await gh(["issue", "comment", String(issue), "-R", repo, "--body", capComment(`<!-- FORGE:NEEDS_HUMAN external=true -->\n## Needs human (external)\nOwner: ${external.owner || "unassigned (name an owner)"}\nUnblock condition: ${external.unblock || "unstated (name the condition that unblocks this issue)"}\n${extra ? `${extra}\n` : ""}${evidence}${!reg.existing && reg.entry ? `\n\n${reg.entry}` : ""}`)]);
|
|
@@ -2391,6 +2401,34 @@ export function makeRelabelNeedsHuman({ gh, repo, now = () => Date.now() }) {
|
|
|
2391
2401
|
};
|
|
2392
2402
|
}
|
|
2393
2403
|
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* #5647: a recovery lane is queued, so the issue shows `workflow:recovering` instead of `needs-human`. The label is added and read
|
|
2407
|
+
* back before needs-human goes (a failure rolls the add back and keeps needs-human); then one FORGE:RECOVERING comment is upserted.
|
|
2408
|
+
* Returns true | "failed".
|
|
2409
|
+
*/
|
|
2410
|
+
export function makeMarkRecovering({ gh, repo }) {
|
|
2411
|
+
return async ({ issue, code, attempt, max }) => {
|
|
2412
|
+
const n = String(issue);
|
|
2413
|
+
try { await gh(["label", "create", RECOVERING_LABEL, "-R", repo, "--force", "--color", "C5DEF5", "--description", "Pipeline: automatic recovery in flight. Managed by ForgeDock."]); } catch { /* exists, or no rights: the add says */ }
|
|
2414
|
+
try {
|
|
2415
|
+
await gh(["issue", "edit", n, "-R", repo, "--add-label", RECOVERING_LABEL]);
|
|
2416
|
+
const names = (JSON.parse(await gh(["issue", "view", n, "-R", repo, "--json", "labels"]))?.labels ?? []).map((l) => l?.name);
|
|
2417
|
+
if (!names.includes(RECOVERING_LABEL)) throw new Error("label not applied");
|
|
2418
|
+
await gh(["issue", "edit", n, "-R", repo, "--remove-label", "needs-human,needs-human:external"]);
|
|
2419
|
+
} catch {
|
|
2420
|
+
try { await gh(["issue", "edit", n, "-R", repo, "--remove-label", RECOVERING_LABEL]); } catch { /* needs-human is still on */ }
|
|
2421
|
+
return "failed";
|
|
2422
|
+
}
|
|
2423
|
+
try {
|
|
2424
|
+
const { capComment } = await import("./lean/render.mjs");
|
|
2425
|
+
const { postUpsert } = await import("./lean/statuscomment.mjs");
|
|
2426
|
+
await postUpsert({ gh, repo, issue, markers: ["FORGE:RECOVERING"], cap: capComment, body: `## Recovering (attempt ${attempt}/${max})\nrecovering (${code}), attempt ${attempt}/${max}: the watchdog is rebuilding this issue; \`needs-human\` appears only if recovery is exhausted.` });
|
|
2427
|
+
} catch { /* best effort */ }
|
|
2428
|
+
return true;
|
|
2429
|
+
};
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2394
2432
|
/** The batch report's "reclaimed" line (#4183). */
|
|
2395
2433
|
export function formatReclaimed(r) {
|
|
2396
2434
|
if (!r?.enabled) return "reclaimed: off (hygiene.auto_gc: false)";
|
|
@@ -2461,6 +2499,8 @@ export async function scheddFromCli(argv, deps = {}) {
|
|
|
2461
2499
|
for (const l of schedd.sharedPendingLines(st.batches)) console.log(l); // #5471
|
|
2462
2500
|
if (st.host) { const h = formatOverload(st.host) ?? formatHostLoad(st.host); if (h) console.log(`schedd: ${st.host.overloaded ? h : `host ${h}`}`); } // #5174
|
|
2463
2501
|
if (st.orphaned?.length) console.log(`schedd: ${st.orphaned.length} orphaned batch(es) (not hosted, pending issues, idle over 7 days): ${st.orphaned.slice(0, 3).map((o) => o.id).join(" ")}${st.orphaned.length > 3 ? " …" : ""} (forgedock orchestrate --gc-orphans cancels them)`);
|
|
2502
|
+
if (st.abandoned?.length) console.log(`schedd: abandoned ${st.abandoned.length} batch(es) not hosted and idle past the abandon age: ${st.abandoned.slice(0, 3).join(" ")}${st.abandoned.length > 3 ? " …" : ""} (forgedock orchestrate --resume <id> reopens one)`); // #5531
|
|
2503
|
+
if (st.rehosted?.length) console.log(`schedd: re-hosted ${st.rehosted.length} batch(es) not hosted and idle past the abandon age: ${st.rehosted.slice(0, 3).join(" ")}${st.rehosted.length > 3 ? " …" : ""}`); // #5531
|
|
2464
2504
|
for (const u of st.unhosted ?? []) console.log(`schedd: batch ${u.id} is not hosted but has ${u.pending.length} pending: ${u.pending.map((n) => `#${n}`).join(" ")} (forgedock orchestrate --resume ${u.id})`);
|
|
2465
2505
|
return { running: true, ...st };
|
|
2466
2506
|
}
|
package/bin/labels.json
CHANGED
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"color": "C5DEF5",
|
|
45
45
|
"description": "Pipeline: autonomous remediation pending (no human action needed). Managed by ForgeDock."
|
|
46
46
|
},
|
|
47
|
+
{
|
|
48
|
+
"name": "workflow:recovering",
|
|
49
|
+
"color": "C5DEF5",
|
|
50
|
+
"description": "Pipeline: automatic recovery in flight (no human action needed). Managed by ForgeDock."
|
|
51
|
+
},
|
|
47
52
|
{
|
|
48
53
|
"name": "workflow:awaiting-merge",
|
|
49
54
|
"color": "FF8C00",
|
package/bin/lean/batch.mjs
CHANGED
|
@@ -80,6 +80,21 @@ export function scrubEnv(env) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const readJson = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return null; } };
|
|
83
|
+
/** #5531: parses done by the cached reader (tests assert a scan parses each batch state once). */
|
|
84
|
+
export const scanStats = { parses: 0 };
|
|
85
|
+
const jsonCache = new Map();
|
|
86
|
+
/** #5531: `readJson` keyed by the file's mtime, size and inode (atomic writes change the inode); callers must treat the value as read-only. */
|
|
87
|
+
const readJsonCached = (file) => {
|
|
88
|
+
let st;
|
|
89
|
+
try { st = statSync(file); } catch { jsonCache.delete(file); return null; }
|
|
90
|
+
const key = `${st.mtimeMs}:${st.size}:${st.ino}`, hit = jsonCache.get(file);
|
|
91
|
+
if (hit?.key === key) return hit.value;
|
|
92
|
+
const value = readJson(file);
|
|
93
|
+
scanStats.parses++;
|
|
94
|
+
if (jsonCache.size > 4096) jsonCache.clear();
|
|
95
|
+
jsonCache.set(file, { key, value });
|
|
96
|
+
return value;
|
|
97
|
+
};
|
|
83
98
|
|
|
84
99
|
const readAdded = (file) => {
|
|
85
100
|
const v = readJson(file);
|
|
@@ -186,6 +201,8 @@ export function openBatch(root, id) {
|
|
|
186
201
|
},
|
|
187
202
|
store: {
|
|
188
203
|
load: () => readJson(f("state.json")),
|
|
204
|
+
/** #5531: read-only cached state for scans (status, watchdog); never mutate or save the result. */
|
|
205
|
+
peek: () => readJsonCached(f("state.json")),
|
|
189
206
|
save: (state) => put(f("state.json"), JSON.stringify(state) + "\n"),
|
|
190
207
|
log: (row) => { try { appendFileSync(f("log.jsonl"), JSON.stringify({ at: new Date().toISOString(), ...row }) + "\n", { mode: 0o600 }); } catch { /* the log is advisory */ } },
|
|
191
208
|
},
|
|
@@ -260,7 +277,7 @@ export function openBatch(root, id) {
|
|
|
260
277
|
return { requeued, refused };
|
|
261
278
|
},
|
|
262
279
|
/** #4917: the issues still `pending` in state.json (deferred or requeued included); [] when none or unreadable. */
|
|
263
|
-
pendingIssues: () => { const p =
|
|
280
|
+
pendingIssues: () => { const p = readJsonCached(f("state.json"))?.pending; return Array.isArray(p) ? p.filter((n) => Number.isSafeInteger(n)) : []; },
|
|
264
281
|
/** Every `--requeue` entry, in order; [] when missing or invalid. */
|
|
265
282
|
readRequeued: () => readRequeueFile(f("requeue")),
|
|
266
283
|
/** Entries the runner has not applied yet (a finished or unhosted batch with a pending requeue). */
|
|
@@ -311,7 +328,9 @@ export function openBatch(root, id) {
|
|
|
311
328
|
readCancel: () => { const v = readJson(f("cancel")); return v && typeof v === "object" && !Array.isArray(v) && typeof v.at === "string" ? v : null; },
|
|
312
329
|
clearCancel: () => rmSync(f("cancel"), { force: true }),
|
|
313
330
|
/** Added issues the batch never took into its `order` (a finished or unhosted batch with pending adds). */
|
|
314
|
-
unrunAdds: () => { const order = new Set(
|
|
331
|
+
unrunAdds: () => { const order = new Set(readJsonCached(f("state.json"))?.order ?? []); return readAdded(f("add")).filter((n) => !order.has(n)); },
|
|
332
|
+
/** #5531: a `report.json` or `cancel` file exists (two stats, no parse): the batch needs no scanning. */
|
|
333
|
+
isTerminal: () => existsSync(f("report.json")) || existsSync(f("cancel")),
|
|
315
334
|
/** #4775: epoch ms of the batch's last progress (newest mtime of `state.json` / `log.jsonl`), or null when neither exists. */
|
|
316
335
|
lastProgressMs: () => {
|
|
317
336
|
let best = null;
|
package/bin/lean/batch.test.mjs
CHANGED
|
@@ -9,7 +9,9 @@ import { tmpDir } from "../tests/_tmp.mjs";
|
|
|
9
9
|
import { resolveLane, makeLaneCache } from "./lane.mjs";
|
|
10
10
|
import { orchestrate, deferPolicy, DEFER_BACKOFF_S, formatOutcomeLists, CAPACITY_FALLBACK_AFTER, isTransientEngineError, transientRetryDelayMs, DEFAULT_TRANSIENT_RETRIES } from "./orchestrate.mjs";
|
|
11
11
|
import { openBatch, fsTypeOf, assertDiskPath, isLaneAlive, writeAtomic, launchLane, detachedLanes } from "./batch.mjs";
|
|
12
|
-
import {
|
|
12
|
+
import { makeLedger } from "./ledger.mjs";
|
|
13
|
+
import { providerLanes } from "./execution.mjs";
|
|
14
|
+
import { orchestrateFromCli, runFromCli, readOrchestration, makeRelabelNeedsHuman, makeMarkRecovering, makeDispatchCheck } from "../engine-cli.mjs";
|
|
13
15
|
|
|
14
16
|
// orchestrateFromCli opens the host lane registry (#4191): keep it in a temp dir, also for spawned dispatchers.
|
|
15
17
|
process.env.FORGEDOCK_SCHED_DIR = tmpDir("batch-sched-");
|
|
@@ -324,6 +326,45 @@ describe("#4318: the batch dispatcher's signal relabel and the needs-human relab
|
|
|
324
326
|
assert.deepEqual(removed.sort(), ["SIGINT", "SIGTERM"]);
|
|
325
327
|
});
|
|
326
328
|
|
|
329
|
+
describe("makeMarkRecovering (#5647)", () => {
|
|
330
|
+
const hook = (failOn = null, labels = ["needs-human", "workflow:recovering"]) => {
|
|
331
|
+
const calls = [];
|
|
332
|
+
const gh = async (a) => {
|
|
333
|
+
calls.push(a.join(" "));
|
|
334
|
+
if (failOn && a.join(" ").includes(failOn)) throw new Error("boom");
|
|
335
|
+
if (a[1] === "view" && a.includes("labels")) return JSON.stringify({ labels: labels.map((name) => ({ name })) });
|
|
336
|
+
if (a[1] === "view") return JSON.stringify({ comments: [] });
|
|
337
|
+
return "";
|
|
338
|
+
};
|
|
339
|
+
return { calls, run: () => makeMarkRecovering({ gh, repo: "o/r" })({ issue: 7, code: "ci.red", attempt: 1, max: 2 }) };
|
|
340
|
+
};
|
|
341
|
+
it("adds workflow:recovering, reads it back, then removes needs-human and posts the attempt comment", async () => {
|
|
342
|
+
const h = hook();
|
|
343
|
+
assert.equal(await h.run(), true);
|
|
344
|
+
const i = (x) => h.calls.findIndex((c) => c.includes(x));
|
|
345
|
+
assert.ok(i("label create workflow:recovering") < i("--add-label workflow:recovering"));
|
|
346
|
+
assert.ok(i("--add-label workflow:recovering") < i("--remove-label needs-human,needs-human:external"));
|
|
347
|
+
assert.ok(h.calls.some((c) => c.includes("attempt 1/2")));
|
|
348
|
+
});
|
|
349
|
+
it("a failed add keeps needs-human and rolls the label back", async () => {
|
|
350
|
+
const h = hook("--add-label");
|
|
351
|
+
assert.equal(await h.run(), "failed");
|
|
352
|
+
assert.ok(!h.calls.some((c) => c.includes("--remove-label needs-human")));
|
|
353
|
+
});
|
|
354
|
+
it("an add that did not read back keeps needs-human", async () => {
|
|
355
|
+
const h = hook(null, ["needs-human"]);
|
|
356
|
+
assert.equal(await h.run(), "failed");
|
|
357
|
+
assert.ok(!h.calls.some((c) => c.includes("--remove-label needs-human")));
|
|
358
|
+
});
|
|
359
|
+
it("the final needs-human relabel removes workflow:recovering after the skip checks", async () => {
|
|
360
|
+
const calls = [];
|
|
361
|
+
const gh = async (a) => { calls.push(a.join(" ")); return a[1] === "view" ? JSON.stringify({ state: "OPEN", body: "" }) : ""; };
|
|
362
|
+
await makeRelabelNeedsHuman({ gh, repo: "o/r", now: () => 1000 })({ issue: 7, evidence: "why" });
|
|
363
|
+
assert.ok(calls.some((c) => c.includes("--add-label needs-human") && c.includes("--remove-label workflow:recovering")));
|
|
364
|
+
assert.ok(calls[0].includes("view"));
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
327
368
|
describe("makeRelabelNeedsHuman", () => {
|
|
328
369
|
const LIVE = (until) => `body\n<!-- FORGE:STATE\n${JSON.stringify({ v: 1, issue: 7, lease: { by: "core_1", until, host: "h", pid: 1 } })}\n-->`;
|
|
329
370
|
const hook = (view, fail = {}) => {
|
|
@@ -795,6 +836,14 @@ describe("#4481: a closed issue or a merged lane PR is skipped at dispatch", ()
|
|
|
795
836
|
assert.equal(await mk(OPEN, { body: new Error("down"), open: new Error("down") })(9), null, "unreadable: fail open");
|
|
796
837
|
assert.equal((await mk('{"state":"CLOSED"}', { body: lease(Date.now() + 600000) })(9)).outcome, "invalid", "closed wins");
|
|
797
838
|
});
|
|
839
|
+
it("#5654 makeDispatchCheck: a lease written by another run of the same batch does not defer; another batch's or a batch-less lease still does", async () => {
|
|
840
|
+
const body = (batch) => JSON.stringify({ body: `x\n<!-- FORGE:STATE\n${JSON.stringify({ v: 1, issue: 9, lease: { by: "core_h_1_aaaaaa", until: Date.now() + 600000, host: "h", pid: 1, ...(batch ? { batch } : {}) } })}\n-->` });
|
|
841
|
+
const mk = (b, batchId) => makeDispatchCheck({ repo: "o/r", batchId, gh: async (a) => (a[0] === "issue" && a[a.length - 1] === "body" ? b : a[0] === "issue" ? '{"state":"OPEN"}' : "[]") });
|
|
842
|
+
assert.equal(await mk(body("bt1"), "bt1")(9), null, "same batch, different run suffix: dispatched");
|
|
843
|
+
assert.equal((await mk(body("bt2"), "bt1")(9)).code, "lease.held", "another batch still defers");
|
|
844
|
+
assert.equal((await mk(body(null), "bt1")(9)).code, "lease.held", "a batch-less lease still defers");
|
|
845
|
+
assert.equal((await mk(body("bt1"), null)(9)).code, "lease.held", "no batch id: foreign");
|
|
846
|
+
});
|
|
798
847
|
it("#4920 a deferred dispatch check launches no lane and no sandbox, and a restarted batch (new orchestrate) defers again", async () => {
|
|
799
848
|
for (const round of [1, 2]) { // round 2: a fresh orchestrate call = a daemon restart; the answer is read from GitHub each time
|
|
800
849
|
const { now, sleep } = fakeClock();
|
|
@@ -1893,3 +1942,69 @@ describe("#5469: holds carry an owner and an expiry", () => {
|
|
|
1893
1942
|
assert.ok(old.readCancel()); assert.equal(fresh.readCancel(), null);
|
|
1894
1943
|
});
|
|
1895
1944
|
});
|
|
1945
|
+
|
|
1946
|
+
describe("batch scan cache (#5531)", () => {
|
|
1947
|
+
it("#5531: pendingIssues re-reads after the state file changes; isTerminal sees report and cancel", () => {
|
|
1948
|
+
const root = tmpDir("batch-cache-"), b = openBatch(root, "b20261031-000000-7001");
|
|
1949
|
+
b.writePlan({ daemon: true });
|
|
1950
|
+
b.store.save({ v: 1, order: [1], pending: [1] });
|
|
1951
|
+
assert.deepEqual(b.pendingIssues(), [1]);
|
|
1952
|
+
b.store.save({ v: 1, order: [1, 2], pending: [1, 2] });
|
|
1953
|
+
assert.deepEqual(b.pendingIssues(), [1, 2]);
|
|
1954
|
+
assert.equal(b.isTerminal(), false);
|
|
1955
|
+
b.requestCancel({ reason: "x" });
|
|
1956
|
+
assert.equal(b.isTerminal(), true);
|
|
1957
|
+
});
|
|
1958
|
+
});
|
|
1959
|
+
|
|
1960
|
+
describe("#5669: an upgrade handover adopts live lanes instead of requeueing them", () => {
|
|
1961
|
+
const OLD = "1.59.1", NEW = "1.59.2";
|
|
1962
|
+
const memStore = (init = null) => { const st = { saved: init, logged: [] }; return Object.assign(st, { load: () => st.saved, save: (x) => { st.saved = x; }, log: (r) => st.logged.push(r) }); };
|
|
1963
|
+
const common = { parallel: 1, pollMs: 5, readBody: async () => "" };
|
|
1964
|
+
it("#5669: handover adopts a live remote lane without an interrupted row", async () => {
|
|
1965
|
+
const live = new Set([5]), results = {}, calls = [];
|
|
1966
|
+
const provider = { name: "mem", idFor: (n) => `mem-${n}`,
|
|
1967
|
+
start: async ({ issue }) => { calls.push("start"); return { provider: "mem", id: `mem-${issue}`, issue }; },
|
|
1968
|
+
status: async (h) => (live.has(h.issue) ? "running" : "exited"), fetchResult: async (h) => results[h.issue] ?? null,
|
|
1969
|
+
teardown: async (h) => { calls.push(["teardown", h.id]); delete results[h.issue]; live.delete(h.issue); return true; } }; // a torn-down sandbox is gone with its result
|
|
1970
|
+
const root = tmpDir("handover-remote-");
|
|
1971
|
+
const ledgerFor = (n) => makeLedger({ root, batch: "bt", lane: `sandbox-${n}`, owner: "orch_test", issue: n });
|
|
1972
|
+
const lanes = providerLanes({ provider, laneArgs: () => [], ledgerFor, pollMs: 5, sleep: (ms) => new Promise((r) => setTimeout(r, ms)) });
|
|
1973
|
+
const store = memStore(), ac = new AbortController();
|
|
1974
|
+
const old = orchestrate({ issues: [5], ...common, store, version: OLD, signal: ac.signal, runOne: lanes.runOne }).catch((e) => e);
|
|
1975
|
+
await until(() => store.saved?.running?.[5]?.handle);
|
|
1976
|
+
ac.abort();
|
|
1977
|
+
assert.equal((await old).code, "batch.stopped");
|
|
1978
|
+
results[5] = { terminalReason: "merged", pr: 105 }; live.delete(5); // the sandbox finishes while the old process is still running
|
|
1979
|
+
await new Promise((r) => setTimeout(r, 60));
|
|
1980
|
+
assert.deepEqual(calls.filter((c) => c[0] === "teardown"), [], "the halted lane leaves its sandbox for the new daemon");
|
|
1981
|
+
const launched = [];
|
|
1982
|
+
const rows = await orchestrate({ issues: [], ...common, store, version: NEW, adopt: lanes.adopt, runOne: async (n) => { launched.push(n); return { terminalReason: "merged", pr: 1 }; } });
|
|
1983
|
+
assert.deepEqual(launched, [], "adopted, not relaunched");
|
|
1984
|
+
assert.deepEqual(rows.map((r) => [r.issue, r.outcome, r.pr]), [[5, "merged", 105]], "the result is recorded once");
|
|
1985
|
+
assert.deepEqual(store.logged.filter((r) => r.code === "run.interrupted"), []);
|
|
1986
|
+
});
|
|
1987
|
+
it("#5669: handover adopts a live local lane", async () => {
|
|
1988
|
+
const rf = join(tmpDir("handover-local-"), "r.json");
|
|
1989
|
+
let up = true;
|
|
1990
|
+
const batch = { resultFile: () => rf, logFile: () => "log" };
|
|
1991
|
+
const lanes = detachedLanes({ batch, alive: () => up, pollMs: 5 });
|
|
1992
|
+
const store = memStore({ v: 1, order: [3], deps: { 3: [] }, lanes: {}, crossSeen: [], results: {}, running: { 3: { startedAt: 1, pid: 33 } }, pending: [], notBefore: {}, requeues: {}, deferrals: {}, engineErrors: {}, prefilter: {}, errorTimes: [], breaker: null, engineVersion: OLD });
|
|
1993
|
+
setTimeout(() => { writeFileSync(rf, JSON.stringify({ terminalReason: "merged", pr: 103 })); up = false; }, 50);
|
|
1994
|
+
const launched = [];
|
|
1995
|
+
const rows = await orchestrate({ issues: [], ...common, store, version: NEW, adopt: lanes.adopt, runOne: async (n) => { launched.push(n); return { terminalReason: "merged" }; } });
|
|
1996
|
+
assert.deepEqual(launched, []);
|
|
1997
|
+
assert.deepEqual(rows.map((r) => [r.issue, r.outcome, r.pr]), [[3, "merged", 103]]);
|
|
1998
|
+
assert.deepEqual(store.logged.filter((r) => r.code === "run.interrupted"), []);
|
|
1999
|
+
});
|
|
2000
|
+
it("#5669: handover requeues a dead lane with the upgrade cause", async () => {
|
|
2001
|
+
const batch = { resultFile: () => join(tmpDir("handover-dead-"), "none.json"), logFile: () => "log" };
|
|
2002
|
+
const lanes = detachedLanes({ batch, alive: () => false, pollMs: 5 });
|
|
2003
|
+
const store = memStore({ v: 1, order: [4], deps: { 4: [] }, lanes: {}, crossSeen: [], results: {}, running: { 4: { startedAt: 1, pid: 44 } }, pending: [], notBefore: {}, requeues: {}, deferrals: {}, engineErrors: {}, prefilter: {}, errorTimes: [], breaker: null, engineVersion: OLD });
|
|
2004
|
+
const rows = await orchestrate({ issues: [], ...common, store, version: NEW, adopt: lanes.adopt, runOne: async () => ({ terminalReason: "merged", pr: 9 }) });
|
|
2005
|
+
const ir = store.logged.filter((r) => r.code === "run.interrupted");
|
|
2006
|
+
assert.equal(ir.length, 1);
|
|
2007
|
+
assert.match(ir[0].detail, /^interrupted: upgrade v1\.59\.1→v1\.59\.2; /);
|
|
2008
|
+
assert.deepEqual(rows.map((r) => [r.issue, r.outcome]), [[4, "merged"]]);
|
|
2009
|
+
});
|
|
2010
|
+
});
|
package/bin/lean/conformance.mjs
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { spawnSync } from "node:child_process";
|
|
11
11
|
import { OUTCOME_CODES, ENV_VALIDATE_TIMEOUT } from "../engine/outcome-codes.mjs";
|
|
12
12
|
import { noComments } from "./context.mjs";
|
|
13
|
+
import { equivalentRuns, isDriftFailure } from "./validate-catalog.mjs";
|
|
13
14
|
import { seqNumber } from "./sequence.mjs";
|
|
14
15
|
import { activationFailures } from "./activation.mjs";
|
|
15
16
|
import * as nodeFs from "node:fs";
|
|
@@ -315,6 +316,8 @@ export const VERIFY_MODES = Object.freeze(["in_lane", "out_of_band"]);
|
|
|
315
316
|
*/
|
|
316
317
|
export const OUT_OF_BAND_RE = /\blighthouse\b|\bweb[- ]vitals\b|\bfield[- ](?:perf\w*|profiles?|data|metrics?)\b|\bthrottled\b|\b(?:nightly|report[- ]only)\b[^.;\n]{0,40}?\b(?:suites?|jobs?|runs?|bench\w*|workflows?)\b/i;
|
|
317
318
|
const PERF_METRIC_RE = /\b(?:LCP|INP|TTI|FCP|TTFB)\b/;
|
|
319
|
+
/** #5653: criteria only time or production can show (a N-day metric, a corpus re-run, a published scorecard, after deploy). */
|
|
320
|
+
const TIME_PROD_ONLY_RE = /\b\d+[- ]days?\b|\bscorecards?\b|\bcorpus re-?runs?\b|\bafter (?:the )?(?:deploy|release|promotion)\b/i;
|
|
318
321
|
export const isOutOfBand = (r) => r?.verify === "out_of_band";
|
|
319
322
|
const tagsOutOfBand = (r) => r?.disposition === "deliver" && r?.verify == null && (OUT_OF_BAND_RE.test(String(r?.quote ?? "")) || PERF_METRIC_RE.test(String(r?.quote ?? "")));
|
|
320
323
|
/**
|
|
@@ -558,7 +561,7 @@ export function testPlanProblems(c, { required = false } = {}) {
|
|
|
558
561
|
|
|
559
562
|
/** #5448: a requirement that starts as an imperative build verb is development work, not a prod-only measurement. */
|
|
560
563
|
const DEV_WORK_RE = /^\W*(?:\w+\s+){0,2}?(?:find|fix|implement|develop|build|write|patch|add|change)\b/i;
|
|
561
|
-
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null } = {}) {
|
|
564
|
+
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null } = {}) {
|
|
562
565
|
const problems = [];
|
|
563
566
|
if (!c || typeof c !== "object" || Array.isArray(c)) return { ok: false, problems: ["contract.json is missing or not a JSON object"] };
|
|
564
567
|
const reqs = Array.isArray(c.requirements) ? c.requirements : [];
|
|
@@ -585,6 +588,7 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
|
|
|
585
588
|
if (r?.verify != null && !VERIFY_MODES.includes(r.verify)) problems.push(`${id}: verify must be one of ${VERIFY_MODES.join("|")}`);
|
|
586
589
|
if (isOutOfBand(r) && r?.disposition !== "deliver") problems.push(`${id}: verify out_of_band applies only to a deliver requirement`);
|
|
587
590
|
else if (isOutOfBand(r) && blank(r?.evidence)) problems.push(`${id}: verify out_of_band needs evidence naming the job or workflow that measures it (or set verify "in_lane" if this change can check it)`);
|
|
591
|
+
if (r?.disposition === "deliver" && !isOutOfBand(r) && r?.verify !== "in_lane" && TIME_PROD_ONLY_RE.test(String(r?.quote ?? ""))) problems.push(`${id}: the quote needs time or production to observe (${String(r.quote).match(TIME_PROD_ONLY_RE)[0]}); classify it post-deploy (with a check id), defer with a bucket, or verify out_of_band with evidence, never narrow it into a deliver the lane can observe (#5653)`);
|
|
588
592
|
}
|
|
589
593
|
if (c.regression != null && !Array.isArray(c.regression)) problems.push("regression must be an array of {id, command, covers}");
|
|
590
594
|
for (const g of Array.isArray(c.regression) ? c.regression : []) {
|
|
@@ -633,7 +637,7 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
|
|
|
633
637
|
}
|
|
634
638
|
problems.push(...testPlanProblems(c, { required: testPlan }));
|
|
635
639
|
if (JSON.stringify(c).length > MAX_CONTRACT_CHARS) problems.push(`the contract is over ${MAX_CONTRACT_CHARS} characters; keep quotes to the requirement sentence and descriptions short`);
|
|
636
|
-
if (pages) problems.push(...contractBriefProblems(c, pages, { readFile })); // #5428: page deliverables need page_gate briefs
|
|
640
|
+
if (pages) problems.push(...contractBriefProblems(c, pages, { readFile, baseFiles })); // #5428: page deliverables need page_gate briefs
|
|
637
641
|
return { ok: problems.length === 0, problems };
|
|
638
642
|
}
|
|
639
643
|
|
|
@@ -1100,7 +1104,7 @@ export function interfaceDecisionFailures(contract, result, changedFiles) {
|
|
|
1100
1104
|
* tool), for the trajectory; always an array.
|
|
1101
1105
|
*/
|
|
1102
1106
|
export function precheck({ contract, result, changedFiles, ignore = [], ciVerified = false, hotspots = null, repro = null, validateRuns = null, repoHas = () => false, frozen = null, checkIds = null, baselineFailures = null, guardFailures = null, coupledFailures = null, relaxationFailures = null, routeFailures = null, docsFailures = null, pageFailures = null, docsPaths = null, prodParityFailures = null, seamFailures = null, newOffKeys = null, substitutedRuns = null, removedPaths = [], baseFiles = [], uiBrowser = null }) {
|
|
1103
|
-
const failures = [], superseded = [], ciCovered = [];
|
|
1107
|
+
const failures = [], superseded = [], ciCovered = [], equivalent = [];
|
|
1104
1108
|
// #4626: a post-deploy check id must be on the default branch or added by this PR (`checkIds`: ids of both checks files; null = not resolved)
|
|
1105
1109
|
if (checkIds) for (const r of contract.requirements ?? []) {
|
|
1106
1110
|
if (r.disposition === "post-deploy" && !(r.check && checkIds.has(r.check))) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "check_unknown", detail: `${r.id} post-deploy check ${r.check ? `'${r.check}'` : "id"} is neither on the default branch nor added by this PR (.forge/post-deploy-checks.json)` });
|
|
@@ -1125,7 +1129,9 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1125
1129
|
const verdict = substituteVerdict(substitutedRuns?.[v.id], { repoHas, command: v.substituted.from });
|
|
1126
1130
|
const from = `validate ${v.id} substituted \`${v.command}\` for the frozen \`${v.substituted.from}\``;
|
|
1127
1131
|
if (verdict === "unverified") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "substitute_unverified", detail: `${from}, but the engine has no rerun of the frozen command to show it cannot run` }); continue; }
|
|
1128
|
-
|
|
1132
|
+
// #5653: the frozen command runs, and the substitute ran the same test ids with the same exit: recorded, not failed
|
|
1133
|
+
if (verdict === "runs" && equivalentRuns(substitutedRuns[v.id], substitutedRuns[v.id].sub)) equivalent.push({ id: v.id, from: v.substituted.from, to: v.command });
|
|
1134
|
+
else if (verdict === "runs") { failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `${from}, but the frozen command runs and fails (exit ${substitutedRuns[v.id].rc}): a substitute-validate replaces only a command that cannot run, never a failing check${outputTail(substitutedRuns[v.id].output)}` }); continue; }
|
|
1129
1135
|
if (verdict === "timeout" && !ciVerified) { failures.push({ code: ENV_VALIDATE_TIMEOUT, kind: "validate_timeout", detail: `${from}, and the frozen command timed out (exit 124) on the engine's rerun, so its substitution cannot be judged: infrastructure (host load)` }); continue; }
|
|
1130
1136
|
}
|
|
1131
1137
|
const r = runs.find((x) => x?.id === v.id);
|
|
@@ -1148,6 +1154,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1148
1154
|
// #5447: CI may not run this test, so a missing tool on the rerun is never covered by a CI-verified head
|
|
1149
1155
|
if (miss) failures.push({ code: C.ENV_TOOL_MISSING, kind: "validate_env", tool: miss.tool, detail: `validate ${v.id} (\`${v.command}\`) could not run: the host is missing ${KIND_NAME[miss.kind]} '${miss.tool}' (environment, not the change)${outputTail(rerun.output)}` });
|
|
1150
1156
|
else if (amendedOnly && isScopeCheck(v.command)) superseded.push({ id: v.id, files: amendedOnly });
|
|
1157
|
+
else if (rerun && isDriftFailure(rerun.output)) failures.push({ code: C.BASE_CONFLICT, kind: "validate_drift", detail: `validate ${v.id} (\`${v.command}\`) failed on a stale generated artifact (base drift, not the change): base-sync, regenerate the artifact (forge.yaml validate.regenerate) and rerun${outputTail(rerun.output)}` }); // #5653: a mechanical base-sync recovery, not unimplemented work
|
|
1151
1158
|
else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${r.exit})${outputTail(rerun?.output)}` });
|
|
1152
1159
|
}
|
|
1153
1160
|
}
|
|
@@ -1179,7 +1186,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1179
1186
|
failures.push(...(prodParityFailures ?? [])); // #5284: topology.prod_parity
|
|
1180
1187
|
failures.push(...interfaceDecisionFailures(contract, result, changedFiles)); // #5338
|
|
1181
1188
|
failures.push(...(seamFailures ?? [])); // #5338: a declared interface's provider and consumer no longer agree
|
|
1182
|
-
return { ok: failures.length === 0, failures, superseded, ciCovered };
|
|
1189
|
+
return { ok: failures.length === 0, failures, superseded, ciCovered, equivalent };
|
|
1183
1190
|
}
|
|
1184
1191
|
|
|
1185
1192
|
/**
|
|
@@ -153,7 +153,7 @@ describe("#4574 amendment slips", () => {
|
|
|
153
153
|
|
|
154
154
|
describe("precheck (deterministic, no reviewer)", () => {
|
|
155
155
|
const res = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
|
|
156
|
-
it("passes a complete, validated, in-scope change", () => assert.deepEqual(precheck({ contract: C, result: res, changedFiles: files }), { ok: true, failures: [], superseded: [], ciCovered: [] }));
|
|
156
|
+
it("passes a complete, validated, in-scope change", () => assert.deepEqual(precheck({ contract: C, result: res, changedFiles: files }), { ok: true, failures: [], superseded: [], ciCovered: [], equivalent: [] }));
|
|
157
157
|
it("unauthorized file -> scope_creep; tests and ignored paths are always allowed", () => {
|
|
158
158
|
assert.deepEqual(codes(precheck({ contract: C, result: res, changedFiles: [...files, "src/billing.js", ".forge-lean/x", "tests/test_x.py", "pkg/foo_test.go"], ignore: [".forge-lean/"] })), ["conformance.scope_creep"]);
|
|
159
159
|
for (const t of ["test/a.js", "src/a.test.ts", "tests/test_a.py", "a_test.go", "spec/a.spec.js"]) assert.ok(isTestPath(t), t);
|
|
@@ -196,6 +196,34 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
196
196
|
for (const cmd of ["node --test a.test.mjs", "echo start && pytest tests/x.py", "test -f out.json", "[ -f a ] && npm test", "bash scripts/check.sh", "if [ -f x ]; then pytest; fi", "if true; then node --test a.test.mjs; fi", "for f in a b; do node --test $f; done"]) assert.ok(!noopCommand(cmd), cmd); // SEC-22: keywords around a real check
|
|
197
197
|
for (const cmd of ["test 1", "[ 1 ]", "sleep 0", "node -e 0", "true\ntrue", "if true; then :; fi", "python -c pass", "exit 1"]) assert.ok(noopCommand(cmd), JSON.stringify(cmd)); // SEC-12
|
|
198
198
|
});
|
|
199
|
+
it("#5653 a substitute running the same passing test ids is satisfied and recorded; a failing check never is", () => {
|
|
200
|
+
const sub = applyAmendments({ ...C, validate: [{ id: "V1", command: "poetry run pytest -k leak" }] }, [{ kind: "substitute-validate", validate: "V1", command: "uv run pytest -k leak", why: "no poetry" }]).contract;
|
|
201
|
+
const res = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
|
|
202
|
+
const pass = "t.py::a PASSED\nt.py::b PASSED\n";
|
|
203
|
+
const run = (frozen, s) => precheck({ contract: sub, result: res, changedFiles: files, substitutedRuns: { V1: { ...frozen, sub: s } } });
|
|
204
|
+
const ok = run({ rc: 1, output: pass }, { rc: 0, output: pass }); // frozen exited non-zero from the runner (coverage plugin), every test passed
|
|
205
|
+
assert.deepEqual(ok.failures, []);
|
|
206
|
+
assert.deepEqual(ok.equivalent.map((e) => e.id), ["V1"]);
|
|
207
|
+
const failing = "t.py::a PASSED\nt.py::b FAILED\n";
|
|
208
|
+
for (const [f, s] of [[{ rc: 1, output: failing }, { rc: 1, output: failing }], [{ rc: 1, output: failing }, { rc: 0, output: pass }], [{ rc: 1, output: pass }, { rc: 1, output: pass }], [{ rc: 1, output: pass }, { rc: 0, output: "t.py::a PASSED\n" }], [{ rc: 1, output: "boom" }, { rc: 0, output: "boom" }]]) {
|
|
209
|
+
assert.deepEqual(run(f, s).failures.map((x) => x.kind), ["validate_failed"], "both failing, a failing test, a failing substitute, other ids or no ids still fails");
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
it("#5653 a validate failing on a stale generated artifact is a base-sync recovery, not unimplemented work", () => {
|
|
213
|
+
const res = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 1 }] };
|
|
214
|
+
const c = { ...C, validate: [{ id: "V1", command: "node scripts/check-gen.mjs" }] };
|
|
215
|
+
const f = precheck({ contract: c, result: res, changedFiles: files, validateRuns: { V1: { rc: 1, output: "error: generated tools file is out of date" } } }).failures;
|
|
216
|
+
assert.deepEqual(f.map((x) => [x.kind, x.code]), [["validate_drift", "base.conflict"]]);
|
|
217
|
+
assert.deepEqual(precheck({ contract: c, result: res, changedFiles: files, validateRuns: { V1: { rc: 1, output: "AssertionError" } } }).failures.map((x) => x.kind), ["validate_failed"]);
|
|
218
|
+
});
|
|
219
|
+
it("#5653 a deliver requirement that only time or production can show must be classified, not delivered", () => {
|
|
220
|
+
const q = "Issues carry criteria like 14-day metrics";
|
|
221
|
+
const mk = (r) => validateContract({ ...C, requirements: [{ id: "R1", quote: q, disposition: "deliver", ...r }] }, q).problems.filter((p) => /needs time or production/.test(p));
|
|
222
|
+
assert.equal(mk({}).length, 1);
|
|
223
|
+
assert.equal(mk({ verify: "in_lane" }).length, 0);
|
|
224
|
+
assert.equal(mk({ verify: "out_of_band", evidence: "nightly job" }).length, 0);
|
|
225
|
+
assert.equal(mk({ disposition: "defer", why: "w", bucket: "date:2026-12-01" }).length, 0);
|
|
226
|
+
});
|
|
199
227
|
it("#4979 SPEC-2 a substitute stands only when the frozen command cannot run", () => {
|
|
200
228
|
const sub = applyAmendments({ ...C, validate: [{ id: "V1", command: "poetry run pytest -k leak" }] }, [{ kind: "substitute-validate", validate: "V1", command: "node --test test/leak.test.js", why: "no pyproject at root" }]).contract;
|
|
201
229
|
const res = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
|
|
@@ -833,7 +861,7 @@ describe("repro_test on bug lanes (#4271)", () => {
|
|
|
833
861
|
});
|
|
834
862
|
it("red on base and green on head passes; anything else fails the precheck as conformance.unimplemented", () => {
|
|
835
863
|
const k = { ...C, repro_test: RT };
|
|
836
|
-
assert.deepEqual(precheck({ contract: k, result: res, changedFiles: files, repro: { base: "FAILED", head: "RAN" } }), { ok: true, failures: [], superseded: [], ciCovered: [] });
|
|
864
|
+
assert.deepEqual(precheck({ contract: k, result: res, changedFiles: files, repro: { base: "FAILED", head: "RAN" } }), { ok: true, failures: [], superseded: [], ciCovered: [], equivalent: [] });
|
|
837
865
|
for (const repro of [{ base: "SKIPPED", head: "FAILED" }, { base: "UNRUNNABLE", head: "RAN" }, { base: "SKIPPED", head: "RAN_NOTHING" }]) {
|
|
838
866
|
const pc = precheck({ contract: k, result: res, changedFiles: files, repro });
|
|
839
867
|
assert.deepEqual(pc.failures.map((f) => [f.code, f.kind]), [["conformance.unimplemented", "repro_red_green"]], JSON.stringify(repro));
|