@open-cr-agent/core 0.6.0 → 0.7.0

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 (204) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/budget.d.ts +0 -1
  3. package/dist/agent/budget.js +0 -1
  4. package/dist/agent/json.d.ts +0 -1
  5. package/dist/agent/json.js +0 -1
  6. package/dist/agent/pool.d.ts +0 -1
  7. package/dist/agent/pool.js +0 -1
  8. package/dist/agent/settings.d.ts +0 -1
  9. package/dist/agent/settings.js +0 -1
  10. package/dist/agent/usage.d.ts +0 -1
  11. package/dist/agent/usage.js +0 -1
  12. package/dist/anchor/anchor.d.ts +0 -1
  13. package/dist/anchor/anchor.js +0 -1
  14. package/dist/anchor/match.d.ts +0 -1
  15. package/dist/anchor/match.js +0 -1
  16. package/dist/anchor/relocate.d.ts +0 -1
  17. package/dist/anchor/relocate.js +0 -1
  18. package/dist/at.d.ts +0 -1
  19. package/dist/at.js +0 -1
  20. package/dist/bounded-file.d.ts +12 -0
  21. package/dist/bounded-file.js +47 -0
  22. package/dist/bundle/bundle.d.ts +0 -1
  23. package/dist/bundle/bundle.js +0 -1
  24. package/dist/bundle/grouping.d.ts +0 -1
  25. package/dist/bundle/grouping.js +0 -1
  26. package/dist/bundle/runtime-grouper.d.ts +0 -1
  27. package/dist/bundle/runtime-grouper.js +0 -1
  28. package/dist/contracts.d.ts +10 -1
  29. package/dist/contracts.js +4 -1
  30. package/dist/diff/hunks.d.ts +0 -1
  31. package/dist/diff/hunks.js +0 -1
  32. package/dist/diff/parse.d.ts +0 -1
  33. package/dist/diff/parse.js +0 -1
  34. package/dist/diff/quoted-path.d.ts +0 -1
  35. package/dist/diff/quoted-path.js +0 -1
  36. package/dist/domain.d.ts +4 -1
  37. package/dist/domain.js +0 -1
  38. package/dist/errors.d.ts +0 -1
  39. package/dist/errors.js +0 -1
  40. package/dist/hash.d.ts +0 -1
  41. package/dist/hash.js +0 -1
  42. package/dist/index.d.ts +5 -5
  43. package/dist/index.js +2 -3
  44. package/dist/internal.d.ts +3 -3
  45. package/dist/internal.js +2 -2
  46. package/dist/judge/judge.d.ts +0 -1
  47. package/dist/judge/judge.js +0 -1
  48. package/dist/judge/prompt.d.ts +0 -1
  49. package/dist/judge/prompt.js +0 -1
  50. package/dist/judge/verdict.d.ts +0 -1
  51. package/dist/judge/verdict.js +0 -1
  52. package/dist/memory/memory.d.ts +0 -1
  53. package/dist/memory/memory.js +0 -1
  54. package/dist/net/proxied-fetch.d.ts +0 -1
  55. package/dist/net/proxied-fetch.js +0 -1
  56. package/dist/pipeline/assemble-report.d.ts +0 -1
  57. package/dist/pipeline/assemble-report.js +0 -1
  58. package/dist/pipeline/check-stage.d.ts +0 -1
  59. package/dist/pipeline/check-stage.js +0 -1
  60. package/dist/pipeline/context.d.ts +0 -1
  61. package/dist/pipeline/context.js +8 -5
  62. package/dist/pipeline/coverage.d.ts +0 -1
  63. package/dist/pipeline/coverage.js +37 -17
  64. package/dist/pipeline/execute-stage.d.ts +0 -1
  65. package/dist/pipeline/execute-stage.js +29 -3
  66. package/dist/pipeline/execute.d.ts +9 -2
  67. package/dist/pipeline/execute.js +90 -9
  68. package/dist/pipeline/filter-stage.d.ts +0 -1
  69. package/dist/pipeline/filter-stage.js +0 -1
  70. package/dist/pipeline/findings.d.ts +0 -1
  71. package/dist/pipeline/findings.js +0 -1
  72. package/dist/pipeline/imports.d.ts +0 -1
  73. package/dist/pipeline/imports.js +0 -1
  74. package/dist/pipeline/matrix.d.ts +0 -1
  75. package/dist/pipeline/matrix.js +0 -1
  76. package/dist/pipeline/options.d.ts +2 -1
  77. package/dist/pipeline/options.js +0 -1
  78. package/dist/pipeline/plan-output.d.ts +0 -1
  79. package/dist/pipeline/plan-output.js +0 -1
  80. package/dist/pipeline/plan.d.ts +1 -2
  81. package/dist/pipeline/plan.js +6 -2
  82. package/dist/pipeline/preview.d.ts +0 -1
  83. package/dist/pipeline/preview.js +0 -1
  84. package/dist/pipeline/provenance.d.ts +0 -1
  85. package/dist/pipeline/provenance.js +0 -1
  86. package/dist/pipeline/resume.d.ts +22 -0
  87. package/dist/pipeline/resume.js +24 -0
  88. package/dist/pipeline/run-id.d.ts +0 -1
  89. package/dist/pipeline/run-id.js +0 -1
  90. package/dist/pipeline/run.d.ts +0 -1
  91. package/dist/pipeline/run.js +0 -1
  92. package/dist/pipeline/task.d.ts +5 -8
  93. package/dist/pipeline/task.js +8 -6
  94. package/dist/plugin/builtin.d.ts +1 -1
  95. package/dist/plugin/builtin.js +12 -3
  96. package/dist/plugin/host.d.ts +0 -1
  97. package/dist/plugin/host.js +0 -1
  98. package/dist/plugin/registry.d.ts +0 -1
  99. package/dist/plugin/registry.js +0 -1
  100. package/dist/plugin/types.d.ts +0 -1
  101. package/dist/plugin/types.js +0 -1
  102. package/dist/report/output-schema.d.ts +39 -1
  103. package/dist/report/output-schema.js +10 -3
  104. package/dist/report/output.d.ts +0 -1
  105. package/dist/report/output.js +7 -4
  106. package/dist/report/provenance.d.ts +0 -1
  107. package/dist/report/provenance.js +0 -1
  108. package/dist/report/read.d.ts +0 -1
  109. package/dist/report/read.js +5 -3
  110. package/dist/report/report.d.ts +26 -3
  111. package/dist/report/report.js +11 -3
  112. package/dist/report/serialize.d.ts +0 -1
  113. package/dist/report/serialize.js +0 -1
  114. package/dist/rereview/presence.d.ts +0 -1
  115. package/dist/rereview/presence.js +0 -1
  116. package/dist/rereview/quote.d.ts +0 -1
  117. package/dist/rereview/quote.js +0 -1
  118. package/dist/rereview/reconcile.d.ts +0 -1
  119. package/dist/rereview/reconcile.js +0 -1
  120. package/dist/review/impact.d.ts +0 -1
  121. package/dist/review/impact.js +0 -1
  122. package/dist/review/plan-phase.d.ts +0 -1
  123. package/dist/review/plan-phase.js +0 -1
  124. package/dist/review/prompt-text.d.ts +0 -1
  125. package/dist/review/prompt-text.js +0 -1
  126. package/dist/review/prompt.d.ts +0 -1
  127. package/dist/review/prompt.js +0 -1
  128. package/dist/review/reviewer.d.ts +0 -1
  129. package/dist/review/reviewer.js +0 -1
  130. package/dist/review/reviewers/agents-md.d.ts +0 -1
  131. package/dist/review/reviewers/agents-md.js +0 -1
  132. package/dist/review/reviewers/correctness.d.ts +0 -1
  133. package/dist/review/reviewers/correctness.js +0 -1
  134. package/dist/review/reviewers/docs.d.ts +0 -1
  135. package/dist/review/reviewers/docs.js +0 -1
  136. package/dist/review/reviewers/performance.d.ts +0 -1
  137. package/dist/review/reviewers/performance.js +0 -1
  138. package/dist/review/reviewers/scopes.d.ts +0 -1
  139. package/dist/review/reviewers/scopes.js +0 -1
  140. package/dist/review/reviewers/security.d.ts +0 -1
  141. package/dist/review/reviewers/security.js +0 -1
  142. package/dist/review/tools.d.ts +0 -1
  143. package/dist/review/tools.js +0 -1
  144. package/dist/rules/builtin/general.d.ts +0 -1
  145. package/dist/rules/builtin/general.js +0 -1
  146. package/dist/rules/builtin/go.d.ts +0 -1
  147. package/dist/rules/builtin/go.js +0 -1
  148. package/dist/rules/builtin/index.d.ts +0 -1
  149. package/dist/rules/builtin/index.js +0 -1
  150. package/dist/rules/builtin/java.d.ts +0 -1
  151. package/dist/rules/builtin/java.js +0 -1
  152. package/dist/rules/builtin/performance.d.ts +0 -1
  153. package/dist/rules/builtin/performance.js +0 -1
  154. package/dist/rules/builtin/python.d.ts +0 -1
  155. package/dist/rules/builtin/python.js +0 -1
  156. package/dist/rules/builtin/security.d.ts +0 -1
  157. package/dist/rules/builtin/security.js +0 -1
  158. package/dist/rules/builtin/typescript.d.ts +0 -1
  159. package/dist/rules/builtin/typescript.js +0 -1
  160. package/dist/rules/languages.d.ts +0 -1
  161. package/dist/rules/languages.js +0 -1
  162. package/dist/rules/repo-rules.d.ts +0 -1
  163. package/dist/rules/repo-rules.js +0 -1
  164. package/dist/rules/resolve.d.ts +0 -1
  165. package/dist/rules/resolve.js +0 -1
  166. package/dist/rules/rule-set.d.ts +0 -1
  167. package/dist/rules/rule-set.js +0 -1
  168. package/dist/runtime/attempt.d.ts +15 -2
  169. package/dist/runtime/attempt.js +47 -1
  170. package/dist/runtime/chain-runner.d.ts +0 -1
  171. package/dist/runtime/chain-runner.js +0 -1
  172. package/dist/runtime/effort-capability.d.ts +0 -1
  173. package/dist/runtime/effort-capability.js +0 -1
  174. package/dist/runtime/failback.d.ts +0 -1
  175. package/dist/runtime/failback.js +38 -9
  176. package/dist/runtime/models.d.ts +0 -1
  177. package/dist/runtime/models.js +14 -13
  178. package/dist/runtime/quota.d.ts +1 -1
  179. package/dist/runtime/quota.js +3 -2
  180. package/dist/runtime/tools.d.ts +0 -1
  181. package/dist/runtime/tools.js +0 -1
  182. package/dist/sarif/candidates.d.ts +0 -1
  183. package/dist/sarif/candidates.js +0 -1
  184. package/dist/sarif/schema.d.ts +0 -1
  185. package/dist/sarif/schema.js +0 -1
  186. package/dist/select/patterns.d.ts +0 -1
  187. package/dist/select/patterns.js +0 -1
  188. package/dist/select/select.d.ts +1 -1
  189. package/dist/select/select.js +16 -3
  190. package/dist/session/jsonl.d.ts +2 -2
  191. package/dist/session/jsonl.js +9 -4
  192. package/dist/session/resume-read.d.ts +2 -0
  193. package/dist/session/resume-read.js +128 -0
  194. package/dist/session/seal.d.ts +5 -0
  195. package/dist/session/seal.js +24 -0
  196. package/dist/triage.d.ts +0 -1
  197. package/dist/triage.js +0 -1
  198. package/dist/vcs.d.ts +0 -1
  199. package/dist/vcs.js +0 -1
  200. package/dist/verify/prompt.d.ts +0 -1
  201. package/dist/verify/prompt.js +0 -1
  202. package/dist/verify/verify.d.ts +0 -1
  203. package/dist/verify/verify.js +0 -1
  204. package/package.json +1 -1
@@ -39,8 +39,8 @@ export async function executeTask(runtime, spec, runSignal, callbacks) {
39
39
  const ending = iterator
40
40
  ? await collectAfterAbort(iterator, pending, result, callbacks)
41
41
  : undefined;
42
- // The task's last usage report crossed the limit, and it finished
43
- // anyway: its review is complete.
42
+ // The spend limit stopped the run, often through the task's own last
43
+ // usage report, after the task had finished: its review is complete.
44
44
  if (ending === "done" && runSignal.reason instanceof SpendLimitReached) {
45
45
  result.status = "completed";
46
46
  delete result.error;
@@ -68,8 +68,9 @@ async function collectAfterAbort(iterator, pending, result, callbacks) {
68
68
  if (event.done)
69
69
  return undefined;
70
70
  const { value } = event;
71
- if (value.type === "usage" || value.type === "finding")
71
+ if (value.type === "usage" || value.type === "finding" || value.type === "done") {
72
72
  handle(value, result, callbacks);
73
+ }
73
74
  if (value.type === "done" || value.type === "error")
74
75
  return value.type;
75
76
  next = iterator.next();
@@ -84,7 +85,7 @@ async function collectAfterAbort(iterator, pending, result, callbacks) {
84
85
  function handle(event, result, callbacks) {
85
86
  switch (event.type) {
86
87
  case "progress":
87
- callbacks.onProgress(event.message);
88
+ callbacks.onProgress(event.message, event.attempt);
88
89
  return false;
89
90
  case "finding": {
90
91
  const parsed = reportedFindingSchema.safeParse(withReviewerCategory(event.finding, callbacks.category));
@@ -111,6 +112,8 @@ function handle(event, result, callbacks) {
111
112
  return false;
112
113
  }
113
114
  case "done":
115
+ if (event.ended)
116
+ result.ended = event.ended;
114
117
  return true;
115
118
  case "error":
116
119
  result.status = "failed";
@@ -120,7 +123,7 @@ function handle(event, result, callbacks) {
120
123
  }
121
124
  // A reviewer steered by the change could flood the pull request with
122
125
  // comments or pad them without end; both are bounded.
123
- const MAX_FINDINGS_PER_TASK = 50;
126
+ export const MAX_FINDINGS_PER_TASK = 50;
124
127
  const MAX_TITLE = 300;
125
128
  const MAX_TEXT = 4_000;
126
129
  const MAX_EVIDENCE = 10;
@@ -159,4 +162,3 @@ function untilAborted(promise, signal) {
159
162
  });
160
163
  });
161
164
  }
162
- //# sourceMappingURL=task.js.map
@@ -8,7 +8,7 @@ export declare const agentsMdReviewerPlugin: OcraPlugin;
8
8
  declare const sessionSettings: z.ZodObject<{
9
9
  dir: z.ZodString;
10
10
  id: z.ZodString;
11
+ sealKey: z.ZodExactOptional<z.ZodString>;
11
12
  }, z.core.$strict>;
12
13
  export declare const sessionJsonlPlugin: OcraPlugin<z.infer<typeof sessionSettings>>;
13
14
  export {};
14
- //# sourceMappingURL=builtin.d.ts.map
@@ -5,6 +5,7 @@ import { docsReviewer } from "../review/reviewers/docs.js";
5
5
  import { performanceReviewer } from "../review/reviewers/performance.js";
6
6
  import { securityReviewer } from "../review/reviewers/security.js";
7
7
  import { JsonlSessionWriter } from "../session/jsonl.js";
8
+ import { SEAL_KEY } from "../session/seal.js";
8
9
  export const correctnessReviewerPlugin = {
9
10
  name: "reviewer-correctness",
10
11
  configure(ctx) {
@@ -35,13 +36,21 @@ export const agentsMdReviewerPlugin = {
35
36
  ctx.registerReviewer(agentsMdReviewer);
36
37
  },
37
38
  };
38
- const sessionSettings = z.object({ dir: z.string().min(1), id: z.string().min(1) }).strict();
39
+ // sealKey: this machine's secret (64 hex digits) that seals each line, so
40
+ // that only this machine's ocra resumes the session.
41
+ const sessionSettings = z
42
+ .object({
43
+ dir: z.string().min(1),
44
+ id: z.string().min(1),
45
+ sealKey: z.string().regex(SEAL_KEY).exactOptional(),
46
+ })
47
+ .strict();
39
48
  export const sessionJsonlPlugin = {
40
49
  name: "session-jsonl",
41
50
  settingsSchema: sessionSettings,
42
51
  configure(ctx) {
43
- const writer = new JsonlSessionWriter(ctx.settings.dir, ctx.settings.id);
52
+ const { dir, id, sealKey } = ctx.settings;
53
+ const writer = new JsonlSessionWriter(dir, id, sealKey);
44
54
  ctx.onEvent((event) => writer.write(event));
45
55
  },
46
56
  };
47
- //# sourceMappingURL=builtin.js.map
@@ -6,4 +6,3 @@ export interface PluginHostOptions {
6
6
  warn?: (message: string) => void;
7
7
  }
8
8
  export declare function startPlugins(plugins: readonly OcraPlugin[], options?: PluginHostOptions): Promise<PluginRegistry>;
9
- //# sourceMappingURL=host.d.ts.map
@@ -75,4 +75,3 @@ function assertUniqueNames(plugins) {
75
75
  seen.add(plugin.name);
76
76
  }
77
77
  }
78
- //# sourceMappingURL=host.js.map
@@ -39,4 +39,3 @@ export declare class PluginRegistry {
39
39
  private lookup;
40
40
  private assertOpen;
41
41
  }
42
- //# sourceMappingURL=registry.d.ts.map
@@ -111,4 +111,3 @@ export class PluginRegistry {
111
111
  }
112
112
  }
113
113
  }
114
- //# sourceMappingURL=registry.js.map
@@ -62,4 +62,3 @@ export interface OcraPlugin<Settings = unknown> {
62
62
  configure?(ctx: ConfigureContext<Settings>): void | Promise<void>;
63
63
  postConfigure?(ctx: PostConfigureContext<Settings>): void | Promise<void>;
64
64
  }
65
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -11,6 +11,33 @@ export declare const changeRequestSchema: z.ZodObject<{
11
11
  reason: z.ZodString;
12
12
  }, z.core.$strict>>;
13
13
  }, z.core.$strict>;
14
+ export declare const taskOutcomeSchema: z.ZodObject<{
15
+ taskId: z.ZodString;
16
+ reviewer: z.ZodString;
17
+ bundle: z.ZodString;
18
+ files: z.ZodArray<z.ZodString>;
19
+ status: z.ZodEnum<{
20
+ cancelled: "cancelled";
21
+ completed: "completed";
22
+ failed: "failed";
23
+ timed_out: "timed_out";
24
+ }>;
25
+ error: z.ZodExactOptional<z.ZodString>;
26
+ ended: z.ZodExactOptional<z.ZodEnum<{
27
+ step_cap: "step_cap";
28
+ stopped_early: "stopped_early";
29
+ }>>;
30
+ findings: z.ZodInt;
31
+ durationMs: z.ZodNumber;
32
+ usage: z.ZodObject<{
33
+ inputTokens: z.ZodNumber;
34
+ outputTokens: z.ZodNumber;
35
+ reasoningTokens: z.ZodNumber;
36
+ cachedTokens: z.ZodNumber;
37
+ costUsd: z.ZodNumber;
38
+ }, z.core.$strict>;
39
+ reusedFrom: z.ZodExactOptional<z.ZodString>;
40
+ }, z.core.$strict>;
14
41
  export declare const skippedCellSchema: z.ZodObject<{
15
42
  reviewer: z.ZodString;
16
43
  bundle: z.ZodString;
@@ -63,6 +90,13 @@ export declare const reportOutputSchema: z.ZodObject<{
63
90
  unchanged: "unchanged";
64
91
  unreviewed: "unreviewed";
65
92
  }>;
93
+ }, z.core.$strict>, z.ZodObject<{
94
+ path: z.ZodString;
95
+ status: z.ZodLiteral<"incomplete">;
96
+ ended: z.ZodEnum<{
97
+ step_cap: "step_cap";
98
+ stopped_early: "stopped_early";
99
+ }>;
66
100
  }, z.core.$strict>, z.ZodObject<{
67
101
  path: z.ZodString;
68
102
  status: z.ZodLiteral<"excluded">;
@@ -254,6 +288,10 @@ export declare const reportOutputSchema: z.ZodObject<{
254
288
  timed_out: "timed_out";
255
289
  }>;
256
290
  error: z.ZodExactOptional<z.ZodString>;
291
+ ended: z.ZodExactOptional<z.ZodEnum<{
292
+ step_cap: "step_cap";
293
+ stopped_early: "stopped_early";
294
+ }>>;
257
295
  findings: z.ZodInt;
258
296
  durationMs: z.ZodNumber;
259
297
  usage: z.ZodObject<{
@@ -263,6 +301,7 @@ export declare const reportOutputSchema: z.ZodObject<{
263
301
  cachedTokens: z.ZodNumber;
264
302
  costUsd: z.ZodNumber;
265
303
  }, z.core.$strict>;
304
+ reusedFrom: z.ZodExactOptional<z.ZodString>;
266
305
  }, z.core.$strict>>;
267
306
  skipped: z.ZodArray<z.ZodObject<{
268
307
  reviewer: z.ZodString;
@@ -354,4 +393,3 @@ export declare const reportOutputSchema: z.ZodObject<{
354
393
  }, z.core.$strict>;
355
394
  export declare const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
356
395
  export declare function reportJsonSchema(): Record<string, unknown>;
357
- //# sourceMappingURL=output-schema.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { EFFORT_LEVELS } from "../agent/settings.js";
3
- import { MODEL_TIERS } from "../contracts.js";
3
+ import { INCOMPLETE_ENDINGS, MODEL_TIERS } from "../contracts.js";
4
4
  import { anchorMethodSchema, riskTierSchema, severitySchema, verdictSchema, verificationSchema, } from "../domain.js";
5
5
  import { memoryEntrySchema } from "../memory/memory.js";
6
6
  import { skipReasonSchema } from "../pipeline/matrix.js";
@@ -37,6 +37,11 @@ const coverageEntrySchema = z.discriminatedUnion("status", [
37
37
  path: z.string(),
38
38
  status: z.enum(["reviewed", "failed", "unreviewed", "unchanged"]),
39
39
  }),
40
+ z.strictObject({
41
+ path: z.string(),
42
+ status: z.literal("incomplete"),
43
+ ended: z.enum(INCOMPLETE_ENDINGS),
44
+ }),
40
45
  z.strictObject({
41
46
  path: z.string(),
42
47
  status: z.literal("excluded"),
@@ -101,16 +106,19 @@ const judgeDecisionsSchema = z.strictObject({
101
106
  reason: z.string(),
102
107
  })),
103
108
  });
104
- const taskOutcomeSchema = z.strictObject({
109
+ export const taskOutcomeSchema = z.strictObject({
105
110
  taskId: z.string(),
106
111
  reviewer: z.string(),
107
112
  bundle: z.string(),
108
113
  files: z.array(z.string()),
109
114
  status: taskStatusSchema,
110
115
  error: z.string().exactOptional(),
116
+ ended: z.enum(INCOMPLETE_ENDINGS).exactOptional(),
111
117
  findings: z.int().nonnegative(),
112
118
  durationMs: z.number(),
113
119
  usage: usageSchema,
120
+ // Taken from this earlier run (--resume): usage is what that run paid.
121
+ reusedFrom: z.string().exactOptional(),
114
122
  });
115
123
  export const skippedCellSchema = z.strictObject({
116
124
  reviewer: z.string(),
@@ -202,4 +210,3 @@ export function reportJsonSchema() {
202
210
  ...rest,
203
211
  };
204
212
  }
205
- //# sourceMappingURL=output-schema.js.map
@@ -5,4 +5,3 @@ export type ReportOutput = z.output<typeof reportOutputSchema>;
5
5
  export type OutputFinding = ReportOutput["findings"][number];
6
6
  export type OutputPriorFinding = NonNullable<ReportOutput["rereview"]>["fixed"][number];
7
7
  export declare function toReportOutput(report: ReviewReport): ReportOutput;
8
- //# sourceMappingURL=output.d.ts.map
@@ -51,9 +51,11 @@ function outputChangeRequest(c) {
51
51
  };
52
52
  }
53
53
  function outputCoverage(c) {
54
- return c.status === "excluded"
55
- ? { path: c.path, status: c.status, reason: c.reason }
56
- : { path: c.path, status: c.status };
54
+ if (c.status === "excluded")
55
+ return { path: c.path, status: c.status, reason: c.reason };
56
+ if (c.status === "incomplete")
57
+ return { path: c.path, status: c.status, ended: c.ended };
58
+ return { path: c.path, status: c.status };
57
59
  }
58
60
  function outputFinding(f) {
59
61
  const output = {
@@ -113,6 +115,8 @@ function outputTask(t) {
113
115
  durationMs: t.durationMs,
114
116
  usage: outputUsage(t.usage),
115
117
  ...(t.error === undefined ? {} : { error: t.error }),
118
+ ...(t.ended === undefined ? {} : { ended: t.ended }),
119
+ ...(t.reusedFrom === undefined ? {} : { reusedFrom: t.reusedFrom }),
116
120
  };
117
121
  }
118
122
  function outputSkipped(s) {
@@ -208,4 +212,3 @@ function outputPrior(f) {
208
212
  ...(f.reviewer ? { reviewer: f.reviewer } : {}),
209
213
  };
210
214
  }
211
- //# sourceMappingURL=output.js.map
@@ -23,4 +23,3 @@ export interface AgentProvenance {
23
23
  applied?: boolean;
24
24
  notApplied?: (keyof Sampling)[];
25
25
  }
26
- //# sourceMappingURL=provenance.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=provenance.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReportOutput } from "./output.js";
2
2
  export declare function readReport(path: string): Promise<ReportOutput>;
3
- //# sourceMappingURL=read.d.ts.map
@@ -1,7 +1,10 @@
1
- import { readFile } from "node:fs/promises";
2
1
  import { z } from "zod";
2
+ import { readBoundedFile } from "../bounded-file.js";
3
3
  import { errorMessage, OcraError } from "../errors.js";
4
4
  import { REPORT_VERSION, reportOutputSchema } from "./output-schema.js";
5
+ // Far above what a run's task and finding limits let a report reach; a
6
+ // session's report.json lives in the reviewed tree, which may hold anything.
7
+ const MAX_REPORT_BYTES = 64 * 1024 * 1024;
5
8
  // A JSON report from disk, as ocra wrote it (--format json, a session's
6
9
  // report.json). Anything else is an INPUT_INVALID error saying why, with the
7
10
  // read or parse error as its cause; a caller that may skip a report decides
@@ -9,7 +12,7 @@ import { REPORT_VERSION, reportOutputSchema } from "./output-schema.js";
9
12
  export async function readReport(path) {
10
13
  let text;
11
14
  try {
12
- text = await readFile(path, "utf8");
15
+ text = await readBoundedFile(path, { maxBytes: MAX_REPORT_BYTES, followLinks: true });
13
16
  }
14
17
  catch (error) {
15
18
  throw new OcraError("INPUT_INVALID", `cannot read ${path}: ${errorMessage(error)}`, {
@@ -31,4 +34,3 @@ export async function readReport(path) {
31
34
  }
32
35
  return parsed.data;
33
36
  }
34
- //# sourceMappingURL=read.js.map
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
- import type { Usage } from "../contracts.js";
3
- import type { AnchorMethod, ChangeRequest, Finding, PriorFinding, RiskTier, Verdict } from "../domain.js";
2
+ import type { AttemptRecord, IncompleteEnding, Usage } from "../contracts.js";
3
+ import type { AnchorMethod, ChangeRequest, Finding, PriorFinding, RiskTier, TaskFinding, Verdict } from "../domain.js";
4
4
  import type { JudgeDecisions } from "../judge/judge.js";
5
5
  import type { RememberedEntry } from "../memory/memory.js";
6
6
  import type { SkippedCell } from "../pipeline/matrix.js";
@@ -10,17 +10,23 @@ import type { RunProvenance } from "./provenance.js";
10
10
  export type CoverageEntry = {
11
11
  path: string;
12
12
  status: "reviewed" | "failed" | "unreviewed" | "unchanged";
13
+ } | {
14
+ path: string;
15
+ status: "incomplete";
16
+ ended: IncompleteEnding;
13
17
  } | {
14
18
  path: string;
15
19
  status: "excluded";
16
20
  reason: ExclusionReason;
17
21
  };
22
+ export declare function isUnfinished(entry: CoverageEntry): boolean;
18
23
  export declare function coverageGaps(run: {
19
24
  coverage: readonly CoverageEntry[];
20
25
  tasks: readonly Pick<TaskOutcome, "status">[];
21
26
  }): {
22
27
  notReviewed: number;
23
28
  nothingReviewed: boolean;
29
+ incomplete: Record<IncompleteEnding, number>;
24
30
  };
25
31
  export declare const taskStatusSchema: z.ZodEnum<{
26
32
  cancelled: "cancelled";
@@ -36,9 +42,11 @@ export interface TaskOutcome {
36
42
  files: string[];
37
43
  status: TaskStatus;
38
44
  error?: string;
45
+ ended?: IncompleteEnding;
39
46
  findings: number;
40
47
  durationMs: number;
41
48
  usage: Usage;
49
+ reusedFrom?: string;
42
50
  }
43
51
  export interface ReviewReport {
44
52
  runId: string;
@@ -94,6 +102,10 @@ export type ReviewEvent = {
94
102
  type: "files_bundled";
95
103
  strategy: string;
96
104
  bundles: number;
105
+ groups: {
106
+ label: string;
107
+ files: string[];
108
+ }[];
97
109
  warnings: string[];
98
110
  } | {
99
111
  type: "matrix_planned";
@@ -109,10 +121,22 @@ export type ReviewEvent = {
109
121
  type: "task_progress";
110
122
  taskId: string;
111
123
  message: string;
124
+ attempt?: AttemptRecord;
112
125
  } | {
113
126
  type: "finding";
114
127
  taskId: string;
115
128
  finding: Finding;
129
+ } | {
130
+ type: "finding_dropped";
131
+ taskId: string;
132
+ reason: "outside_bundle";
133
+ file: string;
134
+ title: string;
135
+ } | {
136
+ type: "task_reported";
137
+ taskId: string;
138
+ key: string;
139
+ findings: TaskFinding[];
116
140
  } | {
117
141
  type: "task_finished";
118
142
  outcome: TaskOutcome;
@@ -134,4 +158,3 @@ export interface AnchoringSummary {
134
158
  relocationCalls: number;
135
159
  }
136
160
  export declare function summarizeAnchoring(findings: readonly Finding[], relocationCalls: number): AnchoringSummary;
137
- //# sourceMappingURL=report.d.ts.map
@@ -1,16 +1,25 @@
1
1
  import { z } from "zod";
2
+ // A selected file this run did not finish: the run is incomplete, and the
3
+ // next review of a pull or merge request includes it.
4
+ export function isUnfinished(entry) {
5
+ return (entry.status === "failed" || entry.status === "unreviewed" || entry.status === "incomplete");
6
+ }
2
7
  // How much of the selection this run actually reviewed. Every surface (exit
3
8
  // code, terminal, pull request summary) reads it from here, so none of them
4
9
  // can call a run that reviewed nothing "approved".
5
10
  export function coverageGaps(run) {
6
- const notReviewed = run.coverage.filter((c) => c.status === "failed" || c.status === "unreviewed").length;
11
+ const notReviewed = run.coverage.filter(isUnfinished).length;
12
+ const incomplete = { step_cap: 0, stopped_early: 0 };
13
+ for (const c of run.coverage)
14
+ if (c.status === "incomplete")
15
+ incomplete[c.ended] += 1;
7
16
  // Unchanged files were reviewed by an earlier run, and their findings and
8
17
  // verdict carry over: a re-review whose new files all failed still has them.
9
18
  // A file stays failed while any of its reviewers failed, so a reviewer that
10
19
  // finished its tasks has still reviewed something (#263).
11
20
  const reviewed = run.coverage.some((c) => c.status === "reviewed" || c.status === "unchanged") ||
12
21
  run.tasks.some((t) => t.status === "completed");
13
- return { notReviewed, nothingReviewed: notReviewed > 0 && !reviewed };
22
+ return { notReviewed, nothingReviewed: notReviewed > 0 && !reviewed, incomplete };
14
23
  }
15
24
  export const taskStatusSchema = z.enum(["completed", "failed", "timed_out", "cancelled"]);
16
25
  export function summarizeAnchoring(findings, relocationCalls) {
@@ -29,4 +38,3 @@ export function summarizeAnchoring(findings, relocationCalls) {
29
38
  relocationCalls,
30
39
  };
31
40
  }
32
- //# sourceMappingURL=report.js.map
@@ -1,3 +1,2 @@
1
1
  export declare function isUnsafeCodePoint(code: number): boolean;
2
2
  export declare function serializeOutput(value: unknown, indent?: number): string;
3
- //# sourceMappingURL=serialize.d.ts.map
@@ -24,4 +24,3 @@ export function serializeOutput(value, indent = 2) {
24
24
  }
25
25
  return out;
26
26
  }
27
- //# sourceMappingURL=serialize.js.map
@@ -1,3 +1,2 @@
1
1
  import type { PriorReview } from "../domain.js";
2
2
  export declare function priorCodePresence(prior: PriorReview | undefined, reported: ReadonlySet<string>, readFile: (path: string) => Promise<string | undefined>): Promise<Map<string, boolean>>;
3
- //# sourceMappingURL=presence.d.ts.map
@@ -24,4 +24,3 @@ export async function priorCodePresence(prior, reported, readFile) {
24
24
  });
25
25
  return presence;
26
26
  }
27
- //# sourceMappingURL=presence.js.map
@@ -1,4 +1,3 @@
1
1
  import type { LineRange, QuoteSignature } from "../domain.js";
2
2
  export declare function quoteSignature(content: string, range: LineRange): QuoteSignature | undefined;
3
3
  export declare function containsQuote(content: string, signature: QuoteSignature): boolean;
4
- //# sourceMappingURL=quote.d.ts.map
@@ -25,4 +25,3 @@ export function containsQuote(content, signature) {
25
25
  function hashLines(lines) {
26
26
  return shortHash(lines.join("\n"));
27
27
  }
28
- //# sourceMappingURL=quote.js.map
@@ -17,4 +17,3 @@ export interface Reconciled {
17
17
  }
18
18
  export declare function reconcile(input: ReconcileInput): Reconciled;
19
19
  export declare function stillOpen(reconciled: Reconciled): PriorFinding[];
20
- //# sourceMappingURL=reconcile.d.ts.map
@@ -52,4 +52,3 @@ export function stillOpen(reconciled) {
52
52
  function replyFields(replies) {
53
53
  return replies && replies.length > 0 ? { replies: [...replies] } : {};
54
54
  }
55
- //# sourceMappingURL=reconcile.js.map
@@ -6,4 +6,3 @@ export interface SymbolUse {
6
6
  uses: CodeMatch[];
7
7
  }
8
8
  export declare function findCallers(files: readonly FileDiff[], context: Pick<ReviewContext, "searchCode">): Promise<SymbolUse[]>;
9
- //# sourceMappingURL=impact.d.ts.map
@@ -50,4 +50,3 @@ export async function findCallers(files, context) {
50
50
  function escapeRegExp(text) {
51
51
  return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
52
52
  }
53
- //# sourceMappingURL=impact.js.map
@@ -8,4 +8,3 @@ export declare function planBundle(runtime: AgentRuntime, reviewer: ReviewerDefi
8
8
  usage: Usage[];
9
9
  warning?: string;
10
10
  }>;
11
- //# sourceMappingURL=plan-phase.d.ts.map
@@ -32,4 +32,3 @@ export async function planBundle(runtime, reviewer, prompt, signal, call) {
32
32
  };
33
33
  }
34
34
  }
35
- //# sourceMappingURL=plan-phase.js.map
@@ -13,4 +13,3 @@ export declare function labelled(label: string, value: string, separator?: strin
13
13
  export declare function truncated(text: string, max: number): PromptText;
14
14
  export declare function oneLine(text: string): string;
15
15
  export {};
16
- //# sourceMappingURL=prompt-text.d.ts.map
@@ -87,4 +87,3 @@ export function truncated(text, max) {
87
87
  export function oneLine(text) {
88
88
  return text.replace(/[\r\n\u2028\u2029]+/g, " ");
89
89
  }
90
- //# sourceMappingURL=prompt-text.js.map
@@ -22,4 +22,3 @@ export interface ReviewPrompt {
22
22
  }
23
23
  export declare function buildReviewPrompt(input: ReviewPromptInput): ReviewPrompt;
24
24
  export declare function renderChangeRequest(cr: ChangeRequest, maxDescription?: number): PromptText;
25
- //# sourceMappingURL=prompt.d.ts.map
@@ -82,4 +82,3 @@ function renderHunk(hunk) {
82
82
  });
83
83
  return [hunk.header, ...lines].join("\n");
84
84
  }
85
- //# sourceMappingURL=prompt.js.map
@@ -14,4 +14,3 @@ export interface ReviewerDefinition {
14
14
  scope?: ReviewerScope;
15
15
  rules?: RuleSet;
16
16
  }
17
- //# sourceMappingURL=reviewer.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=reviewer.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReviewerDefinition } from "../reviewer.js";
2
2
  export declare const agentsMdReviewer: ReviewerDefinition;
3
- //# sourceMappingURL=agents-md.d.ts.map
@@ -42,4 +42,3 @@ export const agentsMdReviewer = {
42
42
  systemPrompt: SYSTEM_PROMPT,
43
43
  scope: { minTier: "lite", ignore: [...TEST_FILES], requiresGuidelines: true },
44
44
  };
45
- //# sourceMappingURL=agents-md.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReviewerDefinition } from "../reviewer.js";
2
2
  export declare const correctnessReviewer: ReviewerDefinition;
3
- //# sourceMappingURL=correctness.d.ts.map
@@ -45,4 +45,3 @@ export const correctnessReviewer = {
45
45
  systemPrompt: SYSTEM_PROMPT,
46
46
  rules: CORRECTNESS_RULES,
47
47
  };
48
- //# sourceMappingURL=correctness.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReviewerDefinition } from "../reviewer.js";
2
2
  export declare const docsReviewer: ReviewerDefinition;
3
- //# sourceMappingURL=docs.d.ts.map
@@ -44,4 +44,3 @@ export const docsReviewer = {
44
44
  systemPrompt: SYSTEM_PROMPT,
45
45
  scope: { minTier: "lite", ignore: [...TEST_FILES] },
46
46
  };
47
- //# sourceMappingURL=docs.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReviewerDefinition } from "../reviewer.js";
2
2
  export declare const performanceReviewer: ReviewerDefinition;
3
- //# sourceMappingURL=performance.d.ts.map
@@ -56,4 +56,3 @@ export const performanceReviewer = {
56
56
  },
57
57
  rules: { general: PERFORMANCE_RULES },
58
58
  };
59
- //# sourceMappingURL=performance.js.map
@@ -1,3 +1,2 @@
1
1
  export declare const DOCUMENTATION_FILES: string[];
2
2
  export declare const TEST_FILES: string[];
3
- //# sourceMappingURL=scopes.d.ts.map
@@ -6,4 +6,3 @@ export const TEST_FILES = [
6
6
  "**/{__tests__,__fixtures__,__snapshots__,__mocks__}/**",
7
7
  "**/{test,tests,fixtures,testdata}/**",
8
8
  ];
9
- //# sourceMappingURL=scopes.js.map
@@ -1,3 +1,2 @@
1
1
  import type { ReviewerDefinition } from "../reviewer.js";
2
2
  export declare const securityReviewer: ReviewerDefinition;
3
- //# sourceMappingURL=security.d.ts.map
@@ -49,4 +49,3 @@ export const securityReviewer = {
49
49
  scope: { minTier: "lite", ignore: [...DOCUMENTATION_FILES, ...TEST_FILES] },
50
50
  rules: { general: SECURITY_RULES },
51
51
  };
52
- //# sourceMappingURL=security.js.map
@@ -6,4 +6,3 @@ export declare const REVIEW_TOOLS: {
6
6
  readonly taskDone: "task_done";
7
7
  };
8
8
  export type ReviewToolName = (typeof REVIEW_TOOLS)[keyof typeof REVIEW_TOOLS];
9
- //# sourceMappingURL=tools.d.ts.map
@@ -5,4 +5,3 @@ export const REVIEW_TOOLS = {
5
5
  reportFinding: "report_finding",
6
6
  taskDone: "task_done",
7
7
  };
8
- //# sourceMappingURL=tools.js.map
@@ -1,2 +1 @@
1
1
  export declare const GENERAL_RULES = "### General correctness\n- Logic that produces a wrong result on a reachable input: inverted or incomplete conditions, off-by-one bounds, wrong operator, wrong variable, unreachable or dead branches that were meant to run.\n- Broken contracts between changed code and its callers or callees: changed signatures, return shapes, units, nullability or error behavior whose other side was not updated.\n- Error handling that hides failure: swallowed exceptions, errors converted to success or default values, partial writes reported as complete, cleanup that masks the original error.\n- State and resource bugs: missing cleanup on error paths, double release, leaked handles, mutation of shared or input data that callers do not expect.\n- Concurrency hazards that the code makes reachable: unsynchronized shared state, check-then-act races, missing cancellation or timeouts on blocking work.\n- Data integrity: lost updates, non-idempotent retries, inconsistent writes across stores, incorrect migrations or backfills.\n- Security defects visible in the change: injection, missing authorization on a new path, secrets in code or logs, unsafe deserialization.";
2
- //# sourceMappingURL=general.d.ts.map