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
@@ -4,8 +4,8 @@
4
4
  * Parses the mandated reviewer OUTPUT FORMAT (`VERDICT:` / `RISK:` /
5
5
  * `ISSUES:` / `FIXES:`) from a returning reviewer Task delegation and
6
6
  * persists it as a durable review receipt under `.swarm/review-receipts/`
7
- * via the existing receipt store (scope-fingerprinted over the delegation
8
- * prompt, which defines the reviewed scope).
7
+ * via the existing receipt store. Scope is derived from guardrails-observed
8
+ * modified files and their current content, never architect-authored prose.
9
9
  *
10
10
  * Before this collector, reviewer verdicts existed only as free text inside
11
11
  * the architect's context — re-reviews and drift verification had no durable
@@ -15,7 +15,14 @@
15
15
  *
16
16
  * Fail-open: parsing or persistence failures never block tool execution.
17
17
  */
18
- export type ParsedReviewSeverity = 'critical' | 'high' | 'medium';
18
+ import { type ReviewFinding } from '../agents/agent-output-schema.js';
19
+ import { type AutoReviewConfig } from '../config/schema.js';
20
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
21
+ import { type FindingValidationScheduler } from '../review/finding-validator.js';
22
+ import { type ReviewAgentModelRegistry } from '../review/runtime.js';
23
+ import { persistReviewReceipt, type ReviewFindingSeverity, updateReviewReceiptValidations } from './review-receipt.js';
24
+ import { buildReviewerTaskScope, resolveReviewerTaskScope } from './review-receipt-scope.js';
25
+ export type ParsedReviewSeverity = ReviewFindingSeverity;
19
26
  export interface ParsedReviewIssue {
20
27
  /** Raw issue line (trimmed, bullet stripped) */
21
28
  text: string;
@@ -23,6 +30,8 @@ export interface ParsedReviewIssue {
23
30
  severity: ParsedReviewSeverity;
24
31
  /** `path:line` reference when one appears in the line */
25
32
  location?: string;
33
+ /** Machine-readable source finding, when structured output parsed. */
34
+ finding?: ReviewFinding;
26
35
  }
27
36
  export interface ParsedReviewerOutput {
28
37
  verdict: 'approved' | 'rejected';
@@ -32,30 +41,64 @@ export interface ParsedReviewerOutput {
32
41
  issues: ParsedReviewIssue[];
33
42
  /** Required-change lines from the FIXES section */
34
43
  fixes: string[];
44
+ outputMode: 'structured' | 'legacy';
45
+ overallConfidence?: number;
46
+ structuredFindings?: ReviewFinding[];
35
47
  }
36
48
  /**
37
49
  * Parse the reviewer agent's mandated output block. Returns null when no
38
- * unambiguous line-anchored `VERDICT: APPROVED|REJECTED` is present
39
- * including when multiple anchored verdict lines DISAGREE (ambiguous output
40
- * fails toward "no machine-readable verdict", never toward approval).
50
+ * single unambiguous line-anchored `VERDICT: APPROVED|REJECTED` is present,
51
+ * including missing, duplicate, or contradictory verdict lines. A structured
52
+ * verdict must match that single legacy line so ambiguous output fails toward
53
+ * "no machine-readable verdict", never toward approval.
41
54
  */
42
- export declare function parseReviewerOutput(text: string): ParsedReviewerOutput | null;
55
+ export declare function parseReviewerOutput(text: string, options?: {
56
+ structured?: boolean;
57
+ }): ParsedReviewerOutput | null;
43
58
  export interface ReviewerReceiptInput {
44
59
  tool: unknown;
45
60
  args?: unknown;
46
61
  sessionID?: unknown;
62
+ callID?: unknown;
47
63
  }
48
64
  export interface ReviewerReceiptOutput {
49
65
  output?: unknown;
66
+ state?: unknown;
67
+ status?: unknown;
68
+ error?: unknown;
69
+ errors?: unknown;
70
+ metadata?: unknown;
71
+ result?: unknown;
50
72
  }
51
73
  export interface ReviewerReceiptTranscriptInput {
52
74
  targetAgent?: string;
53
- prompt: string;
75
+ prompt?: string;
54
76
  transcript: string;
55
77
  sessionID?: string;
56
78
  sessionId?: string;
79
+ taskId?: string;
80
+ reviewerCallID?: string;
81
+ /** Production collectors consume the exact claimed coder generation. */
82
+ consumeHandoff?: boolean;
57
83
  }
58
- export declare function collectReviewerReceiptFromTranscript(directory: string, input: ReviewerReceiptTranscriptInput): Promise<string | null>;
84
+ export interface ReviewerReceiptValidationOptions {
85
+ dispatcher?: ReviewModelDispatcher;
86
+ config?: AutoReviewConfig;
87
+ generatedAgentNames?: Iterable<string>;
88
+ agentModelRegistry?: ReviewAgentModelRegistry;
89
+ injectAdvisory?: (sessionID: string, message: string) => void;
90
+ /** Shared only within the owning plugin instance. */
91
+ validationScheduler?: FindingValidationScheduler;
92
+ }
93
+ /** Test seam for the otherwise process-global telemetry sink. */
94
+ export declare const _internals: {
95
+ delegationEnd: (sessionId: string, agentName: string, taskId: string, result: string, costFields?: Partial<import("../services/cost-accounting.js").DelegationCostFields>) => void;
96
+ resolveReviewerTaskScope: typeof resolveReviewerTaskScope;
97
+ buildReviewerTaskScope: typeof buildReviewerTaskScope;
98
+ persistReviewReceipt: typeof persistReviewReceipt;
99
+ updateReviewReceiptValidations: typeof updateReviewReceiptValidations;
100
+ };
101
+ export declare function collectReviewerReceiptFromTranscript(directory: string, input: ReviewerReceiptTranscriptInput, validationOptions?: ReviewerReceiptValidationOptions): Promise<string | null>;
59
102
  /**
60
103
  * `tool.execute.after` collector. When a reviewer Task returns, parse its
61
104
  * verdict block and persist a durable review receipt. No-op for non-reviewer
@@ -63,4 +106,4 @@ export declare function collectReviewerReceiptFromTranscript(directory: string,
63
106
  *
64
107
  * Returns the persisted receipt path (for tests/telemetry) or null.
65
108
  */
66
- export declare function collectReviewerReceiptAfter(directory: string, input: ReviewerReceiptInput, output: ReviewerReceiptOutput): Promise<string | null>;
109
+ export declare function collectReviewerReceiptAfter(directory: string, input: ReviewerReceiptInput, output: ReviewerReceiptOutput, validationOptions?: ReviewerReceiptValidationOptions): Promise<string | null>;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Canonical scope construction for Stage-B reviewer receipts.
3
+ *
4
+ * The architect-authored reviewer prompt is not authoritative scope: it can
5
+ * omit files that the coder actually changed. Guardrails records every
6
+ * write-tool target in `modifiedFilesThisCoderTask`, so receipts fingerprint a
7
+ * bounded manifest of repository HEAD, those paths, and their current byte
8
+ * content instead. A base change therefore invalidates the receipt even when
9
+ * the working-file bytes happen to remain identical.
10
+ *
11
+ * Any missing session state, unsafe path, symlink/reparse point, concurrent
12
+ * mutation, or size overflow fails toward no receipt. A durable receipt must
13
+ * never claim a scope the harness could not reconstruct exactly.
14
+ */
15
+ import * as child_process from 'node:child_process';
16
+ import * as fs from 'node:fs';
17
+ export declare const REVIEWER_TASK_SCOPE_DESCRIPTION = "reviewer-task-files-v1";
18
+ export interface ReviewerTaskScope {
19
+ content: string;
20
+ description: typeof REVIEWER_TASK_SCOPE_DESCRIPTION;
21
+ files: string[];
22
+ headSha: string;
23
+ taskId?: string;
24
+ coderCallID?: string;
25
+ generation?: number;
26
+ sessionIncarnation?: string;
27
+ }
28
+ export interface ReviewerTaskScopeProvenance {
29
+ taskId: string;
30
+ coderCallID: string;
31
+ generation: number;
32
+ sessionIncarnation: string;
33
+ }
34
+ export interface ResolveReviewerTaskScopeOptions {
35
+ /** Consume the completed coder's one-shot scope instead of the live list. */
36
+ consumeHandoff?: boolean;
37
+ /** Exact task expected by the returning reviewer/background record. */
38
+ expectedTaskId?: string;
39
+ /** Exact reviewer Task call that claimed the generation. */
40
+ reviewerCallID?: string;
41
+ /** Injectable clock used only for deterministic expiry tests. */
42
+ now?: number;
43
+ }
44
+ /**
45
+ * Resolve the exact known plan task carried by reviewer/coder Task arguments.
46
+ *
47
+ * This deliberately reuses delegation-gate's canonical extractor so lifecycle
48
+ * identity cannot drift from scope authorization. It checks all supported Task
49
+ * text fields, prefers an unambiguous TASK line, rejects ambiguity, and filters
50
+ * numeric-dot tokens against the current plan.
51
+ */
52
+ export declare function resolveReviewerScopeTaskId(directory: string, args: unknown): Promise<string | null>;
53
+ /**
54
+ * Test-only dependency-injection seam. Keeping the spawn binding local avoids
55
+ * process-global `mock.module()` pollution while allowing tests to prove that
56
+ * the production call really creates a child with ignored stdin.
57
+ */
58
+ export declare const _internals: {
59
+ spawn: typeof child_process.spawn;
60
+ realpath: typeof fs.promises.realpath;
61
+ lstatBigInt: (path: fs.PathLike) => Promise<fs.BigIntStats>;
62
+ open: typeof fs.promises.open;
63
+ fileHandleStatBigInt: (handle: fs.promises.FileHandle) => Promise<fs.BigIntStats>;
64
+ };
65
+ /**
66
+ * Build the exact scope fingerprint input for a guardrails-observed file list.
67
+ */
68
+ export declare function buildReviewerTaskScope(directory: string, modifiedFiles: readonly string[], maxBytes?: number, provenance?: ReviewerTaskScopeProvenance): Promise<ReviewerTaskScope | null>;
69
+ /**
70
+ * Resolve scope only from the architect session's guardrails-owned task state.
71
+ * Receipt collection consumes the completed coder handoff exactly once; direct
72
+ * callers retain the legacy live-list view for diagnostics and drift probes.
73
+ */
74
+ export declare function resolveReviewerTaskScope(directory: string, sessionID: string, maxBytes?: number, options?: ResolveReviewerTaskScopeOptions): Promise<ReviewerTaskScope | null>;
@@ -22,13 +22,21 @@
22
22
  * but MUST NOT blindly trust them — staleness check is mandatory.
23
23
  *
24
24
  * Scope-description heterogeneity: receipts in one index may be fingerprinted
25
- * over different canonical contents (e.g. 'reviewer-task-prompt' hashes the
26
- * delegation prompt; 'auto-review-*-diff' hashes the reviewed diff). A prompt
27
- * fingerprint does NOT change when the worktree changes, so consumers MUST
28
- * filter by `scope_fingerprint.scope_description` (or compare like-for-like
29
- * content) before treating an approved receipt as fresh via isScopeStale().
25
+ * over different canonical contents (e.g. `reviewer-task-files-v1` hashes the
26
+ * guardrails-observed file scope plus HEAD and current content; auto-review
27
+ * receipts hash a canonical diff). Consumers MUST filter by
28
+ * `scope_fingerprint.scope_description` and compare like-for-like content
29
+ * before treating an approved receipt as fresh via isScopeStale().
30
30
  */
31
+ import * as fs from 'node:fs';
32
+ import type { FindingValidation, ReviewFinding } from '../agents/agent-output-schema.js';
31
33
  export type ReceiptVerdict = 'rejected' | 'approved';
34
+ export type ReviewFindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
35
+ /** Raised when reviewed bytes stop matching immediately before a durable commit. */
36
+ export declare class ReviewScopeStaleError extends Error {
37
+ readonly code = "REVIEW_SCOPE_STALE";
38
+ constructor(message: string);
39
+ }
32
40
  /** Identity of the reviewer/curator that produced the receipt. */
33
41
  export interface ReviewerIdentity {
34
42
  /** Agent name (e.g. 'reviewer', 'critic', 'curator') */
@@ -45,7 +53,12 @@ export interface ScopeFingerprint {
45
53
  /** Length of the original content in characters */
46
54
  content_length: number;
47
55
  }
48
- /** A blocking finding recorded in a rejected review. */
56
+ /**
57
+ * A finding recorded in a rejected review.
58
+ *
59
+ * The `blocking_findings` JSON field name is retained for schema-v1
60
+ * compatibility, but `effective_severity` is authoritative when present.
61
+ */
49
62
  export interface BlockingFinding {
50
63
  /** File path (relative) or identifier */
51
64
  location: string;
@@ -53,8 +66,23 @@ export interface BlockingFinding {
53
66
  summary: string;
54
67
  /** Line number if applicable */
55
68
  line?: number;
56
- /** Severity: 'critical' | 'high' | 'medium' */
57
- severity: 'critical' | 'high' | 'medium';
69
+ /** Reviewer-reported severity. */
70
+ severity: ReviewFindingSeverity;
71
+ /** Structured-finding fields are additive so legacy v1 receipts remain readable. */
72
+ finding_id?: string;
73
+ title?: string;
74
+ body?: string;
75
+ confidence?: number;
76
+ file?: string;
77
+ line_start?: number;
78
+ line_end?: number;
79
+ /** Severity after confidence, anchoring, and validation policy is applied. */
80
+ effective_severity?: ReviewFindingSeverity;
81
+ validator_disposition?: FindingValidation['disposition'];
82
+ validator_confidence?: number;
83
+ validator_evidence?: string;
84
+ anchor_status?: 'anchored' | 'unanchored' | 'truncated' | 'rejected';
85
+ anchor_reason?: string;
58
86
  }
59
87
  /**
60
88
  * Rejected review receipt.
@@ -71,7 +99,10 @@ export interface RejectedReviewReceipt {
71
99
  reviewed_at: string;
72
100
  /** Fingerprint of the reviewed scope */
73
101
  scope_fingerprint: ScopeFingerprint;
74
- /** Blocking findings that caused rejection */
102
+ /**
103
+ * Rejected findings retained under the schema-v1 field name.
104
+ * Consumers must use effective severity when deciding which can block.
105
+ */
75
106
  blocking_findings: BlockingFinding[];
76
107
  /** Exact evidence references (file paths, line numbers, etc.) */
77
108
  evidence_references: string[];
@@ -79,6 +110,11 @@ export interface RejectedReviewReceipt {
79
110
  pass_conditions: string[];
80
111
  /** Optional free-text summary */
81
112
  summary?: string;
113
+ /** Original machine-readable reviewer payload, when one was available. */
114
+ structured_findings?: ReviewFinding[];
115
+ review_overall_confidence?: number;
116
+ /** Independent validator output, when validation was requested. */
117
+ finding_validations?: FindingValidation[];
82
118
  }
83
119
  /**
84
120
  * Approved review receipt.
@@ -101,6 +137,11 @@ export interface ApprovedReviewReceipt {
101
137
  validated_claims: string[];
102
138
  /** Residual risk or caveats */
103
139
  caveats?: string[];
140
+ /** Original machine-readable reviewer payload, when one was available. */
141
+ structured_findings?: ReviewFinding[];
142
+ review_overall_confidence?: number;
143
+ /** Independent validator output, when validation was requested. */
144
+ finding_validations?: FindingValidation[];
104
145
  }
105
146
  export type ReviewReceipt = RejectedReviewReceipt | ApprovedReviewReceipt;
106
147
  /** Index entry for fast lookup without reading every receipt file. */
@@ -121,6 +162,20 @@ export interface ReceiptIndex {
121
162
  export declare function resolveReceiptsDir(directory: string): string;
122
163
  /** Returns the index file path. */
123
164
  export declare function resolveReceiptIndexPath(directory: string): string;
165
+ export declare const _internals: {
166
+ openSync: typeof fs.openSync;
167
+ lstatBigIntSync: (path: fs.PathLike) => fs.BigIntStats;
168
+ fstatBigIntSync: (fd: number) => fs.BigIntStats;
169
+ };
170
+ /**
171
+ * Read a direct review-receipt file without following redirected ancestors.
172
+ *
173
+ * The directory identities are captured before opening, then revalidated
174
+ * around a descriptor-owned read. Comparing the opened descriptor with the
175
+ * pathname snapshots prevents a project/.swarm/review-receipts swap from
176
+ * redirecting the read outside the project between validation and open.
177
+ */
178
+ export declare function readReviewReceiptText(directory: string, receiptPath: string, maxBytes?: number): string | null;
124
179
  /**
125
180
  * Compute a SHA-256 scope fingerprint for a given content string.
126
181
  * The hash is deterministic: same content → same hash.
@@ -135,12 +190,45 @@ export declare function computeScopeFingerprint(content: string, scopeDescriptio
135
190
  * is treated as stale (conservative: assume the scope has changed).
136
191
  */
137
192
  export declare function isScopeStale(receipt: ReviewReceipt, currentContent: string | undefined): boolean;
193
+ export interface PersistReviewReceiptOptions {
194
+ /**
195
+ * Rebuild and verify the immutable reviewed scope immediately before each
196
+ * synchronous atomic rename. A false result aborts without publishing stale
197
+ * receipt/index state.
198
+ */
199
+ verifyCurrent?: () => Promise<boolean>;
200
+ }
201
+ export interface UpdateReviewReceiptValidationsOptions {
202
+ /** Refuse to update a receipt that no longer has the expected immutable identity. */
203
+ expectedIdentity?: {
204
+ id: string;
205
+ scopeHash: string;
206
+ scopeDescription: string;
207
+ };
208
+ /**
209
+ * Rebuild and verify the exact reviewer generation and scope immediately before
210
+ * the synchronous atomic rename. A false result discards the temporary update.
211
+ */
212
+ verifyCurrent?: () => Promise<boolean>;
213
+ }
138
214
  /**
139
215
  * Persist a review receipt (rejected or approved) to disk.
140
216
  * Creates .swarm/review-receipts/<date>-<id>.json and updates the index.
141
217
  * Returns the absolute path of the written receipt file.
142
218
  */
143
- export declare function persistReviewReceipt(directory: string, receipt: ReviewReceipt): Promise<string>;
219
+ export declare function persistReviewReceipt(directory: string, receipt: ReviewReceipt, options?: PersistReviewReceiptOptions): Promise<string>;
220
+ /**
221
+ * Remove a just-persisted receipt after a later persistence step fails.
222
+ *
223
+ * The index entry is committed first so a crash can leave at most an unindexed
224
+ * orphan file, never a dangling index entry that points at missing evidence.
225
+ */
226
+ export declare function removeReviewReceipt(directory: string, receiptPath: string, receiptId: string): Promise<void>;
227
+ /**
228
+ * Atomically attach independent finding-validation results to an existing
229
+ * receipt. The receipt identity and index entry remain unchanged.
230
+ */
231
+ export declare function updateReviewReceiptValidations(receiptPath: string, validations: FindingValidation[], options?: UpdateReviewReceiptValidationsOptions): Promise<void>;
144
232
  /**
145
233
  * Read a single receipt by ID. Returns null if not found or unreadable.
146
234
  */
@@ -168,6 +256,9 @@ export declare function buildRejectedReceipt(opts: {
168
256
  evidenceReferences: string[];
169
257
  passConditions: string[];
170
258
  summary?: string;
259
+ structuredFindings?: ReviewFinding[];
260
+ reviewOverallConfidence?: number;
261
+ findingValidations?: FindingValidation[];
171
262
  }): RejectedReviewReceipt;
172
263
  /**
173
264
  * Build an ApprovedReviewReceipt.
@@ -181,6 +272,9 @@ export declare function buildApprovedReceipt(opts: {
181
272
  checkedAspects: string[];
182
273
  validatedClaims: string[];
183
274
  caveats?: string[];
275
+ structuredFindings?: ReviewFinding[];
276
+ reviewOverallConfidence?: number;
277
+ findingValidations?: FindingValidation[];
184
278
  }): ApprovedReviewReceipt;
185
279
  /**
186
280
  * Build a structured context summary of prior receipts for critic drift
@@ -0,0 +1,21 @@
1
+ import * as fs from 'node:fs';
2
+ export declare const MAX_REVIEWER_SCOPE_FINGERPRINT_BYTES = 1048576;
3
+ export declare const MAX_REVIEWER_SCOPE_FINGERPRINT_AGGREGATE_BYTES = 4194304;
4
+ export type ReviewerScopeFileFingerprint = {
5
+ file: string;
6
+ kind: 'file';
7
+ size: number;
8
+ hash: string;
9
+ } | {
10
+ file: string;
11
+ kind: 'deleted';
12
+ };
13
+ export declare const _internals: {
14
+ readFileSync: typeof fs.readFileSync;
15
+ };
16
+ /**
17
+ * Capture the exact post-write file state with a bounded read. Oversized,
18
+ * non-regular, path-racing, and unreadable targets fail closed to null.
19
+ */
20
+ export declare function captureReviewerScopeFileFingerprint(directory: string, file: string, maxBytes?: number): ReviewerScopeFileFingerprint | null;
21
+ export declare function reviewerScopeFileFingerprintsEqual(left: ReviewerScopeFileFingerprint, right: ReviewerScopeFileFingerprint): boolean;
@@ -0,0 +1,19 @@
1
+ export type ReviewerScopeLifecycleTransition = 'coder_started' | 'coder_ready' | 'reviewer_claimed';
2
+ /** Run only after the complete blocking before-chain approved this Task call. */
3
+ export declare function beginApprovedReviewerScopeLifecycle(input: {
4
+ directory: string;
5
+ tool: unknown;
6
+ args: unknown;
7
+ parentSessionID: string;
8
+ callID: string;
9
+ maxBytes?: number;
10
+ }): Promise<ReviewerScopeLifecycleTransition | null>;
11
+ /** Mark a synchronous coder terminal; background running placeholders are inert. */
12
+ export declare function completeReviewerScopeLifecycle(input: {
13
+ directory: string;
14
+ tool: unknown;
15
+ args: unknown;
16
+ output: unknown;
17
+ parentSessionID: string;
18
+ callID: string;
19
+ }): Promise<ReviewerScopeLifecycleTransition | null>;
@@ -0,0 +1,6 @@
1
+ export type TaskResultClassification = 'running' | 'success' | 'non_success';
2
+ /**
3
+ * Shared Task-result classifier for every Stage-B lifecycle consumer.
4
+ * Explicit state/status and error fields win. Unknown shapes fail closed.
5
+ */
6
+ export declare function classifyTaskResult(output: unknown): TaskResultClassification;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from '@opencode-ai/plugin';
2
2
  import { loadPluginConfigWithMetaAsync } from './config';
3
+ import { resolveAutoReviewConfig } from './config/schema';
3
4
  import { createRepoGraphBuilderHook } from './hooks';
4
5
  import { loadSnapshot } from './session/snapshot-reader.js';
5
6
  import { ensureSwarmGitExcluded } from './utils/gitignore-warning';
@@ -24,6 +25,7 @@ export declare function overrideIndexInternalsForTest(overrides: {
24
25
  loadPluginConfigWithMetaAsync?: typeof loadPluginConfigWithMetaAsync;
25
26
  loadSnapshot?: typeof loadSnapshot;
26
27
  ensureSwarmGitExcluded?: typeof ensureSwarmGitExcluded;
28
+ resolveAutoReviewConfig?: typeof resolveAutoReviewConfig;
27
29
  }): () => void;
28
30
  export declare function schedulePostResolutionTasksForTest(tasks: readonly PostResolutionTask[]): void;
29
31
  /**