opencode-swarm 7.140.4 → 7.140.6

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 (100) hide show
  1. package/.opencode/skills/plan/SKILL.md +40 -12
  2. package/.opencode/skills/swarm-pr-review/SKILL.md +2 -4
  3. package/.opencode/skills/swarm-pr-review/references/lane-output-recoverability.md +54 -0
  4. package/dist/agents/architect.d.ts +2 -1
  5. package/dist/background/candidate-contract.d.ts +1 -1
  6. package/dist/background/pending-delegations.d.ts +5 -0
  7. package/dist/background/pr-review-trigger-contract.d.ts +36 -0
  8. package/dist/cli/{config-doctor-qqe6172n.js → config-doctor-y5qeh18c.js} +3 -3
  9. package/dist/cli/{core-52k057mf.js → core-pwd9604e.js} +2 -2
  10. package/dist/cli/{curation-policy-9291bdat.js → curation-policy-avvb56x2.js} +6 -6
  11. package/dist/cli/curator-llm-factory-96pnc23w.js +61 -0
  12. package/dist/cli/{curator-04xqq68e.js → curator-q1nchgpg.js} +36 -36
  13. package/dist/cli/{evidence-summary-service-em58myd7.js → evidence-summary-service-18142mr3.js} +14 -11
  14. package/dist/cli/gate-evidence-smn2wqft.js +51 -0
  15. package/dist/cli/guardrail-explain-kyd89z8z.js +62 -0
  16. package/dist/cli/{guardrail-log-vb5zkegf.js → guardrail-log-cahp1ews.js} +4 -4
  17. package/dist/cli/{hive-promoter-z09khawt.js → hive-promoter-vcbcvcsh.js} +36 -36
  18. package/dist/cli/{index-ysa38bnr.js → index-1p72dtym.js} +3 -3
  19. package/dist/cli/{index-s8g7jh1k.js → index-2778hhh7.js} +2 -2
  20. package/dist/cli/{index-v3xhc7kg.js → index-4s7xgzbm.js} +1 -1
  21. package/dist/cli/{index-wk8s1m7b.js → index-4zxrkk1h.js} +217 -15
  22. package/dist/cli/{index-hz0refz4.js → index-56rqw2hs.js} +70 -29
  23. package/dist/cli/{index-djbhe0yh.js → index-5qd5vt2d.js} +38 -38
  24. package/dist/cli/{index-35qep0v7.js → index-912qz4y0.js} +88 -88
  25. package/dist/cli/{index-2rb3x0fk.js → index-92n3d5ky.js} +7 -7
  26. package/dist/cli/{index-ryq97w1x.js → index-bjqpdr83.js} +4 -4
  27. package/dist/cli/{index-c5kr20nz.js → index-c432knmy.js} +1 -1
  28. package/dist/cli/{index-v3x7j9ey.js → index-dtqjxfw9.js} +2 -2
  29. package/dist/cli/{index-hfwzxh3j.js → index-e58e3v0v.js} +12 -10
  30. package/dist/cli/{index-bfhwtdsw.js → index-epvhf50h.js} +3 -3
  31. package/dist/cli/{index-vrmkg8fm.js → index-fejfzy2j.js} +9 -9
  32. package/dist/cli/{index-mpytsq6k.js → index-h01wb18g.js} +2 -2
  33. package/dist/cli/{index-hxvkfx6t.js → index-jqsfsqbx.js} +15 -2
  34. package/dist/cli/{index-bn17ycxn.js → index-m9xrdjn0.js} +1 -1
  35. package/dist/cli/{index-a1fjhx4w.js → index-nakkgkkt.js} +37922 -35984
  36. package/dist/cli/index-p04qrwck.js +43 -0
  37. package/dist/cli/{index-arza4m4j.js → index-p2ty3eee.js} +2 -2
  38. package/dist/cli/{index-4hp8nvwb.js → index-p8kk34am.js} +3 -3
  39. package/dist/cli/{index-1kyex7z2.js → index-qwm6vdyv.js} +32 -1
  40. package/dist/cli/{index-dtam929z.js → index-qy1nq52t.js} +1 -1
  41. package/dist/cli/{index-rrb6cz2f.js → index-s1v0wza5.js} +6 -2
  42. package/dist/cli/{index-w4etfamq.js → index-t5pytnca.js} +2 -2
  43. package/dist/cli/{index-tj04dj06.js → index-thp186x0.js} +2 -2
  44. package/dist/cli/index-tjqzr3jc.js +623 -0
  45. package/dist/cli/{index-mrpfd1jx.js → index-vh05t3w5.js} +1 -1
  46. package/dist/cli/{index-7begd9aq.js → index-y9q9f6ms.js} +4 -4
  47. package/dist/cli/{index-v1an91bq.js → index-z0z9pe7b.js} +5 -5
  48. package/dist/cli/{index-hfjvepk2.js → index-z3s0a44b.js} +3 -3
  49. package/dist/cli/{index-pp5m7xga.js → index-zd4qhnr7.js} +70 -34
  50. package/dist/cli/{index-b8zgtz81.js → index-zsrtt42s.js} +34 -1
  51. package/dist/cli/index.js +35 -35
  52. package/dist/cli/{knowledge-escalator-gdjnwszd.js → knowledge-escalator-gj58za4g.js} +12 -12
  53. package/dist/cli/{knowledge-events-581x4q7n.js → knowledge-events-3m5jnnv6.js} +10 -10
  54. package/dist/cli/{knowledge-link-axx45d1h.js → knowledge-link-m9p80f4r.js} +5 -5
  55. package/dist/cli/{knowledge-store-ttg33482.js → knowledge-store-0vy8wbzd.js} +6 -6
  56. package/dist/cli/{knowledge-validator-8kywqt8b.js → knowledge-validator-mvcs8wf6.js} +8 -8
  57. package/dist/cli/{pending-delegations-btwqsvz4.js → pending-delegations-cxx9tezp.js} +4 -4
  58. package/dist/cli/{pr-subscriptions-83y1cdwv.js → pr-subscriptions-2sfnb599.js} +4 -4
  59. package/dist/cli/{runner-fh3r41nw.js → runner-mky3vvht.js} +6 -6
  60. package/dist/cli/{scan-cursor-j8ytdpam.js → scan-cursor-wznc7p7p.js} +7 -7
  61. package/dist/cli/{schema-6xfqtpvn.js → schema-k596bhds.js} +2 -2
  62. package/dist/cli/{scope-persistence-8c72jrgp.js → scope-persistence-0ny5fn07.js} +10 -5
  63. package/dist/cli/{skill-generator-n8vm1yhn.js → skill-generator-vrks0jjj.js} +14 -14
  64. package/dist/cli/{telemetry-fb44gpba.js → telemetry-0x6kszvk.js} +1 -1
  65. package/dist/cli/{worktree-collision-ownership-f28r473k.js → worktree-collision-ownership-wm5pse49.js} +8 -8
  66. package/dist/cli/worktree-isolation-zgk7314k.js +102 -0
  67. package/dist/cli/worktree-provisioning-owner-sjh7te1h.js +22 -0
  68. package/dist/commands/acknowledge-spec-drift.d.ts +4 -5
  69. package/dist/config/evidence-schema.d.ts +3 -3
  70. package/dist/config/index.d.ts +2 -2
  71. package/dist/config/plan-schema.d.ts +8 -0
  72. package/dist/config/schema.d.ts +2 -2
  73. package/dist/council/council-evidence-writer.d.ts +1 -1
  74. package/dist/gate-evidence.d.ts +117 -4
  75. package/dist/hooks/delegation-gate.d.ts +21 -0
  76. package/dist/hooks/pr-workflow-gate.d.ts +20 -0
  77. package/dist/index.js +775 -748
  78. package/dist/plan/ledger.d.ts +55 -0
  79. package/dist/plan/manager.d.ts +9 -0
  80. package/dist/plan/planning-profile.d.ts +27 -0
  81. package/dist/services/spec-drift-recovery.d.ts +84 -0
  82. package/dist/session/snapshot-writer.d.ts +3 -1
  83. package/dist/state.d.ts +19 -17
  84. package/dist/summaries/schema.d.ts +2 -2
  85. package/dist/tools/convene-council.d.ts +6 -6
  86. package/dist/tools/save-plan.d.ts +8 -0
  87. package/dist/tools/submit-phase-council-verdicts.d.ts +6 -6
  88. package/dist/tools/tool-metadata.d.ts +28 -28
  89. package/dist/tools/update-task-status.d.ts +13 -0
  90. package/dist/tools/write-final-council-evidence.d.ts +6 -6
  91. package/dist/types/events.d.ts +29 -1
  92. package/dist/workflow/coder-settlement.d.ts +62 -0
  93. package/dist/workflow/task-repair.d.ts +30 -0
  94. package/dist/workflow/task-terminal.d.ts +52 -0
  95. package/package.json +1 -1
  96. package/dist/cli/curator-llm-factory-cfm8fhdw.js +0 -61
  97. package/dist/cli/gate-evidence-ezxfkb22.js +0 -32
  98. package/dist/cli/guardrail-explain-pn1bcgfz.js +0 -62
  99. package/dist/cli/index-d181x9zr.js +0 -71
  100. package/dist/cli/index-dtyeabmj.js +0 -239
@@ -78,6 +78,28 @@ declare function getLedgerPath(directory: string): string;
78
78
  * Get the path to plan.json
79
79
  */
80
80
  declare function getPlanJsonPath(directory: string): string;
81
+ /**
82
+ * Durable atomic write: write `data` to `tempPath`, fsync the file descriptor so
83
+ * the bytes are flushed to stable storage, then atomically rename it over
84
+ * `targetPath`.
85
+ *
86
+ * WHY the fsync matters: a plain `writeFileSync` returns once the data is in the
87
+ * OS page cache, not on disk. A crash/power-loss between the write and the
88
+ * subsequent `rename` can publish a zero-length or partially-written temp file as
89
+ * the canonical ledger — silent truncation that later reads cannot distinguish
90
+ * from a legitimately short ledger. Forcing an fsync before the rename guarantees
91
+ * the temp file's bytes are durable before it becomes the canonical file.
92
+ *
93
+ * NOTE: the containing-directory fsync (which would also durably persist the
94
+ * rename's directory entry so the *rename itself* survives a crash) is
95
+ * intentionally OMITTED. The rename is atomic on POSIX, and the ledger's
96
+ * crash-consistency contract only requires that a published ledger never be
97
+ * partially-written; it tolerates losing the very last rename on power-loss (the
98
+ * prior canonical file is then still intact). Omitting the dir-fsync avoids the
99
+ * portability and cost concerns of opening the directory as a file descriptor.
100
+ */
101
+ declare function writeFileFsyncedThenRename(tempPath: string, targetPath: string, data: string | Uint8Array): void;
102
+ declare function fsyncRecoveryDirectory(directory: string): void;
81
103
  /**
82
104
  * Compute a SHA-256 hash of the plan state.
83
105
  * Uses deterministic JSON serialization for consistent hashing.
@@ -163,6 +185,13 @@ export declare function initLedger(directory: string, planId: string, initialPla
163
185
  export declare function appendLedgerEvent(directory: string, eventInput: LedgerEventInput, options?: {
164
186
  expectedSeq?: number;
165
187
  expectedHash?: string;
188
+ /**
189
+ * CAS against the durable ledger tail rather than plan.json. This is used
190
+ * only by stale-projection reconciliation, where plan.json intentionally
191
+ * differs from the ledger and a snapshot adopts that exact projection as
192
+ * the new authoritative state.
193
+ */
194
+ expectedLedgerHash?: string;
166
195
  planHashAfter?: string;
167
196
  }): Promise<LedgerEvent>;
168
197
  /**
@@ -244,7 +273,31 @@ export declare function takeSnapshotEvent(directory: string, plan: Plan, options
244
273
  source?: string;
245
274
  approvalMetadata?: Record<string, unknown>;
246
275
  payloadHashOverride?: string;
276
+ /** CAS binding for stale-projection recovery snapshots. */
277
+ expectedSeq?: number;
278
+ /** Previous durable hash used to preserve the ledger hash chain. */
279
+ expectedLedgerHash?: string;
247
280
  }): Promise<LedgerEvent>;
281
+ export interface TruncatedLedgerRecoveryResult {
282
+ archivePath: string;
283
+ archiveSha256: string;
284
+ recoveryRoot: LedgerEvent;
285
+ }
286
+ /**
287
+ * Recover an explicitly verified stale projection from a malformed ledger.
288
+ *
289
+ * A snapshot appended after an unparsable line is not durable recovery because
290
+ * integrity replay stops at that line after restart. This transaction first
291
+ * writes and fsyncs a byte-for-byte archive of the complete canonical ledger,
292
+ * then atomically replaces the canonical file with a new `plan_created` root
293
+ * that embeds the verified projection and links to the preserved archive.
294
+ * A crash therefore leaves either the old canonical ledger or the new complete
295
+ * root; it never creates a missing-ledger window or silently discards history.
296
+ */
297
+ export declare function replaceTruncatedLedgerWithRecoveryRoot(directory: string, plan: Plan, expected: {
298
+ seq: number;
299
+ ledgerHash: string;
300
+ }): Promise<TruncatedLedgerRecoveryResult>;
248
301
  /**
249
302
  * Options for replayFromLedger
250
303
  */
@@ -461,5 +514,7 @@ export declare const _internals: {
461
514
  loadLastPlanCriticApprovedSnapshot: typeof loadLastPlanCriticApprovedSnapshot;
462
515
  getLedgerPath: typeof getLedgerPath;
463
516
  getPlanJsonPath: typeof getPlanJsonPath;
517
+ writeFileFsyncedThenRename: typeof writeFileFsyncedThenRename;
518
+ fsyncRecoveryDirectory: typeof fsyncRecoveryDirectory;
464
519
  };
465
520
  export {};
@@ -146,6 +146,15 @@ export declare function savePlan(directory: string, plan: Plan, options?: {
146
146
  acknowledged_removals?: AcknowledgedRemovals;
147
147
  /** True only when the caller already owns the canonical plan.json lock. */
148
148
  planLockAlreadyHeld?: boolean;
149
+ /**
150
+ * Narrow recovery mode for a semantically unreadable ledger tail. The
151
+ * caller must bind the exact tail observed while validating an unchanged
152
+ * `_ledgerReplayStale` projection.
153
+ */
154
+ staleProjectionReconcile?: {
155
+ expectedSeq: number;
156
+ expectedLedgerHash: string;
157
+ };
149
158
  }): Promise<void>;
150
159
  /**
151
160
  * Rebuild plan from ledger events.
@@ -0,0 +1,27 @@
1
+ import type { ExecutionProfile, Plan } from '../config/plan-schema';
2
+ import type { PluginConfig } from '../config/schema';
3
+ export type PlanningProfile = NonNullable<NonNullable<ExecutionProfile['planning_profile']>>;
4
+ export interface ResolvedPlanningProfile {
5
+ effective: PlanningProfile;
6
+ persisted: PlanningProfile | undefined;
7
+ source: 'incoming' | 'persisted' | 'repository_default' | 'legacy_locked_default';
8
+ }
9
+ export type PlanningProfileDirectiveContext = 'repository_default' | 'runtime';
10
+ /**
11
+ * Render the authoritative planning ceremony for the architect prompt.
12
+ *
13
+ * Keep this policy next to the resolver so static agent construction and
14
+ * per-turn persisted-plan injection cannot drift into different meanings for
15
+ * the same resolved profile.
16
+ */
17
+ export declare function renderPlanningProfileDirective(resolution: ResolvedPlanningProfile, context?: PlanningProfileDirectiveContext): string;
18
+ interface ResolvePlanningProfileOptions {
19
+ directory: string;
20
+ incomingExecutionProfile?: Partial<ExecutionProfile>;
21
+ existingExecutionProfile?: Plan['execution_profile'];
22
+ resetStatuses?: boolean;
23
+ config?: Pick<PluginConfig, 'execution_mode'>;
24
+ }
25
+ export declare function resolvePlanningProfile({ directory, incomingExecutionProfile, existingExecutionProfile, resetStatuses, config, }: ResolvePlanningProfileOptions): ResolvedPlanningProfile;
26
+ export declare function normalizeExecutionProfileForHash(profile: Plan['execution_profile']): Record<string, unknown> | undefined;
27
+ export {};
@@ -0,0 +1,84 @@
1
+ import { validateSwarmPath } from '../hooks/utils.js';
2
+ import { tryAcquireLock } from '../parallel/file-locks.js';
3
+ import { takeSnapshotEvent } from '../plan/ledger.js';
4
+ import { loadPlanJsonOnly, savePlan } from '../plan/manager.js';
5
+ import { readEffectiveSpecSync } from '../sdd/effective-spec.js';
6
+ import type { SpecDriftAcknowledgedEvent, SpecDriftRepairedEvent } from '../types/events.js';
7
+ import { bunWrite } from '../utils/bun-compat.js';
8
+ import { assertProjectRoot } from '../utils/project-boundary.js';
9
+ import { invalidateCachedArtifact } from '../utils/swarm-artifact-cache.js';
10
+ type RecoveryMode = 'acknowledge' | 'repair';
11
+ type RecoveryActor = 'cli' | 'spec_write' | 'unknown' | 'user';
12
+ type RecoveryState = 'COMMITTED' | 'PREPARED';
13
+ interface SpecStalenessMarker {
14
+ planTitle: string;
15
+ phase: number;
16
+ specHash_plan: string | null;
17
+ specHash_current: string | null;
18
+ reason: string;
19
+ timestamp: string;
20
+ }
21
+ interface SpecDriftRecoveryWal {
22
+ version: 2;
23
+ mode: RecoveryMode;
24
+ state: RecoveryState;
25
+ transitionId: string;
26
+ markerHash: string;
27
+ planTitle: string;
28
+ phase: number;
29
+ previousHash: string | null;
30
+ newHash: string | null;
31
+ specContent: string | null;
32
+ actor: RecoveryActor;
33
+ recordedAt: string;
34
+ }
35
+ export interface SpecDriftRecoveryResult {
36
+ status: 'applied' | 'cleanup_pending' | 'corrupt_marker' | 'failed' | 'no_marker' | 'retry_later';
37
+ mode: RecoveryMode;
38
+ message: string;
39
+ phase?: number;
40
+ planTitle?: string;
41
+ previousHash?: string | null;
42
+ newHash?: string | null;
43
+ transitionId?: string;
44
+ }
45
+ export declare const _internals: {
46
+ appendEvent: typeof appendEvent;
47
+ assertProjectRoot: typeof assertProjectRoot;
48
+ bunWrite: typeof bunWrite;
49
+ invalidateCachedArtifact: typeof invalidateCachedArtifact;
50
+ loadPlanJsonOnly: typeof loadPlanJsonOnly;
51
+ now: typeof now;
52
+ parseMarker: typeof parseMarker;
53
+ parseWal: typeof parseWal;
54
+ readEffectiveSpecSync: typeof readEffectiveSpecSync;
55
+ readFileText: typeof readFileText;
56
+ savePlan: typeof savePlan;
57
+ tryAcquireLock: typeof tryAcquireLock;
58
+ takeSnapshotEvent: typeof takeSnapshotEvent;
59
+ unlinkIfExists: typeof unlinkIfExists;
60
+ validateSwarmPath: typeof validateSwarmPath;
61
+ verifyEventPresence: typeof verifyEventPresence;
62
+ ensureSnapshotEvent: typeof ensureSnapshotEvent;
63
+ verifySnapshot: typeof verifySnapshot;
64
+ writeWal: typeof writeWal;
65
+ };
66
+ declare function now(): string;
67
+ declare function parseMarker(raw: string): SpecStalenessMarker | null;
68
+ declare function parseWal(raw: string): SpecDriftRecoveryWal | null;
69
+ declare function readFileText(filePath: string): Promise<string | null>;
70
+ declare function unlinkIfExists(filePath: string): Promise<boolean>;
71
+ declare function writeWal(walPath: string, wal: SpecDriftRecoveryWal): Promise<void>;
72
+ declare function verifySnapshot(snapshotPath: string, currentSpec: {
73
+ content: string;
74
+ } | null): Promise<void>;
75
+ declare function ensureSnapshotEvent(directory: string, plan: NonNullable<Awaited<ReturnType<typeof loadPlanJsonOnly>>>, transitionId: string): Promise<void>;
76
+ declare function appendEvent(eventsPath: string, event: SpecDriftAcknowledgedEvent | SpecDriftRepairedEvent): Promise<void>;
77
+ declare function verifyEventPresence(eventsPath: string, eventType: 'spec_drift_acknowledged' | 'spec_drift_repaired', transitionId: string): Promise<boolean>;
78
+ export declare function reconcileSpecDrift(directory: string, options: {
79
+ mode: RecoveryMode;
80
+ actor: RecoveryActor;
81
+ /** Caller already holds the spec.md lock across the canonical spec write. */
82
+ specLockAlreadyHeld?: boolean;
83
+ }): Promise<SpecDriftRecoveryResult>;
84
+ export {};
@@ -2,6 +2,7 @@
2
2
  * Session snapshot writer for OpenCode Swarm plugin.
3
3
  * Serializes swarmState to .swarm/session/state.json using atomic write (temp-file + rename).
4
4
  */
5
+ import { TASK_WORKFLOW_SCHEMA_MARKER } from '../gate-evidence.js';
5
6
  import type { AgentSessionState, DelegationEntry, ToolAggregate } from '../state';
6
7
  import { swarmState } from '../state';
7
8
  /**
@@ -114,8 +115,9 @@ export interface SerializedInvocationWindow {
114
115
  * Snapshot data structure written to disk
115
116
  */
116
117
  export interface SnapshotData {
117
- version: 1 | 2;
118
+ version: 1 | 2 | 3;
118
119
  writtenAt: number;
120
+ workflowSchema?: typeof TASK_WORKFLOW_SCHEMA_MARKER;
119
121
  toolAggregates: Record<string, ToolAggregate>;
120
122
  activeAgent: Record<string, string>;
121
123
  delegationChains: Record<string, DelegationEntry[]>;
package/dist/state.d.ts CHANGED
@@ -10,6 +10,7 @@ import type { OpencodeClient } from '@opencode-ai/sdk';
10
10
  import type { CouncilAgent } from './council/types';
11
11
  import { type QaGates } from './db/qa-gate-profile.js';
12
12
  import { type EnvironmentProfile } from './environment/profile.js';
13
+ import { type TaskWorkflowMetadata } from './gate-evidence';
13
14
  import type { EscalationTracker } from './prm/escalation.js';
14
15
  import type { PatternMatch } from './prm/types.js';
15
16
  import { AgentRunContext } from './state/agent-run-context.js';
@@ -63,7 +64,14 @@ export interface PrSubscriptionState {
63
64
  * Per-task workflow state for gate progression tracking.
64
65
  * Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
65
66
  */
66
- export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'complete';
67
+ export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'rework_required' | 'complete' | 'blocked';
68
+ export interface TaskWorkflowCacheEntry {
69
+ generation: number;
70
+ retryCount: number;
71
+ lastOutcome: TaskWorkflowMetadata['lastOutcome'];
72
+ lastTransitionId: string | null;
73
+ updatedAt: string;
74
+ }
67
75
  /**
68
76
  * Upper bound for per-session task file-attribution entries.
69
77
  *
@@ -187,6 +195,8 @@ export interface AgentSessionState {
187
195
  qaSkipTaskIds: string[];
188
196
  /** Per-task workflow state — taskId → current state */
189
197
  taskWorkflowStates: Map<string, TaskWorkflowState>;
198
+ /** Exact-task workflow cache keyed by taskId. Durable evidence remains authoritative. */
199
+ taskWorkflowCache?: Map<string, TaskWorkflowCacheEntry>;
190
200
  /**
191
201
  * PR 2 Stage B barrier: per-task set of completed Stage B agents.
192
202
  * Order-independent — either 'reviewer' or 'test_engineer' may complete first.
@@ -213,6 +223,8 @@ export interface AgentSessionState {
213
223
  */
214
224
  rewarded?: boolean;
215
225
  }>;
226
+ /** Generation captured when the first member of a task council is dispatched. */
227
+ taskCouncilWorkflowGeneration?: Map<string, number>;
216
228
  /**
217
229
  * Per-(task,round) required council members for the next submission attempt.
218
230
  * Key format: `${taskId}:${roundNumber}`.
@@ -1026,6 +1038,7 @@ export declare function resetModifiedFilesForTask(session: AgentSessionState, ta
1026
1038
  * Epic sessions retain it until `epic_record_divergence` consumes the entry.
1027
1039
  */
1028
1040
  export declare function completeModifiedFilesForTask(session: AgentSessionState, taskId: string): void;
1041
+ export declare function updateTaskWorkflowCache(session: AgentSessionState, taskId: string, overrides: Partial<TaskWorkflowCacheEntry>): void;
1029
1042
  /**
1030
1043
  * Advance a task's workflow state. Validates forward-only transitions.
1031
1044
  * Throws 'INVALID_TASK_STATE_TRANSITION: [taskId] [current] → [requested]' on illegal transition.
@@ -1061,23 +1074,12 @@ export declare function canAdvanceTaskState(session: AgentSessionState, taskId:
1061
1074
  requireAllMembers?: boolean;
1062
1075
  }): boolean;
1063
1076
  /**
1064
- * Advance the per-task workflow state machine AND persist the corresponding
1065
- * plan.json status at meaningful workflow boundaries.
1066
- *
1067
- * The two-layer model splits in-memory workflow state (Layer 1, fast, used by
1068
- * gates) from the durable plan (Layer 2, projected to plan.md). Without this
1069
- * bridge, council APPROVE → 'complete' updates Layer 1 only and plan.md goes
1070
- * stale. This helper closes the gap by mapping:
1071
- * - 'coder_delegated' → plan.json status 'in_progress'
1072
- * - 'complete' → plan.json status 'completed'
1073
- * Other transitions are in-memory only (the task is already in_progress on disk
1074
- * once coder_delegated has fired).
1075
- *
1076
- * Persistence errors are logged and swallowed so a transient disk failure does
1077
- * not break the in-memory state machine — matches the existing defensive
1078
- * pattern around advanceTaskState call sites.
1077
+ * Legacy compatibility wrapper for diagnostic-only intermediate projections.
1078
+ * Durable coder/terminal boundaries must use the exact-task evidence reducer
1079
+ * and the plan→evidence transaction/WAL; this wrapper intentionally refuses
1080
+ * those states so no caller can recreate the former split-brain writer.
1079
1081
  */
1080
- export declare function advanceTaskStateAndPersist(session: AgentSessionState, taskId: string, newState: TaskWorkflowState, directory: string, options?: {
1082
+ export declare function advanceTaskStateAndPersist(session: AgentSessionState, taskId: string, newState: TaskWorkflowState, _directory: string, options?: {
1081
1083
  telemetrySessionId?: string;
1082
1084
  emitTelemetry?: boolean;
1083
1085
  }, councilConfig?: {
@@ -22,8 +22,8 @@ export declare const MAX_LIST_ITEMS = 5;
22
22
  /** Verdict vocabulary — mirrors the phase-council gate (APPROVE | CONCERNS | REJECT). */
23
23
  export declare const SupervisorVerdictSchema: z.ZodEnum<{
24
24
  APPROVE: "APPROVE";
25
- REJECT: "REJECT";
26
25
  CONCERNS: "CONCERNS";
26
+ REJECT: "REJECT";
27
27
  }>;
28
28
  export type SupervisorVerdict = z.infer<typeof SupervisorVerdictSchema>;
29
29
  /** Count whitespace-delimited words in a string. */
@@ -130,8 +130,8 @@ export declare const ArchitectureSupervisorReportSchema: z.ZodObject<{
130
130
  phase: z.ZodNumber;
131
131
  verdict: z.ZodEnum<{
132
132
  APPROVE: "APPROVE";
133
- REJECT: "REJECT";
134
133
  CONCERNS: "CONCERNS";
134
+ REJECT: "REJECT";
135
135
  }>;
136
136
  findings: z.ZodDefault<z.ZodArray<z.ZodObject<{
137
137
  severity: z.ZodEnum<{
@@ -8,23 +8,23 @@ 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
+ critic: "critic";
12
12
  explorer: "explorer";
13
+ test_engineer: "test_engineer";
13
14
  sme: "sme";
14
- critic: "critic";
15
15
  }>;
16
16
  verdict: z.ZodEnum<{
17
17
  APPROVE: "APPROVE";
18
- REJECT: "REJECT";
19
18
  CONCERNS: "CONCERNS";
19
+ REJECT: "REJECT";
20
20
  }>;
21
21
  confidence: z.ZodNumber;
22
22
  findings: z.ZodArray<z.ZodObject<{
23
23
  severity: z.ZodEnum<{
24
- LOW: "LOW";
25
- MEDIUM: "MEDIUM";
26
- HIGH: "HIGH";
27
24
  CRITICAL: "CRITICAL";
25
+ HIGH: "HIGH";
26
+ MEDIUM: "MEDIUM";
27
+ LOW: "LOW";
28
28
  }>;
29
29
  category: z.ZodString;
30
30
  location: z.ZodString;
@@ -82,6 +82,12 @@ export interface SavePlanArgs {
82
82
  * Omit to leave the current profile unchanged.
83
83
  */
84
84
  execution_profile?: Partial<ExecutionProfile>;
85
+ /**
86
+ * Narrow recovery mode for stale plan.json projections whose ledger replay
87
+ * previously failed. When true, save_plan will only accept an unchanged
88
+ * semantic re-save that reconverges plan.json with the authoritative ledger.
89
+ */
90
+ reconcile_ledger_projection?: boolean;
85
91
  }
86
92
  /**
87
93
  * Result from executing save_plan
@@ -115,6 +121,8 @@ interface RequirementCoverageResult {
115
121
  missing: RequirementCoverageEntry[];
116
122
  blocking_missing: RequirementCoverageEntry[];
117
123
  }
124
+ export declare function isLedgerProjectionReconcileRequest(args: Pick<SavePlanArgs, 'reconcile_ledger_projection'>): boolean;
125
+ export declare function isPureLedgerProjectionReconcileRequest(args: SavePlanArgs): boolean;
118
126
  /**
119
127
  * Detect template placeholder content (e.g., [task], [Project], [description], [N]).
120
128
  * These patterns indicate the LLM reproduced template examples literally rather than
@@ -8,23 +8,23 @@ 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
+ critic: "critic";
12
12
  explorer: "explorer";
13
+ test_engineer: "test_engineer";
13
14
  sme: "sme";
14
- critic: "critic";
15
15
  }>;
16
16
  verdict: z.ZodEnum<{
17
17
  APPROVE: "APPROVE";
18
- REJECT: "REJECT";
19
18
  CONCERNS: "CONCERNS";
19
+ REJECT: "REJECT";
20
20
  }>;
21
21
  confidence: z.ZodNumber;
22
22
  findings: z.ZodArray<z.ZodObject<{
23
23
  severity: z.ZodEnum<{
24
- LOW: "LOW";
25
- MEDIUM: "MEDIUM";
26
- HIGH: "HIGH";
27
24
  CRITICAL: "CRITICAL";
25
+ HIGH: "HIGH";
26
+ MEDIUM: "MEDIUM";
27
+ LOW: "LOW";
28
28
  }>;
29
29
  category: z.ZodString;
30
30
  location: z.ZodString;
@@ -34,7 +34,7 @@ export interface ToolMeta {
34
34
  export declare const TOOL_METADATA: {
35
35
  diff: {
36
36
  description: string;
37
- agents: ("reviewer" | "test_engineer" | "coder" | "critic_oversight" | "critic_finding_validator" | "architect")[];
37
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "coder" | "test_engineer" | "architect")[];
38
38
  prWorkflow: {
39
39
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
40
40
  capability: "observe";
@@ -50,7 +50,7 @@ export declare const TOOL_METADATA: {
50
50
  };
51
51
  syntax_check: {
52
52
  description: string;
53
- agents: ("test_engineer" | "coder" | "architect")[];
53
+ agents: ("coder" | "test_engineer" | "architect")[];
54
54
  prWorkflow: {
55
55
  modes: "PR_REVIEW"[];
56
56
  capability: "validate";
@@ -66,7 +66,7 @@ export declare const TOOL_METADATA: {
66
66
  };
67
67
  imports: {
68
68
  description: string;
69
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_finding_validator" | "architect" | "researcher" | "docs_design")[];
69
+ agents: ("reviewer" | "critic" | "critic_finding_validator" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier")[];
70
70
  prWorkflow: {
71
71
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
72
72
  capability: "observe";
@@ -74,7 +74,7 @@ export declare const TOOL_METADATA: {
74
74
  };
75
75
  lint: {
76
76
  description: string;
77
- agents: ("reviewer" | "coder" | "critic_finding_validator" | "architect")[];
77
+ agents: ("reviewer" | "critic_finding_validator" | "coder" | "architect")[];
78
78
  prWorkflow: {
79
79
  modes: "PR_REVIEW"[];
80
80
  capability: "validate";
@@ -98,7 +98,7 @@ export declare const TOOL_METADATA: {
98
98
  };
99
99
  build_check: {
100
100
  description: string;
101
- agents: ("test_engineer" | "coder" | "architect")[];
101
+ agents: ("coder" | "test_engineer" | "architect")[];
102
102
  };
103
103
  pre_check_batch: {
104
104
  description: string;
@@ -114,15 +114,15 @@ export declare const TOOL_METADATA: {
114
114
  };
115
115
  symbols: {
116
116
  description: string;
117
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_finding_validator" | "architect" | "researcher" | "docs_design" | "spec_writer")[];
117
+ agents: ("reviewer" | "critic" | "critic_finding_validator" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "designer" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "spec_writer")[];
118
118
  };
119
119
  complexity_hotspots: {
120
120
  description: string;
121
- agents: ("reviewer" | "test_engineer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect" | "researcher")[];
121
+ agents: ("reviewer" | "critic" | "critic_oversight" | "critic_finding_validator" | "explorer" | "test_engineer" | "architect" | "sme" | "researcher" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier")[];
122
122
  };
123
123
  schema_drift: {
124
124
  description: string;
125
- agents: ("docs" | "explorer" | "sme" | "architect" | "researcher")[];
125
+ agents: ("explorer" | "architect" | "sme" | "researcher" | "docs")[];
126
126
  prWorkflow: {
127
127
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
128
128
  capability: "observe";
@@ -130,7 +130,7 @@ export declare const TOOL_METADATA: {
130
130
  };
131
131
  todo_extract: {
132
132
  description: string;
133
- agents: ("docs" | "explorer" | "architect" | "researcher")[];
133
+ agents: ("explorer" | "architect" | "researcher" | "docs")[];
134
134
  prWorkflow: {
135
135
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
136
136
  capability: "observe";
@@ -210,7 +210,7 @@ export declare const TOOL_METADATA: {
210
210
  };
211
211
  pkg_audit: {
212
212
  description: string;
213
- agents: ("reviewer" | "test_engineer" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect")[];
213
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "test_engineer" | "architect" | "critic_hallucination_verifier")[];
214
214
  prWorkflow: {
215
215
  modes: "PR_REVIEW"[];
216
216
  capability: "validate";
@@ -238,7 +238,7 @@ export declare const TOOL_METADATA: {
238
238
  };
239
239
  test_runner: {
240
240
  description: string;
241
- agents: ("reviewer" | "test_engineer" | "critic_finding_validator" | "architect")[];
241
+ agents: ("reviewer" | "critic_finding_validator" | "test_engineer" | "architect")[];
242
242
  prWorkflow: {
243
243
  modes: "PR_REVIEW"[];
244
244
  capability: "validate";
@@ -246,7 +246,7 @@ export declare const TOOL_METADATA: {
246
246
  };
247
247
  test_impact: {
248
248
  description: string;
249
- agents: ("reviewer" | "test_engineer" | "critic_oversight" | "critic_finding_validator" | "architect")[];
249
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "test_engineer" | "architect")[];
250
250
  prWorkflow: {
251
251
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
252
252
  capability: "observe";
@@ -262,11 +262,11 @@ export declare const TOOL_METADATA: {
262
262
  };
263
263
  detect_domains: {
264
264
  description: string;
265
- agents: ("docs" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_oversight" | "architect" | "docs_design")[];
265
+ agents: ("critic" | "critic_oversight" | "explorer" | "architect" | "sme" | "docs" | "docs_design" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier")[];
266
266
  };
267
267
  git_blame: {
268
268
  description: string;
269
- agents: ("reviewer" | "explorer" | "critic_finding_validator" | "architect")[];
269
+ agents: ("reviewer" | "critic_finding_validator" | "explorer" | "architect")[];
270
270
  prWorkflow: {
271
271
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
272
272
  capability: "observe";
@@ -274,7 +274,7 @@ export declare const TOOL_METADATA: {
274
274
  };
275
275
  gitingest: {
276
276
  description: string;
277
- agents: ("docs" | "explorer" | "architect")[];
277
+ agents: ("explorer" | "architect" | "docs")[];
278
278
  prWorkflow: {
279
279
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
280
280
  capability: "observe";
@@ -282,7 +282,7 @@ export declare const TOOL_METADATA: {
282
282
  };
283
283
  retrieve_summary: {
284
284
  description: string;
285
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_finding_validator" | "architect" | "docs_design" | "spec_writer")[];
285
+ agents: ("reviewer" | "critic" | "critic_finding_validator" | "coder" | "test_engineer" | "architect" | "sme" | "docs" | "docs_design" | "designer" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "spec_writer")[];
286
286
  prWorkflow: {
287
287
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
288
288
  capability: "observe";
@@ -298,7 +298,7 @@ export declare const TOOL_METADATA: {
298
298
  };
299
299
  extract_code_blocks: {
300
300
  description: string;
301
- agents: ("test_engineer" | "coder" | "docs" | "designer" | "docs_design" | "spec_writer")[];
301
+ agents: ("coder" | "test_engineer" | "docs" | "docs_design" | "designer" | "spec_writer")[];
302
302
  };
303
303
  phase_complete: {
304
304
  description: string;
@@ -362,7 +362,7 @@ export declare const TOOL_METADATA: {
362
362
  };
363
363
  knowledge_recall: {
364
364
  description: string;
365
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "critic_finding_validator" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
365
+ agents: ("reviewer" | "critic" | "critic_oversight" | "critic_finding_validator" | "explorer" | "coder" | "test_engineer" | "architect" | "sme" | "docs" | "docs_design" | "designer" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
366
366
  };
367
367
  knowledge_remove: {
368
368
  description: string;
@@ -378,11 +378,11 @@ export declare const TOOL_METADATA: {
378
378
  };
379
379
  search: {
380
380
  description: string;
381
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect" | "researcher" | "docs_design" | "skill_improver" | "spec_writer")[];
381
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "explorer" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "designer" | "critic_hallucination_verifier" | "skill_improver" | "spec_writer")[];
382
382
  };
383
383
  ast_grep: {
384
384
  description: string;
385
- agents: ("test_engineer" | "coder" | "docs" | "explorer" | "sme" | "critic_hallucination_verifier" | "architect" | "researcher" | "docs_design" | "spec_writer")[];
385
+ agents: ("explorer" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "critic_hallucination_verifier" | "spec_writer")[];
386
386
  };
387
387
  actionlint_scan: {
388
388
  description: string;
@@ -418,7 +418,7 @@ export declare const TOOL_METADATA: {
418
418
  };
419
419
  batch_symbols: {
420
420
  description: string;
421
- agents: ("reviewer" | "explorer" | "critic_hallucination_verifier" | "critic_oversight" | "critic_finding_validator" | "architect")[];
421
+ agents: ("reviewer" | "critic_oversight" | "critic_finding_validator" | "explorer" | "architect" | "critic_hallucination_verifier")[];
422
422
  };
423
423
  suggest_patch: {
424
424
  description: string;
@@ -426,15 +426,15 @@ export declare const TOOL_METADATA: {
426
426
  };
427
427
  req_coverage: {
428
428
  description: string;
429
- agents: ("critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_oversight" | "spec_writer")[];
429
+ agents: ("critic" | "critic_oversight" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "spec_writer")[];
430
430
  };
431
431
  get_approved_plan: {
432
432
  description: string;
433
- agents: ("critic" | "critic_drift_verifier" | "critic_oversight")[];
433
+ agents: ("critic" | "critic_oversight" | "critic_drift_verifier")[];
434
434
  };
435
435
  repo_map: {
436
436
  description: string;
437
- agents: ("reviewer" | "coder" | "explorer" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_oversight" | "critic_finding_validator" | "architect")[];
437
+ agents: ("reviewer" | "critic" | "critic_oversight" | "critic_finding_validator" | "explorer" | "coder" | "architect" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor")[];
438
438
  prWorkflow: {
439
439
  modes: ("PR_REVIEW" | "PR_FEEDBACK")[];
440
440
  capability: "observe";
@@ -502,7 +502,7 @@ export declare const TOOL_METADATA: {
502
502
  };
503
503
  knowledge_receipt: {
504
504
  description: string;
505
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "sme" | "critic" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "critic_finding_validator" | "architect" | "docs_design" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
505
+ agents: ("reviewer" | "critic" | "critic_finding_validator" | "coder" | "test_engineer" | "architect" | "sme" | "docs" | "docs_design" | "designer" | "critic_sounding_board" | "critic_drift_verifier" | "critic_hallucination_verifier" | "critic_architecture_supervisor" | "curator_init" | "curator_phase" | "skill_improver" | "spec_writer")[];
506
506
  };
507
507
  knowledge_archive: {
508
508
  description: string;
@@ -518,7 +518,7 @@ export declare const TOOL_METADATA: {
518
518
  };
519
519
  swarm_command: {
520
520
  description: string;
521
- agents: ("reviewer" | "test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "critic" | "critic_finding_validator" | "architect" | "researcher" | "docs_design")[];
521
+ agents: ("reviewer" | "critic" | "critic_finding_validator" | "explorer" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "designer")[];
522
522
  };
523
523
  dispatch_lanes: {
524
524
  description: string;
@@ -534,7 +534,7 @@ export declare const TOOL_METADATA: {
534
534
  };
535
535
  summarize_work: {
536
536
  description: string;
537
- agents: ("test_engineer" | "coder" | "docs" | "designer" | "explorer" | "sme" | "architect" | "researcher" | "docs_design")[];
537
+ agents: ("explorer" | "coder" | "test_engineer" | "architect" | "sme" | "researcher" | "docs" | "docs_design" | "designer")[];
538
538
  };
539
539
  write_architecture_supervisor_evidence: {
540
540
  description: string;
@@ -566,7 +566,7 @@ export declare const TOOL_METADATA: {
566
566
  };
567
567
  swarm_apply_patch: {
568
568
  description: string;
569
- agents: ("test_engineer" | "coder")[];
569
+ agents: ("coder" | "test_engineer")[];
570
570
  };
571
571
  external_skill_discover: {
572
572
  description: string;