opencode-swarm 7.145.0 → 7.145.2

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 (105) hide show
  1. package/.opencode/skills/phase-wrap/SKILL.md +3 -2
  2. package/README.md +5 -1
  3. package/dist/background/workspace-snapshot.d.ts +29 -0
  4. package/dist/cli/{config-doctor-dzsv3pqy.js → config-doctor-j1r33f4q.js} +3 -3
  5. package/dist/cli/{core-qkh9me8x.js → core-c2zrd384.js} +4 -4
  6. package/dist/cli/{curation-policy-5x6346tf.js → curation-policy-xv0j8zyt.js} +6 -6
  7. package/dist/cli/{curator-zssndq5x.js → curator-gk2kmrk1.js} +31 -31
  8. package/dist/cli/{curator-llm-factory-q5p4578g.js → curator-llm-factory-sat3mn5n.js} +31 -31
  9. package/dist/cli/{evidence-summary-service-dqcpapj8.js → evidence-summary-service-0mhx0t0v.js} +14 -14
  10. package/dist/cli/{gate-evidence-bkdqryqg.js → gate-evidence-a5adh55x.js} +9 -9
  11. package/dist/cli/{guardrail-explain-kspf83x5.js → guardrail-explain-r50fery8.js} +32 -32
  12. package/dist/cli/{guardrail-log-qg4sq6gr.js → guardrail-log-p69eys6d.js} +4 -4
  13. package/dist/cli/{hive-promoter-3h7dhnek.js → hive-promoter-ay8a7sct.js} +31 -31
  14. package/dist/cli/{index-wk54ey3h.js → index-0a0asz2s.js} +1 -1
  15. package/dist/cli/{index-2dnqazyr.js → index-1g87esfp.js} +2 -2
  16. package/dist/cli/{index-0pcq32y2.js → index-2vefr1f8.js} +1 -1
  17. package/dist/cli/{index-fp464as8.js → index-4p3qfb05.js} +1 -1
  18. package/dist/cli/{index-77ef8gye.js → index-5e5a1y2r.js} +1 -1
  19. package/dist/cli/{index-0jr9zn34.js → index-612rr70a.js} +2 -2
  20. package/dist/cli/{index-apjdytwx.js → index-673axbjx.js} +3 -3
  21. package/dist/cli/{index-qfawexc8.js → index-6wf75rcm.js} +6 -6
  22. package/dist/cli/{index-k6pdsct6.js → index-7y5akvc9.js} +1 -1
  23. package/dist/cli/{index-hfzcztv6.js → index-9080b3de.js} +34 -34
  24. package/dist/cli/{index-v64kjqvg.js → index-917z76qr.js} +25 -18
  25. package/dist/cli/{index-ffdwj1an.js → index-97psh79d.js} +1 -1
  26. package/dist/cli/{index-kp87kr1a.js → index-9gt8g2qj.js} +4 -4
  27. package/dist/cli/{index-4e5a28h7.js → index-b9kxxd6k.js} +2 -2
  28. package/dist/cli/{index-pa86tpgt.js → index-bghwrr59.js} +1 -1
  29. package/dist/cli/{index-6ezbzd5e.js → index-cb2qtetk.js} +682 -181
  30. package/dist/cli/{index-v3y3qg48.js → index-cpg98bh1.js} +17 -1
  31. package/dist/cli/{index-c13ttmak.js → index-cxn95n7q.js} +180 -32
  32. package/dist/cli/{index-7g276m9m.js → index-czde45km.js} +3 -3
  33. package/dist/cli/{index-zfhe7vbb.js → index-gpnv14kq.js} +2 -2
  34. package/dist/cli/{index-6q3agdmr.js → index-j20fzn0w.js} +2 -2
  35. package/dist/cli/{index-mkks7jwg.js → index-jgb7mq2y.js} +4 -4
  36. package/dist/cli/{index-h4hasck4.js → index-jpppcckq.js} +4 -4
  37. package/dist/cli/{index-4evasm2b.js → index-kggqpefz.js} +5 -5
  38. package/dist/cli/{index-s6cwsnrw.js → index-n55a28zr.js} +254 -36
  39. package/dist/cli/{index-b3xret0a.js → index-ncfjxz9n.js} +5 -5
  40. package/dist/cli/{index-e00wbqw5.js → index-np4ytvvv.js} +2 -2
  41. package/dist/cli/{index-jy9bwa9k.js → index-nsr5b69r.js} +2 -2
  42. package/dist/cli/{index-zz5qsjd1.js → index-qyvjp0bq.js} +66 -38
  43. package/dist/cli/{index-6hqhyb0f.js → index-rk80jhef.js} +19 -5
  44. package/dist/cli/{index-4zwjc9sb.js → index-vav705md.js} +101 -4
  45. package/dist/cli/{index-s72naw1j.js → index-x8pm918t.js} +1 -1
  46. package/dist/cli/{index-b30x236n.js → index-z9yhhk6q.js} +96 -8
  47. package/dist/cli/index.js +32 -32
  48. package/dist/cli/{knowledge-escalator-w1mbaktt.js → knowledge-escalator-22apj3dj.js} +14 -14
  49. package/dist/cli/{knowledge-events-a0dj6gy6.js → knowledge-events-bx8xba9z.js} +12 -12
  50. package/dist/cli/{knowledge-link-mzdjvjsd.js → knowledge-link-82ew2yc4.js} +5 -5
  51. package/dist/cli/{knowledge-store-8kk3rghx.js → knowledge-store-nc71kfsg.js} +6 -6
  52. package/dist/cli/{knowledge-validator-91ym56e0.js → knowledge-validator-g8ne80v6.js} +8 -8
  53. package/dist/cli/model-preflight-7ea00h34.js +170 -0
  54. package/dist/cli/{pending-delegations-6vsrmw5w.js → pending-delegations-kkrczqv7.js} +3 -3
  55. package/dist/cli/{pr-subscriptions-zc3skxde.js → pr-subscriptions-2xn238xt.js} +3 -3
  56. package/dist/cli/{runner-jj32v8bk.js → runner-pqsf809k.js} +6 -6
  57. package/dist/cli/{scan-cursor-12jxwd14.js → scan-cursor-6ksgv514.js} +7 -7
  58. package/dist/cli/{schema-nq9tcz87.js → schema-mpcm7nje.js} +2 -2
  59. package/dist/cli/{scope-persistence-dv6z7n08.js → scope-persistence-mj1w3hqw.js} +11 -8
  60. package/dist/cli/{skill-generator-drscnzq9.js → skill-generator-gsa6qwwt.js} +16 -16
  61. package/dist/cli/{telemetry-z54dgdrh.js → telemetry-t109dhv7.js} +1 -1
  62. package/dist/cli/{workspace-snapshot-q21mgbsh.js → workspace-snapshot-kznz5e13.js} +4 -2
  63. package/dist/cli/{worktree-collision-ownership-rfyyjjct.js → worktree-collision-ownership-2jtg2my1.js} +8 -8
  64. package/dist/cli/{worktree-isolation-4tehtym5.js → worktree-isolation-ajzyp2gm.js} +33 -31
  65. package/dist/config/schema.d.ts +2 -2
  66. package/dist/evidence/task-gate-repair.d.ts +26 -0
  67. package/dist/evidence/task-gate-requirements.d.ts +20 -0
  68. package/dist/gate-evidence.d.ts +7 -0
  69. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +4 -0
  70. package/dist/hooks/knowledge-receipt-ledger-storage.d.ts +2 -0
  71. package/dist/hooks/knowledge-receipt-ledger.d.ts +72 -3
  72. package/dist/hooks/knowledge-receipt-observability.d.ts +1 -1
  73. package/dist/hooks/phase-complete-directive-gate.d.ts +9 -0
  74. package/dist/index.js +566 -546
  75. package/dist/observability/catalog.d.ts +2 -2
  76. package/dist/plan/manager.d.ts +8 -0
  77. package/dist/review/diff-source.d.ts +30 -0
  78. package/dist/review/engine.d.ts +1 -0
  79. package/dist/review/evidence.d.ts +16 -2
  80. package/dist/review/phase-runner.d.ts +1 -0
  81. package/dist/scope/scope-binding.d.ts +16 -0
  82. package/dist/services/model-preflight.d.ts +151 -0
  83. package/dist/services/session-reflection.d.ts +24 -0
  84. package/dist/telemetry.d.ts +12 -1
  85. package/dist/tools/completion-verify.d.ts +2 -0
  86. package/dist/tools/convene-council.d.ts +1 -1
  87. package/dist/tools/index.d.ts +4 -0
  88. package/dist/tools/manifest.d.ts +4 -0
  89. package/dist/tools/phase-complete/gates/final-review-gate.d.ts +3 -3
  90. package/dist/tools/phase-complete/gates/types.d.ts +2 -2
  91. package/dist/tools/phase-complete/preflight-report.d.ts +66 -0
  92. package/dist/tools/phase-complete/snapshot-identity.d.ts +1 -0
  93. package/dist/tools/phase-complete.d.ts +66 -3
  94. package/dist/tools/placeholder-scan.d.ts +64 -0
  95. package/dist/tools/record-directive-override.d.ts +14 -0
  96. package/dist/tools/repair-gate-evidence.d.ts +6 -0
  97. package/dist/tools/repair-knowledge-receipt-ledger.d.ts +27 -0
  98. package/dist/tools/run-phase-review.d.ts +37 -0
  99. package/dist/tools/sast-scan.d.ts +6 -0
  100. package/dist/tools/submit-phase-council-verdicts.d.ts +1 -1
  101. package/dist/tools/tool-metadata.d.ts +32 -16
  102. package/dist/tools/write-final-council-evidence.d.ts +1 -1
  103. package/dist/tools/write-retro.d.ts +2 -0
  104. package/package.json +1 -1
  105. package/dist/cli/{curator-drift-yn5d0mvq.js → curator-drift-r50x1rac.js} +1 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The event catalog (issue #2029).
3
3
  *
4
- * Exactly 44 entries, matching the `TelemetryEvent` union at
4
+ * Exactly 45 entries, matching the `TelemetryEvent` union at
5
5
  * `src/telemetry.ts:15-92`. Thirty-eight predate the #2029 contract; the 39th is
6
6
  * `agent_conflict_detected` (previously emitted through a force-cast past the
7
7
  * type system), the 40th is `close_archive_result` (issue #2030 — the
@@ -65,7 +65,7 @@ export interface CatalogEntry {
65
65
  /**
66
66
  * Whether an event of this kind must carry `trace.parentSpanId`.
67
67
  *
68
- * `false` for all 44 entries today, and that is a truthful statement about
68
+ * `false` for all 45 entries today, and that is a truthful statement about
69
69
  * the current system rather than a placeholder: no producer supplies a
70
70
  * parent span, so `createObservation` never sets one. Setting this to `true`
71
71
  * for a kind whose producer cannot supply a parent would make every
@@ -155,6 +155,14 @@ export declare function savePlan(directory: string, plan: Plan, options?: {
155
155
  expectedSeq: number;
156
156
  expectedLedgerHash: string;
157
157
  };
158
+ /**
159
+ * Optional synchronous CAS guard for a caller whose authoritative write is
160
+ * conditioned on external evidence. It is invoked immediately before every
161
+ * ledger/projection mutation and must throw when the captured identity is
162
+ * stale. Keep it synchronous so no writer can interleave in this process
163
+ * between the final check and the atomic filesystem operation.
164
+ */
165
+ preCommitCheck?: () => void;
158
166
  }): Promise<void>;
159
167
  /**
160
168
  * Rebuild plan from ledger events.
@@ -69,6 +69,34 @@ export interface ReviewDiffStalenessMetadata {
69
69
  includesWorkingTree: boolean;
70
70
  scopeHash: string;
71
71
  }
72
+ export interface ReviewManifestIdentity {
73
+ algorithm: 'sha256' | 'git-blob';
74
+ sha256?: string;
75
+ byte_length?: number;
76
+ git_blob_oid?: string;
77
+ git_object_format?: string;
78
+ }
79
+ export interface ReviewManifestPathRecord {
80
+ kind: ReviewDiffFileScope['kind'];
81
+ old_path?: string;
82
+ new_path?: string;
83
+ old_identity?: ReviewManifestIdentity;
84
+ new_identity?: ReviewManifestIdentity;
85
+ }
86
+ export interface ReviewDiffManifest {
87
+ schema_version: 2;
88
+ hash: string;
89
+ content_hash: string;
90
+ selector: ReviewDiffSelector;
91
+ selector_key: string;
92
+ review_target_kind: 'checkout-history-index-working-tree' | 'checkout-index-working-tree' | 'exact-committed-range';
93
+ completeness: {
94
+ complete: boolean;
95
+ truncated: boolean;
96
+ skip_reason_codes: ReviewDiffSkipCode[];
97
+ };
98
+ path_records: ReviewManifestPathRecord[];
99
+ }
72
100
  interface ReviewDiffScopeFields {
73
101
  selector: ReviewDiffSelector;
74
102
  canonicalText: string;
@@ -84,6 +112,7 @@ interface ReviewDiffScopeFields {
84
112
  files: Map<string, ReviewDiffFileScope>;
85
113
  completeness: ReviewDiffCompleteness;
86
114
  staleness: ReviewDiffStalenessMetadata;
115
+ manifest: ReviewDiffManifest;
87
116
  }
88
117
  export type ReviewDiffResult = ({
89
118
  status: 'ok';
@@ -132,5 +161,6 @@ export declare const _internals: {
132
161
  readSync: typeof fs.readSync;
133
162
  closeSync: typeof fs.closeSync;
134
163
  resolveGitExecutable: typeof resolveGitExecutableAsync;
164
+ now: () => number;
135
165
  };
136
166
  export {};
@@ -34,6 +34,7 @@ export interface ReviewEngineResult {
34
34
  receiptPath?: string;
35
35
  evidencePath?: string;
36
36
  scopeHash?: string;
37
+ manifestHash?: string;
37
38
  scopeComplete?: boolean;
38
39
  scopeWarnings?: string[];
39
40
  scopeFileList?: string[];
@@ -1,6 +1,8 @@
1
1
  import { type FindingValidation, type ReviewFinding } from '../agents/agent-output-schema.js';
2
+ import type { Plan } from '../config/plan-schema.js';
3
+ import type { AutoReviewConfig } from '../config/schema.js';
2
4
  import { type ReviewFindingSeverity, type ReviewReceipt } from '../hooks/review-receipt.js';
3
- import type { ReviewDiffCompleteness, ReviewDiffSelector } from './diff-source.js';
5
+ import type { ReviewDiffCompleteness, ReviewDiffManifest, ReviewDiffSelector } from './diff-source.js';
4
6
  export interface AutoReviewEvidenceFinding extends ReviewFinding {
5
7
  finding_id: string;
6
8
  duplicate_count: number;
@@ -9,8 +11,13 @@ export interface AutoReviewEvidenceFinding extends ReviewFinding {
9
11
  effective_severity: ReviewFindingSeverity;
10
12
  validation?: FindingValidation;
11
13
  }
14
+ export interface AutoReviewScopeManifest extends ReviewDiffManifest {
15
+ plan_requirements_hash: string;
16
+ review_policy_digest: string;
17
+ hash: string;
18
+ }
12
19
  export interface AutoReviewEvidence {
13
- schema_version: 1;
20
+ schema_version: 1 | 2;
14
21
  timestamp: string;
15
22
  trigger: 'task_completion' | 'phase_completion' | 'plan_completion' | 'manual';
16
23
  session_id: string;
@@ -25,12 +32,14 @@ export interface AutoReviewEvidence {
25
32
  range_to_sha?: string;
26
33
  review_text_bytes: number;
27
34
  completeness: ReviewDiffCompleteness;
35
+ manifest?: AutoReviewScopeManifest;
28
36
  };
29
37
  policy: {
30
38
  mode: 'advisory' | 'gate';
31
39
  min_confidence: number;
32
40
  structured_findings: boolean;
33
41
  validate_findings: boolean;
42
+ digest?: string;
34
43
  };
35
44
  review: {
36
45
  status: 'completed' | 'clean' | 'error';
@@ -57,6 +66,7 @@ export interface AutoReviewEvidence {
57
66
  cost_source: 'reported' | 'estimated' | 'unavailable';
58
67
  };
59
68
  }
69
+ export declare function computeAutoReviewManifestHash(manifest: Omit<AutoReviewScopeManifest, 'hash'>): string;
60
70
  export declare function autoReviewEvidenceRelativePath(trigger: AutoReviewEvidence['trigger'], scopeHash: string, phase?: number): string;
61
71
  export interface PersistAutoReviewEvidenceOptions {
62
72
  /** Rebuild the exact reviewed scope immediately before the atomic rename. */
@@ -65,6 +75,10 @@ export interface PersistAutoReviewEvidenceOptions {
65
75
  export declare function persistAutoReviewEvidence(directory: string, evidence: AutoReviewEvidence, options?: PersistAutoReviewEvidenceOptions): Promise<string>;
66
76
  export declare function readAutoReviewEvidenceForPhase(directory: string, phase: number): AutoReviewEvidence | null;
67
77
  export declare function isAutoReviewEvidence(value: unknown): value is AutoReviewEvidence;
78
+ export declare function computePlanRequirementsHash(directory: string): Promise<string>;
79
+ export declare function computeAutoReviewPolicyDigest(config: AutoReviewConfig): string;
80
+ export declare function materializeAutoReviewManifest(directory: string, manifest: ReviewDiffManifest, config: AutoReviewConfig): Promise<AutoReviewScopeManifest>;
81
+ export declare function computeReviewPlanRequirementsHash(plan: Plan): string;
68
82
  export interface AutoReviewEvidenceExpectation {
69
83
  scopeHash: string;
70
84
  phase: number;
@@ -18,6 +18,7 @@ export interface RunPhaseAutoReviewInput {
18
18
  export interface PhaseAutoReviewResult {
19
19
  trigger?: 'phase_completion' | 'plan_completion';
20
20
  scopeHash?: string;
21
+ manifestHash?: string;
21
22
  scopeComplete?: boolean;
22
23
  blocked?: boolean;
23
24
  blockReason?: ReviewEngineResult['blockReason'];
@@ -198,6 +198,22 @@ export declare function clearExactScopeBinding(input: {
198
198
  }): ScopeBinding | null;
199
199
  export declare function installScopeBindingTombstone(binding: ScopeBinding): void;
200
200
  export declare function hasScopeBindingDenyOverlay(binding: ScopeBinding): boolean;
201
+ /**
202
+ * Issue #2271 bug 5: deny check that ignores purely time-based (sweep)
203
+ * tombstones. `sweepExpired` installs an 'expired'-lifecycle tombstone at
204
+ * revision+1 for every lapsed generation on ANY scope read — that is not a
205
+ * deliberate denial, and the durable CAS in the idle-revival path re-verifies
206
+ * the on-disk generation anyway. Deliberate revocation classes
207
+ * ('revoked'/'superseded') and any failed-revocation overlay still deny.
208
+ */
209
+ export declare function hasDeliberateScopeBindingDenyOverlay(binding: ScopeBinding): boolean;
210
+ /**
211
+ * Issue #2271 bug 5: remove a sweep-signature tombstone so a durable-CAS
212
+ * revival can be admitted in memory. Only 'expired'-lifecycle tombstones at
213
+ * or below the revived revision are cleared — deliberate revocations and any
214
+ * newer overlay are preserved.
215
+ */
216
+ export declare function clearSweepTombstoneForRevival(binding: ScopeBinding): void;
201
217
  /** Fail-closed overlay used only when durable revocation cannot be verified. */
202
218
  export declare function installFailedRevocationOverlay(binding: ScopeBinding, reason: Exclude<ScopeBindingLifecycleState, 'live'>): boolean;
203
219
  /**
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Agent model-resolution preflight (issue #2271 bug 4).
3
+ *
4
+ * Agent model strings (DEFAULT_MODELS plus user `agents.<role>.model`
5
+ * overrides) are handed to the OpenCode host unvalidated. When one does not
6
+ * resolve ("Model not found", "Forbidden"), dispatch-lanes classifies the
7
+ * failure as permanent, the affected agent never runs, and the plan-critic
8
+ * gate wedges into manual `approve_plan_critic` overrides because no APPROVED
9
+ * verdict is ever produced.
10
+ *
11
+ * This module validates configured model IDs against the live provider
12
+ * catalog (`client.provider.list()`). Every check is FAIL-OPEN: if the catalog
13
+ * is unreachable or malformed, results come back `unknown` and callers must
14
+ * proceed — the preflight only acts on a POSITIVE confirmation that a model
15
+ * does not resolve.
16
+ */
17
+ import type { OpencodeClient } from '@opencode-ai/sdk';
18
+ import type { PluginConfig } from '../config/schema.js';
19
+ /** Tight bound for the catalog HTTP call — it runs on init/doctor paths. */
20
+ export declare const PROVIDER_LIST_TIMEOUT_MS = 2000;
21
+ export interface ConfiguredAgentModel {
22
+ /** Agent role the model is configured for. */
23
+ agent: string;
24
+ /** Full model id in `provider/model` form. */
25
+ model: string;
26
+ /** Where the value came from. */
27
+ source: 'default' | 'override' | 'fallback';
28
+ }
29
+ export type ModelResolutionStatus = 'ok' | 'unresolved' | 'unknown';
30
+ export interface ModelResolution {
31
+ agent: string;
32
+ model: string;
33
+ source: ConfiguredAgentModel['source'];
34
+ status: ModelResolutionStatus;
35
+ /** Human-readable explanation for non-ok statuses. */
36
+ detail?: string;
37
+ }
38
+ export interface ModelPreflightResult {
39
+ /** False when the catalog could not be fetched — every entry is `unknown`. */
40
+ catalogAvailable: boolean;
41
+ resolutions: ModelResolution[];
42
+ }
43
+ /**
44
+ * Split a model id into its provider and model parts. Returns null for ids
45
+ * without a provider prefix (e.g. a bare model name) — those cannot be
46
+ * validated against a provider catalog.
47
+ */
48
+ export declare function splitModelId(model: string): {
49
+ provider: string;
50
+ model: string;
51
+ } | null;
52
+ /**
53
+ * Collect every model id the swarm could dispatch with: DEFAULT_MODELS
54
+ * entries, user agent overrides, and declared fallback_models. Overriding one
55
+ * role replaces its default (mirrors getModelForAgent precedence).
56
+ */
57
+ export declare function collectConfiguredAgentModels(config?: PluginConfig): ConfiguredAgentModel[];
58
+ /** Provider catalog snapshot: provider id → set of model ids. */
59
+ export type ProviderCatalog = Map<string, Set<string>>;
60
+ /** Test/gate seam: drop the cached catalogs (used after config changes and denials). */
61
+ export declare function invalidateProviderCatalogCache(): void;
62
+ /**
63
+ * Fetch the provider catalog. Returns null when the catalog cannot be
64
+ * obtained or parsed — callers fail open on null.
65
+ */
66
+ export declare function fetchProviderCatalog(client: OpencodeClient | null): Promise<ProviderCatalog | null>;
67
+ /**
68
+ * Validate collected models against a catalog. A model whose provider is
69
+ * absent from the catalog, or whose provider exists but does not list the
70
+ * model, is `unresolved` — but only when the catalog itself was successfully
71
+ * fetched (callers must treat a null catalog as fail-open, never unresolved).
72
+ */
73
+ export declare function resolveAgainstCatalog(models: ConfiguredAgentModel[], catalog: ProviderCatalog | null): ModelPreflightResult;
74
+ /**
75
+ * End-to-end preflight: collect configured models, fetch the catalog, and
76
+ * resolve. Fail-open on every catalog error.
77
+ */
78
+ export declare function runModelPreflight(config: PluginConfig | undefined, client: OpencodeClient | null): Promise<ModelPreflightResult>;
79
+ /**
80
+ * Resolves a single model id against the live catalog for gate preflights.
81
+ * Returns 'unknown' whenever the catalog cannot be fetched — gates must only
82
+ * block on 'unresolved'.
83
+ */
84
+ export declare function checkSingleModelResolution(model: string, client: OpencodeClient | null): Promise<ModelResolutionStatus>;
85
+ export declare const _internals: {
86
+ /** Injectable seam for the SDK catalog call (tests substitute this). */
87
+ providerList: (client: OpencodeClient) => Promise<({
88
+ data: undefined;
89
+ error: unknown;
90
+ } | {
91
+ data: {
92
+ all: Array<{
93
+ api?: string;
94
+ name: string;
95
+ env: Array<string>;
96
+ id: string;
97
+ npm?: string;
98
+ models: {
99
+ [key: string]: {
100
+ id: string;
101
+ name: string;
102
+ release_date: string;
103
+ attachment: boolean;
104
+ reasoning: boolean;
105
+ temperature: boolean;
106
+ tool_call: boolean;
107
+ cost?: {
108
+ input: number;
109
+ output: number;
110
+ cache_read?: number;
111
+ cache_write?: number;
112
+ context_over_200k?: {
113
+ input: number;
114
+ output: number;
115
+ cache_read?: number;
116
+ cache_write?: number;
117
+ };
118
+ };
119
+ limit: {
120
+ context: number;
121
+ output: number;
122
+ };
123
+ modalities?: {
124
+ input: Array<"text" | "audio" | "image" | "video" | "pdf">;
125
+ output: Array<"text" | "audio" | "image" | "video" | "pdf">;
126
+ };
127
+ experimental?: boolean;
128
+ status?: "alpha" | "beta" | "deprecated" | "active";
129
+ options: {
130
+ [key: string]: unknown;
131
+ };
132
+ headers?: {
133
+ [key: string]: string;
134
+ };
135
+ provider?: {
136
+ npm: string;
137
+ };
138
+ };
139
+ };
140
+ }>;
141
+ default: {
142
+ [key: string]: string;
143
+ };
144
+ connected: Array<string>;
145
+ };
146
+ error: undefined;
147
+ }) & {
148
+ request: Request;
149
+ response: Response;
150
+ }>;
151
+ };
@@ -109,6 +109,14 @@ export interface SessionReflectionData {
109
109
  knowledgeDelta?: KnowledgeDelta;
110
110
  skillViolations: SkillViolationSignal[];
111
111
  contradictionCandidates: ContradictionCandidate[];
112
+ /**
113
+ * Issue #2271 bug 6: rejection/circuit-breaker/manual-approval event counts
114
+ * by type, read from the session ledger (.swarm/events.jsonl). Gate denials
115
+ * throw in tool.execute.before and never increment ToolAggregate counters
116
+ * (denied calls do not fire toolAfter), so without this field a session
117
+ * full of gate rejections reports "0 tool failures or gate rejections".
118
+ */
119
+ ledgerRejections?: Record<string, number>;
112
120
  }
113
121
  export interface SessionReflectionResult {
114
122
  data: SessionReflectionData;
@@ -138,6 +146,21 @@ declare function gatherRetroLessonsAndTaxonomy(directory: string): Promise<{
138
146
  taxonomy: Record<string, number>;
139
147
  }>;
140
148
  declare function gatherGateFailures(directory: string): Promise<GateFailureSummary[]>;
149
+ /**
150
+ * Count rejection-class events in the session ledger. Reads the LIVE
151
+ * .swarm/events.jsonl first (finalize runs before archive in the close
152
+ * pipeline), falling back to the newest archived copy for a partially-run
153
+ * prior close. Fail-open: any read/parse problem yields empty counts.
154
+ *
155
+ * When `sessionId` is provided, events carrying a DIFFERENT session id are
156
+ * ignored so a per-session close summary cannot overcount sibling sessions'
157
+ * rejections in multi-swarm projects. Events with NO session field are still
158
+ * counted: several rejection writers emit none (coder_retry_circuit_breaker,
159
+ * architect_loop_detected), a sessionless event cannot be attributed to a
160
+ * sibling session, and dropping them would resurrect the bug-6 undercount in
161
+ * the standard close flow.
162
+ */
163
+ declare function gatherLedgerRejections(directory: string, sessionId?: string): Promise<Record<string, number>>;
141
164
  /**
142
165
  * Top skills by violation this session (issue #2077).
143
166
  *
@@ -242,6 +265,7 @@ export declare const _internals: {
242
265
  gatherAgentDispatches: typeof gatherAgentDispatches;
243
266
  gatherRetroLessonsAndTaxonomy: typeof gatherRetroLessonsAndTaxonomy;
244
267
  gatherGateFailures: typeof gatherGateFailures;
268
+ gatherLedgerRejections: typeof gatherLedgerRejections;
245
269
  buildReflectionDataSummary: typeof buildReflectionDataSummary;
246
270
  buildDeterministicReport: typeof buildDeterministicReport;
247
271
  gatherSkillViolations: typeof gatherSkillViolations;
@@ -1,6 +1,12 @@
1
1
  import { createObservation, toLegacyTelemetryLine } from './observability/index.js';
2
2
  import type { DelegationCostFields } from './services/cost-accounting.js';
3
- export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'reviewer_gate_decision' | 'phase_changed' | 'budget_updated' | 'context_pruned' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'no_op_strong_warning' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'gate_denial_loop'
3
+ export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'gate_parse_error' | 'reviewer_gate_decision' | 'phase_changed' | 'budget_updated' | 'context_pruned' | 'model_fallback'
4
+ /**
5
+ * Issue #2271 bug 4 — a configured agent model id was POSITIVELY confirmed
6
+ * unresolvable against the live provider catalog (distinct from a runtime
7
+ * model_fallback: this fires at preflight, before any dispatch attempt).
8
+ */
9
+ | 'model_unresolved' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'no_op_strong_warning' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'snapshot_failed' | 'gate_denial_loop'
4
10
  /**
5
11
  * Issue #2063 B5 — an ARMED execution episode reached the advisory rung:
6
12
  * `execution_stall_warn_calls` tool calls with no delegation completion, no
@@ -133,6 +139,11 @@ export declare const telemetry: {
133
139
  prunedTokensFreed: number;
134
140
  }): void;
135
141
  modelFallback(sessionId: string, agentName: string, fromModel: string, toModel: string, reason: string): void;
142
+ /**
143
+ * Issue #2271 bug 4 — preflight confirmed a configured model id does not
144
+ * resolve against the provider catalog. Emitted once per detected model.
145
+ */
146
+ modelUnresolved(agentName: string, model: string, detail: string): void;
136
147
  hardLimitHit(sessionId: string, agentName: string, limitType: string, value: number): void;
137
148
  revisionLimitHit(sessionId: string, agentName: string): void;
138
149
  loopDetected(sessionId: string, agentName: string, loopType: string): void;
@@ -14,6 +14,8 @@ export interface CompletionVerifyArgs {
14
14
  sessionID?: string;
15
15
  /** Explicit project root directory override */
16
16
  working_directory?: string;
17
+ /** Internal observational mode used by aggregate phase preflight. */
18
+ writeEvidence?: boolean;
17
19
  }
18
20
  /**
19
21
  * Execute the completion verification check
@@ -8,9 +8,9 @@ export declare const ArgsSchema: z.ZodObject<{
8
8
  verdicts: z.ZodArray<z.ZodObject<{
9
9
  agent: z.ZodEnum<{
10
10
  reviewer: "reviewer";
11
+ test_engineer: "test_engineer";
11
12
  critic: "critic";
12
13
  explorer: "explorer";
13
- test_engineer: "test_engineer";
14
14
  sme: "sme";
15
15
  }>;
16
16
  verdict: z.ZodEnum<{
@@ -54,11 +54,15 @@ export { pr_workflow_status } from './pr-workflow-status';
54
54
  export { type PreCheckBatchInput, type PreCheckBatchResult, pre_check_batch, runPreCheckBatch, type ToolResult, } from './pre-check-batch';
55
55
  export { executePreparePrFeedbackScope, prepare_pr_feedback_scope, } from './prepare-pr-feedback-scope';
56
56
  export { type QualityBudgetInput, type QualityBudgetResult, quality_budget, qualityBudget, } from './quality-budget';
57
+ export { executeRecordDirectiveOverride, record_directive_override, } from './record-directive-override';
58
+ export { executeRepairGateEvidence, repair_gate_evidence, } from './repair-gate-evidence';
59
+ export { executeRepairKnowledgeReceiptLedger, repair_knowledge_receipt_ledger, } from './repair-knowledge-receipt-ledger';
57
60
  export { buildWorkspaceGraph, type GraphEdge, type GraphNode, loadGraph, loadOrCreateGraph, type RepoGraph, resolveModuleSpecifier, saveGraph, updateGraphForFiles, } from './repo-graph';
58
61
  export { repo_map } from './repo-map';
59
62
  export { req_coverage } from './req-coverage';
60
63
  export { retrieve_lane_output } from './retrieve-lane-output';
61
64
  export { retrieve_summary } from './retrieve-summary';
65
+ export { createRunPhaseReviewTool, executeRunPhaseReview, run_phase_review, } from './run-phase-review';
62
66
  export { type SastScanFinding, type SastScanInput, type SastScanResult, sast_scan, sastScan, } from './sast-scan';
63
67
  export type { SavePlanArgs, SavePlanResult } from './save-plan';
64
68
  export { save_plan } from './save-plan';
@@ -74,6 +74,10 @@ export declare const TOOL_MANIFEST: {
74
74
  retrieve_lane_output: () => ToolDefinition;
75
75
  extract_code_blocks: () => ToolDefinition;
76
76
  phase_complete: () => ToolDefinition;
77
+ run_phase_review: () => ToolDefinition;
78
+ repair_gate_evidence: () => ToolDefinition;
79
+ repair_knowledge_receipt_ledger: () => ToolDefinition;
80
+ record_directive_override: () => ToolDefinition;
77
81
  save_plan: () => ToolDefinition;
78
82
  update_task_status: () => ToolDefinition;
79
83
  lint_spec: () => ToolDefinition;
@@ -3,10 +3,10 @@ import type { GateContext, GateResult } from './types.js';
3
3
  /**
4
4
  * Evidence-only final review gate.
5
5
  *
6
- * The model dispatch belongs to the phase_complete tool body. This gate performs
6
+ * Model dispatch belongs to the explicit run_phase_review recovery tool. This gate performs
7
7
  * one bounded, model-free scope collection at the terminal decision point, then
8
- * verifies that the persisted artifact and in-memory result both describe that
9
- * current scope and that the configured blocking policy is satisfied.
8
+ * verifies that the persisted artifact describes that current scope and that
9
+ * the configured blocking policy is satisfied.
10
10
  */
11
11
  export declare function runFinalReviewGate(ctx: GateContext): Promise<GateResult>;
12
12
  /**
@@ -40,13 +40,13 @@ export interface GateContext {
40
40
  loadedRetroBundle?: import('../../../config/evidence-schema').EvidenceBundle | null;
41
41
  /** Task id for the accepted retrospective bundle, if one was loaded */
42
42
  loadedRetroTaskId?: string | null;
43
- /** Exact scope produced by the model-dispatching phase_complete body. */
43
+ /** Legacy compatibility field; current final review derives persisted scope. */
44
44
  autoReviewScopeHash?: string;
45
45
  /** Completeness of the freshly collected in-memory review scope. */
46
46
  autoReviewScopeComplete?: boolean;
47
47
  /** Distinguishes ordinary phase review from the final durable plan phase. */
48
48
  autoReviewTrigger?: 'phase_completion' | 'plan_completion';
49
- /** Fresh in-memory disposition from the review run owned by phase_complete. */
49
+ /** Legacy compatibility field for callers carrying a fresh disposition. */
50
50
  autoReviewBlocked?: boolean;
51
51
  /** Machine-readable reason from the current review run, when blocked. */
52
52
  autoReviewBlockReason?: import('../../../review/engine').ReviewEngineResult['blockReason'];
@@ -0,0 +1,66 @@
1
+ import type { GateResult } from './gates/types.js';
2
+ export type PhaseGateOutcome = 'pass' | 'block' | 'error' | 'not_applicable';
3
+ export interface PhaseGateRecovery {
4
+ kind: 'tool' | 'command' | 'retry' | 'user_action';
5
+ action: string;
6
+ args?: Record<string, unknown>;
7
+ }
8
+ export interface PhaseGateEntry {
9
+ id: string;
10
+ code: string;
11
+ outcome: PhaseGateOutcome;
12
+ detail?: string;
13
+ evidenceRefs: string[];
14
+ responsibleActor: string;
15
+ recovery?: PhaseGateRecovery;
16
+ requiredRecoveryKind?: PhaseGateRecovery['kind'];
17
+ agentsDispatched: string[];
18
+ agentsMissing: string[];
19
+ warnings: string[];
20
+ recoveryGuidance?: string;
21
+ phase_council_required?: boolean;
22
+ final_council_required?: boolean;
23
+ retrospective_gate?: {
24
+ schema_valid: boolean;
25
+ gate_pass: boolean;
26
+ verdict?: 'pass' | 'fail';
27
+ };
28
+ }
29
+ export interface PhaseGateReport {
30
+ schemaVersion: 1;
31
+ phase: number;
32
+ outcome: 'pass' | 'block';
33
+ reportHash: string;
34
+ entries: PhaseGateEntry[];
35
+ }
36
+ export interface PhaseGateCheck {
37
+ id: string;
38
+ responsibleActor: string;
39
+ applicable?: boolean;
40
+ notApplicableDetail?: string;
41
+ run: () => Promise<GateResult>;
42
+ timeoutMs?: number;
43
+ }
44
+ export declare function collectPhaseGateReport(input: {
45
+ phase: number;
46
+ checks: readonly PhaseGateCheck[];
47
+ }): Promise<PhaseGateReport>;
48
+ export declare function formatPhaseGateCompatibility(report: PhaseGateReport): {
49
+ success: boolean;
50
+ phase: number;
51
+ status: 'success' | 'blocked' | 'incomplete';
52
+ reason?: string;
53
+ message?: string;
54
+ agentsDispatched: string[];
55
+ agentsMissing: string[];
56
+ warnings: string[];
57
+ gate_report: PhaseGateReport;
58
+ retrospective_gate?: {
59
+ schema_valid: boolean;
60
+ gate_pass: boolean;
61
+ verdict?: 'pass' | 'fail';
62
+ };
63
+ recovery_guidance?: string;
64
+ phase_council_required?: boolean;
65
+ final_council_required?: boolean;
66
+ };
@@ -0,0 +1 @@
1
+ export declare function computePhaseEvidenceSnapshot(directory: string): string;
@@ -3,6 +3,10 @@
3
3
  * Core implementation - gathers data, enforces policy, writes event, resets state.
4
4
  */
5
5
  import type { ToolDefinition } from '@opencode-ai/plugin/tool';
6
+ import { savePlan } from '../plan/manager';
7
+ import type { ReviewModelDispatcher } from '../review/contracts.js';
8
+ import type { ReviewAgentModelRegistry } from '../review/runtime.js';
9
+ import { runArchitectureSupervisorGate, runCompletionVerifyGate, runDriftGate, runFinalCouncilGate, runFinalReviewGate, runHallucinationGate, runMutationGate, runPhaseCouncilGate } from './phase-complete/gates/index.js';
6
10
  /** Narrow seam for receipt/plan ordering tests. */
7
11
  export declare const phaseCompleteReceiptInternals: {
8
12
  recordPhaseCloseIntent: (directory: string, phase: string, sessionId?: string, taskId?: string) => Promise<import("../hooks/knowledge-receipt-ledger.js").ReceiptLedgerResult<{
@@ -12,8 +16,67 @@ export declare const phaseCompleteReceiptInternals: {
12
16
  event_id: string;
13
17
  }>>;
14
18
  };
15
- import type { ReviewModelDispatcher } from '../review/contracts.js';
16
- import type { ReviewAgentModelRegistry } from '../review/runtime.js';
19
+ /** Narrow seam for guarded-plan commit tests. */
20
+ export declare const phaseCompleteCommitInternals: {
21
+ savePlan: (directory: string, plan: {
22
+ schema_version: "1.0.0";
23
+ title: string;
24
+ swarm: string;
25
+ phases: {
26
+ id: number;
27
+ name: string;
28
+ status: "blocked" | "complete" | "completed" | "pending" | "in_progress" | "closed";
29
+ tasks: {
30
+ id: string;
31
+ phase: number;
32
+ status: "blocked" | "completed" | "pending" | "in_progress" | "closed";
33
+ size: "small" | "medium" | "large";
34
+ description: string;
35
+ depends: string[];
36
+ files_touched: string[];
37
+ acceptance?: string | undefined;
38
+ evidence_path?: string | undefined;
39
+ blocked_reason?: string | undefined;
40
+ fr_refs?: string[] | undefined;
41
+ }[];
42
+ type?: "code" | "non-code" | undefined;
43
+ required_agents?: string[] | undefined;
44
+ }[];
45
+ current_phase?: number | undefined;
46
+ migration_status?: "migrated" | "native" | "migration_failed" | undefined;
47
+ specMtime?: string | undefined;
48
+ specHash?: string | undefined;
49
+ execution_profile?: {
50
+ parallelization_enabled: boolean;
51
+ max_concurrent_tasks: number;
52
+ council_parallel: boolean;
53
+ locked: boolean;
54
+ auto_proceed: boolean;
55
+ commit_after_each_completed_task: boolean;
56
+ planning_profile?: "balanced" | "strict" | undefined;
57
+ } | undefined;
58
+ }, options?: {
59
+ preserveCompletedStatuses?: boolean;
60
+ acknowledged_removals?: import("../plan/manager").AcknowledgedRemovals;
61
+ planLockAlreadyHeld?: boolean;
62
+ staleProjectionReconcile?: {
63
+ expectedSeq: number;
64
+ expectedLedgerHash: string;
65
+ };
66
+ preCommitCheck?: () => void;
67
+ } | undefined) => Promise<void>;
68
+ };
69
+ /** Injectable observational gates for aggregate-preflight regression tests. */
70
+ export declare const phaseCompletePreflightInternals: {
71
+ runCompletionVerifyGate: typeof runCompletionVerifyGate;
72
+ runDriftGate: typeof runDriftGate;
73
+ runHallucinationGate: typeof runHallucinationGate;
74
+ runMutationGate: typeof runMutationGate;
75
+ runPhaseCouncilGate: typeof runPhaseCouncilGate;
76
+ runArchitectureSupervisorGate: typeof runArchitectureSupervisorGate;
77
+ runFinalReviewGate: typeof runFinalReviewGate;
78
+ runFinalCouncilGate: typeof runFinalCouncilGate;
79
+ };
17
80
  /**
18
81
  * Arguments for the phase_complete tool
19
82
  */
@@ -52,7 +115,7 @@ declare function allCompletedTasksHavePassedGateEvidence(directory: string, task
52
115
  * Execute the phase_complete tool
53
116
  * Gathers data, enforces policy, writes event, resets state
54
117
  */
55
- export declare function executePhaseComplete(args: PhaseCompleteArgs, workingDirectory?: string, directory?: string, runtime?: PhaseCompleteRuntime): Promise<string>;
118
+ export declare function executePhaseComplete(args: PhaseCompleteArgs, workingDirectory?: string, directory?: string, _runtime?: PhaseCompleteRuntime): Promise<string>;
56
119
  /** @internal exported for testing only */
57
120
  export declare function _buildOutputJson(outputData: {
58
121
  phase: number;