forgedock 1.59.2 → 1.60.1
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 +19 -6
- package/bin/lean/conformance.test.mjs +37 -3
- 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 +144 -21
- package/bin/lean/lean.test.mjs +180 -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 +67 -3
- package/bin/lean/preflight.test.mjs +37 -1
- 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 +110 -0
- package/bin/lean/validate-catalog.test.mjs +55 -0
- package/bin/pool/agent.mjs +12 -1
- package/bin/pool/lane-tools.mjs +146 -0
- package/bin/pool/lane-tools.test.mjs +26 -0
- package/bin/pool/router.mjs +3 -1
- package/bin/pool/warm.mjs +14 -3
- 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 +1 -1
- package/pool/README.md +2 -0
- package/scripts/acceptance-red-green.sh +5 -2
- package/scripts/acceptance-red-green.test.sh +11 -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
package/bin/lean/lean.mjs
CHANGED
|
@@ -29,7 +29,8 @@ import { checksAt, mergeCheckEntries, CHECKS_FILE } from "./postdeploy-check.mjs
|
|
|
29
29
|
import { matchBaselines, baselineFailures, foldRegression } from "./baselines.mjs";
|
|
30
30
|
import { readRollouts, detectNewOffKeys, rolloutModes, liveDeferralBlocks } from "./activation.mjs";
|
|
31
31
|
import { toolMisses } from "./toolplace.mjs";
|
|
32
|
-
import {
|
|
32
|
+
import { hasRecipe, installLaneTools } from "../pool/lane-tools.mjs";
|
|
33
|
+
import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins, manifestDepOwner } from "./preflight.mjs";
|
|
33
34
|
import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
34
35
|
import { splitGate, rationaleLine } from "./decompose.mjs";
|
|
35
36
|
import { ceilingFor, predictRestart, handoffFacts, NARROW_NOTE } from "./ceiling.mjs";
|
|
@@ -110,6 +111,7 @@ import { makePostRun } from "./postrun.mjs";
|
|
|
110
111
|
import { ensureSignedOff, salvageBranch, dropSalvageTracking } from "./signoff.mjs";
|
|
111
112
|
import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
|
|
112
113
|
import { createLedger, flattenPhases } from "./phaseledger.mjs";
|
|
114
|
+
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
113
115
|
import { runLightStep, runLightTests, lightBuildPrompt, upgradeNote, renderLiteReceipt } from "./lightlane.mjs";
|
|
114
116
|
|
|
115
117
|
/**
|
|
@@ -130,8 +132,16 @@ export const RECOVER_HOW = Object.freeze({
|
|
|
130
132
|
[OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED]: "an earlier run's conformance check found a requirement or validate command not done after one builder resume; the branch holds its work. For each named gap deliver the requirement against the frozen contract, adding any file it needs as an `add-deliverable` amendment, and re-run the validate commands",
|
|
131
133
|
[OUTCOME_CODES.CONFORMANCE_OMISSION]: "an earlier run's review found a requirement the change left out or narrowed after one builder resume; the branch holds its work. For each named gap either deliver the requirement (adding any needed file as an `add-deliverable` amendment) or, when the clause is optional, unquantified or outside the issue's acceptance criteria, record an `add-requirement` / `defer` amendment with a why so the engine files a tracked follow-up instead of stopping",
|
|
132
134
|
[OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL]: "an earlier run deferred a requirement without a sufficient why after one builder resume; the branch holds its work. An in-lane engineering deferral (bucket new-issue or none) must be delivered, never deferred (#5207). For each other named gap either deliver the requirement (adding any needed file as an `add-deliverable` amendment) or, when the clause is optional, unquantified or outside the issue's acceptance criteria, record a `defer` amendment with a concrete why so the engine files a tracked follow-up instead of stopping",
|
|
135
|
+
[OUTCOME_CODES.CONFORMANCE_REGRESSION]: "an earlier run's review found a regression (a compile, type or test failure the diff introduced, e.g. a removed symbol still referenced) that stayed after the builder resume rounds; the branch holds its work. Re-plan from the frozen contract: fix each named failure in the code and re-run the validate commands",
|
|
136
|
+
[OUTCOME_CODES.CONFORMANCE_SCOPE_CREEP]: "an earlier run changed files no deliverable names after the builder resume rounds; the branch holds its work. Re-plan from the frozen contract: revert each unnamed file or add it as an `add-deliverable` amendment with a why",
|
|
133
137
|
[OUTCOME_CODES.ENV_REPRO_UNRUNNABLE]: "the repro harness could not run the contract's repro_test on head (timeout, missing runner or dependencies); the change may already be correct. Do not edit the deliverables or stub dependencies for it and never install anything globally: run the repro command through the repo's own toolchain and installed dependencies, and when it cannot run in this checkout, fix the repro_test command (not the code) so it does",
|
|
134
138
|
});
|
|
139
|
+
/** #5644: review/conformance findings a builder can fix itself (code, test, deferral or scope gaps); an empty set is not fixable. */
|
|
140
|
+
const BUILDER_FIXABLE = [OUTCOME_CODES.CONFORMANCE_REGRESSION, OUTCOME_CODES.CONFORMANCE_UNIMPLEMENTED, OUTCOME_CODES.CONFORMANCE_OMISSION, OUTCOME_CODES.CONFORMANCE_UNJUSTIFIED_DEFERRAL, OUTCOME_CODES.CONFORMANCE_UNTRACKED_DEFERRAL, OUTCOME_CODES.CONFORMANCE_SCOPE_CREEP, OUTCOME_CODES.CONFORMANCE_PRESERVE_VIOLATED];
|
|
141
|
+
export function builderFixable(failures) {
|
|
142
|
+
const list = Array.isArray(failures) ? failures : [];
|
|
143
|
+
return list.length > 0 && list.every((f) => BUILDER_FIXABLE.includes(f?.code));
|
|
144
|
+
}
|
|
135
145
|
/** #5168: retry-in for a `backend.auth` deferral; the batch holds the account for it (an operator `--set-env` fix runs under a new identity). */
|
|
136
146
|
const AUTH_RETRY_SECONDS = 900;
|
|
137
147
|
/** #4323/#4334: precheck failure codes that are environment errors (state "environment"), never a builder resume. */
|
|
@@ -286,7 +296,7 @@ const defaultCredExec = (args) => {
|
|
|
286
296
|
export async function runCore(o) {
|
|
287
297
|
const armed = applyArmOverrides(o, o.issue); o = armed.options; // #5206: the arm's overrides shape the lane before any config is parsed
|
|
288
298
|
const { issue, repo, lane: requestedLane = null, laneOverride = false, branches = {}, cwd, dir, io, builderModel = null, reviewerModel = DEFAULT_REVIEWER_MODEL, fixModel = null,
|
|
289
|
-
toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, routeReachability = null, docsConfig = null, pagesConfig = null, designConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens = 120000, contextCeilingBySize = null, turnBudgets = null, laneLimits = null, maxMergeRetries = 5, contractMaxCorrections = 3, sessionLimitMaxWaitMs = DEFAULT_SESSION_LIMIT_WAIT_MS, contextWaitSeconds = 5, onProgress = () => {}, emitTelemetry = null, random = Math.random } = o;
|
|
299
|
+
toolchainOverride = null, testRunners = null, coupledFiles = null, validateRecipes = null, validateRegenerate = null, validateCatalogSources = null, routeReachability = null, docsConfig = null, pagesConfig = null, designConfig = null, prodParity = null, envSetup = null, ciMaxMinutes = 360, conformance = "shadow", conformanceKinds = null, conformanceMutation = "off", reviewIncomplete = "needs-human", reproTest = "prefer", reproQuality = "shadow", closeParent = false, mergeWait = "required", maxSessionLimitPauses = DEFAULT_MAX_SESSION_LIMIT_PAUSES, cliIdleMinutes = 15, cliMaxMinutes = 180, cliBusyMinutes = 45, contextCeilingTokens = 120000, contextCeilingBySize = null, turnBudgets = null, laneLimits = null, maxMergeRetries = 5, contractMaxCorrections = 3, reviewMaxResumes = 3, sessionLimitMaxWaitMs = DEFAULT_SESSION_LIMIT_WAIT_MS, contextWaitSeconds = 5, onProgress = () => {}, emitTelemetry = null, random = Math.random } = o;
|
|
290
300
|
const now = io.now ?? (() => Date.now());
|
|
291
301
|
const rotator = io.rotator !== undefined ? io.rotator : openRotator({ kind: o.accountRotator }); // #5094
|
|
292
302
|
// #5205: a rotator with pick() relaunches a limited phase pinned to another account; lane-level rotations and limited accounts
|
|
@@ -356,7 +366,8 @@ export async function runCore(o) {
|
|
|
356
366
|
if (phase === "implement") { builderTriggers.push({ trigger, restart_of: restartOf }); impl.cost += c.delta ?? 0; if (r?.model && r.model !== "default") impl.models.add(r.model); tb.note(num(r?.turns), stage === "implement"); }
|
|
357
367
|
ev(rec); await emit(rec);
|
|
358
368
|
modelMs += rec.duration_ms; // #4451: model time next to the lane's wall time
|
|
359
|
-
phaseLedger.
|
|
369
|
+
const ledgerNow = phaseLedger.current(); // #5649: model time of contract and fix calls lands in those phases
|
|
370
|
+
phaseLedger.addModel(phase === "review" ? "review" : ledgerNow === "contract" || ledgerNow === "fix" ? ledgerNow : stage === "plan" ? "plan" : "implement", rec.duration_ms, c.delta);
|
|
360
371
|
const u = r?.usage ?? {};
|
|
361
372
|
usage.cost_usd += c.delta ?? 0;
|
|
362
373
|
usage.input += u.input_tokens ?? 0; usage.output += u.output_tokens ?? 0;
|
|
@@ -389,7 +400,7 @@ export async function runCore(o) {
|
|
|
389
400
|
const myHost = o.hostName ?? osHostname();
|
|
390
401
|
// #4920: unique per lane. A sandbox's pid is 1, so `core_<pid>` made every remote lane the same holder and the lease never refused one.
|
|
391
402
|
const agentId = o.agentId ?? `core_${sanitizeLeaseHost(myHost)}_${o.pid ?? process.pid}_${randomBytes(3).toString("hex")}`;
|
|
392
|
-
const leaseObj = () => ({ by: agentId, until: now() + leaseTtlMs, host: myHost, pid: o.pid ?? process.pid });
|
|
403
|
+
const leaseObj = () => ({ by: agentId, until: now() + leaseTtlMs, host: myHost, pid: o.pid ?? process.pid, ...(o.batchId ? { batch: o.batchId } : {}) }); // #5654: the batch id lets its own requeue tell this lease from a foreign one
|
|
393
404
|
/** Provably dead: same host and `kill(pid, 0)` throws ESRCH. A different host keeps the TTL behaviour. */
|
|
394
405
|
const holderDead = (l) => {
|
|
395
406
|
const parsed = parseLeaseHolder(l?.by);
|
|
@@ -447,6 +458,43 @@ export async function runCore(o) {
|
|
|
447
458
|
let recoverUnlabelled = false; // #4297: the recovery lane removed needs-human; a final ci-pending (or needsHuman()) puts it back
|
|
448
459
|
const runId = `${issue}-${t0}`;
|
|
449
460
|
let runTmp = null, sandboxEnv = {}, sandboxDown = null; // #5450: test sandboxes of this lane (testsandbox.mjs)
|
|
461
|
+
/** #5557: after the plan call, derive the classification record from Affected Files + the base-ref unit map, post FORGE:CLASSIFY and namespaced labels. Fail-open; a no-op without `.forge/release.yaml`. */
|
|
462
|
+
async function classifyStage(correct) {
|
|
463
|
+
try {
|
|
464
|
+
const { parsePolicy, validatePolicy, POLICY_PATH } = await import("./release-config.mjs");
|
|
465
|
+
const C = await import("./release-classify.mjs");
|
|
466
|
+
let text; try { text = String(await git(["show", `${base}:${POLICY_PATH}`])); } catch { return; }
|
|
467
|
+
const { policy } = parsePolicy(text);
|
|
468
|
+
if (!policy || validatePolicy(policy).length) return;
|
|
469
|
+
const md = await io.fs.read(`${wt}/${INVESTIGATION_FILE}`).catch(() => "");
|
|
470
|
+
const { affectedFilesOf } = await import("./fastforward.mjs");
|
|
471
|
+
const files = affectedFilesOf(md);
|
|
472
|
+
const texts = {};
|
|
473
|
+
for (const f of files.filter((x) => /migrations\//.test(x))) texts[f] = String(await io.fs.read(`${wt}/${f}`).catch(() => ""));
|
|
474
|
+
const facts = C.deriveFacts(policy, files, { texts });
|
|
475
|
+
let llm = null; try { llm = JSON.parse(await io.fs.read(`${wt}/${C.CLASSIFICATION_FILE}`)); } catch { /* text-only below */ }
|
|
476
|
+
let problems = llm ? C.validateClassification(llm) : ["classification.json missing or unreadable"];
|
|
477
|
+
if (problems.length && correct) { // one correction, as for the contract; a second failure falls back to text-only
|
|
478
|
+
await correct(problems);
|
|
479
|
+
try { llm = JSON.parse(await io.fs.read(`${wt}/${C.CLASSIFICATION_FILE}`)); problems = C.validateClassification(llm); } catch { llm = null; problems = ["classification.json missing or unreadable"]; }
|
|
480
|
+
}
|
|
481
|
+
if (problems.length) { ev({ event: "CLASSIFY_INVALID", problems }); llm = { type: "chore", severity: "P3", exists_in: "unknown", confidence: 0.3 }; }
|
|
482
|
+
const live = policy.branches?.release;
|
|
483
|
+
let liveSha = null; if (live) liveSha = String(await git(["rev-parse", `origin/${live}`]).catch(() => "")).trim() || null;
|
|
484
|
+
let rec = C.buildClassifyRecord(llm, policy, facts, { text: problems.length > 0 });
|
|
485
|
+
const run = async (command, sha) => { // repro on a detached checkout of the live sha under the run TMPDIR (#5557)
|
|
486
|
+
const dir = `${runTmp ?? process.env.TMPDIR ?? "/tmp"}/classify-live-${issue}`;
|
|
487
|
+
await git(["worktree", "add", "--detach", dir, sha]);
|
|
488
|
+
try { const x = await io.runCommand({ command, cwd: dir, timeoutMs: 120000, env: laneEnv() }); const r = x?.r ?? x; const c = r?.rc ?? r?.exit; return typeof c === "number" ? c : 1; /* runCommand reports rc */ }
|
|
489
|
+
finally { await git(["worktree", "remove", "--force", dir]).catch(() => {}); }
|
|
490
|
+
};
|
|
491
|
+
rec = await C.verifyExistsIn(rec, { git: (a) => git(a), liveSha, run: io.runCommand ? run : undefined });
|
|
492
|
+
if (rec.exists_in === "unknown" && rec.lane_hint === "none") rec.lane_hint = "release";
|
|
493
|
+
await io.fs.write?.(`${wt}/${C.CLASSIFICATION_FILE}`, JSON.stringify(rec, null, 1));
|
|
494
|
+
await post("FORGE:CLASSIFY", C.renderClassify(rec));
|
|
495
|
+
for (const l of C.labelsOf(rec)) { try { await ghc(["issue", "edit", String(issue), "-R", repo, "--add-label", l]); } catch { /* label may not exist */ } }
|
|
496
|
+
} catch (e) { ev({ event: "CLASSIFY_FAILED", error: String(e?.message ?? e).slice(0, 200) }); }
|
|
497
|
+
}
|
|
450
498
|
let sparse = null; // #4221: {excluded, maxKb} when the lane worktree is a sparse checkout; null leaves prompts unchanged
|
|
451
499
|
// #4395: lane profile. full (FORGEDOCK_FULL_SESSION=1): unchanged sessions; memory-off: no auto-memory; lane: also no CLAUDE.md, the lane file appended
|
|
452
500
|
let laneProfile = { name: process.env.FORGEDOCK_FULL_SESSION === "1" ? "full" : "memory-off", text: null };
|
|
@@ -600,6 +648,7 @@ export async function runCore(o) {
|
|
|
600
648
|
const wf = ["investigating", "building", "in-review"].map((x) => `workflow:${x}`).join(",");
|
|
601
649
|
try { await ghc(["issue", "edit", String(issue), "-R", repo, "--remove-label", wf]); } catch { /* best effort */ }
|
|
602
650
|
}
|
|
651
|
+
if (recover) { try { await ghc(["issue", "edit", String(issue), "-R", repo, "--remove-label", "workflow:recovering"]); } catch { /* best effort (#5647): the batch re-marks a requeued attempt */ } }
|
|
603
652
|
if (["merged", "invalid", "needs-human", "budget-exceeded"].includes(reason)) {
|
|
604
653
|
if (reason === "budget-exceeded") T.close = ["left open", "recoverable budget.exceeded"]; // #4505: not a human escalation
|
|
605
654
|
else if (reason === "merged") T.close = [extra.keptOpen ? "left open (follow-up pending)" : extra.close === "partial" ? "issue closed (partial)" : "issue closed (completed)", "label workflow:merged"]; // #5159
|
|
@@ -1830,6 +1879,13 @@ export async function runCore(o) {
|
|
|
1830
1879
|
await git(["add", "--", CHECKS_FILE]); await git(["commit", "--no-verify", "-m", "chore(forge): generated post-deploy checks for production-only e2e requirements (#5468)"]);
|
|
1831
1880
|
} catch (e) { T.anomalies.push(`generated post-deploy checks not committed: ${String(e?.message ?? e).slice(0, 160)}`); }
|
|
1832
1881
|
}
|
|
1882
|
+
let freezeTracked = []; // #5683: tracked paths, for the sub-project venv rewrite at freeze
|
|
1883
|
+
/** #5683: name -> the sub-project dir whose tracked manifest declares it (a project dependency, not a host tool), else null. */
|
|
1884
|
+
async function depOwnerOf() {
|
|
1885
|
+
const files = String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean), texts = new Map();
|
|
1886
|
+
for (const f of files) if (/(^|\/)(package\.json|pyproject\.toml|requirements[\w.-]*\.txt)$/.test(f) && !f.split("/").includes("node_modules")) texts.set(f, String(await io.fs.read(`${wt}/${f}`).catch(() => "")));
|
|
1887
|
+
return { files, owner: (name) => manifestDepOwner(name, files, (f) => texts.get(f) ?? "") };
|
|
1888
|
+
}
|
|
1833
1889
|
function freezeRewrites(c) {
|
|
1834
1890
|
const r = applyValidateRecipes(c, validateRecipes);
|
|
1835
1891
|
const pd = (id, cmd) => { const to = rewriteProjectDirCommand(cmd); if (to !== cmd) T.decisions.push(`project-dir rewrite of ${id}: \`${cmd}\` -> \`${to}\``); return to; };
|
|
@@ -1839,6 +1895,9 @@ export async function runCore(o) {
|
|
|
1839
1895
|
if (t && typeof t === "object" && typeof t.command === "string") r.contract = { ...r.contract, repro_test: { ...t, command: pd("repro_test", t.command) } };
|
|
1840
1896
|
}
|
|
1841
1897
|
for (const x of r.applied) T.decisions.push(`validate recipe rewrote ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
1898
|
+
const vr = rewriteSubprojectVenv(r.contract, freezeTracked, (rel) => existsSync(join(wt, rel))); // #5683
|
|
1899
|
+
r.contract = vr.contract;
|
|
1900
|
+
for (const x of vr.applied) T.decisions.push(`sub-project venv rewrite of ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
1842
1901
|
r.contract = foldRegression(r.contract); // #5448: the blast-radius regression set runs as validate G# entries
|
|
1843
1902
|
const e = autoPostDeployE2e(r.contract); // #5468: production-only e2e/manual rows become post-deploy with a generated check
|
|
1844
1903
|
for (const x of e.converted) { if (x.check) genChecks[x.check] = x.entry; T.decisions.push(`Production-only e2e/manual requirement ${x.id} frozen as post-deploy with ${x.check ? `generated check ${x.check}` : "no check (production observation window)"}`); }
|
|
@@ -1999,7 +2058,8 @@ export async function runCore(o) {
|
|
|
1999
2058
|
* #4363: one fix round. Mechanical failures (and a conformance/review FAIL citing file:line) run in a fresh session on
|
|
2000
2059
|
* the fix model with a narrow prompt; one resume of the build session follows when it made no commit. Else: a resume.
|
|
2001
2060
|
*/
|
|
2002
|
-
|
|
2061
|
+
function fixRound(...a) { return phaseLedger.during("fix", () => fixRoundRaw(...a)); } // #5649: fix rounds are their own ledger phase
|
|
2062
|
+
async function fixRoundRaw(kind, task, failures, trigger, failureText = "", narrow = null) { // #5348: `narrow` {files} = the minimal profile (no diff, no lane text)
|
|
2003
2063
|
await notePitfall(trigger, failureText); await escalateOn(trigger); // #4375: learned once the same gate passes; #4394
|
|
2004
2064
|
if (!freshFix(kind, failures)) return await builder(++attemptN, task, sessionId ?? null, false, undefined, { mode: "resume", trigger });
|
|
2005
2065
|
const before = String(await git(["rev-parse", "HEAD"])).trim();
|
|
@@ -2133,7 +2193,8 @@ export async function runCore(o) {
|
|
|
2133
2193
|
{ const f = await gateSetup(); if (f) return f; } // #5434: the light build is an implement-class session
|
|
2134
2194
|
liveKeys = ["implementation"]; stage = "implement"; phaseLedger.enter("implement");
|
|
2135
2195
|
tb.setSize(recoverySize(laneSize({ labels: (iss?.labels ?? []).map((l) => l?.name ?? l) }), recover)); // #4505
|
|
2136
|
-
const
|
|
2196
|
+
const lightBase = pagesConfig ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : null; // #5648: pages already on the base are modified, not new
|
|
2197
|
+
const lr = await runLightStep({ title: iss.title, issueText, riskPaths, predictedFiles: lightPred ?? namedPaths(iss.body ?? ""), cfg: o.light ?? {}, validate: (c) => validateContract(c, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: lightBase, testPlan: reproOn() }),
|
|
2137
2198
|
build: () => builder(++attemptN, (ffGo ? FF_BUILD_LEAD : "") + lightBuildPrompt(issue, tcOpts()) + hotspotBuildRule(hotFacts) + enumeratingBuildRule(enumList) + invariantsBuildRule(vcfg.invariants), ffGo ? sessionId : null, true, undefined, { trigger: "build" }),
|
|
2138
2199
|
readResult, checkpoint: () => checkpoint("light build"), changedFiles, reproOf, numstat: () => git(["diff", "--numstat", `${base}...HEAD`]),
|
|
2139
2200
|
runTests: async (cmds) => (io.runCommand ? runLightTests({ commands: mergeChecks(vcfg.invariants ?? [], cmds).commands, parallelism: Number(verifyParallelism()) || 1, now, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, acquire: () => heavyAcquire("precheck"), // #4451: host-capped
|
|
@@ -2168,7 +2229,7 @@ export async function runCore(o) {
|
|
|
2168
2229
|
}
|
|
2169
2230
|
}
|
|
2170
2231
|
if (!frozen) {
|
|
2171
|
-
if (ffPlan === "contract") await builder(++attemptN, contractStepPrompt(issue, tcOpts()) + recoverNote() + decisionsNote, sessionId, true, planPrompt, { mode: "resume", trigger: "plan" }); // #5426: same session, investigation already written
|
|
2232
|
+
if (ffPlan === "contract") await phaseLedger.during("contract", () => builder(++attemptN, contractStepPrompt(issue, tcOpts()) + recoverNote() + decisionsNote, sessionId, true, planPrompt, { mode: "resume", trigger: "plan" })); // #5426: same session, investigation already written
|
|
2172
2233
|
else if (ffPlan === "full") { const tPrompt = now(), planText = planPrompt(); setupStep("prompt_assembly", tPrompt); await builder(++attemptN, planText + (hasCommits || lightCommits ? PLAN_RERUN_NOTE.replace("BASE", lane) : "") + recoverNote() + resumeNote + decisionsNote, null, true, planPrompt, { trigger: "plan" }); }
|
|
2173
2234
|
planned = true;
|
|
2174
2235
|
result = await readResult();
|
|
@@ -2206,6 +2267,7 @@ export async function runCore(o) {
|
|
|
2206
2267
|
return o.contract;
|
|
2207
2268
|
};
|
|
2208
2269
|
let contract = dropScope(await readContract());
|
|
2270
|
+
freezeTracked = (await depOwnerOf()).files;
|
|
2209
2271
|
contract = freezeRewrites(contract);
|
|
2210
2272
|
await persistGenChecks();
|
|
2211
2273
|
await refreshIssue("contract validation");
|
|
@@ -2215,10 +2277,24 @@ export async function runCore(o) {
|
|
|
2215
2277
|
return sq.contract;
|
|
2216
2278
|
};
|
|
2217
2279
|
contract = snapContract(contract);
|
|
2280
|
+
await classifyStage(sessionId ? (problems) => builder(++attemptN, `${contractCorrectionPrompt(problems)}\nThis concerns .forge-lean/classification.json: fix only the invalid fields.`, sessionId, false, planPrompt, { trigger: "contract_correction" }) : null);
|
|
2218
2281
|
const wtRead = (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }; // #5585: noindex pages are not public
|
|
2282
|
+
const freezeBase = pagesConfig ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : null; // #5648
|
|
2219
2283
|
const freezeCheckIds = await (async () => { try { return new Set(Object.keys(await checksAt(git, [base], wt))); } catch { return null; } })(); // first-pass: the base's registered post-deploy check ids
|
|
2220
|
-
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2221
|
-
const
|
|
2284
|
+
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2285
|
+
const found0 = await preflightValidates(contract); // #4328: validate commands the host cannot run share the one correction
|
|
2286
|
+
let missed = found0;
|
|
2287
|
+
// #5653: an unrunnable command is rewritten from the repo catalogue (forge.yaml recipes first, then CI-derived) before any builder correction
|
|
2288
|
+
if (found0.length) {
|
|
2289
|
+
const texts = (validateCatalogSources ?? DEFAULT_CATALOG_SOURCES).map(wtRead);
|
|
2290
|
+
const rw = rewriteMissed(contract, mergeRecipes(validateRecipes, deriveCatalog(texts)), found0.flatMap((m) => m.ids ?? []), applyValidateRecipes);
|
|
2291
|
+
if (rw.applied.length) {
|
|
2292
|
+
contract = snapContract(rw.contract);
|
|
2293
|
+
for (const x of rw.applied) T.decisions.push(`validate catalogue rewrote unrunnable ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
2294
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2295
|
+
missed = await preflightValidates(contract);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2222
2298
|
let misses = missed;
|
|
2223
2299
|
const correctContract = async (problems, note) => {
|
|
2224
2300
|
T.decisions.push(`Contract rejected (${problems[0]}); ${note}`);
|
|
@@ -2227,7 +2303,7 @@ export async function runCore(o) {
|
|
|
2227
2303
|
await persistGenChecks();
|
|
2228
2304
|
await refreshIssue("contract validation");
|
|
2229
2305
|
contract = snapContract(contract);
|
|
2230
|
-
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2306
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2231
2307
|
};
|
|
2232
2308
|
if ((!vc.ok || missed.length || testRunnerProblems(contract, testRunners).length) && sessionId) {
|
|
2233
2309
|
await correctContract([...vc.problems, ...preflightProblems(missed), ...testRunnerProblems(contract, testRunners)], "resumed once");
|
|
@@ -2244,8 +2320,8 @@ export async function runCore(o) {
|
|
|
2244
2320
|
}
|
|
2245
2321
|
if (!vc.ok) ev({ event: "CONTRACT_INVALID_RULES", rules: contractRuleCounts(vc.problems) }), await emit({ event: "CONTRACT_INVALID_RULES", rules: contractRuleCounts(vc.problems) }); // #5587: per-rule counts for the batch false-park rate
|
|
2246
2322
|
planMisses = misses;
|
|
2247
|
-
if (
|
|
2248
|
-
ev({ event: "VALIDATE_PREFLIGHT", misses: misses.map((m) => ({ ids: m.ids, tool: m.tool, kind: m.kind, source: m.source })), found:
|
|
2323
|
+
if (found0.length) {
|
|
2324
|
+
ev({ event: "VALIDATE_PREFLIGHT", misses: misses.map((m) => ({ ids: m.ids, tool: m.tool, kind: m.kind, source: m.source })), found: found0.map((m) => ({ ids: m.ids, tool: m.tool, kind: m.kind, source: m.source })), corrected: misses.length === 0 });
|
|
2249
2325
|
if (misses.length) {
|
|
2250
2326
|
T.anomalies.push(`Validate preflight: the host lacks ${misses.map((m) => m.tool).join(", ")} after the contract correction (advisory; a failed rerun ends env.tool_missing)`);
|
|
2251
2327
|
T.decisions.push(`Validate preflight left ${misses.length} miss(es) after one correction; contract frozen anyway`);
|
|
@@ -2270,15 +2346,19 @@ export async function runCore(o) {
|
|
|
2270
2346
|
}
|
|
2271
2347
|
const dgFiles = (frozen?.deliverables ?? []).map((d) => d?.path).filter(Boolean);
|
|
2272
2348
|
const designComments = (iss?.comments ?? []).filter(isTrustedIssueComment);
|
|
2273
|
-
const
|
|
2349
|
+
const dgBase = dgFiles.length && designConfig ? String(await git(["ls-tree", "--name-only", base, "--", ...dgFiles]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean) : []; // #5648: deliverables already on the base are modified pages
|
|
2350
|
+
const designRoute = designGate({ files: dgFiles, cfg: designConfig, comments: designComments, labels: iss?.labels, baseFiles: dgBase }); // #5330: opt-in (forge.yaml design.routes): a page without a FORGE:DESIGN_SPEC goes to /design
|
|
2274
2351
|
if (designRoute.route) {
|
|
2275
2352
|
ev({ event: "DESIGN_ROUTED", pages: designRoute.pages, blocked: designRoute.blocked });
|
|
2276
2353
|
T.decisions.push(`Design gate: ${designRoute.reason}${designRoute.blocked ? " (design.gate: blocking, lane stopped)" : " (advisory)"}`);
|
|
2277
2354
|
if (designRoute.blocked) return await needsHuman(`Design gate (forge.yaml design.gate: blocking): ${designRoute.reason}.\n\nRun /design on #${issue}; a FORGE:DESIGN_SPEC comment or the \`${designConfig.specLabel}\` label lifts the hold.`, OUTCOME_CODES.DESIGN_SPEC_REQUIRED, { ask: `Run /design for #${issue} (${designRoute.pages.slice(0, 3).join(", ")})` });
|
|
2278
2355
|
}
|
|
2279
2356
|
{ // #5447: the test plan's declared env is checked on the host the lane runs on before building; a missing runner is provisioned once, else the lane ends env.tool_missing (the orchestrator re-places it on a host that has it)
|
|
2280
|
-
const
|
|
2357
|
+
const deps5683 = await depOwnerOf(), projEnv = () => { const e = laneEnv(); const d = projectBinDirs(wt, deps5683.files); if (d.length) e.PATH = withLocalBins(e.PATH ?? process.env.PATH ?? "", d); return e; };
|
|
2358
|
+
const projDeps = declaredEnv(frozen).filter((t) => deps5683.owner(t) !== null); // #5683: a sub-project's declared dependency is prepared and resolved through its bin dirs, never a host tool
|
|
2359
|
+
const probeEnv = async () => { const miss = []; for (const t of declaredEnv(frozen)) { if (deps5683.owner(t) !== null) continue; const r = io.runCommand ? await io.runCommand({ command: t === "pytest" ? "python3 -m pytest --version" : `command -v ${t} >/dev/null || { test -d node_modules/${t} && ! test -e node_modules/.bin/${t}; } || ls -d .venv/lib/python*/site-packages/${t} >/dev/null 2>&1`, cwd: wt, timeoutMs: 30000, env: projEnv() }).catch(() => ({ rc: 1 })) : { rc: 0 }; if ((r?.rc ?? 0) !== 0) miss.push(t); } return miss; };
|
|
2281
2360
|
let envMiss = await probeEnv();
|
|
2361
|
+
if (projDeps.length && io.deps?.prepare) { try { await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined }); ev({ event: "TESTPLAN_ENV_PROJECT_DEPS", names: projDeps }); } catch { /* the install gate reports failures */ } }
|
|
2282
2362
|
if (envMiss.length) {
|
|
2283
2363
|
try {
|
|
2284
2364
|
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
@@ -2304,15 +2384,29 @@ export async function runCore(o) {
|
|
|
2304
2384
|
const hn = contractHostNeeds(frozen, o.hostCaps && { ...o.hostCaps, hostCapabilities: (o.hostCaps.hostCapabilities ?? []).filter((c) => !relayed.has(c)) });
|
|
2305
2385
|
if (hn.caps.length) return await needsHuman(`Remote sandbox lacks host capability ${hn.caps.join(", ")}, which the frozen contract's validate command(s) ${hn.ids.join(", ")} need.\n\nThe dispatching host has it; the lane is recovered locally with the frozen contract.`, OUTCOME_CODES.ENV_CAPABILITY_REMOTE);
|
|
2306
2386
|
// #5331: a tool the sandbox itself lacks (probed where the lane runs) ends the lane before the builder implements; the tool-missing recovery places it on the host (orchestrate placeOf)
|
|
2307
|
-
|
|
2387
|
+
const remoteDeps = await depOwnerOf(); // #5683: a tool that is a tracked manifest dependency is prepared in the sandbox, never a lane_tools recipe or a host tool
|
|
2388
|
+
const ownedDep = (t) => remoteDeps.owner(t) !== null, notOwned = (m) => ({ ...m, tools: m.tools.filter((t) => !ownedDep(t)) });
|
|
2389
|
+
let tm0 = toolMisses(planMisses ?? await preflightValidates(frozen).catch(() => [])), tm = notOwned(tm0);
|
|
2390
|
+
if (tm0.tools.length && !tm.tools.length) { try { if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined }); ev({ event: "REMOTE_PROJECT_DEPS", tools: tm0.tools }); } catch { /* the install gate reports failures */ } }
|
|
2308
2391
|
if (tm.tools.length) { // #5423: provision the sandbox once (nested lockfiles, pytest) and re-probe before giving the lane up
|
|
2309
2392
|
try {
|
|
2310
2393
|
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
2311
2394
|
if (tm.tools.includes("pytest") && io.runCommand) await io.runCommand({ command: "python3 -m pip install --user --quiet pytest", cwd: wt, timeoutMs: 180000, env: laneEnv() });
|
|
2312
|
-
tm = toolMisses(await preflightValidates(frozen).catch(() => []));
|
|
2395
|
+
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2313
2396
|
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
2314
2397
|
} catch { /* keep the original miss */ }
|
|
2315
2398
|
}
|
|
2399
|
+
if (tm.tools.length) { // #5652: a recipe-backed tool is installed in this sandbox and re-probed before any host re-placement
|
|
2400
|
+
const withRecipe = tm.tools.filter(hasRecipe), noRecipe = tm.tools.filter((t) => !hasRecipe(t));
|
|
2401
|
+
if (withRecipe.length && io.runCommand) {
|
|
2402
|
+
const ins = await installLaneTools(withRecipe, { run: (a) => io.runCommand({ command: a.command, cwd: wt, timeoutMs: a.timeoutMs, env: laneEnv() }), root: process.getuid?.() === 0 });
|
|
2403
|
+
ev({ event: "REMOTE_TOOLS_INSTALLED", tools: withRecipe, ok: ins.ok });
|
|
2404
|
+
if (!ins.ok) return await needsHuman(`Installing ${ins.tool} in the remote sandbox failed (execution.lane_tools recipe); not re-placed on the host. Install stderr tail:\n${ins.stderrTail}`, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
2405
|
+
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2406
|
+
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
2407
|
+
}
|
|
2408
|
+
if (noRecipe.length && tm.tools.some((t) => noRecipe.includes(t))) return await needsHuman(`Remote sandbox lacks ${noRecipe.join(", ")}, and no lane_tools recipe exists for ${noRecipe.length > 1 ? "them" : "it"}. Add it to \`execution.lane_tools\` in forge.yaml once a recipe exists, or add a recipe for ${noRecipe.join(", ")} in bin/pool/lane-tools.mjs (RECIPES).`, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
2409
|
+
}
|
|
2316
2410
|
if (tm.tools.length) {
|
|
2317
2411
|
ev({ event: "REMOTE_TOOL_MISSING", tools: tm.tools, ids: tm.ids });
|
|
2318
2412
|
return await needsHuman(`Remote sandbox lacks ${tm.tools.join(", ")}, which the frozen contract's validate command(s) ${tm.ids.join(", ")} need; the lane is re-placed on the host before the builder implements.`, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
@@ -2820,7 +2914,7 @@ export async function runCore(o) {
|
|
|
2820
2914
|
const kindsNow = () => (riskEnforced ? null : kinds);
|
|
2821
2915
|
const recording = () => shadow || (!riskEnforced && Object.keys(kinds).length > 0); // the gate records what it would have blocked
|
|
2822
2916
|
const blockingOf = (fs, allow) => blockingFailures(fs, { shadow, kinds: kindsNow(), allow });
|
|
2823
|
-
let effective = frozen, review = null, lastAmend = "", resumes = 0, verdict = null, degraded = null, triggerSkipped = false, selfReviewCompared = false;
|
|
2917
|
+
let effective = frozen, review = null, lastAmend = "", resumes = 0, lastFailKey = null, verdict = null, degraded = null, triggerSkipped = false, selfReviewCompared = false;
|
|
2824
2918
|
const TRIGGER_SKIP = "skipped (review.trigger enforce: no risk trigger)";
|
|
2825
2919
|
const triggerSkipNote = "## Conformance Review\n**Skipped by `review.trigger: enforce`:** no risk path, package edge or hotspot in the diff, and every deterministic gate passed; no reviewer ran (#4273).";
|
|
2826
2920
|
let pendingDecisions = [], firstRounds = null, firstReply = null;
|
|
@@ -2956,6 +3050,27 @@ export async function runCore(o) {
|
|
|
2956
3050
|
const note = `Validate ${v.id} hit a runner usage error; reran normalised (\`${fixed}\`): exit ${x?.rc}`;
|
|
2957
3051
|
if (!T.decisions.includes(note)) T.decisions.push(note);
|
|
2958
3052
|
}
|
|
3053
|
+
// #5653: a stale generated artifact (base drift) is mechanical: base-sync (a clean merge of the lane tip), then the repo's configured regenerate command, then one rerun
|
|
3054
|
+
if (x && x.rc !== 0 && x.rc !== 124 && isDriftFailure(x.output)) {
|
|
3055
|
+
try {
|
|
3056
|
+
const rerunV = async () => await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.command), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r);
|
|
3057
|
+
let note = "";
|
|
3058
|
+
if (Number(String(await git(["rev-list", "--count", `HEAD..${base}`]).catch(() => "0")).trim()) > 0) {
|
|
3059
|
+
try { await git(["merge", "--no-edit", base]); note = `base-synced onto ${base}`; } catch { await git(["merge", "--abort"]).catch(() => {}); }
|
|
3060
|
+
if (note) { const again = await rerunV(); if (again?.rc === 0) { x = again; T.decisions.push(`Validate ${v.id} failed on a stale generated artifact; ${note} and the rerun passed (base drift, not a conformance failure)`); } }
|
|
3061
|
+
}
|
|
3062
|
+
if (validateRegenerate && x.rc !== 0) {
|
|
3063
|
+
const status = async () => String(await git(["status", "--porcelain"]).catch(() => "")).split("\n").filter(Boolean);
|
|
3064
|
+
const before = new Set(await status());
|
|
3065
|
+
await heavyStep("precheck", () => io.runCommand({ command: forgedockResolved(validateRegenerate), cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env }));
|
|
3066
|
+
const added = (await status()).filter((l) => !before.has(l)); // regeneration must leave nothing new to commit: the lane's diff stays its own
|
|
3067
|
+
if (!added.length) {
|
|
3068
|
+
const again = await rerunV();
|
|
3069
|
+
if (again?.rc === 0) { x = again; T.decisions.push(`Validate ${v.id} failed on a stale generated artifact; ${note ? `${note}, ` : ""}\`${validateRegenerate}\` then a rerun passed (base drift, not a conformance failure)`); }
|
|
3070
|
+
} else for (const l of added.filter((l) => /^ M /.test(l))) await git(["checkout", "--", l.slice(3)]).catch(() => {}); // undo only the files regeneration modified
|
|
3071
|
+
}
|
|
3072
|
+
} catch { /* fail-open: the original failure stands */ }
|
|
3073
|
+
}
|
|
2959
3074
|
out[v.id] = { rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") };
|
|
2960
3075
|
}
|
|
2961
3076
|
if (Object.keys(out).length) ev({ event: "VALIDATE_RERUN", runs: Object.entries(out).map(([id, x]) => ({ id, rc: x.rc })) });
|
|
@@ -2971,6 +3086,11 @@ export async function runCore(o) {
|
|
|
2971
3086
|
let x;
|
|
2972
3087
|
try { x = await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.substituted.from), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r); } catch (e) { x = { rc: 127, output: String(e?.message ?? e) }; }
|
|
2973
3088
|
out[v.id] = { rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") };
|
|
3089
|
+
// #5653: the substitute runs too, so conformance can judge "same test ids, same result" (equivalentRuns)
|
|
3090
|
+
if (out[v.id].rc !== 0 && out[v.id].rc !== 124) {
|
|
3091
|
+
let y; try { y = await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.command), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r); } catch { y = null; }
|
|
3092
|
+
if (y) out[v.id].sub = { rc: Number.isInteger(y.rc) ? y.rc : 1, output: String(y.output ?? "") };
|
|
3093
|
+
}
|
|
2974
3094
|
}
|
|
2975
3095
|
if (Object.keys(out).length) ev({ event: "SUBSTITUTE_RERUN", runs: Object.entries(out).map(([id, x]) => ({ id, rc: x.rc })) });
|
|
2976
3096
|
return out;
|
|
@@ -3070,9 +3190,10 @@ export async function runCore(o) {
|
|
|
3070
3190
|
// #5419: forge.yaml docs: user-facing surfaces need docs, and added /docs links must resolve; unset = no check
|
|
3071
3191
|
const docsFail = docsConfig ? await docsFailures({ cfg: docsConfig, files, result, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), tracked: String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean), run: io.runCommand ? async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } : null }) : [];
|
|
3072
3192
|
// #5428: forge.yaml pages: a public page needs design, SEO and GEO briefs and passes the deterministic page checks; unset = no check
|
|
3073
|
-
const
|
|
3193
|
+
const addedNow = String(await git(["diff", "--name-only", "--diff-filter=A", `${base}...HEAD`]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean); // #5648: new vs modified pages
|
|
3194
|
+
const pageFail = pagesConfig ? await pageFailures({ cfg: pagesConfig, files, result, added: addedNow, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), tracked: String(await git(["ls-files"]).catch(() => "")).split("\n").filter(Boolean), readFile: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }, designApproved: designLabelApproved(iss?.labels) || designSpecApproved((iss?.comments ?? []).filter(isTrustedIssueComment)), run: io.runCommand ? async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } : null }) : [];
|
|
3074
3195
|
// #5330: forge.yaml design.routes (opt-in, blocking only): a user-visible page needs an approved spec and passes the deterministic visual critique
|
|
3075
|
-
const designFail = designFailures({ cfg: designConfig, files, specs: designSpecOk({ comments: (iss?.comments ?? []).filter(isTrustedIssueComment), labels: iss?.labels, cfg: designConfig }), readFile: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } } });
|
|
3196
|
+
const designFail = designFailures({ cfg: designConfig, files, added: addedNow, diff: String(await git(["diff", "-U0", `${base}...HEAD`]).catch(() => "")), specs: designSpecOk({ comments: (iss?.comments ?? []).filter(isTrustedIssueComment), labels: iss?.labels, cfg: designConfig }), readFile: (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } } });
|
|
3076
3197
|
// #5284: forge.yaml topology.prod_parity: declared production-only surfaces this diff touches need a check result or a justification
|
|
3077
3198
|
const parityRules = parseProdParity(prodParity);
|
|
3078
3199
|
const prodParityFailures = parityRules.length && io.runCommand ? await prodParityOf({ rules: parityRules, changedFiles: files, result, run: async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } }) : [];
|
|
@@ -3296,9 +3417,11 @@ export async function runCore(o) {
|
|
|
3296
3417
|
}
|
|
3297
3418
|
if (outcome.state === "review.incomplete") return await needsHuman(`The conformance review was incomplete twice (a review without complete rows cannot pass); nothing merged:\n${list}`, OUTCOME_CODES.REVIEW_INCOMPLETE);
|
|
3298
3419
|
if (outcome.state === "review.inconsistent") return await needsHuman(`The conformance reviewer twice said NONCONFORMING without a failing row; nothing merged.`, OUTCOME_CODES.REVIEW_INCONSISTENT);
|
|
3299
|
-
|
|
3420
|
+
let failKey = JSON.stringify((outcome.failures ?? []).map((f) => `${f.code}|${f.detail}`).sort()); // #5644: a round that leaves the failure set unchanged ends the rounds
|
|
3421
|
+
if (!sessionId || resumes >= (builderFixable(outcome.failures) ? reviewMaxResumes : 1) || failKey === lastFailKey) return await needsHuman(`The change does not conform to the issue and its frozen contract after ${resumes ? (resumes === 1 ? "one builder resume" : `${resumes} builder resumes`) : "the build (no session to resume)"} (${outcome.by}); nothing merged:\n${list}`, outcome.failures?.[0]?.code);
|
|
3422
|
+
lastFailKey = failKey;
|
|
3300
3423
|
resumes++;
|
|
3301
|
-
T.decisions.push(`Not conforming (${outcome.by}${outcome.inconsistent ? ", reviewer verdict contradicted its rows" : ""}): ${[...new Set(outcome.failures.map((f) => f.code))].join(", ")} (${explained.slice(0, 5).map((f) => String(f.detail).slice(0, 160)).join("; ")}); builder resumed
|
|
3424
|
+
T.decisions.push(`Not conforming (${outcome.by}${outcome.inconsistent ? ", reviewer verdict contradicted its rows" : ""}): ${[...new Set(outcome.failures.map((f) => f.code))].join(", ")} (${explained.slice(0, 5).map((f) => String(f.detail).slice(0, 160)).join("; ")}); builder resumed (round ${resumes} of ${reviewMaxResumes})`);
|
|
3302
3425
|
// A failed validate may only mean the base moved on: fetch the lane so the resume can merge it (never rebase).
|
|
3303
3426
|
if (outcome.failures.some((f) => f?.kind === "validate_failed")) { try { await io.git(["fetch", "origin", lane], { cwd: wt }); } catch { /* offline: the resume uses the local ref */ } }
|
|
3304
3427
|
await fixRound("conformance", conformanceResumePrompt(outcome.failures, vcfg.mode, lane), outcome.failures, "conformance", failureLog(outcome.failures));
|