toolroll 0.9.73 → 0.9.75

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 (145) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent-turns.js +5 -0
  4. package/dist/agents-live.d.ts +31 -0
  5. package/dist/agents-live.js +43 -0
  6. package/dist/assignment.d.ts +3 -0
  7. package/dist/assignment.js +27 -8
  8. package/dist/browser/THIRD_PARTY_NOTICES.txt +40 -0
  9. package/dist/browser/workspace.css +2 -2
  10. package/dist/browser/workspace.js +31 -30
  11. package/dist/browser-workspace.d.ts +7 -1
  12. package/dist/builder.js +1 -1
  13. package/dist/chat-acceptance.d.ts +4 -1
  14. package/dist/chat-acceptance.js +13 -3
  15. package/dist/chat-continuity.js +10 -0
  16. package/dist/chat-quiet.js +3 -3
  17. package/dist/cli.js +1 -1
  18. package/dist/coding-handoff.js +4 -3
  19. package/dist/coding-ui.js +2 -2
  20. package/dist/coding-workspace.js +16 -4
  21. package/dist/contracts/console-api.d.ts +5 -1
  22. package/dist/contracts/console-api.js +10 -0
  23. package/dist/control-ui.d.ts +3 -2
  24. package/dist/control-ui.js +7 -2
  25. package/dist/demo.js +5 -3
  26. package/dist/deploy-gate.js +5 -2
  27. package/dist/desktop-update.d.ts +4 -1
  28. package/dist/desktop-update.js +43 -9
  29. package/dist/dispose.js +35 -2
  30. package/dist/exec.js +13 -16
  31. package/dist/first-run.d.ts +20 -1
  32. package/dist/first-run.js +71 -0
  33. package/dist/flow-card-task.js +3 -2
  34. package/dist/flow-unattended.d.ts +2 -0
  35. package/dist/flow-unattended.js +12 -1
  36. package/dist/integrations.d.ts +4 -3
  37. package/dist/integrations.js +5 -6
  38. package/dist/invoke.d.ts +13 -0
  39. package/dist/invoke.js +21 -12
  40. package/dist/knowledge-ui.d.ts +4 -1
  41. package/dist/knowledge-ui.js +10 -5
  42. package/dist/lead-contract.d.ts +1 -1
  43. package/dist/lead-contract.js +2 -2
  44. package/dist/lead-follow.js +3 -1
  45. package/dist/lead-progress.d.ts +4 -1
  46. package/dist/lead-progress.js +3 -1
  47. package/dist/lead.js +4 -0
  48. package/dist/live-bus.d.ts +2 -0
  49. package/dist/live-bus.js +1 -0
  50. package/dist/live-children-read.d.ts +52 -0
  51. package/dist/live-children-read.js +333 -0
  52. package/dist/live-children.d.ts +73 -0
  53. package/dist/live-children.js +318 -0
  54. package/dist/live-detail.d.ts +4 -3
  55. package/dist/live-detail.js +9 -5
  56. package/dist/live-input.js +7 -8
  57. package/dist/live-main-read.d.ts +19 -0
  58. package/dist/live-main-read.js +91 -0
  59. package/dist/live-open.d.ts +28 -0
  60. package/dist/live-open.js +125 -0
  61. package/dist/live-records.d.ts +10 -1
  62. package/dist/live-records.js +16 -5
  63. package/dist/live.d.ts +54 -22
  64. package/dist/live.js +218 -69
  65. package/dist/openrouter-models.d.ts +5 -2
  66. package/dist/openrouter-models.js +7 -4
  67. package/dist/operate.js +5 -2
  68. package/dist/peek-cli.d.ts +10 -3
  69. package/dist/peek-cli.js +17 -8
  70. package/dist/planner.js +1 -1
  71. package/dist/project-learning.js +44 -6
  72. package/dist/project-tools.js +19 -1
  73. package/dist/provider-limits.d.ts +3 -1
  74. package/dist/provider-limits.js +5 -2
  75. package/dist/provider.js +6 -12
  76. package/dist/pull-request-ui.d.ts +1 -1
  77. package/dist/pull-request-ui.js +5 -1
  78. package/dist/push.d.ts +2 -0
  79. package/dist/push.js +24 -19
  80. package/dist/read-only-request.d.ts +4 -0
  81. package/dist/read-only-request.js +15 -0
  82. package/dist/release-adapters.js +4 -0
  83. package/dist/release.d.ts +3 -0
  84. package/dist/release.js +3 -0
  85. package/dist/repository-context-ui.js +2 -1
  86. package/dist/repository-context.js +6 -1
  87. package/dist/result-follow-ups.js +20 -1
  88. package/dist/result-review.js +5 -1
  89. package/dist/run-efficiency.d.ts +3 -3
  90. package/dist/run-efficiency.js +20 -8
  91. package/dist/scout.d.ts +3 -0
  92. package/dist/scout.js +5 -3
  93. package/dist/serve.js +196 -29
  94. package/dist/server/agents-live-filed.d.ts +17 -0
  95. package/dist/server/agents-live-filed.js +97 -0
  96. package/dist/server/agents-live-lead.d.ts +47 -0
  97. package/dist/server/agents-live-lead.js +116 -0
  98. package/dist/server/agents-live-room.d.ts +23 -0
  99. package/dist/server/agents-live-room.js +91 -0
  100. package/dist/server/chat.js +115 -53
  101. package/dist/server/chrome.js +2 -2
  102. package/dist/server/console.css +68 -40
  103. package/dist/server/http.d.ts +5 -0
  104. package/dist/server/last-checks.d.ts +17 -0
  105. package/dist/server/last-checks.js +22 -0
  106. package/dist/server/live.d.ts +4 -0
  107. package/dist/server/live.js +42 -2
  108. package/dist/server/pages.js +98 -4
  109. package/dist/server/people-tokens.js +7 -4
  110. package/dist/server/render-chat.d.ts +15 -1
  111. package/dist/server/render-chat.js +14 -7
  112. package/dist/server/render-pages.d.ts +10 -5
  113. package/dist/server/render-pages.js +83 -74
  114. package/dist/server/render-results.d.ts +11 -2
  115. package/dist/server/render-results.js +54 -12
  116. package/dist/server/render-settings.js +3 -3
  117. package/dist/server/render-tasks.js +13 -3
  118. package/dist/server/route-table.js +19 -2
  119. package/dist/server/runtime.d.ts +17 -2
  120. package/dist/server/settings.js +85 -32
  121. package/dist/server/task-views.js +1 -2
  122. package/dist/server/tasks.js +70 -43
  123. package/dist/storage-ui.d.ts +2 -0
  124. package/dist/storage-ui.js +1 -1
  125. package/dist/storage.js +2 -1
  126. package/dist/store.d.ts +34 -1
  127. package/dist/store.js +108 -11
  128. package/dist/stream-scope.d.ts +18 -0
  129. package/dist/stream-scope.js +28 -0
  130. package/dist/subagent-work.js +3 -0
  131. package/dist/subscription-chat.js +5 -3
  132. package/dist/task-status.d.ts +28 -1
  133. package/dist/task-status.js +93 -11
  134. package/dist/teardown-git.d.ts +27 -1
  135. package/dist/teardown-git.js +185 -39
  136. package/dist/telegram-progress.js +4 -4
  137. package/dist/telegram-status.js +8 -3
  138. package/dist/tool-secret-store.js +8 -0
  139. package/dist/toolroll-update-ui.d.ts +2 -0
  140. package/dist/toolroll-update-ui.js +4 -3
  141. package/dist/toolroll-update.js +10 -9
  142. package/dist/work-index.js +29 -12
  143. package/dist/workspace-ui.d.ts +5 -0
  144. package/dist/workspace-ui.js +38 -10
  145. package/package.json +1 -1
@@ -21,6 +21,7 @@ import { claudeStreamReader } from "./lead-progress.js";
21
21
  import { ALL_CREDENTIAL_ENV } from "./provider.js";
22
22
  import { claudeLimitsOf, noteLimits } from "./provider-limits.js";
23
23
  import { claudeBillingFrom } from "./spend.js";
24
+ import { primaryResultEvent, topLevelEvent } from "./stream-scope.js";
24
25
  const RESPONSE_CAP_BYTES = 65_536;
25
26
  function outputSchema(tools) {
26
27
  return {
@@ -179,7 +180,8 @@ function lastResultLine(stdout) {
179
180
  continue;
180
181
  try {
181
182
  const event = JSON.parse(line);
182
- if (typeof event === "object" && event !== null && event["type"] === "result")
183
+ // The main query's result, never a subagent's or a background task's (stream-scope.ts).
184
+ if (typeof event === "object" && event !== null && primaryResultEvent(event))
183
185
  return line;
184
186
  }
185
187
  catch { /* not an event line */ }
@@ -254,11 +256,11 @@ export async function performSubscriptionLeadRequest(request, runner = run) {
254
256
  seen.planWindows = true;
255
257
  noteLimits(reading);
256
258
  }
257
- else if (event["type"] === "system" && event["subtype"] === "init") {
259
+ else if (event["type"] === "system" && event["subtype"] === "init" && topLevelEvent(event)) {
258
260
  seen.keySource = typeof event["apiKeySource"] === "string" ? event["apiKeySource"] : null;
259
261
  seen.model = typeof event["model"] === "string" ? event["model"] : null;
260
262
  }
261
- else if (event["type"] === "result")
263
+ else if (primaryResultEvent(event))
262
264
  answered = true;
263
265
  }
264
266
  const billing = answered ? claudeBillingFrom(seen) : null;
@@ -43,6 +43,8 @@ export type TaskStatus = {
43
43
  key: NeedKey;
44
44
  action: NeedAction;
45
45
  } | null;
46
+ /** The approved check as the Checks row shows it (`approvedCheckStateOf`): the road reads this, never the row's words. */
47
+ check?: ApprovedCheckState | null;
46
48
  };
47
49
  /** `reviewing`: the one automatic review (build-review.ts) is reading a finished build; it reads Building, not a headline of its own. */
48
50
  export type TaskStage = "queued" | "planning" | "needs-you" | "waiting" | "building" | "checking" | "reviewing" | "finished" | "complete" | "failed" | "stopped";
@@ -61,6 +63,8 @@ export type ChecksFact = {
61
63
  run: number;
62
64
  head: string;
63
65
  } | null;
66
+ /** Why it can't be read, when that is the project's check command approved again since it ran. */
67
+ cause?: "command-changed" | null;
64
68
  };
65
69
  /** What checks Off leaves for a release: `pending` until a passing full release check contains the commit, then
66
70
  * `covered`. `running`: a check is waiting for its batch or running on this commit. */
@@ -70,6 +74,25 @@ export declare function releaseStateOf(checks: Pick<ChecksFact, "status" | "leve
70
74
  /** How the project check stands for requirements that rest on it, read now: `covered` once a check passed on this
71
75
  * commit (its own, a follow-up, or a release check containing it), `pending` while checks Off wait for a release. */
72
76
  export declare function checkBackingOf(checks: Pick<ChecksFact, "status" | "level" | "release" | "running" | "batch"> | null | undefined): ReleaseState | undefined;
77
+ /**
78
+ * Did the approved check pass for this result? The ONE answer the status headline and sentence, the Project checks
79
+ * row, the road's Checks step and the result page all read, so none of them can say "passed" while another says the
80
+ * check couldn't be read. Two records speak to it: the machine verdict sealed when the build finished, and the saved
81
+ * check receipt read now (with any follow-up check on the same commit). Fail closed: the check passed only when the
82
+ * receipt read now says so. A verdict that recorded a pass whose receipt is missing, says nothing ran, or can't be
83
+ * read is unreadable; a verdict that recorded a failure stays failed unless a later check on the same commit passed.
84
+ * `checks` undefined or null: nothing was read. Returns the check as every surface shows it (null: nothing to show).
85
+ */
86
+ export declare function approvedCheckOf(verdict: string | null | undefined, reasons: readonly string[], checks: ChecksFact | null | undefined): ChecksFact | null;
87
+ /** How the approved check reads, in one word every surface shares (from `approvedCheckOf`'s answer): `running` while a
88
+ * check is underway on the commit, else what it recorded. `unreadable`: it couldn't be read or the records disagree. */
89
+ export type ApprovedCheckState = "passed" | "failed" | "running" | "not-run" | "off" | "unreadable";
90
+ export declare function approvedCheckStateOf(checks: Pick<ChecksFact, "status" | "level" | "release" | "running" | "batch"> | null | undefined): ApprovedCheckState | null;
91
+ /** A saved check that can't be read, in the words every surface uses. */
92
+ export declare const CHECK_UNREADABLE = "The check result couldn't be read.";
93
+ export declare const CHECK_UNREADABLE_ASK = "The check result couldn't be read. Run checks on it, or open the result to see why.";
94
+ /** A saved check whose files are intact but whose command was approved again since it ran. */
95
+ export declare const CHECK_COMMAND_CHANGED = "The check command changed since this check; run checks again.";
73
96
  /** What stands between a finished result and Complete (`completionBlockersOf`): each with the exact next step. */
74
97
  export type CompletionBlocker = {
75
98
  key: "check-failed" | "check-missing" | "criteria" | "high";
@@ -224,7 +247,7 @@ export declare function requirementsOf(matrix: readonly RequirementRow[] | null
224
247
  * the rest); an unresolved HIGH review finding. A release check that covers the commit counts as passed. */
225
248
  export declare function completionBlockersOf(f: {
226
249
  report: boolean;
227
- checks: Pick<ChecksFact, "status" | "exitCode" | "level" | "release" | "running" | "batch"> | null;
250
+ checks: Pick<ChecksFact, "status" | "exitCode" | "level" | "release" | "running" | "batch" | "cause"> | null;
228
251
  checkRequired: boolean;
229
252
  matrix: readonly RequirementRow[] | null | undefined;
230
253
  verdict: string | null | undefined;
@@ -235,6 +258,10 @@ export declare function completionBlockersOf(f: {
235
258
  export declare function unverifiedWhenRefuted(requirements: NonNullable<TaskStatusFacts["requirements"]> | null, verdict: string | null | undefined): NonNullable<TaskStatusFacts["requirements"]> | null;
236
259
  /** Saved evidence health from the receipt's artifact list and its caveats. */
237
260
  export declare function evidenceOf(receipt: AssignmentSnapshot["receipt"], problems?: readonly string[]): NonNullable<TaskStatusFacts["evidence"]> | null;
261
+ /** A saved check reading as the shared fact (head, level, a follow-up running, a batch, release coverage). */
262
+ export declare function checksFactOf(checks: NonNullable<AssignmentSnapshot["receipt"]>["checks"], head: string | null): ChecksFact;
263
+ /** A receipt's approved check, as every surface reads it (`approvedCheckOf` over its verdict and its saved check). */
264
+ export declare function receiptChecksOf(receipt: NonNullable<AssignmentSnapshot["receipt"]>): ChecksFact | null;
238
265
  /** The status facts of one assignment, as every surface reads them. */
239
266
  export declare function assignmentStatusFacts(assignment: AssignmentSnapshot, options?: {
240
267
  work?: {
@@ -12,6 +12,7 @@
12
12
  * technical reason stays one tap away in `why`. */
13
13
  import { DEFAULT_LEAD_NAME } from "./lead-identity.js";
14
14
  import { html } from "./html.js";
15
+ import { FAILED_CHECK } from "./result-acts.js";
15
16
  import { CODE_NEED, NEEDS, needSentence, waitSentence } from "./needs-you.js";
16
17
  /** A cancelled task with a successor reads "Replaced by <id>" everywhere, never "Cancelled". */
17
18
  export const replacedWords = (successor) => `Replaced by ${successor}`;
@@ -38,6 +39,67 @@ export function releaseStateOf(checks) {
38
39
  export function checkBackingOf(checks) {
39
40
  return checks?.status === "passed" ? "covered" : checksUnderway(checks) ? "running" : releaseStateOf(checks);
40
41
  }
42
+ /**
43
+ * Did the approved check pass for this result? The ONE answer the status headline and sentence, the Project checks
44
+ * row, the road's Checks step and the result page all read, so none of them can say "passed" while another says the
45
+ * check couldn't be read. Two records speak to it: the machine verdict sealed when the build finished, and the saved
46
+ * check receipt read now (with any follow-up check on the same commit). Fail closed: the check passed only when the
47
+ * receipt read now says so. A verdict that recorded a pass whose receipt is missing, says nothing ran, or can't be
48
+ * read is unreadable; a verdict that recorded a failure stays failed unless a later check on the same commit passed.
49
+ * `checks` undefined or null: nothing was read. Returns the check as every surface shows it (null: nothing to show).
50
+ */
51
+ export function approvedCheckOf(verdict, reasons, checks) {
52
+ let failedExit = null;
53
+ for (const reason of reasons) {
54
+ const found = FAILED_CHECK.exec(reason);
55
+ if (found !== null) {
56
+ failedExit = Number(found[1]);
57
+ break;
58
+ }
59
+ }
60
+ const recordedFail = verdict === "refuted" && failedExit !== null;
61
+ const recordedPass = verdict === "verified";
62
+ const read = checks ?? null;
63
+ if (read === null) {
64
+ if (recordedFail)
65
+ return { status: "failed", exitCode: failedExit, head: null };
66
+ return recordedPass ? { status: "unavailable", exitCode: null, head: null } : null;
67
+ }
68
+ if (read.status === "passed" || read.status === "failed" || read.status === "running")
69
+ return read;
70
+ // Checks Off covered by a passing release check read as passed (the row says on which commit); nothing to correct.
71
+ if (read.level === "off" && read.release != null && !recordedFail)
72
+ return read;
73
+ if (recordedFail)
74
+ return { ...read, status: "failed", exitCode: failedExit };
75
+ // The verdict says the check passed, the receipt read now can't show it: the two disagree, so it doesn't count.
76
+ if (recordedPass)
77
+ return { ...read, status: "unavailable", exitCode: null };
78
+ return read;
79
+ }
80
+ export function approvedCheckStateOf(checks) {
81
+ if (checks == null)
82
+ return null;
83
+ // A failure stands while a new check runs: only its result can change the answer. A check that couldn't be read (a
84
+ // result waiting for its batch check has none yet) reads running while one is underway, and never passed.
85
+ if (checks.status === "failed")
86
+ return "failed";
87
+ if (checksUnderway(checks) || checks.status === "running")
88
+ return "running";
89
+ if (checks.status === "unavailable")
90
+ return "unreadable";
91
+ if (checks.status === "passed")
92
+ return "passed";
93
+ if (checks.level === "off")
94
+ return checks.release != null ? "passed" : "off";
95
+ return "not-run";
96
+ }
97
+ /** A saved check that can't be read, in the words every surface uses. */
98
+ export const CHECK_UNREADABLE = "The check result couldn't be read.";
99
+ export const CHECK_UNREADABLE_ASK = `${CHECK_UNREADABLE} Run checks on it, or open the result to see why.`;
100
+ /** A saved check whose files are intact but whose command was approved again since it ran. */
101
+ export const CHECK_COMMAND_CHANGED = "The check command changed since this check; run checks again.";
102
+ const unreadableAsk = (checks) => checks?.cause === "command-changed" ? CHECK_COMMAND_CHANGED : CHECK_UNREADABLE_ASK;
41
103
  /** "T2", "T2 and T3", "T2, T3 and 2 more": short enough for one line. The full list is on the result. */
42
104
  export function peerWords(peers, shown = 2) {
43
105
  if (peers.length <= shown)
@@ -65,10 +127,11 @@ function resultAsk(facts) {
65
127
  if (blocker !== undefined)
66
128
  return blocker.message;
67
129
  const req = facts.requirements;
68
- if (req == null || facts.accepted === true || req.unverified === true)
69
- return null;
70
- if ((req.yours > 0 || (req.unshown ?? 0) > 0) && req.ask != null)
130
+ if (req != null && facts.accepted !== true && req.unverified !== true && (req.yours > 0 || (req.unshown ?? 0) > 0) && req.ask != null)
71
131
  return req.ask;
132
+ // A check that can't be read is never a pass: a person runs it again or looks at why, unless they already accepted.
133
+ if (facts.accepted !== true && approvedCheckStateOf(facts.checks) === "unreadable")
134
+ return unreadableAsk(facts.checks);
72
135
  return null;
73
136
  }
74
137
  export function headlineOf(facts) {
@@ -122,6 +185,8 @@ function sentenceOf(headline, facts) {
122
185
  }
123
186
  if (facts.checks?.batch?.state === "waiting")
124
187
  return "Its full check runs with other results within 10 minutes. Review the change, then mark it complete.";
188
+ if (facts.checks?.status === "unavailable")
189
+ return `${facts.checks.cause === "command-changed" ? CHECK_COMMAND_CHANGED : CHECK_UNREADABLE} Review the change, then mark it complete.`;
125
190
  // Never claim a check that isn't known to have passed.
126
191
  if (facts.checks == null)
127
192
  return "Review the change, then mark it complete.";
@@ -155,7 +220,11 @@ function detailsOf(headline, facts) {
155
220
  const batch = checks.batch ?? null;
156
221
  const together = batch === null ? null : checkedTogetherWords(batch);
157
222
  const batchWhy = batch === null ? null : BATCH_WHY[batch.state] ?? null;
158
- if (batch?.state === "waiting")
223
+ // A failure or an unreadable check keeps its words while a new check runs, so the row never reads better than the answer.
224
+ const again = checksUnderway(checks) && checks.status === "failed" ? " · running again" : "";
225
+ if (again !== "")
226
+ row("checks", CHECKS_LABEL, `${quick ? "Quick checks failed" : "Failed"}${checks.exitCode === null ? "" : ` (exit ${checks.exitCode})`}${again}`, problem(headline), headline === "Failed" ? { href: checksHref } : { action: { label: "See what failed", href: checksHref } });
227
+ else if (batch?.state === "waiting")
159
228
  row("checks", CHECKS_LABEL, "Waiting to check with other results", "running", { href: checksHref });
160
229
  else if (checks.running != null)
161
230
  row("checks", CHECKS_LABEL, `${checks.running === "quick" ? "Quick" : "Full"} checks running`, "running", { href: checksHref });
@@ -178,6 +247,8 @@ function detailsOf(headline, facts) {
178
247
  else if (checks.status === "not-run")
179
248
  row("checks", CHECKS_LABEL, "Didn't run", "none", runChecks === null ? {} : { action: runChecks });
180
249
  // A saved check that can't be read is run again where that is possible.
250
+ else if (checks.cause === "command-changed")
251
+ row("checks", CHECKS_LABEL, "Check command changed since", "note", { action: runChecks ?? { label: OPEN_RESULT, href: facts.links?.result ?? null }, why: CHECK_COMMAND_CHANGED });
181
252
  else
182
253
  row("checks", CHECKS_LABEL, "Couldn't be read", "note", { action: runChecks ?? { label: OPEN_RESULT, href: facts.links?.result ?? null } });
183
254
  }
@@ -255,7 +326,7 @@ export function statusOf(facts) {
255
326
  const primaryAction = need === null || ownWords ? facts.action ?? null : { label: need.action.label, href: facts.action?.href ?? null };
256
327
  const sentence = lead === "on-it" ? leadSentence(headline, facts) : lead === "lapsed" ? `${leadLapsed(facts.leadName)} ${sentenceOf(headline, facts)}` : sentenceOf(headline, facts);
257
328
  return { headline, tone: HEADLINE_TONE[headline], sentence, details: detailsOf(headline, facts),
258
- primaryAction, why: [...new Set(facts.why ?? [])].filter(one => one.trim() !== ""), need };
329
+ primaryAction, why: [...new Set(facts.why ?? [])].filter(one => one.trim() !== ""), need, check: facts.report ? null : approvedCheckStateOf(facts.checks) };
259
330
  }
260
331
  /** The name most surfaces already import. */
261
332
  export const taskStatusOf = statusOf;
@@ -267,7 +338,7 @@ const CODE_STAGE = {
267
338
  "waiting-dependency": ["queued"], "scouting-ready": ["queued"], "planning-ready": ["queued"], "provider-quota": ["queued"],
268
339
  // A request the planner cannot be given (too long to hand back, say) waits on a person to shorten it.
269
340
  "planner-source": ["needs-you", "fix-request"],
270
- running: ["building"], reviewing: ["reviewing"], "review-pending": ["building"],
341
+ running: ["building"], reviewing: ["reviewing"], "review-pending": ["building"], "checks-running": ["checking"],
271
342
  "signed-out": ["needs-you", "sign-in"],
272
343
  "needs-approval": ["needs-you", "approval"],
273
344
  "waiting-decision": ["needs-you", "answer"], "decision-queue": ["needs-you", "answer"],
@@ -432,7 +503,8 @@ export function completionBlockersOf(f) {
432
503
  }
433
504
  else if (!f.report && f.checkRequired && f.checks?.status !== "passed" && release === undefined) {
434
505
  blockers.push({ key: "check-missing", message: checksUnderway(f.checks) ? "Its project check hasn't finished yet. Mark it complete once it passes."
435
- : "No passing project check is recorded for this result. Run checks on it, then mark it complete." });
506
+ : f.checks?.status === "unavailable" ? f.checks.cause === "command-changed" ? `${CHECK_COMMAND_CHANGED.replace(/; run checks again\.$/, ".")} Run checks again, then mark it complete.` : `${CHECK_UNREADABLE} Run checks on it, then mark it complete.`
507
+ : "No passing project check is recorded for this result. Run checks on it, then mark it complete." });
436
508
  }
437
509
  if (!f.accepted && f.checks?.status !== "failed") {
438
510
  const refuted = f.verdict === "refuted";
@@ -457,11 +529,24 @@ export function unverifiedWhenRefuted(requirements, verdict) {
457
529
  export function evidenceOf(receipt, problems = receipt?.caveats ?? []) {
458
530
  if (receipt === null)
459
531
  return null;
532
+ // The check's own reading is the Project checks row's to say (a changed command is not a missing file).
533
+ problems = problems.filter(one => one !== receipt.checks.detail);
460
534
  const shortened = receipt.artifacts.filter(one => !one.complete).length + problems.filter(one => /shortened|cut short/.test(one)).length;
461
535
  const damaged = problems.filter(one => /unavailable or changed|no longer verif|cannot be read|could not be read|failed capture|altered|damaged/i.test(one)).length;
462
536
  const missing = problems.filter(one => /missing|ambiguous|no longer exists/i.test(one) && !/unavailable or changed/.test(one)).length;
463
537
  return { shortened, missing, damaged };
464
538
  }
539
+ /** A saved check reading as the shared fact (head, level, a follow-up running, a batch, release coverage). */
540
+ export function checksFactOf(checks, head) {
541
+ return { status: checks.status, exitCode: checks.exitCode, head,
542
+ ...(checks.level == null ? {} : { level: checks.level }), ...(checks.running == null ? {} : { running: checks.running }),
543
+ ...(checks.batch == null ? {} : { batch: checks.batch }), ...(checks.release == null ? {} : { release: checks.release }),
544
+ ...(checks.cause == null ? {} : { cause: checks.cause }) };
545
+ }
546
+ /** A receipt's approved check, as every surface reads it (`approvedCheckOf` over its verdict and its saved check). */
547
+ export function receiptChecksOf(receipt) {
548
+ return approvedCheckOf(receipt.proof?.verdict ?? null, receipt.proof?.reasons ?? [], checksFactOf(receipt.checks, receipt.head));
549
+ }
465
550
  /** The status facts of one assignment, as every surface reads them. */
466
551
  export function assignmentStatusFacts(assignment, options = {}) {
467
552
  const { stage, need, wait } = assignmentStageOf(assignment, options.work ?? null, options.planning ?? false);
@@ -471,10 +556,7 @@ export function assignmentStatusFacts(assignment, options = {}) {
471
556
  // A saved result's rows show whenever it is the reason a person is needed, too.
472
557
  const withResult = finished || stage === "failed" || ((stage === "needs-you" || stage === "waiting") && receipt !== null);
473
558
  const report = receipt?.completionKind === "research-report";
474
- const checks = receipt === null || !withResult ? null
475
- : { status: receipt.checks.status, exitCode: receipt.checks.exitCode, head: receipt.head,
476
- ...(receipt.checks.level == null ? {} : { level: receipt.checks.level }), ...(receipt.checks.running == null ? {} : { running: receipt.checks.running }),
477
- ...(receipt.checks.batch == null ? {} : { batch: receipt.checks.batch }), ...(receipt.checks.release == null ? {} : { release: receipt.checks.release }) };
559
+ const checks = receipt === null || !withResult ? null : receiptChecksOf(receipt);
478
560
  const publication = assignment.publication;
479
561
  const pullRequest = options.pullRequest !== undefined ? options.pullRequest
480
562
  : publication === null ? (withResult && !report ? { state: "none", number: null, url: null, ci: null, error: null } : null)
@@ -33,4 +33,30 @@ export declare function checkoutIncludes(checkout: string): boolean;
33
33
  * program (anything but INERT_LFS). A file that
34
34
  * isn't a plain one, or doesn't parse, counts as naming one. */
35
35
  export declare function lfsExtensionIn(checkout: string): boolean;
36
- export declare function checkoutGit(inner?: Runner): Runner;
36
+ /** `mode` "read" is for reading a checkout an agent may still be writing (the code page): every command also takes
37
+ * readFlags() and runs against the checkout's readView, so neither its config nor its info/attributes can change
38
+ * between the inspection and the run. */
39
+ export declare function checkoutGit(inner?: Runner, mode?: "build" | "read"): Runner;
40
+ /**
41
+ * Flags for reading a checkout an agent writes while a page waits (docs/plans/get-side-effects.md). Command-line
42
+ * settings win over anything the checkout's config says, even one changed after it was inspected: no fsmonitor, hooks,
43
+ * pager or credential helper; no network (lazy fetch off, every protocol refused); and attributes read from the empty
44
+ * tree, so no filter or textconv a .gitattributes names can run. A diff also takes --no-ext-diff --no-textconv.
45
+ */
46
+ export declare const PAGE_READ_FLAGS: readonly string[];
47
+ /** The read flags, for every read of an agent-written checkout, whatever the HTTP method (security review of
48
+ * 01bf3114): the worktree's attributes come from the empty tree. Git still reads the repository's info/attributes and
49
+ * its config as it starts, so the flags alone don't stop a filter planted in both after the inspection: every read
50
+ * also runs against the checkout's readView (checkoutGitSync, checkoutGit "read"), whose config and info are the plane's. The cost is cosmetic: a checkout's line-ending or encoding rules are not applied, so
51
+ * a file they would normalize can read as changed (fail closed: shipping then asks for a clean commit). */
52
+ export declare function readFlags(): readonly string[];
53
+ /**
54
+ * checkoutGit, synchronously, for reads a page shows from a checkout an agent writes (docs/plans/get-side-effects.md):
55
+ * the same refusals (an include, an .lfsconfig extension, a config key that can run a command), no system or global
56
+ * config, the operator's own values carried, PAGE_READ_FLAGS and the checkout's readView (which hold even if its config
57
+ * or info/attributes change after they were read), submodules skipped, bounded. A refusal throws.
58
+ */
59
+ export declare function checkoutGitSync(cwd: string, args: readonly string[], options?: {
60
+ timeoutMs?: number;
61
+ maxBuffer?: number;
62
+ }): string;
@@ -11,7 +11,8 @@
11
11
  * nothing is removed.
12
12
  */
13
13
  import { spawnSync } from "node:child_process";
14
- import { existsSync, lstatSync, readdirSync, readFileSync } from "node:fs";
14
+ import { existsSync, lstatSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
15
+ import { tmpdir } from "node:os";
15
16
  import { join, resolve } from "node:path";
16
17
  import { run } from "./exec.js";
17
18
  import { ENV, ENV_ALLOWLIST } from "./remote-main.js";
@@ -166,47 +167,112 @@ export function teardownGit(runner = run) {
166
167
  * that can't be read so counts as including.
167
168
  */
168
169
  export function checkoutIncludes(checkout) {
169
- const regular = (path) => {
170
- try {
171
- const held = lstatSync(path);
172
- if (!held.isFile() || held.size > 1024 * 1024)
173
- return null;
174
- return readFileSync(path, "utf8");
175
- }
176
- catch {
170
+ const dirs = gitDirsOf(checkout);
171
+ if (dirs === null)
172
+ return true;
173
+ for (const path of [join(dirs.common, "config"), join(dirs.gitdir, "config.worktree")]) {
174
+ if (!existsSync(path) && path.endsWith("config.worktree"))
175
+ continue;
176
+ if (configIncludes(path))
177
+ return true;
178
+ }
179
+ return false;
180
+ }
181
+ /** One config file, read only as the regular file it is (bounded), or null. */
182
+ function regularFile(path) {
183
+ try {
184
+ const held = lstatSync(path);
185
+ if (!held.isFile() || held.size > 1024 * 1024)
177
186
  return null;
178
- }
179
- };
187
+ return readFileSync(path, "utf8");
188
+ }
189
+ catch {
190
+ return null;
191
+ }
192
+ }
193
+ /** A checkout's git directory and common directory, as git finds them from its `.git` (a folder, or a one-line
194
+ * `gitdir: ` file); null when the pointer isn't one git would read the same way. */
195
+ function gitDirsOf(checkout) {
180
196
  let gitdir = join(checkout, ".git");
181
197
  try {
182
198
  if (!lstatSync(gitdir).isDirectory()) {
183
199
  // As git reads a .git file: "gitdir: " then the path, one line; anything else (more lines, stray space) refused.
184
- const text = (regular(gitdir) ?? "").replace(/\r?\n$/, "");
200
+ const text = (regularFile(gitdir) ?? "").replace(/\r?\n$/, "");
185
201
  if (!text.startsWith("gitdir: ") || /[\r\n]/.test(text))
186
- return true;
202
+ return null;
187
203
  const pointer = text.slice("gitdir: ".length);
188
204
  if (pointer === "" || pointer !== pointer.trim())
189
- return true;
205
+ return null;
190
206
  gitdir = resolve(checkout, pointer);
191
207
  }
192
208
  }
193
209
  catch {
210
+ return null;
211
+ }
212
+ const named = regularFile(join(gitdir, "commondir"))?.trim();
213
+ return { gitdir, common: named === undefined || named === "" ? gitdir : resolve(gitdir, named) };
214
+ }
215
+ /** Whether one config file includes another (or can't be read as a plain file): by a plain reading, and as git itself
216
+ * parses it, includes not followed (only this one regular file, from a neutral folder, with no other config read). */
217
+ function configIncludes(path) {
218
+ const text = regularFile(path);
219
+ if (text === null || /^\s*\[\s*include(if)?\b/im.test(text))
194
220
  return true;
221
+ const parsed = spawnSync("git", ["config", "--file", path, "--no-includes", "--name-only", "--list", "-z"], { cwd: "/", encoding: "utf8", timeout: 5_000, env: { PATH: process.env["PATH"] ?? "", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", HOME: "/nonexistent" } });
222
+ return parsed.status !== 0 || parsed.stdout.split("\0").some(name => /^(include\.path|includeif\..*\.path)$/i.test(name));
223
+ }
224
+ function readView(checkout) {
225
+ const dirs = gitDirsOf(checkout);
226
+ if (dirs === null)
227
+ throw new Error("the checkout's .git couldn't be read as git reads it");
228
+ const view = realpathSync(mkdtempSync(join(tmpdir(), "toolroll-git-read-")));
229
+ const dispose = () => rmSync(view, { recursive: true, force: true });
230
+ try {
231
+ let config = regularFile(join(dirs.common, "config"));
232
+ if (config === null)
233
+ throw new Error("the checkout's git config couldn't be read as a plain file");
234
+ const configPath = join(view, "config");
235
+ writeFileSync(configPath, config, { mode: 0o600 });
236
+ const plain = { cwd: "/", encoding: "utf8", timeout: 5_000, env: { PATH: process.env["PATH"] ?? "", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", HOME: "/nonexistent" } };
237
+ if (/worktreeconfig/i.test(config)) {
238
+ const flag = spawnSync("git", ["config", "--file", configPath, "--no-includes", "--type=bool", "--get", "extensions.worktreeConfig"], plain);
239
+ if (flag.status !== 0 && flag.status !== 1)
240
+ throw new Error("the checkout's git config couldn't be read");
241
+ if (flag.stdout.trim() === "true") {
242
+ // Git would also read the worktree's config.worktree, which the agent can still change: folded in as it is now.
243
+ const worktree = join(dirs.gitdir, "config.worktree");
244
+ const own = existsSync(worktree) ? regularFile(worktree) : "";
245
+ if (own === null)
246
+ throw new Error("the checkout's config.worktree couldn't be read as a plain file");
247
+ config = `${config}\n${own}`;
248
+ writeFileSync(configPath, config, { mode: 0o600 });
249
+ }
250
+ const unset = spawnSync("git", ["config", "--file", configPath, "--unset-all", "extensions.worktreeConfig"], plain);
251
+ if (unset.status !== 0 && unset.status !== 5)
252
+ throw new Error("the checkout's git config couldn't be read");
253
+ }
254
+ if (configIncludes(configPath))
255
+ throw new Error("the checkout's git config includes another file");
256
+ mkdirSync(join(view, "info"));
257
+ const exclude = join(dirs.common, "info", "exclude");
258
+ if (existsSync(exclude)) {
259
+ const text = regularFile(exclude);
260
+ if (text !== null)
261
+ writeFileSync(join(view, "info", "exclude"), text, { mode: 0o600 });
262
+ }
263
+ for (const name of readdirSync(dirs.common)) {
264
+ if (name === "config" || name === "info" || name === "hooks")
265
+ continue;
266
+ symlinkSync(join(dirs.common, name), join(view, name));
267
+ }
195
268
  }
196
- const common = (() => { const named = regular(join(gitdir, "commondir"))?.trim(); return named === undefined || named === "" ? gitdir : resolve(gitdir, named); })();
197
- for (const path of [join(common, "config"), join(gitdir, "config.worktree")]) {
198
- if (!existsSync(path) && path.endsWith("config.worktree"))
199
- continue;
200
- const text = regular(path);
201
- if (text === null || /^\s*\[\s*include(if)?\b/im.test(text))
202
- return true;
203
- // And as git itself parses it, includes not followed (only this one regular file, from a neutral folder, with no
204
- // other config read): an include git sees by any spelling is refused.
205
- const parsed = spawnSync("git", ["config", "--file", path, "--no-includes", "--name-only", "--list", "-z"], { cwd: "/", encoding: "utf8", timeout: 5_000, env: { PATH: process.env["PATH"] ?? "", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", HOME: "/nonexistent" } });
206
- if (parsed.status !== 0 || parsed.stdout.split("\0").some(name => /^(include\.path|includeif\..*\.path)$/i.test(name)))
207
- return true;
269
+ catch (error) {
270
+ dispose();
271
+ throw error;
208
272
  }
209
- return false;
273
+ // Where git names the view (rev-parse --git-common-dir), the caller is told the repository's own common directory.
274
+ const restore = (output) => output.split("\n").map(line => line === view || line.startsWith(`${view}/`) ? dirs.common + line.slice(view.length) : line).join("\n");
275
+ return { env: { GIT_DIR: dirs.gitdir, GIT_COMMON_DIR: view, GIT_WORK_TREE: resolve(checkout) }, restore, dispose };
210
276
  }
211
277
  /** Whether the checkout's .lfsconfig (read as git parses it, that file only) sets any git-lfs key that could name a
212
278
  * program (anything but INERT_LFS). A file that
@@ -223,7 +289,10 @@ export function lfsExtensionIn(checkout) {
223
289
  const parsed = spawnSync("git", ["config", "--file", path, "--no-includes", "--name-only", "--list", "-z"], { cwd: "/", encoding: "utf8", timeout: 5_000, env: { PATH: process.env["PATH"] ?? "", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", HOME: "/nonexistent" } });
224
290
  return parsed.status !== 0 || parsed.stdout.split("\0").filter(Boolean).some(name => lfsCommand(name.toLowerCase()) || /^include(if)?\./i.test(name));
225
291
  }
226
- export function checkoutGit(inner = run) {
292
+ /** `mode` "read" is for reading a checkout an agent may still be writing (the code page): every command also takes
293
+ * readFlags() and runs against the checkout's readView, so neither its config nor its info/attributes can change
294
+ * between the inspection and the run. */
295
+ export function checkoutGit(inner = run, mode = "build") {
227
296
  return async (file, args, options) => {
228
297
  if (file !== "git")
229
298
  return inner(file, args, options);
@@ -233,21 +302,98 @@ export function checkoutGit(inner = run) {
233
302
  // git-lfs also reads .lfsconfig from the checkout: one that names an extension (a command it would run) is refused.
234
303
  if (lfsExtensionIn(cwd))
235
304
  return refused("the checkout's .lfsconfig sets a git-lfs key that can run a command");
236
- // The checkout's own config may name no command.
237
- const own = await inner("git", ["--no-optional-locks", "config", "--list", "--show-scope", "-z"], options);
238
- if (own.code !== 0)
239
- return refused("its config couldn't be read");
305
+ let view = null;
306
+ if (mode === "read") {
307
+ try {
308
+ view = readView(cwd);
309
+ }
310
+ catch (error) {
311
+ return refused(error instanceof Error ? error.message : "the checkout couldn't be read");
312
+ }
313
+ }
314
+ try {
315
+ const viewed = { ...options, env: { ...(options?.env ?? {}), ...(view?.env ?? {}) } };
316
+ // The checkout's own config may name no command.
317
+ const own = await inner("git", ["--no-optional-locks", "config", "--list", "--show-scope", "-z"], view === null ? options : viewed);
318
+ if (own.code !== 0)
319
+ return refused("its config couldn't be read");
320
+ const key = commandSetting(own.stdout);
321
+ if (key !== null)
322
+ return refused(`the checkout's git config sets ${key}, which can run a command`);
323
+ // The operator's own config contributes values only (carriedSettings); git then reads no global or system config.
324
+ // A read carries no filter: it reads attributes from the empty tree anyway.
325
+ const carried = view === null ? carriedSettings(own.stdout) : withoutFilters(carriedSettings(own.stdout));
326
+ const env = { ...viewed.env, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null" };
327
+ // Never into a submodule or nested repository, whose own config this never read: status and diff skip them.
328
+ const safeArgs = [...args];
329
+ const command = safeArgs.findIndex(arg => arg === "status" || arg === "diff");
330
+ if (command >= 0 && !safeArgs.includes("--ignore-submodules=all"))
331
+ safeArgs.splice(command + 1, 0, "--ignore-submodules=all");
332
+ const flags = view === null ? [] : readFlags();
333
+ const ran = await inner("git", [...TEARDOWN_FLAGS, ...flags, "-c", "diff.ignoreSubmodules=all", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false", ...carried, ...safeArgs], { ...options, env });
334
+ return view !== null && args.includes("rev-parse") ? { ...ran, stdout: view.restore(ran.stdout) } : ran;
335
+ }
336
+ finally {
337
+ view?.dispose();
338
+ }
339
+ };
340
+ }
341
+ const withoutFilters = (carried) => carried.filter((one, at, all) => !(one.startsWith("filter.") || (one === "-c" && all[at + 1]?.startsWith("filter."))));
342
+ /**
343
+ * Flags for reading a checkout an agent writes while a page waits (docs/plans/get-side-effects.md). Command-line
344
+ * settings win over anything the checkout's config says, even one changed after it was inspected: no fsmonitor, hooks,
345
+ * pager or credential helper; no network (lazy fetch off, every protocol refused); and attributes read from the empty
346
+ * tree, so no filter or textconv a .gitattributes names can run. A diff also takes --no-ext-diff --no-textconv.
347
+ */
348
+ export const PAGE_READ_FLAGS = [
349
+ "--no-lazy-fetch", "--attr-source=4b825dc642cb6eb9a060e54bf8d69288fbee4904",
350
+ "-c", "protocol.allow=never", "-c", "core.pager=cat", "-c", "core.alternateRefsCommand=", "-c", "core.attributesFile=/dev/null",
351
+ ];
352
+ /** The read flags, for every read of an agent-written checkout, whatever the HTTP method (security review of
353
+ * 01bf3114): the worktree's attributes come from the empty tree. Git still reads the repository's info/attributes and
354
+ * its config as it starts, so the flags alone don't stop a filter planted in both after the inspection: every read
355
+ * also runs against the checkout's readView (checkoutGitSync, checkoutGit "read"), whose config and info are the plane's. The cost is cosmetic: a checkout's line-ending or encoding rules are not applied, so
356
+ * a file they would normalize can read as changed (fail closed: shipping then asks for a clean commit). */
357
+ export function readFlags() {
358
+ return PAGE_READ_FLAGS;
359
+ }
360
+ /**
361
+ * checkoutGit, synchronously, for reads a page shows from a checkout an agent writes (docs/plans/get-side-effects.md):
362
+ * the same refusals (an include, an .lfsconfig extension, a config key that can run a command), no system or global
363
+ * config, the operator's own values carried, PAGE_READ_FLAGS and the checkout's readView (which hold even if its config
364
+ * or info/attributes change after they were read), submodules skipped, bounded. A refusal throws.
365
+ */
366
+ export function checkoutGitSync(cwd, args, options = {}) {
367
+ if (checkoutIncludes(cwd))
368
+ throw new Error("the checkout's git config includes another file, or couldn't be read as a plain file");
369
+ if (lfsExtensionIn(cwd))
370
+ throw new Error("the checkout's .lfsconfig sets a git-lfs key that can run a command");
371
+ // Its config and info/attributes as read once, in a folder of the plane's own: neither can change before git runs.
372
+ const view = readView(cwd);
373
+ try {
374
+ const env = { PATH: process.env["PATH"] ?? "", HOME: process.env["HOME"] ?? "", LANG: "C", GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null", GIT_TERMINAL_PROMPT: "0", ...view.env };
375
+ const bounded = { cwd, env, encoding: "utf8", timeout: options.timeoutMs ?? 60_000, maxBuffer: options.maxBuffer ?? 1_048_576, stdio: ["ignore", "pipe", "pipe"] };
376
+ const own = spawnSync("git", ["--no-optional-locks", "config", "--list", "--show-scope", "-z"], bounded);
377
+ if (own.status !== 0)
378
+ throw new Error("its config couldn't be read");
240
379
  const key = commandSetting(own.stdout);
241
380
  if (key !== null)
242
- return refused(`the checkout's git config sets ${key}, which can run a command`);
243
- // The operator's own config contributes values only (carriedSettings); git then reads no global or system config.
244
- const carried = carriedSettings(own.stdout);
245
- const env = { ...(options?.env ?? {}), GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: "/dev/null" };
246
- // Never into a submodule or nested repository, whose own config this never read: status and diff skip them.
381
+ throw new Error(`the checkout's git config sets ${key}, which can run a command`);
247
382
  const safeArgs = [...args];
248
383
  const command = safeArgs.findIndex(arg => arg === "status" || arg === "diff");
249
384
  if (command >= 0 && !safeArgs.includes("--ignore-submodules=all"))
250
385
  safeArgs.splice(command + 1, 0, "--ignore-submodules=all");
251
- return inner("git", [...TEARDOWN_FLAGS, "-c", "diff.ignoreSubmodules=all", "-c", "commit.gpgsign=false", "-c", "tag.gpgsign=false", ...carried, ...safeArgs], { ...options, env });
252
- };
386
+ // An external diff program is named by config, which may change after it was read: never used here.
387
+ if (command >= 0 && safeArgs[command] === "diff")
388
+ safeArgs.splice(command + 1, 0, "--no-ext-diff", "--no-textconv");
389
+ // The operator's own values, but no filter: PAGE_READ_FLAGS reads attributes from the empty tree anyway.
390
+ const carried = withoutFilters(carriedSettings(own.stdout));
391
+ const ran = spawnSync("git", [...TEARDOWN_FLAGS, ...readFlags(), "-c", "diff.ignoreSubmodules=all", ...carried, ...safeArgs], bounded);
392
+ if (ran.status !== 0)
393
+ throw new Error(`git ${args[0] ?? ""} failed`);
394
+ return args.includes("rev-parse") ? view.restore(ran.stdout) : ran.stdout;
395
+ }
396
+ finally {
397
+ view.dispose();
398
+ }
253
399
  }
@@ -7,7 +7,7 @@
7
7
  import { assignmentOf } from "./assignment.js";
8
8
  import { chatResultHref, chatControlHref } from "./chat-controls.js";
9
9
  import { phoneText, projectLabel } from "./telegram-status.js";
10
- import { assignmentStatusFacts, headlineEmoji, pullRequestFactOf, requirementsOf, statusDetailLines, unverifiedWhenRefuted, taskStatusOf } from "./task-status.js";
10
+ import { approvedCheckOf, assignmentStatusFacts, checksFactOf, headlineEmoji, pullRequestFactOf, requirementsOf, statusDetailLines, unverifiedWhenRefuted, taskStatusOf } from "./task-status.js";
11
11
  import { leadClaimOf } from "./lead-voice.js";
12
12
  import { leadNameOf } from "./lead-identity.js";
13
13
  import { chatTitle } from "./chat-voice.js";
@@ -46,10 +46,10 @@ export function telegramProgressCard(store, run, taskId, project, now = new Date
46
46
  const proof = store.proofVerdictFor(run.id);
47
47
  const machine = proof?.machineVerdict ?? proof?.verdict ?? null;
48
48
  const exit = failedCheckExit(proof?.reasons ?? []);
49
- const checks = recorded !== null ? { status: recorded.status, exitCode: recorded.exitCode, head: run.headRevision }
49
+ // The one answer (task-status.ts approvedCheckOf) when a saved check was read; a verdict alone claims no pass.
50
+ const checks = recorded !== null ? approvedCheckOf(machine, proof?.reasons ?? [], checksFactOf(recorded, run.headRevision))
50
51
  : exit !== null ? { status: "failed", exitCode: exit, head: run.headRevision }
51
- : machine === "verified" ? { status: "passed", exitCode: null, head: run.headRevision }
52
- : machine === "attested" ? { status: "not-run", exitCode: null, head: null } : null;
52
+ : machine === "attested" ? { status: "not-run", exitCode: null, head: null } : null;
53
53
  facts = { stage: "finished", report: run.role === "scout", checks, requirements: unverifiedWhenRefuted(requirementsOf(proof?.matrix), proof?.verdict),
54
54
  ...(pullRequest === undefined ? {} : { pullRequest }) };
55
55
  }