agent-dealer 1.4.4 → 1.4.6
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/github.js +233 -3
- package/bundle/server/dist/adapters/github.test.js +177 -1
- 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/commands.js +2 -1
- package/bundle/server/dist/coordinator/developer-effect.js +11 -1
- package/bundle/server/dist/coordinator/developer-effect.test.js +26 -1
- package/bundle/server/dist/coordinator/failure-reason.js +3 -0
- package/bundle/server/dist/coordinator/merge-conflict-sync.js +5 -1
- package/bundle/server/dist/coordinator/routing.js +5 -0
- package/bundle/server/dist/coordinator/routing.test.js +32 -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
|
@@ -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");
|
|
@@ -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.
|
|
@@ -32,7 +32,7 @@ import { recordIssueBaseSha } from "../repository/issues.js";
|
|
|
32
32
|
import { ensureIssueRepoCheckout, roleWorktreePathForResolution, resolveCheckoutBaseBranch, } from "../adapters/managed-repo.js";
|
|
33
33
|
import { baseRefCandidates, inspectBranchProgress } from "./branch-progress.js";
|
|
34
34
|
import { prepareWorkerDeckConnection, releaseWorkerDeckConnection, verifyWorkerDeckConnection } from "../adapters/agent-deck-bind.js";
|
|
35
|
-
import { realGithubAdapter, pollPrChecksDetailed, } from "../adapters/github.js";
|
|
35
|
+
import { ChecksUnreadableError, realGithubAdapter, pollPrChecksDetailed, } from "../adapters/github.js";
|
|
36
36
|
import { checksWaitCeilingExceeded, checksWaitCeilingMs } from "./checks-wait-config.js";
|
|
37
37
|
import { museCapabilitySafetyNetAfterSession } from "../adapters/muse-capability.js";
|
|
38
38
|
import { getOrAssignSessionCorrelationId, getWorkerSession, mergeSessionMetadata, patchRunningSession, recordSessionProcess, setSessionInputSha } from "../repository/worker-sessions.js";
|
|
@@ -898,6 +898,12 @@ async function runPublishOnlyHandoff(ctx, deps, branchName) {
|
|
|
898
898
|
};
|
|
899
899
|
}
|
|
900
900
|
catch (err) {
|
|
901
|
+
// NOT-670: unreadable checks (token lacks Checks read and the fallback is
|
|
902
|
+
// denied too) is a permission problem, not infra — escalate once without
|
|
903
|
+
// spending an attempt instead of entering the adapter_failure retry loop.
|
|
904
|
+
if (err instanceof ChecksUnreadableError) {
|
|
905
|
+
return { kind: "checks_unreadable", reason: err.message };
|
|
906
|
+
}
|
|
901
907
|
return {
|
|
902
908
|
kind: "adapter_failure",
|
|
903
909
|
reason: String(err),
|
|
@@ -2161,6 +2167,10 @@ export async function runDeveloperEffect(ctx, deps = defaultDeps) {
|
|
|
2161
2167
|
console.error("[coordinator] developer session could not start", { issueId: issue.id, sessionId, round, err });
|
|
2162
2168
|
return { kind: "session_failed", reason };
|
|
2163
2169
|
}
|
|
2170
|
+
// NOT-670: same permission short-circuit as the publish-only path above.
|
|
2171
|
+
if (err instanceof ChecksUnreadableError) {
|
|
2172
|
+
return { kind: "checks_unreadable", reason: err.message };
|
|
2173
|
+
}
|
|
2164
2174
|
return { kind: "adapter_failure", reason: String(err) };
|
|
2165
2175
|
}
|
|
2166
2176
|
finally {
|
|
@@ -33,7 +33,7 @@ const { registerEffectHandler, resetEffectHandlers } = await import("./effect-re
|
|
|
33
33
|
const { runCoordinatorTick, drainCoordinator } = await import("./worker-loop.js");
|
|
34
34
|
const { runDeveloperEffect, extractPrDescription } = await import("./developer-effect.js");
|
|
35
35
|
const { realDeveloperSpawn } = await import("./spawn.js");
|
|
36
|
-
const { realGithubAdapter } = await import("../adapters/github.js");
|
|
36
|
+
const { realGithubAdapter, ChecksUnreadableError } = await import("../adapters/github.js");
|
|
37
37
|
const { branchExists, roleWorktreePath, withRepoLock, observeGitCommands } = await import("../adapters/git-worktree.js");
|
|
38
38
|
before(() => migrate());
|
|
39
39
|
// NOT-220's test runs reviewer effects, which record review_publications rows keyed
|
|
@@ -243,6 +243,31 @@ test("clean handoff: real worktree, real push, fake GitHub — issue moves to re
|
|
|
243
243
|
assert.ok(finished);
|
|
244
244
|
assert.equal(finished.actorType, "developer");
|
|
245
245
|
});
|
|
246
|
+
test("NOT-670: unreadable checks land in needs_human once with the permission message and no infra attempt spent", async () => {
|
|
247
|
+
const issueId = await makeIssue();
|
|
248
|
+
const github = fakeGithub();
|
|
249
|
+
github.checksSnapshot = async () => {
|
|
250
|
+
throw new ChecksUnreadableError("Cannot read PR checks for not-so-fat/agent-box: the GitHub token lacks Checks read, " +
|
|
251
|
+
"and the fallback also failed (Actions: read / Commit statuses: read). Grant actions:read " +
|
|
252
|
+
"and commit statuses:read to the fine-grained token, or use a token with Checks access.");
|
|
253
|
+
};
|
|
254
|
+
registerEffectHandler("developer", (ctx) => runDeveloperEffect(ctx, { deckCallTool: okDeckCallTool, spawn: commitingSpawn, github }));
|
|
255
|
+
startWorkflow(issueId);
|
|
256
|
+
await pump(1);
|
|
257
|
+
const issue = getIssue(issueId);
|
|
258
|
+
assert.equal(issue.status, "needs_human");
|
|
259
|
+
assert.equal(issue.infraAttempts, 0, "a permission problem never spends an infra attempt");
|
|
260
|
+
assert.equal(issue.currentRound, 1);
|
|
261
|
+
assert.equal(listWorkItemsForIssue(issueId).filter((i) => i.kind === "reviewer").length, 0);
|
|
262
|
+
assert.equal(listWorkItemsForIssue(issueId).filter((i) => i.kind === "developer" && i.status === "pending").length, 0, "no developer retry is queued");
|
|
263
|
+
const action = listHumanActionsForIssue(issueId).find((a) => a.actionType === "policy_escalation");
|
|
264
|
+
assert.ok(action, "expected a single policy_escalation human action");
|
|
265
|
+
assert.match(action.reason, /Cannot read PR checks for not-so-fat\/agent-box/);
|
|
266
|
+
assert.match(action.reason, /Actions: read/);
|
|
267
|
+
assert.match(action.reason, /Commit statuses: read/);
|
|
268
|
+
assert.match(action.reason, /Checks/);
|
|
269
|
+
assert.doesNotMatch(action.reason, /infra-attempt limit reached/);
|
|
270
|
+
});
|
|
246
271
|
test("no_pr: the agent makes no commits — retried, no reviewer work item", async () => {
|
|
247
272
|
const issueId = await makeIssue();
|
|
248
273
|
registerEffectHandler("developer", (ctx) => runDeveloperEffect(ctx, { deckCallTool: okDeckCallTool, spawn: noopSpawn, github: fakeGithub() }));
|
|
@@ -224,6 +224,8 @@ function fallbackReasonForKind(outcome) {
|
|
|
224
224
|
return "muse_cron_used: the Muse session called a cron_* tool, which Muse cannot disable.";
|
|
225
225
|
case "adapter_failure":
|
|
226
226
|
return "Git/GitHub verification failed.";
|
|
227
|
+
case "checks_unreadable":
|
|
228
|
+
return "PR checks cannot be read with the current GitHub token.";
|
|
227
229
|
case "deck_failure":
|
|
228
230
|
return "Agent Deck preflight failed.";
|
|
229
231
|
case "deck_unavailable":
|
|
@@ -277,6 +279,7 @@ export function outcomeShouldRecordError(outcome) {
|
|
|
277
279
|
outcome.kind === "no_pr" ||
|
|
278
280
|
outcome.kind === "checks_failed" ||
|
|
279
281
|
outcome.kind === "adapter_failure" ||
|
|
282
|
+
outcome.kind === "checks_unreadable" ||
|
|
280
283
|
outcome.kind === "deck_failure" ||
|
|
281
284
|
outcome.kind === "unpushed_commit" ||
|
|
282
285
|
outcome.kind === "worktree_conflict" ||
|
|
@@ -60,7 +60,7 @@ import { cancelWorkItem, enqueueWorkItem, finishWorkItem, listWorkItemsForIssue,
|
|
|
60
60
|
import { appendWorkflowEvent, getActiveWorkflowInstance, listWorkflowEventsForIssue, } from "../repository/workflow-events.js";
|
|
61
61
|
import { addWorktree, DEFAULT_BASE_FETCH_TIMEOUT_MS, fastForwardLocalBranchToSha, fetchFreshBase, fetchReusedBranch, findWorktreeForBranch, isAncestor, isWorktreeClean, pruneWorktrees, removeWorktree, revParseHead, safeRemoveWorktree, } from "../adapters/git-worktree.js";
|
|
62
62
|
import { classifyIssueRepo, worktreesRootForResolution, } from "../adapters/managed-repo.js";
|
|
63
|
-
import { pollPrChecks, realGithubAdapter, } from "../adapters/github.js";
|
|
63
|
+
import { ChecksUnreadableError, pollPrChecks, realGithubAdapter, } from "../adapters/github.js";
|
|
64
64
|
import { withRepoLock } from "../runners/process-registry.js";
|
|
65
65
|
import { checkDeveloperWorktreeOwnerLiveness } from "./worktree-owner-liveness.js";
|
|
66
66
|
import { buildProfileSnapshot, serializeProfileSnapshot } from "./profile-snapshot.js";
|
|
@@ -839,6 +839,10 @@ export async function runMergeConflictSync(opts) {
|
|
|
839
839
|
}
|
|
840
840
|
catch (err) {
|
|
841
841
|
await cleanupSyncCheckout(repoPath, syncPath);
|
|
842
|
+
// NOT-670: surface the missing-permission message as-is so the operator
|
|
843
|
+
// sees what to grant, not a generic poll error.
|
|
844
|
+
if (err instanceof ChecksUnreadableError)
|
|
845
|
+
return failed(err.message);
|
|
842
846
|
const detail = err instanceof Error ? err.message : String(err);
|
|
843
847
|
return failed(`checks poll errored: ${detail}`);
|
|
844
848
|
}
|
|
@@ -111,6 +111,11 @@ export function routeDeveloperOutcome(outcome, limits) {
|
|
|
111
111
|
? { next: "retry_developer", reason }
|
|
112
112
|
: { next: "human_action", actionType: "policy_escalation", reason: `${reason} (infra-attempt limit reached).` };
|
|
113
113
|
}
|
|
114
|
+
case "checks_unreadable":
|
|
115
|
+
// NOT-670: a missing GitHub permission — retrying the developer (or the
|
|
116
|
+
// poll) cannot grant it, so escalate once with the exact message: no
|
|
117
|
+
// infra attempt spent, no retry, no limit-reached suffix.
|
|
118
|
+
return { next: "human_action", actionType: "policy_escalation", reason: outcome.reason };
|
|
114
119
|
case "no_pr":
|
|
115
120
|
case "deck_failure": {
|
|
116
121
|
// Unified infra-failure policy: the session/environment failed to produce a
|
|
@@ -260,6 +260,38 @@ test("adapter failure escalates once the infra-attempt limit is reached", () =>
|
|
|
260
260
|
assert.equal(result.next, "human_action");
|
|
261
261
|
assert.equal(result.actionType, "policy_escalation");
|
|
262
262
|
});
|
|
263
|
+
test("NOT-670: unreadable checks escalate once with the missing-permission message, spending no infra attempt", () => {
|
|
264
|
+
const outcome = {
|
|
265
|
+
kind: "checks_unreadable",
|
|
266
|
+
reason: "Cannot read PR checks for not-so-fat/agent-box: the GitHub token lacks Checks read, " +
|
|
267
|
+
"and the fallback also failed (Actions: read / Commit statuses: read). Grant actions:read " +
|
|
268
|
+
"and commit statuses:read to the fine-grained token, or use a token with Checks access.",
|
|
269
|
+
};
|
|
270
|
+
// Fresh budget and exhausted budget route identically — a permission problem is
|
|
271
|
+
// never retried, so the infra-attempt count is untouched either way.
|
|
272
|
+
for (const limits of [INFRA_ATTEMPTS_LEFT, INFRA_AT_LIMIT]) {
|
|
273
|
+
assert.deepStrictEqual(routeDeveloperOutcome(outcome, limits), {
|
|
274
|
+
next: "human_action",
|
|
275
|
+
actionType: "policy_escalation",
|
|
276
|
+
reason: outcome.reason,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
const result = routeDeveloperOutcome(outcome, INFRA_ATTEMPTS_LEFT);
|
|
280
|
+
assert.match(result.reason, /Actions: read/);
|
|
281
|
+
assert.match(result.reason, /Commit statuses: read/);
|
|
282
|
+
assert.match(result.reason, /Checks/);
|
|
283
|
+
assert.doesNotMatch(result.reason, /infra-attempt limit reached/);
|
|
284
|
+
});
|
|
285
|
+
test("NOT-670: a non-permission gh failure keeps the adapter_failure infra-retry path", () => {
|
|
286
|
+
const outcome = {
|
|
287
|
+
kind: "adapter_failure",
|
|
288
|
+
reason: "Error: gh pr view failed: failed to connect: dial tcp: lookup api.github.com: no such host",
|
|
289
|
+
};
|
|
290
|
+
assert.deepStrictEqual(routeDeveloperOutcome(outcome, INFRA_ATTEMPTS_LEFT), {
|
|
291
|
+
next: "retry_developer",
|
|
292
|
+
reason: `Git/GitHub verification failed: ${outcome.reason}`,
|
|
293
|
+
});
|
|
294
|
+
});
|
|
263
295
|
test("timed_out with infra attempts remaining retries (same bucket as session_failed/no_pr)", () => {
|
|
264
296
|
const outcome = { kind: "timed_out" };
|
|
265
297
|
assert.deepStrictEqual(routeDeveloperOutcome(outcome, INFRA_ATTEMPTS_LEFT), {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-dealer/server",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 npm run build -w @agent-dealer/shared && AGENT_DEALER_SKIP_GITHUB_HEALTH=1 AGENT_DEALER_SKIP_AGENT_HEALTH=1 node ../../scripts/run-workspace-tests.mjs"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@agent-dealer/shared": "1.4.
|
|
26
|
+
"@agent-dealer/shared": "1.4.6",
|
|
27
27
|
"@fastify/cors": "^11.0.1",
|
|
28
28
|
"@fastify/static": "^8.2.0",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.29.0",
|