@open-cr-agent/core 0.5.0 → 0.6.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.
- package/dist/agent/json.d.ts +2 -0
- package/dist/agent/json.js +12 -0
- package/dist/{pipeline → agent}/pool.js +2 -1
- package/dist/{pipeline/agents.d.ts → agent/settings.d.ts} +10 -5
- package/dist/{pipeline/agents.js → agent/settings.js} +15 -6
- package/dist/anchor/match.js +5 -4
- package/dist/anchor/relocate.d.ts +1 -2
- package/dist/anchor/relocate.js +2 -2
- package/dist/at.d.ts +2 -0
- package/dist/at.js +12 -0
- package/dist/bundle/bundle.d.ts +2 -1
- package/dist/bundle/bundle.js +3 -2
- package/dist/bundle/grouping.d.ts +0 -1
- package/dist/bundle/runtime-grouper.d.ts +5 -0
- package/dist/{pipeline/helpers.js → bundle/runtime-grouper.js} +5 -14
- package/dist/contracts.d.ts +6 -14
- package/dist/contracts.js +2 -1
- package/dist/diff/hunks.js +3 -2
- package/dist/diff/parse.js +5 -4
- package/dist/diff/quoted-path.js +16 -15
- package/dist/domain.d.ts +10 -2
- package/dist/domain.js +2 -2
- package/dist/errors.d.ts +3 -1
- package/dist/errors.js +12 -0
- package/dist/hash.d.ts +2 -0
- package/dist/hash.js +7 -0
- package/dist/index.d.ts +26 -12
- package/dist/index.js +16 -5
- package/dist/internal.d.ts +9 -12
- package/dist/internal.js +9 -12
- package/dist/judge/judge.d.ts +1 -2
- package/dist/judge/judge.js +9 -8
- package/dist/judge/verdict.d.ts +0 -1
- package/dist/judge/verdict.js +1 -1
- package/dist/memory/memory.js +2 -2
- package/dist/net/proxied-fetch.js +2 -1
- package/dist/pipeline/assemble-report.d.ts +22 -0
- package/dist/pipeline/assemble-report.js +99 -0
- package/dist/pipeline/check-stage.d.ts +13 -0
- package/dist/pipeline/check-stage.js +70 -0
- package/dist/pipeline/context.d.ts +2 -1
- package/dist/pipeline/coverage.d.ts +1 -1
- package/dist/pipeline/coverage.js +2 -1
- package/dist/pipeline/execute-stage.d.ts +26 -0
- package/dist/pipeline/execute-stage.js +104 -0
- package/dist/pipeline/execute.d.ts +2 -4
- package/dist/pipeline/execute.js +63 -56
- package/dist/pipeline/filter-stage.d.ts +16 -0
- package/dist/pipeline/filter-stage.js +46 -0
- package/dist/pipeline/findings.js +3 -2
- package/dist/pipeline/imports.d.ts +1 -1
- package/dist/pipeline/imports.js +1 -1
- package/dist/pipeline/matrix.d.ts +1 -8
- package/dist/pipeline/options.d.ts +65 -0
- package/dist/pipeline/options.js +9 -0
- package/dist/pipeline/plan-output.d.ts +90 -0
- package/dist/pipeline/plan-output.js +109 -0
- package/dist/pipeline/plan.d.ts +2 -3
- package/dist/pipeline/plan.js +4 -4
- package/dist/pipeline/preview.d.ts +23 -9
- package/dist/pipeline/preview.js +25 -4
- package/dist/pipeline/provenance.d.ts +4 -27
- package/dist/pipeline/provenance.js +2 -2
- package/dist/pipeline/run.d.ts +2 -48
- package/dist/pipeline/run.js +18 -273
- package/dist/pipeline/task.d.ts +1 -3
- package/dist/pipeline/task.js +4 -4
- package/dist/plugin/registry.d.ts +5 -4
- package/dist/plugin/registry.js +3 -3
- package/dist/plugin/types.d.ts +3 -5
- package/dist/{pipeline → report}/output-schema.d.ts +57 -63
- package/dist/{pipeline → report}/output-schema.js +55 -40
- package/dist/report/output.d.ts +8 -0
- package/dist/report/output.js +211 -0
- package/dist/report/provenance.d.ts +26 -0
- package/dist/report/provenance.js +2 -0
- package/dist/report/read.d.ts +3 -0
- package/dist/report/read.js +34 -0
- package/dist/{pipeline → report}/report.d.ts +1 -1
- package/dist/report/serialize.d.ts +3 -0
- package/dist/report/serialize.js +27 -0
- package/dist/rereview/presence.js +1 -1
- package/dist/rereview/quote.js +2 -2
- package/dist/rereview/reconcile.d.ts +1 -1
- package/dist/review/impact.d.ts +0 -2
- package/dist/review/impact.js +2 -2
- package/dist/review/plan-phase.d.ts +1 -2
- package/dist/review/plan-phase.js +2 -2
- package/dist/review/prompt-text.d.ts +1 -1
- package/dist/review/prompt-text.js +1 -1
- package/dist/review/prompt.d.ts +0 -3
- package/dist/review/prompt.js +3 -3
- package/dist/rules/builtin/index.d.ts +0 -4
- package/dist/rules/builtin/index.js +1 -2
- package/dist/rules/repo-rules.d.ts +0 -6
- package/dist/rules/repo-rules.js +3 -3
- package/dist/runtime/chain-runner.d.ts +19 -0
- package/dist/runtime/chain-runner.js +63 -0
- package/dist/runtime/effort-capability.d.ts +14 -0
- package/dist/runtime/effort-capability.js +70 -0
- package/dist/runtime/failback.d.ts +0 -9
- package/dist/runtime/failback.js +14 -4
- package/dist/runtime/models.d.ts +1 -2
- package/dist/runtime/tools.d.ts +0 -16
- package/dist/runtime/tools.js +3 -3
- package/dist/sarif/candidates.d.ts +2 -1
- package/dist/sarif/schema.d.ts +2 -2
- package/dist/sarif/schema.js +4 -4
- package/dist/session/jsonl.d.ts +2 -2
- package/dist/session/jsonl.js +5 -4
- package/dist/triage.d.ts +2 -2
- package/dist/triage.js +1 -1
- package/dist/vcs.d.ts +15 -0
- package/dist/vcs.js +2 -0
- package/dist/verify/prompt.d.ts +0 -6
- package/dist/verify/prompt.js +1 -1
- package/dist/verify/verify.d.ts +2 -3
- package/dist/verify/verify.js +4 -4
- package/package.json +1 -1
- package/dist/pipeline/helpers.d.ts +0 -7
- package/dist/pipeline/output.d.ts +0 -79
- package/dist/pipeline/output.js +0 -132
- /package/dist/{pipeline → agent}/budget.d.ts +0 -0
- /package/dist/{pipeline → agent}/budget.js +0 -0
- /package/dist/{pipeline → agent}/pool.d.ts +0 -0
- /package/dist/{pipeline → agent}/usage.d.ts +0 -0
- /package/dist/{pipeline → agent}/usage.js +0 -0
- /package/dist/{pipeline → report}/report.js +0 -0
|
@@ -1,50 +1,37 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
4
|
-
|
|
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;
|
|
21
|
-
}, z.core.$strict>>;
|
|
22
|
-
inDiff: z.ZodBoolean;
|
|
23
|
-
status: z.ZodEnum<{
|
|
24
|
-
new: "new";
|
|
25
|
-
unfixed: "unfixed";
|
|
26
|
-
}>;
|
|
2
|
+
export declare const REPORT_VERSION = 1;
|
|
3
|
+
export declare const changeRequestSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
27
5
|
title: z.ZodString;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
task: z.ZodString;
|
|
35
|
-
model: z.ZodOptional<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;
|
|
36
12
|
}, z.core.$strict>>;
|
|
37
13
|
}, z.core.$strict>;
|
|
14
|
+
export declare const skippedCellSchema: z.ZodObject<{
|
|
15
|
+
reviewer: z.ZodString;
|
|
16
|
+
bundle: z.ZodString;
|
|
17
|
+
reason: z.ZodEnum<{
|
|
18
|
+
below_tier: "below_tier";
|
|
19
|
+
disabled: "disabled";
|
|
20
|
+
no_guidelines: "no_guidelines";
|
|
21
|
+
no_matching_files: "no_matching_files";
|
|
22
|
+
task_limit: "task_limit";
|
|
23
|
+
}>;
|
|
24
|
+
}, z.core.$strict>;
|
|
38
25
|
export declare const reportOutputSchema: z.ZodObject<{
|
|
39
26
|
version: z.ZodLiteral<1>;
|
|
40
|
-
runId: z.
|
|
27
|
+
runId: z.ZodExactOptional<z.ZodString>;
|
|
41
28
|
changeRequest: z.ZodObject<{
|
|
42
29
|
id: z.ZodString;
|
|
43
30
|
title: z.ZodString;
|
|
44
31
|
description: z.ZodString;
|
|
45
32
|
baseSha: z.ZodString;
|
|
46
33
|
headSha: z.ZodString;
|
|
47
|
-
override: z.
|
|
34
|
+
override: z.ZodExactOptional<z.ZodObject<{
|
|
48
35
|
by: z.ZodString;
|
|
49
36
|
reason: z.ZodString;
|
|
50
37
|
}, z.core.$strict>>;
|
|
@@ -61,7 +48,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
61
48
|
significant_concerns: "significant_concerns";
|
|
62
49
|
}>;
|
|
63
50
|
summary: z.ZodString;
|
|
64
|
-
scope: z.
|
|
51
|
+
scope: z.ZodExactOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
65
52
|
mode: z.ZodLiteral<"incremental">;
|
|
66
53
|
since: z.ZodString;
|
|
67
54
|
}, z.core.$strict>, z.ZodObject<{
|
|
@@ -104,7 +91,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
104
91
|
unchecked: "unchecked";
|
|
105
92
|
}>;
|
|
106
93
|
file: z.ZodString;
|
|
107
|
-
lines: z.
|
|
94
|
+
lines: z.ZodExactOptional<z.ZodObject<{
|
|
108
95
|
start: z.ZodInt;
|
|
109
96
|
end: z.ZodInt;
|
|
110
97
|
}, z.core.$strict>>;
|
|
@@ -115,13 +102,18 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
115
102
|
}>;
|
|
116
103
|
title: z.ZodString;
|
|
117
104
|
body: z.ZodString;
|
|
118
|
-
suggestion: z.
|
|
105
|
+
suggestion: z.ZodExactOptional<z.ZodString>;
|
|
106
|
+
fix: z.ZodExactOptional<z.ZodObject<{
|
|
107
|
+
startLine: z.ZodInt;
|
|
108
|
+
endLine: z.ZodInt;
|
|
109
|
+
replacement: z.ZodString;
|
|
110
|
+
}, z.core.$strict>>;
|
|
119
111
|
evidence: z.ZodArray<z.ZodString>;
|
|
120
112
|
code: z.ZodString;
|
|
121
|
-
lowConfidence: z.
|
|
122
|
-
provenance: z.
|
|
113
|
+
lowConfidence: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
114
|
+
provenance: z.ZodExactOptional<z.ZodObject<{
|
|
123
115
|
task: z.ZodString;
|
|
124
|
-
model: z.
|
|
116
|
+
model: z.ZodExactOptional<z.ZodString>;
|
|
125
117
|
}, z.core.$strict>>;
|
|
126
118
|
}, z.core.$strict>>;
|
|
127
119
|
unverifiedCriticals: z.ZodInt;
|
|
@@ -137,12 +129,12 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
137
129
|
title: z.ZodString;
|
|
138
130
|
reason: z.ZodString;
|
|
139
131
|
added: z.ZodOptional<z.ZodString>;
|
|
140
|
-
source: z.
|
|
132
|
+
source: z.ZodExactOptional<z.ZodEnum<{
|
|
141
133
|
account: "account";
|
|
142
134
|
repository: "repository";
|
|
143
135
|
}>>;
|
|
144
136
|
}, z.core.$strip>>;
|
|
145
|
-
judgement: z.
|
|
137
|
+
judgement: z.ZodExactOptional<z.ZodObject<{
|
|
146
138
|
merged: z.ZodArray<z.ZodObject<{
|
|
147
139
|
kept: z.ZodString;
|
|
148
140
|
merged: z.ZodArray<z.ZodString>;
|
|
@@ -168,7 +160,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
168
160
|
reason: z.ZodString;
|
|
169
161
|
}, z.core.$strict>>;
|
|
170
162
|
}, z.core.$strict>>;
|
|
171
|
-
rereview: z.
|
|
163
|
+
rereview: z.ZodExactOptional<z.ZodObject<{
|
|
172
164
|
fixed: z.ZodArray<z.ZodObject<{
|
|
173
165
|
fingerprint: z.ZodString;
|
|
174
166
|
title: z.ZodString;
|
|
@@ -183,6 +175,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
183
175
|
uncertain: "uncertain";
|
|
184
176
|
unchecked: "unchecked";
|
|
185
177
|
}>;
|
|
178
|
+
reviewer: z.ZodExactOptional<z.ZodString>;
|
|
186
179
|
}, z.core.$strict>>;
|
|
187
180
|
notReproduced: z.ZodArray<z.ZodObject<{
|
|
188
181
|
fingerprint: z.ZodString;
|
|
@@ -198,6 +191,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
198
191
|
uncertain: "uncertain";
|
|
199
192
|
unchecked: "unchecked";
|
|
200
193
|
}>;
|
|
194
|
+
reviewer: z.ZodExactOptional<z.ZodString>;
|
|
201
195
|
}, z.core.$strict>>;
|
|
202
196
|
notRechecked: z.ZodArray<z.ZodObject<{
|
|
203
197
|
fingerprint: z.ZodString;
|
|
@@ -213,6 +207,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
213
207
|
uncertain: "uncertain";
|
|
214
208
|
unchecked: "unchecked";
|
|
215
209
|
}>;
|
|
210
|
+
reviewer: z.ZodExactOptional<z.ZodString>;
|
|
216
211
|
}, z.core.$strict>>;
|
|
217
212
|
unchanged: z.ZodArray<z.ZodObject<{
|
|
218
213
|
fingerprint: z.ZodString;
|
|
@@ -228,6 +223,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
228
223
|
uncertain: "uncertain";
|
|
229
224
|
unchecked: "unchecked";
|
|
230
225
|
}>;
|
|
226
|
+
reviewer: z.ZodExactOptional<z.ZodString>;
|
|
231
227
|
}, z.core.$strict>>;
|
|
232
228
|
dismissed: z.ZodArray<z.ZodObject<{
|
|
233
229
|
fingerprint: z.ZodString;
|
|
@@ -243,6 +239,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
243
239
|
uncertain: "uncertain";
|
|
244
240
|
unchecked: "unchecked";
|
|
245
241
|
}>;
|
|
242
|
+
reviewer: z.ZodExactOptional<z.ZodString>;
|
|
246
243
|
}, z.core.$strict>>;
|
|
247
244
|
}, z.core.$strict>>;
|
|
248
245
|
tasks: z.ZodArray<z.ZodObject<{
|
|
@@ -256,7 +253,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
256
253
|
failed: "failed";
|
|
257
254
|
timed_out: "timed_out";
|
|
258
255
|
}>;
|
|
259
|
-
error: z.
|
|
256
|
+
error: z.ZodExactOptional<z.ZodString>;
|
|
260
257
|
findings: z.ZodInt;
|
|
261
258
|
durationMs: z.ZodNumber;
|
|
262
259
|
usage: z.ZodObject<{
|
|
@@ -282,7 +279,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
282
279
|
label: z.ZodString;
|
|
283
280
|
files: z.ZodArray<z.ZodString>;
|
|
284
281
|
}, z.core.$strict>>;
|
|
285
|
-
anchoring: z.
|
|
282
|
+
anchoring: z.ZodExactOptional<z.ZodObject<{
|
|
286
283
|
byMethod: z.ZodRecord<z.ZodEnum<{
|
|
287
284
|
cross_file: "cross_file";
|
|
288
285
|
file: "file";
|
|
@@ -293,56 +290,56 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
293
290
|
ambiguous: z.ZodInt;
|
|
294
291
|
relocationCalls: z.ZodInt;
|
|
295
292
|
}, z.core.$strict>>;
|
|
296
|
-
spendLimit: z.
|
|
293
|
+
spendLimit: z.ZodExactOptional<z.ZodObject<{
|
|
297
294
|
usd: z.ZodNumber;
|
|
298
|
-
reached: z.
|
|
295
|
+
reached: z.ZodExactOptional<z.ZodEnum<{
|
|
299
296
|
review: "review";
|
|
300
297
|
total: "total";
|
|
301
298
|
}>>;
|
|
302
299
|
}, z.core.$strict>>;
|
|
303
|
-
provenance: z.
|
|
300
|
+
provenance: z.ZodExactOptional<z.ZodObject<{
|
|
304
301
|
ocraVersion: z.ZodString;
|
|
305
302
|
promptHash: z.ZodString;
|
|
306
303
|
configHash: z.ZodString;
|
|
307
304
|
sampling: z.ZodObject<{
|
|
308
|
-
temperature: z.
|
|
309
|
-
seed: z.
|
|
310
|
-
notApplied: z.
|
|
305
|
+
temperature: z.ZodExactOptional<z.ZodNumber>;
|
|
306
|
+
seed: z.ZodExactOptional<z.ZodInt>;
|
|
307
|
+
notApplied: z.ZodExactOptional<z.ZodArray<z.ZodEnum<{
|
|
311
308
|
seed: "seed";
|
|
312
309
|
temperature: "temperature";
|
|
313
310
|
}>>>;
|
|
314
311
|
}, z.core.$strict>;
|
|
315
|
-
agents: z.
|
|
312
|
+
agents: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
316
313
|
tier: z.ZodEnum<{
|
|
317
314
|
light: "light";
|
|
318
315
|
standard: "standard";
|
|
319
316
|
top: "top";
|
|
320
317
|
}>;
|
|
321
|
-
models: z.
|
|
322
|
-
effort: z.
|
|
318
|
+
models: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
319
|
+
effort: z.ZodExactOptional<z.ZodEnum<{
|
|
323
320
|
high: "high";
|
|
324
321
|
low: "low";
|
|
325
322
|
medium: "medium";
|
|
326
323
|
minimal: "minimal";
|
|
327
324
|
none: "none";
|
|
328
325
|
}>>;
|
|
329
|
-
applied: z.
|
|
330
|
-
notApplied: z.
|
|
326
|
+
applied: z.ZodExactOptional<z.ZodBoolean>;
|
|
327
|
+
notApplied: z.ZodExactOptional<z.ZodArray<z.ZodEnum<{
|
|
331
328
|
seed: "seed";
|
|
332
329
|
temperature: "temperature";
|
|
333
330
|
}>>>;
|
|
334
331
|
}, z.core.$strict>>>;
|
|
335
|
-
rules: z.
|
|
332
|
+
rules: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
336
333
|
path: z.ZodArray<z.ZodString>;
|
|
337
334
|
rule: z.ZodString;
|
|
338
|
-
source: z.
|
|
335
|
+
source: z.ZodExactOptional<z.ZodEnum<{
|
|
339
336
|
account: "account";
|
|
340
337
|
plugin: "plugin";
|
|
341
338
|
repository: "repository";
|
|
342
339
|
shared: "shared";
|
|
343
340
|
}>>;
|
|
344
341
|
}, z.core.$strict>>>;
|
|
345
|
-
accountSettings: z.
|
|
342
|
+
accountSettings: z.ZodExactOptional<z.ZodObject<{
|
|
346
343
|
version: z.ZodNullable<z.ZodString>;
|
|
347
344
|
}, z.core.$strict>>;
|
|
348
345
|
}, z.core.$strict>>;
|
|
@@ -355,9 +352,6 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
355
352
|
}, z.core.$strict>;
|
|
356
353
|
warnings: z.ZodArray<z.ZodString>;
|
|
357
354
|
}, z.core.$strict>;
|
|
358
|
-
type OutputFromSchema = z.output<typeof reportOutputSchema>;
|
|
359
|
-
export declare function asSchemaOutput(output: ReportOutput): OutputFromSchema;
|
|
360
355
|
export declare const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
|
|
361
356
|
export declare function reportJsonSchema(): Record<string, unknown>;
|
|
362
|
-
export {};
|
|
363
357
|
//# 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 { 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
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
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,13 +24,13 @@ 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() }).
|
|
33
|
+
override: z.strictObject({ by: z.string(), reason: z.string() }).exactOptional(),
|
|
27
34
|
});
|
|
28
35
|
const coverageEntrySchema = z.discriminatedUnion("status", [
|
|
29
36
|
z.strictObject({
|
|
@@ -37,23 +44,33 @@ const coverageEntrySchema = z.discriminatedUnion("status", [
|
|
|
37
44
|
}),
|
|
38
45
|
]);
|
|
39
46
|
const linesSchema = z.strictObject({ start: z.int().positive(), end: z.int().positive() });
|
|
40
|
-
|
|
47
|
+
const fixSchema = z
|
|
48
|
+
.strictObject({
|
|
49
|
+
startLine: z.int().positive(),
|
|
50
|
+
endLine: z.int().positive(),
|
|
51
|
+
replacement: z.string(),
|
|
52
|
+
})
|
|
53
|
+
.refine((f) => f.endLine >= f.startLine, { message: "endLine is before startLine" });
|
|
54
|
+
const outputFindingSchema = z.strictObject({
|
|
41
55
|
fingerprint: z.string(),
|
|
42
56
|
reviewer: z.string(),
|
|
43
57
|
category: z.string(),
|
|
44
58
|
severity: severitySchema,
|
|
45
59
|
verification: verificationSchema,
|
|
46
60
|
file: z.string(),
|
|
47
|
-
lines: linesSchema.
|
|
61
|
+
lines: linesSchema.exactOptional(),
|
|
48
62
|
inDiff: z.boolean(),
|
|
49
63
|
status: z.enum(["new", "unfixed"]),
|
|
50
64
|
title: z.string(),
|
|
51
65
|
body: z.string(),
|
|
52
|
-
suggestion: z.string().
|
|
66
|
+
suggestion: z.string().exactOptional(),
|
|
67
|
+
fix: fixSchema.exactOptional(),
|
|
53
68
|
evidence: z.array(z.string()),
|
|
54
69
|
code: z.string(),
|
|
55
|
-
lowConfidence: z.literal(true).
|
|
56
|
-
provenance: z
|
|
70
|
+
lowConfidence: z.literal(true).exactOptional(),
|
|
71
|
+
provenance: z
|
|
72
|
+
.strictObject({ task: z.string(), model: z.string().exactOptional() })
|
|
73
|
+
.exactOptional(),
|
|
57
74
|
});
|
|
58
75
|
const outputPriorFindingSchema = z.strictObject({
|
|
59
76
|
fingerprint: z.string(),
|
|
@@ -61,6 +78,7 @@ const outputPriorFindingSchema = z.strictObject({
|
|
|
61
78
|
file: z.string(),
|
|
62
79
|
severity: severitySchema,
|
|
63
80
|
verification: verificationSchema,
|
|
81
|
+
reviewer: z.string().exactOptional(),
|
|
64
82
|
});
|
|
65
83
|
const refutedFindingSchema = z.strictObject({
|
|
66
84
|
fingerprint: z.string(),
|
|
@@ -89,12 +107,12 @@ const taskOutcomeSchema = z.strictObject({
|
|
|
89
107
|
bundle: z.string(),
|
|
90
108
|
files: z.array(z.string()),
|
|
91
109
|
status: taskStatusSchema,
|
|
92
|
-
error: z.string().
|
|
110
|
+
error: z.string().exactOptional(),
|
|
93
111
|
findings: z.int().nonnegative(),
|
|
94
112
|
durationMs: z.number(),
|
|
95
113
|
usage: usageSchema,
|
|
96
114
|
});
|
|
97
|
-
const skippedCellSchema = z.strictObject({
|
|
115
|
+
export const skippedCellSchema = z.strictObject({
|
|
98
116
|
reviewer: z.string(),
|
|
99
117
|
bundle: z.string(),
|
|
100
118
|
reason: skipReasonSchema,
|
|
@@ -110,46 +128,46 @@ const scopeSchema = z.discriminatedUnion("mode", [
|
|
|
110
128
|
]);
|
|
111
129
|
const priorList = z.array(outputPriorFindingSchema);
|
|
112
130
|
const samplingSchema = z.strictObject({
|
|
113
|
-
temperature: z.number().
|
|
114
|
-
seed: z.int().
|
|
115
|
-
notApplied: z.array(z.enum(["temperature", "seed"])).
|
|
131
|
+
temperature: z.number().exactOptional(),
|
|
132
|
+
seed: z.int().exactOptional(),
|
|
133
|
+
notApplied: z.array(z.enum(["temperature", "seed"])).exactOptional(),
|
|
116
134
|
});
|
|
117
135
|
const agentProvenanceSchema = z.strictObject({
|
|
118
|
-
tier: z.enum(
|
|
119
|
-
models: z.array(z.string()).
|
|
120
|
-
effort: z.enum(EFFORT_LEVELS).
|
|
121
|
-
applied: z.boolean().
|
|
122
|
-
notApplied: z.array(z.enum(["temperature", "seed"])).
|
|
136
|
+
tier: z.enum(MODEL_TIERS),
|
|
137
|
+
models: z.array(z.string()).exactOptional(),
|
|
138
|
+
effort: z.enum(EFFORT_LEVELS).exactOptional(),
|
|
139
|
+
applied: z.boolean().exactOptional(),
|
|
140
|
+
notApplied: z.array(z.enum(["temperature", "seed"])).exactOptional(),
|
|
123
141
|
});
|
|
124
142
|
const provenanceSchema = z.strictObject({
|
|
125
143
|
ocraVersion: z.string(),
|
|
126
144
|
promptHash: z.string(),
|
|
127
145
|
configHash: z.string(),
|
|
128
146
|
sampling: samplingSchema,
|
|
129
|
-
agents: z.record(z.string(), agentProvenanceSchema).
|
|
147
|
+
agents: z.record(z.string(), agentProvenanceSchema).exactOptional(),
|
|
130
148
|
rules: z
|
|
131
149
|
.array(z.strictObject({
|
|
132
150
|
path: z.array(z.string()),
|
|
133
151
|
rule: z.string(),
|
|
134
|
-
source: z.enum(["repository", "shared", "account", "plugin"]).
|
|
152
|
+
source: z.enum(["repository", "shared", "account", "plugin"]).exactOptional(),
|
|
135
153
|
}))
|
|
136
|
-
.
|
|
137
|
-
accountSettings: z.strictObject({ version: z.string().nullable() }).
|
|
154
|
+
.exactOptional(),
|
|
155
|
+
accountSettings: z.strictObject({ version: z.string().nullable() }).exactOptional(),
|
|
138
156
|
});
|
|
139
157
|
export const reportOutputSchema = z.strictObject({
|
|
140
158
|
version: z.literal(REPORT_VERSION),
|
|
141
|
-
runId: z.string().
|
|
159
|
+
runId: z.string().exactOptional(),
|
|
142
160
|
changeRequest: changeRequestSchema,
|
|
143
161
|
tier: riskTierSchema,
|
|
144
162
|
verdict: verdictSchema,
|
|
145
163
|
summary: z.string(),
|
|
146
|
-
scope: scopeSchema.
|
|
164
|
+
scope: scopeSchema.exactOptional(),
|
|
147
165
|
coverage: z.array(coverageEntrySchema),
|
|
148
166
|
findings: z.array(outputFindingSchema),
|
|
149
167
|
unverifiedCriticals: z.int().nonnegative(),
|
|
150
168
|
refuted: z.array(refutedFindingSchema),
|
|
151
|
-
remembered: z.array(memoryEntrySchema.extend({ source: z.enum(["repository", "account"]).
|
|
152
|
-
judgement: judgeDecisionsSchema.
|
|
169
|
+
remembered: z.array(memoryEntrySchema.extend({ source: z.enum(["repository", "account"]).exactOptional() })),
|
|
170
|
+
judgement: judgeDecisionsSchema.exactOptional(),
|
|
153
171
|
rereview: z
|
|
154
172
|
.strictObject({
|
|
155
173
|
fixed: priorList,
|
|
@@ -158,21 +176,18 @@ export const reportOutputSchema = z.strictObject({
|
|
|
158
176
|
unchanged: priorList,
|
|
159
177
|
dismissed: priorList,
|
|
160
178
|
})
|
|
161
|
-
.
|
|
179
|
+
.exactOptional(),
|
|
162
180
|
tasks: z.array(taskOutcomeSchema),
|
|
163
181
|
skipped: z.array(skippedCellSchema),
|
|
164
182
|
bundles: z.array(z.strictObject({ label: z.string(), files: z.array(z.string()) })),
|
|
165
|
-
anchoring: anchoringSummarySchema.
|
|
183
|
+
anchoring: anchoringSummarySchema.exactOptional(),
|
|
166
184
|
spendLimit: z
|
|
167
|
-
.strictObject({ usd: z.number(), reached: z.enum(["review", "total"]).
|
|
168
|
-
.
|
|
169
|
-
provenance: provenanceSchema.
|
|
185
|
+
.strictObject({ usd: z.number(), reached: z.enum(["review", "total"]).exactOptional() })
|
|
186
|
+
.exactOptional(),
|
|
187
|
+
provenance: provenanceSchema.exactOptional(),
|
|
170
188
|
usage: usageSchema,
|
|
171
189
|
warnings: z.array(z.string()),
|
|
172
190
|
});
|
|
173
|
-
export function asSchemaOutput(output) {
|
|
174
|
-
return output;
|
|
175
|
-
}
|
|
176
191
|
export const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
|
|
177
192
|
// JSON Schema (draft 2020-12) for `--format json` and a session's
|
|
178
193
|
// report.json, for validators and code generators outside this codebase.
|
|
@@ -0,0 +1,8 @@
|
|
|
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;
|
|
8
|
+
//# sourceMappingURL=output.d.ts.map
|