forgedock 1.60.0 → 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/lean/conformance.mjs +7 -1
- package/bin/lean/conformance.test.mjs +7 -1
- package/bin/lean/lean.mjs +23 -6
- package/bin/lean/lean.test.mjs +26 -0
- package/bin/lean/preflight.mjs +62 -1
- package/bin/lean/preflight.test.mjs +30 -1
- package/bin/lean/validate-catalog.mjs +16 -0
- package/bin/lean/validate-catalog.test.mjs +14 -1
- package/bin/pool/agent.mjs +9 -1
- package/bin/pool/lane-tools.mjs +31 -0
- package/bin/pool/router.mjs +3 -1
- package/bin/pool/warm.mjs +13 -2
- package/package.json +1 -1
- package/scripts/acceptance-red-green.sh +5 -2
- package/scripts/acceptance-red-green.test.sh +11 -0
package/bin/lean/conformance.mjs
CHANGED
|
@@ -1206,7 +1206,7 @@ function frozenAmendedFiles(frozen, contract, outside, creep) {
|
|
|
1206
1206
|
* #4271: the frozen repro_test's red-green proof ({base, head} words from scripts/acceptance-red-green.sh). Anything but
|
|
1207
1207
|
* HEAD=RAN BASE=FAILED fails; code conformance.unimplemented, so it blocks in shadow too and goes back to the builder.
|
|
1208
1208
|
* #4334: HEAD=UNRUNNABLE or no words (the harness could not run the test) is env.repro_unrunnable, kind repro_env: an
|
|
1209
|
-
* environment error, never a builder resume.
|
|
1209
|
+
* environment error, never a builder resume. So is BASE=UNRUNNABLE with HEAD=RAN (the base checkout could not run it).
|
|
1210
1210
|
*/
|
|
1211
1211
|
export function reproFailures(contract, { base, head, pristine } = {}) {
|
|
1212
1212
|
if (head === "RAN" && base === "FAILED") return [];
|
|
@@ -1218,6 +1218,12 @@ export function reproFailures(contract, { base, head, pristine } = {}) {
|
|
|
1218
1218
|
return [{ code: C.ENV_REPRO_UNRUNNABLE, kind: "repro_env",
|
|
1219
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"}` }];
|
|
1220
1220
|
}
|
|
1221
|
+
// 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
|
+
// environment too: the change cannot fix it, so it is never a builder resume (AlterLab 40652/40665, BASE=UNRUNNABLE HEAD=RAN).
|
|
1223
|
+
if (head === "RAN" && base === "UNRUNNABLE") {
|
|
1224
|
+
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` }];
|
|
1226
|
+
}
|
|
1221
1227
|
const skipped = base === "SKIPPED" ? " (base not run: head did not pass)" : "";
|
|
1222
1228
|
// #5080: the test already passes on the base: the fix is there (a hotfix or another PR), not missing from this change
|
|
1223
1229
|
if (base === "RAN") return [{ code: C.CONFORMANCE_UNIMPLEMENTED, kind: "repro_base_green",
|
|
@@ -862,7 +862,7 @@ describe("repro_test on bug lanes (#4271)", () => {
|
|
|
862
862
|
it("red on base and green on head passes; anything else fails the precheck as conformance.unimplemented", () => {
|
|
863
863
|
const k = { ...C, repro_test: RT };
|
|
864
864
|
assert.deepEqual(precheck({ contract: k, result: res, changedFiles: files, repro: { base: "FAILED", head: "RAN" } }), { ok: true, failures: [], superseded: [], ciCovered: [], equivalent: [] });
|
|
865
|
-
for (const repro of [{ base: "SKIPPED", head: "FAILED" }, { base: "
|
|
865
|
+
for (const repro of [{ base: "SKIPPED", head: "FAILED" }, { base: "SKIPPED", head: "RAN_NOTHING" }]) {
|
|
866
866
|
const pc = precheck({ contract: k, result: res, changedFiles: files, repro });
|
|
867
867
|
assert.deepEqual(pc.failures.map((f) => [f.code, f.kind]), [["conformance.unimplemented", "repro_red_green"]], JSON.stringify(repro));
|
|
868
868
|
assert.match(pc.failures[0].detail, new RegExp(`BASE=${repro.base} HEAD=${repro.head}`));
|
|
@@ -907,6 +907,12 @@ describe("repro_test on bug lanes (#4271)", () => {
|
|
|
907
907
|
assert.match(pc.failures[0].detail, new RegExp(`BASE=${repro.base ?? "UNRUNNABLE"} HEAD=UNRUNNABLE$`));
|
|
908
908
|
}
|
|
909
909
|
});
|
|
910
|
+
it("BASE=UNRUNNABLE with HEAD=RAN (the base checkout could not run the test) is env.repro_unrunnable, never a builder resume", () => {
|
|
911
|
+
const k = { ...C, repro_test: RT };
|
|
912
|
+
const pc = precheck({ contract: k, result: res, changedFiles: files, repro: { base: "UNRUNNABLE", head: "RAN" } });
|
|
913
|
+
assert.deepEqual(pc.failures.map((f) => [f.code, f.kind]), [["env.repro_unrunnable", "repro_env"]]);
|
|
914
|
+
assert.match(pc.failures[0].detail, /could not run the test on the base \(environment, not the change\); got BASE=UNRUNNABLE HEAD=RAN$/);
|
|
915
|
+
});
|
|
910
916
|
it("off (no repro option) is today's contract check and precheck exactly", () => {
|
|
911
917
|
assert.deepEqual(validateContract(C, ISSUE), validateContract(C, ISSUE, { repro: false }));
|
|
912
918
|
assert.deepEqual(validateContract(C, ISSUE), { ok: true, problems: [] });
|
package/bin/lean/lean.mjs
CHANGED
|
@@ -30,7 +30,7 @@ import { matchBaselines, baselineFailures, foldRegression } from "./baselines.mj
|
|
|
30
30
|
import { readRollouts, detectNewOffKeys, rolloutModes, liveDeferralBlocks } from "./activation.mjs";
|
|
31
31
|
import { toolMisses } from "./toolplace.mjs";
|
|
32
32
|
import { hasRecipe, installLaneTools } from "../pool/lane-tools.mjs";
|
|
33
|
-
import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins } from "./preflight.mjs";
|
|
33
|
+
import { testRunnerProblems, preflightProbes, preflightProblems, unsetEnvVars, runPreflight, knownToContract, declaredEnv, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins, manifestDepOwner } from "./preflight.mjs";
|
|
34
34
|
import { resolveLane, isDefaultLane, isShippedLane, DEFAULT_STAGING_BRANCH } from "./lane.mjs";
|
|
35
35
|
import { splitGate, rationaleLine } from "./decompose.mjs";
|
|
36
36
|
import { ceilingFor, predictRestart, handoffFacts, NARROW_NOTE } from "./ceiling.mjs";
|
|
@@ -111,7 +111,7 @@ import { makePostRun } from "./postrun.mjs";
|
|
|
111
111
|
import { ensureSignedOff, salvageBranch, dropSalvageTracking } from "./signoff.mjs";
|
|
112
112
|
import { reconcileCheckpoints } from "./checkpoint-reconcile.mjs";
|
|
113
113
|
import { createLedger, flattenPhases } from "./phaseledger.mjs";
|
|
114
|
-
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure } from "./validate-catalog.mjs";
|
|
114
|
+
import { DEFAULT_CATALOG_SOURCES, deriveCatalog, mergeRecipes, rewriteMissed, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
115
115
|
import { runLightStep, runLightTests, lightBuildPrompt, upgradeNote, renderLiteReceipt } from "./lightlane.mjs";
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -1879,6 +1879,13 @@ export async function runCore(o) {
|
|
|
1879
1879
|
await git(["add", "--", CHECKS_FILE]); await git(["commit", "--no-verify", "-m", "chore(forge): generated post-deploy checks for production-only e2e requirements (#5468)"]);
|
|
1880
1880
|
} catch (e) { T.anomalies.push(`generated post-deploy checks not committed: ${String(e?.message ?? e).slice(0, 160)}`); }
|
|
1881
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
|
+
}
|
|
1882
1889
|
function freezeRewrites(c) {
|
|
1883
1890
|
const r = applyValidateRecipes(c, validateRecipes);
|
|
1884
1891
|
const pd = (id, cmd) => { const to = rewriteProjectDirCommand(cmd); if (to !== cmd) T.decisions.push(`project-dir rewrite of ${id}: \`${cmd}\` -> \`${to}\``); return to; };
|
|
@@ -1888,6 +1895,9 @@ export async function runCore(o) {
|
|
|
1888
1895
|
if (t && typeof t === "object" && typeof t.command === "string") r.contract = { ...r.contract, repro_test: { ...t, command: pd("repro_test", t.command) } };
|
|
1889
1896
|
}
|
|
1890
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}\``);
|
|
1891
1901
|
r.contract = foldRegression(r.contract); // #5448: the blast-radius regression set runs as validate G# entries
|
|
1892
1902
|
const e = autoPostDeployE2e(r.contract); // #5468: production-only e2e/manual rows become post-deploy with a generated check
|
|
1893
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)"}`); }
|
|
@@ -2257,6 +2267,7 @@ export async function runCore(o) {
|
|
|
2257
2267
|
return o.contract;
|
|
2258
2268
|
};
|
|
2259
2269
|
let contract = dropScope(await readContract());
|
|
2270
|
+
freezeTracked = (await depOwnerOf()).files;
|
|
2260
2271
|
contract = freezeRewrites(contract);
|
|
2261
2272
|
await persistGenChecks();
|
|
2262
2273
|
await refreshIssue("contract validation");
|
|
@@ -2343,8 +2354,11 @@ export async function runCore(o) {
|
|
|
2343
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(", ")})` });
|
|
2344
2355
|
}
|
|
2345
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)
|
|
2346
|
-
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; };
|
|
2347
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 */ } }
|
|
2348
2362
|
if (envMiss.length) {
|
|
2349
2363
|
try {
|
|
2350
2364
|
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
@@ -2370,12 +2384,15 @@ export async function runCore(o) {
|
|
|
2370
2384
|
const hn = contractHostNeeds(frozen, o.hostCaps && { ...o.hostCaps, hostCapabilities: (o.hostCaps.hostCapabilities ?? []).filter((c) => !relayed.has(c)) });
|
|
2371
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);
|
|
2372
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)
|
|
2373
|
-
|
|
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 */ } }
|
|
2374
2391
|
if (tm.tools.length) { // #5423: provision the sandbox once (nested lockfiles, pytest) and re-probe before giving the lane up
|
|
2375
2392
|
try {
|
|
2376
2393
|
if (io.deps?.prepare) await io.deps.prepare({ wt, repoKey: repoKey(cwd), env: toolchain?.env ?? undefined });
|
|
2377
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() });
|
|
2378
|
-
tm = toolMisses(await preflightValidates(frozen).catch(() => []));
|
|
2395
|
+
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2379
2396
|
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
2380
2397
|
} catch { /* keep the original miss */ }
|
|
2381
2398
|
}
|
|
@@ -2385,7 +2402,7 @@ export async function runCore(o) {
|
|
|
2385
2402
|
const ins = await installLaneTools(withRecipe, { run: (a) => io.runCommand({ command: a.command, cwd: wt, timeoutMs: a.timeoutMs, env: laneEnv() }), root: process.getuid?.() === 0 });
|
|
2386
2403
|
ev({ event: "REMOTE_TOOLS_INSTALLED", tools: withRecipe, ok: ins.ok });
|
|
2387
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);
|
|
2388
|
-
tm = toolMisses(await preflightValidates(frozen).catch(() => []));
|
|
2405
|
+
tm = notOwned(toolMisses(await preflightValidates(frozen).catch(() => [])));
|
|
2389
2406
|
ev({ event: "REMOTE_PROVISIONED", remaining: tm.tools });
|
|
2390
2407
|
}
|
|
2391
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);
|
package/bin/lean/lean.test.mjs
CHANGED
|
@@ -8894,3 +8894,29 @@ describe("#5592 (8) comment and label spam", () => {
|
|
|
8894
8894
|
assert.ok(w.edits.some((e) => e.join(" ") === "issue edit 7 -R o/r --remove-label parked:ci.red"));
|
|
8895
8895
|
});
|
|
8896
8896
|
});
|
|
8897
|
+
|
|
8898
|
+
describe("#5683 monorepo sub-project dependencies are not host tools", () => {
|
|
8899
|
+
const pkg = JSON.stringify({ devDependencies: { vitest: "^1", vite: "^5" } });
|
|
8900
|
+
const withWeb = (w) => { const g = w.io.git; w.io.git = async (a, ...r) => (a[0] === "ls-files" && !a.includes(".forge-lean/") ? `${await g(a, ...r)}\nweb/package.json` : g(a, ...r)); w.files[`${WT}/web/package.json`] = pkg; return w; };
|
|
8901
|
+
const planEnv = (env) => ({ ...CONTRACT, test_plan: [{ requirement: "R1", proof: "the runner resolves", level: "unit", level_reason: "cheapest level that observes it", repro: "no-repro", reason: "env-only", command: "node --test test/foo.test.js", env }] });
|
|
8902
|
+
const hostMiss = (w) => { w.io.runCommand = async ({ command }) => (/command -v/.test(command) ? { rc: 1, output: "" } : { rc: 0, output: "" }); };
|
|
8903
|
+
it("monorepo sub-project env name is not a host tool: prepared, never env.tool_missing; a real host tool still is", async () => {
|
|
8904
|
+
const w = withWeb(world({ contract: planEnv(["vitest"]) })); let prepared = 0;
|
|
8905
|
+
w.io.deps = { prepare: async () => { prepared++; return []; } }; hostMiss(w);
|
|
8906
|
+
const ok = await run(w, { conformance: "enforce" });
|
|
8907
|
+
assert.notEqual(ok.code, OUTCOME_CODES.ENV_TOOL_MISSING); assert.ok(prepared >= 1);
|
|
8908
|
+
const h = withWeb(world({ contract: planEnv(["psql"]) })); h.io.deps = { prepare: async () => [] }; hostMiss(h);
|
|
8909
|
+
assert.equal((await run(h, { conformance: "enforce" })).code, OUTCOME_CODES.ENV_TOOL_MISSING);
|
|
8910
|
+
});
|
|
8911
|
+
it("monorepo sub-project remote name skips recipe branch; a manifest-less tool still hits it", async () => {
|
|
8912
|
+
const remote = { placement: { where: "remote", reason: "mode remote" } };
|
|
8913
|
+
const withTool = (tool) => ({ ...CONTRACT, validate: [...CONTRACT.validate, { id: "V2", command: `${tool} check x` }] });
|
|
8914
|
+
const probing = (w, tool) => { w.io.probeCommand = async (a) => ({ rc: new RegExp(tool).test(JSON.stringify(a)) ? 127 : 0, output: "" }); };
|
|
8915
|
+
const w = withWeb(world({ contract: withTool("vite") })); probing(w, "vite"); let prepared = 0; w.io.deps = { prepare: async () => { prepared++; return []; } };
|
|
8916
|
+
const r = await run(w, { dir: tmpDir("lean-5683a-"), ...remote });
|
|
8917
|
+
assert.notEqual(r.code, "env.tool_missing"); assert.ok(prepared >= 1);
|
|
8918
|
+
assert.doesNotMatch(w.comments.map((c) => c.body ?? c).join("\n"), /no lane_tools recipe/);
|
|
8919
|
+
const h = withWeb(world({ contract: withTool("zzcheck") })); probing(h, "zzcheck");
|
|
8920
|
+
assert.equal((await run(h, { dir: tmpDir("lean-5683b-"), ...remote })).code, "env.tool_missing");
|
|
8921
|
+
});
|
|
8922
|
+
});
|
package/bin/lean/preflight.mjs
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { builtinModules } from "node:module";
|
|
13
13
|
import { existsSync } from "node:fs";
|
|
14
|
-
import { join, dirname, delimiter } from "node:path";
|
|
14
|
+
import { join, dirname, delimiter, relative } from "node:path";
|
|
15
15
|
import { missingTool } from "./conformance.mjs";
|
|
16
16
|
|
|
17
17
|
export const PREFLIGHT_CAP = 20;
|
|
@@ -345,3 +345,64 @@ export function projectBinDirs(wt, files = [], { exists = existsSync, cap = 24 }
|
|
|
345
345
|
|
|
346
346
|
/** #5592: `base` PATH with the project-local executable dirs appended (never ahead of what the lane already resolves). */
|
|
347
347
|
export const withLocalBins = (base, dirs) => [...String(base ?? "").split(delimiter).filter(Boolean), ...dirs.filter((d) => !String(base ?? "").split(delimiter).includes(d))].join(delimiter);
|
|
348
|
+
|
|
349
|
+
const PY_MANIFESTS = new Set(["pyproject.toml", "poetry.lock", "uv.lock", "requirements.txt"]);
|
|
350
|
+
const normPy = (n) => String(n).toLowerCase().replace(/[-_.]+/g, "-");
|
|
351
|
+
const reEsc = (n) => String(n).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
352
|
+
/** #5683: does manifest text `text` (package.json, pyproject.toml, a requirements file) declare `name` as a dependency? */
|
|
353
|
+
function manifestDeclares(base, text, name) {
|
|
354
|
+
if (base === "package.json") {
|
|
355
|
+
try { const j = JSON.parse(text); return ["dependencies", "devDependencies", "peerDependencies", "optionalDependencies"].some((k) => j?.[k] && Object.hasOwn(j[k], name)); } catch { return false; }
|
|
356
|
+
}
|
|
357
|
+
const n = reEsc(normPy(name)).replace(/-/g, "[-_.]+");
|
|
358
|
+
if (base === "pyproject.toml") return new RegExp(`["']\\s*${n}(?:\\[[^\\]]*\\])?\\s*(?:[<>=!~;@ ,]|["'])|^\\s*${n}\\s*=`, "im").test(text);
|
|
359
|
+
return new RegExp(`^\\s*${n}(?:\\[[^\\]]*\\])?\\s*(?:[<>=!~;@#]|$)`, "im").test(text);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* #5683: the sub-project dir whose tracked manifest (package.json deps/devDeps/peerDeps, pyproject dependencies, a requirements
|
|
363
|
+
* file) declares `name`, or null. A declared test-plan env name that has an owner is a project dependency the lane prepares
|
|
364
|
+
* (deps.prepare), never a host tool or a lane_tools recipe. `files`: tracked paths; `readFile(path)`: manifest text. Pure.
|
|
365
|
+
*/
|
|
366
|
+
export function manifestDepOwner(name, files = [], readFile = () => "") {
|
|
367
|
+
for (const f of files) {
|
|
368
|
+
const parts = String(f).split("/"), base = parts[parts.length - 1];
|
|
369
|
+
if (parts.includes("node_modules") || !(base === "package.json" || base === "pyproject.toml" || /^requirements[\w.-]*\.txt$/.test(base))) continue;
|
|
370
|
+
let text = ""; try { text = String(readFile(f) ?? ""); } catch { continue; }
|
|
371
|
+
if (manifestDeclares(base.startsWith("requirements") ? "requirements.txt" : base, text, name)) return dirname(f);
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** nearest ancestor dir (of `dir`, up to the root ".") holding a tracked Python manifest, or null. */
|
|
377
|
+
function nearestPyProject(dir, files) {
|
|
378
|
+
const have = new Set(files.filter((f) => PY_MANIFESTS.has(String(f).split("/").pop()) || /(^|\/)requirements[\w.-]*\.txt$/.test(f)).map((f) => dirname(f)));
|
|
379
|
+
for (let d = dir; ; d = dirname(d)) { if (have.has(d)) return d; if (d === "." || d === "/") return null; }
|
|
380
|
+
}
|
|
381
|
+
const PYTEST_SEG = /^(\s*(?:[A-Za-z_]\w*=\S*\s+)*)(?:python3?(?:\.\d+)?\s+-m\s+pytest|pytest)\b/;
|
|
382
|
+
/**
|
|
383
|
+
* #5683: a bare `python -m pytest` / `pytest` in a sub-project that has a tracked Python manifest and an in-project `.venv`
|
|
384
|
+
* runs through that venv's interpreter. The sub-project is the `cd X &&` directory, else the nearest manifest of the first
|
|
385
|
+
* test path, else the root. `exists(rel)`: repo-relative path check. Unchanged when no manifest or venv applies. Pure.
|
|
386
|
+
*/
|
|
387
|
+
export function venvPythonRewrite(command, files = [], exists = () => false) {
|
|
388
|
+
const parts = String(command ?? "").split(/(&&|\|\||;|\||\n)/);
|
|
389
|
+
let cwd = ".", changed = false;
|
|
390
|
+
const out = parts.map((seg, i) => {
|
|
391
|
+
if (i % 2) return seg;
|
|
392
|
+
const cd = /^\s*cd\s+(?:"([^"]+)"|'([^']+)'|(\S+))\s*$/.exec(seg);
|
|
393
|
+
if (cd) { const t = (cd[1] ?? cd[2] ?? cd[3]).replace(/^\.\//, "").replace(/\/+$/, ""); cwd = t.startsWith("/") || t.startsWith("$") || t.startsWith("..") ? "?" : join(cwd === "?" ? "." : cwd, t) || "."; return seg; }
|
|
394
|
+
const m = PYTEST_SEG.exec(seg);
|
|
395
|
+
if (!m || cwd === "?") return seg;
|
|
396
|
+
const rest = seg.slice(m[0].length);
|
|
397
|
+
const tp = rest.split(/\s+/).map((x) => x.replace(/::.*$/, "").replace(/^\.\//, "")).find((x) => x && !x.startsWith("-") && /[\w-]\/|\.py$/.test(x) && !x.startsWith("/"));
|
|
398
|
+
const origin = cwd !== "." ? cwd : tp ? dirname(tp) : ".";
|
|
399
|
+
const proj = nearestPyProject(origin, files);
|
|
400
|
+
if (proj === null) return seg;
|
|
401
|
+
const venv = join(proj, ".venv/bin/python");
|
|
402
|
+
if (!exists(venv)) return seg;
|
|
403
|
+
const rel = cwd === "." ? venv : relative(cwd, venv);
|
|
404
|
+
changed = true;
|
|
405
|
+
return `${m[1]}${rel} -m pytest${rest}`;
|
|
406
|
+
});
|
|
407
|
+
return changed ? out.join("") : String(command ?? "");
|
|
408
|
+
}
|
|
@@ -4,7 +4,7 @@ import { describe, it } from "node:test";
|
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
|
-
import { testRunnerProblems, shellSegments, pythonImports, nodeImports, preflightProbes, preflightProblems, runProbeMiss, unsetEnvVars, runPreflight, knownToContract, contractCommands, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins } from "./preflight.mjs";
|
|
7
|
+
import { manifestDepOwner, venvPythonRewrite, testRunnerProblems, shellSegments, pythonImports, nodeImports, preflightProbes, preflightProblems, runProbeMiss, unsetEnvVars, runPreflight, knownToContract, contractCommands, depInstallFailures, testRunSummary, projectBinDirs, withLocalBins } from "./preflight.mjs";
|
|
8
8
|
import { runCheckCommand } from "./effects.mjs";
|
|
9
9
|
import { repoTracks } from "./conformance.mjs";
|
|
10
10
|
import { tmpDir } from "../tests/_tmp.mjs";
|
|
@@ -194,3 +194,32 @@ describe("project-local executables (#5592 3d/9)", () => {
|
|
|
194
194
|
assert.equal(withLocalBins("/a:/b", ["/c", "/a"]), "/a:/b:/c");
|
|
195
195
|
});
|
|
196
196
|
});
|
|
197
|
+
|
|
198
|
+
describe("#5683 sub-project manifest deps and venv python", () => {
|
|
199
|
+
const files = ["package.json", "web/package.json", "services/api/pyproject.toml", "shared/content/pyproject.toml", "tools/requirements-dev.txt"];
|
|
200
|
+
const texts = { "web/package.json": JSON.stringify({ devDependencies: { vitest: "^1", vite: "^5" } }), "services/api/pyproject.toml": 'dependencies = ["Fast_Api>=1", "httpx"]\n[dependency-groups]\ndev = ["pytest>=8"]', "tools/requirements-dev.txt": "# dev\nruff==0.4\nblack[jupyter]>=24\n" };
|
|
201
|
+
const read = (f) => texts[f] ?? "";
|
|
202
|
+
it("manifestDepOwner resolves vitest to web", () => {
|
|
203
|
+
assert.equal(manifestDepOwner("vitest", files, read), "web");
|
|
204
|
+
assert.equal(manifestDepOwner("vite", files, read), "web");
|
|
205
|
+
assert.equal(manifestDepOwner("pytest", files, read), "services/api");
|
|
206
|
+
assert.equal(manifestDepOwner("fast-api", files, read), "services/api");
|
|
207
|
+
assert.equal(manifestDepOwner("black", files, read), "tools");
|
|
208
|
+
});
|
|
209
|
+
it("manifestDepOwner null for host tools", () => {
|
|
210
|
+
for (const t of ["psql", "promtool", "ruf"]) assert.equal(manifestDepOwner(t, files, read), null);
|
|
211
|
+
assert.equal(manifestDepOwner("vitest", ["web/node_modules/x/package.json"], () => texts["web/package.json"]), null);
|
|
212
|
+
});
|
|
213
|
+
const exists = (p) => ["services/api/.venv/bin/python", "shared/content/.venv/bin/python"].includes(p);
|
|
214
|
+
it("venvPythonRewrite uses sub-project venv", () => {
|
|
215
|
+
assert.equal(venvPythonRewrite("pytest -q", ["pyproject.toml"], (p) => p === ".venv/bin/python"), ".venv/bin/python -m pytest -q");
|
|
216
|
+
assert.equal(venvPythonRewrite("python -m pytest tests/x.py", files, exists), "python -m pytest tests/x.py");
|
|
217
|
+
assert.equal(venvPythonRewrite("cd services/api && .venv/bin/python -m pytest t.py", files, exists), "cd services/api && .venv/bin/python -m pytest t.py");
|
|
218
|
+
assert.equal(venvPythonRewrite("cd services/api && python -m pytest t.py", files, () => false), "cd services/api && python -m pytest t.py");
|
|
219
|
+
});
|
|
220
|
+
it("venvPythonRewrite cd prefix and nearest manifest", () => {
|
|
221
|
+
assert.equal(venvPythonRewrite("cd services/api && python -m pytest tests/x.py -q", files, exists), "cd services/api && .venv/bin/python -m pytest tests/x.py -q");
|
|
222
|
+
assert.equal(venvPythonRewrite("python3 -m pytest shared/content/tests/t.py::a", files, exists), "shared/content/.venv/bin/python -m pytest shared/content/tests/t.py::a");
|
|
223
|
+
assert.equal(venvPythonRewrite("cd web && pytest", files, exists), "cd web && pytest");
|
|
224
|
+
});
|
|
225
|
+
});
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* base-drift classifier. Pure; lean.mjs owns every effect.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { venvPythonRewrite } from "./preflight.mjs";
|
|
11
|
+
|
|
10
12
|
/** Default CI sources read for the derived catalogue (repo-relative). */
|
|
11
13
|
export const DEFAULT_CATALOG_SOURCES = [".github/workflows/ci.yml", "scripts/ci-local.sh"];
|
|
12
14
|
|
|
@@ -92,3 +94,17 @@ export function equivalentRuns(frozen, sub) {
|
|
|
92
94
|
const DRIFT_RE = /(?:generated|artifact|snapshot)s?\b[^\n]*\b(?:out of date|out-of-date|stale|differ|drift|not up to date)|\b(?:out of date|stale)\b[^\n]*\b(?:generated|regenerate)|run [`'"]?[^\n]*\bgenerate[\w:-]*[`'"]? to (?:update|regenerate)/i;
|
|
93
95
|
/** True when a validate failure's output reads as a stale generated artifact (a regenerate case), not a failing test. */
|
|
94
96
|
export const isDriftFailure = (output) => DRIFT_RE.test(String(output ?? ""));
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* #5683: the repro and validate commands that run a bare `python -m pytest` / `pytest` inside a sub-project with a tracked
|
|
100
|
+
* Python manifest and a `.venv` run through that venv's interpreter. Returns {contract, applied[{id, from, to}]}.
|
|
101
|
+
*/
|
|
102
|
+
export function rewriteSubprojectVenv(contract, files, exists) {
|
|
103
|
+
if (!contract || typeof contract !== "object") return { contract, applied: [] };
|
|
104
|
+
const applied = [], fix = (id, cmd) => { const to = venvPythonRewrite(cmd, files, exists); if (to !== cmd) applied.push({ id, from: cmd, to }); return to; };
|
|
105
|
+
const out = { ...contract };
|
|
106
|
+
if (Array.isArray(contract.validate)) out.validate = contract.validate.map((v) => (v && typeof v.command === "string" ? { ...v, command: fix(v.id, v.command) } : v));
|
|
107
|
+
const t = contract.repro_test;
|
|
108
|
+
if (t && typeof t === "object" && typeof t.command === "string") out.repro_test = { ...t, command: fix("repro_test", t.command) };
|
|
109
|
+
return applied.length ? { contract: out, applied } : { contract, applied };
|
|
110
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { describe, it } from "node:test";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
|
-
import { deriveCatalog, mergeRecipes, rewriteMissed, extractTestIds, equivalentRuns, isDriftFailure } from "./validate-catalog.mjs";
|
|
5
|
+
import { deriveCatalog, mergeRecipes, rewriteMissed, extractTestIds, equivalentRuns, isDriftFailure, rewriteSubprojectVenv } from "./validate-catalog.mjs";
|
|
6
6
|
import { applyValidateRecipes } from "./conformance.mjs";
|
|
7
7
|
|
|
8
8
|
const CI = "run: uv run --with-requirements r.txt pytest tests\nrun: npx vitest run";
|
|
@@ -40,3 +40,16 @@ describe("#5653 validate catalogue", () => {
|
|
|
40
40
|
assert.equal(isDriftFailure("AssertionError: 1 != 2"), false);
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
describe("#5683 sub-project venv rewrite", () => {
|
|
45
|
+
const files = ["services/api/pyproject.toml"], exists = (p) => p === "services/api/.venv/bin/python";
|
|
46
|
+
it("rewrites the repro and validate commands, leaves others, and returns the input when nothing changes", () => {
|
|
47
|
+
const c = { repro_test: { path: "t", id: "i", command: "cd services/api && python -m pytest tests/a.py" }, validate: [{ id: "V1", command: "cd services/api && pytest" }, { id: "V2", command: "node --test x" }] };
|
|
48
|
+
const r = rewriteSubprojectVenv(c, files, exists);
|
|
49
|
+
assert.equal(r.contract.repro_test.command, "cd services/api && .venv/bin/python -m pytest tests/a.py");
|
|
50
|
+
assert.deepEqual(r.contract.validate.map((v) => v.command), ["cd services/api && .venv/bin/python -m pytest", "node --test x"]);
|
|
51
|
+
assert.deepEqual(r.applied.map((a) => a.id).sort(), ["V1", "repro_test"]);
|
|
52
|
+
const same = { validate: [{ id: "V1", command: "node --test x" }] };
|
|
53
|
+
assert.equal(rewriteSubprojectVenv(same, files, exists).contract, same);
|
|
54
|
+
});
|
|
55
|
+
});
|
package/bin/pool/agent.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: Copyright (c) RapierCraft Studios
|
|
2
2
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
|
+
/** Retry-After for a launch whose lane_tools image is still building: lanes cap capacity deferrals at 3, so 3 × 5 min covers a cold build. */
|
|
5
|
+
const LANE_BUILD_RETRY_AFTER_S = 300;
|
|
4
6
|
import { randomBytes } from "node:crypto";
|
|
5
7
|
import { execFile, spawn } from "node:child_process";
|
|
6
8
|
import { promisify } from "node:util";
|
|
@@ -11,7 +13,7 @@ import { bearerOk, call, readJson, route, sameSecret, send } from "./http.mjs";
|
|
|
11
13
|
import { repoRoot, versionOf, laneImageTag, laneBuildArgs } from "./version.mjs";
|
|
12
14
|
import { jsonStore } from "./store.mjs";
|
|
13
15
|
import { makeWarm } from "./warm.mjs";
|
|
14
|
-
import { resolveLaneImage } from "./lane-tools.mjs";
|
|
16
|
+
import { resolveLaneImage, laneImageNow } from "./lane-tools.mjs";
|
|
15
17
|
|
|
16
18
|
const LABEL = "computeshare=1";
|
|
17
19
|
const LOG_CHUNK = 256 * 1024;
|
|
@@ -121,6 +123,12 @@ export function createAgent(cfg, { docker, now = () => Date.now(), log = console
|
|
|
121
123
|
// Burst model: reservations are small, so also refuse when the VM is genuinely short of memory or overloaded right now.
|
|
122
124
|
const h = live(cfg);
|
|
123
125
|
if (!h.ok) return { status: 503, body: { error: `host busy: ${h.reason}`, live: h }, retryAfter: 60 };
|
|
126
|
+
if (spec.lane_tools?.length) { // #5650 follow-up: never build inside the launch request (router timeout); 503 + retry while it builds
|
|
127
|
+
let st;
|
|
128
|
+
try { st = await laneImageNow({ tools: spec.lane_tools, baseImage: spec.image ?? image, docker }); } catch (e) { return { status: 422, body: { error: e.message, code: e.code ?? "lane_tools.invalid" } }; }
|
|
129
|
+
if (st.building) return { status: 503, body: { error: `lane image ${st.tag} building`, code: "lane_tools.building" }, retryAfter: LANE_BUILD_RETRY_AFTER_S };
|
|
130
|
+
if (st.failed) return { status: 422, body: { error: st.failed, code: "lane_tools.build_failed" } };
|
|
131
|
+
}
|
|
124
132
|
const name = safeName(spec.id);
|
|
125
133
|
const dir = join(stateDir, "sandboxes", name);
|
|
126
134
|
mkdirSync(join(dir, "result"), { recursive: true });
|
package/bin/pool/lane-tools.mjs
CHANGED
|
@@ -92,6 +92,12 @@ export function laneToolsDockerfile(baseImage, tools) {
|
|
|
92
92
|
return [`FROM ${baseImage}`, "USER root", ...steps, ""].join("\n");
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/** One in-flight build per tag (shared by every launch and the warm pool), and the last failure per tag. */
|
|
96
|
+
const BUILDS = new Map();
|
|
97
|
+
const FAILED = new Map();
|
|
98
|
+
/** How long a failed build is reported instead of retried. */
|
|
99
|
+
export const LANE_BUILD_RETRY_MS = 10 * 60000;
|
|
100
|
+
|
|
95
101
|
/**
|
|
96
102
|
* The image a launch runs: `baseImage` when no tools; else the per-repo tag, reused when present, built from the base
|
|
97
103
|
* otherwise. `docker.hasImage` and `docker.build(dir, tag, args)` are injected. Throws typed lane_tools.unknown_recipe
|
|
@@ -102,6 +108,31 @@ export async function resolveLaneImage({ tools = [], baseImage, docker, buildTim
|
|
|
102
108
|
checkRecipes(tools);
|
|
103
109
|
const tag = laneToolsTag(baseImage, tools);
|
|
104
110
|
if (await docker.hasImage?.(tag)) return tag;
|
|
111
|
+
if (!BUILDS.has(tag)) BUILDS.set(tag, buildLaneImage({ tag, baseImage, tools, docker, buildTimeoutMs }).finally(() => BUILDS.delete(tag)));
|
|
112
|
+
return BUILDS.get(tag); // concurrent callers share one build of a tag
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Non-blocking form for a launch (the router waits ~120 s, a build can take many minutes): {image} when the tag exists,
|
|
117
|
+
* {building: true} after starting (or joining) a background build, {failed: message} for a build that failed in the last
|
|
118
|
+
* LANE_BUILD_RETRY_MS. Throws typed lane_tools.unknown_recipe.
|
|
119
|
+
*/
|
|
120
|
+
export async function laneImageNow({ tools = [], baseImage, docker, buildTimeoutMs = 45 * 60000, now = Date.now }) {
|
|
121
|
+
if (!tools.length) return { image: baseImage };
|
|
122
|
+
checkRecipes(tools);
|
|
123
|
+
const tag = laneToolsTag(baseImage, tools);
|
|
124
|
+
if (await docker.hasImage?.(tag)) return { image: tag };
|
|
125
|
+
const f = FAILED.get(tag);
|
|
126
|
+
if (f && now() - f.at < LANE_BUILD_RETRY_MS) return { failed: f.message };
|
|
127
|
+
if (!BUILDS.has(tag)) {
|
|
128
|
+
FAILED.delete(tag);
|
|
129
|
+
const p = buildLaneImage({ tag, baseImage, tools, docker, buildTimeoutMs }).catch((e) => { FAILED.set(tag, { at: now(), message: e.message }); }).finally(() => BUILDS.delete(tag));
|
|
130
|
+
BUILDS.set(tag, p);
|
|
131
|
+
}
|
|
132
|
+
return { building: true, tag };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function buildLaneImage({ tag, baseImage, tools, docker, buildTimeoutMs }) {
|
|
105
136
|
const dir = mkdtempSync(join(tmpdir(), "lane-tools-"));
|
|
106
137
|
let timer;
|
|
107
138
|
try {
|
package/bin/pool/router.mjs
CHANGED
|
@@ -190,12 +190,14 @@ export function createRouter(cfg, { fetchFn = globalThis.fetch, now = () => Date
|
|
|
190
190
|
const size = sizeFor(spec);
|
|
191
191
|
const fits = (await capacities()).filter((c) => c.ok && !c.paused && c.cpus_free >= size.cpus && c.mem_free_gb >= size.mem_gb)
|
|
192
192
|
.sort((a, b) => b.cpus_free - a.cpus_free || b.mem_free_gb - a.mem_free_gb);
|
|
193
|
+
let busy = null; // the last agent 503 (e.g. lane_tools image building): its body and Retry-After are passed back
|
|
193
194
|
for (const c of fits) {
|
|
194
195
|
const r = await agentCall(own(agents(), c.name), "POST", "/sandboxes", { spec: withForgeYaml(spec), ...size }, 120000);
|
|
195
|
-
if (r.status === 503) continue; // raced with another launch; try the next host
|
|
196
|
+
if (r.status === 503) { busy = { r, name: c.name }; continue; } // raced with another launch, or still building; try the next host
|
|
196
197
|
if (r.ok) { sbx()[spec.id] = { agent: c.name, issue: spec.issue ?? null, batch: spec.batch ?? null, createdAt: now(), touched: now() }; store.save(); }
|
|
197
198
|
return { status: r.status, body: { ...agentBody(r, c.name), agent: c.name } };
|
|
198
199
|
}
|
|
200
|
+
if (busy) return { status: 503, body: { ...agentBody(busy.r, busy.name), agent: busy.name }, retryAfter: busy.r.retryAfter ?? cfg.retry_after_s ?? 60 };
|
|
199
201
|
return { status: 503, body: { error: "no host has a free reservation", lane: size }, retryAfter: cfg.retry_after_s ?? 60 };
|
|
200
202
|
}
|
|
201
203
|
|
package/bin/pool/warm.mjs
CHANGED
|
@@ -28,8 +28,19 @@ export function makeWarm({ store, sb, own, now, launch, destroy, view, log = con
|
|
|
28
28
|
return { key, n: want };
|
|
29
29
|
}
|
|
30
30
|
const list = () => recs().map((r) => ({ id: r.id, key: r.warm, state: r.state, ready: isReady(r), cpus: r.cpus, mem_gb: r.mem_gb }));
|
|
31
|
-
/**
|
|
32
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Start sandboxes until each repo has its n (ready or still preparing). Refused launches (capacity) are retried on the next call.
|
|
33
|
+
* Single-flight: a sandbox counts as warm only once its launch returns, so concurrent passes (every lane launch, claim and
|
|
34
|
+
* reaper tick calls this) each saw 0 and over-filled the pool (11 for n=1 when launches were slow). A call during a pass
|
|
35
|
+
* joins it and schedules one more pass for config that changed meanwhile.
|
|
36
|
+
*/
|
|
37
|
+
let inflight = null, again = false;
|
|
38
|
+
function replenish() {
|
|
39
|
+
if (inflight) { again = true; return inflight; }
|
|
40
|
+
inflight = (async () => { do { again = false; await replenishPass(); } while (again); })().finally(() => { inflight = null; });
|
|
41
|
+
return inflight;
|
|
42
|
+
}
|
|
43
|
+
async function replenishPass() {
|
|
33
44
|
for (const [key, w] of Object.entries(wanted())) {
|
|
34
45
|
for (let have = recs(key).length; have < w.n; have++) {
|
|
35
46
|
const id = `warm-${key}-${randomBytes(3).toString("hex")}`;
|
package/package.json
CHANGED
|
@@ -101,9 +101,12 @@ while IFS= read -r f; do
|
|
|
101
101
|
mkdir -p "$BASE_WT/$(dirname "$f")" && cp -p "$REPO/$f" "$BASE_WT/$f" 2>/dev/null && [ -f "$BASE_WT/$f" ] || OVERLAY_OK=false
|
|
102
102
|
done <<< "$CHANGED"
|
|
103
103
|
# Untracked dependency trees (never in git): link head's so a missing install is not mistaken for a red run (#4334):
|
|
104
|
-
# every node_modules next to a tracked package.json (workspace packages too, e.g. apps/web/node_modules) and
|
|
104
|
+
# every node_modules next to a tracked package.json (workspace packages too, e.g. apps/web/node_modules), and every .venv
|
|
105
|
+
# next to a tracked Python manifest (root or a monorepo service, e.g. services/api/.venv).
|
|
105
106
|
DEPS=$( { git -C "$REPO" ls-files -- package.json '*/package.json' 2>/dev/null | while IFS= read -r p; do
|
|
106
|
-
d=$(dirname "$p"); [ "$d" = "." ] && echo node_modules || echo "$d/node_modules"; done
|
|
107
|
+
d=$(dirname "$p"); [ "$d" = "." ] && echo node_modules || echo "$d/node_modules"; done
|
|
108
|
+
git -C "$REPO" ls-files -- pyproject.toml '*/pyproject.toml' poetry.lock '*/poetry.lock' uv.lock '*/uv.lock' 'requirements*.txt' '*/requirements*.txt' 2>/dev/null | while IFS= read -r p; do
|
|
109
|
+
d=$(dirname "$p"); [ "$d" = "." ] && echo .venv || echo "$d/.venv"; done; echo .venv; } | sort -u )
|
|
107
110
|
while IFS= read -r t; do
|
|
108
111
|
[ -n "$t" ] || continue
|
|
109
112
|
case "$t" in */node_modules/*) continue ;; esac # a package.json inside an installed tree
|
|
@@ -87,6 +87,17 @@ check "workspace node_modules and .venv linked into base; new nested test overla
|
|
|
87
87
|
[ -d "$R5/apps/web/node_modules/dep" ] && [ -d "$R5/.venv/bin" ] && ok "head dependency trees survive base cleanup" || bad "head dependency trees removed by cleanup"
|
|
88
88
|
|
|
89
89
|
|
|
90
|
+
# 11b. Python service venv (AlterLab 40652): a test under services/api runs with services/api/.venv (next to its tracked
|
|
91
|
+
# pyproject.toml), not the root .venv; base gets that tree linked, so it fails on the defect instead of UNRUNNABLE
|
|
92
|
+
R6="$TMP/r6"; make_repo "$R6"
|
|
93
|
+
mkdir -p "$R6/services/api"; printf '[project]\nname="api"\n' > "$R6/services/api/pyproject.toml"
|
|
94
|
+
printf '.venv/\n' > "$R6/.gitignore"; git -C "$R6" add -A; git -C "$R6" commit -qm svc; git -C "$R6" update-ref refs/remotes/origin/main HEAD
|
|
95
|
+
fix_head "$R6"
|
|
96
|
+
mkdir -p "$R6/services/api/.venv/bin" "$R6/services/api/tests"; printf 'echo venv\n' > "$R6/services/api/.venv/bin/python"
|
|
97
|
+
printf 'bash .venv/bin/python >/dev/null 2>&1 || exit 127\ntest "$(bash ../../app.sh)" = good && echo "1 passed"\n' > "$R6/services/api/tests/t.sh"
|
|
98
|
+
git -C "$R6" add -A; git -C "$R6" commit -qm test
|
|
99
|
+
check "service .venv next to a tracked pyproject.toml is linked into base" "BASE=FAILED HEAD=RAN" "$R6" "cd services/api && bash tests/t.sh"
|
|
100
|
+
|
|
90
101
|
# 12. #5544 test-only fix: the base's own version of the test fails, head's passes, source unchanged
|
|
91
102
|
R5="$TMP/r5"; make_repo "$R5"; mkdir -p "$R5/tests"; printf 'test "$(bash app.sh)" = good && echo "1 passed"\n' > "$R5/tests/t.sh"
|
|
92
103
|
git -C "$R5" add -A; git -C "$R5" commit -qm "bad test"; git -C "$R5" update-ref refs/remotes/origin/main HEAD
|