opencode-swarm 7.132.2 → 7.134.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +4 -1
  2. package/dist/agents/agent-output-schema.d.ts +74 -0
  3. package/dist/agents/critic.d.ts +2 -1
  4. package/dist/agents/reviewer.d.ts +1 -1
  5. package/dist/background/completion-observer.d.ts +17 -5
  6. package/dist/background/pending-delegations.d.ts +315 -2
  7. package/dist/background/stage-b-gates.d.ts +2 -0
  8. package/dist/cli/{config-doctor-bp5spb79.js → config-doctor-t5r92674.js} +3 -3
  9. package/dist/cli/{core-wg3re04e.js → core-d6yd2jzv.js} +2 -2
  10. package/dist/cli/{curation-policy-7zp2m9gv.js → curation-policy-3smfn2a3.js} +7 -7
  11. package/dist/cli/{curator-drift-y1wm4atk.js → curator-drift-tsyyf4b4.js} +4 -4
  12. package/dist/cli/{curator-h067mrcc.js → curator-hva8f3nf.js} +31 -29
  13. package/dist/cli/{curator-llm-factory-605d08hf.js → curator-llm-factory-p3aqev12.js} +31 -29
  14. package/dist/cli/{dispatch-3mhgqj2x.js → dispatch-gxbeb2ps.js} +2 -2
  15. package/dist/cli/{evidence-summary-service-jfagmvrh.js → evidence-summary-service-mrzsjpg4.js} +12 -11
  16. package/dist/cli/{gate-evidence-cy2te3x8.js → gate-evidence-b5v1xvxp.js} +4 -4
  17. package/dist/cli/guardrail-explain-k8mcvk61.js +57 -0
  18. package/dist/cli/{guardrail-log-aa112fxv.js → guardrail-log-absma1rv.js} +5 -5
  19. package/dist/cli/{hive-promoter-nv0m5rzk.js → hive-promoter-jwd51gzk.js} +31 -29
  20. package/dist/cli/{index-g4mnf3p5.js → index-1j3682j8.js} +5 -5
  21. package/dist/cli/{index-6ccynjv3.js → index-2njes601.js} +8 -8
  22. package/dist/cli/{index-w9cb5zwh.js → index-2t1n9k7b.js} +4 -4
  23. package/dist/cli/{index-f6480ee6.js → index-3dtjhr26.js} +5259 -1759
  24. package/dist/cli/{index-2tn5h2zp.js → index-4p02dp92.js} +6 -6
  25. package/dist/cli/index-b4z7s917.js +80 -0
  26. package/dist/cli/{index-bvp2v7k1.js → index-b5ek2cge.js} +266 -19
  27. package/dist/cli/index-b8zgtz81.js +123 -0
  28. package/dist/cli/{index-3s9rfnqq.js → index-baawkm48.js} +12 -12
  29. package/dist/cli/{index-fgcmxjp7.js → index-c3e0ymrg.js} +1 -1
  30. package/dist/cli/{index-q27bajqb.js → index-cfkvc5q9.js} +3 -3
  31. package/dist/cli/{index-7mkpsw6g.js → index-dd7ttx8x.js} +1 -1
  32. package/dist/cli/{index-jgfcp9bh.js → index-dgxgvzab.js} +7 -7
  33. package/dist/cli/{index-8d3m0ge3.js → index-eedq2y40.js} +48 -34
  34. package/dist/cli/{index-630badhp.js → index-g87ty4wp.js} +149 -6
  35. package/dist/cli/{index-yvv1wt2h.js → index-hgh01f6h.js} +25 -3
  36. package/dist/cli/{index-9cf1yr67.js → index-j6ywarjp.js} +3 -3
  37. package/dist/cli/{index-mwkwyej1.js → index-jpkxjmfw.js} +5 -5
  38. package/dist/cli/{index-03zyn94g.js → index-k742ecbm.js} +178 -222
  39. package/dist/cli/{index-y5qp59rc.js → index-kapharv7.js} +10 -4
  40. package/dist/cli/{index-djwemsjn.js → index-m2s0gbzt.js} +2 -2
  41. package/dist/cli/{index-4ff0x4cg.js → index-p8hezdtz.js} +1 -1
  42. package/dist/cli/{index-k4tmx21m.js → index-rkyhv4p5.js} +2 -2
  43. package/dist/cli/{index-3x761jqv.js → index-wk1h5ec2.js} +1 -1
  44. package/dist/cli/{index-jj4earrh.js → index-xfejq1p9.js} +1 -1
  45. package/dist/cli/{index-rt5jgktq.js → index-y0kk3rtv.js} +2 -2
  46. package/dist/cli/index-y3v1404y.js +1625 -0
  47. package/dist/cli/index.js +35 -31
  48. package/dist/cli/{knowledge-escalator-j0nceas7.js → knowledge-escalator-mkdac2m7.js} +8 -8
  49. package/dist/cli/{knowledge-events-gpqc62jr.js → knowledge-events-jjc9qbe0.js} +6 -6
  50. package/dist/cli/{knowledge-link-4yd2z8ev.js → knowledge-link-nc4y2zkq.js} +5 -5
  51. package/dist/cli/{knowledge-store-ggxr3ww5.js → knowledge-store-9e0w1kxm.js} +6 -6
  52. package/dist/cli/{knowledge-validator-007smap6.js → knowledge-validator-h1nrn2pk.js} +9 -9
  53. package/dist/cli/pending-delegations-v9e40hfk.js +96 -0
  54. package/dist/cli/{pr-subscriptions-zqbmctwz.js → pr-subscriptions-ztq40hrt.js} +7 -7
  55. package/dist/cli/{scan-cursor-wz4bff7a.js → scan-cursor-mk3tq3sf.js} +7 -7
  56. package/dist/cli/{schema-023gwne7.js → schema-bjb0yzsq.js} +7 -3
  57. package/dist/cli/{scope-persistence-dm5bab50.js → scope-persistence-hz3zmmsv.js} +5 -5
  58. package/dist/cli/{skill-generator-rtsg1m7x.js → skill-generator-p1de0wkr.js} +10 -10
  59. package/dist/cli/worktree-collision-ownership-c4bdnjtx.js +221 -0
  60. package/dist/commands/command-dispatch.d.ts +7 -0
  61. package/dist/commands/index.d.ts +7 -0
  62. package/dist/commands/registry.d.ts +16 -0
  63. package/dist/commands/review.d.ts +21 -0
  64. package/dist/config/agent-names.d.ts +3 -3
  65. package/dist/config/evidence-schema.d.ts +47 -47
  66. package/dist/config/index.d.ts +2 -2
  67. package/dist/config/schema.d.ts +58 -6
  68. package/dist/consensus/contracts.d.ts +3 -3
  69. package/dist/evaluation/ephemeral-agent-dispatcher.d.ts +64 -0
  70. package/dist/evaluation/model-dispatcher.d.ts +11 -5
  71. package/dist/hooks/auto-review.d.ts +30 -65
  72. package/dist/hooks/delegation-gate/worktree-collision-ownership.d.ts +28 -0
  73. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +63 -1
  74. package/dist/hooks/delegation-gate/worktree-merge-status.d.ts +14 -0
  75. package/dist/hooks/delegation-gate/worktree-ownership-tag.d.ts +19 -0
  76. package/dist/hooks/delegation-gate/worktree-provisioning-owner.d.ts +30 -0
  77. package/dist/hooks/delegation-gate.d.ts +15 -6
  78. package/dist/hooks/guardrails/tool-before.d.ts +8 -0
  79. package/dist/hooks/index.d.ts +1 -1
  80. package/dist/hooks/init-orphan-recovery.d.ts +17 -0
  81. package/dist/hooks/review-receipt-collector.d.ts +53 -10
  82. package/dist/hooks/review-receipt-scope.d.ts +74 -0
  83. package/dist/hooks/review-receipt.d.ts +104 -10
  84. package/dist/hooks/reviewer-scope-file-fingerprint.d.ts +21 -0
  85. package/dist/hooks/reviewer-scope-lifecycle.d.ts +19 -0
  86. package/dist/hooks/task-result-classifier.d.ts +6 -0
  87. package/dist/index.d.ts +2 -0
  88. package/dist/index.js +583 -524
  89. package/dist/memory/schema.d.ts +1 -1
  90. package/dist/review/contracts.d.ts +29 -0
  91. package/dist/review/diff-source.d.ts +134 -0
  92. package/dist/review/engine.d.ts +60 -0
  93. package/dist/review/evidence.d.ts +88 -0
  94. package/dist/review/finding-validator.d.ts +77 -0
  95. package/dist/review/phase-runner.d.ts +37 -0
  96. package/dist/review/runtime.d.ts +32 -0
  97. package/dist/scope/scope-binding.d.ts +9 -0
  98. package/dist/services/config-doctor.d.ts +12 -0
  99. package/dist/session/snapshot-writer.d.ts +2 -0
  100. package/dist/state.d.ts +222 -1
  101. package/dist/tools/dispatch-lanes.d.ts +3 -1
  102. package/dist/tools/epic-record-divergence.d.ts +5 -5
  103. package/dist/tools/lean-turbo-review.d.ts +4 -1
  104. package/dist/tools/lean-turbo-run-phase.d.ts +3 -1
  105. package/dist/tools/phase-complete/gates/final-review-gate.d.ts +18 -0
  106. package/dist/tools/phase-complete/gates/index.d.ts +1 -0
  107. package/dist/tools/phase-complete/gates/types.d.ts +10 -0
  108. package/dist/tools/phase-complete.d.ts +13 -1
  109. package/dist/tools/plugin-registration.d.ts +3 -1
  110. package/dist/tools/swarm-command.d.ts +4 -1
  111. package/dist/tools/tool-metadata.d.ts +22 -22
  112. package/dist/turbo/lean/integration.d.ts +18 -2
  113. package/dist/turbo/lean/reviewer.d.ts +19 -3
  114. package/dist/turbo/lean/runner.d.ts +1 -1
  115. package/dist/worktree/merge.d.ts +47 -1
  116. package/package.json +1 -1
  117. package/dist/cli/guardrail-explain-s7vzm6z7.js +0 -55
  118. package/dist/cli/index-y2pfmd0z.js +0 -259
  119. package/dist/cli/pending-delegations-37t4xecr.js +0 -34
  120. package/dist/cli/{index-9f71ye47.js → index-13xxjfhn.js} +3 -3
  121. package/dist/cli/{index-s80bsjkj.js → index-2ghkk9ve.js} +6 -6
  122. package/dist/cli/{index-76kvm9z5.js → index-5nybajn9.js} +3 -3
@@ -238,8 +238,8 @@ export declare const MemoryProposalSchema: z.ZodObject<{
238
238
  status: z.ZodEnum<{
239
239
  pending: "pending";
240
240
  applied: "applied";
241
- rejected: "rejected";
242
241
  approved: "approved";
242
+ rejected: "rejected";
243
243
  superseded: "superseded";
244
244
  }>;
245
245
  reviewer: z.ZodOptional<z.ZodEnum<{
@@ -0,0 +1,29 @@
1
+ import type { OpencodeClient } from '@opencode-ai/sdk';
2
+ import { type EphemeralAgentDispatchResult } from '../evaluation/ephemeral-agent-dispatcher.js';
3
+ import type { ModelOverride } from '../utils/model-dispatch-fallback.js';
4
+ export type ReviewDispatchRequest = {
5
+ directory: string;
6
+ parentSessionId?: string;
7
+ /** Already-resolved reviewer or validator agent name. */
8
+ agentName: string;
9
+ model?: ModelOverride;
10
+ /** Complete replacement system prompt for the isolated review session. */
11
+ system: string;
12
+ prompt: string;
13
+ title?: string;
14
+ timeoutMs?: number;
15
+ promptByteLimit?: number;
16
+ responseByteLimit?: number;
17
+ abortSignal?: AbortSignal;
18
+ };
19
+ export type ReviewDispatchResult = EphemeralAgentDispatchResult;
20
+ export interface ReviewModelDispatcher {
21
+ dispatch(request: ReviewDispatchRequest): Promise<ReviewDispatchResult>;
22
+ }
23
+ /**
24
+ * Bind an OpenCode client to the shared ephemeral-session primitive.
25
+ *
26
+ * The returned dispatcher is instance-local and safe to inject into hooks and
27
+ * tools; it does not read or mutate module-level client state.
28
+ */
29
+ export declare function createReviewModelDispatcher(client: OpencodeClient): ReviewModelDispatcher;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Canonical, bounded Git diff collection for review-model consumers.
3
+ *
4
+ * This module is intentionally independent from hooks and command dispatch so
5
+ * automatic review, phase review, Lean review, and `/swarm review` can bind to
6
+ * one identical scope. Every Git child is array-spawned with an explicit cwd,
7
+ * ignored stdin, bounded streams, a timeout, and best-effort cleanup.
8
+ */
9
+ import * as fs from 'node:fs';
10
+ import { bunSpawn } from '../utils/bun-compat.js';
11
+ export interface InclusiveLineRange {
12
+ start: number;
13
+ end: number;
14
+ }
15
+ export type ReviewDiffSelector = {
16
+ kind: 'default';
17
+ } | {
18
+ kind: 'base';
19
+ ref: string;
20
+ } | {
21
+ kind: 'range';
22
+ from: string;
23
+ to: string;
24
+ operator: '..' | '...';
25
+ } | {
26
+ kind: 'working-tree';
27
+ };
28
+ export type ReviewDiffSelectorParseResult = {
29
+ ok: true;
30
+ selector: ReviewDiffSelector;
31
+ json: boolean;
32
+ } | {
33
+ ok: false;
34
+ code: 'INVALID_ARGUMENT' | 'INVALID_REF' | 'AMBIGUOUS_SELECTOR';
35
+ reason: string;
36
+ };
37
+ export type ReviewDiffSkipCode = 'UNSAFE_PATH' | 'PATH_OUTSIDE_ROOT' | 'MISSING_FILE' | 'SYMLINK_OR_REPARSE' | 'NON_REGULAR_FILE' | 'BINARY_FILE' | 'UNREADABLE_FILE' | 'UNTRACKED_FILE_TRUNCATED' | 'TOTAL_SCOPE_TRUNCATED' | 'UNPARSEABLE_DIFF_PATH' | 'TRACKED_BINARY' | 'CONCURRENT_PATH_MUTATION' | 'FILE_LIST_FALLBACK_TRUNCATED' | 'FILE_LIST_FALLBACK_INCOMPLETE' | 'FILE_LIST_FALLBACK_UNAVAILABLE';
38
+ export interface ReviewDiffSkipReason {
39
+ code: ReviewDiffSkipCode;
40
+ path?: string;
41
+ detail: string;
42
+ }
43
+ export interface ReviewDiffCompleteness {
44
+ complete: boolean;
45
+ truncated: boolean;
46
+ skipReasons: ReviewDiffSkipReason[];
47
+ fileListFallback?: {
48
+ files: string[];
49
+ complete: boolean;
50
+ truncated: boolean;
51
+ };
52
+ }
53
+ export interface ReviewDiffFileScope {
54
+ kind: 'added' | 'modified' | 'deleted' | 'renamed';
55
+ oldPath?: string;
56
+ newPath?: string;
57
+ }
58
+ export interface ParsedUnifiedDiffScope {
59
+ changedLines: Map<string, InclusiveLineRange[]>;
60
+ deletedLines: Map<string, InclusiveLineRange[]>;
61
+ files: Map<string, ReviewDiffFileScope>;
62
+ warnings: ReviewDiffSkipReason[];
63
+ }
64
+ export interface ReviewDiffStalenessMetadata {
65
+ collectedAt: string;
66
+ headSha: string;
67
+ selectorKey: string;
68
+ includesWorkingTree: boolean;
69
+ scopeHash: string;
70
+ }
71
+ interface ReviewDiffScopeFields {
72
+ selector: ReviewDiffSelector;
73
+ canonicalText: string;
74
+ reviewTextBytes: number;
75
+ scopeHash: string;
76
+ headSha: string;
77
+ baseRef?: string;
78
+ baseSha?: string;
79
+ mergeBase?: string;
80
+ rangeToSha?: string;
81
+ changedLines: Map<string, InclusiveLineRange[]>;
82
+ deletedLines: Map<string, InclusiveLineRange[]>;
83
+ files: Map<string, ReviewDiffFileScope>;
84
+ completeness: ReviewDiffCompleteness;
85
+ staleness: ReviewDiffStalenessMetadata;
86
+ }
87
+ export type ReviewDiffResult = ({
88
+ status: 'ok';
89
+ } & ReviewDiffScopeFields) | ({
90
+ status: 'clean';
91
+ } & ReviewDiffScopeFields) | {
92
+ status: 'error';
93
+ code: 'INVALID_DIRECTORY' | 'NOT_REPOSITORY_ROOT' | 'HEAD_UNAVAILABLE' | 'BASE_UNAVAILABLE' | 'MERGE_BASE_UNAVAILABLE' | 'GIT_FAILED' | 'GIT_TIMEOUT' | 'GIT_OUTPUT_LIMIT';
94
+ reason: string;
95
+ };
96
+ export interface CollectReviewDiffOptions {
97
+ directory: string;
98
+ selector?: ReviewDiffSelector;
99
+ timeoutMs?: number;
100
+ maxBytes?: number;
101
+ maxUntrackedFileBytes?: number;
102
+ }
103
+ /**
104
+ * Parse `/swarm review` argv. Exactly one selector is accepted; `--json` is
105
+ * orthogonal and may appear before or after it.
106
+ */
107
+ export declare function parseReviewDiffSelector(argv: readonly string[]): ReviewDiffSelectorParseResult;
108
+ /**
109
+ * Parse actual +/- lines, rather than trusting hunk counts. A line is eligible
110
+ * for anchoring only when its content was present in the exact text sent to the
111
+ * reviewer; a line-boundary-truncated hunk therefore cannot overclaim scope.
112
+ */
113
+ export declare function parseUnifiedDiffScope(text: string): ParsedUnifiedDiffScope;
114
+ /**
115
+ * Collect one canonical review scope. Default/base scopes are merge-base
116
+ * through the current tracked working tree plus safe untracked text. Exact
117
+ * ranges are committed-only. Working-tree scopes compare HEAD to tracked and
118
+ * safe untracked content.
119
+ */
120
+ export declare function collectReviewDiff(options: CollectReviewDiffOptions): Promise<ReviewDiffResult>;
121
+ /**
122
+ * File-scoped injection seam. Production reads through this object at each
123
+ * call site so tests can replace one boundary without process-global mocks.
124
+ */
125
+ export declare const _internals: {
126
+ bunSpawn: typeof bunSpawn;
127
+ realpathSync: typeof fs.realpathSync;
128
+ lstatBigIntSync: (path: fs.PathLike) => fs.BigIntStats;
129
+ openSync: typeof fs.openSync;
130
+ fstatBigIntSync: (fd: number) => fs.BigIntStats;
131
+ readSync: typeof fs.readSync;
132
+ closeSync: typeof fs.closeSync;
133
+ };
134
+ export {};
@@ -0,0 +1,60 @@
1
+ import type { AutoReviewConfig } from '../config/schema.js';
2
+ import { persistReviewReceipt } from '../hooks/review-receipt.js';
3
+ import type { ModelOverride } from '../utils/model-dispatch-fallback.js';
4
+ import type { ReviewModelDispatcher } from './contracts.js';
5
+ import { collectReviewDiff, type ReviewDiffResult, type ReviewDiffSelector } from './diff-source.js';
6
+ import { type AutoReviewEvidenceFinding, persistAutoReviewEvidence, readAutoReviewEvidenceForPhase } from './evidence.js';
7
+ export type ReviewEngineTrigger = 'task_completion' | 'phase_completion' | 'plan_completion' | 'manual';
8
+ export interface RunReviewEngineInput {
9
+ directory: string;
10
+ sessionID: string;
11
+ trigger: ReviewEngineTrigger;
12
+ phase?: number;
13
+ selector?: ReviewDiffSelector;
14
+ config: AutoReviewConfig;
15
+ dispatcher: ReviewModelDispatcher;
16
+ reviewerAgent: string;
17
+ validatorAgent: string;
18
+ reviewerModel?: ModelOverride;
19
+ reviewerFallbackModels?: ModelOverride[];
20
+ validatorModel?: ModelOverride;
21
+ validatorFallbackModels?: readonly ModelOverride[];
22
+ injectAdvisory?: (sessionID: string, message: string) => void;
23
+ }
24
+ export interface ReviewEngineResult {
25
+ status: 'completed' | 'clean' | 'error';
26
+ /** Parsed reviewer verdict when a model response completed successfully. */
27
+ reviewVerdict?: 'approved' | 'rejected';
28
+ blocked: boolean;
29
+ blockReason?: 'DIFF_COLLECTION_FAILED' | 'REVIEW_DISPATCH_FAILED' | 'INCOMPLETE_REVIEW_EVIDENCE' | 'INCOMPLETE_SCOPE' | 'INCOMPLETE_VALIDATION' | 'REVIEW_SCOPE_STALE' | 'EVIDENCE_PERSISTENCE_FAILED' | 'CONFIRMED_FINDINGS';
30
+ message: string;
31
+ findings: AutoReviewEvidenceFinding[];
32
+ blockingFindings: AutoReviewEvidenceFinding[];
33
+ validationComplete: boolean;
34
+ receiptPath?: string;
35
+ evidencePath?: string;
36
+ scopeHash?: string;
37
+ scopeComplete?: boolean;
38
+ scopeWarnings?: string[];
39
+ scopeFileList?: string[];
40
+ scopeFileListComplete?: boolean;
41
+ reviewModel?: string;
42
+ modelCalls: number;
43
+ }
44
+ export declare const REVIEW_SYSTEM_PROMPT: string;
45
+ interface BuildReviewPromptInput {
46
+ trigger: ReviewEngineTrigger;
47
+ diff: Extract<ReviewDiffResult, {
48
+ status: 'ok';
49
+ }>;
50
+ phase?: number;
51
+ }
52
+ export declare function buildReviewPrompt(input: BuildReviewPromptInput): string;
53
+ export declare function runReviewEngine(input: RunReviewEngineInput): Promise<ReviewEngineResult>;
54
+ export declare const _internals: {
55
+ collectReviewDiff: typeof collectReviewDiff;
56
+ persistEvidence: typeof persistAutoReviewEvidence;
57
+ persistReceipt: typeof persistReviewReceipt;
58
+ readPhaseEvidence: typeof readAutoReviewEvidenceForPhase;
59
+ };
60
+ export {};
@@ -0,0 +1,88 @@
1
+ import { type FindingValidation, type ReviewFinding } from '../agents/agent-output-schema.js';
2
+ import { type ReviewFindingSeverity, type ReviewReceipt } from '../hooks/review-receipt.js';
3
+ import type { ReviewDiffCompleteness, ReviewDiffSelector } from './diff-source.js';
4
+ export interface AutoReviewEvidenceFinding extends ReviewFinding {
5
+ finding_id: string;
6
+ duplicate_count: number;
7
+ anchored: boolean;
8
+ anchor_rejection?: string;
9
+ effective_severity: ReviewFindingSeverity;
10
+ validation?: FindingValidation;
11
+ }
12
+ export interface AutoReviewEvidence {
13
+ schema_version: 1;
14
+ timestamp: string;
15
+ trigger: 'task_completion' | 'phase_completion' | 'plan_completion' | 'manual';
16
+ session_id: string;
17
+ phase?: number;
18
+ scope: {
19
+ hash: string;
20
+ selector: ReviewDiffSelector;
21
+ head_sha: string;
22
+ base_ref?: string;
23
+ base_sha?: string;
24
+ merge_base?: string;
25
+ range_to_sha?: string;
26
+ review_text_bytes: number;
27
+ completeness: ReviewDiffCompleteness;
28
+ };
29
+ policy: {
30
+ mode: 'advisory' | 'gate';
31
+ min_confidence: number;
32
+ structured_findings: boolean;
33
+ validate_findings: boolean;
34
+ };
35
+ review: {
36
+ status: 'completed' | 'clean' | 'error';
37
+ output_mode?: 'structured' | 'legacy';
38
+ overall_confidence?: number;
39
+ error?: string;
40
+ model?: string;
41
+ duration_ms?: number;
42
+ };
43
+ findings: AutoReviewEvidenceFinding[];
44
+ validation_complete: boolean;
45
+ validation_error?: string;
46
+ blocking_finding_ids: string[];
47
+ receipt_path?: string;
48
+ cost: {
49
+ model_calls: number;
50
+ diff_bytes: number;
51
+ prompt_bytes: number;
52
+ tokens_input: number;
53
+ tokens_output: number;
54
+ tokens_reasoning: number;
55
+ tokens_cache: number;
56
+ cost_usd: number | null;
57
+ cost_source: 'reported' | 'estimated' | 'unavailable';
58
+ };
59
+ }
60
+ export declare function autoReviewEvidenceRelativePath(trigger: AutoReviewEvidence['trigger'], scopeHash: string, phase?: number): string;
61
+ export interface PersistAutoReviewEvidenceOptions {
62
+ /** Rebuild the exact reviewed scope immediately before the atomic rename. */
63
+ verifyCurrent?: () => Promise<boolean>;
64
+ }
65
+ export declare function persistAutoReviewEvidence(directory: string, evidence: AutoReviewEvidence, options?: PersistAutoReviewEvidenceOptions): Promise<string>;
66
+ export declare function readAutoReviewEvidenceForPhase(directory: string, phase: number): AutoReviewEvidence | null;
67
+ export declare function isAutoReviewEvidence(value: unknown): value is AutoReviewEvidence;
68
+ export interface AutoReviewEvidenceExpectation {
69
+ scopeHash: string;
70
+ phase: number;
71
+ trigger: 'phase_completion' | 'plan_completion';
72
+ policy: AutoReviewEvidence['policy'];
73
+ /** Canonical diff text used to bind the independent receipt to this scope. */
74
+ scopeContent?: string;
75
+ }
76
+ export type AutoReviewEvidenceIntegrityResult = {
77
+ ok: true;
78
+ receipt?: ReviewReceipt;
79
+ } | {
80
+ ok: false;
81
+ code: 'evidence' | 'receipt_missing' | 'receipt';
82
+ reason: string;
83
+ };
84
+ /**
85
+ * Cross-validates phase evidence against its independently persisted receipt.
86
+ * Callers must fail closed on any non-ok result; this function never dispatches.
87
+ */
88
+ export declare function validateAutoReviewEvidenceIntegrity(directory: string, evidence: AutoReviewEvidence, expected: AutoReviewEvidenceExpectation): AutoReviewEvidenceIntegrityResult;
@@ -0,0 +1,77 @@
1
+ import { type FindingValidation, type ReviewFinding } from '../agents/agent-output-schema.js';
2
+ import type { ModelOverride } from '../utils/model-dispatch-fallback.js';
3
+ import type { ReviewDispatchResult, ReviewModelDispatcher } from './contracts.js';
4
+ import type { ReviewDiffCompleteness, ReviewDiffSelector } from './diff-source.js';
5
+ export interface ValidationCandidate extends ReviewFinding {
6
+ finding_id: string;
7
+ duplicate_count: number;
8
+ }
9
+ export interface FindingValidationResult {
10
+ complete: boolean;
11
+ candidates: ValidationCandidate[];
12
+ validations: FindingValidation[];
13
+ /**
14
+ * Every model dispatch attempted, in configured order.
15
+ *
16
+ * Callers own telemetry and aggregate cost accounting from this list. The
17
+ * validator deliberately emits no telemetry so synchronous engine review and
18
+ * asynchronous receipt validation cannot double-count the same attempt.
19
+ */
20
+ attempts: readonly ReviewDispatchResult[];
21
+ error?: string;
22
+ /** Terminal completed or failed attempt retained for compatibility. */
23
+ dispatch?: ReviewDispatchResult;
24
+ }
25
+ export interface FindingValidationScopeContext {
26
+ selector: ReviewDiffSelector;
27
+ canonicalText: string;
28
+ scopeHash: string;
29
+ headSha: string;
30
+ baseRef?: string;
31
+ baseSha?: string;
32
+ mergeBase?: string;
33
+ rangeToSha?: string;
34
+ completeness: ReviewDiffCompleteness;
35
+ /** Optional Stage-B manifest description when canonicalText is not a diff. */
36
+ scopeDescription?: string;
37
+ /** Exact files represented by a Stage-B reviewer manifest. */
38
+ files?: string[];
39
+ }
40
+ export interface RunFindingValidationInput {
41
+ dispatcher: ReviewModelDispatcher;
42
+ directory: string;
43
+ parentSessionId?: string;
44
+ agentName: string;
45
+ model?: ModelOverride;
46
+ /** Plugin-instance-local configured fallback chain, in declared order. */
47
+ fallbackModels?: readonly ModelOverride[];
48
+ timeoutMs: number;
49
+ findings: Array<ReviewFinding | ValidationCandidate>;
50
+ /**
51
+ * Exact bounded scope reviewed by the originating reviewer.
52
+ *
53
+ * Receipt-only callers may omit this when they do not own canonical diff
54
+ * evidence. The shared review engine always supplies it so arbitrary ranges
55
+ * remain bound to their resolved target even when that target is not checked
56
+ * out in the validator's working directory.
57
+ */
58
+ scopeContext?: FindingValidationScopeContext;
59
+ abortSignal?: AbortSignal;
60
+ }
61
+ export declare const MAX_VALIDATOR_FALLBACK_MODELS = 3;
62
+ export declare function canonicalizeValidationCandidates(findings: Array<ReviewFinding | ValidationCandidate>): ValidationCandidate[];
63
+ export declare function runFindingValidation(input: RunFindingValidationInput): Promise<FindingValidationResult>;
64
+ export declare const MAX_TRACKED_VALIDATION_SESSIONS = 256;
65
+ export interface FindingValidationScheduler {
66
+ schedule: (validationIdentity: string, run: () => Promise<FindingValidationResult>, onComplete: (result: FindingValidationResult) => void | Promise<void>, onError?: (error: unknown) => void | Promise<void>) => boolean;
67
+ /** Instance-local test/lifecycle seam. */
68
+ reset: () => void;
69
+ readonly pendingCount: number;
70
+ }
71
+ /**
72
+ * Creates one bounded finding-validation scheduler for one plugin instance.
73
+ *
74
+ * Keeping the pending map in this closure is load-bearing: a saturated plugin
75
+ * instance must not consume another instance's 256 live validation slots.
76
+ */
77
+ export declare function createFindingValidationScheduler(): FindingValidationScheduler;
@@ -0,0 +1,37 @@
1
+ import type { AutoReviewConfig } from '../config/schema.js';
2
+ import type { ReviewModelDispatcher } from './contracts.js';
3
+ import { type ReviewEngineResult, runReviewEngine } from './engine.js';
4
+ import { type ReviewAgentModelRegistry } from './runtime.js';
5
+ export interface RunPhaseAutoReviewInput {
6
+ directory: string;
7
+ sessionID: string;
8
+ phase: number;
9
+ isFinalPlanPhase: boolean;
10
+ activeLeanTurbo: boolean;
11
+ config: AutoReviewConfig;
12
+ dispatcher?: ReviewModelDispatcher;
13
+ generatedAgentNames: Iterable<string>;
14
+ activeAgentName?: string;
15
+ agentModelRegistry?: ReviewAgentModelRegistry;
16
+ injectAdvisory: (sessionID: string, message: string) => void;
17
+ }
18
+ export interface PhaseAutoReviewResult {
19
+ trigger?: 'phase_completion' | 'plan_completion';
20
+ scopeHash?: string;
21
+ scopeComplete?: boolean;
22
+ blocked?: boolean;
23
+ blockReason?: ReviewEngineResult['blockReason'];
24
+ warnings: string[];
25
+ }
26
+ /**
27
+ * Return whether phase completion needs plan context to select a phase or
28
+ * final-plan review trigger.
29
+ *
30
+ * Keep this preflight free of I/O so the phase_complete path does not replay
31
+ * the plan ledger when auto-review is disabled or task-only.
32
+ */
33
+ export declare function mayRunPhaseAutoReview(config: AutoReviewConfig): boolean;
34
+ export declare function runPhaseAutoReview(input: RunPhaseAutoReviewInput): Promise<PhaseAutoReviewResult>;
35
+ export declare const _internals: {
36
+ runReviewEngine: typeof runReviewEngine;
37
+ };
@@ -0,0 +1,32 @@
1
+ import { type PluginConfig } from '../config/schema.js';
2
+ import { type ModelOverride } from '../utils/model-dispatch-fallback.js';
3
+ export interface ReviewAgentModelConfig {
4
+ readonly primaryModel?: string;
5
+ readonly fallbackModels: readonly string[];
6
+ }
7
+ /**
8
+ * Immutable, plugin-instance-local model configuration keyed by generated
9
+ * agent name. Runtime review paths must consume this snapshot instead of the
10
+ * process-global agent map, which can be overwritten by another plugin
11
+ * instance in the same host process.
12
+ */
13
+ export type ReviewAgentModelRegistry = Readonly<Record<string, ReviewAgentModelConfig>>;
14
+ export interface ReviewAgentNames {
15
+ reviewer: string;
16
+ validator: string;
17
+ }
18
+ /**
19
+ * Resolve a generated role from the active agent's exact swarm prefix.
20
+ *
21
+ * When no active identity is available, only unambiguous registries are
22
+ * accepted: a single candidate or an explicit default-swarm (bare) role.
23
+ * Multiple named swarms without either signal fail closed instead of routing
24
+ * work to an unrelated longest/alphabetical prefix.
25
+ */
26
+ export declare function resolveAgentForActiveSwarm(generatedAgentNames: Iterable<string>, role: string, activeAgentName?: string): string;
27
+ export declare function resolveReviewAgentNames(generatedAgentNames: Iterable<string>, activeAgentName?: string): ReviewAgentNames;
28
+ export declare function captureReviewAgentModelRegistry(config: PluginConfig | undefined, generatedAgentNames: Iterable<string>): ReviewAgentModelRegistry;
29
+ export declare function reviewFallbackModelStrings(agentName: string, registry: ReviewAgentModelRegistry | undefined): readonly string[];
30
+ export declare function reviewPrimaryModel(agentName: string, registry: ReviewAgentModelRegistry | undefined): string | undefined;
31
+ export declare function resolveReviewFallbackModels(agentName: string, registry: ReviewAgentModelRegistry | undefined): ModelOverride[];
32
+ export declare function optionalModelOverride(model: string | null | undefined): ModelOverride | undefined;
@@ -37,6 +37,15 @@ export declare function createScopeBinding(input: {
37
37
  ttlMs?: number;
38
38
  }): ScopeBinding | null;
39
39
  export declare function registerScopeBinding(binding: ScopeBinding): void;
40
+ /**
41
+ * Resolve the binding created for one fully-approved parent Task dispatch.
42
+ * An already-claimed child binding wins over its pending parent precursor;
43
+ * multiple candidates at either specificity fail closed.
44
+ */
45
+ export declare function getScopeBindingForParentDispatch(input: {
46
+ parentSessionId: string;
47
+ dispatchCallId: string;
48
+ }): ScopeBinding | null;
40
49
  export declare function getScopeBinding(input: {
41
50
  directory: string;
42
51
  plan: Plan;
@@ -63,6 +63,18 @@ export interface ConfigDoctorResult {
63
63
  timestamp: number;
64
64
  /** The config that was analyzed */
65
65
  configSource: string;
66
+ /**
67
+ * Migration availability metadata. Present when the loaded config's
68
+ * config_format_version predates the deprecatedIn version of any
69
+ * DEPRECATED_FIELDS entry.
70
+ */
71
+ availableMigrations?: Array<{
72
+ field: string;
73
+ replacement: string;
74
+ deprecatedIn: number;
75
+ sinceVersion: number;
76
+ currentFormatVersion: number;
77
+ }>;
66
78
  }
67
79
  /** Backup artifact for rollback */
68
80
  export interface ConfigBackup {
@@ -43,6 +43,8 @@ export interface SerializedAgentSession {
43
43
  qaSkipTaskIds: string[];
44
44
  pendingAdvisoryMessages: string[];
45
45
  taskWorkflowStates?: Record<string, string>;
46
+ /** Task-keyed coder file attribution. Optional for backward compatibility. */
47
+ modifiedFilesByTask?: Record<string, string[]>;
46
48
  /** Flag for one-shot scope violation warning injection (omitted when undefined for additive-only schema) */
47
49
  scopeViolationDetected?: boolean;
48
50
  /** Current index into the fallback_models array (v6.33) */