@andorra-labs/code 0.1.15 → 0.1.17

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 (242) hide show
  1. package/dist/src/acp-agent.d.ts +6 -0
  2. package/dist/src/acp-agent.js +15 -4
  3. package/dist/src/agent-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +15 -10
  5. package/dist/src/agent-mcp-catalog.js +1 -0
  6. package/dist/src/agent-mcp.d.ts +4 -1
  7. package/dist/src/agent-mcp.js +46 -10
  8. package/dist/src/andorra/entry.d.ts +10 -0
  9. package/dist/src/andorra/entry.js +18 -4
  10. package/dist/src/andorra/hosted.d.ts +2 -1
  11. package/dist/src/andorra/hosted.js +2 -1
  12. package/dist/src/andorra/notices.d.ts +5 -0
  13. package/dist/src/andorra/notices.js +7 -0
  14. package/dist/src/andorra/state.d.ts +3 -2
  15. package/dist/src/andorra/state.js +4 -4
  16. package/dist/src/andorra/terminal.js +7 -2
  17. package/dist/src/anthropic-credentials.js +2 -0
  18. package/dist/src/app-server/error.d.ts +5 -0
  19. package/dist/src/app-server/error.js +7 -0
  20. package/dist/src/app-server/protocol.d.ts +22 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +89 -0
  23. package/dist/src/app-server/workspace.js +457 -11
  24. package/dist/src/app-server.d.ts +465 -32
  25. package/dist/src/app-server.js +3308 -517
  26. package/dist/src/auth/deployment.js +2 -2
  27. package/dist/src/bridge/cloud.d.ts +27 -0
  28. package/dist/src/bridge/cloud.js +187 -0
  29. package/dist/src/bridge/command.d.ts +30 -0
  30. package/dist/src/bridge/command.js +347 -0
  31. package/dist/src/bridge/control.d.ts +68 -0
  32. package/dist/src/bridge/control.js +233 -0
  33. package/dist/src/bridge/engines.d.ts +90 -0
  34. package/dist/src/bridge/engines.js +601 -0
  35. package/dist/src/bridge/host-ops.d.ts +9 -0
  36. package/dist/src/bridge/host-ops.js +129 -0
  37. package/dist/src/bridge/host.d.ts +47 -0
  38. package/dist/src/bridge/host.js +540 -0
  39. package/dist/src/bridge/link.d.ts +38 -0
  40. package/dist/src/bridge/link.js +508 -0
  41. package/dist/src/bridge/login-link.d.ts +29 -0
  42. package/dist/src/bridge/login-link.js +54 -0
  43. package/dist/src/bridge/protocol.d.ts +136 -0
  44. package/dist/src/bridge/protocol.js +11 -0
  45. package/dist/src/bridge/store.d.ts +12 -0
  46. package/dist/src/bridge/store.js +61 -0
  47. package/dist/src/bridge/wording.d.ts +6 -0
  48. package/dist/src/bridge/wording.js +10 -0
  49. package/dist/src/browser-runner.js +1 -0
  50. package/dist/src/browser-server.js +7 -1
  51. package/dist/src/browser-ui/style.css +3 -3
  52. package/dist/src/browser-ui/tokens.css +28 -17
  53. package/dist/src/change-authors.d.ts +41 -0
  54. package/dist/src/change-authors.js +146 -0
  55. package/dist/src/claude-provider.js +3 -1
  56. package/dist/src/cli.js +202 -38
  57. package/dist/src/codex-errors.js +4 -1
  58. package/dist/src/coding-tools.js +15 -15
  59. package/dist/src/command-screens.d.ts +6 -0
  60. package/dist/src/command-screens.js +19 -14
  61. package/dist/src/commands.d.ts +14 -1
  62. package/dist/src/compaction-phrases.d.ts +4 -0
  63. package/dist/src/compaction-phrases.js +20 -0
  64. package/dist/src/completion.js +82 -5
  65. package/dist/src/config.d.ts +71 -3
  66. package/dist/src/config.js +202 -77
  67. package/dist/src/context-compaction.js +2 -1
  68. package/dist/src/deadline.js +13 -1
  69. package/dist/src/decision/DecisionManager.js +3 -2
  70. package/dist/src/decision/checks.js +1 -1
  71. package/dist/src/decision/requestPhrases.d.ts +4 -0
  72. package/dist/src/decision/requestPhrases.js +22 -0
  73. package/dist/src/default-graph.js +1 -1
  74. package/dist/src/file-diff.d.ts +4 -0
  75. package/dist/src/file-diff.js +2 -1
  76. package/dist/src/github-app/agent-writes.d.ts +102 -0
  77. package/dist/src/github-app/agent-writes.js +320 -0
  78. package/dist/src/github-app/client.d.ts +349 -0
  79. package/dist/src/github-app/client.js +810 -0
  80. package/dist/src/github-app/event-source.d.ts +208 -0
  81. package/dist/src/github-app/event-source.js +684 -0
  82. package/dist/src/github-app/metrics.d.ts +32 -0
  83. package/dist/src/github-app/metrics.js +49 -0
  84. package/dist/src/github-app/review-loop.d.ts +274 -0
  85. package/dist/src/github-app/review-loop.js +1177 -0
  86. package/dist/src/github-app/review-node.d.ts +81 -0
  87. package/dist/src/github-app/review-node.js +205 -0
  88. package/dist/src/github-app/review-post.d.ts +73 -0
  89. package/dist/src/github-app/review-post.js +139 -0
  90. package/dist/src/github-app/review-text.d.ts +107 -0
  91. package/dist/src/github-app/review-text.js +1133 -0
  92. package/dist/src/github-app/review-threads.d.ts +47 -0
  93. package/dist/src/github-app/review-threads.js +107 -0
  94. package/dist/src/github-app/reviewer.d.ts +121 -0
  95. package/dist/src/github-app/reviewer.js +598 -0
  96. package/dist/src/github-app/store.d.ts +59 -0
  97. package/dist/src/github-app/store.js +148 -0
  98. package/dist/src/github-app/triggers.d.ts +141 -0
  99. package/dist/src/github-app/triggers.js +441 -0
  100. package/dist/src/github-inbox.d.ts +55 -0
  101. package/dist/src/github-inbox.js +153 -0
  102. package/dist/src/github-names.d.ts +8 -0
  103. package/dist/src/github-names.js +8 -0
  104. package/dist/src/glob-search.d.ts +61 -0
  105. package/dist/src/glob-search.js +180 -0
  106. package/dist/src/graph-health.js +13 -4
  107. package/dist/src/graph-manager-chat.js +1 -1
  108. package/dist/src/graph-preview.d.ts +46 -0
  109. package/dist/src/graph-preview.js +55 -0
  110. package/dist/src/graph-provider-portability.js +34 -11
  111. package/dist/src/graph-quota.d.ts +29 -2
  112. package/dist/src/graph-quota.js +68 -10
  113. package/dist/src/graph-runner.js +88 -10
  114. package/dist/src/graph-server.d.ts +1 -1
  115. package/dist/src/graph-server.js +11 -9
  116. package/dist/src/graph-sync.js +3 -3
  117. package/dist/src/graph-ui/app.js +201 -40
  118. package/dist/src/graph-ui/controls.css +1 -0
  119. package/dist/src/graph-ui/embed.js +2 -2
  120. package/dist/src/graph-ui/icons.js +3 -1
  121. package/dist/src/graph-ui/index.html +1 -1
  122. package/dist/src/graph-ui/manager.css +1 -1
  123. package/dist/src/graph-ui/manager.js +2 -2
  124. package/dist/src/graph-ui/sidebar.js +30 -0
  125. package/dist/src/graph-ui/studio-canvas.js +26 -13
  126. package/dist/src/graph-ui/studio.css +15 -7
  127. package/dist/src/graph-ui/studio.js +26 -5
  128. package/dist/src/graph-ui/style.css +77 -45
  129. package/dist/src/graph-ui/theme.js +3 -36
  130. package/dist/src/graph-ui/tokens.css +28 -20
  131. package/dist/src/graphs.d.ts +34 -1
  132. package/dist/src/graphs.js +162 -17
  133. package/dist/src/image-input.d.ts +16 -0
  134. package/dist/src/image-input.js +41 -0
  135. package/dist/src/membership.d.ts +30 -1
  136. package/dist/src/membership.js +48 -8
  137. package/dist/src/model-health-cache.js +1 -1
  138. package/dist/src/model-metadata.d.ts +7 -1
  139. package/dist/src/model-metadata.js +39 -17
  140. package/dist/src/model-relay/local.d.ts +116 -0
  141. package/dist/src/model-relay/local.js +468 -0
  142. package/dist/src/model-relay/remote.d.ts +129 -0
  143. package/dist/src/model-relay/remote.js +252 -0
  144. package/dist/src/model-relay/runs.d.ts +34 -0
  145. package/dist/src/model-relay/runs.js +146 -0
  146. package/dist/src/model-relay/wire.d.ts +5 -0
  147. package/dist/src/model-relay/wire.js +5 -0
  148. package/dist/src/plan-pass.d.ts +59 -0
  149. package/dist/src/plan-pass.js +165 -0
  150. package/dist/src/project-registry.d.ts +21 -0
  151. package/dist/src/project-registry.js +74 -0
  152. package/dist/src/provider-engine.js +3 -0
  153. package/dist/src/provider-import.d.ts +0 -12
  154. package/dist/src/provider-import.js +7 -195
  155. package/dist/src/providers.d.ts +40 -2
  156. package/dist/src/providers.js +93 -23
  157. package/dist/src/pull-request-checks.d.ts +26 -0
  158. package/dist/src/pull-request-checks.js +56 -0
  159. package/dist/src/pull-request-conversation.d.ts +134 -0
  160. package/dist/src/pull-request-conversation.js +221 -0
  161. package/dist/src/pull-request-create.d.ts +175 -0
  162. package/dist/src/pull-request-create.js +392 -0
  163. package/dist/src/pull-request-details.d.ts +242 -0
  164. package/dist/src/pull-request-details.js +614 -0
  165. package/dist/src/pull-request-edit.d.ts +23 -0
  166. package/dist/src/pull-request-edit.js +91 -0
  167. package/dist/src/pull-request-logs.d.ts +87 -0
  168. package/dist/src/pull-request-logs.js +183 -0
  169. package/dist/src/pull-request-merge.d.ts +112 -0
  170. package/dist/src/pull-request-merge.js +258 -0
  171. package/dist/src/pull-request-review.d.ts +137 -0
  172. package/dist/src/pull-request-review.js +401 -0
  173. package/dist/src/pull-requests.d.ts +369 -8
  174. package/dist/src/pull-requests.js +524 -55
  175. package/dist/src/react-runtime.js +38 -5
  176. package/dist/src/remote/engine-pool.d.ts +88 -4
  177. package/dist/src/remote/engine-pool.js +379 -90
  178. package/dist/src/remote/roots.d.ts +19 -0
  179. package/dist/src/remote/roots.js +45 -7
  180. package/dist/src/remote/types.d.ts +0 -44
  181. package/dist/src/run-control.d.ts +17 -0
  182. package/dist/src/run-control.js +47 -0
  183. package/dist/src/run-progress.d.ts +10 -0
  184. package/dist/src/run-progress.js +122 -0
  185. package/dist/src/run-records.d.ts +7 -2
  186. package/dist/src/run-records.js +71 -6
  187. package/dist/src/runtime.d.ts +9 -1
  188. package/dist/src/runtime.js +24 -4
  189. package/dist/src/session-changes.d.ts +35 -0
  190. package/dist/src/session-changes.js +194 -6
  191. package/dist/src/session-monitor.js +2 -1
  192. package/dist/src/session-reaper.d.ts +1 -1
  193. package/dist/src/session-reaper.js +6 -1
  194. package/dist/src/session-summary.d.ts +2 -1
  195. package/dist/src/session-summary.js +2 -1
  196. package/dist/src/sessions.d.ts +11 -1
  197. package/dist/src/sessions.js +17 -4
  198. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  199. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  200. package/dist/src/skills/bundled/provenance.json +2 -2
  201. package/dist/src/skills/runtime-skills.js +1 -1
  202. package/dist/src/subagent-run.js +1 -0
  203. package/dist/src/telemetry/capture-core.d.ts +17 -0
  204. package/dist/src/telemetry/capture-core.js +59 -1
  205. package/dist/src/telemetry/classify.d.ts +3 -1
  206. package/dist/src/telemetry/classify.js +37 -0
  207. package/dist/src/telemetry/emitter.d.ts +17 -0
  208. package/dist/src/telemetry/emitter.js +76 -5
  209. package/dist/src/telemetry/schema.d.ts +47 -2
  210. package/dist/src/telemetry/schema.js +120 -5
  211. package/dist/src/telemetry/surface.d.ts +3 -1
  212. package/dist/src/telemetry/surface.js +4 -1
  213. package/dist/src/telemetry/uploader.d.ts +6 -1
  214. package/dist/src/telemetry/uploader.js +22 -3
  215. package/dist/src/terminal-ui.d.ts +1 -0
  216. package/dist/src/terminal-ui.js +10 -3
  217. package/dist/src/test-edit-guard.d.ts +7 -0
  218. package/dist/src/test-edit-guard.js +49 -1
  219. package/dist/src/timers.d.ts +2 -0
  220. package/dist/src/tools.js +59 -9
  221. package/dist/src/transcript.js +8 -2
  222. package/dist/src/types.d.ts +7 -0
  223. package/dist/src/usage-analytics.js +18 -10
  224. package/package.json +6 -1
  225. package/dist/src/remote/cert.d.ts +0 -11
  226. package/dist/src/remote/cert.js +0 -87
  227. package/dist/src/remote/client.d.ts +0 -119
  228. package/dist/src/remote/client.js +0 -544
  229. package/dist/src/remote/command.d.ts +0 -4
  230. package/dist/src/remote/command.js +0 -194
  231. package/dist/src/remote/errors.d.ts +0 -11
  232. package/dist/src/remote/errors.js +0 -14
  233. package/dist/src/remote/network.d.ts +0 -22
  234. package/dist/src/remote/network.js +0 -102
  235. package/dist/src/remote/pairing.d.ts +0 -63
  236. package/dist/src/remote/pairing.js +0 -299
  237. package/dist/src/remote/pem.d.ts +0 -2
  238. package/dist/src/remote/pem.js +0 -7
  239. package/dist/src/remote/serve.d.ts +0 -68
  240. package/dist/src/remote/serve.js +0 -244
  241. package/dist/src/remote/server.d.ts +0 -21
  242. package/dist/src/remote/server.js +0 -406
@@ -0,0 +1,81 @@
1
+ import type { ReviewNodeSettings } from '../graphs.js';
2
+ import { type AutoFixWrites, type SessionPullRequest } from '../pull-requests.js';
3
+ import type { GitHubCoverage } from './client.js';
4
+ import { type ReviewLoopController } from './review-loop.js';
5
+ /**
6
+ * The graph form of the Andorra review loop (design/specs/andorra-review-loop.md, "Graphs", R12): a `review` node runs one
7
+ * round per visit on the task's PR and leaves through `findings`, `clean` or `stopped`. The rounds are the chat loop's
8
+ * (the controller's round, its reviewer and its post); this is what decides whether a visit reviews at all.
9
+ */
10
+ export type ReviewNodeOutcome = 'findings' | 'clean' | 'stopped';
11
+ /** Why a visit left through `stopped`: a loop's end reason, or one of the node's own. */
12
+ export type ReviewNodeStop = 'no-pull-request' | 'loop-busy' | 'draft' | 'steered' | 'declined' | 'unavailable' | 'cancelled' | string;
13
+ export interface ReviewNodeFinding {
14
+ priority: 'P1' | 'P2';
15
+ where: 'inline' | 'summary';
16
+ threadId?: string;
17
+ url: string;
18
+ path: string;
19
+ line: number;
20
+ title: string;
21
+ }
22
+ export interface ReviewNodeOutput {
23
+ round: number;
24
+ rounds: number;
25
+ loop?: string;
26
+ head?: string;
27
+ reviewUrl?: string;
28
+ findings: ReviewNodeFinding[];
29
+ nits: number;
30
+ /** Why the node stopped or signed off; '' with findings. Every outcome carries it, so an output schema holds for all. */
31
+ reason: ReviewNodeStop;
32
+ detail?: string;
33
+ /** The graph form of the fixer's prompt, for the `findings` edge to map into the engineer's task; '' otherwise. */
34
+ prompt: string;
35
+ }
36
+ export interface ReviewNodeAnswer {
37
+ outcome: ReviewNodeOutcome;
38
+ output: ReviewNodeOutput;
39
+ summary: string;
40
+ }
41
+ export interface ReviewNodeRequest {
42
+ nodeId: string;
43
+ name: string;
44
+ settings: ReviewNodeSettings;
45
+ signal: AbortSignal;
46
+ /** Asks the person once per loop, where the run's permissions ask; true in full access, false where nobody can answer. */
47
+ approve(question: string): Promise<boolean>;
48
+ emit(type: string, data: Record<string, unknown>): Promise<void> | void;
49
+ }
50
+ export interface ReviewNodeService {
51
+ round(request: ReviewNodeRequest): Promise<ReviewNodeAnswer>;
52
+ }
53
+ export interface ReviewNodeDependencies {
54
+ home: string;
55
+ sessionId: string;
56
+ runId: string;
57
+ controller: Pick<ReviewLoopController, 'startGraphLoop' | 'graphRound' | 'end' | 'adoptGraphLoop'>;
58
+ /** The run this one resumed, whose loop it takes over. */
59
+ resumedFrom?: string;
60
+ /** `github.app.reviews` on this machine. */
61
+ enabled(): Promise<boolean>;
62
+ /** R18: the plan allows Andorra review; a refusal's sentence otherwise. */
63
+ plan(): Promise<string | undefined>;
64
+ coverage(pullRequest: SessionPullRequest): Promise<GitHubCoverage>;
65
+ /** The PR read again now, through the watcher, so the record's state is current. */
66
+ readNow(): Promise<void>;
67
+ /** The PR's head on GitHub now, or undefined when it cannot be read. */
68
+ head(pullRequest: SessionPullRequest): Promise<string | undefined>;
69
+ writes(): Promise<AutoFixWrites>;
70
+ /** The ids of the person's messages to the task not yet delivered: one that comes while a draft waits ends the wait. */
71
+ steers?(): string[];
72
+ bot?: string;
73
+ sleep?(ms: number, signal: AbortSignal): Promise<void>;
74
+ now?(): number;
75
+ }
76
+ export declare const DRAFT_WAIT_MS: number;
77
+ /** A run without the review loop service (a Graph Builder preview, a headless run with no PR watcher). */
78
+ export declare function reviewNodeUnavailable(settings: ReviewNodeSettings): ReviewNodeAnswer;
79
+ export declare function createReviewNodeService(deps: ReviewNodeDependencies): ReviewNodeService;
80
+ /** A graph run ended: a loop it still drives (its fixer never came back) ends with it. */
81
+ export declare function endGraphLoops(home: string, sessionId: string, runId: string, controller: Pick<ReviewLoopController, 'end'>): Promise<void>;
@@ -0,0 +1,205 @@
1
+ import { isFinishedPullRequest, readPullRequest, reviewLoopActive } from '../pull-requests.js';
2
+ import { watcherCovered } from './event-source.js';
3
+ import { coverageRefusal, reviewFixPrompt, ReviewLoopStopping } from './review-loop.js';
4
+ export const DRAFT_WAIT_MS = 6 * 3_600_000;
5
+ const DRAFT_POLL_MS = 30_000;
6
+ /** Coverage still unknown (a PR the engine has just subscribed) is waited for this long on a first visit. */
7
+ const COVERAGE_WAIT_MS = 5 * 60_000;
8
+ const COVERAGE_POLL_MS = 5_000;
9
+ const sleepFor = (ms, signal) => new Promise((resolve, reject) => {
10
+ if (signal.aborted) {
11
+ reject(signal.reason);
12
+ return;
13
+ }
14
+ const timer = setTimeout(() => { signal.removeEventListener('abort', onAbort); resolve(); }, ms);
15
+ const onAbort = () => { clearTimeout(timer); reject(signal.reason); };
16
+ signal.addEventListener('abort', onAbort, { once: true });
17
+ });
18
+ const plural = (count, word) => `${count} ${word}${count === 1 ? '' : 's'}`;
19
+ /** A run without the review loop service (a Graph Builder preview, a headless run with no PR watcher). */
20
+ export function reviewNodeUnavailable(settings) {
21
+ return stopped(settings, 'unavailable', 'Andorra review is not available in this run.');
22
+ }
23
+ function stopped(settings, reason, detail, extra = {}) {
24
+ return { outcome: 'stopped', output: { round: 0, rounds: settings.rounds, findings: [], nits: 0, prompt: '', ...extra, reason, detail }, summary: `Andorra review stopped: ${detail}` };
25
+ }
26
+ export function createReviewNodeService(deps) {
27
+ const sleep = deps.sleep ?? sleepFor;
28
+ const now = deps.now ?? Date.now;
29
+ const read = () => readPullRequest(deps.home, deps.sessionId);
30
+ /** The loop each review node of this run started: a loop belongs to its node, and one that ended is not started again. */
31
+ const started = new Map();
32
+ const mine = (pullRequest, nodeId) => pullRequest?.review !== undefined && reviewLoopActive(pullRequest)
33
+ && pullRequest.review.driver?.kind === 'graph' && pullRequest.review.driver.runId === deps.runId
34
+ && (pullRequest.review.driver.nodeId === undefined || pullRequest.review.driver.nodeId === nodeId);
35
+ /** R8's draft rule for a node: a draft holds the run, without the model, until it is ready, closed, steered or 6 hours pass. */
36
+ async function waitForReady(settings, signal, request) {
37
+ const since = now();
38
+ const earlier = new Set(deps.steers?.() ?? []);
39
+ let announced = false;
40
+ for (;;) {
41
+ const current = await read();
42
+ if (!current)
43
+ return stopped(settings, 'no-pull-request', 'This task has no pull request any more.');
44
+ if (isFinishedPullRequest(current.state))
45
+ return stopped(settings, current.state, `The pull request was ${current.state}.`);
46
+ if (current.state !== 'draft' || settings.when === 'always')
47
+ return current;
48
+ if (!announced) {
49
+ announced = true;
50
+ await request.emit('review.waiting', { reason: 'draft', url: current.url });
51
+ }
52
+ if ((deps.steers?.() ?? []).some(id => !earlier.has(id)))
53
+ return stopped(settings, 'steered', 'The person sent the task a message while the draft waited.');
54
+ if (now() - since >= DRAFT_WAIT_MS)
55
+ return stopped(settings, 'draft', 'The pull request stayed a draft for 6 hours.');
56
+ await sleep(DRAFT_POLL_MS, signal);
57
+ await deps.readNow().catch(() => { });
58
+ }
59
+ }
60
+ /** Covered, or lost for a moment (a minute at most); the coverage's own reason otherwise. */
61
+ async function covered(pullRequest, signal) {
62
+ const since = now();
63
+ for (;;) {
64
+ const coverage = await deps.coverage(pullRequest);
65
+ if (watcherCovered(coverage) || (coverage !== 'pending' && coverage !== 'unavailable') || now() - since >= COVERAGE_WAIT_MS)
66
+ return coverage;
67
+ await sleep(COVERAGE_POLL_MS, signal);
68
+ }
69
+ }
70
+ /** What the record says once the round settled: the node's outcome, its output and its summary. */
71
+ async function answerFrom(settings, loop) {
72
+ const current = await read();
73
+ const review = current?.review;
74
+ if (!current || !review || review.loop !== loop)
75
+ return stopped(settings, 'cancelled', 'The loop ended while its round ran.');
76
+ const last = review.reviewed.at(-1);
77
+ const base = {
78
+ round: review.round, rounds: review.rounds, loop, ...(last === undefined ? {} : { head: last.head, reviewUrl: last.url }),
79
+ findings: (last?.findings ?? []).map(finding => ({ priority: finding.priority, where: finding.where, ...(finding.threadId === undefined ? {} : { threadId: finding.threadId }), url: last.url, path: finding.path, line: finding.line, title: finding.title })),
80
+ nits: last?.nits ?? 0,
81
+ };
82
+ if (review.phase === 'ended' || !review.on) {
83
+ const reason = review.ended?.reason ?? 'cancelled';
84
+ const detail = review.ended?.detail ?? 'The loop ended.';
85
+ if (reason === 'signed-off')
86
+ return { outcome: 'clean', output: { ...base, reason, detail, prompt: '' }, summary: `Andorra review signed off on ${last?.head.slice(0, 7) ?? 'the head'} after round ${review.round} of ${review.rounds}.` };
87
+ return { outcome: 'stopped', output: { ...base, reason, detail, prompt: '' }, summary: `Andorra review stopped: ${detail}` };
88
+ }
89
+ if (review.phase !== 'fixing' || last === undefined)
90
+ return stopped(settings, 'cancelled', 'The round did not finish.', base);
91
+ const inline = last.findings.filter(finding => finding.where === 'inline').length;
92
+ const writes = await deps.writes().catch(() => ({ botWrites: false }));
93
+ const prompt = reviewFixPrompt(current, { loop, round: review.round, rounds: review.rounds, reviewUrl: last.url, inline, summary: last.findings.length - inline, writes, form: 'graph' });
94
+ return {
95
+ outcome: 'findings', output: { ...base, reason: '', prompt },
96
+ summary: `Andorra review, round ${review.round} of ${review.rounds}: ${plural(last.findings.length, 'finding')} on ${last.head.slice(0, 7)}.`,
97
+ };
98
+ }
99
+ return {
100
+ async round(request) {
101
+ const { settings, signal } = request;
102
+ let current = await read();
103
+ if (!current)
104
+ return stopped(settings, 'no-pull-request', 'This task tracks no pull request.');
105
+ let loop = mine(current, request.nodeId) ? current.review.loop : undefined;
106
+ if (isFinishedPullRequest(current.state)) {
107
+ if (loop !== undefined)
108
+ await deps.controller.end(deps.sessionId, loop, current.state === 'merged' ? 'merged' : 'closed', `The pull request was ${current.state}.`);
109
+ return stopped(settings, current.state, `The pull request is ${current.state}.`);
110
+ }
111
+ // This node's loop ended while the fixer worked (the person switched it off, or it failed): that end stands.
112
+ const previous = started.get(request.nodeId);
113
+ if (loop === undefined && previous !== undefined && current.review?.loop === previous && current.review.ended !== undefined) {
114
+ return stopped(settings, current.review.ended.reason, current.review.ended.detail ?? 'The loop ended.');
115
+ }
116
+ // A resumed run goes on with the loop its earlier attempt drove; the marker check keeps a stopped post from repeating.
117
+ if (loop === undefined && deps.resumedFrom !== undefined && reviewLoopActive(current) && current.review.driver?.kind === 'graph' && current.review.driver.runId === deps.resumedFrom
118
+ && (current.review.driver.nodeId === undefined || current.review.driver.nodeId === request.nodeId)
119
+ && await deps.controller.adoptGraphLoop(deps.sessionId, current.review.loop, deps.resumedFrom, deps.runId)) {
120
+ loop = current.review.loop;
121
+ current = (await read()) ?? current;
122
+ }
123
+ if (loop === undefined && reviewLoopActive(current))
124
+ return stopped(settings, 'loop-busy', 'Another Andorra review loop runs on this pull request.');
125
+ const ready = await waitForReady(settings, signal, request);
126
+ if ('outcome' in ready) {
127
+ if (loop !== undefined)
128
+ await deps.controller.end(deps.sessionId, loop, ready.output.reason === 'closed' || ready.output.reason === 'merged' ? ready.output.reason : 'cancelled', ready.output.detail);
129
+ return ready;
130
+ }
131
+ current = ready;
132
+ if (loop === undefined) {
133
+ // A new loop: the checks a chat switch-on makes, then the person's word once.
134
+ if (!await deps.enabled())
135
+ return stopped(settings, 'service-off', 'Andorra review is turned off on this machine (github.app.reviews is false).');
136
+ const plan = await deps.plan();
137
+ if (plan !== undefined)
138
+ return stopped(settings, 'plan', plan);
139
+ const coverage = await covered(current, signal);
140
+ if (!watcherCovered(coverage))
141
+ return stopped(settings, coverage === 'signed-out' ? 'signed-out' : coverage === 'pending' || coverage === 'unavailable' ? 'unavailable' : 'not-covered', coverageRefusal(coverage, current));
142
+ const bot = deps.bot ?? 'andorra-code[bot]';
143
+ const times = settings.rounds === 1 ? 'once' : settings.rounds === 2 ? 'twice' : `up to ${settings.rounds} times`;
144
+ if (!await request.approve(`${bot} will review ${current.url} ${times}, and the engineer fixes the findings between reviews.`)) {
145
+ return stopped(settings, 'declined', 'The person did not allow Andorra review for this run.');
146
+ }
147
+ signal.throwIfAborted();
148
+ loop = await deps.controller.startGraphLoop(deps.sessionId, deps.runId, {
149
+ rounds: settings.rounds, ...(settings.instruction === undefined ? {} : { instruction: settings.instruction }),
150
+ ...(settings.provider !== undefined && settings.model !== undefined ? { model: { provider: settings.provider, model: settings.model } } : {}),
151
+ nodeId: request.nodeId,
152
+ });
153
+ if (loop === undefined)
154
+ return stopped(settings, 'loop-busy', 'Another Andorra review loop runs on this pull request.');
155
+ started.set(request.nodeId, loop);
156
+ }
157
+ else if (current.review.phase === 'fixing') {
158
+ // A return from the fixer: its push is the next round's head. The same head means it pushed nothing.
159
+ const last = current.review.reviewed.at(-1)?.head;
160
+ const head = await deps.head(current);
161
+ if (head !== undefined && head === last) {
162
+ await deps.controller.end(deps.sessionId, loop, 'no-new-commits', `The fixer finished with the head still ${head.slice(0, 7)}, the commit round ${current.review.round} reviewed.`);
163
+ return answerFrom(settings, loop);
164
+ }
165
+ }
166
+ started.set(request.nodeId, loop);
167
+ // A round that fails is tried once more, as chat tries a failed round again at its next look.
168
+ for (let attempt = 1;; attempt++) {
169
+ try {
170
+ await deps.controller.graphRound(deps.sessionId, loop, signal);
171
+ break;
172
+ }
173
+ catch (error) {
174
+ if (error instanceof ReviewLoopStopping)
175
+ throw error;
176
+ if (signal.aborted) {
177
+ await deps.controller.end(deps.sessionId, loop, 'cancelled', 'The graph run stopped during the round.').catch(() => { });
178
+ throw error;
179
+ }
180
+ const posting = (await read())?.review?.phase === 'posting';
181
+ // A post whose outcome is unknown keeps its record for the marker check: the loop is not ended over it.
182
+ if (attempt < 2 && !posting)
183
+ continue;
184
+ if (posting)
185
+ return stopped(settings, 'unavailable', `The review's post could not be confirmed: ${error instanceof Error ? error.message : String(error)}`, { loop });
186
+ await deps.controller.end(deps.sessionId, loop, 'error', `The round failed twice: ${error instanceof Error ? error.message : String(error)}`);
187
+ return answerFrom(settings, loop);
188
+ }
189
+ }
190
+ if (signal.aborted) {
191
+ await deps.controller.end(deps.sessionId, loop, 'cancelled', 'The graph run stopped during the round.').catch(() => { });
192
+ signal.throwIfAborted();
193
+ }
194
+ return answerFrom(settings, loop);
195
+ },
196
+ };
197
+ }
198
+ /** A graph run ended: a loop it still drives (its fixer never came back) ends with it. */
199
+ export async function endGraphLoops(home, sessionId, runId, controller) {
200
+ const current = await readPullRequest(home, sessionId).catch(() => undefined);
201
+ const review = current?.review;
202
+ if (!current || !review || !reviewLoopActive(current) || review.driver?.kind !== 'graph' || review.driver.runId !== runId)
203
+ return;
204
+ await controller.end(sessionId, review.loop, 'cancelled', 'The graph run that drove this loop ended.');
205
+ }
@@ -0,0 +1,73 @@
1
+ import type { GitHubAppClient, ReviewCheckRequest, ReviewWriteRequest } from './client.js';
2
+ /**
3
+ * Posting one round's review, and the `review-check` before it, under the request-id rules
4
+ * (design/specs/andorra-review-loop.md, "The review write": "Request ids" and "Answers, and what the engine does
5
+ * with each"). The client asks once; this decides what to ask again, after how long, and with which id.
6
+ */
7
+ /** Why a loop ended ("Stopping"). The graph node's own reasons come with L4. */
8
+ export type ReviewLoopEnd = 'signed-off' | 'rounds-used' | 'review-only' | 'no-new-commits' | 'merged' | 'closed' | 'switched-off' | 'cancelled' | 'not-covered' | 'unavailable' | 'rate-limited' | 'service-off' | 'signed-out' | 'plan' | 'head-moving' | 'reviewer-failed' | 'error';
9
+ export type PostOutcome = {
10
+ kind: 'posted';
11
+ reviewId: string;
12
+ url?: string;
13
+ comments?: number;
14
+ requestId: string;
15
+ }
16
+ /** The PR moved on: review the new head once (a second time in one round ends the loop `head-moving`). */
17
+ | {
18
+ kind: 'stale-head';
19
+ head?: string;
20
+ }
21
+ /** GitHub refused the review with 422 and nothing was posted: retry once with every finding in the summary. */
22
+ | {
23
+ kind: 'refused-422';
24
+ } | {
25
+ kind: 'ended';
26
+ reason: ReviewLoopEnd;
27
+ detail: string;
28
+ };
29
+ export type CheckOutcome = {
30
+ kind: 'ok';
31
+ } | {
32
+ kind: 'ended';
33
+ reason: ReviewLoopEnd;
34
+ detail: string;
35
+ };
36
+ export interface ReviewPostDependencies {
37
+ client: Pick<GitHubAppClient, 'review' | 'reviewCheck'>;
38
+ newRequestId(): string;
39
+ sleep(ms: number, signal?: AbortSignal): Promise<void>;
40
+ /** Kept on the PR record before each request is sent, so an engine that stops mid-post resumes with the marker check. */
41
+ recordAttempt?(attempt: {
42
+ requestId: string;
43
+ firstAt: string;
44
+ }): Promise<void>;
45
+ /** The marker check: this loop's round's review on GitHub, if it is there. */
46
+ markerCheck(): Promise<{
47
+ reviewId: string;
48
+ url?: string;
49
+ } | undefined>;
50
+ now?(): number;
51
+ }
52
+ /** The waits after an answer that says nothing was posted, before the loop ends `unavailable`. */
53
+ export declare const UNAVAILABLE_WAITS_MS: readonly number[];
54
+ /** A cap's `retry-after` over this ends the loop at once (`rate-limited`). */
55
+ export declare const LONGEST_LIMIT_WAIT_MS = 600000;
56
+ export declare const RATE_LIMIT_RETRIES = 3;
57
+ /** `503 in_progress`: ask again with the same id every 5 s for up to 30 s. */
58
+ export declare const IN_PROGRESS_POLL_MS = 5000;
59
+ export declare const IN_PROGRESS_POLLS = 6;
60
+ /** Unknown outcomes resolved by the marker check before the loop gives up (`unavailable`). */
61
+ export declare const UNKNOWN_ROUNDS = 3;
62
+ /** `review-check` before any model runs. A refusal ends the loop; nothing it asks can post, so every retry takes a new id. */
63
+ export declare function checkReview(request: Omit<ReviewCheckRequest, 'requestId'>, deps: ReviewPostDependencies, signal?: AbortSignal): Promise<CheckOutcome>;
64
+ /**
65
+ * Posts the round's review. With `resume`, the engine stopped while posting: the marker check runs first, and the
66
+ * stored id is asked once more before a new one is used, so GitHub never holds two reviews of one round.
67
+ */
68
+ export declare function postReview(request: Omit<ReviewWriteRequest, 'requestId'>, deps: ReviewPostDependencies, options?: {
69
+ resume?: {
70
+ requestId: string;
71
+ };
72
+ signal?: AbortSignal;
73
+ }): Promise<PostOutcome>;
@@ -0,0 +1,139 @@
1
+ /** The waits after an answer that says nothing was posted, before the loop ends `unavailable`. */
2
+ export const UNAVAILABLE_WAITS_MS = [30_000, 120_000, 600_000];
3
+ /** A cap's `retry-after` over this ends the loop at once (`rate-limited`). */
4
+ export const LONGEST_LIMIT_WAIT_MS = 600_000;
5
+ export const RATE_LIMIT_RETRIES = 3;
6
+ /** `503 in_progress`: ask again with the same id every 5 s for up to 30 s. */
7
+ export const IN_PROGRESS_POLL_MS = 5_000;
8
+ export const IN_PROGRESS_POLLS = 6;
9
+ /** Unknown outcomes resolved by the marker check before the loop gives up (`unavailable`). */
10
+ export const UNKNOWN_ROUNDS = 3;
11
+ /** The answers that end a loop, whatever it was doing. */
12
+ function ending(answer) {
13
+ switch (answer.kind) {
14
+ case 'closed': return answer.merged ? { reason: 'merged', detail: 'The pull request was merged.' } : { reason: 'closed', detail: 'The pull request was closed.' };
15
+ case 'loop-taken': return { reason: 'error', detail: 'This review loop belongs to another Andorra account.' };
16
+ case 'service-off': return { reason: 'service-off', detail: 'Andorra review is off on Andorra\'s service.' };
17
+ case 'not-covered': return { reason: 'not-covered', detail: answer.error === 'not_allowed' ? 'This Andorra account is not in the GitHub App\'s preview.' : 'The Andorra Code bot may not post on this pull request.' };
18
+ case 'plan': return { reason: 'plan', detail: 'Andorra review needs a paid plan.' };
19
+ case 'signed-out': return { reason: 'signed-out', detail: 'The Andorra sign-in was refused.' };
20
+ case 'bad-request': return { reason: 'error', detail: `Andorra's service refused the review${answer.field === undefined ? '' : ` (field ${answer.field})`}.` };
21
+ case 'not-found': return { reason: 'error', detail: 'Andorra\'s service did not find what the review named.' };
22
+ case 'github-refused': return answer.status === 422 ? undefined : { reason: 'not-covered', detail: `GitHub refused the bot's review (HTTP ${answer.status}).` };
23
+ default: return undefined;
24
+ }
25
+ }
26
+ /** What to do about an answer that says nothing was posted: wait and go on with a new id, or end. */
27
+ async function waitAfterNothing(answer, retry, deps, signal) {
28
+ if (answer.kind === 'rate-limited') {
29
+ const wait = answer.retryAfterMs ?? 60_000;
30
+ if (wait > LONGEST_LIMIT_WAIT_MS)
31
+ return { reason: 'rate-limited', detail: `Andorra's service asked to wait ${Math.ceil(wait / 60_000)} minutes.` };
32
+ if (retry.limited >= RATE_LIMIT_RETRIES)
33
+ return { reason: 'rate-limited', detail: 'Andorra\'s service kept asking to wait.' };
34
+ retry.limited++;
35
+ await deps.sleep(wait, signal);
36
+ return undefined;
37
+ }
38
+ const detail = answer.kind === 'unavailable' ? answer.detail : 'Andorra\'s service could not post the review.';
39
+ if (retry.unavailable >= UNAVAILABLE_WAITS_MS.length)
40
+ return { reason: 'unavailable', detail };
41
+ await deps.sleep(UNAVAILABLE_WAITS_MS[retry.unavailable++], signal);
42
+ return undefined;
43
+ }
44
+ /** `review-check` before any model runs. A refusal ends the loop; nothing it asks can post, so every retry takes a new id. */
45
+ export async function checkReview(request, deps, signal) {
46
+ const retry = { unavailable: 0, limited: 0 };
47
+ for (;;) {
48
+ signal?.throwIfAborted();
49
+ const answer = await deps.client.reviewCheck({ ...request, requestId: deps.newRequestId() }, signal);
50
+ if (answer.kind === 'ok')
51
+ return { kind: 'ok' };
52
+ const end = ending(answer);
53
+ if (end)
54
+ return { kind: 'ended', ...end };
55
+ if (answer.kind === 'posted' || answer.kind === 'stale-head' || answer.kind === 'github-refused')
56
+ return { kind: 'ended', reason: 'error', detail: `Andorra's service answered review-check with ${answer.kind}.` };
57
+ // Unknown and in-progress mean nothing for a check, which writes nothing: ask again like any failure.
58
+ const ended = await waitAfterNothing(answer.kind === 'rate-limited' ? answer : { kind: 'unavailable', detail: answer.kind === 'unavailable' ? answer.detail : 'Andorra\'s service did not answer the check.' }, retry, deps, signal);
59
+ if (ended)
60
+ return { kind: 'ended', ...ended };
61
+ }
62
+ }
63
+ /**
64
+ * Posts the round's review. With `resume`, the engine stopped while posting: the marker check runs first, and the
65
+ * stored id is asked once more before a new one is used, so GitHub never holds two reviews of one round.
66
+ */
67
+ export async function postReview(request, deps, options = {}) {
68
+ const { signal } = options;
69
+ const retry = { unavailable: 0, limited: 0 };
70
+ const now = deps.now ?? Date.now;
71
+ let unknownRounds = 0;
72
+ let requestId = options.resume?.requestId ?? deps.newRequestId();
73
+ /** The id was sent and its outcome is unknown: only the marker check, or the same id's stored answer, decides. */
74
+ let uncertain = options.resume !== undefined;
75
+ /** The same id has already been asked once more after an unknown outcome (on a resume, the first ask is that). */
76
+ let askedAgain = options.resume !== undefined;
77
+ /** Some attempt of this round had an unknown outcome: before acting on any other answer, the marker check runs. */
78
+ let everUncertain = uncertain;
79
+ const fresh = async () => { requestId = deps.newRequestId(); uncertain = false; askedAgain = false; };
80
+ const found = async () => {
81
+ const review = await deps.markerCheck();
82
+ return review === undefined ? undefined : { kind: 'posted', reviewId: review.reviewId, ...(review.url === undefined ? {} : { url: review.url }), requestId };
83
+ };
84
+ if (uncertain) {
85
+ const posted = await found();
86
+ if (posted)
87
+ return posted;
88
+ }
89
+ for (;;) {
90
+ signal?.throwIfAborted();
91
+ if (!uncertain)
92
+ await deps.recordAttempt?.({ requestId, firstAt: new Date(now()).toISOString() });
93
+ let answer = await deps.client.review({ ...request, requestId }, signal);
94
+ // `503 in_progress`: the first attempt with this id is still running; its answer is asked for every 5 s.
95
+ for (let poll = 0; answer.kind === 'in-progress' && poll < IN_PROGRESS_POLLS; poll++) {
96
+ await deps.sleep(IN_PROGRESS_POLL_MS, signal);
97
+ answer = await deps.client.review({ ...request, requestId }, signal);
98
+ }
99
+ if (answer.kind === 'posted')
100
+ return { kind: 'posted', reviewId: answer.reviewId, ...(answer.url === undefined ? {} : { url: answer.url }), ...(answer.comments === undefined ? {} : { comments: answer.comments }), requestId };
101
+ if (answer.kind === 'unknown' || answer.kind === 'in-progress') {
102
+ everUncertain = true;
103
+ const posted = await found();
104
+ if (posted)
105
+ return posted;
106
+ if (!askedAgain) {
107
+ // Asked once more with the same id: that only reads back an answer the service stored and the engine lost.
108
+ uncertain = true;
109
+ askedAgain = true;
110
+ continue;
111
+ }
112
+ if (++unknownRounds >= UNKNOWN_ROUNDS)
113
+ return { kind: 'ended', reason: 'unavailable', detail: answer.kind === 'unknown' ? answer.detail : 'Andorra\'s service kept working on the review.' };
114
+ await fresh();
115
+ continue;
116
+ }
117
+ // An answer given before the service's request-id check (a throttle, the kill switch) says nothing about an
118
+ // earlier attempt whose fate is unknown, and that one may have posted.
119
+ if (everUncertain) {
120
+ const posted = await found();
121
+ if (posted)
122
+ return posted;
123
+ }
124
+ if (answer.kind === 'stale-head')
125
+ return { kind: 'stale-head', ...(answer.head === undefined ? {} : { head: answer.head }) };
126
+ if (answer.kind === 'github-refused' && answer.status === 422)
127
+ return { kind: 'refused-422' };
128
+ const end = ending(answer);
129
+ if (end)
130
+ return { kind: 'ended', ...end };
131
+ if (answer.kind === 'ok')
132
+ return { kind: 'ended', reason: 'error', detail: 'Andorra\'s service answered a review as if it were a check.' };
133
+ // Nothing was posted (`rate-limited`, `unavailable`): wait, then a new id.
134
+ const ended = await waitAfterNothing(answer, retry, deps, signal);
135
+ if (ended)
136
+ return { kind: 'ended', ...ended };
137
+ await fresh();
138
+ }
139
+ }
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The text of an Andorra review (`design/specs/andorra-review-loop.md`): the reviewer's output checked ("The
3
+ * reviewer"), the diff's hunks indexed so that a finding goes inline only where GitHub takes it ("A round",
4
+ * step 2), every text the reviewer wrote sanitised before it reaches the service ("Sanitising what the bot
5
+ * posts", R16), and the review cut to the service's sizes ("Limits"). Pure functions: no I/O.
6
+ *
7
+ * The sanitiser keeps one invariant: whatever it leaves untouched as code, GitHub reads as code too. Where it
8
+ * cannot tell how GitHub will read a line, it reads the line as text and neutralises it; at worst an escape then
9
+ * shows inside a code block. So that GitHub opens no fence, pairs no backtick and makes no link the sanitiser did
10
+ * not, it escapes every unpaired backtick run, every run of three tildes and every bracket it does not keep.
11
+ */
12
+ export type ReviewPriority = 'P1' | 'P2' | 'P3';
13
+ export type DiffSide = 'LEFT' | 'RIGHT';
14
+ export interface ReviewFinding {
15
+ priority: ReviewPriority;
16
+ title: string;
17
+ path: string;
18
+ line: number;
19
+ startLine?: number;
20
+ side?: DiffSide;
21
+ body: string;
22
+ }
23
+ /** The service's inline comment shape (POST /v1/github/writes action review). */
24
+ export interface ReviewComment {
25
+ path: string;
26
+ line: number;
27
+ side: DiffSide;
28
+ startLine?: number;
29
+ startSide?: DiffSide;
30
+ body: string;
31
+ }
32
+ /** The service's limit on a review's summary (its `BODY_BYTES`). */
33
+ export declare const REVIEW_SUMMARY_BYTES = 16384;
34
+ /** The service's limit on one inline comment. */
35
+ export declare const REVIEW_COMMENT_BYTES = 4096;
36
+ /** The most inline comments the service takes in one review. */
37
+ export declare const REVIEW_COMMENTS = 30;
38
+ /** The most findings the reviewer is asked for. */
39
+ export declare const REVIEWER_FINDINGS = 20;
40
+ /** The service's limit on a whole write request (`WRITE_REQUEST_BYTES`). */
41
+ export declare const REVIEW_REQUEST_BYTES = 163840;
42
+ /** Validates the reviewer's structured output ({summary, findings[]}); drops malformed findings; keeps at most 50. Undefined when the value is not an object with a string summary and a findings array. */
43
+ export declare function parseReviewerOutput(value: unknown): {
44
+ summary: string;
45
+ findings: ReviewFinding[];
46
+ } | undefined;
47
+ /**
48
+ * The same, with how many findings it dropped as malformed (those past the 50 kept are not counted). The loop reads a
49
+ * dropped finding as a failed reviewer run: a P1 without a line must not turn into "No findings".
50
+ */
51
+ export declare function readReviewerOutput(value: unknown): {
52
+ output: {
53
+ summary: string;
54
+ findings: ReviewFinding[];
55
+ };
56
+ dropped: number;
57
+ } | undefined;
58
+ /** The marker's opening `<!-- andorra-review` (any case, any whitespace after `<!--`) broken everywhere, code included, with U+2060 WORD JOINER after the `<`. */
59
+ export declare function breakMarker(text: string): string;
60
+ /** R16: every text the reviewer wrote, before it reaches the service. */
61
+ export declare function sanitizeReviewText(text: string, repo: {
62
+ owner: string;
63
+ repo: string;
64
+ }): string;
65
+ /** For the fixer's own replies and PR comments: `<!--` outside code becomes `&lt;!--`, and breakMarker everywhere. Nothing else changes. */
66
+ export declare function escapeWriteBody(text: string): string;
67
+ export interface DiffIndex {
68
+ files: string[];
69
+ covers(path: string, side: DiffSide, startLine: number, line: number): boolean;
70
+ }
71
+ /** Parses a unified diff (git diff output, possibly many files, renames, binary files, ``). RIGHT covers added and context lines of the new file; LEFT covers deleted and context lines of the old file. covers() is true only when every line from startLine to line is inside ONE hunk on that side. */
72
+ export declare function indexDiff(patch: string): DiffIndex;
73
+ export interface ComposedReview {
74
+ body: string;
75
+ comments: ReviewComment[];
76
+ recorded: {
77
+ priority: 'P1' | 'P2';
78
+ where: 'inline' | 'summary';
79
+ comment?: number;
80
+ title: string;
81
+ path: string;
82
+ line: number;
83
+ }[];
84
+ nits: number;
85
+ blocking: number;
86
+ }
87
+ export declare function composeReview(input: {
88
+ repo: {
89
+ owner: string;
90
+ repo: string;
91
+ };
92
+ headSha: string;
93
+ round: number;
94
+ rounds: number;
95
+ summary: string;
96
+ findings: ReviewFinding[];
97
+ diff: DiffIndex;
98
+ /** Earlier rounds' findings still open (unresolved), listed as disputed in a clean review. */
99
+ stillOpen?: {
100
+ priority: 'P1' | 'P2';
101
+ title: string;
102
+ path: string;
103
+ line: number;
104
+ }[];
105
+ /** The retry after GitHub refused the review (422): every finding in the summary, none inline. */
106
+ summaryOnly?: boolean;
107
+ }): ComposedReview;