@orion-agents/orion-code 0.3.25 → 0.3.27

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/CHANGELOG.md CHANGED
@@ -22,15 +22,80 @@ which is **not** a pass.
22
22
 
23
23
  ## [Unreleased]
24
24
 
25
- ## [0.3.25] — UNRELEASED
26
-
27
- > **Status: candidate.** Open. Four open-issue fixes: the Git conflict view reads the
28
- > edited working file from the filesystem instead of an unstored object (#269), file
29
- > history walks the requested revision instead of always HEAD (#270), model switching
30
- > gates the compact preflight on effective input budgets instead of raw context windows
31
- > (#271), and the left project navigation keeps a stable registration order when
32
- > sessions are activated (#272). Plan: `docs/plan/v0.3.25-plan.md`. Not merged, tagged
33
- > or published.
25
+ ## [0.3.27] — UNRELEASED
26
+
27
+ > **Status: candidate.** Open. First slice of the professional code review loop
28
+ > (plan: `docs/plan/v0.3.27-plan.md`): the shared review contract (selectors,
29
+ > states, conclusions, findings, tighten-only budgets, receipt digests,
30
+ > stale-applicability) is frozen in `src/services/code-review` and bound by
31
+ > contract tests; the shared Git snapshot reader captures worktree (staged /
32
+ > unstaged / untracked, separate sources) and base (frozen merge-base..HEAD
33
+ > OIDs, rename tracking) scopes with typed scope errors; and the read-only
34
+ > workflow constraints deny every non-read tool by default with a dispatch-level
35
+ > guard whose digest binds receipts. Runtime / CLI wiring (PR2), the Web loop
36
+ > (PR3) and the qualification benchmark (PR4) are subsequent slices of the same
37
+ > plan and are not part of this release. Not merged, tagged or published.
38
+
39
+ ### Added
40
+
41
+ - #277-plan PR0: `src/services/code-review/contract.ts` — the shared review
42
+ contract with the plan §4.1 conclusion mapping (a partial, failed, cancelled
43
+ or untrustworthy review can never surface as a green "no findings"),
44
+ tighten-only budgets from plan §4.3, finding validation, receipt digests
45
+ verified by recomputation, and stale-applicability annotation that never
46
+ rewrites history. Twelve contract tests pin the semantics.
47
+ - PR0: the human-annotation review-quality benchmark set (12 defect + 8 clean
48
+ samples across TypeScript/JavaScript/Python with content digests, expected
49
+ triggers, allowed locations and frozen scoring thresholds), awaiting
50
+ per-sample human sign-off before any paid model run (plan §9.3).
51
+ - PR1: `src/services/code-review/snapshot.ts` — the shared Git snapshot reader:
52
+ worktree scope records staged (index OIDs), unstaged (working content with
53
+ before/after digest re-checks) and untracked changes as separate sources;
54
+ base scope freezes ref/HEAD/merge-base into immutable OIDs with rename
55
+ tracking and typed `ref_unresolved` / `no_merge_base` errors; sensitive and
56
+ binary entries are skipped without being read; tightened budgets skip the
57
+ excess with typed reasons; the contained worktree reader refuses to leave the
58
+ repository root.
59
+ - PR1: `src/services/code-review/constraints.ts` — deny-by-default read-only
60
+ workflow constraints (only `read_file`, `list_files`, `glob`, `grep` pass the
61
+ dispatch-level guard) with a frozen digest that receipts bind.
62
+
63
+ ## [0.3.26] — 2026-10-17
64
+
65
+ > **Status: published.** Released as `@orion-agents/orion-code@0.3.26` from
66
+ > `refs/tags/v0.3.26`, and merged to `main` as `b810996` (#278). Structured-diff
67
+ > integrity and Session lifecycle: header-lookalike body rows stay body rows
68
+ > (#274), hunks split across pagination keep their rows, line numbers and
69
+ > identity (#275), permanent Session deletion removes the v2 Thread records
70
+ > (#276), and exiting a cutover Session no longer rewrites its summary from the
71
+ > frozen legacy JSONL (#277). Plan: `docs/plan/v0.3.26-plan.md`. GitHub Release:
72
+ > https://github.com/orion-agents/orion-code/releases/tag/v0.3.26
73
+
74
+ ### Fixed
75
+
76
+ - #274: a deletion row whose text starts with `-- ` (`--- old comment`) is no longer
77
+ mistaken for the old-file header; the hunk stays open and the remaining body is
78
+ no longer demoted to document metadata.
79
+ - #275: the structured diff continuation contract carries the split hunk's state
80
+ (header, index, running line cursors) in the cursor, so every page of a large
81
+ hunk keeps its rows with correct line numbers and the stable hunk identity, and
82
+ the last page reports the true completeness.
83
+ - #276: permanently deleting a cutover Session removes its v2 records — cutover
84
+ index entry, event log, head, projection, compact state and checkpoints,
85
+ session-index manifest, transcript pages and import receipt — under the same
86
+ file-lock and atomic-write discipline as the cutover itself.
87
+ - #277: `/exit` (and the shutdown path) no longer rewrites a cutover Session's
88
+ `messageCount`/`historySizeBytes` from the frozen legacy JSONL; the summary comes
89
+ from the authoritative v2 Thread.
90
+
91
+ ## [0.3.25] — 2026-10-13
92
+
93
+ > **Status: published.** Released as `@orion-agents/orion-code@0.3.25` from
94
+ > `refs/tags/v0.3.25`, and merged to `main` as `c356323` (#273). Four open-issue fixes
95
+ > for the Git conflict view (#269), file-history revisions (#270), the model-switch
96
+ > compact preflight (#271) and the stable project navigation order (#272). Plan:
97
+ > `docs/plan/v0.3.25-plan.md`. GitHub Release:
98
+ > https://github.com/orion-agents/orion-code/releases/tag/v0.3.25
34
99
 
35
100
  ### Fixed
36
101
 
package/README.md CHANGED
@@ -2,12 +2,14 @@
2
2
 
3
3
  Local-first, goal-driven coding agent for the terminal and browser.
4
4
 
5
- > v0.3.25 candidate — open. Four open-issue fixes: the Git conflict view reads the edited
6
- > working file from the filesystem (#269), file history walks the requested revision
7
- > (#270), model switching gates the compact preflight on effective input budgets (#271),
8
- > and the left project navigation keeps a stable registration order (#272). The previous
9
- > release 0.3.24 is on npm (registry `latest`), tagged `v0.3.24` (`85fadb4`, #268) and
10
- > released on GitHub.
5
+ > v0.3.27 candidate — open. First slice of the professional code review loop: the
6
+ > shared review contract (selectors, states, conclusions, findings, tighten-only
7
+ > budgets, receipt digests, stale-applicability) is frozen and contract-tested,
8
+ > the shared Git snapshot reader captures worktree and frozen-base scopes with
9
+ > typed errors, and the read-only workflow constraints deny every non-read tool
10
+ > by default. Runtime/CLI wiring, the Web loop and the qualification benchmark
11
+ > are subsequent slices of the same plan. The previous release 0.3.26 is on npm
12
+ > (registry `latest`), tagged `v0.3.26` (`b810996`, #278) and released on GitHub.
11
13
 
12
14
  [中文说明](README.zh-CN.md) ·
13
15
  [v0.3.24 plan](docs/plan/v0.3.24-plan.md) ·
@@ -170,10 +172,10 @@ user extension boundaries.
170
172
  Node.js 22.12+, 24, and 26 are supported. Use Node 24 LTS for production or Node 26 Current for
171
173
  current development environments. Node 20 is upstream EOL and is no longer a v0.3 runtime.
172
174
 
173
- To install the pinned v0.3.25 package when it is available on npm:
175
+ To install the pinned v0.3.27 package when it is available on npm:
174
176
 
175
177
  ```bash
176
- npm install -g @orion-agents/orion-code@0.3.25
178
+ npm install -g @orion-agents/orion-code@0.3.27
177
179
  orion --version
178
180
  orion doctor
179
181
  ```
package/README.zh-CN.md CHANGED
@@ -2,10 +2,11 @@
2
2
 
3
3
  面向终端与浏览器、本地优先的目标驱动 Coding Agent。
4
4
 
5
- > v0.3.25 候选版本:进行中。四个开放 issue 修复:Git 冲突视图从文件系统读取已编辑的
6
- > 工作区文件(#269)、文件历史按请求的 revision 遍历(#270)、模型切换按有效输入预算
7
- > 触发压缩预检(#271)、左侧项目导航保持稳定注册序(#272)。上一版 0.3.24 已发布 npm
8
- > (registry `latest`)、打 tag `v0.3.24`(`85fadb4`,#268)并发布 GitHub Release。
5
+ > v0.3.27 候选版本:进行中。专业代码审查闭环首切片:共享审查契约(selector、状态、结论、
6
+ > finding、只收紧预算、receipt digest、stale 标注)已冻结并通过契约测试;共享 Git snapshot
7
+ > reader 捕获 worktree 与冻结 base 两种范围并给出类型化错误;只读 workflow 约束默认拒绝一切
8
+ > 非读取工具。Runtime/CLI 接线、Web 闭环与资格验证为同一计划的后续切片。上一版 0.3.26 已发布
9
+ > npm(registry `latest`)、打 tag `v0.3.26`(`b810996`,#278)并发布 GitHub Release。
9
10
 
10
11
  [English](README.md) ·
11
12
  [v0.3.24 方案](docs/plan/v0.3.24-plan.md) ·
@@ -100,10 +101,10 @@ MCP 仍是用户可见的扩展边界。
100
101
  支持 Node.js 22.12+、24 和 26。生产环境建议使用 Node 24 LTS,当前开发环境也支持 Node 26
101
102
  Current。Node 20 已结束上游维护,不再属于 v0.3 Runtime 合同。
102
103
 
103
- v0.3.25 在 npm 可用后,可安装固定版本:
104
+ v0.3.27 在 npm 可用后,可安装固定版本:
104
105
 
105
106
  ```bash
106
- npm install -g @orion-agents/orion-code@0.3.25
107
+ npm install -g @orion-agents/orion-code@0.3.27
107
108
  orion --version
108
109
  orion doctor
109
110
  ```
@@ -102,4 +102,17 @@ export declare function openSessionCheckpointStorageV1(projectPathInput: string,
102
102
  */
103
103
  export declare function openSessionStorageV1(projectPathInput: string, sessionId: string): OpenedSessionStorageV1;
104
104
  export declare function loadThreadCutoverIndexV1(projectPath: string): ThreadCutoverIndexV1;
105
+ /**
106
+ * v0.3.26 #276 — permanently removes one Session's durable v2 records: the
107
+ * cutover index entry plus every thread file the materializer and the event
108
+ * store publish (event log, projection, head, compact state and checkpoints,
109
+ * session-index manifest, transcript pages, import receipt). Returns the
110
+ * removed thread id, or null when the Session was never cut over.
111
+ *
112
+ * The index write takes the same file lock and atomic-write discipline as the
113
+ * cutover itself, with the generation bumped; an emptied index keeps its file
114
+ * with an empty session map so readers stay on the atomic authority instead of
115
+ * treating a missing file as "no v2 Sessions at all".
116
+ */
117
+ export declare function deleteSessionThreadRecordsV1(projectPathInput: string, sessionId: string): string | null;
105
118
  //# sourceMappingURL=legacy-thread-materializer.d.ts.map
@@ -7,6 +7,7 @@ exports.resolveSessionStorageV1 = resolveSessionStorageV1;
7
7
  exports.openSessionCheckpointStorageV1 = openSessionCheckpointStorageV1;
8
8
  exports.openSessionStorageV1 = openSessionStorageV1;
9
9
  exports.loadThreadCutoverIndexV1 = loadThreadCutoverIndexV1;
10
+ exports.deleteSessionThreadRecordsV1 = deleteSessionThreadRecordsV1;
10
11
  const fs_1 = require("fs");
11
12
  const path_1 = require("path");
12
13
  const atomic_write_1 = require("../services/atomic-write");
@@ -205,6 +206,77 @@ function openSessionStorageV1(projectPathInput, sessionId) {
205
206
  function loadThreadCutoverIndexV1(projectPath) {
206
207
  return readThreadCutoverIndex((0, paths_1.getProjectThreadsV2IndexPath)((0, path_1.resolve)(projectPath)));
207
208
  }
209
+ /**
210
+ * v0.3.26 #276 — permanently removes one Session's durable v2 records: the
211
+ * cutover index entry plus every thread file the materializer and the event
212
+ * store publish (event log, projection, head, compact state and checkpoints,
213
+ * session-index manifest, transcript pages, import receipt). Returns the
214
+ * removed thread id, or null when the Session was never cut over.
215
+ *
216
+ * The index write takes the same file lock and atomic-write discipline as the
217
+ * cutover itself, with the generation bumped; an emptied index keeps its file
218
+ * with an empty session map so readers stay on the atomic authority instead of
219
+ * treating a missing file as "no v2 Sessions at all".
220
+ */
221
+ function deleteSessionThreadRecordsV1(projectPathInput, sessionId) {
222
+ const projectPath = (0, path_1.resolve)(projectPathInput);
223
+ const indexPath = (0, paths_1.getProjectThreadsV2IndexPath)(projectPath);
224
+ // A project that never cut a Session over has no index and no threads-v2
225
+ // directory; taking the lock would create one on a pure legacy deletion.
226
+ if (!(0, fs_1.existsSync)(indexPath))
227
+ return null;
228
+ const threadsDir = (0, paths_1.getProjectThreadsV2Dir)(projectPath);
229
+ return (0, file_lock_1.withFileLockSync)(indexPath, () => {
230
+ const current = readThreadCutoverIndex(indexPath);
231
+ const entry = current.sessions[sessionId];
232
+ if (!entry)
233
+ return null;
234
+ const sessions = { ...current.sessions };
235
+ delete sessions[sessionId];
236
+ const content = { version: 1, generation: current.generation + 1, sessions };
237
+ const next = deepFreeze({ ...content, digest: (0, canonical_1.digestRuntimeValue)(content) });
238
+ (0, atomic_write_1.atomicWriteFileSync)(indexPath, `${(0, canonical_1.canonicalRuntimeJson)(next)}\n`, {
239
+ mode: 0o600,
240
+ fsync: true,
241
+ });
242
+ removeThreadFiles(threadsDir, projectPath, entry.threadId);
243
+ return entry.threadId;
244
+ });
245
+ }
246
+ /** v0.3.26 #276 — removes every durable file of one thread. Best effort per
247
+ * file: a missing artifact is already deleted, and an unlink failure must not
248
+ * resurrect the cutover entry that was just removed. */
249
+ function removeThreadFiles(threadsDir, projectPath, threadId) {
250
+ const files = [
251
+ (0, path_1.join)(threadsDir, `${threadId}.events.v1.jsonl`),
252
+ (0, path_1.join)(threadsDir, `${threadId}.projection.v1.json`),
253
+ (0, path_1.join)(threadsDir, `${threadId}.head.v1.json`),
254
+ (0, path_1.join)(threadsDir, `${threadId}.compact-state.v1.json`),
255
+ (0, path_1.join)(threadsDir, `${threadId}.session-index.v1.json`),
256
+ (0, paths_1.getProjectThreadV2ImportReceiptPath)(projectPath, threadId),
257
+ ];
258
+ for (const file of files) {
259
+ try {
260
+ if ((0, fs_1.existsSync)(file))
261
+ (0, fs_1.unlinkSync)(file);
262
+ }
263
+ catch {
264
+ // Durable leftovers are reported by the integrity checks, never by
265
+ // throwing here: the cutover entry removal is already committed.
266
+ }
267
+ }
268
+ for (const dir of [
269
+ (0, path_1.join)(threadsDir, `${threadId}.compact-checkpoints.v1`),
270
+ (0, path_1.join)(threadsDir, `${threadId}.transcript-pages.v1`),
271
+ ]) {
272
+ try {
273
+ (0, fs_1.rmSync)(dir, { recursive: true, force: true });
274
+ }
275
+ catch {
276
+ // See above.
277
+ }
278
+ }
279
+ }
208
280
  function buildMaterializedEvents(snapshot) {
209
281
  const receipt = snapshot.receipt;
210
282
  const pending = [
@@ -0,0 +1,25 @@
1
+ /** Read-only tools the review turn may use. Only first-party core tools with
2
+ * `readOnly: true` in their descriptors qualify (plan §5.1); `edit_file`,
3
+ * `exec_command` and `write_file` are structurally excluded. */
4
+ export declare const REVIEW_ALLOWED_TOOLS: ReadonlySet<string>;
5
+ export interface ReviewWorkflowConstraintsV1 {
6
+ readonly schemaVersion: 1;
7
+ readonly workflow: 'code-review';
8
+ readonly allowedTools: readonly string[];
9
+ readonly constraintsDigest: string;
10
+ readonly policy: string;
11
+ }
12
+ /** The frozen constraint set with its digest. Receipts and capability
13
+ * compilations bind this digest so a policy change invalidates old reviews'
14
+ * rules provenance alongside the rules digest. */
15
+ export declare const REVIEW_WORKFLOW_CONSTRAINTS: ReviewWorkflowConstraintsV1;
16
+ export declare class ReviewToolPolicyError extends Error {
17
+ readonly code: 'review_tool_denied';
18
+ readonly toolName: string;
19
+ constructor(message: string, code: 'review_tool_denied', toolName: string);
20
+ }
21
+ /** Dispatch-level re-validation. Called on every tool invocation of a review
22
+ * turn — direct calls, batch calls, aliases and steering all funnel through
23
+ * here before the gateway executes anything. */
24
+ export declare function assertReviewToolAllowed(toolName: string): void;
25
+ //# sourceMappingURL=constraints.d.ts.map
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReviewToolPolicyError = exports.REVIEW_WORKFLOW_CONSTRAINTS = exports.REVIEW_ALLOWED_TOOLS = void 0;
4
+ exports.assertReviewToolAllowed = assertReviewToolAllowed;
5
+ /**
6
+ * v0.3.27 PR1 — read-only workflow constraints for code review (plan §5.1).
7
+ *
8
+ * The review turn runs through the normal AgentLoop / ToolGateway, but under
9
+ * immutable workflow constraints: the model only sees bounded read/list/glob/
10
+ * grep capabilities, and every dispatch re-validates against this module so
11
+ * aliases, batch calls, steering or permission escalation (AUTO / ALLOW) can
12
+ * never widen the turn. The constraint set is deny-by-default: a tool that is
13
+ * not explicitly allowlisted is rejected, which covers long-tail tools, MCP,
14
+ * network, task derivation and future additions without maintaining a denylist.
15
+ *
16
+ * PR2 wires this guard into the review workflow's dispatch; PR1 ships the
17
+ * frozen model, its digest, and the negative tests.
18
+ */
19
+ const canonical_1 = require("../../runtime/protocol/canonical");
20
+ /** Read-only tools the review turn may use. Only first-party core tools with
21
+ * `readOnly: true` in their descriptors qualify (plan §5.1); `edit_file`,
22
+ * `exec_command` and `write_file` are structurally excluded. */
23
+ exports.REVIEW_ALLOWED_TOOLS = new Set([
24
+ 'read_file',
25
+ 'list_files',
26
+ 'glob',
27
+ 'grep',
28
+ ]);
29
+ const REVIEW_CONSTRAINT_CONTENT = Object.freeze({
30
+ schemaVersion: 1,
31
+ workflow: 'code-review',
32
+ mode: 'read-only',
33
+ allowedTools: [...exports.REVIEW_ALLOWED_TOOLS].sort(),
34
+ deniedByDefault: Object.freeze([
35
+ 'exec_command',
36
+ 'write_file',
37
+ 'edit_file',
38
+ 'git mutations',
39
+ 'mcp',
40
+ 'network tools',
41
+ 'dynamic skills',
42
+ 'task derivation',
43
+ 'settings mutation',
44
+ ]),
45
+ /** Rationale text is part of the digest: changing the policy changes every
46
+ * receipt that binds it. */
47
+ policy: 'The review turn may only inspect the frozen snapshot through the ' +
48
+ 'allowlisted read tools. Permission escalation (AUTO / ALLOW) may tighten ' +
49
+ 'or maintain but never widen this set. Test commands are not run: they ' +
50
+ 'can write caches and mutate the workspace under review.',
51
+ });
52
+ /** The frozen constraint set with its digest. Receipts and capability
53
+ * compilations bind this digest so a policy change invalidates old reviews'
54
+ * rules provenance alongside the rules digest. */
55
+ exports.REVIEW_WORKFLOW_CONSTRAINTS = Object.freeze({
56
+ schemaVersion: 1,
57
+ workflow: 'code-review',
58
+ allowedTools: REVIEW_CONSTRAINT_CONTENT.allowedTools,
59
+ constraintsDigest: (0, canonical_1.digestRuntimeValue)(REVIEW_CONSTRAINT_CONTENT),
60
+ policy: REVIEW_CONSTRAINT_CONTENT.policy,
61
+ });
62
+ class ReviewToolPolicyError extends Error {
63
+ constructor(message, code, toolName) {
64
+ super(message);
65
+ this.code = code;
66
+ this.toolName = toolName;
67
+ this.name = 'ReviewToolPolicyError';
68
+ }
69
+ }
70
+ exports.ReviewToolPolicyError = ReviewToolPolicyError;
71
+ /** Dispatch-level re-validation. Called on every tool invocation of a review
72
+ * turn — direct calls, batch calls, aliases and steering all funnel through
73
+ * here before the gateway executes anything. */
74
+ function assertReviewToolAllowed(toolName) {
75
+ if (!exports.REVIEW_ALLOWED_TOOLS.has(toolName)) {
76
+ throw new ReviewToolPolicyError(`Tool "${toolName}" is not available in a read-only code review turn.`, 'review_tool_denied', toolName);
77
+ }
78
+ }
79
+ //# sourceMappingURL=constraints.js.map
@@ -0,0 +1,172 @@
1
+ /** v0.3.27 §3.1 — what a review examines. Parsed once, frozen at admission. */
2
+ export type ReviewSelectorV1 = {
3
+ readonly kind: 'worktree';
4
+ readonly paths?: readonly string[];
5
+ } | {
6
+ readonly kind: 'base';
7
+ readonly ref: string;
8
+ readonly paths?: readonly string[];
9
+ };
10
+ /** v0.3.27 §4.1 — run states. `queued`/`running` never carry a conclusion. */
11
+ export type ReviewRunStateV1 = 'queued' | 'running' | 'completed' | 'partial' | 'failed' | 'cancelled';
12
+ /** v0.3.27 §4.1 — terminal conclusions. Absence can only be asserted when the
13
+ * state is `completed`, coverage is complete and the output contained no
14
+ * invalid findings; everything else maps to findings or inconclusive. */
15
+ export type ReviewConclusionV1 = 'findings' | 'no_findings' | 'inconclusive';
16
+ /** v0.3.27 §6.1 — a stored result's applicability after code or rules change.
17
+ * History is never rewritten; staleness is an annotation, not an edit. */
18
+ export type ReviewApplicabilityV1 = 'current' | 'stale';
19
+ /** Priority levels. P0 requires evidence that the defect blocks usage without
20
+ * special preconditions; the definition is frozen here and in PR0 tests. */
21
+ export type ReviewFindingPriorityV1 = 'P0' | 'P1' | 'P2' | 'P3';
22
+ /** v0.3.27 §4.1 — one review finding. `fileKey` is validated for shape here;
23
+ * membership against the frozen snapshot manifest happens at Host validation
24
+ * time (PR1+), never in the model's favor. */
25
+ export interface ReviewFindingV1 {
26
+ readonly findingId: string;
27
+ readonly priority: ReviewFindingPriorityV1;
28
+ readonly title: string;
29
+ /** The condition under which the defect manifests — not a style opinion. */
30
+ readonly trigger: string;
31
+ readonly impact: string;
32
+ readonly fileKey: string;
33
+ readonly side: 'old' | 'new';
34
+ readonly startLine: number;
35
+ readonly endLine: number;
36
+ readonly evidence: string;
37
+ }
38
+ /** Coverage is evidence, not a count: what was actually inspected, what was
39
+ * skipped and why, and where truncation or budget exhaustion occurred. */
40
+ export interface ReviewCoverageV1 {
41
+ readonly inspectedFiles: readonly string[];
42
+ readonly inspectedRanges: readonly {
43
+ readonly fileKey: string;
44
+ readonly startLine: number;
45
+ readonly endLine: number;
46
+ }[];
47
+ readonly skipped: readonly {
48
+ readonly fileKey: string;
49
+ readonly reason: 'over_budget_files' | 'over_budget_bytes' | 'binary' | 'sensitive' | 'unreadable' | 'changed_during_review' | 'other';
50
+ readonly detail?: string;
51
+ }[];
52
+ readonly truncated: boolean;
53
+ readonly budgetExhausted: readonly string[];
54
+ }
55
+ /** Whether the declared coverage is internally consistent and complete for the
56
+ * resolved selector — computed by the Host from the frozen manifest, never
57
+ * taken from the model's self-report (§4.1). */
58
+ export interface ReviewCoverageAssertionV1 {
59
+ readonly complete: boolean;
60
+ readonly reason?: string;
61
+ }
62
+ /** v0.3.27 §4.1 — the persisted receipt. `receiptDigest` covers the canonical
63
+ * form of everything above it and is recomputed on read. */
64
+ export interface CodeReviewResultV1 {
65
+ readonly schemaVersion: 1;
66
+ readonly reviewId: string;
67
+ readonly workspaceIdentity: string;
68
+ readonly sessionId: string;
69
+ readonly threadId: string;
70
+ readonly turnId: string;
71
+ readonly requestedSelector: ReviewSelectorV1;
72
+ /** The actually resolved target (commit OIDs, snapshot ids), not the request. */
73
+ readonly resolvedTarget: {
74
+ readonly kind: 'worktree' | 'base';
75
+ readonly baseOid?: string;
76
+ readonly headOid?: string;
77
+ readonly snapshotId: string;
78
+ };
79
+ /** Digest of the frozen input snapshot; a stored result is stale when this
80
+ * no longer matches the current snapshot digest for the same selector. */
81
+ readonly inputSnapshotDigest: string;
82
+ readonly rulesDigest: string;
83
+ readonly state: ReviewRunStateV1;
84
+ readonly conclusion: ReviewConclusionV1;
85
+ readonly findings: readonly ReviewFindingV1[];
86
+ /** Findings that failed validation — counted and surfaced, never silently
87
+ * dropped (dropping them must not turn the run into no_findings). */
88
+ readonly invalidFindingCount: number;
89
+ readonly coverage: ReviewCoverageV1;
90
+ readonly coverageAssertion: ReviewCoverageAssertionV1;
91
+ readonly limits: readonly string[];
92
+ readonly model: {
93
+ readonly provider: string;
94
+ readonly model: string;
95
+ };
96
+ readonly usage: {
97
+ readonly inputTokens: number;
98
+ readonly outputTokens: number;
99
+ };
100
+ readonly startedAt: number;
101
+ readonly endedAt: number;
102
+ readonly receiptDigest: string;
103
+ }
104
+ /** Budgets are ceilings that may only be tightened (§4.3): a provider with a
105
+ * smaller window takes the stricter value; nothing may widen them at runtime. */
106
+ export interface ReviewBudgetsV1 {
107
+ readonly maxFiles: number;
108
+ readonly maxBodyBytes: number;
109
+ readonly maxDiffBytes: number;
110
+ readonly maxReadToolCalls: number;
111
+ readonly maxDurationMs: number;
112
+ readonly maxFindings: number;
113
+ readonly maxResultBytes: number;
114
+ }
115
+ export declare const DEFAULT_REVIEW_BUDGETS: ReviewBudgetsV1;
116
+ /** Text size caps for finding fields, in characters. Chosen so 100 maximal
117
+ * findings stay well inside the 256 KiB result bound. */
118
+ export declare const FINDING_TEXT_LIMITS: Readonly<{
119
+ title: 200;
120
+ trigger: 2000;
121
+ impact: 2000;
122
+ evidence: 4000;
123
+ fileKey: 1024;
124
+ }>;
125
+ /** Validates one model-produced finding against the frozen shape. Returns the
126
+ * finding unchanged when valid; a typed reason when not. Membership against
127
+ * the snapshot manifest is a separate Host check (PR1+). */
128
+ export declare function validateReviewFinding(value: unknown): {
129
+ readonly valid: true;
130
+ readonly finding: ReviewFindingV1;
131
+ } | {
132
+ readonly valid: false;
133
+ readonly reason: 'not_an_object' | 'finding_id_invalid' | 'priority_invalid' | 'title_invalid' | 'trigger_invalid' | 'impact_invalid' | 'file_key_invalid' | 'side_invalid' | 'line_range_invalid' | 'evidence_invalid';
134
+ };
135
+ /**
136
+ * v0.3.27 §4.1 — the conclusion mapping, frozen as code so CLI and Web cannot
137
+ * diverge. The invariants:
138
+ * - `queued`/`running` results carry no conclusion (callers must not call this).
139
+ * - A state that is not `completed` can never conclude `no_findings`.
140
+ * - Invalid findings make the output untrustworthy: zero valid findings with
141
+ * invalid ones present is `inconclusive`, never a green pass.
142
+ * - Zero findings without complete coverage is `inconclusive`, never a green
143
+ * pass ("不静默截断后宣布全部完成").
144
+ */
145
+ export declare function resolveReviewConclusion(input: {
146
+ readonly state: ReviewRunStateV1;
147
+ readonly validFindingCount: number;
148
+ readonly invalidFindingCount: number;
149
+ readonly coverageComplete: boolean;
150
+ }): ReviewConclusionV1;
151
+ /** Applies the budgets with the tighten-only rule: every override must be a
152
+ * safe integer at or below the frozen default, otherwise the run is refused
153
+ * rather than silently widened. */
154
+ export declare function resolveReviewBudgets(overrides?: Partial<ReviewBudgetsV1>): {
155
+ readonly ok: true;
156
+ readonly budgets: ReviewBudgetsV1;
157
+ } | {
158
+ readonly ok: false;
159
+ readonly field: string;
160
+ };
161
+ /** Marks a stored result's applicability against the current input snapshot and
162
+ * rules digests. The receipt itself is never rewritten. */
163
+ export declare function reviewApplicability(result: Pick<CodeReviewResultV1, 'inputSnapshotDigest' | 'rulesDigest'>, current: {
164
+ readonly inputSnapshotDigest: string;
165
+ readonly rulesDigest: string;
166
+ }): ReviewApplicabilityV1;
167
+ /** The receipt digest covers the canonical form of the result with the digest
168
+ * field itself excluded, so verification is a recomputation, not a lookup. */
169
+ export declare function computeReceiptDigest(result: Omit<CodeReviewResultV1, 'receiptDigest'>): string;
170
+ /** Verifies a stored receipt by recomputing its digest. */
171
+ export declare function verifyReceiptDigest(result: CodeReviewResultV1): boolean;
172
+ //# sourceMappingURL=contract.d.ts.map