opencode-swarm 7.167.2 → 7.168.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/cli/{coder-settlement-jy9rad28.js → coder-settlement-a35acvj1.js} +12 -12
  4. package/dist/cli/{config-doctor-p66vnpy3.js → config-doctor-9csx775x.js} +3 -3
  5. package/dist/cli/{core-tw0wtntz.js → core-agk5s7dm.js} +2 -2
  6. package/dist/cli/{curation-policy-ndp27v0c.js → curation-policy-mgwv8h2k.js} +5 -5
  7. package/dist/cli/{curator-5nzde80g.js → curator-2fcagjyk.js} +38 -38
  8. package/dist/cli/{curator-drift-gb651hcw.js → curator-drift-k0zrnm09.js} +5 -5
  9. package/dist/cli/curator-llm-factory-qaxmyy46.js +71 -0
  10. package/dist/cli/{evidence-summary-service-bzpfaypy.js → evidence-summary-service-4s6cje60.js} +17 -17
  11. package/dist/cli/{gate-evidence-wa8cj8h6.js → gate-evidence-saja4dan.js} +7 -7
  12. package/dist/cli/guardrail-explain-z41q6sf0.js +72 -0
  13. package/dist/cli/{guardrail-log-7dv73e0q.js → guardrail-log-0h24spq0.js} +8 -8
  14. package/dist/cli/{guardrail-reset-1kng6y8x.js → guardrail-reset-cwbe47k5.js} +38 -38
  15. package/dist/cli/{hive-promoter-87kk2pg5.js → hive-promoter-esxtcvr1.js} +38 -38
  16. package/dist/cli/{index-3r6k6qa7.js → index-00zx94vn.js} +4 -4
  17. package/dist/cli/{index-arqv4psy.js → index-21ree67h.js} +57 -101
  18. package/dist/cli/{index-dme7wvwg.js → index-30h1pk05.js} +4 -4
  19. package/dist/cli/{index-shrf0wt3.js → index-3dywbkyr.js} +4 -4
  20. package/dist/cli/{index-vgpedapd.js → index-4r5pmtvk.js} +2 -2
  21. package/dist/cli/{index-3ws11dq0.js → index-54w1564x.js} +2 -2
  22. package/dist/cli/{index-m7cwnt9r.js → index-5zqakgp4.js} +2 -2
  23. package/dist/cli/{index-f91fhch0.js → index-64phnth4.js} +4 -4
  24. package/dist/cli/{index-09gv90d7.js → index-8f0kscpg.js} +2 -2
  25. package/dist/cli/{index-0q839sg6.js → index-8ybjqg51.js} +1 -1
  26. package/dist/cli/{index-z6we1abx.js → index-a8xbvsse.js} +2 -2
  27. package/dist/cli/{index-jhd3pmd1.js → index-an8b5gda.js} +7 -7
  28. package/dist/cli/{index-gmjg65tm.js → index-bvqqwx84.js} +2 -2
  29. package/dist/cli/{index-rrne6g2m.js → index-cyenn3pf.js} +6 -2
  30. package/dist/cli/{index-65s0vgb1.js → index-ddr97ram.js} +40 -40
  31. package/dist/cli/{index-mtepgqan.js → index-dfyv3xkd.js} +7 -7
  32. package/dist/cli/{index-2b1hd1fx.js → index-exatbqwj.js} +13 -4
  33. package/dist/cli/{index-83r0v5tn.js → index-gp9yzr1v.js} +1 -1
  34. package/dist/cli/{index-79234evf.js → index-h0e2e3h1.js} +1 -1
  35. package/dist/cli/{index-962qme08.js → index-h439y187.js} +1 -1
  36. package/dist/cli/{index-18rfc7qv.js → index-j950hqmq.js} +7 -7
  37. package/dist/cli/{index-8vbahc4c.js → index-kear8gb7.js} +11 -6
  38. package/dist/cli/{index-syedr4e3.js → index-m35hybf0.js} +1 -1
  39. package/dist/cli/{index-ce8p9t28.js → index-mr0wn36f.js} +5 -5
  40. package/dist/cli/{index-sjkg2hc4.js → index-nprngf8p.js} +6 -6
  41. package/dist/cli/{index-m3z83nhs.js → index-nsyxj57e.js} +8 -8
  42. package/dist/cli/{index-f8cc92g7.js → index-nwwk3dej.js} +1 -1
  43. package/dist/cli/{index-g409c7ke.js → index-pyf517sz.js} +2 -2
  44. package/dist/cli/{index-k73ehxa1.js → index-qhey6vc3.js} +1 -1
  45. package/dist/cli/{index-gs12223x.js → index-qwsh0h2g.js} +2 -2
  46. package/dist/cli/{index-n4fzmqz8.js → index-rdm3px0g.js} +4 -2
  47. package/dist/cli/{index-25xeyjfx.js → index-rxcgrgkc.js} +38 -38
  48. package/dist/cli/{index-ehq2vtkq.js → index-s0d5xter.js} +4 -4
  49. package/dist/cli/{index-wjet7x0a.js → index-seetnhpx.js} +1 -1
  50. package/dist/cli/{index-g5m43paw.js → index-sxt7fgcw.js} +1 -0
  51. package/dist/cli/{index-x7pm61wk.js → index-v3xc4sde.js} +9 -8
  52. package/dist/cli/{index-pdcperq5.js → index-wnzxcr0z.js} +2 -2
  53. package/dist/cli/{index-hhkm64wh.js → index-wst6n478.js} +103 -3
  54. package/dist/cli/{index-s7a9dqtb.js → index-x7k3dps5.js} +4 -3
  55. package/dist/cli/{index-y1sj2e1n.js → index-yevn4jpe.js} +2094 -1686
  56. package/dist/cli/index-yv76j77m.js +2008 -0
  57. package/dist/cli/{index-tcj8v6my.js → index-z6qreakh.js} +6 -6
  58. package/dist/cli/{index-5sjq3shs.js → index-ze520xw1.js} +8 -8
  59. package/dist/cli/index.js +38 -38
  60. package/dist/cli/{knowledge-escalator-5e4zxan5.js → knowledge-escalator-b2tf3sd1.js} +13 -13
  61. package/dist/cli/{knowledge-events-abzm5vfh.js → knowledge-events-bgs2kxe0.js} +11 -11
  62. package/dist/cli/{knowledge-link-9ga6hyd5.js → knowledge-link-dr3xnwyd.js} +4 -4
  63. package/dist/cli/{knowledge-store-q4a92eq7.js → knowledge-store-stbmb1b9.js} +5 -5
  64. package/dist/cli/{knowledge-validator-pn3m5r41.js → knowledge-validator-zykgnsag.js} +7 -7
  65. package/dist/cli/{model-preflight-mw895vgt.js → model-preflight-1ycat9jz.js} +1 -1
  66. package/dist/cli/{pending-delegations-3z0xjppd.js → pending-delegations-n5qavj20.js} +12 -12
  67. package/dist/cli/{pr-subscriptions-h7mwnp62.js → pr-subscriptions-gnvmyrng.js} +12 -12
  68. package/dist/cli/{pr-workflow-gate-fec04fa0.js → pr-workflow-gate-cf3ybrws.js} +38 -38
  69. package/dist/cli/{runner-d9833azt.js → runner-k0ycgv8x.js} +5 -5
  70. package/dist/cli/{scan-cursor-ymfvzdkz.js → scan-cursor-b3mcrx23.js} +6 -6
  71. package/dist/cli/{schema-chc4aez6.js → schema-08049cjb.js} +4 -2
  72. package/dist/cli/{scope-persistence-3xnr59y8.js → scope-persistence-a493gv51.js} +16 -16
  73. package/dist/cli/{skill-generator-3mvaghxk.js → skill-generator-2qqzkdpv.js} +15 -15
  74. package/dist/cli/{snapshot-coordination-init-arnc77r9.js → snapshot-coordination-init-8yt8p7q0.js} +38 -38
  75. package/dist/cli/{sqlite-loader-xrnf6bq8.js → sqlite-loader-amp9z7ty.js} +1 -1
  76. package/dist/cli/{telemetry-g9pppt9e.js → telemetry-2wzapf11.js} +1 -1
  77. package/dist/cli/{workspace-snapshot-hvsjtepd.js → workspace-snapshot-rkgxhj9b.js} +3 -3
  78. package/dist/cli/{worktree-collision-ownership-vj8anvb7.js → worktree-collision-ownership-xttafc4h.js} +13 -13
  79. package/dist/cli/{worktree-isolation-mt7z75hz.js → worktree-isolation-e5q5rewk.js} +38 -38
  80. package/dist/commands/reset.d.ts +10 -0
  81. package/dist/commands/rollback.d.ts +9 -0
  82. package/dist/config/schema.d.ts +29 -0
  83. package/dist/db/project-db.d.ts +8 -0
  84. package/dist/db/sqlite-loader.d.ts +2 -1
  85. package/dist/dispatch/spawn-circuit.d.ts +121 -0
  86. package/dist/dispatch/token-bucket.d.ts +46 -0
  87. package/dist/hooks/delegation-gate/dead-lane-reclaim.d.ts +61 -0
  88. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +22 -0
  89. package/dist/hooks/issue-trace.d.ts +3 -0
  90. package/dist/hooks/utils.d.ts +1 -1
  91. package/dist/index.js +657 -572
  92. package/dist/plan/ledger-sqlite.d.ts +226 -0
  93. package/dist/plan/ledger.d.ts +24 -0
  94. package/dist/plan/manager.d.ts +19 -0
  95. package/dist/retention/sweep.d.ts +2 -0
  96. package/dist/services/spec-drift-recovery.d.ts +2 -1
  97. package/dist/utils/ephemeral-session-teardown.d.ts +55 -2
  98. package/opencode-swarm.schema.json +41 -0
  99. package/package.json +1 -1
  100. package/dist/cli/curator-llm-factory-xy96x5x8.js +0 -71
  101. package/dist/cli/guardrail-explain-1ef5he6j.js +0 -72
  102. package/dist/cli/index-z7z3g5wt.js +0 -1017
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Token-bucket dispatch rate limiting for native task delegations
3
+ * (issue #2507 / ADR 0002 G3 — reimplemented, no upstream code ported).
4
+ *
5
+ * Pacing, never denial: an empty bucket awaits until a token refills, so
6
+ * dispatch rate is bounded WITHOUT blocking diagnosis or recovery (only the
7
+ * `task` tool acquires tokens; read/diagnose/repair/rescope/abort controls
8
+ * never wait).
9
+ *
10
+ * Restart-state integration: the per-PROJECT bucket level and refill
11
+ * timestamp persist as one row in the existing `coordination_state` table
12
+ * under namespace `dispatch.token-bucket` (entity `project`), written when
13
+ * tokens are consumed. A fresh process rehydrates from that row and refills
14
+ * by elapsed wall time — an exhausted bucket does not grant a fresh burst
15
+ * after restart. Write failures fail OPEN (debug log, never break
16
+ * dispatch): the in-memory bucket stays authoritative for the process
17
+ * lifetime, and a restart after persistent write failure sees no row and
18
+ * grants a fresh burst (documented limitation — the limiter's purpose is
19
+ * runaway containment within a process).
20
+ */
21
+ export declare const TOKEN_BUCKET_NAMESPACE = "dispatch.token-bucket";
22
+ export declare const TOKEN_BUCKET_ENTITY_KEY = "project";
23
+ /**
24
+ * Acquire one dispatch token, awaiting until one is available (paced, never
25
+ * denied). `ratePerSecond === 0` disables the limiter entirely.
26
+ *
27
+ * Persistence is debounced to the acquires that matter for restart
28
+ * semantics: only a PACED acquire (one that had to wait for a refill)
29
+ * writes the coordination row. Immediate burst consumption is
30
+ * reconstructible within the documented one-burst over-permission bound,
31
+ * and skipping those writes keeps the common fast path free of SQLite I/O
32
+ * (composing gates run under tight timing windows).
33
+ */
34
+ export declare function acquireDispatchToken(input: {
35
+ directory: string;
36
+ ratePerSecond: number;
37
+ burstCapacity: number;
38
+ }): Promise<void>;
39
+ /** Test seam: forget all in-memory buckets (does not touch persisted rows). */
40
+ export declare function _resetDispatchTokenBuckets(): void;
41
+ export declare const _internals: {
42
+ now: () => number;
43
+ sleep: (ms: number) => Promise<void>;
44
+ readState: (directory: string) => import("../db/coordination-store.js").CoordinationState | null;
45
+ onPersistError: (err: unknown) => void;
46
+ };
@@ -0,0 +1,61 @@
1
+ import { closeProjectDb } from '../../db/project-db';
2
+ import { atomicWriteSwarmFileSync } from '../../utils/atomic-write';
3
+ import { bunSpawn } from '../../utils/bun-compat';
4
+ import { canonicalRootKeyFresh } from '../../utils/canonical-root';
5
+ import { resolveGitExecutable } from '../../utils/git-executable.js';
6
+ import { removeWorktree } from '../../worktree/core';
7
+ export interface DeadLaneReclaimEntry {
8
+ lanePath: string;
9
+ branchName: string;
10
+ parentSessionId: string;
11
+ taskId: string;
12
+ /** The removal error that stranded the lane (e.g. `EBUSY: ...`). */
13
+ reason: string;
14
+ recordedAt: number;
15
+ }
16
+ export interface ReclaimDeadLanesContext {
17
+ /**
18
+ * Session ids that still own live state (#2527 interplay: a lane whose
19
+ * parent session is active, or whose path is protected by recovery/
20
+ * ownership machinery, is NOT reclaimable — it is not dead).
21
+ */
22
+ activeSessionIds?: Iterable<string>;
23
+ protectedWorktreePaths?: Iterable<string>;
24
+ }
25
+ export interface ReclaimDeadLanesResult {
26
+ reclaimed: string[];
27
+ retained: Array<{
28
+ lanePath: string;
29
+ reason: string;
30
+ }>;
31
+ }
32
+ /** Record a dead lane for next-start reclaim. Dedupes by lanePath. */
33
+ export declare function recordDeadLaneReclaim(directory: string, entry: Omit<DeadLaneReclaimEntry, 'recordedAt'>): void;
34
+ /** Read-only view for diagnostics and tests. */
35
+ export declare function listDeadLaneReclaims(directory: string): DeadLaneReclaimEntry[];
36
+ declare function isLaneOwnedByActiveSession(lanePath: string, activeSessionIds: Set<string>, parentSessionId?: string): boolean;
37
+ /**
38
+ * Dirty-lane gate (#2508 interplay): a lane with uncommitted changes is NEVER
39
+ * purged without the shared confirmation primitive — fail closed. Any git
40
+ * error also counts as dirty: an unknowable state is not a purgeable state.
41
+ */
42
+ declare function isLaneDirty(lanePath: string): Promise<boolean>;
43
+ /**
44
+ * Reclaim every recorded dead lane whose gates pass. Runs inside the bounded,
45
+ * fail-open next-start init task (`runInitOrphanRecovery`), so it never throws
46
+ * and never blocks init: per-lane failures retain the entry for the next start.
47
+ */
48
+ export declare function reclaimDeadLanes(directory: string, context?: ReclaimDeadLanesContext): Promise<ReclaimDeadLanesResult>;
49
+ declare function pathExists(target: string): Promise<boolean>;
50
+ export declare const _internals: {
51
+ removeWorktree: typeof removeWorktree;
52
+ closeProjectDb: typeof closeProjectDb;
53
+ isLaneOwnedByActiveSession: typeof isLaneOwnedByActiveSession;
54
+ isLaneDirty: typeof isLaneDirty;
55
+ pathExists: typeof pathExists;
56
+ bunSpawn: typeof bunSpawn;
57
+ resolveGitExecutable: typeof resolveGitExecutable;
58
+ atomicWriteSwarmFileSync: typeof atomicWriteSwarmFileSync;
59
+ canonicalRootKeyFresh: typeof canonicalRootKeyFresh;
60
+ };
61
+ export {};
@@ -146,6 +146,16 @@ interface SessionSerializationState {
146
146
  */
147
147
  successfulDispatchesSince: number;
148
148
  }
149
+ /**
150
+ * Issue #2599: bounded lane session.create with deterministic late-settle
151
+ * handling. The create promise's outcome is captured exactly once into a
152
+ * derived settle-state promise — never a mutable flag read across async
153
+ * continuations — so a create that settles after the deadline reaches
154
+ * `onLateResolve` (verified teardown of the late child) under EVERY
155
+ * microtask interleaving, and only after the settle (or this grace bound)
156
+ * does the caller's lane cleanup begin.
157
+ */
158
+ declare function createSessionWithinBudget<T>(promise: Promise<T>, label: string, onLateResolve?: (result: T) => Promise<void> | void, timeoutMs?: number): Promise<T>;
149
159
  interface CleanupStandardWorktreeResult {
150
160
  removedWorktree: boolean;
151
161
  cleanedBranch: boolean;
@@ -384,6 +394,18 @@ export declare const _internals: {
384
394
  preserveDirtyWorktreeAtPath: typeof preserveDirtyWorktreeAtPath;
385
395
  /** Bounded lane session.create timeout (tests may override). */
386
396
  worktreeSessionCreateTimeoutMs: number;
397
+ /**
398
+ * Issue #2599 AC4: bound on how long the deadline path waits for the
399
+ * create promise to settle before proceeding to lane cleanup. Tests
400
+ * override this to keep never-settling-create cases fast.
401
+ */
402
+ worktreeSessionCreateSettleGraceMs: number;
403
+ /**
404
+ * Issue #2599: the settle-state-machine budget wrapper, exposed so tests
405
+ * can drive both late-settle interleavings directly with controlled
406
+ * promises (no racy shared flag is involved).
407
+ */
408
+ createSessionWithinBudget: typeof createSessionWithinBudget;
387
409
  /** FR-001a: abort entry point for in-flight dispatches. */
388
410
  abortStandardWorktreeDispatch: typeof abortStandardWorktreeDispatch;
389
411
  standardWorktreeByCallID: Map<string, StandardWorktreeDispatch>;
@@ -15,6 +15,7 @@
15
15
  * advanced, so the next cycle recomputes and retries — a lost directive can
16
16
  * no longer be permanently suppressed by idempotency while state advances.
17
17
  */
18
+ import { getPlanLedgerStateReadOnly } from '../plan/ledger-sqlite';
18
19
  import { error as _logErrorImpl } from '../utils/logger.js';
19
20
  import { isPlanCriticApproved } from './delegation-gate';
20
21
  import { implementationReviewReceiptExists, publicationReceiptExists, readIssueReference, readPlanPhaseStatus, readSpecIssueNumber, readTraceState, recurrenceSweepReceiptExists, reproductionReceiptExists, specExists, writeTraceState } from './issue-trace-state';
@@ -30,7 +31,9 @@ export declare const _internals: {
30
31
  recurrenceSweepReceiptExists: typeof recurrenceSweepReceiptExists;
31
32
  implementationReviewReceiptExists: typeof implementationReviewReceiptExists;
32
33
  isPlanCriticApproved: typeof isPlanCriticApproved;
34
+ getPlanLedgerState: typeof getPlanLedgerStateReadOnly;
33
35
  logError: typeof _logErrorImpl;
36
+ boundedApprovalCheck: (directory: string, timeoutMs: number) => Promise<boolean>;
34
37
  };
35
38
  export declare function createIssueTraceHook(_config: unknown, directory: string, approvalTimeoutMs?: number): {
36
39
  messagesTransform: (input: unknown, output: unknown) => Promise<void>;
@@ -76,7 +76,7 @@ export declare function composeBlockingHandlers<I, O>(...fns: Array<HookHandler<
76
76
  * @throws Error if the filename is invalid or attempts path traversal
77
77
  */
78
78
  export declare function validateSwarmPath(directory: string, filename: string): string;
79
- export declare function readSwarmFileAsync(directory: string, filename: string, cache?: Map<string, Promise<string | null>>): Promise<string | null>;
79
+ export declare function readSwarmFileAsync(directory: string, filename: string, cache?: Map<string, Promise<string | null>>, reader?: (resolvedPath: string) => Promise<string | null>, useArtifactCache?: boolean): Promise<string | null>;
80
80
  /**
81
81
  * Estimate tokens from a character count using the canonical heuristic.
82
82
  * This is the single sanctioned numeric form (issue #2107 §1).