opencode-swarm 7.183.1 → 7.184.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
- package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
- package/dist/background/delegation-health.d.ts +1 -1
- package/dist/background/index.d.ts +1 -0
- package/dist/background/pr-event-delivery.d.ts +29 -14
- package/dist/background/pr-event-subscribers.d.ts +6 -5
- package/dist/background/pr-feedback-event-queue.d.ts +19 -2
- package/dist/background/pr-feedback-loop-runtime.d.ts +75 -0
- package/dist/background/pr-feedback-loop.d.ts +47 -12
- package/dist/cli/{coder-settlement-rserb0hm.js → coder-settlement-yvpewr52.js} +15 -12
- package/dist/cli/{config-doctor-r4fmzprn.js → config-doctor-qgwpvrbz.js} +7 -3
- package/dist/cli/{core-rzek3e2n.js → core-9qt388hq.js} +4 -4
- package/dist/cli/{curation-policy-g0jjwrg5.js → curation-policy-49f8jx48.js} +7 -6
- package/dist/cli/{curator-drift-a0r5krfx.js → curator-drift-wf0sm2te.js} +9 -9
- package/dist/cli/{curator-v84tfqcr.js → curator-ffz5pxgc.js} +40 -39
- package/dist/cli/curator-llm-factory-drs36v1q.js +75 -0
- package/dist/cli/{dispatch-p5zjg5e6.js → dispatch-cv89p2y1.js} +1 -1
- package/dist/cli/{evidence-summary-service-t4csk176.js → evidence-summary-service-8dfzjnxe.js} +21 -20
- package/dist/cli/{gate-evidence-3z04zprn.js → gate-evidence-aa5q30f4.js} +14 -7
- package/dist/cli/guardrail-explain-9g5y2gjm.js +76 -0
- package/dist/cli/{guardrail-log-cbzdh4qj.js → guardrail-log-0g51p94w.js} +8 -8
- package/dist/cli/{guardrail-reset-5e75rz44.js → guardrail-reset-dcbmt2wr.js} +40 -39
- package/dist/cli/{hive-promoter-f54nrhqn.js → hive-promoter-2g8nga0y.js} +40 -39
- package/dist/cli/{index-31e105jf.js → index-046psajf.js} +80 -2
- package/dist/cli/{index-rhw6m7s9.js → index-0874kghs.js} +9 -3
- package/dist/cli/{index-6h81yvyc.js → index-131ay7x1.js} +3 -3
- package/dist/cli/{index-raws06d3.js → index-2c91cxdv.js} +4 -4
- package/dist/cli/{index-9f930sy8.js → index-32vszgv0.js} +3 -3
- package/dist/cli/{index-0bpr8vag.js → index-3n5zsp31.js} +2 -2
- package/dist/cli/{index-b26hje53.js → index-3skvygca.js} +5 -5
- package/dist/cli/{index-w81jmdkt.js → index-456awy1p.js} +2 -2
- package/dist/cli/{index-hb1zqz50.js → index-475bkab8.js} +2 -2
- package/dist/cli/{index-80qhm8aq.js → index-49ptc9xx.js} +10 -4
- package/dist/cli/{index-bsjwchw7.js → index-57swfxyp.js} +8 -8
- package/dist/cli/{index-y5hhkx1n.js → index-5ppx86w1.js} +38 -18
- package/dist/cli/{index-jb7ywm4w.js → index-6b427dy8.js} +6 -6
- package/dist/cli/{index-3qy7v4k1.js → index-6cvdk98y.js} +2 -2
- package/dist/cli/{index-hsvsz3mj.js → index-6g664sy8.js} +1 -1
- package/dist/cli/{index-8me6m6ew.js → index-76abqm8d.js} +2 -2
- package/dist/cli/{index-z425p51d.js → index-7hvy33gc.js} +271 -80
- package/dist/cli/{index-4xr4gtwd.js → index-7p4ym4q3.js} +1 -1
- package/dist/cli/{index-j8ty457v.js → index-aghd9kcx.js} +2 -2
- package/dist/cli/{index-h01p5ygy.js → index-ar2gsn6b.js} +8 -8
- package/dist/cli/{index-ak1dd17g.js → index-dbshccrr.js} +3 -3
- package/dist/cli/{index-908k7jhw.js → index-depfky1j.js} +158 -27
- package/dist/cli/{index-5t08vc6m.js → index-earq3mda.js} +1 -1
- package/dist/cli/{index-6dm6ettv.js → index-ejb7ejhd.js} +1 -1
- package/dist/cli/{index-3rb5gs4w.js → index-f0nj3d8z.js} +1 -1
- package/dist/cli/{index-qjzbs971.js → index-gsgy1psq.js} +4 -4
- package/dist/cli/{index-jk05g11c.js → index-jc8pcf0r.js} +7 -7
- package/dist/cli/{index-mt0s67hg.js → index-jkxef52n.js} +2 -2
- package/dist/cli/{index-wpn7ftw1.js → index-jvk95e6y.js} +2 -2
- package/dist/cli/{index-5cve9g2b.js → index-k53a69vb.js} +6 -6
- package/dist/cli/{index-1xnse449.js → index-mc72pk74.js} +1 -1
- package/dist/cli/{index-w196wb3a.js → index-mz4zz59c.js} +42 -41
- package/dist/cli/{index-4hnk9npg.js → index-n107956q.js} +5 -5
- package/dist/cli/{index-gaykghrm.js → index-qczxr0wh.js} +12 -10
- package/dist/cli/{index-nazzb4em.js → index-s7bseqza.js} +3220 -1893
- package/dist/cli/{index-dg3f2sqq.js → index-t7hmqgjy.js} +90 -141
- package/dist/cli/{index-08x7gsnf.js → index-w9hxzcz4.js} +2 -2
- package/dist/cli/{index-bqphhrwf.js → index-wfdx7yw2.js} +39 -15
- package/dist/cli/{index-xtysafzj.js → index-wsb0wbw6.js} +40 -39
- package/dist/cli/{index-nmh0s6dg.js → index-wy3zpwjy.js} +1 -1
- package/dist/cli/{index-tt705bap.js → index-x1gyqgze.js} +7 -7
- package/dist/cli/index-xf69xty9.js +105 -0
- package/dist/cli/{index-ydefv5fn.js → index-ya32wfkp.js} +4 -2
- package/dist/cli/{index-1hnknn34.js → index-yk0r42nr.js} +4 -4
- package/dist/cli/{index-77650pyg.js → index-zzvxj02e.js} +3 -3
- package/dist/cli/index.js +41 -40
- package/dist/cli/{knowledge-escalator-cs7fjgy0.js → knowledge-escalator-pt21q3eh.js} +14 -13
- package/dist/cli/{knowledge-events-262c1jg2.js → knowledge-events-hp96b55k.js} +12 -11
- package/dist/cli/{knowledge-link-8kcms7pj.js → knowledge-link-ap2274vm.js} +6 -5
- package/dist/cli/{knowledge-store-yjrkfens.js → knowledge-store-rnw1e7zp.js} +7 -6
- package/dist/cli/{knowledge-validator-t98cvpt5.js → knowledge-validator-xy7r6eyx.js} +9 -8
- package/dist/cli/{mcp-wj6143vj.js → mcp-3nd85kww.js} +15 -1
- package/dist/cli/mcp.d.ts +1 -0
- package/dist/cli/{model-preflight-tz4ar9ys.js → model-preflight-xe0chjad.js} +40 -39
- package/dist/cli/{pending-delegations-vvbkqe24.js → pending-delegations-2pdngdzq.js} +13 -12
- package/dist/cli/{pr-subscriptions-maeppcws.js → pr-subscriptions-hxxwszyr.js} +13 -12
- package/dist/cli/{pr-workflow-gate-en54gabv.js → pr-workflow-gate-m37ynr6h.js} +40 -39
- package/dist/cli/{runner-618229m8.js → runner-yz3ysehf.js} +7 -6
- package/dist/cli/{scan-cursor-sxwh1ax8.js → scan-cursor-be9hbq1v.js} +8 -7
- package/dist/cli/{schema-fb8vm14k.js → schema-j17hv98z.js} +3 -1
- package/dist/cli/{scope-persistence-sc2zhr15.js → scope-persistence-rmt56rma.js} +16 -15
- package/dist/cli/{server-7ksq9wr7.js → server-wzrb59mh.js} +40 -39
- package/dist/cli/{skill-generator-ccmq47cm.js → skill-generator-vsfya55z.js} +16 -15
- package/dist/cli/{snapshot-coordination-init-h8eg88w2.js → snapshot-coordination-init-pc8ykvh8.js} +40 -39
- package/dist/cli/{speckit-checkoff-vkqn317p.js → speckit-checkoff-j407j8ew.js} +4 -4
- package/dist/cli/{telemetry-vqyy5nha.js → telemetry-39zmx4fp.js} +2 -2
- package/dist/cli/{workspace-snapshot-t22m6gbd.js → workspace-snapshot-0q1n1xq5.js} +4 -4
- package/dist/cli/{worktree-collision-ownership-8hr7aycc.js → worktree-collision-ownership-je4fb407.js} +14 -13
- package/dist/cli/{worktree-isolation-gwq3y9tf.js → worktree-isolation-27rt584e.js} +40 -39
- package/dist/commands/doctor.d.ts +5 -0
- package/dist/config/schema.d.ts +15 -0
- package/dist/context/role-filter.d.ts +2 -0
- package/dist/db/qa-gate-session-override.d.ts +12 -12
- package/dist/gate-evidence.d.ts +43 -1
- package/dist/hooks/final-context-accounting.d.ts +3 -2
- package/dist/hooks/guardrails/index.d.ts +13 -7
- package/dist/hooks/host-boundary.d.ts +10 -0
- package/dist/hooks/system-enhancer.d.ts +9 -2
- package/dist/hooks/system-guidance-carrier.d.ts +18 -0
- package/dist/index.js +520 -514
- package/dist/plan/ledger.d.ts +20 -4
- package/dist/plan/manager.d.ts +20 -2
- package/dist/services/config-doctor.d.ts +24 -0
- package/dist/services/injection-budget.d.ts +56 -8
- package/dist/session/hydration-ownership.d.ts +39 -12
- package/dist/session/snapshot-coordination-init.d.ts +11 -4
- package/dist/session/snapshot-reader.d.ts +9 -4
- package/dist/session/snapshot-writer.d.ts +2 -3
- package/dist/state.d.ts +35 -5
- package/dist/tools/phase-complete.d.ts +1 -0
- package/dist/tools/save-plan.d.ts +12 -0
- package/dist/tools/update-task-status.d.ts +1 -1
- package/dist/utils/project-boundary.d.ts +32 -1
- package/dist/workflow/coder-settlement.d.ts +8 -0
- package/dist/workflow/task-terminal.d.ts +2 -1
- package/dist/workflow/workflow-wal-schema.d.ts +2 -0
- package/opencode-swarm.schema.json +8 -0
- package/package.json +1 -1
- package/dist/cli/curator-llm-factory-xp4hgd8r.js +0 -74
- package/dist/cli/guardrail-explain-j2y5sj4d.js +0 -75
package/dist/plan/ledger.d.ts
CHANGED
|
@@ -226,7 +226,9 @@ export declare function readLedgerEvents(directory: string): Promise<LedgerEvent
|
|
|
226
226
|
* @param directory - The working directory
|
|
227
227
|
* @param planId - Unique identifier for the plan
|
|
228
228
|
*/
|
|
229
|
-
export declare function initLedger(directory: string, planId: string, initialPlanHash?: string, initialPlan?: Plan
|
|
229
|
+
export declare function initLedger(directory: string, planId: string, initialPlanHash?: string, initialPlan?: Plan, options?: {
|
|
230
|
+
preCommitCheck?: () => void;
|
|
231
|
+
}): Promise<void>;
|
|
230
232
|
/**
|
|
231
233
|
* Read and validate the current plan epoch identity without creating,
|
|
232
234
|
* adopting, or appending any ledger state.
|
|
@@ -264,6 +266,8 @@ export declare function appendLedgerEvent(directory: string, eventInput: LedgerE
|
|
|
264
266
|
*/
|
|
265
267
|
expectedLedgerHash?: string;
|
|
266
268
|
planHashAfter?: string;
|
|
269
|
+
/** Synchronous authority fence inside the evidence lock. */
|
|
270
|
+
preCommitCheck?: () => void;
|
|
267
271
|
}): Promise<LedgerEvent>;
|
|
268
272
|
/**
|
|
269
273
|
* Append a ledger event with optimistic retry on stale-writer conflicts.
|
|
@@ -303,6 +307,7 @@ export declare function appendLedgerEventWithRetry(directory: string, eventInput
|
|
|
303
307
|
maxRetries?: number;
|
|
304
308
|
backoffMs?: number;
|
|
305
309
|
verifyValid?: () => Promise<boolean> | boolean;
|
|
310
|
+
preCommitCheck?: () => void;
|
|
306
311
|
}): Promise<LedgerEvent | null>;
|
|
307
312
|
/**
|
|
308
313
|
* Take a snapshot with bounded retry and always-visible warning logging (FR-004).
|
|
@@ -351,6 +356,8 @@ export declare function takeSnapshotEvent(directory: string, plan: Plan, options
|
|
|
351
356
|
expectedSeq?: number;
|
|
352
357
|
/** Previous durable hash used to preserve the ledger hash chain. */
|
|
353
358
|
expectedLedgerHash?: string;
|
|
359
|
+
/** Synchronous authority fence immediately before ledger append. */
|
|
360
|
+
preCommitCheck?: () => void;
|
|
354
361
|
}): Promise<LedgerEvent>;
|
|
355
362
|
export interface TruncatedLedgerRecoveryResult {
|
|
356
363
|
archivePath: string;
|
|
@@ -379,13 +386,17 @@ export declare function clearPlanLedgerForReset(directory: string): Promise<void
|
|
|
379
386
|
* Existing JSONL bytes are content-addressed before the SQLite transaction;
|
|
380
387
|
* the portable export is published only after the new SQLite root commits.
|
|
381
388
|
*/
|
|
382
|
-
export declare function replacePlanLedgerWithRoot(directory: string, plan: Plan, source: string
|
|
389
|
+
export declare function replacePlanLedgerWithRoot(directory: string, plan: Plan, source: string, options?: {
|
|
390
|
+
preCommitCheck?: () => void;
|
|
391
|
+
}): Promise<void>;
|
|
383
392
|
/**
|
|
384
393
|
* Options for replayFromLedger
|
|
385
394
|
*/
|
|
386
395
|
interface ReplayOptions {
|
|
387
396
|
/** If true, use the latest snapshot to speed up replay */
|
|
388
397
|
useSnapshot?: boolean;
|
|
398
|
+
/** Optional authority fence for recovery-side durable publications. */
|
|
399
|
+
preCommitCheck?: () => void;
|
|
389
400
|
}
|
|
390
401
|
/**
|
|
391
402
|
* Result of a status-aware ledger replay.
|
|
@@ -449,7 +460,8 @@ export declare function peekPlanFromLedger(directory: string, _options?: ReplayO
|
|
|
449
460
|
* `replayWithIntegrity`'s bug — it hid genuine replay failures).
|
|
450
461
|
*
|
|
451
462
|
* @param directory - The working directory
|
|
452
|
-
* @param _options - Optional replay options
|
|
463
|
+
* @param _options - Optional replay options, including an authority fence for
|
|
464
|
+
* recovery-side quarantine publications
|
|
453
465
|
* @returns {@link ReplayStatusResult} with plan, truncated flag, and bad suffix
|
|
454
466
|
*/
|
|
455
467
|
export declare function replayFromLedgerWithStatus(directory: string, _options?: ReplayOptions): Promise<ReplayStatusResult>;
|
|
@@ -526,10 +538,14 @@ export interface QuarantineResult {
|
|
|
526
538
|
*
|
|
527
539
|
* @param directory - The working directory
|
|
528
540
|
* @param badSuffix - The corrupted content to quarantine
|
|
541
|
+
* @param options - Optional authority fence checked immediately before writing
|
|
542
|
+
* the quarantine side file
|
|
529
543
|
* @returns {@link QuarantineResult} with the written path (or null) and the
|
|
530
544
|
* number of parseable lines salvaged from the suffix
|
|
531
545
|
*/
|
|
532
|
-
export declare function quarantineLedgerSuffix(directory: string, badSuffix: string
|
|
546
|
+
export declare function quarantineLedgerSuffix(directory: string, badSuffix: string, options?: {
|
|
547
|
+
preCommitCheck?: () => void;
|
|
548
|
+
}): Promise<QuarantineResult>;
|
|
533
549
|
/**
|
|
534
550
|
* Metadata describing an approved snapshot recovered from the ledger.
|
|
535
551
|
*/
|
package/dist/plan/manager.d.ts
CHANGED
|
@@ -6,6 +6,15 @@
|
|
|
6
6
|
export declare class PlanConcurrentModificationError extends Error {
|
|
7
7
|
constructor(message: string);
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* Internal control-flow error used to stop every recovery rung when the
|
|
11
|
+
* coordinator's captured hydration generation is no longer authoritative.
|
|
12
|
+
* Broad availability catches must rethrow this instead of trying a fallback
|
|
13
|
+
* that could publish stale durable state.
|
|
14
|
+
*/
|
|
15
|
+
export declare class PlanRecoverySupersededError extends Error {
|
|
16
|
+
constructor(message?: string);
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Thrown when savePlan detects that the incoming plan would silently drop one
|
|
11
20
|
* or more tasks from the prior plan without the caller acknowledging the
|
|
@@ -61,6 +70,7 @@ export declare const _internals: {
|
|
|
61
70
|
readPlanJsonUtf8: typeof readPlanJsonUtf8;
|
|
62
71
|
readPlanFileUtf8: typeof readPlanFileUtf8;
|
|
63
72
|
verifyWrittenPlanJson: typeof verifyWrittenPlanJson;
|
|
73
|
+
writeRebuildPlanMarkdown: typeof writeRebuildPlanMarkdown;
|
|
64
74
|
ledgerExists: typeof ledgerExists;
|
|
65
75
|
replayFromLedger: typeof replayFromLedger;
|
|
66
76
|
loadLastApprovedPlan: typeof loadLastApprovedPlan;
|
|
@@ -91,6 +101,7 @@ export declare function retryCasWithBackoff(directory: string, eventInput: Ledge
|
|
|
91
101
|
planHashAfter?: string;
|
|
92
102
|
verifyValid?: () => Promise<boolean> | boolean;
|
|
93
103
|
maxRetries?: number;
|
|
104
|
+
preCommitCheck?: () => void;
|
|
94
105
|
}): Promise<LedgerEvent | null>;
|
|
95
106
|
/**
|
|
96
107
|
* Load plan.json ONLY without auto-migration from plan.md.
|
|
@@ -114,7 +125,9 @@ export declare function isPlanMdInSync(directory: string, plan: Plan, cache?: Ma
|
|
|
114
125
|
/**
|
|
115
126
|
* Regenerate plan.md from valid plan.json (auto-heal case 1).
|
|
116
127
|
*/
|
|
117
|
-
export declare function regeneratePlanMarkdown(directory: string, plan: Plan
|
|
128
|
+
export declare function regeneratePlanMarkdown(directory: string, plan: Plan, options?: {
|
|
129
|
+
preCommitCheck?: () => void;
|
|
130
|
+
}): Promise<void>;
|
|
118
131
|
/**
|
|
119
132
|
* Load and validate plan from .swarm/plan.json with auto-heal sync.
|
|
120
133
|
*
|
|
@@ -128,7 +141,9 @@ export declare function regeneratePlanMarkdown(directory: string, plan: Plan): P
|
|
|
128
141
|
* 3. .swarm/plan.md exists only -> migrate from plan.md, save both files, return Plan
|
|
129
142
|
* 4. Neither exists -> return null
|
|
130
143
|
*/
|
|
131
|
-
export declare function loadPlan(directory: string, cache?: Map<string, Promise<string | null
|
|
144
|
+
export declare function loadPlan(directory: string, cache?: Map<string, Promise<string | null>>, options?: {
|
|
145
|
+
preCommitCheck?: () => void;
|
|
146
|
+
}): Promise<RuntimePlan | null>;
|
|
132
147
|
/**
|
|
133
148
|
* Recovery-path helper for callers that legitimately need to replace the
|
|
134
149
|
* plan task set without explicit per-id acknowledgement (e.g. rebuilding
|
|
@@ -146,6 +161,7 @@ export declare function loadPlan(directory: string, cache?: Map<string, Promise<
|
|
|
146
161
|
export declare function savePlanWithAutoAcknowledgedRemovals(directory: string, plan: Plan, source: string, reason: string, options?: {
|
|
147
162
|
preserveCompletedStatuses?: boolean;
|
|
148
163
|
planLockAlreadyHeld?: boolean;
|
|
164
|
+
preCommitCheck?: () => void;
|
|
149
165
|
}): Promise<{
|
|
150
166
|
removedCount: number;
|
|
151
167
|
}>;
|
|
@@ -216,6 +232,7 @@ export declare function savePlan(directory: string, plan: Plan, options?: {
|
|
|
216
232
|
*/
|
|
217
233
|
preCommitCheck?: () => void;
|
|
218
234
|
}): Promise<PlanSaveDurability>;
|
|
235
|
+
declare function writeRebuildPlanMarkdown(tempPath: string, content: string): Promise<void>;
|
|
219
236
|
/**
|
|
220
237
|
* Rebuild plan from ledger events.
|
|
221
238
|
* Replays the ledger to reconstruct plan state, then writes the result.
|
|
@@ -226,6 +243,7 @@ export declare function savePlan(directory: string, plan: Plan, options?: {
|
|
|
226
243
|
*/
|
|
227
244
|
export declare function rebuildPlan(directory: string, plan?: Plan, options?: {
|
|
228
245
|
reason?: string;
|
|
246
|
+
preCommitCheck?: () => void;
|
|
229
247
|
}): Promise<Plan | null>;
|
|
230
248
|
/**
|
|
231
249
|
* Write terminal plan state through the managed write path (FR-002, FR-005, FR-006).
|
|
@@ -5,6 +5,30 @@
|
|
|
5
5
|
* classifies findings by severity, and proposes safe auto-fixes.
|
|
6
6
|
*/
|
|
7
7
|
import type { PluginConfig } from '../config/schema';
|
|
8
|
+
/**
|
|
9
|
+
* Current config format version (issue #2504). Version 3 introduces the
|
|
10
|
+
* governed v8 defaults-flip rows below; a config stamped at this version has
|
|
11
|
+
* acknowledged those default changes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CURRENT_CONFIG_FORMAT_VERSION = 3;
|
|
14
|
+
/**
|
|
15
|
+
* Governed v8 default flips (issue #2504). Unlike DEPRECATED_FIELDS (key
|
|
16
|
+
* renames surfaced through `availableMigrations`), these are default-value
|
|
17
|
+
* changes surfaced as info-severity `defaults-flip` findings — they never
|
|
18
|
+
* rewrite user keys (explicit user values always win), they inform the owner
|
|
19
|
+
* of the change, the one-line kill switch, and the conservative preset that
|
|
20
|
+
* restores the pre-flip (v7) default. Evidence for every entry is cited in
|
|
21
|
+
* docs/defaults-governance.md.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_FLIPS: ReadonlyArray<{
|
|
24
|
+
field: string;
|
|
25
|
+
v7Default: string;
|
|
26
|
+
v8Default: string;
|
|
27
|
+
killSwitch: string;
|
|
28
|
+
preset: 'conservative';
|
|
29
|
+
sinceVersion: number;
|
|
30
|
+
evidence: string;
|
|
31
|
+
}>;
|
|
8
32
|
/**
|
|
9
33
|
* Lean Turbo evidence-requiring gates and the registered producer tool that
|
|
10
34
|
* writes each gate's evidence (issue #2470: every evidence-requiring gate must
|
|
@@ -70,7 +70,7 @@ export declare function allocateInjectionBudget(systemEnhancerDemandTokens: numb
|
|
|
70
70
|
* therefore already inside the final measurement (attribution only — adding
|
|
71
71
|
* them again would double-count).
|
|
72
72
|
*/
|
|
73
|
-
export type InjectionProducer = 'system-enhancer' | 'knowledge-injector' | 'context-capsule' | 'memory-recall' | 'advisory-queue' | 'swarm-command-banner' | 'linked-cohort-advisory' | 'spec-drift-advisory' | 'final-accounting-warning';
|
|
73
|
+
export type InjectionProducer = 'system-enhancer' | 'knowledge-injector' | 'context-capsule' | 'memory-recall' | 'advisory-queue' | 'swarm-command-banner' | 'guidance-carrier-fence' | 'linked-cohort-advisory' | 'spec-drift-advisory' | 'final-accounting-warning';
|
|
74
74
|
export type InjectionSurface = 'system' | 'messages';
|
|
75
75
|
export interface ProducerAccounting {
|
|
76
76
|
/** Tokens the producer asked the ledger for this turn (claims only). */
|
|
@@ -79,10 +79,15 @@ export interface ProducerAccounting {
|
|
|
79
79
|
granted: number;
|
|
80
80
|
/** Tokens actually emitted to the model-visible surface. */
|
|
81
81
|
emitted: number;
|
|
82
|
-
/** Tokens the producer wanted but did not
|
|
82
|
+
/** Tokens the producer wanted but did not reach the model-visible surface, whether pruned locally or rejected during downstream carrier delivery. */
|
|
83
83
|
truncated: number;
|
|
84
84
|
surface: InjectionSurface;
|
|
85
85
|
}
|
|
86
|
+
declare const injectionBudgetReceiptBrand: unique symbol;
|
|
87
|
+
/** Opaque, one-shot handle for a turn-ledger reservation. */
|
|
88
|
+
export interface InjectionBudgetReceipt {
|
|
89
|
+
readonly [injectionBudgetReceiptBrand]: true;
|
|
90
|
+
}
|
|
86
91
|
export interface TurnLedgerSummary {
|
|
87
92
|
generation: number;
|
|
88
93
|
totalBudget: number;
|
|
@@ -112,13 +117,25 @@ export declare function beginTurnLedger(sessionID: string, totalBudget: number,
|
|
|
112
117
|
* preserving #1617's fail-open contract; the caller is expected to report that
|
|
113
118
|
* the hard ceiling was unavailable.
|
|
114
119
|
*/
|
|
115
|
-
|
|
116
|
-
localMaxTokens?: number;
|
|
117
|
-
surface?: InjectionSurface;
|
|
118
|
-
}): {
|
|
120
|
+
interface TurnBudgetClaimResult {
|
|
119
121
|
granted: number;
|
|
120
122
|
ledgerPresent: boolean;
|
|
121
123
|
ceilingActive: boolean;
|
|
124
|
+
}
|
|
125
|
+
export declare function claimTurnBudget(sessionID: string, producer: InjectionProducer, requestedTokens: number, opts?: {
|
|
126
|
+
localMaxTokens?: number;
|
|
127
|
+
surface?: InjectionSurface;
|
|
128
|
+
}): TurnBudgetClaimResult;
|
|
129
|
+
/**
|
|
130
|
+
* Claim from the ledger and return an opaque receipt that can settle exactly
|
|
131
|
+
* this claim. A missing ledger keeps the normal fail-open grant and produces
|
|
132
|
+
* no receipt because there is no reservation to commit or refund.
|
|
133
|
+
*/
|
|
134
|
+
export declare function claimTurnBudgetWithReceipt(sessionID: string, producer: InjectionProducer, requestedTokens: number, opts?: {
|
|
135
|
+
localMaxTokens?: number;
|
|
136
|
+
surface?: InjectionSurface;
|
|
137
|
+
}): TurnBudgetClaimResult & {
|
|
138
|
+
receipt?: InjectionBudgetReceipt;
|
|
122
139
|
};
|
|
123
140
|
/**
|
|
124
141
|
* Record a producer's grant without claiming through `claimTurnBudget`.
|
|
@@ -132,13 +149,33 @@ export declare function claimTurnBudget(sessionID: string, producer: InjectionPr
|
|
|
132
149
|
* exceed `totalBudget`.
|
|
133
150
|
*/
|
|
134
151
|
export declare function recordProducerGrant(sessionID: string, producer: InjectionProducer, requestedTokens: number, grantedTokens: number, surface: InjectionSurface): void;
|
|
152
|
+
/**
|
|
153
|
+
* Record an allocator-derived producer grant and return a receipt tied to the
|
|
154
|
+
* exact ledger generation and charged amount. `expectedGeneration` prevents a
|
|
155
|
+
* delayed transform from booking into a newer request's replacement ledger.
|
|
156
|
+
*/
|
|
157
|
+
export declare function recordProducerGrantWithReceipt(sessionID: string, producer: InjectionProducer, requestedTokens: number, grantedTokens: number, surface: InjectionSurface, options?: {
|
|
158
|
+
expectedGeneration?: number;
|
|
159
|
+
retractEmissionOnRefund?: boolean;
|
|
160
|
+
emittedTokensOnRefund?: number;
|
|
161
|
+
}): InjectionBudgetReceipt | undefined;
|
|
135
162
|
/**
|
|
136
163
|
* Record what a producer actually emitted (and pruned itself) this turn.
|
|
137
164
|
* Producers that never claim (fixed/base content: advisory queue, banners,
|
|
138
165
|
* the context-budget warning, the final-accounting warning) still record their
|
|
139
166
|
* emission here so the final accounting can include them.
|
|
140
167
|
*/
|
|
141
|
-
export declare function recordProducerEmission(sessionID: string, producer: InjectionProducer, emittedTokens: number, truncatedTokens: number, surface: InjectionSurface
|
|
168
|
+
export declare function recordProducerEmission(sessionID: string, producer: InjectionProducer, emittedTokens: number, truncatedTokens: number, surface: InjectionSurface, options?: {
|
|
169
|
+
expectedGeneration?: number;
|
|
170
|
+
}): void;
|
|
171
|
+
/**
|
|
172
|
+
* Record a direct producer emission and return a receipt that retracts exactly
|
|
173
|
+
* that emission if its carrier is not delivered. A generation mismatch is a
|
|
174
|
+
* no-op, so an old staged transform cannot write into a replacement ledger.
|
|
175
|
+
*/
|
|
176
|
+
export declare function recordProducerEmissionWithReceipt(sessionID: string, producer: InjectionProducer, emittedTokens: number, surface: InjectionSurface, options?: {
|
|
177
|
+
expectedGeneration?: number;
|
|
178
|
+
}): InjectionBudgetReceipt | undefined;
|
|
142
179
|
/**
|
|
143
180
|
* Snapshot of the session's current turn ledger (null when absent).
|
|
144
181
|
*/
|
|
@@ -148,7 +185,9 @@ export declare function recordProducerEmission(sessionID: string, producer: Inje
|
|
|
148
185
|
* recorded them, and the final accounting must not count bytes the model
|
|
149
186
|
* never sees. Floors at zero; no-op without a ledger or producer entry.
|
|
150
187
|
*/
|
|
151
|
-
export declare function deductProducerEmission(sessionID: string, producer: InjectionProducer, removedTokens: number
|
|
188
|
+
export declare function deductProducerEmission(sessionID: string, producer: InjectionProducer, removedTokens: number, options?: {
|
|
189
|
+
expectedGeneration?: number;
|
|
190
|
+
}): void;
|
|
152
191
|
export declare function getTurnLedgerSummary(sessionID: string): TurnLedgerSummary | null;
|
|
153
192
|
/**
|
|
154
193
|
* Emitted tokens recorded for one producer this turn (0 when no ledger or the
|
|
@@ -156,6 +195,14 @@ export declare function getTurnLedgerSummary(sessionID: string): TurnLedgerSumma
|
|
|
156
195
|
* knowledge-injector reads the system-enhancer's actual emission from here.
|
|
157
196
|
*/
|
|
158
197
|
export declare function getProducerEmission(sessionID: string, producer: InjectionProducer): number;
|
|
198
|
+
/** Commit exactly one live receipt. Repeated or stale commits are no-ops. */
|
|
199
|
+
export declare function commitInjectionBudgetReceipt(receipt: InjectionBudgetReceipt): boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Refund exactly one live receipt. Repeated, post-commit, or stale-generation
|
|
202
|
+
* refunds are no-ops. Grant receipts configured for emission retraction also
|
|
203
|
+
* move only their still-emitted amount into that producer's truncation count.
|
|
204
|
+
*/
|
|
205
|
+
export declare function refundInjectionBudgetReceipt(receipt: InjectionBudgetReceipt): boolean;
|
|
159
206
|
/**
|
|
160
207
|
* Advance the turn generation for a session: the current ledger is discarded so
|
|
161
208
|
* the next request composition starts from a fresh generation. Called when
|
|
@@ -173,3 +220,4 @@ export declare function clearTurnLedger(sessionID: string): void;
|
|
|
173
220
|
* review on PR #2415: the reset pattern must cover ALL module-scoped maps).
|
|
174
221
|
*/
|
|
175
222
|
export declare function clearAllTurnLedgers(): void;
|
|
223
|
+
export {};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Project-owned,
|
|
2
|
+
* Project-owned, authority-fenced hydration state (issues #2667/#2668).
|
|
3
3
|
*
|
|
4
4
|
* The live maps on `swarmState` are process-resident and keyed by sessionID;
|
|
5
5
|
* hydration is a per-PROJECT operation. This module owns the per-project
|
|
6
6
|
* registries that scope a hydration's blast radius to the project that
|
|
7
7
|
* initiated it and fence stale generations from publishing over newer state:
|
|
8
8
|
*
|
|
9
|
-
* - `
|
|
10
|
-
*
|
|
9
|
+
* - `projectHydrationAuthorities` — bounded records containing a per-project
|
|
10
|
+
* generation and a process-monotonic authority epoch. The generation is
|
|
11
|
+
* bumped ONLY when a hydration is initiated (`beginHydrationScope`), while
|
|
12
|
+
* the epoch changes whenever an evicted/reset project is reintroduced.
|
|
11
13
|
* Session creation NEVER bumps it; new sessions stamp `current + 1` so a
|
|
12
14
|
* session created while generation `g` is latest survives any later apply
|
|
13
15
|
* at `g`.
|
|
@@ -16,10 +18,12 @@
|
|
|
16
18
|
* - `hydratedAggregateKeys` — the toolAggregates keys each project's last
|
|
17
19
|
* hydration published, so a re-hydration replaces only its own keys.
|
|
18
20
|
*
|
|
19
|
-
* Fence rule: a hydration
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
21
|
+
* Fence rule: a hydration is current only while both its generation and its
|
|
22
|
+
* authority epoch match the bounded record for its project. This prevents an
|
|
23
|
+
* evicted project entry from being reintroduced with a numerically reused
|
|
24
|
+
* generation and accidentally reviving an old scope (ABA). Session stamp
|
|
25
|
+
* rule: an accepted hydration at `{ generation: g, authorityEpoch: e }`
|
|
26
|
+
* evicts owned sessions from an older epoch, or sessions in epoch `e` with
|
|
23
27
|
* `hydrationStamp <= g`.
|
|
24
28
|
*
|
|
25
29
|
* All maps are bounded (FIFO) with an explicit reset path
|
|
@@ -32,10 +36,17 @@ export declare const MAX_TRACKED_PROJECTS = 32;
|
|
|
32
36
|
export declare const MAX_DIRECTORY_KEY_MEMO = 64;
|
|
33
37
|
/** Opaque cache payload owned by state.ts; opaque here by design. */
|
|
34
38
|
export type ProjectRehydrationCache = unknown;
|
|
39
|
+
/** Opaque process-local authority token for a project's current record. */
|
|
40
|
+
export interface HydrationAuthorityToken {
|
|
41
|
+
projectKey: string;
|
|
42
|
+
generation: number;
|
|
43
|
+
authorityEpoch: number;
|
|
44
|
+
}
|
|
35
45
|
/** Fence token captured when a hydration is initiated; see beginHydrationScope. */
|
|
36
46
|
export interface HydrationScope {
|
|
37
47
|
projectKey: string;
|
|
38
48
|
generation: number;
|
|
49
|
+
authorityEpoch: number;
|
|
39
50
|
}
|
|
40
51
|
/**
|
|
41
52
|
* Resolve the canonical project key for a directory spelling through a
|
|
@@ -58,8 +69,8 @@ export interface HydrationScope {
|
|
|
58
69
|
*/
|
|
59
70
|
export declare function hydrationProjectKey(directory: string): string;
|
|
60
71
|
/**
|
|
61
|
-
* Begin a hydration scope: bump the project's generation
|
|
62
|
-
* the fence token. The token must be captured when the hydration is
|
|
72
|
+
* Begin a hydration scope: bump the project's generation, mint a non-reusable
|
|
73
|
+
* authority, and return the fence token. The token must be captured when the hydration is
|
|
63
74
|
* INITIATED (e.g. at `loadSnapshot` entry) and carried into
|
|
64
75
|
* `rehydrateState`, which refuses to apply it once any newer generation has
|
|
65
76
|
* begun.
|
|
@@ -67,6 +78,22 @@ export declare function hydrationProjectKey(directory: string): string;
|
|
|
67
78
|
export declare function beginHydrationScope(directory: string): HydrationScope;
|
|
68
79
|
/** Latest initiated hydration generation for a project (0 when never). */
|
|
69
80
|
export declare function currentHydrationGeneration(projectKey: string): number;
|
|
81
|
+
/**
|
|
82
|
+
* Capture the current project authority without beginning a hydration. This
|
|
83
|
+
* is used by direct session rehydration, which needs an exact record to fence
|
|
84
|
+
* across awaits but must preserve the session-creation/no-generation-bump
|
|
85
|
+
* contract.
|
|
86
|
+
*/
|
|
87
|
+
export declare function captureCurrentHydrationAuthority(projectKey: string): HydrationAuthorityToken;
|
|
88
|
+
/** Return whether an exact authority token still names the current record. */
|
|
89
|
+
export declare function isHydrationAuthorityCurrent(authority: HydrationAuthorityToken): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Return whether a captured hydration scope is still the latest initiated
|
|
92
|
+
* scope for its project. Exact generation+epoch equality is intentional: a
|
|
93
|
+
* scope whose project registry entry was evicted or reset is no longer current
|
|
94
|
+
* either, even if a numerically equal generation is visible at the check.
|
|
95
|
+
*/
|
|
96
|
+
export declare function isHydrationScopeCurrent(scope: HydrationScope): boolean;
|
|
70
97
|
/**
|
|
71
98
|
* Stamp value for a session created NOW under `projectKey`:
|
|
72
99
|
* `current + 1`, i.e. newer than any already-initiated hydration, so an
|
|
@@ -74,10 +101,10 @@ export declare function currentHydrationGeneration(projectKey: string): number;
|
|
|
74
101
|
*/
|
|
75
102
|
export declare function nextSessionHydrationStamp(projectKey: string): number;
|
|
76
103
|
export declare function getRehydrationCache(projectKey: string): ProjectRehydrationCache | undefined;
|
|
77
|
-
export declare function setRehydrationCache(projectKey: string, cache: ProjectRehydrationCache):
|
|
104
|
+
export declare function setRehydrationCache(projectKey: string, cache: ProjectRehydrationCache, authority?: HydrationAuthorityToken): boolean;
|
|
78
105
|
/** Record the aggregate keys a project's hydration published (replace set). */
|
|
79
|
-
export declare function recordHydratedAggregateKeys(projectKey: string, keys: Set<string
|
|
106
|
+
export declare function recordHydratedAggregateKeys(projectKey: string, keys: Set<string>, authority?: HydrationAuthorityToken): boolean;
|
|
80
107
|
/** The aggregate keys the project's last hydration published (empty if none). */
|
|
81
|
-
export declare function hydratedAggregateKeysFor(projectKey: string): Set<string>;
|
|
108
|
+
export declare function hydratedAggregateKeysFor(projectKey: string, authority?: HydrationAuthorityToken): Set<string>;
|
|
82
109
|
/** Reset every registry (invariant 8: bounded state with an explicit reset). */
|
|
83
110
|
export declare function clearHydrationOwnershipState(): void;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/** Post-resolution SQLite snapshot import/readiness lifecycle (#2481). */
|
|
2
|
+
import { loadPlan } from '../plan/manager.js';
|
|
2
3
|
import { type HydrationScope } from './hydration-ownership.js';
|
|
3
|
-
import
|
|
4
|
-
|
|
4
|
+
import { readSnapshotFileStrict } from './snapshot-reader.js';
|
|
5
|
+
import { importSnapshotRowsOnce } from './snapshot-store.js';
|
|
6
|
+
import { writeSnapshotProjection } from './snapshot-writer.js';
|
|
7
|
+
type ReadinessState = 'running' | 'succeeded' | 'superseded' | 'failed' | 'timed_out' | 'closing';
|
|
8
|
+
export type SnapshotCoordinationInitializationOutcome = 'succeeded' | 'superseded';
|
|
5
9
|
interface ReadinessEntry {
|
|
6
10
|
attemptId: number;
|
|
7
11
|
generation: number;
|
|
@@ -42,9 +46,12 @@ export declare function closeSnapshotCoordinationInitialization(directory: strin
|
|
|
42
46
|
export declare function markSnapshotCoordinationClosing(directory: string): void;
|
|
43
47
|
export declare const _snapshotCoordinationInternals: {
|
|
44
48
|
entries: Map<string, ReadinessEntry>;
|
|
45
|
-
initialize: (directory: string, scope?: HydrationScope) => Promise<
|
|
49
|
+
initialize: (directory: string, scope?: HydrationScope) => Promise<SnapshotCoordinationInitializationOutcome>;
|
|
50
|
+
loadPlan: typeof loadPlan;
|
|
51
|
+
readSnapshotFileStrict: typeof readSnapshotFileStrict;
|
|
52
|
+
importSnapshotRowsOnce: typeof importSnapshotRowsOnce;
|
|
46
53
|
renameLegacySnapshot: (from: string, to: string) => void;
|
|
47
|
-
writeProjection:
|
|
54
|
+
writeProjection: typeof writeSnapshotProjection;
|
|
48
55
|
timeoutMs: number;
|
|
49
56
|
};
|
|
50
57
|
export {};
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { AgentSessionState } from '../state';
|
|
6
6
|
import { type HydrationScope } from './hydration-ownership.js';
|
|
7
|
+
import { recordInterruptedExecution } from './restart-reconciliation.js';
|
|
7
8
|
import type { SerializedAgentSession, SnapshotData } from './snapshot-writer';
|
|
9
|
+
export declare const _internals: {
|
|
10
|
+
recordInterruptedExecution: typeof recordInterruptedExecution;
|
|
11
|
+
};
|
|
8
12
|
/**
|
|
9
13
|
* Transient session fields that must be reset on rehydration.
|
|
10
14
|
* Centralised here to keep the reset logic DRY and auditable.
|
|
@@ -35,9 +39,10 @@ export declare function readSnapshotFileStrict(directory: string, relativePath:
|
|
|
35
39
|
/**
|
|
36
40
|
* Rehydrate swarmState from a SnapshotData object.
|
|
37
41
|
*
|
|
38
|
-
*
|
|
42
|
+
* Issues #2667/#2668 — project-owned and authority-fenced:
|
|
39
43
|
* - With a `directory`, this replaces ONLY the state owned by that project
|
|
40
|
-
* (sessions whose `owningProjectKey` matches and whose
|
|
44
|
+
* (sessions whose `owningProjectKey` matches and whose authority epoch is
|
|
45
|
+
* older than the applying epoch, or whose current-epoch `hydrationStamp` is
|
|
41
46
|
* at or below the applying generation). Other projects' live state — and
|
|
42
47
|
* this project's sessions created after the hydration began — survive.
|
|
43
48
|
* - With an explicit `scope` captured at initiation, the apply is refused
|
|
@@ -66,8 +71,8 @@ export declare function rehydrateState(snapshot: SnapshotData, directory?: strin
|
|
|
66
71
|
* Called on plugin init to restore state from previous session.
|
|
67
72
|
* NEVER throws - swallows any errors silently.
|
|
68
73
|
*
|
|
69
|
-
*
|
|
70
|
-
* rehydrateState apply is
|
|
74
|
+
* Issues #2667/#2668: a hydration scope is captured at entry so the eventual
|
|
75
|
+
* rehydrateState apply is authority-fenced — a loadSnapshot whose 5 s init
|
|
71
76
|
* timeout (src/index.ts) abandoned the await is refused once any newer
|
|
72
77
|
* hydration for the same project has begun.
|
|
73
78
|
*/
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Persists swarmState as independently keyed SQLite coordination rows and a
|
|
4
4
|
* non-authoritative, versioned file projection.
|
|
5
5
|
*/
|
|
6
|
-
import { rename as fsRename } from 'node:fs/promises';
|
|
7
6
|
import { TASK_WORKFLOW_SCHEMA_MARKER } from '../gate-evidence.js';
|
|
8
7
|
import type { AgentSessionState, DelegationEntry, ToolAggregate } from '../state';
|
|
9
8
|
import { swarmState } from '../state';
|
|
@@ -190,7 +189,7 @@ export declare function serializeAgentSession(s: AgentSessionState): SerializedA
|
|
|
190
189
|
* Silently swallows errors (non-fatal — never crash the plugin).
|
|
191
190
|
*/
|
|
192
191
|
export declare function writeSnapshot(directory: string, state: typeof swarmState): Promise<void>;
|
|
193
|
-
export declare function writeSnapshotProjection(directory: string, snapshot: SnapshotData): Promise<void>;
|
|
192
|
+
export declare function writeSnapshotProjection(directory: string, snapshot: SnapshotData, shouldCommit?: () => boolean): Promise<void>;
|
|
194
193
|
/**
|
|
195
194
|
* Create a snapshot writer hook suitable for use in tool.execute.after.
|
|
196
195
|
* Writes state immediately on every call. Concurrent calls are serialised so
|
|
@@ -211,5 +210,5 @@ export declare const _internals: {
|
|
|
211
210
|
writeSnapshot: typeof writeSnapshot;
|
|
212
211
|
createSnapshotWriterHook: typeof createSnapshotWriterHook;
|
|
213
212
|
flushPendingSnapshot: typeof flushPendingSnapshot;
|
|
214
|
-
rename:
|
|
213
|
+
rename: (from: string, to: string, shouldCommit?: () => boolean) => void | Promise<void>;
|
|
215
214
|
};
|
package/dist/state.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* and delegation chains.
|
|
8
8
|
*/
|
|
9
9
|
import type { OpencodeClient } from '@opencode-ai/sdk';
|
|
10
|
+
import { type Plan } from './config/plan-schema';
|
|
10
11
|
import type { CouncilAgent } from './council/types';
|
|
11
12
|
import { type QaGates } from './db/qa-gate-profile.js';
|
|
12
13
|
import { type EnvironmentProfile } from './environment/profile.js';
|
|
@@ -14,8 +15,26 @@ import { type TaskWorkflowMetadata } from './gate-evidence';
|
|
|
14
15
|
import type { EscalationTracker } from './prm/escalation.js';
|
|
15
16
|
import type { PatternMatch, PrmEpisodeState } from './prm/types.js';
|
|
16
17
|
import type { ReviewRouteEvidence } from './review/routing-enforcement.js';
|
|
18
|
+
import { getRehydrationCache } from './session/hydration-ownership.js';
|
|
17
19
|
import { AgentRunContext } from './state/agent-run-context.js';
|
|
20
|
+
export { getRehydrationCache };
|
|
18
21
|
export { AgentRunContext } from './state/agent-run-context.js';
|
|
22
|
+
/** Optional controls for rebuilding the project-owned rehydration cache. */
|
|
23
|
+
export interface RehydrationCacheBuildOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Explicitly recovered plan state. Presence of this property, including a
|
|
26
|
+
* null value, means the caller already resolved the authoritative plan and
|
|
27
|
+
* the builder must not fall back to the derived plan.json projection.
|
|
28
|
+
*/
|
|
29
|
+
planOverride?: Plan | null;
|
|
30
|
+
/** Return false when the captured hydration scope was superseded mid-read. */
|
|
31
|
+
shouldCommit?: () => boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Result of a cache rebuild, including whether its publication committed. */
|
|
34
|
+
export interface RehydrationCacheBuildResult {
|
|
35
|
+
committed: boolean;
|
|
36
|
+
reason?: 'superseded';
|
|
37
|
+
}
|
|
19
38
|
/**
|
|
20
39
|
* Represents a single tool call entry for tracking purposes
|
|
21
40
|
*/
|
|
@@ -470,11 +489,21 @@ export interface AgentSessionState {
|
|
|
470
489
|
* Hydration generation this session was created/restored AT.
|
|
471
490
|
* `startAgentSession` stamps `currentGeneration + 1` (newer than any
|
|
472
491
|
* in-flight hydration); `rehydrateState` stamps its applying generation.
|
|
473
|
-
* A hydration at generation
|
|
474
|
-
*
|
|
475
|
-
*
|
|
492
|
+
* A hydration at authority `{ generation: g, epoch: e }` evicts owned
|
|
493
|
+
* sessions from another epoch and same-epoch sessions with
|
|
494
|
+
* `hydrationStamp <= g`, so sessions created after `g` began survive only
|
|
495
|
+
* within the same authority incarnation.
|
|
496
|
+
* `hydrationAuthorityEpoch` disambiguates a numerically reused generation
|
|
497
|
+
* after bounded project-authority eviction or reset. Also never snapshotted.
|
|
476
498
|
*/
|
|
477
499
|
hydrationStamp?: number;
|
|
500
|
+
/**
|
|
501
|
+
* Process-local authority epoch paired with `hydrationStamp`. A session from
|
|
502
|
+
* an older project-authority incarnation is stale even when its numeric
|
|
503
|
+
* generation is larger than the current generation (issue #2668 ABA guard).
|
|
504
|
+
* Deliberately omitted from snapshots with the other ownership fields.
|
|
505
|
+
*/
|
|
506
|
+
hydrationAuthorityEpoch?: number;
|
|
478
507
|
/** Pattern type to detection count mapping */
|
|
479
508
|
prmPatternCounts: Map<string, number>;
|
|
480
509
|
/** Current escalation level (0=none, 1=guidance, 2=strong guidance, 3=hard stop) */
|
|
@@ -1378,7 +1407,7 @@ export declare function _resetCouncilDisagreementWarnings(): void;
|
|
|
1378
1407
|
* refreshed after compaction by the compaction hook (src/hooks/compaction-customizer.ts).
|
|
1379
1408
|
* Non-fatal: missing/malformed files leave an empty cache.
|
|
1380
1409
|
*/
|
|
1381
|
-
export declare function buildRehydrationCache(directory: string): Promise<
|
|
1410
|
+
export declare function buildRehydrationCache(directory: string, options?: RehydrationCacheBuildOptions): Promise<RehydrationCacheBuildResult>;
|
|
1382
1411
|
/**
|
|
1383
1412
|
* Synchronously applies the cached plan+evidence data to a session.
|
|
1384
1413
|
* Merge rules:
|
|
@@ -1398,7 +1427,7 @@ export declare function applyRehydrationCache(session: AgentSessionState, projec
|
|
|
1398
1427
|
* Builds (or refreshes) the rehydration cache from disk, then applies it
|
|
1399
1428
|
* to the target session.
|
|
1400
1429
|
*/
|
|
1401
|
-
export declare function rehydrateSessionFromDisk(directory: string, session: AgentSessionState): Promise<void>;
|
|
1430
|
+
export declare function rehydrateSessionFromDisk(directory: string, session: AgentSessionState, shouldCommit?: () => boolean): Promise<void>;
|
|
1402
1431
|
/**
|
|
1403
1432
|
* Check if Turbo Mode is enabled for a specific session or ANY session.
|
|
1404
1433
|
* @param sessionID - Optional session ID to check. If provided, checks only that session.
|
|
@@ -1615,6 +1644,7 @@ export declare const _internals: {
|
|
|
1615
1644
|
buildRehydrationCache: typeof buildRehydrationCache;
|
|
1616
1645
|
applyRehydrationCache: typeof applyRehydrationCache;
|
|
1617
1646
|
rehydrateSessionFromDisk: typeof rehydrateSessionFromDisk;
|
|
1647
|
+
rehydratePrSubscriptions: typeof rehydratePrSubscriptions;
|
|
1618
1648
|
isCouncilGateActive: typeof isCouncilGateActive;
|
|
1619
1649
|
defaultRunContext: typeof defaultRunContext;
|
|
1620
1650
|
};
|
|
@@ -150,6 +150,7 @@ export declare const MAX_OUTPUT_BYTES = 512000;
|
|
|
150
150
|
declare function allCompletedTasksHavePassedGateEvidence(directory: string, tasks: Array<{
|
|
151
151
|
id: string;
|
|
152
152
|
status: string;
|
|
153
|
+
files_touched?: string[];
|
|
153
154
|
}>): Promise<boolean>;
|
|
154
155
|
/**
|
|
155
156
|
* Execute the phase_complete tool
|
|
@@ -3,8 +3,20 @@
|
|
|
3
3
|
* Allows the Architect agent to save structured plans to .swarm/plan.json and .swarm/plan.md.
|
|
4
4
|
*/
|
|
5
5
|
import type { ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
6
|
+
import { loadPluginConfigWithMeta } from '../config';
|
|
6
7
|
import { type ExecutionProfile } from '../config/plan-schema';
|
|
7
8
|
import { takeSnapshotWithRetry } from '../plan/ledger';
|
|
9
|
+
/**
|
|
10
|
+
* DI seam for hermetic config-load substitution in tests (AGENTS.md invariant 7).
|
|
11
|
+
* Mirrors `src/tools/apply-patch.ts`. Tests override
|
|
12
|
+
* `_internals.loadPluginConfigWithMeta` and restore it in `afterEach` instead of
|
|
13
|
+
* writing real config files or using `mock.module` (which leaks across test
|
|
14
|
+
* files in Bun's shared runner). Used by the #2504 conservative-preset
|
|
15
|
+
* new-plan default below.
|
|
16
|
+
*/
|
|
17
|
+
export declare const _internals: {
|
|
18
|
+
loadPluginConfigWithMeta: typeof loadPluginConfigWithMeta;
|
|
19
|
+
};
|
|
8
20
|
/** Test seam for the snapshot retry helper (FR-004). */
|
|
9
21
|
export declare const _test_exports: {
|
|
10
22
|
takeSnapshotWithRetry: typeof takeSnapshotWithRetry;
|
|
@@ -84,7 +84,7 @@ export interface ReviewerGateResult {
|
|
|
84
84
|
nextAction?: string;
|
|
85
85
|
}
|
|
86
86
|
declare function hasPassedDurableGateEvidence(workingDirectory: string, taskId: string): boolean;
|
|
87
|
-
export declare function checkReviewerGate(taskId: string, workingDirectory?: string, stageBParallelEnabled?: boolean, sessionID?: string, fallbackDir?: string): ReviewerGateResult;
|
|
87
|
+
export declare function checkReviewerGate(taskId: string, workingDirectory?: string, stageBParallelEnabled?: boolean, sessionID?: string, fallbackDir?: string, currentDeclaredFiles?: readonly string[] | null): ReviewerGateResult;
|
|
88
88
|
/**
|
|
89
89
|
* Wrapper around checkReviewerGate that appends a diff-scope advisory warning.
|
|
90
90
|
* Keeps checkReviewerGate synchronous for backward compatibility.
|