@open-cr-agent/core 0.6.0 → 0.9.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/README.md +1 -1
- package/dist/agent/json.d.ts +0 -1
- package/dist/agent/json.js +0 -1
- package/dist/agent/model-call.d.ts +13 -0
- package/dist/agent/model-call.js +22 -0
- package/dist/agent/pool.d.ts +0 -1
- package/dist/agent/pool.js +0 -1
- package/dist/agent/settings.d.ts +9 -5
- package/dist/agent/settings.js +20 -8
- package/dist/agent/spend-limit.d.ts +18 -0
- package/dist/agent/spend-limit.js +53 -0
- package/dist/agent/usage.d.ts +0 -1
- package/dist/agent/usage.js +0 -1
- package/dist/anchor/anchor.d.ts +0 -1
- package/dist/anchor/anchor.js +0 -1
- package/dist/anchor/match.d.ts +0 -1
- package/dist/anchor/match.js +0 -1
- package/dist/anchor/relocate.d.ts +1 -2
- package/dist/anchor/relocate.js +8 -15
- package/dist/at.d.ts +0 -1
- package/dist/at.js +0 -1
- package/dist/bounded-file.d.ts +12 -0
- package/dist/bounded-file.js +47 -0
- package/dist/bundle/bundle.d.ts +0 -1
- package/dist/bundle/bundle.js +0 -1
- package/dist/bundle/grouping.d.ts +0 -1
- package/dist/bundle/grouping.js +0 -1
- package/dist/bundle/runtime-grouper.d.ts +1 -2
- package/dist/bundle/runtime-grouper.js +8 -15
- package/dist/contracts.d.ts +37 -1
- package/dist/contracts.js +14 -1
- package/dist/diff/hunks.d.ts +0 -1
- package/dist/diff/hunks.js +0 -1
- package/dist/diff/parse.d.ts +0 -1
- package/dist/diff/parse.js +0 -1
- package/dist/diff/quoted-path.d.ts +0 -1
- package/dist/diff/quoted-path.js +0 -1
- package/dist/domain.d.ts +11 -1
- package/dist/domain.js +2 -1
- package/dist/errors.d.ts +0 -1
- package/dist/errors.js +0 -1
- package/dist/hash.d.ts +0 -1
- package/dist/hash.js +0 -1
- package/dist/index.d.ts +10 -8
- package/dist/index.js +4 -5
- package/dist/internal.d.ts +10 -6
- package/dist/internal.js +9 -5
- package/dist/judge/judge.d.ts +1 -2
- package/dist/judge/judge.js +10 -14
- package/dist/judge/prompt.d.ts +1 -2
- package/dist/judge/prompt.js +10 -2
- package/dist/judge/verdict.d.ts +2 -2
- package/dist/judge/verdict.js +4 -3
- package/dist/knowledge/learning.d.ts +21 -0
- package/dist/knowledge/learning.js +1 -0
- package/dist/knowledge/select.d.ts +15 -0
- package/dist/knowledge/select.js +175 -0
- package/dist/learn/draft.d.ts +21 -0
- package/dist/learn/draft.js +123 -0
- package/dist/{pipeline → matrix}/matrix.d.ts +1 -3
- package/dist/{pipeline → matrix}/matrix.js +1 -2
- package/dist/memory/memory.d.ts +0 -1
- package/dist/memory/memory.js +0 -1
- package/dist/net/proxied-fetch.d.ts +0 -1
- package/dist/net/proxied-fetch.js +0 -1
- package/dist/pipeline/assemble-report.d.ts +0 -7
- package/dist/pipeline/assemble-report.js +33 -21
- package/dist/pipeline/check-stage.d.ts +0 -1
- package/dist/pipeline/check-stage.js +31 -12
- package/dist/pipeline/context.d.ts +2 -2
- package/dist/pipeline/context.js +26 -7
- package/dist/pipeline/coverage.d.ts +1 -2
- package/dist/pipeline/coverage.js +37 -17
- package/dist/pipeline/execute-stage.d.ts +5 -6
- package/dist/pipeline/execute-stage.js +50 -29
- package/dist/pipeline/execute.d.ts +13 -7
- package/dist/pipeline/execute.js +108 -43
- package/dist/pipeline/filter-stage.d.ts +0 -1
- package/dist/pipeline/filter-stage.js +2 -1
- package/dist/pipeline/findings.d.ts +0 -1
- package/dist/pipeline/findings.js +0 -1
- package/dist/pipeline/imports.d.ts +0 -1
- package/dist/pipeline/imports.js +2 -17
- package/dist/pipeline/options.d.ts +22 -2
- package/dist/pipeline/options.js +31 -1
- package/dist/pipeline/plan-output.d.ts +7 -1
- package/dist/pipeline/plan-output.js +9 -2
- package/dist/pipeline/plan.d.ts +14 -9
- package/dist/pipeline/plan.js +64 -10
- package/dist/pipeline/preview.d.ts +5 -5
- package/dist/pipeline/preview.js +18 -28
- package/dist/pipeline/provenance.d.ts +0 -1
- package/dist/pipeline/provenance.js +0 -1
- package/dist/pipeline/resume.d.ts +22 -0
- package/dist/pipeline/resume.js +24 -0
- package/dist/pipeline/run-id.d.ts +0 -1
- package/dist/pipeline/run-id.js +0 -1
- package/dist/pipeline/run.d.ts +0 -1
- package/dist/pipeline/run.js +18 -45
- package/dist/pipeline/task-prompt.d.ts +13 -0
- package/dist/pipeline/task-prompt.js +43 -0
- package/dist/pipeline/task.d.ts +8 -8
- package/dist/pipeline/task.js +11 -7
- package/dist/plugin/builtin.d.ts +1 -1
- package/dist/plugin/builtin.js +12 -3
- package/dist/plugin/host.d.ts +0 -1
- package/dist/plugin/host.js +0 -1
- package/dist/plugin/registry.d.ts +0 -1
- package/dist/plugin/registry.js +0 -1
- package/dist/plugin/types.d.ts +0 -1
- package/dist/plugin/types.js +0 -1
- package/dist/report/output-schema.d.ts +69 -1
- package/dist/report/output-schema.js +34 -5
- package/dist/report/output.d.ts +0 -1
- package/dist/report/output.js +31 -4
- package/dist/report/provenance.d.ts +0 -1
- package/dist/report/provenance.js +0 -1
- package/dist/report/read.d.ts +0 -1
- package/dist/report/read.js +5 -3
- package/dist/report/report.d.ts +57 -4
- package/dist/report/report.js +40 -3
- package/dist/report/serialize.d.ts +0 -1
- package/dist/report/serialize.js +0 -1
- package/dist/rereview/presence.d.ts +0 -1
- package/dist/rereview/presence.js +0 -1
- package/dist/rereview/quote.d.ts +0 -1
- package/dist/rereview/quote.js +0 -1
- package/dist/rereview/reconcile.d.ts +0 -1
- package/dist/rereview/reconcile.js +0 -1
- package/dist/review/impact.d.ts +20 -5
- package/dist/review/impact.js +153 -29
- package/dist/review/plan-phase.d.ts +1 -2
- package/dist/review/plan-phase.js +13 -13
- package/dist/review/prompt-text.d.ts +1 -2
- package/dist/review/prompt-text.js +82 -21
- package/dist/review/prompt.d.ts +6 -1
- package/dist/review/prompt.js +57 -3
- package/dist/review/reviewer.d.ts +0 -1
- package/dist/review/reviewer.js +0 -1
- package/dist/review/reviewers/agents-md.d.ts +0 -1
- package/dist/review/reviewers/agents-md.js +0 -1
- package/dist/review/reviewers/correctness.d.ts +0 -1
- package/dist/review/reviewers/correctness.js +0 -1
- package/dist/review/reviewers/docs.d.ts +0 -1
- package/dist/review/reviewers/docs.js +0 -1
- package/dist/review/reviewers/performance.d.ts +0 -1
- package/dist/review/reviewers/performance.js +0 -1
- package/dist/review/reviewers/scopes.d.ts +0 -1
- package/dist/review/reviewers/scopes.js +0 -1
- package/dist/review/reviewers/security.d.ts +0 -1
- package/dist/review/reviewers/security.js +0 -1
- package/dist/review/tools.d.ts +1 -1
- package/dist/review/tools.js +1 -1
- package/dist/rules/builtin/general.d.ts +0 -1
- package/dist/rules/builtin/general.js +0 -1
- package/dist/rules/builtin/go.d.ts +0 -1
- package/dist/rules/builtin/go.js +0 -1
- package/dist/rules/builtin/index.d.ts +0 -1
- package/dist/rules/builtin/index.js +0 -1
- package/dist/rules/builtin/java.d.ts +0 -1
- package/dist/rules/builtin/java.js +0 -1
- package/dist/rules/builtin/performance.d.ts +0 -1
- package/dist/rules/builtin/performance.js +0 -1
- package/dist/rules/builtin/python.d.ts +0 -1
- package/dist/rules/builtin/python.js +0 -1
- package/dist/rules/builtin/security.d.ts +0 -1
- package/dist/rules/builtin/security.js +0 -1
- package/dist/rules/builtin/typescript.d.ts +0 -1
- package/dist/rules/builtin/typescript.js +0 -1
- package/dist/rules/languages.d.ts +0 -1
- package/dist/rules/languages.js +0 -1
- package/dist/rules/repo-rules.d.ts +0 -1
- package/dist/rules/repo-rules.js +0 -1
- package/dist/rules/resolve.d.ts +0 -1
- package/dist/rules/resolve.js +0 -1
- package/dist/rules/rule-set.d.ts +0 -1
- package/dist/rules/rule-set.js +0 -1
- package/dist/runtime/attempt.d.ts +27 -2
- package/dist/runtime/attempt.js +68 -2
- package/dist/runtime/chain-runner.d.ts +2 -3
- package/dist/runtime/chain-runner.js +0 -1
- package/dist/runtime/effort-capability.d.ts +0 -1
- package/dist/runtime/effort-capability.js +0 -1
- package/dist/runtime/failback.d.ts +2 -3
- package/dist/runtime/failback.js +61 -15
- package/dist/runtime/models.d.ts +0 -1
- package/dist/runtime/models.js +14 -13
- package/dist/runtime/quota.d.ts +1 -1
- package/dist/runtime/quota.js +3 -2
- package/dist/runtime/tools.d.ts +0 -1
- package/dist/runtime/tools.js +11 -1
- package/dist/runtime/wrap-up.d.ts +6 -0
- package/dist/runtime/wrap-up.js +27 -0
- package/dist/sarif/candidates.d.ts +3 -3
- package/dist/sarif/candidates.js +2 -1
- package/dist/sarif/evidence.d.ts +35 -0
- package/dist/sarif/evidence.js +128 -0
- package/dist/sarif/schema.d.ts +18 -1
- package/dist/sarif/schema.js +8 -1
- package/dist/select/patterns.d.ts +1 -1
- package/dist/select/patterns.js +46 -1
- package/dist/select/select.d.ts +2 -1
- package/dist/select/select.js +34 -4
- package/dist/session/jsonl.d.ts +2 -2
- package/dist/session/jsonl.js +9 -4
- package/dist/session/resume-read.d.ts +2 -0
- package/dist/session/resume-read.js +131 -0
- package/dist/session/seal.d.ts +5 -0
- package/dist/session/seal.js +29 -0
- package/dist/triage.d.ts +0 -1
- package/dist/triage.js +0 -1
- package/dist/vcs.d.ts +0 -1
- package/dist/vcs.js +0 -1
- package/dist/verify/prompt.d.ts +6 -3
- package/dist/verify/prompt.js +13 -5
- package/dist/verify/related.d.ts +3 -0
- package/dist/verify/related.js +88 -0
- package/dist/verify/verify.d.ts +3 -4
- package/dist/verify/verify.js +27 -20
- package/package.json +3 -3
- package/dist/agent/budget.d.ts +0 -13
- package/dist/agent/budget.js +0 -28
package/dist/plugin/builtin.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
package/dist/plugin/host.d.ts
CHANGED
package/dist/plugin/host.js
CHANGED
package/dist/plugin/registry.js
CHANGED
package/dist/plugin/types.d.ts
CHANGED
package/dist/plugin/types.js
CHANGED
|
@@ -11,6 +11,36 @@ 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
|
+
wrapUp: z.ZodExactOptional<z.ZodObject<{
|
|
41
|
+
findings: z.ZodInt;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
}, z.core.$strict>;
|
|
14
44
|
export declare const skippedCellSchema: z.ZodObject<{
|
|
15
45
|
reviewer: z.ZodString;
|
|
16
46
|
bundle: z.ZodString;
|
|
@@ -22,6 +52,13 @@ export declare const skippedCellSchema: z.ZodObject<{
|
|
|
22
52
|
task_limit: "task_limit";
|
|
23
53
|
}>;
|
|
24
54
|
}, z.core.$strict>;
|
|
55
|
+
export declare const scopeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
56
|
+
mode: z.ZodLiteral<"incremental">;
|
|
57
|
+
since: z.ZodString;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
mode: z.ZodLiteral<"full">;
|
|
60
|
+
reason: z.ZodString;
|
|
61
|
+
}, z.core.$strict>], "mode">;
|
|
25
62
|
export declare const reportOutputSchema: z.ZodObject<{
|
|
26
63
|
version: z.ZodLiteral<1>;
|
|
27
64
|
runId: z.ZodExactOptional<z.ZodString>;
|
|
@@ -63,6 +100,13 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
63
100
|
unchanged: "unchanged";
|
|
64
101
|
unreviewed: "unreviewed";
|
|
65
102
|
}>;
|
|
103
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
104
|
+
path: z.ZodString;
|
|
105
|
+
status: z.ZodLiteral<"incomplete">;
|
|
106
|
+
ended: z.ZodEnum<{
|
|
107
|
+
step_cap: "step_cap";
|
|
108
|
+
stopped_early: "stopped_early";
|
|
109
|
+
}>;
|
|
66
110
|
}, z.core.$strict>, z.ZodObject<{
|
|
67
111
|
path: z.ZodString;
|
|
68
112
|
status: z.ZodLiteral<"excluded">;
|
|
@@ -111,6 +155,7 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
111
155
|
evidence: z.ZodArray<z.ZodString>;
|
|
112
156
|
code: z.ZodString;
|
|
113
157
|
lowConfidence: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
158
|
+
preExisting: z.ZodExactOptional<z.ZodLiteral<true>>;
|
|
114
159
|
provenance: z.ZodExactOptional<z.ZodObject<{
|
|
115
160
|
task: z.ZodString;
|
|
116
161
|
model: z.ZodExactOptional<z.ZodString>;
|
|
@@ -134,6 +179,22 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
134
179
|
repository: "repository";
|
|
135
180
|
}>>;
|
|
136
181
|
}, z.core.$strip>>;
|
|
182
|
+
learnings: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
title: z.ZodString;
|
|
185
|
+
critical: z.ZodBoolean;
|
|
186
|
+
source: z.ZodExactOptional<z.ZodObject<{
|
|
187
|
+
kind: z.ZodString;
|
|
188
|
+
ref: z.ZodExactOptional<z.ZodString>;
|
|
189
|
+
}, z.core.$strict>>;
|
|
190
|
+
bundles: z.ZodArray<z.ZodString>;
|
|
191
|
+
}, z.core.$strict>>>;
|
|
192
|
+
analyzerEvidence: z.ZodExactOptional<z.ZodArray<z.ZodObject<{
|
|
193
|
+
tool: z.ZodString;
|
|
194
|
+
version: z.ZodExactOptional<z.ZodString>;
|
|
195
|
+
results: z.ZodInt;
|
|
196
|
+
bundles: z.ZodArray<z.ZodString>;
|
|
197
|
+
}, z.core.$strict>>>;
|
|
137
198
|
judgement: z.ZodExactOptional<z.ZodObject<{
|
|
138
199
|
merged: z.ZodArray<z.ZodObject<{
|
|
139
200
|
kept: z.ZodString;
|
|
@@ -254,6 +315,10 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
254
315
|
timed_out: "timed_out";
|
|
255
316
|
}>;
|
|
256
317
|
error: z.ZodExactOptional<z.ZodString>;
|
|
318
|
+
ended: z.ZodExactOptional<z.ZodEnum<{
|
|
319
|
+
step_cap: "step_cap";
|
|
320
|
+
stopped_early: "stopped_early";
|
|
321
|
+
}>>;
|
|
257
322
|
findings: z.ZodInt;
|
|
258
323
|
durationMs: z.ZodNumber;
|
|
259
324
|
usage: z.ZodObject<{
|
|
@@ -263,6 +328,10 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
263
328
|
cachedTokens: z.ZodNumber;
|
|
264
329
|
costUsd: z.ZodNumber;
|
|
265
330
|
}, z.core.$strict>;
|
|
331
|
+
reusedFrom: z.ZodExactOptional<z.ZodString>;
|
|
332
|
+
wrapUp: z.ZodExactOptional<z.ZodObject<{
|
|
333
|
+
findings: z.ZodInt;
|
|
334
|
+
}, z.core.$strict>>;
|
|
266
335
|
}, z.core.$strict>>;
|
|
267
336
|
skipped: z.ZodArray<z.ZodObject<{
|
|
268
337
|
reviewer: z.ZodString;
|
|
@@ -354,4 +423,3 @@ export declare const reportOutputSchema: z.ZodObject<{
|
|
|
354
423
|
}, z.core.$strict>;
|
|
355
424
|
export declare const REPORT_SCHEMA_ID = "https://ocra.majincheng.com/schema/report.v1.json";
|
|
356
425
|
export declare function reportJsonSchema(): Record<string, unknown>;
|
|
357
|
-
//# sourceMappingURL=output-schema.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
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
|
+
import { skipReasonSchema } from "../matrix/matrix.js";
|
|
5
6
|
import { memoryEntrySchema } from "../memory/memory.js";
|
|
6
|
-
import { skipReasonSchema } from "../pipeline/matrix.js";
|
|
7
7
|
import { exclusionReasonSchema } from "../select/select.js";
|
|
8
8
|
import { taskStatusSchema } from "./report.js";
|
|
9
9
|
// The published shape of a review: `--format json` and a session's
|
|
@@ -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"),
|
|
@@ -68,6 +73,7 @@ const outputFindingSchema = z.strictObject({
|
|
|
68
73
|
evidence: z.array(z.string()),
|
|
69
74
|
code: z.string(),
|
|
70
75
|
lowConfidence: z.literal(true).exactOptional(),
|
|
76
|
+
preExisting: z.literal(true).exactOptional(),
|
|
71
77
|
provenance: z
|
|
72
78
|
.strictObject({ task: z.string(), model: z.string().exactOptional() })
|
|
73
79
|
.exactOptional(),
|
|
@@ -101,16 +107,21 @@ const judgeDecisionsSchema = z.strictObject({
|
|
|
101
107
|
reason: z.string(),
|
|
102
108
|
})),
|
|
103
109
|
});
|
|
104
|
-
const taskOutcomeSchema = z.strictObject({
|
|
110
|
+
export const taskOutcomeSchema = z.strictObject({
|
|
105
111
|
taskId: z.string(),
|
|
106
112
|
reviewer: z.string(),
|
|
107
113
|
bundle: z.string(),
|
|
108
114
|
files: z.array(z.string()),
|
|
109
115
|
status: taskStatusSchema,
|
|
110
116
|
error: z.string().exactOptional(),
|
|
117
|
+
ended: z.enum(INCOMPLETE_ENDINGS).exactOptional(),
|
|
111
118
|
findings: z.int().nonnegative(),
|
|
112
119
|
durationMs: z.number(),
|
|
113
120
|
usage: usageSchema,
|
|
121
|
+
// Taken from this earlier run (--resume): usage is what that run paid.
|
|
122
|
+
reusedFrom: z.string().exactOptional(),
|
|
123
|
+
// The agent ended without task_done and was given the wrap-up turn.
|
|
124
|
+
wrapUp: z.strictObject({ findings: z.int().nonnegative() }).exactOptional(),
|
|
114
125
|
});
|
|
115
126
|
export const skippedCellSchema = z.strictObject({
|
|
116
127
|
reviewer: z.string(),
|
|
@@ -122,7 +133,7 @@ const anchoringSummarySchema = z.strictObject({
|
|
|
122
133
|
ambiguous: z.int().nonnegative(),
|
|
123
134
|
relocationCalls: z.int().nonnegative(),
|
|
124
135
|
});
|
|
125
|
-
const scopeSchema = z.discriminatedUnion("mode", [
|
|
136
|
+
export const scopeSchema = z.discriminatedUnion("mode", [
|
|
126
137
|
z.strictObject({ mode: z.literal("incremental"), since: z.string() }),
|
|
127
138
|
z.strictObject({ mode: z.literal("full"), reason: z.string() }),
|
|
128
139
|
]);
|
|
@@ -167,6 +178,25 @@ export const reportOutputSchema = z.strictObject({
|
|
|
167
178
|
unverifiedCriticals: z.int().nonnegative(),
|
|
168
179
|
refuted: z.array(refutedFindingSchema),
|
|
169
180
|
remembered: z.array(memoryEntrySchema.extend({ source: z.enum(["repository", "account"]).exactOptional() })),
|
|
181
|
+
learnings: z
|
|
182
|
+
.array(z.strictObject({
|
|
183
|
+
id: z.string(),
|
|
184
|
+
title: z.string(),
|
|
185
|
+
critical: z.boolean(),
|
|
186
|
+
source: z
|
|
187
|
+
.strictObject({ kind: z.string(), ref: z.string().exactOptional() })
|
|
188
|
+
.exactOptional(),
|
|
189
|
+
bundles: z.array(z.string()),
|
|
190
|
+
}))
|
|
191
|
+
.exactOptional(),
|
|
192
|
+
analyzerEvidence: z
|
|
193
|
+
.array(z.strictObject({
|
|
194
|
+
tool: z.string(),
|
|
195
|
+
version: z.string().exactOptional(),
|
|
196
|
+
results: z.int().nonnegative(),
|
|
197
|
+
bundles: z.array(z.string()),
|
|
198
|
+
}))
|
|
199
|
+
.exactOptional(),
|
|
170
200
|
judgement: judgeDecisionsSchema.exactOptional(),
|
|
171
201
|
rereview: z
|
|
172
202
|
.strictObject({
|
|
@@ -202,4 +232,3 @@ export function reportJsonSchema() {
|
|
|
202
232
|
...rest,
|
|
203
233
|
};
|
|
204
234
|
}
|
|
205
|
-
//# sourceMappingURL=output-schema.js.map
|
package/dist/report/output.d.ts
CHANGED
|
@@ -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
|
package/dist/report/output.js
CHANGED
|
@@ -20,6 +20,16 @@ export function toReportOutput(report) {
|
|
|
20
20
|
};
|
|
21
21
|
if (report.scope)
|
|
22
22
|
output.scope = outputScope(report.scope);
|
|
23
|
+
if (report.learnings)
|
|
24
|
+
output.learnings = report.learnings.map(outputLearning);
|
|
25
|
+
if (report.analyzerEvidence) {
|
|
26
|
+
output.analyzerEvidence = report.analyzerEvidence.map((e) => ({
|
|
27
|
+
tool: e.tool,
|
|
28
|
+
...(e.version ? { version: e.version } : {}),
|
|
29
|
+
results: e.results,
|
|
30
|
+
bundles: [...e.bundles],
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
23
33
|
if (report.judgement)
|
|
24
34
|
output.judgement = outputJudgement(report.judgement);
|
|
25
35
|
if (report.anchoring)
|
|
@@ -40,6 +50,17 @@ export function toReportOutput(report) {
|
|
|
40
50
|
}
|
|
41
51
|
return output;
|
|
42
52
|
}
|
|
53
|
+
function outputLearning(l) {
|
|
54
|
+
return {
|
|
55
|
+
id: l.id,
|
|
56
|
+
title: l.title,
|
|
57
|
+
critical: l.critical,
|
|
58
|
+
...(l.source
|
|
59
|
+
? { source: { kind: l.source.kind, ...(l.source.ref ? { ref: l.source.ref } : {}) } }
|
|
60
|
+
: {}),
|
|
61
|
+
bundles: [...l.bundles],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
43
64
|
function outputChangeRequest(c) {
|
|
44
65
|
return {
|
|
45
66
|
id: c.id,
|
|
@@ -51,9 +72,11 @@ function outputChangeRequest(c) {
|
|
|
51
72
|
};
|
|
52
73
|
}
|
|
53
74
|
function outputCoverage(c) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
if (c.status === "excluded")
|
|
76
|
+
return { path: c.path, status: c.status, reason: c.reason };
|
|
77
|
+
if (c.status === "incomplete")
|
|
78
|
+
return { path: c.path, status: c.status, ended: c.ended };
|
|
79
|
+
return { path: c.path, status: c.status };
|
|
57
80
|
}
|
|
58
81
|
function outputFinding(f) {
|
|
59
82
|
const output = {
|
|
@@ -83,6 +106,8 @@ function outputFinding(f) {
|
|
|
83
106
|
}
|
|
84
107
|
if (f.lowConfidence)
|
|
85
108
|
output.lowConfidence = true;
|
|
109
|
+
if (f.preExisting)
|
|
110
|
+
output.preExisting = true;
|
|
86
111
|
output.provenance =
|
|
87
112
|
f.provenance.model === undefined
|
|
88
113
|
? { task: f.provenance.task }
|
|
@@ -113,6 +138,9 @@ function outputTask(t) {
|
|
|
113
138
|
durationMs: t.durationMs,
|
|
114
139
|
usage: outputUsage(t.usage),
|
|
115
140
|
...(t.error === undefined ? {} : { error: t.error }),
|
|
141
|
+
...(t.ended === undefined ? {} : { ended: t.ended }),
|
|
142
|
+
...(t.reusedFrom === undefined ? {} : { reusedFrom: t.reusedFrom }),
|
|
143
|
+
...(t.wrapUp === undefined ? {} : { wrapUp: { findings: t.wrapUp.findings } }),
|
|
116
144
|
};
|
|
117
145
|
}
|
|
118
146
|
function outputSkipped(s) {
|
|
@@ -208,4 +236,3 @@ function outputPrior(f) {
|
|
|
208
236
|
...(f.reviewer ? { reviewer: f.reviewer } : {}),
|
|
209
237
|
};
|
|
210
238
|
}
|
|
211
|
-
//# sourceMappingURL=output.js.map
|
package/dist/report/read.d.ts
CHANGED
package/dist/report/read.js
CHANGED
|
@@ -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
|
|
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
|
package/dist/report/report.d.ts
CHANGED
|
@@ -1,27 +1,47 @@
|
|
|
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
|
+
import type { LearningUse } from "../knowledge/learning.js";
|
|
6
|
+
import type { SkippedCell } from "../matrix/matrix.js";
|
|
5
7
|
import type { RememberedEntry } from "../memory/memory.js";
|
|
6
|
-
import type {
|
|
8
|
+
import type { AnalyzerEvidenceUse } from "../sarif/evidence.js";
|
|
7
9
|
import type { ExclusionReason } from "../select/select.js";
|
|
8
10
|
import type { RefutedFinding } from "../verify/verify.js";
|
|
9
11
|
import type { RunProvenance } from "./provenance.js";
|
|
10
12
|
export type CoverageEntry = {
|
|
11
13
|
path: string;
|
|
12
14
|
status: "reviewed" | "failed" | "unreviewed" | "unchanged";
|
|
15
|
+
} | {
|
|
16
|
+
path: string;
|
|
17
|
+
status: "incomplete";
|
|
18
|
+
ended: IncompleteEnding;
|
|
13
19
|
} | {
|
|
14
20
|
path: string;
|
|
15
21
|
status: "excluded";
|
|
16
22
|
reason: ExclusionReason;
|
|
17
23
|
};
|
|
24
|
+
export declare function isUnfinished(entry: CoverageEntry): boolean;
|
|
18
25
|
export declare function coverageGaps(run: {
|
|
19
26
|
coverage: readonly CoverageEntry[];
|
|
20
27
|
tasks: readonly Pick<TaskOutcome, "status">[];
|
|
21
28
|
}): {
|
|
22
29
|
notReviewed: number;
|
|
23
30
|
nothingReviewed: boolean;
|
|
31
|
+
incomplete: Record<IncompleteEnding, number>;
|
|
24
32
|
};
|
|
33
|
+
export declare function isIncompleteReview(run: {
|
|
34
|
+
coverage: readonly CoverageEntry[];
|
|
35
|
+
unverifiedCriticals: number;
|
|
36
|
+
}): boolean;
|
|
37
|
+
export declare function isBlocking(run: {
|
|
38
|
+
verdict: Verdict;
|
|
39
|
+
changeRequest: Pick<ChangeRequest, "override">;
|
|
40
|
+
}): boolean;
|
|
41
|
+
export declare function unconfirmedCriticals(run: {
|
|
42
|
+
verdict: Verdict;
|
|
43
|
+
findings: readonly Pick<Finding, "severity" | "verification" | "lowConfidence">[];
|
|
44
|
+
}): number;
|
|
25
45
|
export declare const taskStatusSchema: z.ZodEnum<{
|
|
26
46
|
cancelled: "cancelled";
|
|
27
47
|
completed: "completed";
|
|
@@ -36,9 +56,14 @@ export interface TaskOutcome {
|
|
|
36
56
|
files: string[];
|
|
37
57
|
status: TaskStatus;
|
|
38
58
|
error?: string;
|
|
59
|
+
ended?: IncompleteEnding;
|
|
39
60
|
findings: number;
|
|
40
61
|
durationMs: number;
|
|
41
62
|
usage: Usage;
|
|
63
|
+
reusedFrom?: string;
|
|
64
|
+
wrapUp?: {
|
|
65
|
+
findings: number;
|
|
66
|
+
};
|
|
42
67
|
}
|
|
43
68
|
export interface ReviewReport {
|
|
44
69
|
runId: string;
|
|
@@ -57,6 +82,8 @@ export interface ReviewReport {
|
|
|
57
82
|
unverifiedCriticals: number;
|
|
58
83
|
refuted: RefutedFinding[];
|
|
59
84
|
remembered: RememberedEntry[];
|
|
85
|
+
learnings?: LearningUse[];
|
|
86
|
+
analyzerEvidence?: AnalyzerEvidenceUse[];
|
|
60
87
|
judgement?: JudgeDecisions;
|
|
61
88
|
scope?: {
|
|
62
89
|
mode: "incremental";
|
|
@@ -81,10 +108,15 @@ export interface ReviewReport {
|
|
|
81
108
|
usage: Usage;
|
|
82
109
|
warnings: string[];
|
|
83
110
|
}
|
|
111
|
+
export declare const REVIEW_STAGES: readonly ["select", "bundle", "plan", "review", "filter", "verify", "judge"];
|
|
112
|
+
export type ReviewStage = (typeof REVIEW_STAGES)[number];
|
|
84
113
|
export type ReviewEvent = {
|
|
85
114
|
type: "run_started";
|
|
86
115
|
runId: string;
|
|
87
116
|
changeRequest: ChangeRequest;
|
|
117
|
+
} | {
|
|
118
|
+
type: "stage_started";
|
|
119
|
+
stage: ReviewStage;
|
|
88
120
|
} | {
|
|
89
121
|
type: "files_selected";
|
|
90
122
|
selected: number;
|
|
@@ -94,6 +126,10 @@ export type ReviewEvent = {
|
|
|
94
126
|
type: "files_bundled";
|
|
95
127
|
strategy: string;
|
|
96
128
|
bundles: number;
|
|
129
|
+
groups: {
|
|
130
|
+
label: string;
|
|
131
|
+
files: string[];
|
|
132
|
+
}[];
|
|
97
133
|
warnings: string[];
|
|
98
134
|
} | {
|
|
99
135
|
type: "matrix_planned";
|
|
@@ -109,13 +145,31 @@ export type ReviewEvent = {
|
|
|
109
145
|
type: "task_progress";
|
|
110
146
|
taskId: string;
|
|
111
147
|
message: string;
|
|
148
|
+
attempt?: AttemptRecord;
|
|
112
149
|
} | {
|
|
113
150
|
type: "finding";
|
|
114
151
|
taskId: string;
|
|
115
152
|
finding: Finding;
|
|
153
|
+
} | {
|
|
154
|
+
type: "finding_dropped";
|
|
155
|
+
taskId: string;
|
|
156
|
+
reason: "outside_review";
|
|
157
|
+
file: string;
|
|
158
|
+
title: string;
|
|
159
|
+
} | {
|
|
160
|
+
type: "task_reported";
|
|
161
|
+
taskId: string;
|
|
162
|
+
key: string;
|
|
163
|
+
findings: TaskFinding[];
|
|
116
164
|
} | {
|
|
117
165
|
type: "task_finished";
|
|
118
166
|
outcome: TaskOutcome;
|
|
167
|
+
} | {
|
|
168
|
+
type: "coverage_settled";
|
|
169
|
+
coverage: CoverageEntry[];
|
|
170
|
+
} | {
|
|
171
|
+
type: "usage_reported";
|
|
172
|
+
usage: Usage;
|
|
119
173
|
} | {
|
|
120
174
|
type: "verification_finished";
|
|
121
175
|
checked: number;
|
|
@@ -134,4 +188,3 @@ export interface AnchoringSummary {
|
|
|
134
188
|
relocationCalls: number;
|
|
135
189
|
}
|
|
136
190
|
export declare function summarizeAnchoring(findings: readonly Finding[], relocationCalls: number): AnchoringSummary;
|
|
137
|
-
//# sourceMappingURL=report.d.ts.map
|
package/dist/report/report.js
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
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(
|
|
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 };
|
|
23
|
+
}
|
|
24
|
+
// An incomplete review: it left an unfinished file or a critical finding
|
|
25
|
+
// Verify could not check, so its result must never be read as a pass. The
|
|
26
|
+
// exit code (3), SARIF, the pull request summary, the ocra Cloud upload and
|
|
27
|
+
// `ocra metrics` all read it from here.
|
|
28
|
+
export function isIncompleteReview(run) {
|
|
29
|
+
return run.coverage.some(isUnfinished) || run.unverifiedCriticals > 0;
|
|
30
|
+
}
|
|
31
|
+
// A verdict that fails the run and requests changes: significant concerns
|
|
32
|
+
// that no one entitled to has overridden for this head commit.
|
|
33
|
+
export function isBlocking(run) {
|
|
34
|
+
return run.verdict === "significant_concerns" && run.changeRequest.override === undefined;
|
|
35
|
+
}
|
|
36
|
+
// Critical findings that only cap the verdict at minor issues: none is
|
|
37
|
+
// confirmed, so none blocks. Zero while a confirmed one blocks, and
|
|
38
|
+
// low-confidence findings do not count toward the verdict at all.
|
|
39
|
+
export function unconfirmedCriticals(run) {
|
|
40
|
+
if (run.verdict === "significant_concerns")
|
|
41
|
+
return 0;
|
|
42
|
+
return run.findings.filter((f) => f.severity === "critical" && f.verification !== "confirmed" && !f.lowConfidence).length;
|
|
14
43
|
}
|
|
15
44
|
export const taskStatusSchema = z.enum(["completed", "failed", "timed_out", "cancelled"]);
|
|
45
|
+
export const REVIEW_STAGES = [
|
|
46
|
+
"select",
|
|
47
|
+
"bundle",
|
|
48
|
+
"plan",
|
|
49
|
+
"review",
|
|
50
|
+
"filter",
|
|
51
|
+
"verify",
|
|
52
|
+
"judge",
|
|
53
|
+
];
|
|
16
54
|
export function summarizeAnchoring(findings, relocationCalls) {
|
|
17
55
|
const byMethod = {
|
|
18
56
|
hunk: 0,
|
|
@@ -29,4 +67,3 @@ export function summarizeAnchoring(findings, relocationCalls) {
|
|
|
29
67
|
relocationCalls,
|
|
30
68
|
};
|
|
31
69
|
}
|
|
32
|
-
//# sourceMappingURL=report.js.map
|
package/dist/report/serialize.js
CHANGED
|
@@ -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
|
package/dist/rereview/quote.d.ts
CHANGED
|
@@ -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
|
package/dist/rereview/quote.js
CHANGED