forgedock 1.61.1 → 1.61.2
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-cli.mjs +3 -3
- package/bin/lean/conformance.mjs +33 -11
- package/bin/lean/conformance.test.mjs +39 -1
- package/bin/lean/effects.mjs +9 -3
- package/bin/lean/execution.mjs +40 -8
- package/bin/lean/execution.test.mjs +57 -0
- package/bin/lean/lean.mjs +22 -12
- package/bin/lean/lean.test.mjs +82 -4
- package/bin/lean/prompts.mjs +1 -1
- package/bin/lean/repro-output.test.mjs +45 -0
- package/bin/pool/agent.mjs +5 -1
- package/package.json +1 -1
- package/scripts/acceptance-red-green.sh +8 -3
- package/scripts/acceptance-red-green.test.sh +8 -0
package/bin/engine-cli.mjs
CHANGED
|
@@ -36,7 +36,7 @@ import { normalizeKindModes } from "./lean/conformance.mjs";
|
|
|
36
36
|
import { parseEnforceDomains } from "./lean/review-trigger.mjs";
|
|
37
37
|
import { viewIssue } from "./lean/gh-assoc.mjs";
|
|
38
38
|
import { otherLaneOwner, clearLease } from "./lean/lanelock.mjs";
|
|
39
|
-
import { parseExecution,
|
|
39
|
+
import { parseExecution, placementNeeds, hostFallbackAllowed } from "./lean/execution.mjs";
|
|
40
40
|
import { openRotator, rotatorKind } from "./lean/rotator.mjs";
|
|
41
41
|
import { relayPrefetchCommands } from "./lean/relay.mjs";
|
|
42
42
|
import { parseCeilingBySize } from "./lean/ceiling.mjs";
|
|
@@ -2228,8 +2228,8 @@ export async function runBatch({ argv, cwd: callerCwd = process.cwd(), env: call
|
|
|
2228
2228
|
sink.line(`cross-lane: #${e.issue} (${e.lane}) depends on #${e.dependency} (${e.dependencyLane}); its fix will not be on ${e.lane}: re-milestone #${e.dependency} or wait for a milestone sync`);
|
|
2229
2229
|
},
|
|
2230
2230
|
readBody: maint || registry || hybrid
|
|
2231
|
-
? async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,labels,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); labelsOf.set(n, (v.labels ?? []).map((x) => x.name)); needsOf.set(n,
|
|
2232
|
-
: async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); needsOf.set(n,
|
|
2231
|
+
? async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,labels,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); labelsOf.set(n, (v.labels ?? []).map((x) => x.name)); needsOf.set(n, placementNeeds(v, execForNeeds)); if (execForNeeds?.relay) prefetchOf.set(n, relayPrefetchCommands(v, execForNeeds.relay)); return v.body; }
|
|
2232
|
+
: async (n) => { const v = await viewIssue(leanIo.gh, repo, n, "body,comments,author,milestone"); if ("milestone" in v) milestoneOf.set(n, v.milestone?.title ?? null); trustedOf.set(n, bodyTrusted(v)); needsOf.set(n, placementNeeds(v, execForNeeds)); if (execForNeeds?.relay) prefetchOf.set(n, relayPrefetchCommands(v, execForNeeds.relay)); return v.body; }, // #4785: decisions and the frozen contract's validate commands too
|
|
2233
2233
|
onUpdate: (r) => sink.row(r),
|
|
2234
2234
|
});
|
|
2235
2235
|
} finally { for (const [sig, f] of Object.entries(handlers)) off(sig, f); healthTimers.cancel(); }
|
package/bin/lean/conformance.mjs
CHANGED
|
@@ -561,7 +561,7 @@ export function testPlanProblems(c, { required = false } = {}) {
|
|
|
561
561
|
|
|
562
562
|
/** #5448: a requirement that starts as an imperative build verb is development work, not a prod-only measurement. */
|
|
563
563
|
const DEV_WORK_RE = /^\W*(?:\w+\s+){0,2}?(?:find|fix|implement|develop|build|write|patch|add|change)\b/i;
|
|
564
|
-
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null } = {}) {
|
|
564
|
+
export function validateContract(c, issueText, { repro = false, pages = null, testPlan = false, readFile = null, checkIds = null, baseFiles = null, reproRecipe = false } = {}) {
|
|
565
565
|
const problems = [];
|
|
566
566
|
if (!c || typeof c !== "object" || Array.isArray(c)) return { ok: false, problems: ["contract.json is missing or not a JSON object"] };
|
|
567
567
|
const reqs = Array.isArray(c.requirements) ? c.requirements : [];
|
|
@@ -628,6 +628,8 @@ export function validateContract(c, issueText, { repro = false, pages = null, te
|
|
|
628
628
|
else {
|
|
629
629
|
for (const p of tmpdirInputs(t.command)) problems.push(tmpInputProblem("repro_test", p));
|
|
630
630
|
if (guessedUvEnv(t.command)) problems.push(guessedUvProblem("repro_test"));
|
|
631
|
+
const prov = reproRecipe ? null : envProvisioningCommand(t.command); // #5732: a forge.yaml validate.recipes rewrite may set the env up
|
|
632
|
+
if (prov) problems.push(`repro_test: the command provisions its own environment (\`${prov}\`); the engine prepares dependencies, so it is host-specific and fails where that interpreter or install is missing (env.repro_unrunnable); use the bare test invocation (e.g. \`poetry run pytest <file>::<test>\`) or a forge.yaml validate.recipes entry`);
|
|
631
633
|
const pdr = projectDirPathMiss(t.command);
|
|
632
634
|
if (pdr) problems.push(projectDirProblem("repro_test", pdr));
|
|
633
635
|
if (vitestQuietFlag(t.command)) problems.push("repro_test: vitest 3 rejects -q/--quiet; use --reporter=dot");
|
|
@@ -862,6 +864,8 @@ const ENV_SIGNATURES = [
|
|
|
862
864
|
[/invalid mount config for type "bind"|bind source path does not exist|error while creating mount source path|mounts denied/i, "Docker bind-mount source"],
|
|
863
865
|
[/Executable doesn't exist at|npx playwright install|browserType\.launch: Executable/i, "Playwright browser"],
|
|
864
866
|
[/\bENOTFOUND\b|\bEAI_AGAIN\b|npm (?:ERR!|error) network|getaddrinfo (?:ENOTFOUND|EAI_AGAIN)/i, "network access for npm"],
|
|
867
|
+
// #5732: the command picks an interpreter the host does not have (`poetry env use python3.11` on a python3.12-only sandbox)
|
|
868
|
+
[/Could not find the python executable|poetry env use\b[^\n]*(?:not found|error|failed)|\bpython\d(?:\.\d+)?:? not found|No interpreter found|pyenv: version `[^`]+' is not installed/i, "Python interpreter"],
|
|
865
869
|
];
|
|
866
870
|
const envSignature = (out) => { const hit = ENV_SIGNATURES.find(([re]) => re.test(out)); return hit ? { tool: hit[1], kind: "environment" } : null; };
|
|
867
871
|
export const SECRET_PAIR_RE = /\b([A-Za-z0-9_]*(?:TOKEN|SECRET|PASSWORD|PASSWD|API_?KEY|CREDENTIAL)[A-Za-z0-9_]*\s*[=:]\s*)\S+/gi;
|
|
@@ -921,6 +925,19 @@ export function applyValidateRecipes(contract, recipes) {
|
|
|
921
925
|
if (Array.isArray(contract.test_plan)) out.test_plan = contract.test_plan.map((r) => (r && typeof r === "object" ? { ...r, command: rewrite(`test_plan ${r.requirement}`, r.command) } : r)); // #5445
|
|
922
926
|
return { contract: applied.length ? out : contract, applied };
|
|
923
927
|
}
|
|
928
|
+
/**
|
|
929
|
+
* #5732: the first env-provisioning step of a repro command (`poetry env use`, `poetry install`, `pip install`, `uv venv`,
|
|
930
|
+
* `uv sync`, `uv pip install`), or null. The engine prepares dependencies (DEPS_PREPARED); the repro command is the bare test run.
|
|
931
|
+
*/
|
|
932
|
+
const ENV_PROVISION_RE = /\b(poetry\s+env\s+use|poetry\s+install|(?:python3?\s+-m\s+)?pip3?\s+install|uv\s+venv|uv\s+sync|uv\s+pip\s+install)\b/;
|
|
933
|
+
export function envProvisioningCommand(command) {
|
|
934
|
+
return ENV_PROVISION_RE.exec(String(command ?? ""))?.[1].replace(/\s+/g, " ") ?? null;
|
|
935
|
+
}
|
|
936
|
+
/** #5732: true when a failed run's output carries test-failure text (an assertion, a runner's failed-test mark), not only an environment error. */
|
|
937
|
+
const ASSERTION_RE = /AssertionError|\bassert(?:ion)?\b[^\n]*(?:==|!=|failed|error)|^FAILED\s+\S+::|^\s*E\s+(?:assert|Expected)|\bExpected\b[^\n]*\b(?:Received|got|to (?:be|equal))|expect\(|^not ok \d+|^\s*[✗×✖]\s|^\s*● |\bTests?:\s+\d+ failed/m;
|
|
938
|
+
export function assertionFailure(output) {
|
|
939
|
+
return ASSERTION_RE.test(String(output ?? ""));
|
|
940
|
+
}
|
|
924
941
|
/** #5020: the env.* verdict for a repro command that failed on head because a tool is missing (e.g. an uninstalled Poetry env); null when the failure is the test's own. */
|
|
925
942
|
export function reproEnvMiss(run, opts) {
|
|
926
943
|
return run && run.rc !== 0 && run.rc !== 124 ? missingTool(run, opts) : null;
|
|
@@ -1094,7 +1111,7 @@ export function interfaceDecisionFailures(contract, result, changedFiles) {
|
|
|
1094
1111
|
* `kind` (scope_creep, validate_missing, validate_failed, validate_env, requirement_unimplemented, untracked_deferral, hotspot_growth, repro_red_green, repro_env) so callers can
|
|
1095
1112
|
* tell the builder's own failed checks apart from bookkeeping gaps. `ciVerified` (#4167): the current head passed the
|
|
1096
1113
|
* engine's CI verification, so a validate id left to CI is not missing; a recorded non-zero exit still fails. `repro` (#4271): the repro_test red-green words, checked when given.
|
|
1097
|
-
* `validateRuns` (#4323): the engine's rerun {[id]: {rc, output}} of validate commands recorded as failed. A rerun that passes
|
|
1114
|
+
* `validateRuns` (#4323): the engine's rerun {[id]: {rc, output}} of validate commands recorded as failed, or (#5728) with no result at all (not CI-covered). A rerun that passes
|
|
1098
1115
|
* counts as passed; one that could not find a host tool or module (missingTool, with `repoHas`) is kind validate_env, code
|
|
1099
1116
|
* env.tool_missing (skipped on a CI-verified head), not a conformance failure.
|
|
1100
1117
|
* `frozen` (#4350): the contract before typed amendments. A failed scope-check validate (isScopeCheck) whose only files
|
|
@@ -1138,8 +1155,10 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1138
1155
|
// #4167: a head the engine verified on CI covers validate ids the builder left to CI (no result, or ci:true without an exit)
|
|
1139
1156
|
const leftToCi = !r || (r.ci === true && r.exit === undefined);
|
|
1140
1157
|
if (ciVerified && leftToCi) { ciCovered.push(v.id); continue; }
|
|
1141
|
-
|
|
1142
|
-
|
|
1158
|
+
// #5728: a row with no recorded result that the engine ran itself is judged like a rerun of a failed row; validate_missing only when nothing ran it
|
|
1159
|
+
const engineRun = leftToCi && validateRuns?.[v.id] ? validateRuns[v.id] : null;
|
|
1160
|
+
if (leftToCi && !engineRun) failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_missing", detail: `validate ${v.id} (\`${v.command}\`) has no recorded result` });
|
|
1161
|
+
else if (engineRun || r.exit !== 0) {
|
|
1143
1162
|
const rerun = validateRuns?.[v.id];
|
|
1144
1163
|
if (rerun?.rc === 0) continue;
|
|
1145
1164
|
if (rerun && cliUsageError(rerun)) { failures.push({ code: C.CONTRACT_INVALID_COMMAND, kind: "validate_command_invalid", detail: `validate ${v.id} (\`${v.command}\`) is a CLI usage error of the runner, a defect of the frozen command rather than of the change` }); continue; }
|
|
@@ -1155,7 +1174,7 @@ export function precheck({ contract, result, changedFiles, ignore = [], ciVerifi
|
|
|
1155
1174
|
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)}` });
|
|
1156
1175
|
else if (amendedOnly && isScopeCheck(v.command)) superseded.push({ id: v.id, files: amendedOnly });
|
|
1157
1176
|
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
|
|
1158
|
-
else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${r.exit})${outputTail(rerun?.output)}` });
|
|
1177
|
+
else failures.push({ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "validate_failed", detail: `validate ${v.id} (\`${v.command}\`) failed (exit ${engineRun ? rerun.rc : r.exit}${engineRun ? ", run by the engine: no recorded result" : ""})${outputTail(rerun?.output)}` });
|
|
1159
1178
|
}
|
|
1160
1179
|
}
|
|
1161
1180
|
const st = Array.isArray(result?.requirements) ? result.requirements : [];
|
|
@@ -1208,28 +1227,31 @@ function frozenAmendedFiles(frozen, contract, outside, creep) {
|
|
|
1208
1227
|
* #4334: HEAD=UNRUNNABLE or no words (the harness could not run the test) is env.repro_unrunnable, kind repro_env: an
|
|
1209
1228
|
* environment error, never a builder resume. So is BASE=UNRUNNABLE with HEAD=RAN (the base checkout could not run it).
|
|
1210
1229
|
*/
|
|
1211
|
-
export function reproFailures(contract, { base, head, pristine } = {}) {
|
|
1230
|
+
export function reproFailures(contract, { base, head, pristine, headOutput, baseOutput } = {}) {
|
|
1212
1231
|
if (head === "RAN" && base === "FAILED") return [];
|
|
1232
|
+
// #5732: the last 20 lines of each run's output, so a failing test reads differently from a broken environment
|
|
1233
|
+
const tail = (label, out) => { const t = outputTail(out, 20); return t ? t.replace("\n output tail", `\n ${label} output tail`) : ""; };
|
|
1234
|
+
const tails = `${tail("head", headOutput)}${tail("base", baseOutput)}`;
|
|
1213
1235
|
// #5544: head's test passes on base source but the base's own version of it fails: a test-only fix, not already fixed
|
|
1214
1236
|
if (head === "RAN" && base === "RAN" && pristine === "FAILED") return [];
|
|
1215
1237
|
const t = contract?.repro_test ?? {};
|
|
1216
1238
|
const name = [t.path, t.id].filter((x) => !blank(x)).join(" ") || "repro_test";
|
|
1217
1239
|
if (!head || head === "UNRUNNABLE") {
|
|
1218
1240
|
return [{ code: C.ENV_REPRO_UNRUNNABLE, kind: "repro_env",
|
|
1219
|
-
detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on head (environment, not the change); got BASE=${base ?? "UNRUNNABLE"} HEAD=${head ?? "UNRUNNABLE"}` }];
|
|
1241
|
+
detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on head (environment, not the change); got BASE=${base ?? "UNRUNNABLE"} HEAD=${head ?? "UNRUNNABLE"}${tails}` }];
|
|
1220
1242
|
}
|
|
1221
1243
|
// A head that ran but a base the harness could not run (e.g. a missing dependency tree in the base checkout) is the
|
|
1222
1244
|
// environment too: the change cannot fix it, so it is never a builder resume (AlterLab 40652/40665, BASE=UNRUNNABLE HEAD=RAN).
|
|
1223
1245
|
if (head === "RAN" && base === "UNRUNNABLE") {
|
|
1224
1246
|
return [{ code: C.ENV_REPRO_UNRUNNABLE, kind: "repro_env",
|
|
1225
|
-
detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on the base (environment, not the change); got BASE=UNRUNNABLE HEAD=RAN` }];
|
|
1247
|
+
detail: `repro test ${name} (\`${t.command ?? ""}\`): the harness could not run the test on the base (environment, not the change); got BASE=UNRUNNABLE HEAD=RAN${tails}` }];
|
|
1226
1248
|
}
|
|
1227
1249
|
const skipped = base === "SKIPPED" ? " (base not run: head did not pass)" : "";
|
|
1228
1250
|
// #5080: the test already passes on the base: the fix is there (a hotfix or another PR), not missing from this change
|
|
1229
1251
|
if (base === "RAN") return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_base_green",
|
|
1230
|
-
detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=RAN HEAD=RAN: it passes on the base already (the fix may already be on the base)` }];
|
|
1231
|
-
return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_red_green",
|
|
1232
|
-
detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=${base ?? "UNRUNNABLE"} HEAD=${head}${skipped}` }];
|
|
1252
|
+
detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=RAN HEAD=RAN: it passes on the base already (the fix may already be on the base)${tails}` }];
|
|
1253
|
+
return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_red_green", head, assertion: assertionFailure(headOutput), // #5732: lean.mjs routes a remote head failure with no assertion text to the host
|
|
1254
|
+
detail: `repro test ${name} (\`${t.command ?? ""}\`) must fail on the base and pass on head; got BASE=${base ?? "UNRUNNABLE"} HEAD=${head}${skipped}${tails}` }];
|
|
1233
1255
|
}
|
|
1234
1256
|
|
|
1235
1257
|
/** #5446: a repro_test every targeted mutation of the fix survived. Only under lean.repro_quality: enforce; patch_echo is the reviewer's call. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
5
|
import assert from "node:assert/strict";
|
|
6
|
-
import { testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered, mockedDeliverable, proofEchoDetail, contractRuleCounts, onlyTestPlanProblems } from "./conformance.mjs";
|
|
6
|
+
import { testPlanProblems, proofEchoesDeliverable, outputTail, removedNamedPaths, removedPathsOf, shellSyntaxError, unrunnableValidate, noopCommand, substituteVerdict, describesUnrunnableCommand, vitestQuietFlag, normalizeRunnerCommand, cliUsageError, validateContract, applyAmendments, amendmentKindProblems, precheck, hotspotGrowth, reproFailures, reproQualityFailures, isBugIssue, parseReview, checkCompleteness, decide, closePlan, isInvestigation, formatShadowSummary, followupItems, inIssue, snapQuote, snapQuotes, isTestPath, normalizeEvidencePath, mergeReviewRows, reviewSkeleton, missingIds, resolveEvidencePath, movingBaseDiff, scopeText, evidencePathLine, evidencePathOnly, reaskable, matchCriterion, criterionLines, fillEngineRows, explainFailures, resolveForgedockPaths, missingTool, repoTracks, tmpdirInputs, isScopeCheck, isPureScopeCheck, dropScopeValidates, tagOutOfBand, outOfBandRequirements, isOutOfBand, followupMap, renderPendingFollowups, VERIFY_MODES, OUT_OF_BAND_RE, FOLLOWUP_CLASSES, followupClass, inLaneDeferral, pendingTracking, BUCKETS, bucketKind, bucketProblems, bucketTally, isE2eCommand, e2eVerified, impliedDocDeliverables, applyValidateRecipes, deferChecklessPostDeploy, substituteShellProblem, reproEnvMiss, ORCHESTRATOR_BUCKET, ownerRoute, weakenedE2eDecisions, guessedUvEnv, envProvisioningCommand, assertionFailure, projectDirPathMiss, rewriteProjectDirCommand, convertDelivered, mockedDeliverable, proofEchoDetail, contractRuleCounts, onlyTestPlanProblems } from "./conformance.mjs";
|
|
7
7
|
|
|
8
8
|
const ISSUE = "## Requirements\n1. The scrape route must release the spend reservation on 429.\n2. The search route must release the spend reservation on 429.\n\n- [ ] Billing pricing is unchanged.";
|
|
9
9
|
const Q1 = "The scrape route must release the spend reservation on 429.";
|
|
@@ -317,6 +317,18 @@ describe("precheck (deterministic, no reviewer)", () => {
|
|
|
317
317
|
const local = precheck({ contract: C, result: failed, changedFiles: files, repoHas: repoTracks(["src/leak/__init__.py"]), validateRuns: { V1: { rc: 1, output: "ModuleNotFoundError: No module named 'leak.core'" } } });
|
|
318
318
|
assert.deepEqual(codes(local), ["conformance.unimplemented"], "a repo module the change did not create is a code defect");
|
|
319
319
|
});
|
|
320
|
+
it("#5728 a folded G1 with no recorded result is judged by the engine's rerun", () => {
|
|
321
|
+
const CG = { ...C, validate: [{ id: "V1", command: "node --test a.test.mjs" }, { id: "G1", command: "node --test b.test.mjs", regression: true }] };
|
|
322
|
+
const rs = { requirements: [{ id: "R1", status: "implemented" }, { id: "R2", status: "implemented" }], validation: [{ id: "V1", exit: 0 }] };
|
|
323
|
+
const vk = (o) => precheck({ contract: CG, result: rs, changedFiles: files, ...o }).failures.filter((f) => /^validate_/.test(f.kind));
|
|
324
|
+
assert.deepEqual(vk({ validateRuns: { G1: { rc: 0, output: "", engine: true } } }), [], "a passing engine run counts as passed");
|
|
325
|
+
const bad = vk({ validateRuns: { G1: { rc: 1, output: "AssertionError: boom", engine: true } } });
|
|
326
|
+
assert.deepEqual(bad.map((f) => f.kind), ["validate_failed"]); assert.match(bad[0].detail, /boom/); assert.match(bad[0].detail, /exit 1, run by the engine/);
|
|
327
|
+
assert.deepEqual(vk({}).map((f) => f.kind), ["validate_missing"], "no run at all stays validate_missing");
|
|
328
|
+
assert.deepEqual(vk({ validateRuns: { G1: { rc: 127, output: "pytest: command not found" } } }).map((f) => f.kind), ["validate_env"]);
|
|
329
|
+
const ci = precheck({ contract: CG, result: rs, changedFiles: files, ciVerified: true });
|
|
330
|
+
assert.deepEqual(ci.ciCovered, ["G1"]);
|
|
331
|
+
});
|
|
320
332
|
it("#4527 a CI-verified head lists the validate ids it accepted without a local result; a ran-and-failed validate still fails", () => {
|
|
321
333
|
const C2 = { ...C, validate: [{ id: "V1", command: "node --test a.test.mjs" }, { id: "V2", command: "tsc" }, { id: "V3", command: "lint" }] };
|
|
322
334
|
const pc = precheck({ contract: C2, result: { ...res, validation: [{ id: "V2", ci: true }, { id: "V3", exit: 0 }] }, changedFiles: files, ciVerified: true });
|
|
@@ -2150,3 +2162,29 @@ describe("first-pass: an unregistered post-deploy check id fails at freeze, not
|
|
|
2150
2162
|
assert.ok(!validateContract(row(), issue).problems.some((p) => /is not registered/.test(p)));
|
|
2151
2163
|
});
|
|
2152
2164
|
});
|
|
2165
|
+
|
|
2166
|
+
describe("#5732 repro commands and failures", () => {
|
|
2167
|
+
const rt = (command, o = {}) => validateContract({ ...C, repro_test: { path: "t/x.py", id: "t", command } }, ISSUE, { repro: true, ...o }).problems.filter((p) => /provisions its own environment/.test(p));
|
|
2168
|
+
it("#5732 validateContract rejects a repro command that provisions its environment", () => {
|
|
2169
|
+
for (const bad of ["cd services/api && poetry env use python3.11 -q && poetry install --no-root --no-interaction -q && poetry run pytest -q tests/test_a.py::test_b",
|
|
2170
|
+
"poetry env use -q python3.11 && poetry run pytest tests/x.py -m 'not integration'", "pip install -r requirements.txt && pytest tests/x.py", "python3 -m pip install pytest && pytest x.py", "uv venv && uv run pytest x.py"]) assert.equal(rt(bad).length, 1, bad);
|
|
2171
|
+
assert.match(rt("poetry install && poetry run pytest x.py")[0], /`poetry install`/);
|
|
2172
|
+
});
|
|
2173
|
+
it("#5732 a bare test invocation, a validate row or a recipe-rewritten repro command is accepted", () => {
|
|
2174
|
+
for (const ok of ["poetry run pytest tests/x.py::t", "cd services/api && .venv/bin/pytest -q tests/x.py", "uv run pytest tests/x.py"]) assert.deepEqual(rt(ok), [], ok);
|
|
2175
|
+
assert.deepEqual(rt("poetry install && poetry run pytest x.py", { reproRecipe: true }), []);
|
|
2176
|
+
assert.ok(!validateContract({ ...C, validate: [{ id: "V1", command: "poetry install && poetry run pytest x.py" }] }, ISSUE).problems.some((p) => /provisions/.test(p)));
|
|
2177
|
+
});
|
|
2178
|
+
it("#5732 envProvisioningCommand and assertionFailure", () => {
|
|
2179
|
+
assert.equal(envProvisioningCommand("poetry env use python3.11 && pytest"), "poetry env use");
|
|
2180
|
+
assert.equal(envProvisioningCommand("pytest tests/pip_install_test.py"), null);
|
|
2181
|
+
for (const yes of ["E AssertionError: 0.5 != 0.4", "FAILED tests/a.py::t - assert 1 == 2", "not ok 3 - foo", " ● suite › case", "Tests: 1 failed, 4 passed", "expect(received).toBe(expected)"]) assert.equal(assertionFailure(yes), true, yes);
|
|
2182
|
+
for (const no of ["poetry env use: python3.11 not found", "Could not find the python executable python3.11", "bash: pytest: command not found", "", undefined]) assert.equal(assertionFailure(no), false, String(no));
|
|
2183
|
+
});
|
|
2184
|
+
it("#5732 a repro_red_green row says whether head's output had assertion text; the interpreter signature is an env miss for validates too", () => {
|
|
2185
|
+
const t = { repro_test: { path: "t.py", command: "pytest t.py" } };
|
|
2186
|
+
assert.equal(reproFailures(t, { base: "SKIPPED", head: "FAILED", headOutput: "Could not find the python executable python3.11" })[0].assertion, false);
|
|
2187
|
+
assert.equal(reproFailures(t, { base: "SKIPPED", head: "FAILED", headOutput: "E AssertionError" })[0].assertion, true);
|
|
2188
|
+
assert.deepEqual(missingTool({ rc: 1, output: "Could not find the python executable python3.11" }), { tool: "Python interpreter", kind: "environment" });
|
|
2189
|
+
});
|
|
2190
|
+
});
|
package/bin/lean/effects.mjs
CHANGED
|
@@ -618,11 +618,17 @@ export function makeLeanIo({ repo, subagentModel = readSubagentModel() }) {
|
|
|
618
618
|
* `env` (#4325): the lane env (run TMPDIR, toolchain), merged over process.env, so the command sees what the builder saw.
|
|
619
619
|
*/
|
|
620
620
|
async redGreen({ cwd, base, command, timeoutSec = 300, env = null }) {
|
|
621
|
-
|
|
621
|
+
let outDir = null;
|
|
622
|
+
try { outDir = mkdtempSync(join(tmpdir(), "forge-rg-out-")); } catch { /* no output tails, the words still come back */ }
|
|
623
|
+
const args = [script("acceptance-red-green.sh"), "--repo-path", cwd, "--base-ref", base, "--test-cmd", command, "--timeout", String(timeoutSec), ...(outDir ? ["--output-dir", outDir] : [])];
|
|
624
|
+
// #5732: the last 64 KB of a run's output, for the failure's output tail; undefined when the harness kept none
|
|
625
|
+
const tailOf = (f) => { try { const t = readFileSync(join(outDir, f), "utf8"); return t.length > 65536 ? t.slice(-65536) : t; } catch { return undefined; } };
|
|
622
626
|
try {
|
|
623
627
|
const m = /BASE=(\w+) HEAD=(\w+)(?: PRISTINE=(\w+))?/.exec(String((await pexec("bash", args, { cwd, timeout: (timeoutSec * 2 + 60) * 1000, maxBuffer: 4 * 1024 * 1024, ...(env ? { env: { ...process.env, ...env } } : {}) })).stdout ?? ""));
|
|
624
|
-
|
|
625
|
-
|
|
628
|
+
if (!m) return null;
|
|
629
|
+
const headOutput = outDir ? tailOf("head.out") : undefined, baseOutput = outDir ? tailOf("base.out") : undefined;
|
|
630
|
+
return { base: m[1], head: m[2], ...(m[3] ? { pristine: m[3] } : {}), ...(headOutput != null ? { headOutput } : {}), ...(baseOutput != null ? { baseOutput } : {}) }; // #5544: pristine only when the base's own test version failed
|
|
631
|
+
} catch { return null; } finally { if (outDir) rmSync(outDir, { recursive: true, force: true }); }
|
|
626
632
|
},
|
|
627
633
|
/**
|
|
628
634
|
* The target repo's own docs-move-with-code rule, when it has one (scripts/check-devdocs-freshness.sh, forge#4185),
|
package/bin/lean/execution.mjs
CHANGED
|
@@ -47,6 +47,8 @@
|
|
|
47
47
|
* (`placementText`); a remote lane whose frozen validate commands name a declared one ends before building (`contractHostNeeds`).
|
|
48
48
|
* #4776: the body is read without its quoted material (comments, code, quotes, evidence sections) and the frozen
|
|
49
49
|
* `repro_test` command counts like a validate command, so a quoted evidence query no longer pins a lane to the host.
|
|
50
|
+
* #5725: body prose pins only on a command signal (`sops -d`, an age key path, `needs: sops`); a bare mention of sops or
|
|
51
|
+
* credentials.yaml counts only in decisions, contract commands and block summaries (`placementNeeds`).
|
|
50
52
|
*/
|
|
51
53
|
import { execFile } from "node:child_process";
|
|
52
54
|
import { existsSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
|
@@ -218,22 +220,37 @@ export function placement(exec) {
|
|
|
218
220
|
return exec?.mode === "remote" && Number.isInteger(exec.maxRemote) && exec.maxRemote >= 1 ? "remote" : "local";
|
|
219
221
|
}
|
|
220
222
|
|
|
221
|
-
/**
|
|
223
|
+
/** An explicit need written in prose (#5725): `needs: sops`, `needs sops`, `host capability: sops`. */
|
|
224
|
+
const DECLARE = String.raw`\b(?:needs?|host[ _-]capabilit(?:y|ies))\s*:?\s+`;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Host-only capabilities and the issue-text signals that mean a lane needs them (#4542). #5725: `command` is a signal that
|
|
228
|
+
* the lane itself uses the capability and counts everywhere, issue prose included; `mention` (only sops and ops_credentials)
|
|
229
|
+
* merely names it and counts only outside body prose (FORGE:DECISION comments, frozen contract commands, block summaries).
|
|
230
|
+
*/
|
|
222
231
|
const CAPABILITY_SIGNALS = Object.freeze({
|
|
223
|
-
sops:
|
|
224
|
-
|
|
225
|
-
|
|
232
|
+
sops: {
|
|
233
|
+
command: new RegExp(String.raw`\bsops\s+(?:-d|--decrypt|-e|--encrypt|edit|exec-env|exec-file|updatekeys|-i|--in-place|rotate)\b|\.age\/[\w.-]+\.key\b|\.secrets\/[^\s\x60'")]*\.enc\.ya?ml|${DECLARE}sops\b`, "i"),
|
|
234
|
+
mention: /\.secrets\/[^\s`'")]*\.enc\.ya?ml|\bsops\b|\bage key\b|\.age\//i,
|
|
235
|
+
},
|
|
236
|
+
prod_monitor: { command: /\bssh\s+[\w.-]*-monitor\b|\b(?:ovh|netcup)-monitor\b|\bobs-psql\b|\bprod(?:uction)?[ _-]monitor|\bread[- ]only (?:prod(?:uction)? )?(?:prod(?:uction)? )?telemetry\b/i },
|
|
237
|
+
ops_credentials: {
|
|
238
|
+
command: /\b(?:cat|less|head|yq|jq|source|grep|sed)\s+\S*credentials\.yaml\b|\bops[ _-]credentials\b/i,
|
|
239
|
+
mention: /\bcredentials\.yaml\b|\bops[ _-]credentials\b/i,
|
|
240
|
+
},
|
|
226
241
|
});
|
|
227
242
|
|
|
228
243
|
/**
|
|
229
244
|
* Host-only capabilities named by `text` (issue body, contract or a builder summary), zero LLM, sorted by name: the
|
|
230
245
|
* built-in signals above, a declared name written out (`prod_monitor`, `prod monitor`) and `exec.hostCapabilityPatterns`.
|
|
246
|
+
* #5725: `prose: true` (issue body prose) counts only command signals, and a declared name only in declaration form
|
|
247
|
+
* (`needs: <name>`, `host capability: <name>`), so prose that merely names SOPS no longer pins a lane to the host.
|
|
231
248
|
*/
|
|
232
|
-
export function detectNeeds(text, exec = null) {
|
|
249
|
+
export function detectNeeds(text, exec = null, { prose = false } = {}) {
|
|
233
250
|
const t = String(text ?? "");
|
|
234
251
|
const found = new Set();
|
|
235
|
-
for (const [name,
|
|
236
|
-
for (const name of exec?.hostCapabilities ?? []) if (new RegExp(
|
|
252
|
+
for (const [name, { command, mention }] of Object.entries(CAPABILITY_SIGNALS)) if (command.test(t) || (!prose && mention?.test(t))) found.add(name);
|
|
253
|
+
for (const name of exec?.hostCapabilities ?? []) if (new RegExp(`${prose ? DECLARE : "\\b"}${name.replace(/[_-]/g, "[ _-]")}\\b`, "i").test(t)) found.add(name);
|
|
237
254
|
for (const { name, pattern } of exec?.hostCapabilityPatterns ?? []) { const re = safeRegExp(pattern); if (re?.test(t)) found.add(name); }
|
|
238
255
|
return [...found].sort();
|
|
239
256
|
}
|
|
@@ -292,6 +309,11 @@ function contractCommands(contract) {
|
|
|
292
309
|
* `<!-- FORGE:CONTRACT -->` comment. `comments` are gh comment objects (`{body}`) or strings; anything else is ignored.
|
|
293
310
|
*/
|
|
294
311
|
export function placementText({ body = "", comments = [] } = {}) {
|
|
312
|
+
return [proseOf(body), ...commentSources(comments)].join("\n");
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Every `<!-- FORGE:DECISION` comment body and the last frozen contract's validate and repro_test commands (#4785, #4776). */
|
|
316
|
+
function commentSources(comments) {
|
|
295
317
|
const bodies = (Array.isArray(comments) ? comments : []).map((c) => String((typeof c === "string" ? c : c?.body) ?? "").trimStart());
|
|
296
318
|
let validate = [];
|
|
297
319
|
for (const b of bodies) {
|
|
@@ -299,7 +321,17 @@ export function placementText({ body = "", comments = [] } = {}) {
|
|
|
299
321
|
const c = parseContractComment(b)?.contract;
|
|
300
322
|
if (c && typeof c === "object") validate = contractCommands(c);
|
|
301
323
|
}
|
|
302
|
-
return [
|
|
324
|
+
return [...bodies.filter((b) => b.startsWith("<!-- FORGE:DECISION")), ...validate];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Host-only capabilities an issue needs for placement (#5725), pure, sorted: body prose (`proseOf`) counts only command
|
|
329
|
+
* signals (`detectNeeds` `prose: true`), while FORGE:DECISION comments and the frozen contract's commands also count mentions.
|
|
330
|
+
*/
|
|
331
|
+
export function placementNeeds({ body = "", comments = [] } = {}, exec = null) {
|
|
332
|
+
const found = new Set(detectNeeds(proseOf(body), exec, { prose: true }));
|
|
333
|
+
for (const n of detectNeeds(commentSources(comments).join("\n"), exec)) found.add(n);
|
|
334
|
+
return [...found].sort();
|
|
303
335
|
}
|
|
304
336
|
|
|
305
337
|
/** Declared host capabilities a contract's validate and repro_test commands name (#4785, #4776): `{caps, ids}`, both empty when none. */
|
|
@@ -8,6 +8,7 @@ import { join } from "node:path";
|
|
|
8
8
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
9
9
|
import { renderContract } from "./render.mjs";
|
|
10
10
|
import { parseExecution, hostFallbackAllowed, SANDBOX_PROVIDERS, detectNeeds, hostCapabilityBlock, placementText, contractHostNeeds, placement, placeLane, validationWeight, hostHeadroom, scopedEnv, providerLanes, remoteHoldId, usageLimitInTail, isTransportError, isCloneFailure, containerProvider, providerByName, openExecutionBudget, poolCredential, remoteTransportFor } from "./execution.mjs";
|
|
11
|
+
import * as executionModule from "./execution.mjs";
|
|
11
12
|
import { remoteProvider } from "./sandbox-remote.mjs";
|
|
12
13
|
import { makeLedger, countLiveLanes } from "./ledger.mjs";
|
|
13
14
|
import { openBatch } from "./batch.mjs";
|
|
@@ -894,6 +895,62 @@ describe("host capabilities in placement (#4542)", () => {
|
|
|
894
895
|
assert.deepEqual(detectNeeds(t, exec), ["promtool"]);
|
|
895
896
|
});
|
|
896
897
|
|
|
898
|
+
// Namespace lookup (#5725): the file still loads on a base without this export, so the repro fails as an assertion, not a link error.
|
|
899
|
+
const placementNeeds = (...a) => executionModule.placementNeeds(...a);
|
|
900
|
+
const declSops = () => parseExecution({ mode: "remote", max_remote: 2, host_capabilities: "sops" });
|
|
901
|
+
const frozen = (cmd) => "<!-- FORGE:CONTRACT -->\n<!-- FORGE:PLAN -->\n" + renderContract({ requirements: [], deliverables: [], validate: [{ id: "V1", command: cmd }] }, "abcdef123456");
|
|
902
|
+
|
|
903
|
+
it("#5725 T1: prose that only names the secrets tool does not pin", () => {
|
|
904
|
+
for (const body of ["add X to SOPS per devdocs/SOPS.md", "the key lives in SOPS", "rotate the age key"]) {
|
|
905
|
+
for (const exec of [null, declSops()]) {
|
|
906
|
+
assert.deepEqual(placementNeeds({ body }, exec), [], body);
|
|
907
|
+
assert.deepEqual(detectNeeds(body, exec, { prose: true }), [], body);
|
|
908
|
+
}
|
|
909
|
+
assert.deepEqual(detectNeeds(placementText({ body }), declSops()), ["sops"], `${body}: pinned before #5725`);
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
it("#5725 T2: commands, key paths and declarations in prose still pin", () => {
|
|
914
|
+
for (const body of ["run sops -d .secrets/prod.enc.yaml first", "sops exec-env .secrets/x.enc.yaml ./run", "load ~/.age/prod.key",
|
|
915
|
+
"needs: sops", "host capability: sops", "Edit .secrets/prod.enc.yaml"]) {
|
|
916
|
+
assert.deepEqual(placementNeeds({ body }), ["sops"], body);
|
|
917
|
+
assert.deepEqual(placementNeeds({ body }, declSops()), ["sops"], body);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
|
|
921
|
+
it("#5725 T3: decisions and frozen contract commands still pin on a bare mention", () => {
|
|
922
|
+
assert.deepEqual(placementNeeds({ body: "x", comments: [{ body: "<!-- FORGE:DECISION -->\nthe owner keeps this in sops" }] }), ["sops"]);
|
|
923
|
+
assert.deepEqual(placementNeeds({ body: "x", comments: [{ body: frozen("sops -d x.enc.yaml") }] }), ["sops"]);
|
|
924
|
+
assert.deepEqual(placementNeeds({ body: "the key lives in SOPS", comments: [{ body: "just chatter about sops" }] }), []);
|
|
925
|
+
assert.deepEqual(contractHostNeeds({ validate: [{ id: "V1", command: "sops -d x.enc.yaml" }] }, { hostCapabilities: ["sops"] }), { caps: ["sops"], ids: ["V1"] });
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
it("#5725 T4: credentials.yaml named in prose does not pin", () => {
|
|
929
|
+
assert.deepEqual(placementNeeds({ body: "the owner adds the token to credentials.yaml" }), []);
|
|
930
|
+
assert.deepEqual(placementNeeds({ body: "cat ~/ops/credentials.yaml" }), ["ops_credentials"]);
|
|
931
|
+
assert.deepEqual(placementNeeds({ body: "needs ops_credentials" }), ["ops_credentials"]);
|
|
932
|
+
assert.deepEqual(placementNeeds({ body: "x", comments: [{ body: "<!-- FORGE:DECISION -->\nread the token from credentials.yaml" }] }), ["ops_credentials"]);
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
it("#5725 T5: AlterLab#40984 body places remote under mode remote", () => {
|
|
936
|
+
const body = ["## Problem", "The DataImpulse balance is never estimated and the poller is dormant.", "",
|
|
937
|
+
"The login is read from `.secrets/prod.enc.yaml` at deploy time.", "", "## Fix", "Wire a balance estimate and alert when the poller stays dormant.", "",
|
|
938
|
+
"## Owner steps", "- add `proxy.dataimpulse_api_login` to SOPS per `devdocs/SOPS.md`", "",
|
|
939
|
+
"<!-- FORGE:STATE\n{\"placement\":{\"where\":\"local\",\"reason\":\"host capability: sops\"}}\n-->"].join("\n");
|
|
940
|
+
const exec = declSops(), view = { body, comments: [] };
|
|
941
|
+
assert.deepEqual(detectNeeds(placementText(view), exec), ["sops"]); // pinned before #5725
|
|
942
|
+
const needs = placementNeeds(view, exec);
|
|
943
|
+
assert.deepEqual(needs, []);
|
|
944
|
+
assert.equal(placeLane({ exec, needs }).where, "remote");
|
|
945
|
+
assert.equal(placeLane({ exec, needs: ["sops"] }).where, "local");
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
it("#5725 T6: block-summary recovery and prod monitor signal unchanged", () => {
|
|
949
|
+
assert.deepEqual(hostCapabilityBlock("this lane has no sops key", { hostCapabilities: ["sops"] }), ["sops"]);
|
|
950
|
+
assert.deepEqual(placementNeeds({ body: "needs the prod monitor" }), ["prod_monitor"]);
|
|
951
|
+
assert.deepEqual(placementNeeds({ body: "run ssh ovh-monitor obs-psql for counts" }), ["prod_monitor"]);
|
|
952
|
+
});
|
|
953
|
+
|
|
897
954
|
it("#4785/#5423 orchestrate: a remote lane that ends env.tool_missing is retried remotely once (sandbox provisioned), see recovery.test.mjs for the host fallback", async () => {
|
|
898
955
|
const calls = [];
|
|
899
956
|
const rows = await orchestrate({ issues: [5], parallel: 2, recovery: { maxAttempts: 1 }, readBody: async () => "",
|
package/bin/lean/lean.mjs
CHANGED
|
@@ -1709,11 +1709,12 @@ export async function runCore(o) {
|
|
|
1709
1709
|
let words = rg?.base && rg?.head ? rg : { base: "UNRUNNABLE", head: "UNRUNNABLE" };
|
|
1710
1710
|
if (words.head === "FAILED" && io.runCommand) { // #5020: a head that failed because a tool or env is missing is env.repro_unrunnable, not a red-green verdict
|
|
1711
1711
|
const hr = await io.runCommand({ command: String(t.command), cwd: wt, timeoutMs: 120000, env: laneEnv() }).then((x) => x?.r ?? x).catch(() => null);
|
|
1712
|
+
if (hr && hr.output != null) words = { ...words, headOutput: String(hr.output) }; // #5732: the head run's output goes into the failure detail
|
|
1712
1713
|
// release review BUG-1: a module the repo tracks is the change's own failure, never an env miss (same repoHas as the validate rerun)
|
|
1713
1714
|
const repoHas = repoTracks(String(await git(["ls-files"]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean));
|
|
1714
1715
|
if (reproEnvMiss(hr, { command: String(t.command), repoHas })) words = { ...words, head: "UNRUNNABLE" };
|
|
1715
1716
|
}
|
|
1716
|
-
ev({ event: "REPRO_RED_GREEN", ...
|
|
1717
|
+
{ const { headOutput: _h, baseOutput: _b, ...w } = words; ev({ event: "REPRO_RED_GREEN", ...w }); } // #5732: outputs stay out of events
|
|
1717
1718
|
T.decisions.push(`repro_test ${t.path ?? ""}${t.id ? ` ${t.id}` : ""}: BASE=${words.base} HEAD=${words.head}`);
|
|
1718
1719
|
if (reproQuality !== "off" && words.base === "FAILED" && words.head === "RAN") words = { ...words, ...(await reproQualityOf(t)) };
|
|
1719
1720
|
return words;
|
|
@@ -1889,6 +1890,7 @@ export async function runCore(o) {
|
|
|
1889
1890
|
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(() => "")));
|
|
1890
1891
|
return { files, owner: (name) => manifestDepOwner(name, files, (f) => texts.get(f) ?? "") };
|
|
1891
1892
|
}
|
|
1893
|
+
let reproRecipe = false; // #5732: a validate recipe rewrote repro_test, so its env-provisioning steps are the repo's own
|
|
1892
1894
|
function freezeRewrites(c) {
|
|
1893
1895
|
const r = applyValidateRecipes(c, validateRecipes);
|
|
1894
1896
|
const pd = (id, cmd) => { const to = rewriteProjectDirCommand(cmd); if (to !== cmd) T.decisions.push(`project-dir rewrite of ${id}: \`${cmd}\` -> \`${to}\``); return to; };
|
|
@@ -1898,6 +1900,7 @@ export async function runCore(o) {
|
|
|
1898
1900
|
if (t && typeof t === "object" && typeof t.command === "string") r.contract = { ...r.contract, repro_test: { ...t, command: pd("repro_test", t.command) } };
|
|
1899
1901
|
}
|
|
1900
1902
|
for (const x of r.applied) T.decisions.push(`validate recipe rewrote ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
1903
|
+
if (r.applied.some((x) => x.id === "repro_test")) reproRecipe = true; // #5732: recipe-authored env setup is allowed in repro_test
|
|
1901
1904
|
const vr = rewriteSubprojectVenv(r.contract, freezeTracked, (rel) => existsSync(join(wt, rel))); // #5683
|
|
1902
1905
|
r.contract = vr.contract;
|
|
1903
1906
|
for (const x of vr.applied) T.decisions.push(`sub-project venv rewrite of ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
@@ -2062,16 +2065,18 @@ export async function runCore(o) {
|
|
|
2062
2065
|
* the fix model with a narrow prompt; one resume of the build session follows when it made no commit. Else: a resume.
|
|
2063
2066
|
*/
|
|
2064
2067
|
function fixRound(...a) { return phaseLedger.during("fix", () => fixRoundRaw(...a)); } // #5649: fix rounds are their own ledger phase
|
|
2068
|
+
// #5728: a context-ceiling restart of a fix resume carries the failure list (no diff), not the full build prompt
|
|
2069
|
+
const fixResumeRestart = (task) => () => fixSessionPrompt({ task, stat: "", base, contract: frozen, title: iss?.title ?? "", summary: issueSummary(iss?.body) });
|
|
2065
2070
|
async function fixRoundRaw(kind, task, failures, trigger, failureText = "", narrow = null) { // #5348: `narrow` {files} = the minimal profile (no diff, no lane text)
|
|
2066
2071
|
await notePitfall(trigger, failureText); await escalateOn(trigger); // #4375: learned once the same gate passes; #4394
|
|
2067
|
-
if (!freshFix(kind, failures)) return await builder(++attemptN, task, sessionId ?? null, false,
|
|
2072
|
+
if (!freshFix(kind, failures)) return await builder(++attemptN, task, sessionId ?? null, false, fixResumeRestart(task), { mode: "resume", trigger });
|
|
2068
2073
|
const before = String(await git(["rev-parse", "HEAD"])).trim();
|
|
2069
2074
|
const ex = [".", `:!${LEAN_DIR}`], diff = narrow ? "" : String(await git(["diff", `${base}...HEAD`, "--", ...ex]).catch(() => "")), stat = narrow ? "" : String(await git(["diff", "--stat", `${base}...HEAD`, "--", ...ex]).catch(() => ""));
|
|
2070
2075
|
const prompt = narrow ? narrowFixPrompt({ task, contract: frozen, files: narrow.files }) : fixSessionPrompt({ task, diff, stat, base, contract: frozen, title: iss?.title ?? "", summary: issueSummary(iss?.body) });
|
|
2071
2076
|
const r = await builder(++attemptN, prompt, null, false, () => prompt, { model: escalated ? null : fixModel ?? reviewerModel, mode: "fresh", keepSession: true, ...(narrow ? { profile: "narrow" } : {}), trigger });
|
|
2072
2077
|
if (!sessionId || String(await git(["rev-parse", "HEAD"])).trim() !== before) return r;
|
|
2073
2078
|
T.decisions.push(`Fresh ${kind} fix session made no commit; builder session resumed once`);
|
|
2074
|
-
return await builder(++attemptN, task, sessionId, false,
|
|
2079
|
+
return await builder(++attemptN, task, sessionId, false, fixResumeRestart(task), { mode: "resume", trigger });
|
|
2075
2080
|
}
|
|
2076
2081
|
/** #5348: commit what the engine applied without a model (only the files it wrote); the findings it fixed were named by a detector. */
|
|
2077
2082
|
async function mechCommit(gate, applied, paths) {
|
|
@@ -2284,7 +2289,7 @@ export async function runCore(o) {
|
|
|
2284
2289
|
const wtRead = (p) => { try { return readFileSync(join(wt, p), "utf8"); } catch { return ""; } }; // #5585: noindex pages are not public
|
|
2285
2290
|
const freezeBase = pagesConfig ? String(await git(["ls-tree", "-r", "-z", "--name-only", base]).catch(() => "")).split("\0").filter(Boolean) : null; // #5648
|
|
2286
2291
|
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
|
|
2287
|
-
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2292
|
+
let vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds, reproRecipe });
|
|
2288
2293
|
const found0 = await preflightValidates(contract); // #4328: validate commands the host cannot run share the one correction
|
|
2289
2294
|
let missed = found0;
|
|
2290
2295
|
// #5653: an unrunnable command is rewritten from the repo catalogue (forge.yaml recipes first, then CI-derived) before any builder correction
|
|
@@ -2294,7 +2299,7 @@ export async function runCore(o) {
|
|
|
2294
2299
|
if (rw.applied.length) {
|
|
2295
2300
|
contract = snapContract(rw.contract);
|
|
2296
2301
|
for (const x of rw.applied) T.decisions.push(`validate catalogue rewrote unrunnable ${x.id}: \`${x.from}\` -> \`${x.to}\``);
|
|
2297
|
-
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2302
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds, reproRecipe });
|
|
2298
2303
|
missed = await preflightValidates(contract);
|
|
2299
2304
|
}
|
|
2300
2305
|
}
|
|
@@ -2306,7 +2311,7 @@ export async function runCore(o) {
|
|
|
2306
2311
|
await persistGenChecks();
|
|
2307
2312
|
await refreshIssue("contract validation");
|
|
2308
2313
|
contract = snapContract(contract);
|
|
2309
|
-
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds });
|
|
2314
|
+
vc = validateContract(contract, issueText, { repro: reproOn(), pages: pagesConfig, baseFiles: freezeBase, testPlan: reproOn(), readFile: wtRead, checkIds: freezeCheckIds, reproRecipe });
|
|
2310
2315
|
};
|
|
2311
2316
|
if ((!vc.ok || missed.length || testRunnerProblems(contract, testRunners).length) && sessionId) {
|
|
2312
2317
|
await correctContract([...vc.problems, ...preflightProblems(missed), ...testRunnerProblems(contract, testRunners)], "resumed once");
|
|
@@ -3042,13 +3047,15 @@ export async function runCore(o) {
|
|
|
3042
3047
|
/** #4323: rerun once each validate command the builder recorded as failed, with the lane env; {[id]: {rc, output}} or null. */
|
|
3043
3048
|
/** #5005: a frozen forgedock entry-point path missing on this host is replaced by this install's own. */
|
|
3044
3049
|
const forgedockResolved = (c) => resolveForgedockPaths(String(c), { exists: existsSync, checksCli: CHECKS_CLI, forgedockCli: FORGEDOCK_CLI });
|
|
3045
|
-
async function rerunFailedValidatesRaw(contract) {
|
|
3050
|
+
async function rerunFailedValidatesRaw(contract, { ciVerified = false } = {}) {
|
|
3046
3051
|
if (!io.runCommand) return null;
|
|
3047
3052
|
const runs = Array.isArray(result?.validation) ? result.validation : [], out = {};
|
|
3048
3053
|
const env = laneEnv();
|
|
3049
3054
|
for (const v of contract.validate ?? []) {
|
|
3050
3055
|
const r = runs.find((x) => x?.id === v.id);
|
|
3051
|
-
|
|
3056
|
+
// #5728: an entry with no recorded result (or ci:true without an exit) is run by the engine unless the head is CI-verified
|
|
3057
|
+
const noRow = !r || (r.ci === true && r.exit === undefined);
|
|
3058
|
+
if (noRow ? ciVerified : r.exit === undefined || r.exit === 0) continue;
|
|
3052
3059
|
let x;
|
|
3053
3060
|
try { x = await heavyStep("precheck", async () => (await runWithTimeoutRetry((timeoutMs) => io.runCommand({ command: forgedockResolved(v.command), cwd: wt, timeoutMs, env }), vcfg.precheckTimeoutSeconds * 1000)).r); } catch (e) { x = { rc: 127, output: String(e?.message ?? e) }; }
|
|
3054
3061
|
// #4761: a runner usage error (vitest -q) is the frozen command's defect: try the normalised command once
|
|
@@ -3079,9 +3086,11 @@ export async function runCore(o) {
|
|
|
3079
3086
|
}
|
|
3080
3087
|
} catch { /* fail-open: the original failure stands */ }
|
|
3081
3088
|
}
|
|
3082
|
-
out[v.id] = { rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? "") };
|
|
3089
|
+
out[v.id] = { rc: Number.isInteger(x?.rc) ? x.rc : 1, output: String(x?.output ?? ""), ...(noRow ? { engine: true } : {}) };
|
|
3083
3090
|
}
|
|
3084
|
-
|
|
3091
|
+
const engineRan = Object.entries(out).filter(([, x]) => x.engine);
|
|
3092
|
+
if (engineRan.length) T.decisions.push(`Validate ${engineRan.map(([id]) => id).join(", ")} had no recorded result: the engine ran ${engineRan.length > 1 ? "them" : "it"} (exit ${engineRan.map(([, x]) => x.rc).join(", ")})`);
|
|
3093
|
+
if (Object.keys(out).length) ev({ event: "VALIDATE_RERUN", runs: Object.entries(out).map(([id, x]) => ({ id, rc: x.rc, ...(x.engine ? { engine: true } : {}) })) });
|
|
3085
3094
|
return out;
|
|
3086
3095
|
}
|
|
3087
3096
|
/** #4979 SPEC-2: rerun the frozen command of every substituted validate, so precheck accepts a substitute only for a command that cannot run. */
|
|
@@ -3191,7 +3200,7 @@ export async function runCore(o) {
|
|
|
3191
3200
|
specReview = !early || early.failures.length ? null : startSpeculative(async () => reviewerCall((await reviewPrep()).prompt));
|
|
3192
3201
|
const gateT0 = now(); let validateMs = 0;
|
|
3193
3202
|
// #4693: guards run beside the validate rerun; SPEC-11: the substituted-original rerun shares the one validate phase
|
|
3194
|
-
const validatePhase = phaseLedger.during("validate", async () => ({ runs: await rerunFailedValidatesRaw(effective), subs: await rerunSubstitutedOriginals(effective) })).finally(() => { validateMs = now() - gateT0; });
|
|
3203
|
+
const validatePhase = phaseLedger.during("validate", async () => ({ runs: await rerunFailedValidatesRaw(effective, { ciVerified }), subs: await rerunSubstitutedOriginals(effective) })).finally(() => { validateMs = now() - gateT0; });
|
|
3195
3204
|
const [{ runs: validateRuns, subs: substitutedRuns }, guardFailures] = await Promise.all([validatePhase, guardGate(files)]);
|
|
3196
3205
|
// #5087: forge.yaml topology.route_reachability gates the route handlers this diff adds; unset = no check
|
|
3197
3206
|
const routeFailures = routeReachability && io.runCommand ? await routeReachabilityFailures({ command: routeReachability, paths: routePathsFromFiles(String(await git(["diff", "--name-only", "--diff-filter=A", `${base}...HEAD`]).catch(() => "")).split("\n").map((x) => x.trim()).filter(Boolean)), run: async ({ command }) => (await io.runCommand({ command, cwd: wt, timeoutMs: vcfg.precheckTimeoutSeconds * 1000, env: laneEnv() }).then((x) => x?.r ?? x)) ?? { rc: 127 } }) : [];
|
|
@@ -3406,7 +3415,8 @@ export async function runCore(o) {
|
|
|
3406
3415
|
const list = explained.slice(0, 15).map((f) => `- ${f.code}: ${f.detail}`).join("\n");
|
|
3407
3416
|
if (outcome.state === "environment") return await envNeedsHuman(outcome.failures);
|
|
3408
3417
|
// #5371: a remote sandbox is a different environment from the host: its failed frozen validate is rerun once in a local recovery lane before it counts
|
|
3409
|
-
|
|
3418
|
+
// #5732: so is a repro head failure whose output carries no assertion text (an env error of the sandbox, not a red test)
|
|
3419
|
+
if (o.placement?.where === "remote" && !recover && outcome.failures?.length && outcome.failures.every((f) => f?.kind === "validate_failed" || (f?.kind === "repro_red_green" && f.head === "FAILED" && f.assertion === false))) {
|
|
3410
3420
|
T.anomalies.push("Remote validate failure: rerun on the host in a local recovery lane before it is terminal");
|
|
3411
3421
|
return await needsHuman(`A frozen validate command failed in the remote sandbox (exit non-zero on the engine's rerun). The sandbox is a different environment from the host, so no builder resume was spent; the branch is pushed and a local recovery lane reruns the frozen command on the host (pass: the change stands; fail: conformance.unimplemented):\n${list}`, ENV_VALIDATE_PLACEMENT);
|
|
3412
3422
|
}
|
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -11,6 +11,8 @@ import { normaliseDecision, writeDecisionIndex } from "./decisions.mjs"; // #533
|
|
|
11
11
|
import { execFileSync } from "node:child_process";
|
|
12
12
|
import { writeFileSync, existsSync, readFileSync, mkdirSync, symlinkSync, readdirSync, chmodSync } from "node:fs";
|
|
13
13
|
import { join } from "node:path";
|
|
14
|
+
import os from "node:os";
|
|
15
|
+
import { syncBuiltinESMExports } from "node:module";
|
|
14
16
|
import { runCore, contractHash, isProtectedLaneBranch, classifyBlock, builderFixable } from "./lean.mjs";
|
|
15
17
|
import { parseFactsComment, normaliseFacts, renderFactsRecord, FACTS_MARKER } from "./facts.mjs";
|
|
16
18
|
import { makeLedger } from "./ledger.mjs";
|
|
@@ -214,6 +216,11 @@ function world(o = {}) {
|
|
|
214
216
|
}
|
|
215
217
|
const run = (w, extra = {}) => runCore({ issue: 7, repo: "o/r", lane: "staging", cwd: "/repo", worktreeRoot: "/wt", dir: tmpDir("core-"), conformance: "enforce",
|
|
216
218
|
io: w.io, emitTelemetry: async (r) => w.telemetry.push(r), random: () => 0.5, ...extra });
|
|
219
|
+
/** #5728: run `fn` with a fixed, idle load average: precheck.mjs sizes its timeout retry from the real host load, so a loaded host defers the check to CI. */
|
|
220
|
+
async function atIdleLoad(fn) {
|
|
221
|
+
const real = os.loadavg; os.loadavg = () => [0.1, 0.1, 0.1]; syncBuiltinESMExports();
|
|
222
|
+
try { return await fn(); } finally { os.loadavg = real; syncBuiltinESMExports(); }
|
|
223
|
+
}
|
|
217
224
|
const builders = (w) => w.calls.filter((c) => c[0] === "runner" && c[1] === "builder");
|
|
218
225
|
const reviewers = (w) => w.calls.filter((c) => c[0] === "runner" && c[1] === "reviewer");
|
|
219
226
|
const traj = (w) => w.comments.filter((c) => c.includes("<!-- FORGE:TRAJECTORY -->"));
|
|
@@ -1749,6 +1756,48 @@ describe("conformance shadow mode (the default)", () => {
|
|
|
1749
1756
|
assert.equal((await runShadow(p)).terminalReason, "merged"); assert.equal(builders(p).length, 2);
|
|
1750
1757
|
});
|
|
1751
1758
|
|
|
1759
|
+
it("#5728 engine-folded G rows with no recorded result are run by the engine: a pass merges with no resume, a failure resumes once as validate_failed", async () => {
|
|
1760
|
+
const GC = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "G1", command: "node --test test/bar.test.js", regression: true }, { id: "G2", command: "node --test test/baz.test.js", regression: true }] };
|
|
1761
|
+
const vrows = [{ id: "V1", command: CONTRACT.validate[0].command, exit: 0 }];
|
|
1762
|
+
const w = world({ contract: GC, validation: vrows }), ran = [];
|
|
1763
|
+
w.io.runCommand = async (a) => { ran.push(a.command); return { rc: 0, output: "" }; };
|
|
1764
|
+
const r = await runShadow(w);
|
|
1765
|
+
assert.equal(r.terminalReason, "merged"); assert.equal(builders(w).length, 2, "plan + implement: no resume for G rows");
|
|
1766
|
+
assert.ok(ran.includes("node --test test/bar.test.js") && ran.includes("node --test test/baz.test.js"), "the engine ran G1 and G2");
|
|
1767
|
+
assert.ok(w.comments.some((c) => /Validate G1, G2 had no recorded result: the engine ran them/.test(c)), "decision note");
|
|
1768
|
+
// a failing engine run is an actionable resume, never validate_missing
|
|
1769
|
+
const f = world({ contract: GC, validation: vrows, resumeValidation: [...vrows, { id: "G1", command: "x", exit: 0 }, { id: "G2", command: "x", exit: 0 }] });
|
|
1770
|
+
f.io.runCommand = async (a) => (/bar/.test(a.command) ? { rc: 1, output: "AssertionError: bar boom" } : { rc: 0, output: "" });
|
|
1771
|
+
await runShadow(f);
|
|
1772
|
+
assert.equal(builders(f).length, 3, "one resume");
|
|
1773
|
+
assert.match(builders(f)[2][4], /validate G1 .*failed \(exit 1, run by the engine: no recorded result\)[\s\S]*bar boom/);
|
|
1774
|
+
assert.doesNotMatch(builders(f)[2][4], /has no recorded result`?$|validate G1 \(`[^`]*`\) has no recorded result/);
|
|
1775
|
+
});
|
|
1776
|
+
it("#5728 a CI-verified head is not rerun for rows left to CI; with no io.runCommand the row stays validate_missing", async () => {
|
|
1777
|
+
const GC = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "G1", command: "node --test test/bar.test.js", regression: true }] };
|
|
1778
|
+
const w = world({ contract: GC, validation: [{ id: "V1", command: CONTRACT.validate[0].command, exit: 0 }] });
|
|
1779
|
+
delete w.io.runCommand;
|
|
1780
|
+
const r = await runShadow(w);
|
|
1781
|
+
assert.notEqual(r.terminalReason, "merged"); assert.ok(builders(w).length >= 3, "validate_missing resumes the builder");
|
|
1782
|
+
});
|
|
1783
|
+
it("#5728 a fix resume that hits the context ceiling restarts with the failure list, not the full build prompt", async () => {
|
|
1784
|
+
const GC = { ...CONTRACT, validate: [...CONTRACT.validate, { id: "G1", command: "node --test test/bar.test.js", regression: true }] };
|
|
1785
|
+
const vrows = [{ id: "V1", command: CONTRACT.validate[0].command, exit: 0 }];
|
|
1786
|
+
const w = world({ contract: GC, validation: vrows, resumeValidation: [...vrows, { id: "G1", command: "x", exit: 0 }] });
|
|
1787
|
+
w.io.runCommand = async () => ({ rc: 1, output: "AssertionError: bar boom" });
|
|
1788
|
+
const orig = w.io.runner, seen = []; let thrown = false;
|
|
1789
|
+
w.io.runner = async (c) => {
|
|
1790
|
+
if (c.role === "builder") seen.push(c.prompt);
|
|
1791
|
+
if (c.role === "builder" && c.resume && !thrown && /^The change does not conform/.test(c.prompt)) { thrown = true; throw Object.assign(new Error("ctx"), { code: "CLI_CONTEXT", context: 130000, turns: 1, usage: null }); }
|
|
1792
|
+
return orig(c);
|
|
1793
|
+
};
|
|
1794
|
+
await runShadow(w, { dir: tmpDir("core-ctx-"), contextCeilingTokens: 120000 });
|
|
1795
|
+
assert.ok(thrown, "the fix resume hit the ceiling");
|
|
1796
|
+
const restart = seen[seen.indexOf(seen.find((x, i) => i > 1 && /validate G1/.test(x))) + 1];
|
|
1797
|
+
assert.ok(restart, "a restart followed the resume");
|
|
1798
|
+
assert.match(restart, /validate G1/); assert.match(restart, /fixing one failure/);
|
|
1799
|
+
assert.doesNotMatch(restart, /The engine froze \.forge-lean\/contract\.json/);
|
|
1800
|
+
});
|
|
1752
1801
|
it("#4328 freeze-time preflight: a validate needing a module the host lacks gets the one contract correction, before any build", async () => {
|
|
1753
1802
|
const pyC = { ...CONTRACT, validate: [{ id: "V1", command: `python3 -c "import yaml"` }] }, uvC = { ...CONTRACT, validate: [{ id: "V1", command: `uv run python -c "import yaml"` }] };
|
|
1754
1803
|
const probe = (w) => { const ran = []; w.io.probeCommand = async (a) => { ran.push(a); return { rc: /^'python3' .*'yaml'/.test(a.command) ? 3 : 0, output: "" }; }; return ran; };
|
|
@@ -2348,6 +2397,35 @@ describe("bug lanes freeze a red-green repro_test (#4271)", () => {
|
|
|
2348
2397
|
assert.equal((await run(fixed, { conformance: "shadow" })).terminalReason, "merged"); assert.equal(fixed.rgCalls.length, 2);
|
|
2349
2398
|
});
|
|
2350
2399
|
|
|
2400
|
+
it("#5732 a head that failed on an absent interpreter is env.repro_unrunnable with its output, no builder resume", async () => {
|
|
2401
|
+
const w = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2402
|
+
w.io.runCommand = async () => ({ rc: 1, output: "Creating virtualenv\npoetry env use: python3.11 not found" });
|
|
2403
|
+
const r = await run(w, { conformance: "enforce" });
|
|
2404
|
+
assert.equal(r.code, "env.repro_unrunnable"); assert.equal(w.merges.length, 0);
|
|
2405
|
+
assert.equal(builders(w).length, 2, "plan + implement only");
|
|
2406
|
+
assert.match(nh(w), /output tail/); assert.match(nh(w), /python3\.11 not found/);
|
|
2407
|
+
});
|
|
2408
|
+
it("#5732 a red head's output tail reaches the builder resume and the needs-human comment", async () => {
|
|
2409
|
+
const w = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2410
|
+
w.io.runCommand = async () => ({ rc: 1, output: "not ok 1 - foo handles null\n AssertionError: expected 3, got undefined" });
|
|
2411
|
+
const r = await run(w, { conformance: "enforce" });
|
|
2412
|
+
assert.equal(r.code, "conformance.unimplemented"); assert.equal(builders(w).length, 3, "one resume");
|
|
2413
|
+
assert.match(builders(w)[2][4], /AssertionError: expected 3, got undefined/);
|
|
2414
|
+
assert.match(nh(w), /AssertionError: expected 3, got undefined/);
|
|
2415
|
+
});
|
|
2416
|
+
it("#5732 remote placement: a head failure with no assertion text goes to the host recovery lane; one with assertion text resumes the builder", async () => {
|
|
2417
|
+
const remote = { conformance: "enforce", placement: { where: "remote", reason: "mode remote" } };
|
|
2418
|
+
const w = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2419
|
+
w.io.runCommand = async () => ({ rc: 1, output: "Traceback (most recent call last):\nOSError: [Errno 30] Read-only file system: '/sandbox/.cache'" });
|
|
2420
|
+
const r = await run(w, remote);
|
|
2421
|
+
assert.equal(r.code, ENV_VALIDATE_PLACEMENT); assert.equal(builders(w).length, 2, "no builder resume"); assert.equal(w.merges.length, 0);
|
|
2422
|
+
assert.match(nh(w), /Read-only file system/);
|
|
2423
|
+
const a = rworld([{ base: "SKIPPED", head: "FAILED" }]);
|
|
2424
|
+
a.io.runCommand = async () => ({ rc: 1, output: "E AssertionError: 0.5 != 0.4" });
|
|
2425
|
+
const ar = await run(a, remote);
|
|
2426
|
+
assert.notEqual(ar.code, ENV_VALIDATE_PLACEMENT); assert.equal(builders(a).length, 3, "a real red test resumes the builder");
|
|
2427
|
+
});
|
|
2428
|
+
|
|
2351
2429
|
it("#5080 a repro that already passes on the base ends already-fixed: the issue closes as completed citing the base, nothing merges, no resume", async () => {
|
|
2352
2430
|
for (const conformance of ["enforce", "shadow"]) {
|
|
2353
2431
|
const w = rworld([{ base: "RAN", head: "RAN" }], { changed: ["test/foo.test.js"] });
|
|
@@ -6053,7 +6131,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6053
6131
|
it("#5332 a precheck round whose only non-zero result is rc 124 does not resume the builder or end ci.red, and is never self_check green", async () => {
|
|
6054
6132
|
const w = world(); const dir = tmpDir("core-");
|
|
6055
6133
|
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
6056
|
-
const r = await run(w, { dir, precheck: { commands: ["make slow"] } });
|
|
6134
|
+
const r = await atIdleLoad(() => run(w, { dir, precheck: { commands: ["make slow"] } }));
|
|
6057
6135
|
assert.equal(r.terminalReason, "merged");
|
|
6058
6136
|
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0, "no builder resume");
|
|
6059
6137
|
const pre = readLog(dir, 7).filter((e) => e.event === "PRECHECK_COMMANDS");
|
|
@@ -6063,7 +6141,7 @@ describe("local-mode CI fix rounds at merge and declared pre-PR check commands (
|
|
|
6063
6141
|
it("#5332 with verify.precheck_block a timed-out check ends env.validate_timeout (not ci.red) naming the command and limit", async () => {
|
|
6064
6142
|
const w = world();
|
|
6065
6143
|
w.io.runCommand = async () => ({ rc: 124, output: "(timed out after 1s)" });
|
|
6066
|
-
const r = await run(w, { precheck: { commands: ["make slow"] }, verify: { ...parseVerify({}), precheckBlock: true } });
|
|
6144
|
+
const r = await atIdleLoad(() => run(w, { precheck: { commands: ["make slow"] }, verify: { ...parseVerify({}), precheckBlock: true } }));
|
|
6067
6145
|
assert.equal(r.code, ENV_VALIDATE_TIMEOUT); assert.equal(r.terminalReason, "needs-human"); assert.equal(w.merges.length, 0);
|
|
6068
6146
|
assert.equal(builders(w).filter((b) => /declared check commands failed/.test(b[4])).length, 0);
|
|
6069
6147
|
assert.match((w.comments.find((c) => c.includes("FORGE:NEEDS_HUMAN")) ?? ""), /`make slow` \(timed out after 1 s, exit 124\)/);
|
|
@@ -8266,8 +8344,8 @@ describe("#4450 light lane: one builder session, derived contract, upgrade to th
|
|
|
8266
8344
|
const cmds = ["node --test t1.js", "node --test t2.js", "node --test t3.js", "node --test t4.js"];
|
|
8267
8345
|
const w = lworld({ result: { ...RESULT, tests: cmds.map((command) => ({ command, result: "pass" })) } }), dir = tmpDir("light-par-");
|
|
8268
8346
|
let live = 0, max = 0;
|
|
8269
|
-
const seen = [];
|
|
8270
|
-
w.io.runCommand = async (a) => { live++; max = Math.max(max, live); seen.push(a.env?.FORGE_HOST_PARALLELISM); await new Promise((r) => setTimeout(r, 5)); live--; return { rc: 0, output: "" }; };
|
|
8347
|
+
const seen = [], first = new Set(); // #5728: only the light run of each command; the engine's later run of the derived V rows (no recorded result) is sequential, full share
|
|
8348
|
+
w.io.runCommand = async (a) => { live++; max = Math.max(max, live); if (!first.has(a.command)) { first.add(a.command); seen.push(a.env?.FORGE_HOST_PARALLELISM); } await new Promise((r) => setTimeout(r, 5)); live--; return { rc: 0, output: "" }; };
|
|
8271
8349
|
const prev = process.env.FORGE_HOST_PARALLELISM;
|
|
8272
8350
|
process.env.FORGE_HOST_PARALLELISM = "2";
|
|
8273
8351
|
try { await run(w, { dir, ...ON }); } finally { if (prev === undefined) delete process.env.FORGE_HOST_PARALLELISM; else process.env.FORGE_HOST_PARALLELISM = prev; }
|
package/bin/lean/prompts.mjs
CHANGED
|
@@ -308,7 +308,7 @@ export function pagePlanNote(cfg) {
|
|
|
308
308
|
|
|
309
309
|
export function reproPlanNote(on) {
|
|
310
310
|
if (!on) return "";
|
|
311
|
-
return `\n\nThis issue is a bug. When it is testable, ${CONTRACT_FILE} must also carry "repro_test":{"path":"<test file>","id":"<test name>","command":"<exact command that runs only that test>"}: a test that fails on the base and passes after the fix. The command's environment must come from the repo's own lockfile or toolchain (its project runner, a lockfile export fed to uv run --with-requirements, or a forge.yaml validate.recipes entry); never a hand-picked --with package list with --offline, which cannot import the module under test (env.repro_unrunnable). The engine proves it with scripts/acceptance-red-green.sh (head's changed test files are overlaid on the base) and fails the run if it is not red on base and green on head. When it is not testable (specs, docs, workflows, environment), write "repro_test":"none","repro_test_reason":"<one line why>" instead.
|
|
311
|
+
return `\n\nThis issue is a bug. When it is testable, ${CONTRACT_FILE} must also carry "repro_test":{"path":"<test file>","id":"<test name>","command":"<exact command that runs only that test>"}: a test that fails on the base and passes after the fix. The command's environment must come from the repo's own lockfile or toolchain (its project runner, a lockfile export fed to uv run --with-requirements, or a forge.yaml validate.recipes entry); never a hand-picked --with package list with --offline, which cannot import the module under test (env.repro_unrunnable). The command is the bare test invocation: the engine prepares dependencies, so never put \`poetry env use\`, \`poetry install\`, \`pip install\`, \`uv venv\` or \`uv sync\` in it (it is rejected at freeze). The engine proves it with scripts/acceptance-red-green.sh (head's changed test files are overlaid on the base) and fails the run if it is not red on base and green on head. When it is not testable (specs, docs, workflows, environment), write "repro_test":"none","repro_test_reason":"<one line why>" instead.
|
|
312
312
|
|
|
313
313
|
Also write a \`### Test plan\` section in ${INVESTIGATION_FILE} and "test_plan":[{"requirement":"R1","proof":"<the root-cause observable that was wrong and must now hold, e.g. 'www.reddit.com/*.json returns 200 JSON', never 'the URL is rewritten'>","level":"unit|integration|e2e|live","level_reason":"<why this is the cheapest level that observes the cause>","repro":"<test id, red on base and green on head> or no-repro","reason":"<no-repro only>","regression":["<neighbouring behaviours that must stay green>"],"env":["<services, fixtures, packages>"],"command":"<exact command>"}] in ${CONTRACT_FILE}, one row per deliver requirement. A proof that restates a deliverable is rejected; never mock the component the bug lives in.`;
|
|
314
314
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
|
+
// #5732: a repro HEAD=FAILED carries the failing run's output, and an absent interpreter is the environment, not a red test.
|
|
4
|
+
// Imports only exports that exist on the base, so on the base this file loads and fails by assertion.
|
|
5
|
+
import { describe, it } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { reproFailures, reproEnvMiss } from "./conformance.mjs";
|
|
8
|
+
|
|
9
|
+
// The recorded AlterLab #41002 repro_test shape (bare test invocation)
|
|
10
|
+
const C41002 = { repro_test: { path: "services/api/tests/test_admin_scraping_kpis_41002.py", id: "test_list_and_detail_success_rate_match_with_tier_cap",
|
|
11
|
+
command: "cd services/api && poetry run pytest -q -p no:cacheprovider tests/test_admin_scraping_kpis_41002.py::test_list_and_detail_success_rate_match_with_tier_cap" } };
|
|
12
|
+
const PYTEST_FAIL = ["F [100%]",
|
|
13
|
+
" def test_list_and_detail_success_rate_match_with_tier_cap():", "> assert detail.success_rate == listing.success_rate",
|
|
14
|
+
"E AssertionError: 0.5 != 0.4", "FAILED tests/test_admin_scraping_kpis_41002.py::test_list_and_detail_success_rate_match_with_tier_cap", "1 failed in 0.31s"].join("\n");
|
|
15
|
+
|
|
16
|
+
describe("#5732 repro output and env classification", () => {
|
|
17
|
+
it("#5732 repro_red_green failure carries the head output tail", () => {
|
|
18
|
+
const [f] = reproFailures(C41002, { base: "SKIPPED", head: "FAILED", headOutput: PYTEST_FAIL });
|
|
19
|
+
assert.equal(f.kind, "repro_red_green");
|
|
20
|
+
assert.match(f.detail, /got BASE=SKIPPED HEAD=FAILED/);
|
|
21
|
+
assert.match(f.detail, /output tail/);
|
|
22
|
+
assert.match(f.detail, /AssertionError: 0\.5 != 0\.4/);
|
|
23
|
+
});
|
|
24
|
+
it("#5732 the tail is the last 20 lines, and the base run's output is shown too", () => {
|
|
25
|
+
const long = Array.from({ length: 30 }, (_, i) => `line ${i + 1}`).join("\n");
|
|
26
|
+
const [f] = reproFailures(C41002, { base: "RAN", head: "RAN", headOutput: "1 passed", baseOutput: long });
|
|
27
|
+
assert.equal(f.kind, "repro_base_green");
|
|
28
|
+
assert.match(f.detail, /base output tail \(last 20 lines\)/);
|
|
29
|
+
assert.match(f.detail, /line 30/);
|
|
30
|
+
assert.doesNotMatch(f.detail, /line 10\n/);
|
|
31
|
+
});
|
|
32
|
+
it("#5732 no output, no tail", () => {
|
|
33
|
+
assert.doesNotMatch(reproFailures(C41002, { base: "SKIPPED", head: "FAILED" })[0].detail, /output tail/);
|
|
34
|
+
});
|
|
35
|
+
it("#5732 interpreter-missing head is env", () => {
|
|
36
|
+
assert.ok(reproEnvMiss({ rc: 1, output: "poetry env use: python3.11 not found" }, {}));
|
|
37
|
+
assert.ok(reproEnvMiss({ rc: 1, output: "\nCould not find the python executable python3.11\n" }, {}));
|
|
38
|
+
assert.equal(reproEnvMiss({ rc: 1, output: PYTEST_FAIL }, {}), null, "a real assertion failure stays the change's");
|
|
39
|
+
});
|
|
40
|
+
it("#5732 an env-classified head is repro_env, with the output tail", () => {
|
|
41
|
+
const [f] = reproFailures(C41002, { base: "SKIPPED", head: "UNRUNNABLE", headOutput: "poetry env use: python3.11 not found" });
|
|
42
|
+
assert.equal(f.kind, "repro_env");
|
|
43
|
+
assert.match(f.detail, /python3\.11 not found/);
|
|
44
|
+
});
|
|
45
|
+
});
|
package/bin/pool/agent.mjs
CHANGED
|
@@ -54,6 +54,8 @@ export const dindName = (name) => `${name}-dind`;
|
|
|
54
54
|
export const workVolume = (name) => `cs-work-${name.replace(/^cs-/, "")}`;
|
|
55
55
|
/** #5696: the lane worktree is a plain dir on the cache volume (one mount), so depcache hardlinks never hit EXDEV. */
|
|
56
56
|
export const workDirOf = (name) => `/cache/work/${name.replace(/^cs-/, "")}`;
|
|
57
|
+
/** #5738: private dockerd boot. $1 is the sandbox work dir; /work points at it exactly as in the lane, loopback API only. */
|
|
58
|
+
export const DIND_BOOT = 'mkdir -p "$1" && ln -sfn "$1" /work && exec dind dockerd --host=tcp://127.0.0.1:2375 --tls=false';
|
|
57
59
|
const WORK_SWEEP_MS = 10 * 60000;
|
|
58
60
|
export const safeName = (id) => `cs-${String(id).toLowerCase().replace(/[^a-z0-9_.-]/g, "-").slice(0, 100)}`;
|
|
59
61
|
/** Minimum gap between two environment-snapshot ensure runs for one cache volume. */
|
|
@@ -204,7 +206,9 @@ export function createAgent(cfg, { docker, now = () => Date.now(), log = console
|
|
|
204
206
|
"--privileged", "--cpus", String(dCpus), "--memory", mb(dMem), "--memory-swap", mb(dMem + swapFor(limit?.dind_swap_gb)),
|
|
205
207
|
...netArgs, ...work,
|
|
206
208
|
// Bypass dockerd-entrypoint: it adds tcp://0.0.0.0:2375 (reachable from other sandboxes on the bridge).
|
|
207
|
-
|
|
209
|
+
// #5738: the lane's /work is a symlink to its work dir (entrypoint.sh), so give the daemon the same symlink:
|
|
210
|
+
// bind sources under /work (`docker run -v /work/x:/y`) must resolve to the checkout, not an empty new dir.
|
|
211
|
+
"--entrypoint", "sh", dindImage, "-c", DIND_BOOT, "sh", rec.workDir,
|
|
208
212
|
]);
|
|
209
213
|
laneNet = ["--network", `container:${dindName(name)}`];
|
|
210
214
|
}
|
package/package.json
CHANGED
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
# Bash 3.2 portable.
|
|
23
23
|
set -uo pipefail
|
|
24
24
|
|
|
25
|
-
REPO=""; BASE_REF=""; CMD=""; TMO=300
|
|
25
|
+
REPO=""; BASE_REF=""; CMD=""; TMO=300; OUTDIR=""
|
|
26
26
|
while [ $# -gt 0 ]; do
|
|
27
27
|
case "$1" in
|
|
28
28
|
--repo-path) REPO="${2-}"; shift 2 ;;
|
|
29
29
|
--base-ref) BASE_REF="${2-}"; shift 2 ;;
|
|
30
30
|
--test-cmd) CMD="${2-}"; shift 2 ;;
|
|
31
31
|
--timeout) TMO="${2-}"; shift 2 ;;
|
|
32
|
-
|
|
32
|
+
--output-dir) OUTDIR="${2-}"; shift 2 ;;
|
|
33
|
+
*) echo "usage: acceptance-red-green.sh --repo-path <dir> --base-ref <ref> --test-cmd <cmd> [--timeout <sec>] [--output-dir <dir>]" >&2; exit 2 ;;
|
|
33
34
|
esac
|
|
34
35
|
done
|
|
35
|
-
[ -n "$REPO" ] && [ -d "$REPO" ] && [ -n "$BASE_REF" ] && [ -n "$CMD" ] || { echo "usage: acceptance-red-green.sh --repo-path <dir> --base-ref <ref> --test-cmd <cmd> [--timeout <sec>]" >&2; exit 2; }
|
|
36
|
+
[ -n "$REPO" ] && [ -d "$REPO" ] && [ -n "$BASE_REF" ] && [ -n "$CMD" ] || { echo "usage: acceptance-red-green.sh --repo-path <dir> --base-ref <ref> --test-cmd <cmd> [--timeout <sec>] [--output-dir <dir>]" >&2; exit 2; }
|
|
36
37
|
case "$TMO" in ''|*[!0-9]*) TMO=300 ;; esac
|
|
37
38
|
CLS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/classify-test-run.sh"
|
|
38
39
|
|
|
@@ -54,6 +55,10 @@ run_in() {
|
|
|
54
55
|
local dir="$1" out="$WORK/out.$$.txt" rc cls
|
|
55
56
|
if [ -n "$TIMEOUT_BIN" ]; then ( cd "$dir" && "$TIMEOUT_BIN" "$TMO" bash -c "$CMD" ) >"$out" 2>&1; rc=$?
|
|
56
57
|
else ( cd "$dir" && bash -c "$CMD" ) >"$out" 2>&1; rc=$?; fi
|
|
58
|
+
# #5732: keep each run's output for the caller's failure detail (head.out for the head run, base.out for the first base run)
|
|
59
|
+
if [ -n "$OUTDIR" ] && [ -d "$OUTDIR" ]; then
|
|
60
|
+
if [ "$dir" = "$REPO" ]; then cp "$out" "$OUTDIR/head.out" 2>/dev/null; elif [ ! -e "$OUTDIR/base.out" ]; then cp "$out" "$OUTDIR/base.out" 2>/dev/null; fi
|
|
61
|
+
fi
|
|
57
62
|
case "$rc" in 124|126|127) echo UNRUNNABLE; return ;; esac
|
|
58
63
|
cls=$(bash "$CLS" "$rc" "$out" 2>/dev/null)
|
|
59
64
|
case "$cls" in FAILED|RAN|RAN_NOTHING) ;; *) echo UNRUNNABLE; return ;; esac
|
|
@@ -109,5 +109,13 @@ git -C "$R6" add -A; git -C "$R6" commit -qm t; git -C "$R6" update-ref refs/rem
|
|
|
109
109
|
printf 'echo "2 passed"\n' > "$R6/tests/t.sh"; git -C "$R6" add -A; git -C "$R6" commit -qm t2
|
|
110
110
|
check "modified test passing on base in both versions has no PRISTINE word (#5544)" "BASE=RAN HEAD=RAN" "$R6" "bash tests/t.sh"
|
|
111
111
|
|
|
112
|
+
# 14. #5732 --output-dir keeps the head run's output (head failed) and the base run's output (red base); the word line is unchanged
|
|
113
|
+
OD="$TMP/od1"; mkdir -p "$OD"
|
|
114
|
+
got=$(bash "$RG" --repo-path "$R1" --base-ref origin/main --test-cmd "echo 'E AssertionError: 0.5 != 0.4'; exit 1" --output-dir "$OD" 2>/dev/null)
|
|
115
|
+
if [ "$got" = "BASE=SKIPPED HEAD=FAILED" ] && grep -q "AssertionError: 0.5 != 0.4" "$OD/head.out" && [ ! -e "$OD/base.out" ]; then ok "#5732 --output-dir keeps the failing head output"; else bad "#5732 --output-dir head (got '$got')"; fi
|
|
116
|
+
OD="$TMP/od2"; mkdir -p "$OD"
|
|
117
|
+
got=$(bash "$RG" --repo-path "$R1" --base-ref origin/main --test-cmd "bash tests/t.sh" --output-dir "$OD" 2>/dev/null)
|
|
118
|
+
if [ "$got" = "BASE=FAILED HEAD=RAN" ] && [ -f "$OD/head.out" ] && [ -f "$OD/base.out" ]; then ok "#5732 --output-dir keeps the base output"; else bad "#5732 --output-dir base (got '$got')"; fi
|
|
119
|
+
|
|
112
120
|
echo "$PASS passed, $FAILN failed"
|
|
113
121
|
[ "$FAILN" -eq 0 ]
|