fix(agents): A3 excluded checkouts hidden, launch boundary rechecks unions, reload collisions and changed defines refuse (#1873)

- A checkout an earlier launch left for a project the instance may no longer
  work in is covered by an empty tmpfs inside the sandbox; the host copy stays.
- The launcher rechecks every prepared project against the reloaded document
  after preparation, and the bus's final admission takes the instance and
  checks the broker's current unions.
- A project define whose vars changed since boot refuses its copy until the
  next start.
- Instance-name collisions are recomputed at each reload from the frozen root
  claims and the current project defines; every claimant refuses.
This commit is contained in:
jason.woltje committed 2026-11-10 20:27:33 -06:00
1 parent 17a48217f6
commit 29f7c3af85
9 files changed
+252 -16

No files matched your search

+13 -4
View File
@@ -632,13 +632,15 @@ export function createLauncher({
const codeProjects = {};
// #1873 A3: an instance gets only the code projects it works in: a project agent its own one, and
// no instance a project that excludes it or whose union refuses. A project agent refuses when its
// own project isn't admitted.
// own project isn't admitted. A checkout an earlier launch left in the workspace for a project
// the instance may not work in now is hidden from the session, never deleted (sandbox.mjs).
const own = copyOf(b, instance)?.project ?? null;
const barred = [];
for (const [project, entry] of Object.entries(b.projects)) {
if (entry.kind === 'library') continue;
if (own !== null && project !== own) continue;
if (own !== null && project !== own) { barred.push(project); continue; }
const unavailable = projectRefusal(b, instance, project);
if (unavailable) { record({ event: "checkout-skipped", instance, project, reason: unavailable.code }); continue; }
if (unavailable) { barred.push(project); record({ event: "checkout-skipped", instance, project, reason: unavailable.code }); continue; }
let answer = null;
try { answer = await host.op({ op: 'request.admission', business: b.id, project }); } catch (e) { answer = { ready: false, code: e.code ?? 'admission-unavailable' }; }
if (answer?.ready !== true) { record({ event: "checkout-skipped", instance, project, reason: answer?.code ?? 'project-pending' }); continue; }
@@ -671,6 +673,12 @@ export function createLauncher({
let harness, route, routeReason, sessionProxy, resolver;
({resolved,model,account,harness,route,routeReason,sessionProxy,resolver}=await check(instance,{pm:instance===b.launch.by,thread,session,human,proxyContext:admittedProxy,proxyReady:true}));
admission(admissionGeneration);
// #1873 A3: check() read the organization again. A project that excluded or refused this
// instance while its checkouts were prepared refuses the launch; the next one leaves it out.
for (const project of Object.keys(codeProjects)) {
const unavailable = projectRefusal(b, instance, project);
if (unavailable) throw new Refusal(unavailable.code, unavailable.message);
}
const { run, runDir } = newRun(dataRoot, b.id);
let modelKeyId;
if (admittedProxy) {
@@ -766,6 +774,7 @@ export function createLauncher({
gitSocket: git,
threadStore: store,
readOnly,
hidden: barred.map((project) => join(workspace, project)).filter((p) => { try { return lstatSync(p).isDirectory(); } catch { return false; } }),
};
admission(admissionGeneration);
await threadAdmission(thread, session);
@@ -776,7 +785,7 @@ export function createLauncher({
}
// One synchronous broker snapshot covers the thread and the entire manifest after every
// asynchronous preparation read. Admission is the launch boundary; bindLaunch remains a fence.
const finalAdmission = await host.op({ op: "request.admission", business: b.id, projects: Object.keys(codeProjects), thread, session });
const finalAdmission = await host.op({ op: "request.admission", business: b.id, projects: Object.keys(codeProjects), instance, thread, session });
if (finalAdmission?.ready !== true) throw new Refusal(finalAdmission?.code ?? "project-pending");
const managed = registerRuntime(dataRoot, { kind: 'session', business: b.id, run });
let child;