agent-dealer 1.4.2 → 1.4.4

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.
Files changed (33) hide show
  1. package/bundle/server/dist/adapters/github.js +66 -3
  2. package/bundle/server/dist/adapters/github.test.js +90 -0
  3. package/bundle/server/dist/coordinator/args.js +7 -9
  4. package/bundle/server/dist/coordinator/args.test.js +5 -2
  5. package/bundle/server/dist/coordinator/auto-merge.js +17 -6
  6. package/bundle/server/dist/coordinator/commands.js +18 -2
  7. package/bundle/server/dist/coordinator/developer-effect.js +46 -5
  8. package/bundle/server/dist/coordinator/developer-effect.test.js +118 -4
  9. package/bundle/server/dist/coordinator/muse-spawn.js +1 -0
  10. package/bundle/server/dist/coordinator/operator-criteria.js +250 -17
  11. package/bundle/server/dist/coordinator/operator-criteria.test.js +177 -4
  12. package/bundle/server/dist/coordinator/operator-verification.integration.test.js +208 -0
  13. package/bundle/server/dist/coordinator/projection.js +5 -1
  14. package/bundle/server/dist/coordinator/prompts.js +77 -4
  15. package/bundle/server/dist/coordinator/prompts.test.js +22 -4
  16. package/bundle/server/dist/coordinator/reviewer-browser-probe.js +2 -3
  17. package/bundle/server/dist/coordinator/reviewer-effect.js +64 -45
  18. package/bundle/server/dist/coordinator/reviewer-effect.test.js +63 -10
  19. package/bundle/server/dist/coordinator/reviewer-pr-evidence.test.js +245 -0
  20. package/bundle/server/dist/coordinator/reviewer-result.js +4 -3
  21. package/bundle/server/dist/coordinator/reviewer-result.test.js +6 -0
  22. package/bundle/server/dist/coordinator/routing.js +3 -0
  23. package/bundle/server/dist/coordinator/routing.test.js +19 -0
  24. package/bundle/server/dist/coordinator/spawn.js +25 -5
  25. package/bundle/server/dist/coordinator/spawn.test.js +84 -0
  26. package/bundle/server/dist/docs-api-reference.test.js +89 -0
  27. package/bundle/server/dist/runners/muse-config-core.js +33 -9
  28. package/bundle/server/dist/runners/muse-config.test.js +13 -8
  29. package/bundle/server/dist/runners/spawn-cli.js +12 -4
  30. package/bundle/server/dist/runners/spawn-cli.test.js +19 -0
  31. package/bundle/server/package.json +2 -2
  32. package/bundle/shared/package.json +1 -1
  33. package/package.json +1 -1
@@ -29,6 +29,17 @@ export const PR_VIEW_FIELDS = "number,url,baseRefName,headRefName,headRefOid,isD
29
29
  export function parsePrMergeableState(raw) {
30
30
  return raw === "CONFLICTING" || raw === "MERGEABLE" ? raw : "UNKNOWN";
31
31
  }
32
+ /**
33
+ * NOT-575: normalizes `gh pr view --json body` output — the body text, or
34
+ * null when absent, non-string, or blank. Callers treat null as "unavailable",
35
+ * never as evidence of anything.
36
+ */
37
+ export function parsePrBody(raw) {
38
+ if (typeof raw !== "string")
39
+ return null;
40
+ const trimmed = raw.trim();
41
+ return trimmed ? raw : null;
42
+ }
32
43
  const FAILURE_STATES = new Set([
33
44
  "failure",
34
45
  "error",
@@ -41,10 +52,55 @@ const FAILURE_STATES = new Set([
41
52
  const PENDING_STATES = new Set(["pending", "queued", "in_progress", "expected", "waiting", "requested"]);
42
53
  /** Every terminal-and-genuinely-ok conclusion `gh` can report — anything else fails closed. */
43
54
  const SUCCESS_STATES = new Set(["success", "neutral", "skipped"]);
55
+ function checkIdentity(check) {
56
+ if (typeof check.context === "string" && check.context) {
57
+ return JSON.stringify(["status", check.context]);
58
+ }
59
+ if (typeof check.name === "string" && check.name) {
60
+ return JSON.stringify(["check", check.workflowName ?? "", check.name]);
61
+ }
62
+ return null;
63
+ }
64
+ function checkTime(check) {
65
+ const candidates = check.context
66
+ ? [check.startedAt, check.createdAt]
67
+ : [check.startedAt, check.completedAt];
68
+ for (const candidate of candidates) {
69
+ if (typeof candidate !== "string" || !candidate)
70
+ continue;
71
+ const time = Date.parse(candidate);
72
+ if (Number.isFinite(time))
73
+ return time;
74
+ }
75
+ return null;
76
+ }
77
+ /**
78
+ * GitHub keeps earlier attempts in the rollup when a check runs again on the same
79
+ * commit. Drop superseded timed entries by the provider's check identity. Untimed
80
+ * entries remain untouched because their relative age cannot be established safely.
81
+ */
82
+ function newestChecks(rollup) {
83
+ const newestIndexByIdentity = new Map();
84
+ for (const [index, check] of rollup.entries()) {
85
+ const identity = checkIdentity(check);
86
+ const time = checkTime(check);
87
+ if (identity == null || time == null)
88
+ continue;
89
+ const current = newestIndexByIdentity.get(identity);
90
+ if (current == null || time >= current.time)
91
+ newestIndexByIdentity.set(identity, { index, time });
92
+ }
93
+ return rollup.filter((check, index) => {
94
+ const identity = checkIdentity(check);
95
+ const time = checkTime(check);
96
+ return identity == null || time == null || newestIndexByIdentity.get(identity)?.index === index;
97
+ });
98
+ }
44
99
  export function summarizeChecks(rollup) {
45
- if (rollup.length === 0)
100
+ const currentChecks = newestChecks(rollup);
101
+ if (currentChecks.length === 0)
46
102
  return "none";
47
- const states = rollup.map((c) => (c.conclusion || c.state || c.status || "").toLowerCase());
103
+ const states = currentChecks.map((c) => (c.conclusion || c.state || c.status || "").toLowerCase());
48
104
  if (states.some((s) => FAILURE_STATES.has(s)))
49
105
  return "failure";
50
106
  if (states.some((s) => PENDING_STATES.has(s)))
@@ -390,6 +446,9 @@ export function createGithubAdapter(exec = defaultExec) {
390
446
  return { ok: false, reason: message, noCommits: NO_COMMITS_PATTERN.test(message) };
391
447
  }
392
448
  },
449
+ async updatePrBody({ cwd, number, bodyFilePath }) {
450
+ await exec(["pr", "edit", String(number), "--body-file", bodyFilePath], { cwd });
451
+ },
393
452
  async checksSnapshot({ cwd, number, branch }) {
394
453
  const selector = number != null ? String(number) : branch;
395
454
  const raw = await ghPrView(exec, cwd, "statusCheckRollup", selector);
@@ -422,6 +481,10 @@ export function createGithubAdapter(exec = defaultExec) {
422
481
  return "UNKNOWN";
423
482
  }
424
483
  },
484
+ async prBody({ cwd, number }) {
485
+ const raw = await ghPrView(exec, cwd, "body", String(number));
486
+ return parsePrBody(raw?.body);
487
+ },
425
488
  async listWorkflowRunsForCommit({ cwd, workflow, commitSha }) {
426
489
  try {
427
490
  const { stdout } = await exec([
@@ -497,7 +560,7 @@ export async function fetchChecksFailureEvidence(exec, opts) {
497
560
  // Never attach another commit's failure: the head must still be the verified one.
498
561
  if (!headSha || headSha !== opts.expectedHeadSha)
499
562
  return null;
500
- const rollup = raw.statusCheckRollup ?? [];
563
+ const rollup = newestChecks(raw.statusCheckRollup ?? []);
501
564
  const failed = rollup.filter((c) => isFailedCheckState(rawCheckState(c)));
502
565
  if (failed.length === 0)
503
566
  return null;
@@ -31,6 +31,66 @@ test("summarizeChecks accepts neutral/skipped as success but fails closed on an
31
31
  assert.equal(summarizeChecks([{ conclusion: "neutral" }, { conclusion: "skipped" }]), "success");
32
32
  assert.equal(summarizeChecks([{ conclusion: "some_new_gh_conclusion_this_code_does_not_know" }]), "failure");
33
33
  });
34
+ test("summarizeChecks uses the newest run of the same workflow check", () => {
35
+ const failedRun = {
36
+ name: "PR body",
37
+ workflowName: "CI",
38
+ status: "COMPLETED",
39
+ conclusion: "FAILURE",
40
+ startedAt: "2026-11-15T18:00:00Z",
41
+ completedAt: "2026-11-15T18:01:00Z",
42
+ };
43
+ const successfulRerun = {
44
+ name: "PR body",
45
+ workflowName: "CI",
46
+ status: "COMPLETED",
47
+ conclusion: "SUCCESS",
48
+ startedAt: "2026-11-15T18:02:00Z",
49
+ completedAt: "2026-11-15T18:03:00Z",
50
+ };
51
+ assert.equal(summarizeChecks([failedRun, successfulRerun]), "success");
52
+ assert.equal(summarizeChecks([successfulRerun, { ...failedRun, startedAt: "2026-11-15T18:04:00Z" }]), "failure");
53
+ });
54
+ test("summarizeChecks keeps checks from different workflows and jobs separate", () => {
55
+ assert.equal(summarizeChecks([
56
+ {
57
+ name: "build",
58
+ workflowName: "CI",
59
+ status: "COMPLETED",
60
+ conclusion: "FAILURE",
61
+ startedAt: "2026-11-15T18:00:00Z",
62
+ completedAt: "2026-11-15T18:01:00Z",
63
+ },
64
+ {
65
+ name: "build",
66
+ workflowName: "Release",
67
+ status: "COMPLETED",
68
+ conclusion: "SUCCESS",
69
+ startedAt: "2026-11-15T18:02:00Z",
70
+ completedAt: "2026-11-15T18:03:00Z",
71
+ },
72
+ {
73
+ name: "lint",
74
+ workflowName: "CI",
75
+ status: "COMPLETED",
76
+ conclusion: "SUCCESS",
77
+ startedAt: "2026-11-15T18:02:00Z",
78
+ completedAt: "2026-11-15T18:03:00Z",
79
+ },
80
+ ]), "failure");
81
+ });
82
+ test("summarizeChecks uses the newest status context", () => {
83
+ assert.equal(summarizeChecks([
84
+ { context: "ci/external", state: "FAILURE", startedAt: "2026-11-15T18:00:00Z" },
85
+ { context: "ci/external", state: "SUCCESS", createdAt: "2026-11-15T18:02:00Z" },
86
+ ]), "success");
87
+ });
88
+ test("summarizeChecks preserves same-identity entries when their run times are unavailable", () => {
89
+ assert.equal(summarizeChecks([
90
+ { name: "build", workflowName: "CI", status: "COMPLETED", conclusion: "FAILURE" },
91
+ { name: "build", workflowName: "CI", status: "COMPLETED", conclusion: "SUCCESS" },
92
+ ]), "failure");
93
+ });
34
94
  /** Records every `gh` invocation and returns responses off a queue — never calls real `gh`. */
35
95
  function queuedExec(responses) {
36
96
  const calls = [];
@@ -77,6 +137,11 @@ test("createDraftPr passes --head explicitly and re-verifies by that same branch
77
137
  assert.deepEqual(calls[1], ["pr", "view", "issue-x", "--json", "number,url"]);
78
138
  assert.deepEqual(result, { ok: true, number: 9, url: "https://github.com/o/r/pull/9" });
79
139
  });
140
+ test("updatePrBody replaces the PR body from the provided file", async () => {
141
+ const { exec, calls } = queuedExec([{ stdout: "" }]);
142
+ await createGithubAdapter(exec).updatePrBody({ cwd: "/repo", number: 17, bodyFilePath: "/tmp/body.md" });
143
+ assert.deepEqual(calls[0], ["pr", "edit", "17", "--body-file", "/tmp/body.md"]);
144
+ });
80
145
  // NOT-82 dogfood repro: a real Dev-review run pushed its generated branch to origin, but
81
146
  // the local worktree had no configured upstream — `gh pr create` (bare, no `--head`)
82
147
  // refused with exactly this error, and the coordinator must never hit it.
@@ -400,6 +465,31 @@ test("NOT-252: no failed checks yields no enrichment", async () => {
400
465
  assert.equal(await fetchChecksFailureEvidence(exec, { cwd: "/repo", number: 42, expectedHeadSha: HEAD_SHA }), null);
401
466
  assert.ok(calls.every((c) => c[0] === "pr"), "no log fetch without a failure");
402
467
  });
468
+ test("NOT-629: failure evidence excludes a stale failed run after a successful rerun", async () => {
469
+ const { exec, calls } = queuedExec([
470
+ {
471
+ stdout: prViewWithRollup([
472
+ actionsCheck("build", "FAILURE", "111", {
473
+ startedAt: "2026-11-15T18:00:00Z",
474
+ completedAt: "2026-11-15T18:01:00Z",
475
+ }),
476
+ actionsCheck("build", "SUCCESS", "222", {
477
+ startedAt: "2026-11-15T18:02:00Z",
478
+ completedAt: "2026-11-15T18:03:00Z",
479
+ }),
480
+ actionsCheck("lint", "FAILURE", "333", {
481
+ startedAt: "2026-11-15T18:02:00Z",
482
+ completedAt: "2026-11-15T18:03:00Z",
483
+ }),
484
+ ]),
485
+ },
486
+ { stdout: "lint failed\nError: nit\n" },
487
+ ]);
488
+ const evidence = await fetchChecksFailureEvidence(exec, { cwd: "/repo", number: 42, expectedHeadSha: HEAD_SHA });
489
+ assert.ok(evidence);
490
+ assert.deepEqual(evidence.failedChecks.map((check) => check.name), ["lint"]);
491
+ assert.deepEqual(calls.filter((call) => call[0] === "run"), [["run", "view", "333", "--log-failed"]]);
492
+ });
403
493
  test("NOT-252: noisy log focuses the excerpt on the actionable E404 lines", async () => {
404
494
  const setup = Array.from({ length: 200 }, (_, i) => `setup step ${i}: downloading dependency cache chunk ${i}`).join("\n");
405
495
  const tail = Array.from({ length: 100 }, (_, i) => `cleanup temp dir ${i}`).join("\n");
@@ -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, prompt, model, mcpConfigPath, effort) {
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(prompt);
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.prompt, opts.model, opts.mcpConfigPath, opts.effort);
126
+ return buildArgs(opts.runtime, opts.policy ?? roleCeiling(opts.role), opts.model, opts.mcpConfigPath, opts.effort);
129
127
  }
130
- export function buildDeveloperArgs(runtime, prompt, model, policy, mcpConfigPath, effort) {
131
- return buildArgs(runtime, policy ?? roleCeiling("developer"), prompt, model, mcpConfigPath, effort);
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, prompt, model, policy, mcpConfigPath, effort) {
134
- return buildArgs(runtime, policy ?? roleCeiling("reviewer"), prompt, model, mcpConfigPath, effort);
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
- assert.ok(buildDeveloperArgs(runtime, "prompt").includes("prompt"), runtime);
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
  });
@@ -33,7 +33,7 @@ import { isMergeConflictFailure, runMergeConflictSync } from "./merge-conflict-s
33
33
  import { triggerLinearPostMerge } from "./linear-merge-verify.js";
34
34
  import { startBaseAdvancedScan } from "./base-advanced-scan.js";
35
35
  import { runHeldWork } from "../power/host-awake-lifecycle.js";
36
- import { OPERATOR_VERIFICATION_RESPONSE_OPTIONS, formatOperatorCriteria, getOperatorCriteriaForIssue, hasOperatorVerificationForHead, operatorVerificationRequestId, } from "./operator-criteria.js";
36
+ import { OPERATOR_VERIFICATION_RESPONSE_OPTIONS, formatOperatorCriteria, getOperatorCriteriaForIssue, hasOperatorVerificationForHead, missingOperatorCriteriaForHead, operatorVerificationRequestId, } from "./operator-criteria.js";
37
37
  import { readVisualEvidenceHold } from "./reviewer-visual-evidence.js";
38
38
  const run = promisify(execFile);
39
39
  /** Bound each `gh` shell-out so a hang cannot freeze the coordinator process. */
@@ -360,10 +360,17 @@ function formatVisualHold(hold) {
360
360
  * (criteria and visual items together), so one recorded result releases it;
361
361
  * no repair round is ever queued for missing evidence alone.
362
362
  *
363
+ * NOT-575: each trailing-`[operator]` criterion needs a recorded result for
364
+ * that exact criterion on the exact head SHA — a result recorded for one
365
+ * criterion never releases another. The visual hold (no criterion list) still
366
+ * releases on any recorded result for the head, so a combined action's one
367
+ * resolve — which covers the gated criteria and counts as a head result —
368
+ * still releases the whole head.
369
+ *
363
370
  * Returns null when the merge may proceed (no operator criteria, no visual
364
- * hold, a recorded result for this head, or no workflow to gate). Idempotent:
365
- * a second finalize for the same head reuses the open action instead of
366
- * raising another.
371
+ * hold, a recorded result for this head covering every criterion, or no
372
+ * workflow to gate). Idempotent: a second finalize for the same head reuses
373
+ * the open action instead of raising another.
367
374
  *
368
375
  * Fail-closed: when operator criteria exist, every non-proceed path returns a
369
376
  * result (never null), so a missing head SHA or an unexpected status blocks the
@@ -382,8 +389,12 @@ export function gateOperatorVerification(issueId) {
382
389
  const visualHold = head ? readVisualEvidenceHold(issueId, head) : null;
383
390
  if (criteria.length === 0 && !visualHold)
384
391
  return null;
385
- if (head && hasOperatorVerificationForHead(issueId, head))
386
- return null;
392
+ if (head) {
393
+ const criteriaCovered = missingOperatorCriteriaForHead(issueId, head, criteria).length === 0;
394
+ const visualCovered = !visualHold || hasOperatorVerificationForHead(issueId, head);
395
+ if (criteriaCovered && visualCovered)
396
+ return null;
397
+ }
387
398
  if (current.status === "done")
388
399
  return null;
389
400
  // Only the auto-merge park (or an already-gated issue) is gated — any other
@@ -35,7 +35,7 @@ import { AUTH_TRANSIENT_RETRY_PAYLOAD_KEY, RUNTIME_AUTH_PARK_EVIDENCE_KEY, authP
35
35
  import { AUTO_MERGE_INTENT, OPERATOR_VERIFICATION_INTENT, finalizeAutoMerge } from "./auto-merge.js";
36
36
  import { triggerLinearPostMerge } from "./linear-merge-verify.js";
37
37
  import { conflictRepairSpent, queueConflictRepairRound } from "./merge-conflict-sync.js";
38
- import { OPERATOR_VERIFICATION_ARTIFACT_KIND, OPERATOR_VERIFICATION_RESPONSE_OPTIONS, } from "./operator-criteria.js";
38
+ import { OPERATOR_VERIFICATION_ARTIFACT_KIND, OPERATOR_VERIFICATION_RESPONSE_OPTIONS, criteriaTextsFromActionEvidence, getOperatorCriteriaForIssue, } from "./operator-criteria.js";
39
39
  import { externalMergeStateForIssue } from "./external-merge.js";
40
40
  import { detectNonConvergence, formatNonConvergenceReason, reviewHistoryFromEvents, } from "./non-convergence.js";
41
41
  import { capEscalationEvents, checksWaitDeferralStartedAt, deferLeasedWorkItemForBaseFetch, deferLeasedWorkItemForChecksPending, deferLeasedWorkItemForDeckOutage, deferLeasedWorkItemForUsageCap, formatCapEscalationReason, formatChecksWaitEscalationReason, usageCapDeferralStartedAt, } from "./usage-cap-defer.js";
@@ -1318,7 +1318,13 @@ function applyReviewer(issue, instance, item, outcome, authFailure) {
1318
1318
  }
1319
1319
  const hasVerdict = outcome.kind === "verdict";
1320
1320
  // Normalize before emit/finding reconcile so remapped blocking findings (NOT-150) persist.
1321
- const verdictResult = outcome.kind === "verdict" ? normalizeReviewerResult(outcome.result) : null;
1321
+ // A truncated review routed directly to an operator preserves the reviewer's own result;
1322
+ // in particular, a bare escalate must not acquire normalizeReviewer's synthetic repair finding.
1323
+ const verdictResult = outcome.kind === "verdict"
1324
+ ? outcome.finalReviewReason
1325
+ ? outcome.result
1326
+ : normalizeReviewerResult(outcome.result)
1327
+ : null;
1322
1328
  const { projection, effect, advance } = projectReviewerRoute(route, issue.currentRound, hasVerdict);
1323
1329
  const ev = eventEmitter(issue, instance, item.workerSessionId, projection.issueStatus, issue.currentRound);
1324
1330
  const patch = {};
@@ -1944,6 +1950,14 @@ export function resolveHumanActionAndAdvance(actionId, resolvedBy, choice, opts)
1944
1950
  // re-checks the record against the then-current head, so new commits
1945
1951
  // re-block the gate.
1946
1952
  if (resolution.actionType === "operator_verification" && operatorNote) {
1953
+ // NOT-575: the result covers exactly the criteria the gated action
1954
+ // listed (read off the action's own stored evidence — never
1955
+ // re-derived, so the coverage is provably the gated set). A result
1956
+ // for one criterion never releases another; the fallback recomputes
1957
+ // from the frozen snapshot for actions raised before that evidence
1958
+ // shape existed.
1959
+ const coveredCriteria = criteriaTextsFromActionEvidence(action) ??
1960
+ getOperatorCriteriaForIssue(issue).map((c) => c.text);
1947
1961
  if (resolution.choice === "verified") {
1948
1962
  createIssueArtifact({
1949
1963
  issueId: issue.id,
@@ -1954,6 +1968,7 @@ export function resolveHumanActionAndAdvance(actionId, resolvedBy, choice, opts)
1954
1968
  note: operatorNote,
1955
1969
  verifiedBy: resolvedBy,
1956
1970
  verifiedAt: new Date().toISOString(),
1971
+ criteria: coveredCriteria,
1957
1972
  },
1958
1973
  });
1959
1974
  }
@@ -1972,6 +1987,7 @@ export function resolveHumanActionAndAdvance(actionId, resolvedBy, choice, opts)
1972
1987
  headSha: issue.headSha,
1973
1988
  waivedBy: resolvedBy,
1974
1989
  note: operatorNote,
1990
+ criteria: coveredCriteria,
1975
1991
  },
1976
1992
  });
1977
1993
  }
@@ -20,7 +20,7 @@ import { parsePhaseBudget, parseProfileSnapshot, roleCeiling } from "@agent-deal
20
20
  import { CONFLICTING_FILES_MAX, runMergeConflictSync } from "./merge-conflict-sync.js";
21
21
  import { getTaskSnapshot } from "./commands.js";
22
22
  import { materializeSourceAttachments, SourceAttachmentError, } from "./source-attachments.js";
23
- import { extractOperatorCriteria } from "./operator-criteria.js";
23
+ import { operatorCriteriaForSnapshot } from "./operator-criteria.js";
24
24
  import { buildDeveloperPrompt } from "./prompts.js";
25
25
  import { VISUAL_QA_EXCLUDE_LINE, collectDeveloperVisualQa } from "./visual-qa.js";
26
26
  import { ensureWorktreeExcluded } from "../adapters/worktree-exclude.js";
@@ -161,6 +161,31 @@ function extractConclusion(transcript) {
161
161
  return "";
162
162
  return trimmed.length > 4000 ? trimmed.slice(-4000) : trimmed;
163
163
  }
164
+ /** Full contents of the last valid four-backtick `pr-description` block. */
165
+ export function extractPrDescription(transcript) {
166
+ const blocks = transcript.matchAll(/^````pr-description[ \t]*\r?\n([\s\S]*?)^````[ \t]*(?:\r?\n|$)/gm);
167
+ let last = null;
168
+ for (const block of blocks)
169
+ last = (block[1] ?? "").replace(/\r?\n$/, "");
170
+ return last?.trim() ? last : null;
171
+ }
172
+ /** A body refresh must never turn completed developer work into a failed round. */
173
+ async function bestEffortUpdatePrBody(opts) {
174
+ if (!opts.github.updatePrBody)
175
+ return;
176
+ const bodyDir = fs.mkdtempSync(path.join(os.tmpdir(), "dealer-pr-body-"));
177
+ const bodyFilePath = path.join(bodyDir, "body.md");
178
+ try {
179
+ fs.writeFileSync(bodyFilePath, opts.body);
180
+ await opts.github.updatePrBody({ cwd: opts.cwd, number: opts.number, bodyFilePath });
181
+ }
182
+ catch (err) {
183
+ console.warn(`[dealer] PR body update failed for ${opts.issueId} (#${opts.number}): ${String(err)}`);
184
+ }
185
+ finally {
186
+ fs.rmSync(bodyDir, { recursive: true, force: true });
187
+ }
188
+ }
164
189
  /** NOT-130: mine + persist a SHA-scoped suite receipt while the worktree still exists.
165
190
  * Tip-tree equivalence: only vouch for HEAD when the tree is clean — a green suite on a
166
191
  * dirty checkout must not be reloaded as tip evidence after a later clean/revert.
@@ -707,8 +732,12 @@ async function runPublishOnlyHandoff(ctx, deps, branchName) {
707
732
  if (prior?.contentJson) {
708
733
  try {
709
734
  const parsed = JSON.parse(prior.contentJson);
710
- if (typeof parsed.text === "string" && parsed.text.trim())
735
+ if (typeof parsed.prDescription === "string" && parsed.prDescription.trim()) {
736
+ body = parsed.prDescription;
737
+ }
738
+ else if (typeof parsed.text === "string" && parsed.text.trim()) {
711
739
  body = parsed.text.trim();
740
+ }
712
741
  }
713
742
  catch {
714
743
  // keep description
@@ -1216,7 +1245,8 @@ export async function runDeveloperEffect(ctx, deps = defaultDeps) {
1216
1245
  : undefined;
1217
1246
  // NOT-314: the frozen snapshot's operator criteria, parsed here so the
1218
1247
  // worker never re-derives them — the section renders only when non-empty.
1219
- const operatorCriteria = extractOperatorCriteria(taskSnapshot.acceptanceCriteria);
1248
+ // NOT-575: the same union the gate uses (AC text + structured contract).
1249
+ const operatorCriteria = operatorCriteriaForSnapshot(taskSnapshot);
1220
1250
  const hasOperatorCriteria = operatorCriteria.length > 0 ? operatorCriteria : undefined;
1221
1251
  // NOT-310: the conflict directive rides only the work item queued by the merge
1222
1252
  // path — exactly this round reads it; nothing is re-read from the DB. Shaped
@@ -1772,12 +1802,13 @@ export async function runDeveloperEffect(ctx, deps = defaultDeps) {
1772
1802
  // dropped on any later verification failure (checks failing, a gh error), even though
1773
1803
  // NOT-61 requires the conclusion/raw trace to stay available through the evidence API
1774
1804
  // regardless of how the handoff subsequently resolves.
1805
+ const prDescription = extractPrDescription(spawned.transcript);
1775
1806
  createIssueArtifact({
1776
1807
  issueId: issue.id,
1777
1808
  workerSessionId: sessionId,
1778
1809
  kind: "implementation_conclusion",
1779
1810
  author: "agent",
1780
- content: { text: extractConclusion(spawned.transcript) },
1811
+ content: { text: extractConclusion(spawned.transcript), prDescription },
1781
1812
  });
1782
1813
  createIssueArtifact({
1783
1814
  issueId: issue.id,
@@ -1908,11 +1939,12 @@ export async function runDeveloperEffect(ctx, deps = defaultDeps) {
1908
1939
  // rather than asking `gh` to infer "the current branch" from upstream tracking, which
1909
1940
  // pushBranch's push does not reliably leave configured (NOT-82).
1910
1941
  let prView = await deps.github.viewPr({ cwd: worktreePath, branch: branchName });
1942
+ const prAlreadyExisted = prView !== null;
1911
1943
  if (!prView) {
1912
1944
  setLiveIntent(issue.id, `Developer · opening draft PR (round ${round})`);
1913
1945
  const bodyDir = fs.mkdtempSync(path.join(os.tmpdir(), "dealer-pr-body-"));
1914
1946
  const bodyFilePath = path.join(bodyDir, "body.md");
1915
- fs.writeFileSync(bodyFilePath, extractConclusion(spawned.transcript) || taskSnapshot.description);
1947
+ fs.writeFileSync(bodyFilePath, (prDescription ?? extractConclusion(spawned.transcript)) || taskSnapshot.description);
1916
1948
  const created = await deps.github.createDraftPr({
1917
1949
  cwd: worktreePath,
1918
1950
  base: baseBranch,
@@ -1963,6 +1995,15 @@ export async function runDeveloperEffect(ctx, deps = defaultDeps) {
1963
1995
  publishable: { branch: branchName },
1964
1996
  };
1965
1997
  }
1998
+ if (prAlreadyExisted && prDescription) {
1999
+ await bestEffortUpdatePrBody({
2000
+ github: deps.github,
2001
+ cwd: worktreePath,
2002
+ number: prView.number,
2003
+ body: prDescription,
2004
+ issueId: issue.id,
2005
+ });
2006
+ }
1966
2007
  // NOT-381: collect the structured Visual QA receipt against the just-pushed
1967
2008
  // head, before the checks wait. Accepted screenshots move to Dealer-owned
1968
2009
  // storage and the transient worktree directory is removed; a rejection is