@open-cr-agent/core 0.5.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 (207) hide show
  1. package/README.md +1 -1
  2. package/dist/{pipeline → agent}/budget.d.ts +0 -1
  3. package/dist/{pipeline → agent}/budget.js +0 -1
  4. package/dist/agent/json.d.ts +1 -0
  5. package/dist/agent/json.js +11 -0
  6. package/dist/{pipeline → agent}/pool.d.ts +0 -1
  7. package/dist/{pipeline → agent}/pool.js +2 -2
  8. package/dist/{pipeline/agents.d.ts → agent/settings.d.ts} +9 -5
  9. package/dist/{pipeline/agents.js → agent/settings.js} +14 -6
  10. package/dist/{pipeline → agent}/usage.d.ts +0 -1
  11. package/dist/{pipeline → 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 +5 -5
  16. package/dist/anchor/relocate.d.ts +1 -3
  17. package/dist/anchor/relocate.js +2 -3
  18. package/dist/at.d.ts +1 -0
  19. package/dist/at.js +11 -0
  20. package/dist/bounded-file.d.ts +12 -0
  21. package/dist/bounded-file.js +47 -0
  22. package/dist/bundle/bundle.d.ts +2 -2
  23. package/dist/bundle/bundle.js +3 -3
  24. package/dist/bundle/grouping.d.ts +0 -2
  25. package/dist/bundle/grouping.js +0 -1
  26. package/dist/bundle/runtime-grouper.d.ts +4 -0
  27. package/dist/{pipeline/helpers.js → bundle/runtime-grouper.js} +4 -14
  28. package/dist/contracts.d.ts +16 -15
  29. package/dist/contracts.js +6 -2
  30. package/dist/diff/hunks.d.ts +0 -1
  31. package/dist/diff/hunks.js +3 -3
  32. package/dist/diff/parse.d.ts +0 -1
  33. package/dist/diff/parse.js +5 -5
  34. package/dist/diff/quoted-path.d.ts +0 -1
  35. package/dist/diff/quoted-path.js +16 -16
  36. package/dist/domain.d.ts +14 -3
  37. package/dist/domain.js +2 -3
  38. package/dist/errors.d.ts +3 -2
  39. package/dist/errors.js +12 -1
  40. package/dist/hash.d.ts +1 -0
  41. package/dist/hash.js +6 -0
  42. package/dist/index.d.ts +27 -13
  43. package/dist/index.js +16 -6
  44. package/dist/internal.d.ts +10 -13
  45. package/dist/internal.js +10 -13
  46. package/dist/judge/judge.d.ts +1 -3
  47. package/dist/judge/judge.js +9 -9
  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 -2
  51. package/dist/judge/verdict.js +1 -2
  52. package/dist/memory/memory.d.ts +0 -1
  53. package/dist/memory/memory.js +2 -3
  54. package/dist/net/proxied-fetch.d.ts +0 -1
  55. package/dist/net/proxied-fetch.js +2 -2
  56. package/dist/pipeline/assemble-report.d.ts +21 -0
  57. package/dist/pipeline/assemble-report.js +98 -0
  58. package/dist/pipeline/check-stage.d.ts +12 -0
  59. package/dist/pipeline/check-stage.js +69 -0
  60. package/dist/pipeline/context.d.ts +2 -2
  61. package/dist/pipeline/context.js +8 -5
  62. package/dist/pipeline/coverage.d.ts +1 -2
  63. package/dist/pipeline/coverage.js +38 -17
  64. package/dist/pipeline/execute-stage.d.ts +25 -0
  65. package/dist/pipeline/execute-stage.js +130 -0
  66. package/dist/pipeline/execute.d.ts +11 -6
  67. package/dist/pipeline/execute.js +147 -59
  68. package/dist/pipeline/filter-stage.d.ts +15 -0
  69. package/dist/pipeline/filter-stage.js +45 -0
  70. package/dist/pipeline/findings.d.ts +0 -1
  71. package/dist/pipeline/findings.js +3 -3
  72. package/dist/pipeline/imports.d.ts +1 -2
  73. package/dist/pipeline/imports.js +1 -2
  74. package/dist/pipeline/matrix.d.ts +1 -9
  75. package/dist/pipeline/matrix.js +0 -1
  76. package/dist/pipeline/options.d.ts +66 -0
  77. package/dist/pipeline/options.js +8 -0
  78. package/dist/pipeline/plan-output.d.ts +89 -0
  79. package/dist/pipeline/plan-output.js +108 -0
  80. package/dist/pipeline/plan.d.ts +3 -5
  81. package/dist/pipeline/plan.js +10 -6
  82. package/dist/pipeline/preview.d.ts +23 -10
  83. package/dist/pipeline/preview.js +25 -5
  84. package/dist/pipeline/provenance.d.ts +4 -28
  85. package/dist/pipeline/provenance.js +2 -3
  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 +2 -49
  91. package/dist/pipeline/run.js +18 -274
  92. package/dist/pipeline/task.d.ts +5 -10
  93. package/dist/pipeline/task.js +10 -8
  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 +5 -5
  99. package/dist/plugin/registry.js +3 -4
  100. package/dist/plugin/types.d.ts +3 -6
  101. package/dist/plugin/types.js +0 -1
  102. package/dist/{pipeline → report}/output-schema.d.ts +95 -63
  103. package/dist/{pipeline → report}/output-schema.js +64 -42
  104. package/dist/report/output.d.ts +7 -0
  105. package/dist/report/output.js +214 -0
  106. package/dist/report/provenance.d.ts +25 -0
  107. package/dist/report/provenance.js +1 -0
  108. package/dist/report/read.d.ts +2 -0
  109. package/dist/report/read.js +36 -0
  110. package/dist/{pipeline → report}/report.d.ts +27 -4
  111. package/dist/{pipeline → report}/report.js +11 -3
  112. package/dist/report/serialize.d.ts +2 -0
  113. package/dist/report/serialize.js +26 -0
  114. package/dist/rereview/presence.d.ts +0 -1
  115. package/dist/rereview/presence.js +1 -2
  116. package/dist/rereview/quote.d.ts +0 -1
  117. package/dist/rereview/quote.js +2 -3
  118. package/dist/rereview/reconcile.d.ts +1 -2
  119. package/dist/rereview/reconcile.js +0 -1
  120. package/dist/review/impact.d.ts +0 -3
  121. package/dist/review/impact.js +2 -3
  122. package/dist/review/plan-phase.d.ts +1 -3
  123. package/dist/review/plan-phase.js +2 -3
  124. package/dist/review/prompt-text.d.ts +1 -2
  125. package/dist/review/prompt-text.js +1 -2
  126. package/dist/review/prompt.d.ts +0 -4
  127. package/dist/review/prompt.js +3 -4
  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 -5
  149. package/dist/rules/builtin/index.js +1 -3
  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 -7
  163. package/dist/rules/repo-rules.js +3 -4
  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 +18 -0
  171. package/dist/runtime/chain-runner.js +62 -0
  172. package/dist/runtime/effort-capability.d.ts +13 -0
  173. package/dist/runtime/effort-capability.js +69 -0
  174. package/dist/runtime/failback.d.ts +0 -10
  175. package/dist/runtime/failback.js +52 -13
  176. package/dist/runtime/models.d.ts +1 -3
  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 -17
  181. package/dist/runtime/tools.js +3 -4
  182. package/dist/sarif/candidates.d.ts +2 -2
  183. package/dist/sarif/candidates.js +0 -1
  184. package/dist/sarif/schema.d.ts +2 -3
  185. package/dist/sarif/schema.js +4 -5
  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 +4 -4
  191. package/dist/session/jsonl.js +14 -8
  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 +2 -3
  197. package/dist/triage.js +1 -2
  198. package/dist/vcs.d.ts +14 -0
  199. package/dist/vcs.js +1 -0
  200. package/dist/verify/prompt.d.ts +0 -7
  201. package/dist/verify/prompt.js +1 -2
  202. package/dist/verify/verify.d.ts +2 -4
  203. package/dist/verify/verify.js +4 -5
  204. package/package.json +1 -1
  205. package/dist/pipeline/helpers.d.ts +0 -7
  206. package/dist/pipeline/output.d.ts +0 -79
  207. package/dist/pipeline/output.js +0 -132
@@ -1,5 +1,5 @@
1
+ import { AGENT_ROLES } from "../agent/settings.js";
1
2
  import { errorMessage, OcraError } from "../errors.js";
2
- import { AGENT_ROLES } from "../pipeline/agents.js";
3
3
  export class PluginError extends OcraError {
4
4
  constructor(message, options) {
5
5
  super("PLUGIN_INVALID", message, options);
@@ -7,8 +7,6 @@ export class PluginError extends OcraError {
7
7
  }
8
8
  }
9
9
  export class PluginRegistry {
10
- reservedToolNames;
11
- warn;
12
10
  vcs = new Map();
13
11
  runtimes = new Map();
14
12
  reviewerMap = new Map();
@@ -16,6 +14,8 @@ export class PluginRegistry {
16
14
  ruleList = [];
17
15
  listeners = [];
18
16
  frozen = false;
17
+ reservedToolNames;
18
+ warn;
19
19
  constructor(reservedToolNames, warn = () => { }) {
20
20
  this.reservedToolNames = reservedToolNames;
21
21
  this.warn = warn;
@@ -111,4 +111,3 @@ export class PluginRegistry {
111
111
  }
112
112
  }
113
113
  }
114
- //# sourceMappingURL=registry.js.map
@@ -1,12 +1,10 @@
1
1
  import type { z } from "zod";
2
- import type { AgentRuntime, ModelTier, ReviewContext, Sampling, VcsAdapter } from "../contracts.js";
3
- import type { ReviewEvent } from "../pipeline/report.js";
2
+ import type { AgentRuntime, ModelChains, ReviewContext, Sampling } from "../contracts.js";
3
+ import type { ReviewEvent } from "../report/report.js";
4
4
  import type { ReviewerDefinition } from "../review/reviewer.js";
5
5
  import type { RepoRule } from "../rules/repo-rules.js";
6
+ import type { VcsAdapter } from "../vcs.js";
6
7
  export type Env = Readonly<Record<string, string | undefined>>;
7
- export type ModelChains = {
8
- [Tier in ModelTier]?: readonly string[];
9
- };
10
8
  export interface RuntimeOptions {
11
9
  models: ModelChains;
12
10
  agentModels?: Readonly<Record<string, readonly string[]>>;
@@ -64,4 +62,3 @@ export interface OcraPlugin<Settings = unknown> {
64
62
  configure?(ctx: ConfigureContext<Settings>): void | Promise<void>;
65
63
  postConfigure?(ctx: PostConfigureContext<Settings>): void | Promise<void>;
66
64
  }
67
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,50 +1,64 @@
1
1
  import { z } from "zod";
2
- import { type ReportOutput } from "./output.js";
3
- export declare const outputFindingSchema: z.ZodObject<{
4
- fingerprint: z.ZodString;
5
- reviewer: z.ZodString;
6
- category: z.ZodString;
7
- severity: z.ZodEnum<{
8
- critical: "critical";
9
- suggestion: "suggestion";
10
- warning: "warning";
11
- }>;
12
- verification: z.ZodEnum<{
13
- confirmed: "confirmed";
14
- uncertain: "uncertain";
15
- unchecked: "unchecked";
16
- }>;
17
- file: z.ZodString;
18
- lines: z.ZodOptional<z.ZodObject<{
19
- start: z.ZodInt;
20
- end: z.ZodInt;
2
+ export declare const REPORT_VERSION = 1;
3
+ export declare const changeRequestSchema: z.ZodObject<{
4
+ id: z.ZodString;
5
+ title: z.ZodString;
6
+ description: z.ZodString;
7
+ baseSha: z.ZodString;
8
+ headSha: z.ZodString;
9
+ override: z.ZodExactOptional<z.ZodObject<{
10
+ by: z.ZodString;
11
+ reason: z.ZodString;
21
12
  }, z.core.$strict>>;
22
- inDiff: z.ZodBoolean;
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>;
23
19
  status: z.ZodEnum<{
24
- new: "new";
25
- unfixed: "unfixed";
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>;
41
+ export declare const skippedCellSchema: z.ZodObject<{
42
+ reviewer: z.ZodString;
43
+ bundle: z.ZodString;
44
+ reason: z.ZodEnum<{
45
+ below_tier: "below_tier";
46
+ disabled: "disabled";
47
+ no_guidelines: "no_guidelines";
48
+ no_matching_files: "no_matching_files";
49
+ task_limit: "task_limit";
26
50
  }>;
27
- title: z.ZodString;
28
- body: z.ZodString;
29
- suggestion: z.ZodOptional<z.ZodString>;
30
- evidence: z.ZodArray<z.ZodString>;
31
- code: z.ZodString;
32
- lowConfidence: z.ZodOptional<z.ZodLiteral<true>>;
33
- provenance: z.ZodOptional<z.ZodObject<{
34
- task: z.ZodString;
35
- model: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strict>>;
37
51
  }, z.core.$strict>;
38
52
  export declare const reportOutputSchema: z.ZodObject<{
39
53
  version: z.ZodLiteral<1>;
40
- runId: z.ZodOptional<z.ZodString>;
54
+ runId: z.ZodExactOptional<z.ZodString>;
41
55
  changeRequest: z.ZodObject<{
42
56
  id: z.ZodString;
43
57
  title: z.ZodString;
44
58
  description: z.ZodString;
45
59
  baseSha: z.ZodString;
46
60
  headSha: z.ZodString;
47
- override: z.ZodOptional<z.ZodObject<{
61
+ override: z.ZodExactOptional<z.ZodObject<{
48
62
  by: z.ZodString;
49
63
  reason: z.ZodString;
50
64
  }, z.core.$strict>>;
@@ -61,7 +75,7 @@ export declare const reportOutputSchema: z.ZodObject<{
61
75
  significant_concerns: "significant_concerns";
62
76
  }>;
63
77
  summary: z.ZodString;
64
- scope: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
78
+ scope: z.ZodExactOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
65
79
  mode: z.ZodLiteral<"incremental">;
66
80
  since: z.ZodString;
67
81
  }, z.core.$strict>, z.ZodObject<{
@@ -76,6 +90,13 @@ export declare const reportOutputSchema: z.ZodObject<{
76
90
  unchanged: "unchanged";
77
91
  unreviewed: "unreviewed";
78
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
+ }>;
79
100
  }, z.core.$strict>, z.ZodObject<{
80
101
  path: z.ZodString;
81
102
  status: z.ZodLiteral<"excluded">;
@@ -104,7 +125,7 @@ export declare const reportOutputSchema: z.ZodObject<{
104
125
  unchecked: "unchecked";
105
126
  }>;
106
127
  file: z.ZodString;
107
- lines: z.ZodOptional<z.ZodObject<{
128
+ lines: z.ZodExactOptional<z.ZodObject<{
108
129
  start: z.ZodInt;
109
130
  end: z.ZodInt;
110
131
  }, z.core.$strict>>;
@@ -115,13 +136,18 @@ export declare const reportOutputSchema: z.ZodObject<{
115
136
  }>;
116
137
  title: z.ZodString;
117
138
  body: z.ZodString;
118
- suggestion: z.ZodOptional<z.ZodString>;
139
+ suggestion: z.ZodExactOptional<z.ZodString>;
140
+ fix: z.ZodExactOptional<z.ZodObject<{
141
+ startLine: z.ZodInt;
142
+ endLine: z.ZodInt;
143
+ replacement: z.ZodString;
144
+ }, z.core.$strict>>;
119
145
  evidence: z.ZodArray<z.ZodString>;
120
146
  code: z.ZodString;
121
- lowConfidence: z.ZodOptional<z.ZodLiteral<true>>;
122
- provenance: z.ZodOptional<z.ZodObject<{
147
+ lowConfidence: z.ZodExactOptional<z.ZodLiteral<true>>;
148
+ provenance: z.ZodExactOptional<z.ZodObject<{
123
149
  task: z.ZodString;
124
- model: z.ZodOptional<z.ZodString>;
150
+ model: z.ZodExactOptional<z.ZodString>;
125
151
  }, z.core.$strict>>;
126
152
  }, z.core.$strict>>;
127
153
  unverifiedCriticals: z.ZodInt;
@@ -137,12 +163,12 @@ export declare const reportOutputSchema: z.ZodObject<{
137
163
  title: z.ZodString;
138
164
  reason: z.ZodString;
139
165
  added: z.ZodOptional<z.ZodString>;
140
- source: z.ZodOptional<z.ZodEnum<{
166
+ source: z.ZodExactOptional<z.ZodEnum<{
141
167
  account: "account";
142
168
  repository: "repository";
143
169
  }>>;
144
170
  }, z.core.$strip>>;
145
- judgement: z.ZodOptional<z.ZodObject<{
171
+ judgement: z.ZodExactOptional<z.ZodObject<{
146
172
  merged: z.ZodArray<z.ZodObject<{
147
173
  kept: z.ZodString;
148
174
  merged: z.ZodArray<z.ZodString>;
@@ -168,7 +194,7 @@ export declare const reportOutputSchema: z.ZodObject<{
168
194
  reason: z.ZodString;
169
195
  }, z.core.$strict>>;
170
196
  }, z.core.$strict>>;
171
- rereview: z.ZodOptional<z.ZodObject<{
197
+ rereview: z.ZodExactOptional<z.ZodObject<{
172
198
  fixed: z.ZodArray<z.ZodObject<{
173
199
  fingerprint: z.ZodString;
174
200
  title: z.ZodString;
@@ -183,6 +209,7 @@ export declare const reportOutputSchema: z.ZodObject<{
183
209
  uncertain: "uncertain";
184
210
  unchecked: "unchecked";
185
211
  }>;
212
+ reviewer: z.ZodExactOptional<z.ZodString>;
186
213
  }, z.core.$strict>>;
187
214
  notReproduced: z.ZodArray<z.ZodObject<{
188
215
  fingerprint: z.ZodString;
@@ -198,6 +225,7 @@ export declare const reportOutputSchema: z.ZodObject<{
198
225
  uncertain: "uncertain";
199
226
  unchecked: "unchecked";
200
227
  }>;
228
+ reviewer: z.ZodExactOptional<z.ZodString>;
201
229
  }, z.core.$strict>>;
202
230
  notRechecked: z.ZodArray<z.ZodObject<{
203
231
  fingerprint: z.ZodString;
@@ -213,6 +241,7 @@ export declare const reportOutputSchema: z.ZodObject<{
213
241
  uncertain: "uncertain";
214
242
  unchecked: "unchecked";
215
243
  }>;
244
+ reviewer: z.ZodExactOptional<z.ZodString>;
216
245
  }, z.core.$strict>>;
217
246
  unchanged: z.ZodArray<z.ZodObject<{
218
247
  fingerprint: z.ZodString;
@@ -228,6 +257,7 @@ export declare const reportOutputSchema: z.ZodObject<{
228
257
  uncertain: "uncertain";
229
258
  unchecked: "unchecked";
230
259
  }>;
260
+ reviewer: z.ZodExactOptional<z.ZodString>;
231
261
  }, z.core.$strict>>;
232
262
  dismissed: z.ZodArray<z.ZodObject<{
233
263
  fingerprint: z.ZodString;
@@ -243,6 +273,7 @@ export declare const reportOutputSchema: z.ZodObject<{
243
273
  uncertain: "uncertain";
244
274
  unchecked: "unchecked";
245
275
  }>;
276
+ reviewer: z.ZodExactOptional<z.ZodString>;
246
277
  }, z.core.$strict>>;
247
278
  }, z.core.$strict>>;
248
279
  tasks: z.ZodArray<z.ZodObject<{
@@ -256,7 +287,11 @@ export declare const reportOutputSchema: z.ZodObject<{
256
287
  failed: "failed";
257
288
  timed_out: "timed_out";
258
289
  }>;
259
- error: z.ZodOptional<z.ZodString>;
290
+ error: z.ZodExactOptional<z.ZodString>;
291
+ ended: z.ZodExactOptional<z.ZodEnum<{
292
+ step_cap: "step_cap";
293
+ stopped_early: "stopped_early";
294
+ }>>;
260
295
  findings: z.ZodInt;
261
296
  durationMs: z.ZodNumber;
262
297
  usage: z.ZodObject<{
@@ -266,6 +301,7 @@ export declare const reportOutputSchema: z.ZodObject<{
266
301
  cachedTokens: z.ZodNumber;
267
302
  costUsd: z.ZodNumber;
268
303
  }, z.core.$strict>;
304
+ reusedFrom: z.ZodExactOptional<z.ZodString>;
269
305
  }, z.core.$strict>>;
270
306
  skipped: z.ZodArray<z.ZodObject<{
271
307
  reviewer: z.ZodString;
@@ -282,7 +318,7 @@ export declare const reportOutputSchema: z.ZodObject<{
282
318
  label: z.ZodString;
283
319
  files: z.ZodArray<z.ZodString>;
284
320
  }, z.core.$strict>>;
285
- anchoring: z.ZodOptional<z.ZodObject<{
321
+ anchoring: z.ZodExactOptional<z.ZodObject<{
286
322
  byMethod: z.ZodRecord<z.ZodEnum<{
287
323
  cross_file: "cross_file";
288
324
  file: "file";
@@ -293,56 +329,56 @@ export declare const reportOutputSchema: z.ZodObject<{
293
329
  ambiguous: z.ZodInt;
294
330
  relocationCalls: z.ZodInt;
295
331
  }, z.core.$strict>>;
296
- spendLimit: z.ZodOptional<z.ZodObject<{
332
+ spendLimit: z.ZodExactOptional<z.ZodObject<{
297
333
  usd: z.ZodNumber;
298
- reached: z.ZodOptional<z.ZodEnum<{
334
+ reached: z.ZodExactOptional<z.ZodEnum<{
299
335
  review: "review";
300
336
  total: "total";
301
337
  }>>;
302
338
  }, z.core.$strict>>;
303
- provenance: z.ZodOptional<z.ZodObject<{
339
+ provenance: z.ZodExactOptional<z.ZodObject<{
304
340
  ocraVersion: z.ZodString;
305
341
  promptHash: z.ZodString;
306
342
  configHash: z.ZodString;
307
343
  sampling: z.ZodObject<{
308
- temperature: z.ZodOptional<z.ZodNumber>;
309
- seed: z.ZodOptional<z.ZodInt>;
310
- notApplied: z.ZodOptional<z.ZodArray<z.ZodEnum<{
344
+ temperature: z.ZodExactOptional<z.ZodNumber>;
345
+ seed: z.ZodExactOptional<z.ZodInt>;
346
+ notApplied: z.ZodExactOptional<z.ZodArray<z.ZodEnum<{
311
347
  seed: "seed";
312
348
  temperature: "temperature";
313
349
  }>>>;
314
350
  }, z.core.$strict>;
315
- agents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
351
+ agents: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
316
352
  tier: z.ZodEnum<{
317
353
  light: "light";
318
354
  standard: "standard";
319
355
  top: "top";
320
356
  }>;
321
- models: z.ZodOptional<z.ZodArray<z.ZodString>>;
322
- effort: z.ZodOptional<z.ZodEnum<{
357
+ models: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
358
+ effort: z.ZodExactOptional<z.ZodEnum<{
323
359
  high: "high";
324
360
  low: "low";
325
361
  medium: "medium";
326
362
  minimal: "minimal";
327
363
  none: "none";
328
364
  }>>;
329
- applied: z.ZodOptional<z.ZodBoolean>;
330
- notApplied: z.ZodOptional<z.ZodArray<z.ZodEnum<{
365
+ applied: z.ZodExactOptional<z.ZodBoolean>;
366
+ notApplied: z.ZodExactOptional<z.ZodArray<z.ZodEnum<{
331
367
  seed: "seed";
332
368
  temperature: "temperature";
333
369
  }>>>;
334
370
  }, z.core.$strict>>>;
335
- rules: z.ZodOptional<z.ZodArray<z.ZodObject<{
371
+ rules: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
336
372
  path: z.ZodArray<z.ZodString>;
337
373
  rule: z.ZodString;
338
- source: z.ZodOptional<z.ZodEnum<{
374
+ source: z.ZodExactOptional<z.ZodEnum<{
339
375
  account: "account";
340
376
  plugin: "plugin";
341
377
  repository: "repository";
342
378
  shared: "shared";
343
379
  }>>;
344
380
  }, z.core.$strict>>>;
345
- accountSettings: z.ZodOptional<z.ZodObject<{
381
+ accountSettings: z.ZodExactOptional<z.ZodObject<{
346
382
  version: z.ZodNullable<z.ZodString>;
347
383
  }, z.core.$strict>>;
348
384
  }, z.core.$strict>>;
@@ -355,9 +391,5 @@ export declare const reportOutputSchema: z.ZodObject<{
355
391
  }, z.core.$strict>;
356
392
  warnings: z.ZodArray<z.ZodString>;
357
393
  }, z.core.$strict>;
358
- type OutputFromSchema = z.output<typeof reportOutputSchema>;
359
- export declare function asSchemaOutput(output: ReportOutput): OutputFromSchema;
360
394
  export declare const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
361
395
  export declare function reportJsonSchema(): Record<string, unknown>;
362
- export {};
363
- //# sourceMappingURL=output-schema.d.ts.map
@@ -1,15 +1,22 @@
1
1
  import { z } from "zod";
2
+ import { EFFORT_LEVELS } from "../agent/settings.js";
3
+ import { INCOMPLETE_ENDINGS, MODEL_TIERS } from "../contracts.js";
2
4
  import { anchorMethodSchema, riskTierSchema, severitySchema, verdictSchema, verificationSchema, } from "../domain.js";
3
5
  import { memoryEntrySchema } from "../memory/memory.js";
6
+ import { skipReasonSchema } from "../pipeline/matrix.js";
4
7
  import { exclusionReasonSchema } from "../select/select.js";
5
- import { EFFORT_LEVELS } from "./agents.js";
6
- import { skipReasonSchema } from "./matrix.js";
7
- import { REPORT_VERSION } from "./output.js";
8
8
  import { taskStatusSchema } from "./report.js";
9
- // The JSON report as a schema: what `toReportOutput` writes, no more. Every
10
- // object is strict, so a field added to the output without a schema change
11
- // fails the tests, and the published JSON Schema (docs/schema/report.v1.json)
12
- // is generated from here, never written by hand.
9
+ // The published shape of a review: `--format json` and a session's
10
+ // report.json. It is a contract with scripts and CI, so it carries a version
11
+ // and only what a reader can rely on; internal fields (per-run ids, how each
12
+ // finding was anchored, code signatures, platform state) stay out, though the
13
+ // anchoring counts of the whole run are in. Change it only by adding optional
14
+ // fields, or by a new version.
15
+ export const REPORT_VERSION = 1;
16
+ // The JSON report as a schema, the one definition of its shape: the
17
+ // `ReportOutput` type is derived from it, and the published JSON Schema
18
+ // (docs/schema/report.v1.json) is generated from it. Every object is strict,
19
+ // so a field `toReportOutput` writes without a schema change fails the tests.
13
20
  const usageSchema = z.strictObject({
14
21
  inputTokens: z.number(),
15
22
  outputTokens: z.number(),
@@ -17,19 +24,24 @@ const usageSchema = z.strictObject({
17
24
  cachedTokens: z.number(),
18
25
  costUsd: z.number(),
19
26
  });
20
- const changeRequestSchema = z.strictObject({
27
+ export const changeRequestSchema = z.strictObject({
21
28
  id: z.string(),
22
29
  title: z.string(),
23
30
  description: z.string(),
24
31
  baseSha: z.string(),
25
32
  headSha: z.string(),
26
- override: z.strictObject({ by: z.string(), reason: z.string() }).optional(),
33
+ override: z.strictObject({ by: z.string(), reason: z.string() }).exactOptional(),
27
34
  });
28
35
  const coverageEntrySchema = z.discriminatedUnion("status", [
29
36
  z.strictObject({
30
37
  path: z.string(),
31
38
  status: z.enum(["reviewed", "failed", "unreviewed", "unchanged"]),
32
39
  }),
40
+ z.strictObject({
41
+ path: z.string(),
42
+ status: z.literal("incomplete"),
43
+ ended: z.enum(INCOMPLETE_ENDINGS),
44
+ }),
33
45
  z.strictObject({
34
46
  path: z.string(),
35
47
  status: z.literal("excluded"),
@@ -37,23 +49,33 @@ const coverageEntrySchema = z.discriminatedUnion("status", [
37
49
  }),
38
50
  ]);
39
51
  const linesSchema = z.strictObject({ start: z.int().positive(), end: z.int().positive() });
40
- export const outputFindingSchema = z.strictObject({
52
+ const fixSchema = z
53
+ .strictObject({
54
+ startLine: z.int().positive(),
55
+ endLine: z.int().positive(),
56
+ replacement: z.string(),
57
+ })
58
+ .refine((f) => f.endLine >= f.startLine, { message: "endLine is before startLine" });
59
+ const outputFindingSchema = z.strictObject({
41
60
  fingerprint: z.string(),
42
61
  reviewer: z.string(),
43
62
  category: z.string(),
44
63
  severity: severitySchema,
45
64
  verification: verificationSchema,
46
65
  file: z.string(),
47
- lines: linesSchema.optional(),
66
+ lines: linesSchema.exactOptional(),
48
67
  inDiff: z.boolean(),
49
68
  status: z.enum(["new", "unfixed"]),
50
69
  title: z.string(),
51
70
  body: z.string(),
52
- suggestion: z.string().optional(),
71
+ suggestion: z.string().exactOptional(),
72
+ fix: fixSchema.exactOptional(),
53
73
  evidence: z.array(z.string()),
54
74
  code: z.string(),
55
- lowConfidence: z.literal(true).optional(),
56
- provenance: z.strictObject({ task: z.string(), model: z.string().optional() }).optional(),
75
+ lowConfidence: z.literal(true).exactOptional(),
76
+ provenance: z
77
+ .strictObject({ task: z.string(), model: z.string().exactOptional() })
78
+ .exactOptional(),
57
79
  });
58
80
  const outputPriorFindingSchema = z.strictObject({
59
81
  fingerprint: z.string(),
@@ -61,6 +83,7 @@ const outputPriorFindingSchema = z.strictObject({
61
83
  file: z.string(),
62
84
  severity: severitySchema,
63
85
  verification: verificationSchema,
86
+ reviewer: z.string().exactOptional(),
64
87
  });
65
88
  const refutedFindingSchema = z.strictObject({
66
89
  fingerprint: z.string(),
@@ -83,18 +106,21 @@ const judgeDecisionsSchema = z.strictObject({
83
106
  reason: z.string(),
84
107
  })),
85
108
  });
86
- const taskOutcomeSchema = z.strictObject({
109
+ export const taskOutcomeSchema = z.strictObject({
87
110
  taskId: z.string(),
88
111
  reviewer: z.string(),
89
112
  bundle: z.string(),
90
113
  files: z.array(z.string()),
91
114
  status: taskStatusSchema,
92
- error: z.string().optional(),
115
+ error: z.string().exactOptional(),
116
+ ended: z.enum(INCOMPLETE_ENDINGS).exactOptional(),
93
117
  findings: z.int().nonnegative(),
94
118
  durationMs: z.number(),
95
119
  usage: usageSchema,
120
+ // Taken from this earlier run (--resume): usage is what that run paid.
121
+ reusedFrom: z.string().exactOptional(),
96
122
  });
97
- const skippedCellSchema = z.strictObject({
123
+ export const skippedCellSchema = z.strictObject({
98
124
  reviewer: z.string(),
99
125
  bundle: z.string(),
100
126
  reason: skipReasonSchema,
@@ -110,46 +136,46 @@ const scopeSchema = z.discriminatedUnion("mode", [
110
136
  ]);
111
137
  const priorList = z.array(outputPriorFindingSchema);
112
138
  const samplingSchema = z.strictObject({
113
- temperature: z.number().optional(),
114
- seed: z.int().optional(),
115
- notApplied: z.array(z.enum(["temperature", "seed"])).optional(),
139
+ temperature: z.number().exactOptional(),
140
+ seed: z.int().exactOptional(),
141
+ notApplied: z.array(z.enum(["temperature", "seed"])).exactOptional(),
116
142
  });
117
143
  const agentProvenanceSchema = z.strictObject({
118
- tier: z.enum(["top", "standard", "light"]),
119
- models: z.array(z.string()).optional(),
120
- effort: z.enum(EFFORT_LEVELS).optional(),
121
- applied: z.boolean().optional(),
122
- notApplied: z.array(z.enum(["temperature", "seed"])).optional(),
144
+ tier: z.enum(MODEL_TIERS),
145
+ models: z.array(z.string()).exactOptional(),
146
+ effort: z.enum(EFFORT_LEVELS).exactOptional(),
147
+ applied: z.boolean().exactOptional(),
148
+ notApplied: z.array(z.enum(["temperature", "seed"])).exactOptional(),
123
149
  });
124
150
  const provenanceSchema = z.strictObject({
125
151
  ocraVersion: z.string(),
126
152
  promptHash: z.string(),
127
153
  configHash: z.string(),
128
154
  sampling: samplingSchema,
129
- agents: z.record(z.string(), agentProvenanceSchema).optional(),
155
+ agents: z.record(z.string(), agentProvenanceSchema).exactOptional(),
130
156
  rules: z
131
157
  .array(z.strictObject({
132
158
  path: z.array(z.string()),
133
159
  rule: z.string(),
134
- source: z.enum(["repository", "shared", "account", "plugin"]).optional(),
160
+ source: z.enum(["repository", "shared", "account", "plugin"]).exactOptional(),
135
161
  }))
136
- .optional(),
137
- accountSettings: z.strictObject({ version: z.string().nullable() }).optional(),
162
+ .exactOptional(),
163
+ accountSettings: z.strictObject({ version: z.string().nullable() }).exactOptional(),
138
164
  });
139
165
  export const reportOutputSchema = z.strictObject({
140
166
  version: z.literal(REPORT_VERSION),
141
- runId: z.string().optional(),
167
+ runId: z.string().exactOptional(),
142
168
  changeRequest: changeRequestSchema,
143
169
  tier: riskTierSchema,
144
170
  verdict: verdictSchema,
145
171
  summary: z.string(),
146
- scope: scopeSchema.optional(),
172
+ scope: scopeSchema.exactOptional(),
147
173
  coverage: z.array(coverageEntrySchema),
148
174
  findings: z.array(outputFindingSchema),
149
175
  unverifiedCriticals: z.int().nonnegative(),
150
176
  refuted: z.array(refutedFindingSchema),
151
- remembered: z.array(memoryEntrySchema.extend({ source: z.enum(["repository", "account"]).optional() })),
152
- judgement: judgeDecisionsSchema.optional(),
177
+ remembered: z.array(memoryEntrySchema.extend({ source: z.enum(["repository", "account"]).exactOptional() })),
178
+ judgement: judgeDecisionsSchema.exactOptional(),
153
179
  rereview: z
154
180
  .strictObject({
155
181
  fixed: priorList,
@@ -158,21 +184,18 @@ export const reportOutputSchema = z.strictObject({
158
184
  unchanged: priorList,
159
185
  dismissed: priorList,
160
186
  })
161
- .optional(),
187
+ .exactOptional(),
162
188
  tasks: z.array(taskOutcomeSchema),
163
189
  skipped: z.array(skippedCellSchema),
164
190
  bundles: z.array(z.strictObject({ label: z.string(), files: z.array(z.string()) })),
165
- anchoring: anchoringSummarySchema.optional(),
191
+ anchoring: anchoringSummarySchema.exactOptional(),
166
192
  spendLimit: z
167
- .strictObject({ usd: z.number(), reached: z.enum(["review", "total"]).optional() })
168
- .optional(),
169
- provenance: provenanceSchema.optional(),
193
+ .strictObject({ usd: z.number(), reached: z.enum(["review", "total"]).exactOptional() })
194
+ .exactOptional(),
195
+ provenance: provenanceSchema.exactOptional(),
170
196
  usage: usageSchema,
171
197
  warnings: z.array(z.string()),
172
198
  });
173
- export function asSchemaOutput(output) {
174
- return output;
175
- }
176
199
  export const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
177
200
  // JSON Schema (draft 2020-12) for `--format json` and a session's
178
201
  // report.json, for validators and code generators outside this codebase.
@@ -187,4 +210,3 @@ export function reportJsonSchema() {
187
210
  ...rest,
188
211
  };
189
212
  }
190
- //# sourceMappingURL=output-schema.js.map
@@ -0,0 +1,7 @@
1
+ import type { z } from "zod";
2
+ import { type reportOutputSchema } from "./output-schema.js";
3
+ import type { ReviewReport } from "./report.js";
4
+ export type ReportOutput = z.output<typeof reportOutputSchema>;
5
+ export type OutputFinding = ReportOutput["findings"][number];
6
+ export type OutputPriorFinding = NonNullable<ReportOutput["rereview"]>["fixed"][number];
7
+ export declare function toReportOutput(report: ReviewReport): ReportOutput;