agent-dealer 1.4.3 → 1.4.5
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/bundle/server/dist/adapters/muse-capability.js +81 -8
- package/bundle/server/dist/adapters/muse-capability.test.js +89 -1
- package/bundle/server/dist/coordinator/args.js +7 -9
- package/bundle/server/dist/coordinator/args.test.js +5 -2
- package/bundle/server/dist/coordinator/commands.js +2 -1
- package/bundle/server/dist/coordinator/muse-spawn.js +1 -0
- package/bundle/server/dist/coordinator/reviewer-browser-probe.js +2 -3
- package/bundle/server/dist/coordinator/spawn.js +25 -5
- package/bundle/server/dist/coordinator/spawn.test.js +84 -0
- package/bundle/server/dist/runners/muse-config-core.js +33 -9
- package/bundle/server/dist/runners/muse-config.test.js +13 -8
- package/bundle/server/dist/runners/spawn-cli.js +12 -4
- package/bundle/server/dist/runners/spawn-cli.test.js +19 -0
- package/bundle/server/package.json +2 -2
- package/bundle/server/static-ui/assets/index-2IuALSbV.js +64 -0
- package/bundle/server/static-ui/assets/index-MgimDoh2.css +1 -0
- package/bundle/server/static-ui/index.html +2 -2
- package/bundle/shared/package.json +1 -1
- package/dist/bin.js +0 -0
- package/package.json +2 -3
- package/bundle/server/dist/adapters/authority-lifecycle.js +0 -289
- package/bundle/server/dist/adapters/execution-authority.js +0 -103
- package/bundle/server/dist/adapters/execution-authority.test.js +0 -166
- package/bundle/server/dist/adapters/external.js +0 -20
- package/bundle/server/dist/coordinator/authority-recovery.integration.test.js +0 -661
- package/bundle/server/dist/coordinator/dispatcher.js +0 -58
- package/bundle/server/dist/coordinator/dispatcher.test.js +0 -81
- package/bundle/server/dist/coordinator/intent-forecast.js +0 -13
- package/bundle/server/dist/coordinator/intent-forecast.test.js +0 -34
- package/bundle/server/dist/coordinator/session-lifecycle.integration.test.js +0 -127
- package/bundle/server/dist/coordinator/session-lifecycle.js +0 -280
- package/bundle/server/dist/coordinator/session-lifecycle.test.js +0 -121
- package/bundle/server/dist/db/authority-attempts-stale-at-migration.test.js +0 -65
- package/bundle/server/dist/intake/agent-routing.js +0 -32
- package/bundle/server/dist/queue/answers.test.js +0 -117
- package/bundle/server/dist/queue/dispatcher-recovery.test.js +0 -37
- package/bundle/server/dist/queue/dispatcher.js +0 -597
- package/bundle/server/dist/queue/plan-delegation.js +0 -27
- package/bundle/server/dist/queue/plan-delegation.test.js +0 -61
- package/bundle/server/dist/queue/plan-gate.test.js +0 -55
- package/bundle/server/dist/queue/result-qa.js +0 -66
- package/bundle/server/dist/queue/result-qa.test.js +0 -146
- package/bundle/server/dist/repository/authority-attempts.js +0 -189
- package/bundle/server/dist/repository/result-qa.js +0 -37
- package/bundle/server/dist/runners/codex-args.js +0 -59
- package/bundle/server/dist/runners/codex-args.test.js +0 -72
- package/bundle/server/dist/runners/codex-resume.test.js +0 -19
- package/bundle/server/dist/runners/codex.js +0 -46
- package/bundle/server/dist/runners/muse-code-settings.js +0 -23
- package/bundle/server/dist/runners/muse-code-settings.test.js +0 -18
- package/bundle/server/dist/runners/persist.js +0 -142
- package/bundle/server/dist/runners/qa.js +0 -54
- package/bundle/server/dist/runners/run-context.js +0 -183
- package/bundle/server/dist/runners/stream-json.test.js +0 -95
- package/bundle/server/dist/trace-summary.js +0 -93
- package/bundle/server/dist/usage-summary.js +0 -61
- package/bundle/server/dist/usage-summary.test.js +0 -33
- package/bundle/server/static-ui/assets/index-CHCiztRI.css +0 -1
- package/bundle/server/static-ui/assets/index-CrLQFFpw.js +0 -64
- package/bundle/server/static-ui/fonts/Monaco.ttf +0 -0
- package/bundle/shared/dist/cursor-auth-health.d.ts +0 -12
- package/bundle/shared/dist/cursor-auth-health.js +0 -36
- package/bundle/shared/dist/cursor-auth-health.test.d.ts +0 -1
- package/bundle/shared/dist/cursor-auth-health.test.js +0 -40
- package/bundle/shared/dist/plan-triage.d.ts +0 -317
- package/bundle/shared/dist/plan-triage.js +0 -65
- package/bundle/shared/dist/plan-triage.test.d.ts +0 -1
- package/bundle/shared/dist/plan-triage.test.js +0 -66
- package/bundle/shared/dist/result-qa.d.ts +0 -45
- package/bundle/shared/dist/result-qa.js +0 -25
- package/bundle/shared/dist/result-qa.test.d.ts +0 -1
- package/bundle/shared/dist/result-qa.test.js +0 -60
|
@@ -67,7 +67,7 @@ function normalizeChecked(raw, currentVersion) {
|
|
|
67
67
|
const c = raw;
|
|
68
68
|
if (typeof c.version !== "string" || c.version !== currentVersion)
|
|
69
69
|
return null;
|
|
70
|
-
if (c.status !== "capable" && c.status !== "missing" && c.status !== "error")
|
|
70
|
+
if (c.status !== "capable" && c.status !== "missing" && c.status !== "host-sandbox" && c.status !== "error")
|
|
71
71
|
return null;
|
|
72
72
|
if (typeof c.checkedAt !== "number")
|
|
73
73
|
return null;
|
|
@@ -170,6 +170,20 @@ function formatDuration(ms) {
|
|
|
170
170
|
function issueFor(checked, from, exhausted = false) {
|
|
171
171
|
if (checked.status === "capable")
|
|
172
172
|
return [];
|
|
173
|
+
// NOT-641: the host cannot start Muse's sandbox (e.g. AppArmor blocking unprivileged
|
|
174
|
+
// user namespaces) — a host problem, never a version regression. Names the sandbox
|
|
175
|
+
// error and the host fix; deliberately not the "update removed access" text.
|
|
176
|
+
if (checked.status === "host-sandbox") {
|
|
177
|
+
return [
|
|
178
|
+
{
|
|
179
|
+
code: "runtime_capability",
|
|
180
|
+
message: `Muse's shell sandbox failed to start on this host (${checked.detail}) — ` +
|
|
181
|
+
`developer admission blocked until the host allows Muse's sandbox ` +
|
|
182
|
+
`(e.g. an AppArmor profile permitting unprivileged user namespaces). ` +
|
|
183
|
+
`This is a host problem, not a Muse Code version regression (probed ${checked.version}).`,
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
}
|
|
173
187
|
const head = transition(from, checked.version);
|
|
174
188
|
if (checked.status === "missing") {
|
|
175
189
|
return [
|
|
@@ -269,7 +283,7 @@ function startCheck(version) {
|
|
|
269
283
|
console.log(`[muse-capability] ${transition(from, version)}: developer ${CAPABILITY} confirmed`);
|
|
270
284
|
dropMissWatchersExcept(null);
|
|
271
285
|
}
|
|
272
|
-
else if (result.status === "missing") {
|
|
286
|
+
else if (result.status === "missing" || result.status === "host-sandbox") {
|
|
273
287
|
console.warn(`[muse-capability] ${issueFor(checked, from)[0].message}`);
|
|
274
288
|
escalateWatchedVersion(version);
|
|
275
289
|
}
|
|
@@ -331,7 +345,9 @@ export function museCapabilityIssues(version, onSettled = () => { }) {
|
|
|
331
345
|
return s.confirmedVersion ? [] : verifyingIssue(version, from);
|
|
332
346
|
if (checked.status === "capable")
|
|
333
347
|
return [];
|
|
334
|
-
|
|
348
|
+
// NOT-641: a host sandbox failure blocks like a confirmed loss (the host cannot run
|
|
349
|
+
// shell sessions on any version), with the host message — never the version text.
|
|
350
|
+
if (checked.status === "missing" || checked.status === "host-sandbox") {
|
|
335
351
|
return s.overriddenVersions.includes(checked.version) ? [] : issueFor(checked, from);
|
|
336
352
|
}
|
|
337
353
|
// Inconclusive: never a block while any baseline exists to work on. With none, the
|
|
@@ -362,13 +378,13 @@ function actionKindOf(action, fallback) {
|
|
|
362
378
|
const evidence = action.evidenceJson
|
|
363
379
|
? JSON.parse(action.evidenceJson)
|
|
364
380
|
: null;
|
|
365
|
-
if (evidence?.kind === "missing" || evidence?.kind === "unverified")
|
|
381
|
+
if (evidence?.kind === "missing" || evidence?.kind === "unverified" || evidence?.kind === "host-sandbox")
|
|
366
382
|
return evidence.kind;
|
|
367
383
|
}
|
|
368
384
|
catch {
|
|
369
385
|
// Fall through to the request_id prefix below.
|
|
370
386
|
}
|
|
371
|
-
const prefixed = /^muse-capability:(missing|unverified):/.exec(action.requestId ?? "");
|
|
387
|
+
const prefixed = /^muse-capability:(missing|unverified|host-sandbox):/.exec(action.requestId ?? "");
|
|
372
388
|
if (prefixed)
|
|
373
389
|
return prefixed[1];
|
|
374
390
|
return fallback;
|
|
@@ -405,6 +421,21 @@ function escalationFor(checked, s) {
|
|
|
405
421
|
`on ${checked.version} anyway${rollback}`,
|
|
406
422
|
};
|
|
407
423
|
}
|
|
424
|
+
// NOT-641: host sandbox start failure — names the host cause and the host fix, never
|
|
425
|
+
// the version-regression text. Acknowledging records an override like `missing` (the
|
|
426
|
+
// operator fixed the host and wants this version admitted).
|
|
427
|
+
if (checked.status === "host-sandbox" && !s.overriddenVersions.includes(checked.version)) {
|
|
428
|
+
return {
|
|
429
|
+
kind: "host-sandbox",
|
|
430
|
+
reason: `Muse's shell sandbox failed to start on this host (${checked.detail}). Last probe ran ` +
|
|
431
|
+
`${formatDuration(checked.durationMs)} (probe timeout ${formatDuration(PROBE_TIMEOUT_MS)}). ` +
|
|
432
|
+
`Developer admission is blocked for ${checked.version}; last confirmed baseline is ${baseline}. ` +
|
|
433
|
+
`This is a host problem, not a Muse Code version regression — no pin/roll back will fix it.`,
|
|
434
|
+
question: `Muse's sandbox cannot start on this host (${checked.detail}). Allow Muse's sandbox on the ` +
|
|
435
|
+
`host (e.g. an AppArmor profile permitting unprivileged user namespaces), then acknowledge ` +
|
|
436
|
+
`to admit developers on ${checked.version} anyway?`,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
408
439
|
if (isExhausted(checked) && checked.status === "error") {
|
|
409
440
|
const detail = checked.detail;
|
|
410
441
|
// With a baseline, admission proceeds on it and probing stops; with none (fresh
|
|
@@ -476,7 +507,7 @@ export function ensureMuseCapabilityEscalation(issueId) {
|
|
|
476
507
|
// parseable choice) falls through and re-raises a fresh action below.
|
|
477
508
|
const acknowledged = sameKind.some((a) => a.status === "resolved" && resolutionChoiceOf(a) === "acknowledge");
|
|
478
509
|
if (acknowledged) {
|
|
479
|
-
if (escalation.kind === "missing")
|
|
510
|
+
if (escalation.kind === "missing" || escalation.kind === "host-sandbox")
|
|
480
511
|
recordMuseCapabilityOverride(checked.version);
|
|
481
512
|
return null;
|
|
482
513
|
}
|
|
@@ -493,7 +524,7 @@ export function ensureMuseCapabilityEscalation(issueId) {
|
|
|
493
524
|
durationMs: checked.durationMs,
|
|
494
525
|
capability: CAPABILITY,
|
|
495
526
|
},
|
|
496
|
-
responseOptions: [{ choice: "acknowledge", label: `Acknowledge — ${escalation.kind === "
|
|
527
|
+
responseOptions: [{ choice: "acknowledge", label: `Acknowledge — ${escalation.kind === "unverified" ? "keep working on baseline" : `admit on ${checked.version}`}` }],
|
|
497
528
|
requestId,
|
|
498
529
|
});
|
|
499
530
|
}
|
|
@@ -572,6 +603,27 @@ export function countMuseShellToolCalls(logPath) {
|
|
|
572
603
|
}
|
|
573
604
|
return parsed === 0 ? null : shells;
|
|
574
605
|
}
|
|
606
|
+
/**
|
|
607
|
+
* NOT-641: extract a host sandbox start failure from probe session log text (the
|
|
608
|
+
* normalized `probe.ndjson` plus the raw stdout envelopes, whichever holds it).
|
|
609
|
+
* Matches bubblewrap/`bwrap` start errors (e.g. AppArmor's unprivileged user-namespace
|
|
610
|
+
* restriction: `bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted`).
|
|
611
|
+
*
|
|
612
|
+
* The log may be JSON envelopes (raw stdout, tool output double-encoded) or plain
|
|
613
|
+
* text (stderr trailer), so the error itself is matched — stopping at JSON escapes,
|
|
614
|
+
* quotes, or newlines — rather than whole lines. Returns the error text, or null.
|
|
615
|
+
*
|
|
616
|
+
* Deliberately narrow: a bare `Operation not permitted` is a normal sandbox denial
|
|
617
|
+
* (e.g. writing outside the workspace) and never counts — only sandbox-startup
|
|
618
|
+
* signatures (`bwrap:`, `bubblewrap`, `RTM_NEWADDR`) do.
|
|
619
|
+
*/
|
|
620
|
+
export function extractHostSandboxError(logText) {
|
|
621
|
+
const m = /bwrap:[^\n\\"]{0,300}|bubblewrap[^\n\\"]{0,300}|Failed RTM_NEWADDR[^\n\\"]{0,200}/i.exec(logText);
|
|
622
|
+
if (!m)
|
|
623
|
+
return null;
|
|
624
|
+
const line = m[0].trim();
|
|
625
|
+
return line === "" ? null : line;
|
|
626
|
+
}
|
|
575
627
|
/**
|
|
576
628
|
* NOT-308 safety net: a developer session ending with a dirty worktree but zero shell
|
|
577
629
|
* tool calls is exactly what a shell-less build looks like from the outside, so when
|
|
@@ -594,7 +646,7 @@ export function museCapabilitySafetyNetAfterSession(input) {
|
|
|
594
646
|
if (s.confirmedVersion === version)
|
|
595
647
|
return "skipped";
|
|
596
648
|
const checked = s.lastChecked;
|
|
597
|
-
if (checked && checked.version === version && checked.status === "missing") {
|
|
649
|
+
if (checked && checked.version === version && (checked.status === "missing" || checked.status === "host-sandbox")) {
|
|
598
650
|
ensureMuseCapabilityEscalation(input.issueId);
|
|
599
651
|
return "escalated";
|
|
600
652
|
}
|
|
@@ -749,6 +801,27 @@ export async function defaultMuseCapabilityProbe(version, opts = {}) {
|
|
|
749
801
|
catch {
|
|
750
802
|
written = null;
|
|
751
803
|
}
|
|
804
|
+
// NOT-641: when the shell did not produce its output, a sandbox start failure in
|
|
805
|
+
// the session logs (bwrap/AppArmor userns) is a host problem, not a version
|
|
806
|
+
// regression — report it as such whatever the exit/failure said. A bare
|
|
807
|
+
// `Operation not permitted` without sandbox-startup context is a normal denial
|
|
808
|
+
// and never takes this path (see extractHostSandboxError).
|
|
809
|
+
if (written !== gitBlobSha1(nonce)) {
|
|
810
|
+
const logTexts = [];
|
|
811
|
+
for (const logFile of [run.logPath, run.muse?.rawLogPath]) {
|
|
812
|
+
if (!logFile)
|
|
813
|
+
continue;
|
|
814
|
+
try {
|
|
815
|
+
logTexts.push(fs.readFileSync(logFile, "utf8"));
|
|
816
|
+
}
|
|
817
|
+
catch {
|
|
818
|
+
// An unreadable log is not a sandbox failure — ignore it.
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
const sandboxError = logTexts.length > 0 ? extractHostSandboxError(logTexts.join("\n")) : null;
|
|
822
|
+
if (sandboxError)
|
|
823
|
+
return { status: "host-sandbox", detail: sandboxError };
|
|
824
|
+
}
|
|
752
825
|
// A session that did not complete cleanly is never a verdict, even if the shell ran first.
|
|
753
826
|
if (run.timedOut)
|
|
754
827
|
return { status: "error", detail: `probe session on ${version} timed out` };
|
|
@@ -24,7 +24,7 @@ after(() => {
|
|
|
24
24
|
// best-effort — a failed rm must not fail the suite
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
const { museCapabilityIssues, museCapabilityCheckInFlight, parseMuseVersion, settleMuseCapabilityCheckForTests, setMuseCapabilityProbeForTests, resetMuseCapabilityStateForTests, ageMuseCapabilityCheckForTests, ensureMuseCapabilityEscalation, recordMuseCapabilityOverride, museCapabilitySafetyNetAfterSession, countMuseShellToolCalls, museCapabilityRequestId, defaultMuseCapabilityProbe, } = await import("./muse-capability.js");
|
|
27
|
+
const { museCapabilityIssues, museCapabilityCheckInFlight, parseMuseVersion, settleMuseCapabilityCheckForTests, setMuseCapabilityProbeForTests, resetMuseCapabilityStateForTests, ageMuseCapabilityCheckForTests, ensureMuseCapabilityEscalation, recordMuseCapabilityOverride, museCapabilitySafetyNetAfterSession, countMuseShellToolCalls, extractHostSandboxError, museCapabilityRequestId, defaultMuseCapabilityProbe, } = await import("./muse-capability.js");
|
|
28
28
|
const { migrate, getDb } = await import("../db/index.js");
|
|
29
29
|
const { listHumanActionsByRequestId, resolveHumanAction } = await import("../repository/human-actions.js");
|
|
30
30
|
migrate();
|
|
@@ -188,6 +188,28 @@ describe("muse-capability", { concurrency: false }, () => {
|
|
|
188
188
|
assert.equal(calls.get(NEW), 1);
|
|
189
189
|
assert.equal(JSON.parse(fs.readFileSync(STATE, "utf8")).confirmedVersion, OLD);
|
|
190
190
|
});
|
|
191
|
+
// NOT-641: a host sandbox start failure blocks with the host cause and fix — never
|
|
192
|
+
// the version-regression text ("no longer get shell/write access").
|
|
193
|
+
test("a host sandbox failure blocks with the sandbox error and fix, not a version regression", async () => {
|
|
194
|
+
const calls = stubProbe({
|
|
195
|
+
[OLD]: { status: "capable" },
|
|
196
|
+
[NEW]: { status: "host-sandbox", detail: "bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted" },
|
|
197
|
+
});
|
|
198
|
+
await check(OLD);
|
|
199
|
+
const { settled } = await check(NEW);
|
|
200
|
+
assert.deepEqual(settled.map((i) => i.code), ["runtime_capability"]);
|
|
201
|
+
assert.match(settled[0].message, /Muse's shell sandbox failed to start on this host/);
|
|
202
|
+
assert.match(settled[0].message, /bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted/);
|
|
203
|
+
assert.match(settled[0].message, /AppArmor profile permitting unprivileged user namespaces/);
|
|
204
|
+
assert.match(settled[0].message, /host problem, not a Muse Code version regression/);
|
|
205
|
+
assert.match(settled[0].message, /developer admission blocked/);
|
|
206
|
+
assert.doesNotMatch(settled[0].message, /no longer get shell\/write access/);
|
|
207
|
+
assert.doesNotMatch(settled[0].message, /Muse Code updated/);
|
|
208
|
+
// Stays blocked on this version without re-probing; the baseline is still the old version.
|
|
209
|
+
assert.deepEqual(museCapabilityIssues(NEW), settled);
|
|
210
|
+
assert.equal(calls.get(NEW), 1);
|
|
211
|
+
assert.equal(JSON.parse(fs.readFileSync(STATE, "utf8")).confirmedVersion, OLD);
|
|
212
|
+
});
|
|
191
213
|
test("a later update that restores the capability unblocks by itself", async () => {
|
|
192
214
|
const FIXED = "1.4.0-R4302.1";
|
|
193
215
|
stubProbe({
|
|
@@ -368,6 +390,44 @@ describe("muse-capability", { concurrency: false }, () => {
|
|
|
368
390
|
assert.deepEqual(museCapabilityIssues(NEW), [], "acknowledge lifts the block");
|
|
369
391
|
assert.equal(ensureMuseCapabilityEscalation(issueId), null, "no re-raise after acknowledge");
|
|
370
392
|
});
|
|
393
|
+
// NOT-641: a host sandbox failure escalates with the host cause and fix — never the
|
|
394
|
+
// version-regression text — and acknowledge lifts the block (the operator fixed the host).
|
|
395
|
+
test("a host-sandbox version escalates with the host fix; acknowledge lifts the block", async () => {
|
|
396
|
+
const calls = stubProbe({
|
|
397
|
+
[OLD]: { status: "capable" },
|
|
398
|
+
[NEW]: { status: "host-sandbox", detail: "bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted" },
|
|
399
|
+
});
|
|
400
|
+
await check(OLD);
|
|
401
|
+
await check(NEW);
|
|
402
|
+
const issueId = makeIssue();
|
|
403
|
+
const action = ensureMuseCapabilityEscalation(issueId);
|
|
404
|
+
assert.ok(action, "a host-sandbox verdict raises an action");
|
|
405
|
+
assert.equal(action.actionType, "muse_capability");
|
|
406
|
+
assert.equal(action.requestId, museCapabilityRequestId(NEW, "host-sandbox"));
|
|
407
|
+
assert.match(action.reason, /Muse's shell sandbox failed to start on this host/);
|
|
408
|
+
assert.match(action.reason, /bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted/);
|
|
409
|
+
assert.match(action.reason, /host problem, not a Muse Code version regression/);
|
|
410
|
+
assert.match(action.reason, new RegExp(`admission is blocked for ${NEW}`));
|
|
411
|
+
assert.doesNotMatch(action.reason, /no longer get shell\/write access/);
|
|
412
|
+
assert.doesNotMatch(action.reason, /Muse Code updated/);
|
|
413
|
+
assert.match(action.question, /Allow Muse's sandbox on the host/);
|
|
414
|
+
assert.match(action.question, /AppArmor profile permitting unprivileged user namespaces/);
|
|
415
|
+
assert.doesNotMatch(action.question, /lost developer/);
|
|
416
|
+
assert.doesNotMatch(action.question, /pin\/roll back/);
|
|
417
|
+
assert.deepEqual(JSON.parse(action.responseOptionsJson), [
|
|
418
|
+
{ choice: "acknowledge", label: `Acknowledge — admit on ${NEW}` },
|
|
419
|
+
]);
|
|
420
|
+
const evidence = JSON.parse(action.evidenceJson);
|
|
421
|
+
assert.equal(evidence.kind, "host-sandbox");
|
|
422
|
+
assert.equal(evidence.version, NEW);
|
|
423
|
+
// Deduped per version, not per poll.
|
|
424
|
+
assert.equal(ensureMuseCapabilityEscalation(issueId)?.id, action.id);
|
|
425
|
+
assert.equal(calls.get(NEW), 1, "a host-sandbox verdict is conclusive: never re-probed");
|
|
426
|
+
assert.deepEqual(museCapabilityIssues(NEW).map((i) => i.code), ["runtime_capability"]);
|
|
427
|
+
recordMuseCapabilityOverride(NEW);
|
|
428
|
+
assert.deepEqual(museCapabilityIssues(NEW), [], "acknowledge lifts the block");
|
|
429
|
+
assert.equal(ensureMuseCapabilityEscalation(issueId), null, "no re-raise after acknowledge");
|
|
430
|
+
});
|
|
371
431
|
// NOT-308 repair round 3: aborting or closing the issue that holds a `missing`
|
|
372
432
|
// escalation resolves its open action with a lifecycle reason (never a choice) —
|
|
373
433
|
// that is not the operator's capability decision, so the next poll must re-raise
|
|
@@ -529,6 +589,27 @@ describe("muse-capability", { concurrency: false }, () => {
|
|
|
529
589
|
assert.equal(countMuseShellToolCalls(writeLog(["not json", ""])), null);
|
|
530
590
|
assert.equal(countMuseShellToolCalls(path.join(os.tmpdir(), `dealer-muse-nope-${randomUUID()}`)), null);
|
|
531
591
|
});
|
|
592
|
+
// NOT-641: sandbox start failures are extracted from plain text (stderr trailer) and
|
|
593
|
+
// JSON-encoded tool output (raw stdout envelopes); a bare EPERM denial never matches.
|
|
594
|
+
test("extractHostSandboxError finds bwrap failures in plain and JSON-encoded logs", () => {
|
|
595
|
+
const BWRAP = "bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted";
|
|
596
|
+
assert.equal(extractHostSandboxError(`${BWRAP}\n`), BWRAP);
|
|
597
|
+
assert.equal(extractHostSandboxError(`prefix ${BWRAP} suffix`), `${BWRAP} suffix`);
|
|
598
|
+
// Raw stdout envelope with double-encoded tool output, as the probe's raw log holds it.
|
|
599
|
+
const envelope = JSON.stringify({
|
|
600
|
+
payload_type: "tool.result",
|
|
601
|
+
payload: {
|
|
602
|
+
call_id: "call-1",
|
|
603
|
+
text: JSON.stringify({ output: `${BWRAP}\n` }),
|
|
604
|
+
correlation_facts: { tool_name: "bash", outcome: "failure" },
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
assert.equal(extractHostSandboxError(envelope), BWRAP);
|
|
608
|
+
// Bare EPERM denials (normal sandbox policy) are not start failures.
|
|
609
|
+
assert.equal(extractHostSandboxError("/bin/sh: /outside.txt: Operation not permitted\n"), null);
|
|
610
|
+
assert.equal(extractHostSandboxError("all good, shell ran\n"), null);
|
|
611
|
+
assert.equal(extractHostSandboxError(""), null);
|
|
612
|
+
});
|
|
532
613
|
// NOT-308 safety net: a dirty, shell-less session ending on an unconfirmed version
|
|
533
614
|
// probes immediately (no backoff wait) and a `missing` verdict escalates on the issue.
|
|
534
615
|
test("safety net: dirty + zero-shell on an unconfirmed version probes immediately, missing escalates", async () => {
|
|
@@ -762,6 +843,13 @@ describe("defaultMuseCapabilityProbe (fake muse)", { concurrency: false }, () =>
|
|
|
762
843
|
const result = await probeWith("capability-no-shell");
|
|
763
844
|
assert.equal(result.status, "missing");
|
|
764
845
|
});
|
|
846
|
+
// NOT-641: the session completes cleanly but its tool output holds a bwrap sandbox
|
|
847
|
+
// start failure — a host problem with that error text, never `missing` for the version.
|
|
848
|
+
test("a session whose sandbox fails to start is host-sandbox with the bwrap line", async () => {
|
|
849
|
+
const result = await probeWith("capability-sandbox-failure");
|
|
850
|
+
assert.equal(result.status, "host-sandbox");
|
|
851
|
+
assert.match(result.detail, /bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted/);
|
|
852
|
+
});
|
|
765
853
|
test("a session that fails to run at all is an error (could not verify), not missing", async () => {
|
|
766
854
|
const result = await probeWith("auth");
|
|
767
855
|
assert.equal(result.status, "error");
|
|
@@ -31,7 +31,7 @@ function claudeDisallowedTools(policy) {
|
|
|
31
31
|
// enforceable capabilities here on purpose.
|
|
32
32
|
return policy.outboundMutation ? [] : [DENY_SEND_TOOL];
|
|
33
33
|
}
|
|
34
|
-
function buildArgs(runtime, policy,
|
|
34
|
+
function buildArgs(runtime, policy, model, mcpConfigPath, effort) {
|
|
35
35
|
if (runtime === "muse_code") {
|
|
36
36
|
// Muse's developer argv is built by runners/muse-config.ts (`prepareMuseAttempt`,
|
|
37
37
|
// NOT-278) inside coordinator/muse-spawn.ts; it needs a per-attempt deck, session id, and
|
|
@@ -61,7 +61,7 @@ function buildArgs(runtime, policy, prompt, model, mcpConfigPath, effort) {
|
|
|
61
61
|
// exec session banner. Cursor has no equivalent separate flag.
|
|
62
62
|
if (effort)
|
|
63
63
|
args.push("-c", `model_reasoning_effort=${effort}`);
|
|
64
|
-
args.push(
|
|
64
|
+
args.push("-");
|
|
65
65
|
return args;
|
|
66
66
|
}
|
|
67
67
|
if (runtime === "cursor_local") {
|
|
@@ -85,7 +85,6 @@ function buildArgs(runtime, policy, prompt, model, mcpConfigPath, effort) {
|
|
|
85
85
|
"--stream-partial-output",
|
|
86
86
|
...(policy.worktreeWrite ? [] : ["--mode", "ask"]),
|
|
87
87
|
...(model ? ["--model", model] : []),
|
|
88
|
-
prompt,
|
|
89
88
|
];
|
|
90
89
|
}
|
|
91
90
|
const { builtins, allowed } = claudeToolSets(policy);
|
|
@@ -95,7 +94,6 @@ function buildArgs(runtime, policy, prompt, model, mcpConfigPath, effort) {
|
|
|
95
94
|
...(model ? ["--model", model] : []),
|
|
96
95
|
...(effort ? ["--effort", effort] : []),
|
|
97
96
|
"-p",
|
|
98
|
-
prompt,
|
|
99
97
|
"--output-format",
|
|
100
98
|
"stream-json",
|
|
101
99
|
"--verbose",
|
|
@@ -125,11 +123,11 @@ function buildArgs(runtime, policy, prompt, model, mcpConfigPath, effort) {
|
|
|
125
123
|
return args;
|
|
126
124
|
}
|
|
127
125
|
export function buildWorkerArgs(opts) {
|
|
128
|
-
return buildArgs(opts.runtime, opts.policy ?? roleCeiling(opts.role), opts.
|
|
126
|
+
return buildArgs(opts.runtime, opts.policy ?? roleCeiling(opts.role), opts.model, opts.mcpConfigPath, opts.effort);
|
|
129
127
|
}
|
|
130
|
-
export function buildDeveloperArgs(runtime,
|
|
131
|
-
return buildArgs(runtime, policy ?? roleCeiling("developer"),
|
|
128
|
+
export function buildDeveloperArgs(runtime, _prompt, model, policy, mcpConfigPath, effort) {
|
|
129
|
+
return buildArgs(runtime, policy ?? roleCeiling("developer"), model, mcpConfigPath, effort);
|
|
132
130
|
}
|
|
133
|
-
export function buildReviewerArgs(runtime,
|
|
134
|
-
return buildArgs(runtime, policy ?? roleCeiling("reviewer"),
|
|
131
|
+
export function buildReviewerArgs(runtime, _prompt, model, policy, mcpConfigPath, effort) {
|
|
132
|
+
return buildArgs(runtime, policy ?? roleCeiling("reviewer"), model, mcpConfigPath, effort);
|
|
135
133
|
}
|
|
@@ -4,7 +4,6 @@ import { buildDeveloperArgs, buildReviewerArgs } from "./args.js";
|
|
|
4
4
|
test("buildDeveloperArgs for claude_code allows Bash and Write/Edit", () => {
|
|
5
5
|
const args = buildDeveloperArgs("claude_code", "do the task");
|
|
6
6
|
assert.ok(args.includes("-p"));
|
|
7
|
-
assert.ok(args.includes("do the task"));
|
|
8
7
|
const toolsIdx = args.indexOf("--allowedTools");
|
|
9
8
|
assert.ok(toolsIdx >= 0);
|
|
10
9
|
assert.ok(args[toolsIdx + 1].includes("Bash"));
|
|
@@ -26,6 +25,7 @@ test("buildDeveloperArgs passes model through when given", () => {
|
|
|
26
25
|
test("buildDeveloperArgs for codex_local uses exec subcommand shape", () => {
|
|
27
26
|
const args = buildDeveloperArgs("codex_local", "do the task");
|
|
28
27
|
assert.equal(args[0], "exec");
|
|
28
|
+
assert.equal(args.at(-1), "-");
|
|
29
29
|
assert.ok(args.includes("workspace-write"));
|
|
30
30
|
});
|
|
31
31
|
test("buildReviewerArgs for codex_local uses read-only sandbox", () => {
|
|
@@ -140,7 +140,10 @@ test("every runtime either builds developer args or is the not-yet-wired muse_co
|
|
|
140
140
|
assert.throws(() => buildReviewerArgs(runtime, "prompt"), /not wired/);
|
|
141
141
|
}
|
|
142
142
|
else {
|
|
143
|
-
|
|
143
|
+
const prompt = "sentinel worker prompt";
|
|
144
|
+
for (const buildArgs of [buildDeveloperArgs, buildReviewerArgs]) {
|
|
145
|
+
assert.ok(buildArgs(runtime, prompt).every((arg) => !arg.includes(prompt)), `${runtime} ${buildArgs.name}`);
|
|
146
|
+
}
|
|
144
147
|
}
|
|
145
148
|
}
|
|
146
149
|
});
|
|
@@ -1845,7 +1845,8 @@ export function resolveHumanActionAndAdvance(actionId, resolvedBy, choice, opts)
|
|
|
1845
1845
|
// File first, then the row: if the resolve below fails the action stays open and
|
|
1846
1846
|
// the operator retries idempotently; the reverse order could leave a resolved
|
|
1847
1847
|
// action whose version still blocks with no way to re-acknowledge.
|
|
1848
|
-
|
|
1848
|
+
// NOT-641: a host-sandbox acknowledge also lifts the block (the operator fixed the host).
|
|
1849
|
+
if ((evidence?.kind === "missing" || evidence?.kind === "host-sandbox") && typeof evidence.version === "string" && evidence.version) {
|
|
1849
1850
|
recordMuseCapabilityOverride(evidence.version);
|
|
1850
1851
|
}
|
|
1851
1852
|
// The lifted block must be visible on the next health read, not after the cache TTL.
|
|
@@ -202,9 +202,8 @@ export function resolveProbeBin(runtime) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
/**
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* production — the probe records it and `realReviewerSpawn` re-derives it.
|
|
205
|
+
* Reviewer argv from the same builder and role ceiling as production.
|
|
206
|
+
* Cursor's per-attempt prompt file is allocated later by realReviewerSpawn.
|
|
208
207
|
*/
|
|
209
208
|
export function resolveProbeArgv(opts) {
|
|
210
209
|
return buildReviewerArgs(opts.runtime, opts.prompt, opts.model, opts.policy ?? roleCeiling("reviewer"), opts.mcpConfigPath, opts.effort ?? null);
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
// `realDeveloperSpawn`/`realReviewerSpawn`, tests inject a fake so no paid CLI is ever
|
|
12
12
|
// spawned in CI (the confirmed NOT-61/62 scope call: fake the agent session, keep
|
|
13
13
|
// worktree/push/PR/review verification real).
|
|
14
|
+
import fs from "node:fs";
|
|
14
15
|
import path from "node:path";
|
|
15
|
-
import { getTemporalLogsDir } from "../paths.js";
|
|
16
|
+
import { getTemporalLogsDir, getWorkerMcpConfigDir } from "../paths.js";
|
|
16
17
|
import { resolveClaudeBin, resolveCodexBin, resolveCursorBin, resolveMuseBin } from "../cli-env.js";
|
|
17
18
|
import { spawnCli } from "../runners/spawn-cli.js";
|
|
18
19
|
import { buildDeveloperArgs, buildReviewerArgs } from "./args.js";
|
|
@@ -47,8 +48,7 @@ export const realDeveloperSpawn = async (input) => {
|
|
|
47
48
|
}
|
|
48
49
|
const args = buildDeveloperArgs(input.runtime, input.prompt, input.model ?? undefined, input.policy, input.mcpConfigPath, input.effort);
|
|
49
50
|
const logPath = input.logPath ?? developerSessionLogPath(input.sessionId);
|
|
50
|
-
|
|
51
|
-
return { exitCode, transcript: extractResultTranscript(logPath, input.runtime, transcript), logPath, timedOut };
|
|
51
|
+
return spawnWorker(input, args, logPath);
|
|
52
52
|
};
|
|
53
53
|
/**
|
|
54
54
|
* Asserts the read-only invariant on the generated args before every real reviewer spawn
|
|
@@ -62,6 +62,26 @@ export const realReviewerSpawn = async (input) => {
|
|
|
62
62
|
const args = buildReviewerArgs(input.runtime, input.prompt, input.model ?? undefined, input.policy, input.mcpConfigPath, input.effort);
|
|
63
63
|
assertReviewerReadOnly(args, { mcpConfigPath: input.mcpConfigPath, mcpEnv: input.mcpEnv });
|
|
64
64
|
const logPath = input.logPath ?? reviewerSessionLogPath(input.sessionId);
|
|
65
|
-
|
|
66
|
-
return { exitCode, transcript: extractResultTranscript(logPath, input.runtime, transcript), logPath, timedOut };
|
|
65
|
+
return spawnWorker(input, args, logPath);
|
|
67
66
|
};
|
|
67
|
+
async function spawnWorker(input, args, logPath) {
|
|
68
|
+
const { runtime, sessionId, cwd, prompt, timeoutMs, mcpEnv, signal, onSpawn } = input;
|
|
69
|
+
// Cursor's headless interface takes a positional instruction. Keep the full
|
|
70
|
+
// prompt in a private attempt directory outside the checkout and retained logs.
|
|
71
|
+
const attemptDir = runtime === "cursor_local"
|
|
72
|
+
? fs.mkdtempSync(path.resolve(getWorkerMcpConfigDir(), "cursor-prompt-"))
|
|
73
|
+
: undefined;
|
|
74
|
+
try {
|
|
75
|
+
if (attemptDir) {
|
|
76
|
+
const promptPath = path.join(attemptDir, "prompt.txt");
|
|
77
|
+
fs.writeFileSync(promptPath, prompt, { mode: 0o600, flag: "wx" });
|
|
78
|
+
args.push(`Read the complete task prompt from ${JSON.stringify(promptPath)} and follow its instructions.`);
|
|
79
|
+
}
|
|
80
|
+
const { exitCode, transcript, timedOut } = await spawnCli(sessionId, BIN_FOR[runtime](), args, cwd, { logPath, timeoutMs, env: mcpEnv, signal, onSpawn, runtime, stdin: attemptDir ? undefined : prompt });
|
|
81
|
+
return { exitCode, transcript: extractResultTranscript(logPath, runtime, transcript), logPath, timedOut };
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
if (attemptDir)
|
|
85
|
+
fs.rmSync(attemptDir, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { test } from "node:test";
|
|
7
|
+
import { roleCeiling } from "@agent-dealer/shared";
|
|
8
|
+
import { assertReviewerReadOnly } from "./permissions.js";
|
|
9
|
+
import { realDeveloperSpawn, realReviewerSpawn } from "./spawn.js";
|
|
10
|
+
const BIN_ENV = {
|
|
11
|
+
codex_local: "CODEX_CLI",
|
|
12
|
+
claude_code: "CLAUDE_CLI",
|
|
13
|
+
cursor_local: "CURSOR_CLI",
|
|
14
|
+
muse_code: "MUSE_CLI",
|
|
15
|
+
};
|
|
16
|
+
for (const runtime of Object.keys(BIN_ENV)) {
|
|
17
|
+
for (const role of runtime === "muse_code" ? ["developer"] : ["developer", "reviewer"]) {
|
|
18
|
+
test(`${runtime} ${role} launches with the full large prompt`, async (t) => {
|
|
19
|
+
// Muse refuses attempts under system temp directories.
|
|
20
|
+
const scratch = runtime === "muse_code" ? path.resolve(import.meta.dirname, "../../../..") : os.tmpdir();
|
|
21
|
+
const dir = fs.mkdtempSync(path.join(scratch, ".dealer-worker-spawn-"));
|
|
22
|
+
t.after(() => fs.rmSync(dir, { recursive: true, force: true }));
|
|
23
|
+
const sessionId = "00000000-0000-4000-8000-000000000635";
|
|
24
|
+
const cwd = path.join(dir, "worktrees", `${sessionId}-${role}`);
|
|
25
|
+
fs.mkdirSync(cwd, { recursive: true });
|
|
26
|
+
const bin = path.join(dir, "worker.cjs");
|
|
27
|
+
fs.writeFileSync(bin, `#!${process.execPath}
|
|
28
|
+
const fs = require("node:fs");
|
|
29
|
+
const argv = process.argv.slice(2);
|
|
30
|
+
const input = fs.readFileSync(0);
|
|
31
|
+
const muse = argv.includes("--prompt-file");
|
|
32
|
+
const pathMatch = argv.at(-1)?.match(/from (".*") and follow/);
|
|
33
|
+
const promptFile = muse ? argv[argv.indexOf("--prompt-file") + 1] : pathMatch && JSON.parse(pathMatch[1]);
|
|
34
|
+
const prompt = promptFile ? fs.readFileSync(promptFile) : input;
|
|
35
|
+
const mode = promptFile ? fs.statSync(promptFile).mode & 0o777 : null;
|
|
36
|
+
const digest = require("node:crypto").createHash("sha256").update(prompt).digest("hex");
|
|
37
|
+
const receipt = { argv, digest, bytes: prompt.length, promptFile, mode, inputBytes: input.length };
|
|
38
|
+
fs.writeFileSync("receipt.json", JSON.stringify(receipt));
|
|
39
|
+
`, { mode: 0o700 });
|
|
40
|
+
const env = {
|
|
41
|
+
[BIN_ENV[runtime]]: bin,
|
|
42
|
+
AGENT_DEALER_HOME: dir,
|
|
43
|
+
XDG_CONFIG_HOME: path.join(dir, "operator-config"),
|
|
44
|
+
META_API_KEY: "test-key",
|
|
45
|
+
};
|
|
46
|
+
for (const [key, value] of Object.entries(env)) {
|
|
47
|
+
const previous = process.env[key];
|
|
48
|
+
process.env[key] = value;
|
|
49
|
+
t.after(() => {
|
|
50
|
+
if (previous === undefined)
|
|
51
|
+
delete process.env[key];
|
|
52
|
+
else
|
|
53
|
+
process.env[key] = previous;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const prompt = "sentinel worker prompt\n" + "é".repeat(100 * 1024) + "\n";
|
|
57
|
+
const spawn = role === "reviewer" ? realReviewerSpawn : realDeveloperSpawn;
|
|
58
|
+
const result = await spawn({
|
|
59
|
+
runtime, cwd, sessionId, prompt, policy: roleCeiling(role), model: null,
|
|
60
|
+
logPath: path.join(dir, "worker.ndjson"), timeoutMs: 5000,
|
|
61
|
+
deckId: "test-deck", agentDeckUrl: "http://127.0.0.1:1111/mcp",
|
|
62
|
+
});
|
|
63
|
+
assert.equal(result.timedOut, false);
|
|
64
|
+
// The Muse stub records transport only. Muse's parser requires model events for a successful turn.
|
|
65
|
+
if (runtime !== "muse_code")
|
|
66
|
+
assert.equal(result.exitCode, 0);
|
|
67
|
+
const receipt = JSON.parse(fs.readFileSync(path.join(cwd, "receipt.json"), "utf8"));
|
|
68
|
+
assert.equal(receipt.bytes, Buffer.byteLength(prompt));
|
|
69
|
+
assert.equal(receipt.digest, createHash("sha256").update(prompt).digest("hex"));
|
|
70
|
+
assert.ok(receipt.argv.every((arg) => !arg.includes("sentinel worker prompt")));
|
|
71
|
+
if (role === "reviewer")
|
|
72
|
+
assertReviewerReadOnly(receipt.argv, {});
|
|
73
|
+
if (runtime === "codex_local")
|
|
74
|
+
assert.equal(receipt.argv.at(-1), "-");
|
|
75
|
+
if (runtime === "claude_code")
|
|
76
|
+
assert.equal(receipt.argv[receipt.argv.indexOf("-p") + 1], "--output-format");
|
|
77
|
+
if (runtime === "cursor_local" || runtime === "muse_code") {
|
|
78
|
+
assert.equal(receipt.mode, 0o600);
|
|
79
|
+
assert.equal(fs.existsSync(receipt.promptFile), false);
|
|
80
|
+
assert.equal(receipt.inputBytes, runtime === "muse_code" ? Buffer.byteLength("test-key\n") : 0);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -181,13 +181,16 @@ export function buildMuseArgv(input) {
|
|
|
181
181
|
];
|
|
182
182
|
if (input.role === "reviewer")
|
|
183
183
|
argv.push("--disable-write", "--disable-shell");
|
|
184
|
-
argv.push(input.
|
|
184
|
+
argv.push("--prompt-file", input.promptFile);
|
|
185
185
|
assertMuseArgv(argv, input.role);
|
|
186
186
|
return argv;
|
|
187
187
|
}
|
|
188
188
|
/** Refuses argv that widens trust/sandbox/orchestration or drops a required restriction. */
|
|
189
189
|
export function assertMuseArgv(argv, role) {
|
|
190
|
-
// The
|
|
190
|
+
// The last argument is the path consumed by --prompt-file.
|
|
191
|
+
if (argv.at(-2) !== "--prompt-file" || !path.isAbsolute(argv.at(-1) ?? "")) {
|
|
192
|
+
throw new MuseIsolationError("invalid_argv", "Muse argv must end with --prompt-file and an absolute path");
|
|
193
|
+
}
|
|
191
194
|
const flags = argv.slice(0, -1);
|
|
192
195
|
for (const arg of flags) {
|
|
193
196
|
const name = arg.split("=")[0];
|
|
@@ -422,13 +425,6 @@ function prepareWithEvidence(rawInput, evidence) {
|
|
|
422
425
|
const settings = deepFreeze(buildMuseSettings(agentDeck, input.role, evidence));
|
|
423
426
|
assertMuseSettings(settings, agentDeck, input.role, evidence);
|
|
424
427
|
const apiKey = input.credential.kind === "api-key" ? input.credential.apiKey : undefined;
|
|
425
|
-
const argv = buildMuseArgv({
|
|
426
|
-
role: input.role,
|
|
427
|
-
sessionId: input.sessionId,
|
|
428
|
-
maxModelSteps: input.maxModelSteps,
|
|
429
|
-
prompt: input.prompt,
|
|
430
|
-
apiKeyStdin: apiKey !== undefined,
|
|
431
|
-
});
|
|
432
428
|
const root = fs.mkdtempSync(path.join(baseDir, ATTEMPT_PREFIX));
|
|
433
429
|
// Terminal only once the dir is confirmed gone, so a failed rmSync can be retried.
|
|
434
430
|
let cleaned = false;
|
|
@@ -470,6 +466,21 @@ function prepareWithEvidence(rawInput, evidence) {
|
|
|
470
466
|
throw original;
|
|
471
467
|
};
|
|
472
468
|
const settingsPath = path.join(root, "config", "muse", "settings.json");
|
|
469
|
+
// stdin may carry the API key, so Muse loads the prompt through its native file option.
|
|
470
|
+
const promptFile = path.join(root, "prompt.txt");
|
|
471
|
+
let argv;
|
|
472
|
+
try {
|
|
473
|
+
argv = buildMuseArgv({
|
|
474
|
+
role: input.role,
|
|
475
|
+
sessionId: input.sessionId,
|
|
476
|
+
maxModelSteps: input.maxModelSteps,
|
|
477
|
+
promptFile,
|
|
478
|
+
apiKeyStdin: apiKey !== undefined,
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
catch (err) {
|
|
482
|
+
return abortConstruction(err);
|
|
483
|
+
}
|
|
473
484
|
const approved = deepFreeze({
|
|
474
485
|
cwd: worktree,
|
|
475
486
|
argv: [...argv],
|
|
@@ -509,6 +520,18 @@ function prepareWithEvidence(rawInput, evidence) {
|
|
|
509
520
|
throw err;
|
|
510
521
|
throw new MuseIsolationError("invalid_settings", "Muse settings.json is missing or unreadable");
|
|
511
522
|
}
|
|
523
|
+
let promptMatches = false;
|
|
524
|
+
try {
|
|
525
|
+
const stat = fs.lstatSync(promptFile);
|
|
526
|
+
promptMatches = stat.isFile() && (stat.mode & 0o777) === 0o600
|
|
527
|
+
&& fs.readFileSync(promptFile).equals(Buffer.from(input.prompt));
|
|
528
|
+
}
|
|
529
|
+
catch {
|
|
530
|
+
// A missing or unreadable prompt also violates the launch contract.
|
|
531
|
+
}
|
|
532
|
+
if (!promptMatches) {
|
|
533
|
+
throw new MuseIsolationError("invalid_argv", "Muse prompt file differs from the approved launch prompt");
|
|
534
|
+
}
|
|
512
535
|
assertMuseSettings(onDisk, agentDeck, input.role, evidence);
|
|
513
536
|
const entries = fs.readdirSync(path.dirname(settingsPath)).sort();
|
|
514
537
|
const allowed = credentialKind === "auth-file" ? ["auth.json", "settings.json"] : ["settings.json"];
|
|
@@ -522,6 +545,7 @@ function prepareWithEvidence(rawInput, evidence) {
|
|
|
522
545
|
writePrivate(path.join(root, SENTINEL), "");
|
|
523
546
|
fs.mkdirSync(path.dirname(settingsPath), { recursive: true, mode: 0o700 });
|
|
524
547
|
fs.mkdirSync(path.join(root, "data"), { recursive: true, mode: 0o700 });
|
|
548
|
+
writePrivate(promptFile, input.prompt);
|
|
525
549
|
writePrivate(settingsPath, `${JSON.stringify(settings, null, 2)}\n`);
|
|
526
550
|
if (input.credential.kind === "auth-file") {
|
|
527
551
|
fs.symlinkSync(input.credential.path, path.join(path.dirname(settingsPath), "auth.json"));
|