@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
|
@@ -1,47 +1,57 @@
|
|
|
1
|
-
import { SpendLimitReached } from "../agent/budget.js";
|
|
2
1
|
import { mapWithConcurrency } from "../agent/pool.js";
|
|
3
2
|
import { roleCall } from "../agent/settings.js";
|
|
4
3
|
import { emptyUsage } from "../agent/usage.js";
|
|
5
4
|
import { runtimeRelocator } from "../anchor/relocate.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
5
|
+
import { DEFAULT_MAX_TASKS, planTasks, } from "../matrix/matrix.js";
|
|
6
|
+
import { jobKey, reuseJob, runJob } from "./execute.js";
|
|
7
|
+
import { reusePool } from "./resume.js";
|
|
9
8
|
// One agent task per (bundle, reviewer) cell of the matrix, within the task
|
|
10
9
|
// limit, the run's signal and the review share of the spend limit.
|
|
11
10
|
export async function executeStage(reviewers, context) {
|
|
12
|
-
const { options, plan, emit } = context;
|
|
11
|
+
const { options, settings, plan, emit } = context;
|
|
12
|
+
emit({ type: "stage_started", stage: "plan" });
|
|
13
13
|
const matrix = planTasks(plan.bundles, reviewers, plan.tier, options.reviewerOverrides, {
|
|
14
|
-
ultra:
|
|
15
|
-
...(
|
|
14
|
+
ultra: settings.ultra,
|
|
15
|
+
...(settings.maxTasks !== undefined ? { maxTasks: settings.maxTasks } : {}),
|
|
16
16
|
hasGuidelines: Boolean(plan.guidelines?.trim()),
|
|
17
17
|
});
|
|
18
18
|
const warnings = [];
|
|
19
19
|
const limited = matrix.skipped.filter((s) => s.reason === "task_limit").length;
|
|
20
20
|
if (limited > 0) {
|
|
21
|
-
warnings.push(`task limit of ${
|
|
21
|
+
warnings.push(`task limit of ${settings.maxTasks ?? DEFAULT_MAX_TASKS} reached: ${limited} review task(s) skipped; their files are reported as not reviewed`);
|
|
22
22
|
}
|
|
23
23
|
emit({ type: "matrix_planned", tasks: matrix.cells.length, skipped: matrix.skipped });
|
|
24
|
+
emit({ type: "stage_started", stage: "review" });
|
|
24
25
|
const relocations = [];
|
|
25
|
-
const
|
|
26
|
-
const
|
|
26
|
+
const execute = executeOptions(context, relocations);
|
|
27
|
+
const resume = options.resume;
|
|
28
|
+
const pool = reusePool(resume);
|
|
29
|
+
if (resume)
|
|
30
|
+
execute.reuse = { pool, runId: resume.runId };
|
|
27
31
|
const notStarted = new Set();
|
|
28
32
|
let unaffordable = 0;
|
|
29
|
-
const results = await mapWithConcurrency(matrix.cells,
|
|
33
|
+
const results = await mapWithConcurrency(matrix.cells, settings.concurrency, async (cell) => {
|
|
30
34
|
// Once the run is cancelled or timed out, remaining cells are not started.
|
|
31
35
|
if (context.signal.aborted) {
|
|
32
36
|
notStarted.add(cell.taskId);
|
|
33
37
|
return skipCell(cell, "run cancelled before this task started", emit);
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
const key = jobKey(cell, plan, execute);
|
|
40
|
+
const reused = await reuseJob(cell, plan, execute, key);
|
|
41
|
+
if (reused)
|
|
42
|
+
return reused;
|
|
43
|
+
if (!context.spendLimit.mayStartReview()) {
|
|
36
44
|
notStarted.add(cell.taskId);
|
|
37
45
|
unaffordable += 1;
|
|
38
|
-
return skipCell(cell, `spend limit of $${
|
|
46
|
+
return skipCell(cell, `spend limit of $${settings.maxCostUsd} reached`, emit);
|
|
39
47
|
}
|
|
40
|
-
return runJob(cell, plan, execute);
|
|
48
|
+
return runJob(cell, plan, execute, key);
|
|
41
49
|
});
|
|
42
50
|
if (unaffordable > 0) {
|
|
43
|
-
warnings.push(`spend limit of $${
|
|
51
|
+
warnings.push(`spend limit of $${settings.maxCostUsd} reached: ${unaffordable} review task(s) did not start; their files are reported as not reviewed`);
|
|
44
52
|
}
|
|
53
|
+
if (resume)
|
|
54
|
+
warnings.push(...resumeWarnings(resume.runId, pool.unused()));
|
|
45
55
|
warnings.push(...results.flatMap((r) => r.warnings));
|
|
46
56
|
return {
|
|
47
57
|
matrix,
|
|
@@ -50,36 +60,48 @@ export async function executeStage(reviewers, context) {
|
|
|
50
60
|
relocations,
|
|
51
61
|
usage: () => [...results.map((r) => r.usage), ...relocations],
|
|
52
62
|
warnings,
|
|
53
|
-
reviewLimitReached: () => spendLimit.signal.aborted || unaffordable > 0,
|
|
54
63
|
};
|
|
55
64
|
}
|
|
56
|
-
function executeOptions({ options,
|
|
65
|
+
function executeOptions({ options, settings, spendLimit, signal, emit }, relocations) {
|
|
57
66
|
const relocator = relocatorOf(options, signal, (u) => {
|
|
58
67
|
relocations.push(u);
|
|
59
|
-
|
|
68
|
+
spendLimit.charge(u);
|
|
60
69
|
});
|
|
61
70
|
return {
|
|
62
71
|
runtime: options.runtime,
|
|
63
|
-
taskTimeoutMs:
|
|
72
|
+
taskTimeoutMs: settings.taskTimeoutMs,
|
|
64
73
|
abortGraceMs: options.abortGraceMs,
|
|
65
74
|
// Past the spend limit a quote that does not match stays file-level.
|
|
66
75
|
relocate: relocator &&
|
|
67
|
-
(async (request) =>
|
|
68
|
-
ultra:
|
|
76
|
+
(async (request) => spendLimit.mayCall() ? relocator(request) : undefined),
|
|
77
|
+
ultra: settings.ultra,
|
|
78
|
+
symbols: options.symbols,
|
|
79
|
+
references: options.references,
|
|
69
80
|
plans: new Map(),
|
|
70
81
|
agents: options,
|
|
82
|
+
keyInputs: keyInputs(options),
|
|
71
83
|
emit,
|
|
72
84
|
// Tasks report spend while they run, so the one that uses up the review
|
|
73
85
|
// share stops every task still running, not only the ones not yet started.
|
|
74
|
-
onUsage: (usage) =>
|
|
75
|
-
|
|
76
|
-
if (budget.reviewExhausted() && !spendLimit.signal.aborted) {
|
|
77
|
-
spendLimit.abort(new SpendLimitReached(options.limits?.maxCostUsd ?? 0));
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
signal: AbortSignal.any([signal, spendLimit.signal]),
|
|
86
|
+
onUsage: (usage) => spendLimit.chargeReview(usage),
|
|
87
|
+
signal: AbortSignal.any([signal, spendLimit.reviewSignal]),
|
|
81
88
|
};
|
|
82
89
|
}
|
|
90
|
+
// The caller's build and sampling: an earlier run made with another ocra or
|
|
91
|
+
// other sampling settings answered a different question.
|
|
92
|
+
function keyInputs({ identity }) {
|
|
93
|
+
const provenance = identity?.provenance;
|
|
94
|
+
return provenance && { ocraVersion: provenance.ocraVersion, sampling: provenance.sampling };
|
|
95
|
+
}
|
|
96
|
+
// Reused tasks are named in report.tasks (reusedFrom); only what could not be
|
|
97
|
+
// reused is worth a warning.
|
|
98
|
+
function resumeWarnings(runId, unused) {
|
|
99
|
+
if (unused === 0)
|
|
100
|
+
return [];
|
|
101
|
+
return [
|
|
102
|
+
`resumed run ${runId}: ${unused} completed task(s) not reused, their inputs changed (commits, configuration, prompts or ocra version)`,
|
|
103
|
+
];
|
|
104
|
+
}
|
|
83
105
|
function relocatorOf(options, signal, onUsage) {
|
|
84
106
|
if (options.relocate === false)
|
|
85
107
|
return undefined;
|
|
@@ -101,4 +123,3 @@ function skipCell(cell, reason, emit) {
|
|
|
101
123
|
emit({ type: "task_finished", outcome });
|
|
102
124
|
return { outcome, findings: [], usage: emptyUsage(), warnings: [] };
|
|
103
125
|
}
|
|
104
|
-
//# sourceMappingURL=execute-stage.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type AgentSettings } from "../agent/settings.js";
|
|
2
2
|
import { type AnchorContext } from "../anchor/anchor.js";
|
|
3
|
-
import type { AgentRuntime, Usage } from "../contracts.js";
|
|
3
|
+
import type { AgentRuntime, ReferenceIndex, SymbolExtractor, Usage } from "../contracts.js";
|
|
4
4
|
import type { Finding } from "../domain.js";
|
|
5
|
+
import type { MatrixCell } from "../matrix/matrix.js";
|
|
5
6
|
import type { ReviewEvent, TaskOutcome } from "../report/report.js";
|
|
6
7
|
import { planBundle } from "../review/plan-phase.js";
|
|
7
|
-
import type { MatrixCell } from "./matrix.js";
|
|
8
8
|
import type { ReviewPlan } from "./plan.js";
|
|
9
|
+
import type { ReusePool } from "./resume.js";
|
|
9
10
|
export interface JobResult {
|
|
10
11
|
outcome: TaskOutcome;
|
|
11
12
|
findings: Finding[];
|
|
@@ -18,16 +19,21 @@ export interface ExecuteOptions {
|
|
|
18
19
|
taskTimeoutMs: number;
|
|
19
20
|
abortGraceMs?: number | undefined;
|
|
20
21
|
relocate?: AnchorContext["relocate"] | undefined;
|
|
22
|
+
symbols?: SymbolExtractor | undefined;
|
|
23
|
+
references?: ReferenceIndex | undefined;
|
|
21
24
|
plans?: Map<string, Promise<PlannedBundle>>;
|
|
22
25
|
emit: (event: ReviewEvent) => void;
|
|
23
26
|
onUsage?: ((usage: Usage) => void) | undefined;
|
|
24
27
|
signal: AbortSignal;
|
|
25
28
|
agents?: AgentSettings;
|
|
29
|
+
reuse?: {
|
|
30
|
+
pool: ReusePool;
|
|
31
|
+
runId: string;
|
|
32
|
+
};
|
|
33
|
+
keyInputs?: unknown;
|
|
26
34
|
}
|
|
27
35
|
type PlannedBundle = Awaited<ReturnType<typeof planBundle>>;
|
|
28
|
-
export declare function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export declare function runJob(job: MatrixCell, plan: ReviewPlan, options: ExecuteOptions): Promise<JobResult>;
|
|
36
|
+
export declare function jobKey(job: MatrixCell, plan: ReviewPlan, options: ExecuteOptions): string;
|
|
37
|
+
export declare function runJob(job: MatrixCell, plan: ReviewPlan, options: ExecuteOptions, key: string): Promise<JobResult>;
|
|
38
|
+
export declare function reuseJob(job: MatrixCell, plan: ReviewPlan, options: ExecuteOptions, key: string): Promise<JobResult | undefined>;
|
|
32
39
|
export {};
|
|
33
|
-
//# sourceMappingURL=execute.d.ts.map
|
package/dist/pipeline/execute.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import { reviewerCall } from "../agent/settings.js";
|
|
2
|
-
import { addUsage } from "../agent/usage.js";
|
|
1
|
+
import { chainOf, reviewerCall, } from "../agent/settings.js";
|
|
2
|
+
import { addUsage, emptyUsage } from "../agent/usage.js";
|
|
3
3
|
import { anchorFinding } from "../anchor/anchor.js";
|
|
4
|
-
import { memoryFor } from "../memory/memory.js";
|
|
5
4
|
import { findCallers } from "../review/impact.js";
|
|
6
5
|
import { planBundle } from "../review/plan-phase.js";
|
|
7
6
|
import { buildReviewPrompt } from "../review/prompt.js";
|
|
8
|
-
import { resolveRules } from "../rules/resolve.js";
|
|
9
7
|
import { toFinding } from "./findings.js";
|
|
8
|
+
import { stableHash } from "./provenance.js";
|
|
10
9
|
import { executeTask } from "./task.js";
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return files.length >= PLAN_MIN_FILES || chars >= PLAN_MIN_PATCH_CHARS;
|
|
10
|
+
import { taskPrompt } from "./task-prompt.js";
|
|
11
|
+
// The key of a cell's inputs (taskKey), under which its answer is reported
|
|
12
|
+
// and an earlier run's answer is reused.
|
|
13
|
+
export function jobKey(job, plan, options) {
|
|
14
|
+
const call = reviewerCall(job.reviewer, options.agents ?? {});
|
|
15
|
+
return taskKey(job, plan, taskPrompt(job, plan, options.ultra === true).prompt, call, options);
|
|
18
16
|
}
|
|
19
17
|
// Runs one (bundle, reviewer) cell and anchors what it reports.
|
|
20
|
-
export async function runJob(job, plan, options) {
|
|
18
|
+
export async function runJob(job, plan, options, key) {
|
|
21
19
|
const { emit } = options;
|
|
22
20
|
const files = job.bundle.files.map((f) => f.newPath);
|
|
23
21
|
const call = reviewerCall(job.reviewer, options.agents ?? {});
|
|
24
|
-
const
|
|
22
|
+
const task = taskPrompt(job, plan, options.ultra === true);
|
|
23
|
+
const prepared = await preparePrompt(job, plan, options, call, task);
|
|
25
24
|
emit({
|
|
26
25
|
type: "task_started",
|
|
27
26
|
taskId: job.taskId,
|
|
@@ -40,7 +39,12 @@ export async function runJob(job, plan, options) {
|
|
|
40
39
|
context: plan.context,
|
|
41
40
|
timeoutMs: options.taskTimeoutMs,
|
|
42
41
|
}, options.signal, {
|
|
43
|
-
onProgress: (message) => emit({
|
|
42
|
+
onProgress: (message, attempt) => emit({
|
|
43
|
+
type: "task_progress",
|
|
44
|
+
taskId: job.taskId,
|
|
45
|
+
message,
|
|
46
|
+
...(attempt ? { attempt } : {}),
|
|
47
|
+
}),
|
|
44
48
|
onUsage: options.onUsage,
|
|
45
49
|
category: job.reviewer.category,
|
|
46
50
|
abortGraceMs: options.abortGraceMs,
|
|
@@ -60,34 +64,86 @@ export async function runJob(job, plan, options) {
|
|
|
60
64
|
};
|
|
61
65
|
if (result.error !== undefined)
|
|
62
66
|
outcome.error = result.error;
|
|
67
|
+
if (result.ended !== undefined)
|
|
68
|
+
outcome.ended = result.ended;
|
|
69
|
+
if (result.wrapUp)
|
|
70
|
+
outcome.wrapUp = result.wrapUp;
|
|
71
|
+
// A task cut off before it finished (ADR-0030) is reviewed again, not reused.
|
|
72
|
+
if (result.status === "completed" && result.ended === undefined) {
|
|
73
|
+
emit({ type: "task_reported", taskId: job.taskId, key, findings: result.findings });
|
|
74
|
+
}
|
|
63
75
|
emit({ type: "task_finished", outcome });
|
|
64
76
|
return { outcome, findings: anchored.findings, usage, warnings };
|
|
65
77
|
}
|
|
66
|
-
//
|
|
67
|
-
//
|
|
68
|
-
|
|
78
|
+
// Everything a task's answer depends on, so an earlier answer is reused only
|
|
79
|
+
// for the same question: the prompt (instructions, change, bundle, rules,
|
|
80
|
+
// guidelines, memory), the commits (the code around the change, which the
|
|
81
|
+
// reviewer reads but the prompt does not hold), the model chain and effort,
|
|
82
|
+
// --ultra (which adds a plan phase and callers; callers at the full tier,
|
|
83
|
+
// like the plan, are derived from the same inputs), and the caller's build
|
|
84
|
+
// and sampling.
|
|
85
|
+
function taskKey(job, plan, prompt, call, options) {
|
|
86
|
+
const { baseSha, headSha } = plan.changeRequest;
|
|
87
|
+
return stableHash({
|
|
88
|
+
prompt: { system: prompt.system, user: prompt.user },
|
|
89
|
+
commits: { base: baseSha, head: headSha },
|
|
90
|
+
tier: job.reviewer.modelTier,
|
|
91
|
+
chain: chainOf(call, job.reviewer.modelTier, options.agents ?? {}),
|
|
92
|
+
effort: call.effort,
|
|
93
|
+
ultra: options.ultra === true,
|
|
94
|
+
inputs: options.keyInputs,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// A cell an earlier run already answered, when the reuse pool holds an answer
|
|
98
|
+
// under its key: the reported findings are anchored again (the change is the
|
|
99
|
+
// same, so they land where they did) and it costs nothing, so the stage takes
|
|
100
|
+
// it before the spend limit; its outcome says where it came from. Undefined
|
|
101
|
+
// when the cell has to run.
|
|
102
|
+
export async function reuseJob(job, plan, options, key) {
|
|
103
|
+
const earlier = options.reuse?.pool.take(key);
|
|
104
|
+
if (!earlier || !options.reuse)
|
|
105
|
+
return undefined;
|
|
106
|
+
const { runId } = options.reuse;
|
|
107
|
+
const { emit } = options;
|
|
69
108
|
const files = job.bundle.files.map((f) => f.newPath);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
bundle: job.bundle.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
109
|
+
emit({
|
|
110
|
+
type: "task_started",
|
|
111
|
+
taskId: job.taskId,
|
|
112
|
+
reviewer: job.reviewer.id,
|
|
113
|
+
bundle: job.bundle.label,
|
|
114
|
+
files,
|
|
115
|
+
});
|
|
116
|
+
const anchored = await anchorFindings(job, plan, options, earlier.findings);
|
|
117
|
+
emit({ type: "task_reported", taskId: job.taskId, key, findings: [...earlier.findings] });
|
|
118
|
+
const { error: _error, ...prior } = earlier.outcome;
|
|
119
|
+
const outcome = {
|
|
120
|
+
...prior,
|
|
121
|
+
taskId: job.taskId,
|
|
122
|
+
reviewer: job.reviewer.id,
|
|
123
|
+
bundle: job.bundle.label,
|
|
124
|
+
files,
|
|
125
|
+
status: "completed",
|
|
126
|
+
findings: anchored.findings.length,
|
|
127
|
+
reusedFrom: earlier.outcome.reusedFrom ?? runId,
|
|
78
128
|
};
|
|
79
|
-
|
|
80
|
-
|
|
129
|
+
emit({ type: "task_finished", outcome });
|
|
130
|
+
return { outcome, findings: anchored.findings, usage: emptyUsage(), warnings: anchored.warnings };
|
|
131
|
+
}
|
|
132
|
+
// The review prompt, with a plan phase and the callers of changed symbols
|
|
133
|
+
// when the task gets them.
|
|
134
|
+
async function preparePrompt(job, plan, options, call, task) {
|
|
135
|
+
const { planCall } = task;
|
|
136
|
+
const callers = task.callers ? await findCallers(job.bundle.files, plan.context, options) : [];
|
|
137
|
+
if (!planCall) {
|
|
138
|
+
const prompt = callers.length > 0 ? buildReviewPrompt({ ...task.input, callers }) : task.prompt;
|
|
139
|
+
return { prompt, usage: [], warnings: [] };
|
|
81
140
|
}
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const shared = options.plans?.get(key);
|
|
85
|
-
const planning = shared ??
|
|
86
|
-
planBundle(options.runtime, job.reviewer, buildReviewPrompt({ ...input, forPlanning: true }), options.signal, call);
|
|
141
|
+
const shared = options.plans?.get(planCall.key);
|
|
142
|
+
const planning = shared ?? planBundle(options.runtime, job.reviewer, planCall.prompt(), options.signal, call);
|
|
87
143
|
if (!shared)
|
|
88
|
-
options.plans?.set(key, planning);
|
|
144
|
+
options.plans?.set(planCall.key, planning);
|
|
89
145
|
const planned = await planning;
|
|
90
|
-
const prompt = buildReviewPrompt({ ...input, callers, plan: planned.plan });
|
|
146
|
+
const prompt = buildReviewPrompt({ ...task.input, callers, plan: planned.plan });
|
|
91
147
|
// The sample that made the call pays for it and reports its warning.
|
|
92
148
|
if (shared)
|
|
93
149
|
return { prompt, usage: [], warnings: [] };
|
|
@@ -104,22 +160,32 @@ async function anchorFindings(job, plan, options, reportedFindings) {
|
|
|
104
160
|
};
|
|
105
161
|
if (options.relocate)
|
|
106
162
|
anchorContext.relocate = options.relocate;
|
|
107
|
-
// A finding on
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
|
|
163
|
+
// A finding on another file of the change is kept: a bug often shows where
|
|
164
|
+
// a changed caller meets a changed callee in another bundle, and dropping
|
|
165
|
+
// it lost the finding outright. A copy the task owning that file also
|
|
166
|
+
// reports shares its fingerprint, so the run keeps one (dedupeFindings).
|
|
167
|
+
// A file outside the change, or left out of an incremental review, is
|
|
168
|
+
// not under review.
|
|
169
|
+
const reviewed = new Set(plan.bundles.flatMap((b) => b.files.map((f) => f.newPath)));
|
|
111
170
|
let outside = 0;
|
|
112
171
|
for (const { reported, model } of reportedFindings) {
|
|
113
|
-
// Relocating a quote on a file outside the
|
|
172
|
+
// Relocating a quote on a file outside the review would pay for an
|
|
114
173
|
// answer the next check throws away.
|
|
115
|
-
const context =
|
|
174
|
+
const context = reviewed.has(reported.file)
|
|
116
175
|
? anchorContext
|
|
117
176
|
: { diffs: anchorContext.diffs, readNewFile: anchorContext.readNewFile };
|
|
118
177
|
const anchor = await anchorFinding(reported, context);
|
|
119
178
|
if (anchor.warning)
|
|
120
179
|
warnings.push(`${job.taskId}: ${anchor.warning}`);
|
|
121
|
-
if (!
|
|
180
|
+
if (!reviewed.has(anchor.file)) {
|
|
122
181
|
outside += 1;
|
|
182
|
+
options.emit({
|
|
183
|
+
type: "finding_dropped",
|
|
184
|
+
taskId: job.taskId,
|
|
185
|
+
reason: "outside_review",
|
|
186
|
+
file: anchor.file,
|
|
187
|
+
title: reported.title,
|
|
188
|
+
});
|
|
123
189
|
continue;
|
|
124
190
|
}
|
|
125
191
|
const content = anchor.lineRange
|
|
@@ -131,8 +197,7 @@ async function anchorFindings(job, plan, options, reportedFindings) {
|
|
|
131
197
|
options.emit({ type: "finding", taskId: job.taskId, finding });
|
|
132
198
|
}
|
|
133
199
|
if (outside > 0) {
|
|
134
|
-
warnings.push(`${job.taskId}: dropped ${outside} finding(s) on files outside
|
|
200
|
+
warnings.push(`${job.taskId}: dropped ${outside} finding(s) on files outside the review`);
|
|
135
201
|
}
|
|
136
202
|
return { findings, warnings };
|
|
137
203
|
}
|
|
138
|
-
//# sourceMappingURL=execute.js.map
|
|
@@ -9,12 +9,14 @@ import { importSarif } from "./imports.js";
|
|
|
9
9
|
// paid for findings that will not be reported, and a person's dismissal
|
|
10
10
|
// keeps a finding out of the verdict whatever the models say.
|
|
11
11
|
export async function filterStage(executed, prior, { options, plan, emit }) {
|
|
12
|
+
emit({ type: "stage_started", stage: "filter" });
|
|
12
13
|
const imported = options.sarif && options.sarif.length > 0
|
|
13
14
|
? await importSarif(options.sarif, plan, emit)
|
|
14
15
|
: { findings: [], outcomes: [], warnings: [] };
|
|
15
16
|
const { results } = executed;
|
|
16
17
|
const found = dedupeFindings([...results.flatMap((r) => r.findings), ...imported.findings]);
|
|
17
18
|
const coverage = coverageOf(plan.decisions, results, plan.unchanged, executed.matrix.limited ?? [], executed.notStarted);
|
|
19
|
+
emit({ type: "coverage_settled", coverage });
|
|
18
20
|
const remembered = applyMemory(found, plan.memory);
|
|
19
21
|
const reported = new Set(found.map((f) => f.fingerprint));
|
|
20
22
|
const priorReview = withoutRemembered(prior, plan.memory);
|
|
@@ -43,4 +45,3 @@ function withoutRemembered(review, memory) {
|
|
|
43
45
|
// Everything else the earlier review carries (replies, tier, head) stays.
|
|
44
46
|
return { ...review, findings: review.findings.filter((f) => !accepted.has(f.fingerprint)) };
|
|
45
47
|
}
|
|
46
|
-
//# sourceMappingURL=filter-stage.js.map
|
|
@@ -3,4 +3,3 @@ import type { Finding, FindingProvenance, ReportedFinding } from "../domain.js";
|
|
|
3
3
|
export declare function fingerprint(category: string, file: string, existingCode: string): string;
|
|
4
4
|
export declare function toFinding(reported: ReportedFinding, reviewer: string, provenance: FindingProvenance, anchor: Anchor, content?: string): Finding;
|
|
5
5
|
export declare function dedupeFindings(findings: readonly Finding[]): Finding[];
|
|
6
|
-
//# sourceMappingURL=findings.d.ts.map
|
|
@@ -9,4 +9,3 @@ export interface SarifImport {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const MAX_IMPORTED_PER_RUN = 200;
|
|
11
11
|
export declare function importSarif(logs: readonly SarifLog[], plan: Pick<ReviewPlan, "selected" | "context">, emit: (event: ReviewEvent) => void): Promise<SarifImport>;
|
|
12
|
-
//# sourceMappingURL=imports.d.ts.map
|
package/dist/pipeline/imports.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { emptyUsage } from "../agent/usage.js";
|
|
2
2
|
import { anchorFinding } from "../anchor/anchor.js";
|
|
3
3
|
import { sarifCandidates } from "../sarif/candidates.js";
|
|
4
|
+
import { changedLines, overlaps } from "../sarif/evidence.js";
|
|
4
5
|
import { toFinding } from "./findings.js";
|
|
5
6
|
import { boundFinding } from "./task.js";
|
|
6
7
|
// A hostile log could carry thousands of results on the change.
|
|
@@ -87,23 +88,8 @@ function quoteFrom(content, lines) {
|
|
|
87
88
|
.trim();
|
|
88
89
|
return quote || undefined;
|
|
89
90
|
}
|
|
90
|
-
// The new-side lines each hunk covers, context included.
|
|
91
|
-
function changedLines(diffs) {
|
|
92
|
-
const windows = new Map();
|
|
93
|
-
for (const diff of diffs) {
|
|
94
|
-
const ranges = diff.hunks
|
|
95
|
-
.filter((h) => h.newLines > 0)
|
|
96
|
-
.map((h) => ({ start: h.newStart, end: h.newStart + h.newLines - 1 }));
|
|
97
|
-
if (ranges.length > 0)
|
|
98
|
-
windows.set(diff.newPath, ranges);
|
|
99
|
-
}
|
|
100
|
-
return windows;
|
|
101
|
-
}
|
|
102
91
|
function touches(windows, candidate) {
|
|
103
|
-
|
|
104
|
-
if (!ranges)
|
|
105
|
-
return false;
|
|
106
|
-
return ranges.some((r) => candidate.lines.start <= r.end && candidate.lines.end >= r.start);
|
|
92
|
+
return (windows.get(candidate.file) ?? []).some((r) => overlaps(candidate.lines, r, 0));
|
|
107
93
|
}
|
|
108
94
|
function importWarnings(tool, c) {
|
|
109
95
|
const left = [];
|
|
@@ -123,4 +109,3 @@ function importWarnings(tool, c) {
|
|
|
123
109
|
return [];
|
|
124
110
|
return [`${tool}: imported ${c.imported} result(s); left out ${left.join(", ")}`];
|
|
125
111
|
}
|
|
126
|
-
//# sourceMappingURL=imports.js.map
|
|
@@ -2,7 +2,8 @@ import type { ReviewerOverrides, RoleSettings, TierEfforts } from "../agent/sett
|
|
|
2
2
|
import type { AnchorContext } from "../anchor/anchor.js";
|
|
3
3
|
import type { BundlePolicy } from "../bundle/bundle.js";
|
|
4
4
|
import type { FileGrouper } from "../bundle/grouping.js";
|
|
5
|
-
import type { AgentRuntime, ModelChains } from "../contracts.js";
|
|
5
|
+
import type { AgentRuntime, ModelChains, ReferenceIndex, SymbolExtractor } from "../contracts.js";
|
|
6
|
+
import type { Learning } from "../knowledge/learning.js";
|
|
6
7
|
import type { MemoryEntry } from "../memory/memory.js";
|
|
7
8
|
import type { ReviewEvent } from "../report/report.js";
|
|
8
9
|
import type { ReviewerDefinition } from "../review/reviewer.js";
|
|
@@ -11,6 +12,7 @@ import type { SarifLog } from "../sarif/schema.js";
|
|
|
11
12
|
import type { SelectionPolicy } from "../select/select.js";
|
|
12
13
|
import type { VcsAdapter } from "../vcs.js";
|
|
13
14
|
import type { ProvenanceInput } from "./provenance.js";
|
|
15
|
+
import type { ResumedRun } from "./resume.js";
|
|
14
16
|
export interface ReviewOptions {
|
|
15
17
|
vcs: VcsAdapter;
|
|
16
18
|
runtime: AgentRuntime;
|
|
@@ -22,12 +24,17 @@ export interface ReviewOptions {
|
|
|
22
24
|
rules?: readonly SourcedRule[];
|
|
23
25
|
readTrusted?: (path: string) => Promise<string | undefined>;
|
|
24
26
|
accountMemory?: readonly MemoryEntry[];
|
|
27
|
+
learnings?: readonly Learning[];
|
|
25
28
|
selection?: Partial<SelectionPolicy>;
|
|
26
29
|
limits?: ReviewLimits;
|
|
27
30
|
stages?: ReviewStages;
|
|
28
31
|
mode?: ReviewMode;
|
|
29
32
|
identity?: RunIdentity;
|
|
33
|
+
resume?: ResumedRun;
|
|
34
|
+
symbols?: SymbolExtractor;
|
|
35
|
+
references?: ReferenceIndex;
|
|
30
36
|
sarif?: readonly SarifLog[];
|
|
37
|
+
sarifEvidence?: readonly SarifLog[];
|
|
31
38
|
signal?: AbortSignal;
|
|
32
39
|
onEvent?: (event: ReviewEvent) => void;
|
|
33
40
|
}
|
|
@@ -41,6 +48,7 @@ export interface ReviewLimits {
|
|
|
41
48
|
export interface ReviewStages {
|
|
42
49
|
verify?: boolean;
|
|
43
50
|
judge?: boolean;
|
|
51
|
+
showPreExisting?: boolean;
|
|
44
52
|
}
|
|
45
53
|
export interface ReviewMode {
|
|
46
54
|
full?: boolean;
|
|
@@ -62,4 +70,16 @@ export declare const REVIEW_DEFAULTS: {
|
|
|
62
70
|
readonly runTimeoutMs: number;
|
|
63
71
|
};
|
|
64
72
|
export declare const MAX_TIMER_MS: number;
|
|
65
|
-
|
|
73
|
+
export interface RunSettings {
|
|
74
|
+
concurrency: number;
|
|
75
|
+
taskTimeoutMs: number;
|
|
76
|
+
runTimeoutMs: number;
|
|
77
|
+
maxCostUsd?: number;
|
|
78
|
+
maxTasks?: number;
|
|
79
|
+
ultra: boolean;
|
|
80
|
+
full: boolean;
|
|
81
|
+
verify: boolean;
|
|
82
|
+
judge: boolean;
|
|
83
|
+
showPreExisting: boolean;
|
|
84
|
+
}
|
|
85
|
+
export declare function runSettings(options: Pick<ReviewOptions, "limits" | "mode" | "stages">): RunSettings;
|
package/dist/pipeline/options.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { OcraError } from "../errors.js";
|
|
1
3
|
export const REVIEW_DEFAULTS = {
|
|
2
4
|
concurrency: 4,
|
|
3
5
|
taskTimeoutMs: 10 * 60_000,
|
|
@@ -6,4 +8,32 @@ export const REVIEW_DEFAULTS = {
|
|
|
6
8
|
// Timers fire at once past 2^31 - 1 ms (about 24.8 days); a longer timeout
|
|
7
9
|
// means no practical limit, so it is cut to the longest one a timer keeps.
|
|
8
10
|
export const MAX_TIMER_MS = 2 ** 31 - 1;
|
|
9
|
-
|
|
11
|
+
// Infinity is allowed (no practical limit), NaN never: z.number() refuses both.
|
|
12
|
+
const atLeast = (min, exclusive, what) => z.custom((v) => typeof v === "number" && (exclusive ? v > min : v >= min), `must be ${what}`);
|
|
13
|
+
const timeoutMs = atLeast(0, true, "a positive number of milliseconds");
|
|
14
|
+
const limitsSchema = z.object({
|
|
15
|
+
concurrency: z.int().positive().optional(),
|
|
16
|
+
taskTimeoutMs: timeoutMs.optional(),
|
|
17
|
+
runTimeoutMs: timeoutMs.optional(),
|
|
18
|
+
maxCostUsd: atLeast(0, false, "a number of US dollars, 0 or more").optional(),
|
|
19
|
+
maxTasks: z.int().nonnegative().optional(),
|
|
20
|
+
});
|
|
21
|
+
export function runSettings(options) {
|
|
22
|
+
const parsed = limitsSchema.safeParse(options.limits ?? {});
|
|
23
|
+
if (!parsed.success) {
|
|
24
|
+
throw new OcraError("CONFIG_INVALID", `ReviewOptions.limits is invalid: ${z.prettifyError(parsed.error)}`);
|
|
25
|
+
}
|
|
26
|
+
const limits = parsed.data;
|
|
27
|
+
return {
|
|
28
|
+
concurrency: limits.concurrency ?? REVIEW_DEFAULTS.concurrency,
|
|
29
|
+
taskTimeoutMs: Math.min(limits.taskTimeoutMs ?? REVIEW_DEFAULTS.taskTimeoutMs, MAX_TIMER_MS),
|
|
30
|
+
runTimeoutMs: Math.min(limits.runTimeoutMs ?? REVIEW_DEFAULTS.runTimeoutMs, MAX_TIMER_MS),
|
|
31
|
+
...(limits.maxCostUsd === undefined ? {} : { maxCostUsd: limits.maxCostUsd }),
|
|
32
|
+
...(limits.maxTasks === undefined ? {} : { maxTasks: limits.maxTasks }),
|
|
33
|
+
ultra: options.mode?.ultra === true,
|
|
34
|
+
full: options.mode?.full === true,
|
|
35
|
+
verify: options.stages?.verify !== false,
|
|
36
|
+
judge: options.stages?.judge !== false,
|
|
37
|
+
showPreExisting: options.stages?.showPreExisting !== false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -19,6 +19,13 @@ export declare const planOutputSchema: z.ZodObject<{
|
|
|
19
19
|
lite: "lite";
|
|
20
20
|
trivial: "trivial";
|
|
21
21
|
}>;
|
|
22
|
+
scope: z.ZodExactOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
23
|
+
mode: z.ZodLiteral<"incremental">;
|
|
24
|
+
since: z.ZodString;
|
|
25
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
26
|
+
mode: z.ZodLiteral<"full">;
|
|
27
|
+
reason: z.ZodString;
|
|
28
|
+
}, z.core.$strict>], "mode">>;
|
|
22
29
|
selected: z.ZodArray<z.ZodString>;
|
|
23
30
|
excluded: z.ZodArray<z.ZodObject<{
|
|
24
31
|
path: z.ZodString;
|
|
@@ -87,4 +94,3 @@ export declare const planOutputSchema: z.ZodObject<{
|
|
|
87
94
|
}, z.core.$strict>;
|
|
88
95
|
export type PlanOutput = z.output<typeof planOutputSchema>;
|
|
89
96
|
export declare function toPlanOutput(preview: ReviewPreview): PlanOutput;
|
|
90
|
-
//# sourceMappingURL=plan-output.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { EFFORT_LEVELS } from "../agent/settings.js";
|
|
3
3
|
import { riskTierSchema } from "../domain.js";
|
|
4
|
-
import { changeRequestSchema, skippedCellSchema } from "../report/output-schema.js";
|
|
4
|
+
import { changeRequestSchema, scopeSchema, skippedCellSchema } from "../report/output-schema.js";
|
|
5
5
|
import { exclusionReasonSchema } from "../select/select.js";
|
|
6
6
|
// The published shape of `ocra review --plan --format json` without what
|
|
7
7
|
// the CLI adds (where each setting came from), versioned like the report: a
|
|
@@ -28,6 +28,8 @@ export const planOutputSchema = z.strictObject({
|
|
|
28
28
|
version: z.literal(PLAN_VERSION),
|
|
29
29
|
changeRequest: changeRequestSchema,
|
|
30
30
|
tier: riskTierSchema,
|
|
31
|
+
// Added in version 1 without a bump, like planCalls: the report's scope.
|
|
32
|
+
scope: scopeSchema.exactOptional(),
|
|
31
33
|
selected: z.array(z.string()),
|
|
32
34
|
excluded: z.array(z.strictObject({ path: z.string(), reason: exclusionReasonSchema })),
|
|
33
35
|
bundles: z.array(z.strictObject({ label: z.string(), files: z.array(z.string()) })),
|
|
@@ -61,6 +63,7 @@ export function toPlanOutput(preview) {
|
|
|
61
63
|
...(c.override ? { override: { by: c.override.by, reason: c.override.reason } } : {}),
|
|
62
64
|
},
|
|
63
65
|
tier: preview.tier,
|
|
66
|
+
...(preview.scope ? { scope: planScope(preview.scope) } : {}),
|
|
64
67
|
selected: [...preview.selected],
|
|
65
68
|
excluded: preview.excluded.map((e) => ({ path: e.path, reason: e.reason })),
|
|
66
69
|
bundles: preview.bundles.map((b) => ({ label: b.label, files: [...b.files] })),
|
|
@@ -106,4 +109,8 @@ function planTask(t) {
|
|
|
106
109
|
: {}),
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
|
|
112
|
+
function planScope(scope) {
|
|
113
|
+
return scope.mode === "incremental"
|
|
114
|
+
? { mode: "incremental", since: scope.since }
|
|
115
|
+
: { mode: "full", reason: scope.reason };
|
|
116
|
+
}
|