opencode-swarm 7.153.0 → 7.153.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/background/pending-delegations.d.ts +7 -0
  2. package/dist/cli/{config-doctor-7s7xga6f.js → config-doctor-tv0ar88m.js} +2 -2
  3. package/dist/cli/{core-vkpy14vv.js → core-kmsm50zn.js} +1 -1
  4. package/dist/cli/{curation-policy-xy7tm4ad.js → curation-policy-twa6agf8.js} +7 -7
  5. package/dist/cli/{curator-llm-factory-q5cjk7mt.js → curator-llm-factory-dxkhdhwg.js} +30 -30
  6. package/dist/cli/{curator-6freqnhf.js → curator-wxe863k9.js} +30 -30
  7. package/dist/cli/{evidence-summary-service-engtgjww.js → evidence-summary-service-9akrdg9t.js} +13 -13
  8. package/dist/cli/{gate-evidence-6bzzz8kq.js → gate-evidence-bdzqbg2y.js} +7 -7
  9. package/dist/cli/{guardrail-explain-vsck39dh.js → guardrail-explain-kx9rem51.js} +31 -31
  10. package/dist/cli/{guardrail-log-0dn8m3k6.js → guardrail-log-zxzyx1de.js} +5 -5
  11. package/dist/cli/{guardrail-reset-6e2vyfn9.js → guardrail-reset-1mc3st34.js} +30 -30
  12. package/dist/cli/{hive-promoter-021abs6z.js → hive-promoter-gncwtq0z.js} +30 -30
  13. package/dist/cli/{index-babtfqa0.js → index-02rbfrab.js} +450 -48
  14. package/dist/cli/{index-eqh3t8eh.js → index-0azn976d.js} +14 -14
  15. package/dist/cli/{index-9gjbe4e4.js → index-1gzdnjg9.js} +2 -2
  16. package/dist/cli/{index-g0m6kypc.js → index-21pt4jwf.js} +1 -1
  17. package/dist/cli/{index-z4bg1hv8.js → index-2mqmvxac.js} +9 -2
  18. package/dist/cli/{index-xv881ahz.js → index-3bh4h6ve.js} +108 -8
  19. package/dist/cli/index-3cegckkq.js +239 -0
  20. package/dist/cli/{index-hkmgzesw.js → index-3fpqpyp6.js} +2 -2
  21. package/dist/cli/{index-1yfpw7w0.js → index-3ttktt56.js} +1 -1
  22. package/dist/cli/{index-x6zy6veh.js → index-4pjkdcgc.js} +1 -1
  23. package/dist/cli/{index-5w915x8b.js → index-56ejcj07.js} +4 -4
  24. package/dist/cli/{index-7q56f3se.js → index-5ad8xcv3.js} +2 -2
  25. package/dist/cli/{index-e2hs0bh7.js → index-5zp4c36c.js} +1 -1
  26. package/dist/cli/{index-9vdh4kdx.js → index-84m4per1.js} +2 -2
  27. package/dist/cli/{index-txbd25bc.js → index-891g7hbf.js} +1 -1
  28. package/dist/cli/{index-3z5jtyan.js → index-a58nmnmz.js} +9 -2
  29. package/dist/cli/{index-77xy577c.js → index-bw55r5bz.js} +9 -9
  30. package/dist/cli/{index-80ekaf5b.js → index-ebshrg4x.js} +3 -3
  31. package/dist/cli/{index-5x67858f.js → index-h06112sh.js} +5 -5
  32. package/dist/cli/{index-6v77adf7.js → index-h3zhb18p.js} +2 -2
  33. package/dist/cli/{index-hw49515c.js → index-hhv2pvab.js} +1 -1
  34. package/dist/cli/{index-95qra69h.js → index-j4f8sz67.js} +4489 -2475
  35. package/dist/cli/{index-dh1gk5c5.js → index-kenz5bja.js} +32 -32
  36. package/dist/cli/{index-hexhzq5j.js → index-kvk65qzz.js} +3 -3
  37. package/dist/cli/{index-0q2mjxp2.js → index-meg33yyv.js} +1 -1
  38. package/dist/cli/{index-6zkm4p7p.js → index-pk1gbqmq.js} +1 -1
  39. package/dist/cli/{index-eajfs7v4.js → index-s6b8jgtn.js} +1 -1
  40. package/dist/cli/{index-k2ydsqs7.js → index-td0jz8xe.js} +4 -4
  41. package/dist/cli/{index-3z2f1cy8.js → index-vhbds89e.js} +4 -4
  42. package/dist/cli/{index-qgfnd206.js → index-x3y6zhgj.js} +1 -1
  43. package/dist/cli/{index-aw492hpn.js → index-x8vw6ap1.js} +58 -41
  44. package/dist/cli/{index-4gn111h3.js → index-yvepnbyd.js} +5 -5
  45. package/dist/cli/{index-0n7nm9e8.js → index-zppxpc3y.js} +2 -2
  46. package/dist/cli/index.js +30 -30
  47. package/dist/cli/{knowledge-escalator-79zbhpz5.js → knowledge-escalator-gp3mpbqe.js} +12 -12
  48. package/dist/cli/{knowledge-events-79cak7eb.js → knowledge-events-nvkhtqvn.js} +10 -10
  49. package/dist/cli/{knowledge-link-40zsr5ja.js → knowledge-link-ge0rddxw.js} +6 -6
  50. package/dist/cli/{knowledge-store-w29aw5w0.js → knowledge-store-2ngh8xvv.js} +7 -7
  51. package/dist/cli/{knowledge-validator-qsecnt2d.js → knowledge-validator-4bphyrec.js} +9 -9
  52. package/dist/cli/{pending-delegations-a2nmssr1.js → pending-delegations-nk78wx7h.js} +4 -4
  53. package/dist/cli/{pr-subscriptions-7879nq5k.js → pr-subscriptions-dq1f61ye.js} +4 -4
  54. package/dist/cli/{runner-fbgsxs74.js → runner-n50w1y4w.js} +7 -7
  55. package/dist/cli/{scan-cursor-1r3pcdqp.js → scan-cursor-c16xtygz.js} +8 -8
  56. package/dist/cli/{schema-19qsv6fw.js → schema-83tbte2g.js} +1 -1
  57. package/dist/cli/{scope-persistence-ypcrvqtt.js → scope-persistence-gdbw8xh8.js} +9 -9
  58. package/dist/cli/{skill-generator-wpp9kpa0.js → skill-generator-gr13xeha.js} +14 -14
  59. package/dist/cli/{telemetry-52pw5xac.js → telemetry-hh1j99za.js} +1 -1
  60. package/dist/cli/{worktree-collision-ownership-p31zm5k0.js → worktree-collision-ownership-4drcjymy.js} +15 -10
  61. package/dist/cli/{worktree-isolation-wcry8qnn.js → worktree-isolation-jjkfg2pg.js} +30 -30
  62. package/dist/commands/lanes.d.ts +25 -0
  63. package/dist/commands/registry.d.ts +1 -1
  64. package/dist/commands/reset-session.d.ts +8 -2
  65. package/dist/consensus/corpus.d.ts +16 -0
  66. package/dist/hooks/delegation-gate/worktree-isolation.d.ts +50 -3
  67. package/dist/hooks/delegation-gate/worktree-provisioning-owner.d.ts +40 -2
  68. package/dist/hooks/delegation-gate/worktree-recovery-authority.d.ts +201 -0
  69. package/dist/hooks/init-orphan-recovery.d.ts +5 -1
  70. package/dist/hooks/knowledge-application-gate.d.ts +10 -1
  71. package/dist/hooks/knowledge-receipt-ledger.d.ts +1 -1
  72. package/dist/hooks/trajectory-logger.d.ts +22 -6
  73. package/dist/hooks/trajectory-step-state.d.ts +43 -2
  74. package/dist/index.js +557 -552
  75. package/dist/observability/catalog.d.ts +6 -4
  76. package/dist/prm/index.d.ts +3 -3
  77. package/dist/prm/replay.d.ts +29 -2
  78. package/dist/prm/trajectory-store.d.ts +210 -20
  79. package/dist/state.d.ts +6 -4
  80. package/dist/telemetry.d.ts +21 -1
  81. package/dist/utils/atomic-write.d.ts +2 -0
  82. package/dist/utils/canonical-root.d.ts +31 -0
  83. package/dist/workflow/coder-settlement.d.ts +2 -0
  84. package/dist/worktree/index.d.ts +2 -2
  85. package/dist/worktree/merge.d.ts +47 -0
  86. package/package.json +8 -1
  87. package/dist/cli/index-fxvgaeq4.js +0 -125
  88. package/dist/cli/worktree-provisioning-owner-cve95q4f.js +0 -22
  89. package/dist/cli/{curator-drift-2h1d2fnq.js → curator-drift-h57z6tm3.js} +1 -1
@@ -9,11 +9,11 @@ import {
9
9
  } from "./index-y8552snf.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-0n7nm9e8.js";
12
+ } from "./index-zppxpc3y.js";
13
13
  import {
14
14
  assertProjectRoot,
15
15
  withEvidenceLock
16
- } from "./index-txbd25bc.js";
16
+ } from "./index-891g7hbf.js";
17
17
  import {
18
18
  exports_external,
19
19
  init_zod
@@ -4,7 +4,7 @@ import {
4
4
  readShellAuditTail,
5
5
  redactPath,
6
6
  redactShellCommand
7
- } from "./index-6v77adf7.js";
7
+ } from "./index-h3zhb18p.js";
8
8
 
9
9
  // src/services/guardrail-log-service.ts
10
10
  var BLOCK_TYPES = new Set([
@@ -8,7 +8,7 @@ import {
8
8
  import {
9
9
  EvidenceLockTimeoutError,
10
10
  withEvidenceLock
11
- } from "./index-txbd25bc.js";
11
+ } from "./index-891g7hbf.js";
12
12
  import {
13
13
  exports_external,
14
14
  init_zod
@@ -469,7 +469,14 @@ var WorktreeDescriptorSchema = exports_external.object({
469
469
  worktreeSessionId: exports_external.string().min(1).max(256),
470
470
  mergeStrategy: exports_external.enum(["merge", "rebase", "cherry-pick"]),
471
471
  laneIndex: exports_external.number().int().nonnegative().max(255),
472
- worktreeDir: exports_external.string().min(1).max(4096).nullable()
472
+ worktreeDir: exports_external.string().min(1).max(4096).nullable(),
473
+ reservationId: exports_external.string().min(1).max(512).optional(),
474
+ generation: exports_external.number().int().min(1).optional(),
475
+ provisioningOwner: exports_external.object({
476
+ reservationId: exports_external.string().min(1).max(512),
477
+ generation: exports_external.number().int().min(1),
478
+ branchName: exports_external.string().min(1).max(1024)
479
+ }).strict().optional()
473
480
  }).strict();
474
481
  var TerminalResultSchema = exports_external.object({
475
482
  eventId: exports_external.string().min(1).max(256),
@@ -4,26 +4,26 @@ import {
4
4
  } from "./index-4cgee5vh.js";
5
5
  import {
6
6
  loadPluginConfigWithMeta
7
- } from "./index-e2hs0bh7.js";
7
+ } from "./index-5zp4c36c.js";
8
8
  import {
9
9
  KnowledgeConfigSchema,
10
10
  init_schema
11
- } from "./index-3z5jtyan.js";
11
+ } from "./index-a58nmnmz.js";
12
12
  import {
13
13
  resolveHiveEventsPath
14
14
  } from "./index-ae75rja9.js";
15
15
  import {
16
16
  resolveKnowledgeStoreDir
17
- } from "./index-qgfnd206.js";
17
+ } from "./index-x3y6zhgj.js";
18
18
  import {
19
19
  atomicWriteFile
20
- } from "./index-0n7nm9e8.js";
20
+ } from "./index-zppxpc3y.js";
21
21
  import {
22
22
  assertProjectRoot
23
- } from "./index-txbd25bc.js";
23
+ } from "./index-891g7hbf.js";
24
24
  import {
25
25
  emit
26
- } from "./index-aw492hpn.js";
26
+ } from "./index-x8vw6ap1.js";
27
27
  import {
28
28
  require_proper_lockfile
29
29
  } from "./index-7g4c7s5r.js";
@@ -590,6 +590,7 @@ var CANONICAL_RECEIPT_SOURCES = new Set([
590
590
  "phase_override",
591
591
  "application_gate_staleness_release",
592
592
  "application_gate_denial_limit_release",
593
+ "application_gate_session_reset_release",
593
594
  "manual",
594
595
  "migration",
595
596
  "unknown"
@@ -1715,6 +1716,26 @@ function isLegacyUnverifiableTrace(state, traceId) {
1715
1716
  return false;
1716
1717
  return ![...state.memberships.values()].some((membership) => membership.origin === "v2");
1717
1718
  }
1719
+ function overlappingRepairUncertainties(state, filters) {
1720
+ return [...state.repairUncertainties.values()].filter((uncertainty) => {
1721
+ if (filters.phase && filters.phase !== uncertainty.phase)
1722
+ return false;
1723
+ if (filters.session_id && filters.session_id !== uncertainty.session_id) {
1724
+ return false;
1725
+ }
1726
+ return true;
1727
+ });
1728
+ }
1729
+ function repairUncertaintyUnavailable(uncertainties) {
1730
+ const scoped = uncertainties.map((uncertainty) => `${uncertainty.session_id}/${uncertainty.phase}`).join(", ");
1731
+ const detail = `receipt authority pending re-evaluation for repaired phase/session scope: ${scoped}`;
1732
+ return {
1733
+ ok: false,
1734
+ code: "store_unavailable",
1735
+ detail,
1736
+ uncertainty: detail
1737
+ };
1738
+ }
1718
1739
  async function runLocked(directory, graceDays, action, options = {}) {
1719
1740
  const observations = [];
1720
1741
  try {
@@ -1816,6 +1837,85 @@ async function commitApplicationMarkerBatch(directory, input) {
1816
1837
  return { committed, idempotent, rejected };
1817
1838
  });
1818
1839
  }
1840
+ async function commitGateReleaseBatch(directory, input) {
1841
+ return runLocked(directory, input.grace_days, async (paths, state) => {
1842
+ const committed = [];
1843
+ const idempotent = [];
1844
+ const rejected = [];
1845
+ const releases = [];
1846
+ const traceExists = state.traceIds.has(input.trace_id);
1847
+ const staged = new Set;
1848
+ for (const item of input.items) {
1849
+ const membership = state.memberships.get(keyOf(input.trace_id, item.entry_id));
1850
+ if (!membership) {
1851
+ rejected.push({
1852
+ entry_id: item.entry_id,
1853
+ reason: traceExists ? "id_not_in_trace" : isLegacyUnverifiableTrace(state, input.trace_id) ? "legacy_unverifiable" : "trace_not_found"
1854
+ });
1855
+ continue;
1856
+ }
1857
+ if (membership.session_id !== input.session_id) {
1858
+ rejected.push({ entry_id: item.entry_id, reason: "wrong_session" });
1859
+ continue;
1860
+ }
1861
+ if (staged.has(item.entry_id)) {
1862
+ idempotent.push({
1863
+ entry_id: item.entry_id,
1864
+ event_id: membership.gate_release?.event_id ?? releases.at(-1)?.release.event_id ?? ""
1865
+ });
1866
+ continue;
1867
+ }
1868
+ staged.add(item.entry_id);
1869
+ if (membership.gate_release?.membership_event_id === membership.membership_event_id) {
1870
+ idempotent.push({
1871
+ entry_id: item.entry_id,
1872
+ event_id: membership.gate_release.event_id
1873
+ });
1874
+ continue;
1875
+ }
1876
+ const release = {
1877
+ source: normalizeReceiptSource(item.source),
1878
+ reason: item.reason,
1879
+ event_id: randomUUID2(),
1880
+ committed_at: nowIso(),
1881
+ membership_event_id: membership.membership_event_id
1882
+ };
1883
+ releases.push({
1884
+ trace_id: input.trace_id,
1885
+ entry_id: item.entry_id,
1886
+ release
1887
+ });
1888
+ committed.push({
1889
+ entry_id: item.entry_id,
1890
+ event_id: release.event_id,
1891
+ membership_event_id: release.membership_event_id
1892
+ });
1893
+ }
1894
+ if (releases.length) {
1895
+ await appendRecord(paths, state, makeRecord(state, "gate_release_committed", {
1896
+ releases
1897
+ }));
1898
+ }
1899
+ return { committed, idempotent, rejected };
1900
+ });
1901
+ }
1902
+ async function queryLiveMemberships(directory, filters = {}) {
1903
+ return runLocked(directory, filters.grace_days, async (_paths, state) => {
1904
+ const overlaps = overlappingRepairUncertainties(state, {
1905
+ phase: filters.phase,
1906
+ session_id: filters.session_id
1907
+ });
1908
+ if (overlaps.length > 0) {
1909
+ throw new ReceiptStoreError("store_unavailable", repairUncertaintyUnavailable(overlaps).detail);
1910
+ }
1911
+ return {
1912
+ memberships: [...state.memberships.values()].filter((m) => (!filters.phase || m.phase === filters.phase) && (!filters.task_id || m.task_id === filters.task_id) && (!filters.session_id || m.session_id === filters.session_id) && (filters.include_terminal !== false || !m.terminal) && (filters.include_phase_closed !== false || !m.phase_closed_at) && (!filters.exposure_kind || m.exposure_kind === filters.exposure_kind)).map((m) => ({
1913
+ ...m,
1914
+ terminal: m.terminal ? { ...m.terminal } : undefined
1915
+ }))
1916
+ };
1917
+ }, { compact: false, writeSnapshot: false });
1918
+ }
1819
1919
  async function queryHistoricalOutcomes(directory, entryIds, graceDays) {
1820
1920
  return runLocked(directory, graceDays, async (paths, state) => {
1821
1921
  const wanted = entryIds ? new Set(entryIds) : null;
@@ -2693,7 +2793,7 @@ async function applyKnowledgeVerdictFeedback(directory, options) {
2693
2793
  }
2694
2794
  let bumps = 0;
2695
2795
  if (deltas.length > 0) {
2696
- const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-w29aw5w0.js");
2796
+ const { bumpKnowledgeConfidenceBatch } = await import("./knowledge-store-2ngh8xvv.js");
2697
2797
  bumps = await bumpKnowledgeConfidenceBatch(directory, deltas, options?.floorOptions);
2698
2798
  }
2699
2799
  return {
@@ -2730,4 +2830,4 @@ var _internals4 = {
2730
2830
  mergeRollupInto
2731
2831
  };
2732
2832
 
2733
- export { queryHistoricalOutcomes, recordPhaseCloseIntent, reconcilePhaseClose, KNOWLEDGE_EVENT_SCHEMA_VERSION, MAX_EVENT_LOG_ENTRIES, RECEIPT_EVENT_TYPES, resolveKnowledgeEventsPath, resolveKnowledgeCounterBaselinePath, resolveHiveEventsPath2 as resolveHiveEventsPath, resolveLegacyApplicationLogPath, newTraceId, newEventId, appendKnowledgeEvent, appendKnowledgeEventsBatch, recordKnowledgeEvent, recordKnowledgeEventsBatch, appendHiveKnowledgeEvent, recordHiveKnowledgeEvent, readKnowledgeEvents, readHiveKnowledgeEvents, readLegacyApplicationRecords, MAX_VIOLATION_TIMESTAMPS, recomputeCounters, countViolationsInWindow, countEmptyTraceTerminals, countEntryViolationsInWindow, countEntryContradictionsInWindow, readKnowledgeCounterRollups, readAuthoritativeKnowledgeCounterRollups, effectiveRetrievalOutcomes, applyKnowledgeVerdictFeedback, _internals4 as _internals };
2833
+ export { commitGateReleaseBatch, queryLiveMemberships, queryHistoricalOutcomes, recordPhaseCloseIntent, reconcilePhaseClose, KNOWLEDGE_EVENT_SCHEMA_VERSION, MAX_EVENT_LOG_ENTRIES, RECEIPT_EVENT_TYPES, resolveKnowledgeEventsPath, resolveKnowledgeCounterBaselinePath, resolveHiveEventsPath2 as resolveHiveEventsPath, resolveLegacyApplicationLogPath, newTraceId, newEventId, appendKnowledgeEvent, appendKnowledgeEventsBatch, recordKnowledgeEvent, recordKnowledgeEventsBatch, appendHiveKnowledgeEvent, recordHiveKnowledgeEvent, readKnowledgeEvents, readHiveKnowledgeEvents, readLegacyApplicationRecords, MAX_VIOLATION_TIMESTAMPS, recomputeCounters, countViolationsInWindow, countEmptyTraceTerminals, countEntryViolationsInWindow, countEntryContradictionsInWindow, readKnowledgeCounterRollups, readAuthoritativeKnowledgeCounterRollups, effectiveRetrievalOutcomes, applyKnowledgeVerdictFeedback, _internals4 as _internals };
@@ -0,0 +1,239 @@
1
+ // @bun
2
+ import {
3
+ validateSwarmPath
4
+ } from "./index-4cgee5vh.js";
5
+ import {
6
+ atomicWriteSwarmFileSync
7
+ } from "./index-td0jz8xe.js";
8
+
9
+ // src/hooks/delegation-gate/worktree-provisioning-owner.ts
10
+ import { createHash } from "crypto";
11
+ import * as fs from "fs";
12
+ import * as path from "path";
13
+ var PROVISIONING_OWNER_DIR = "worktree-provisioning-owners";
14
+ var MAX_PROVISIONING_OWNERS = 512;
15
+ var MAX_PROVISIONING_OWNER_BYTES = 16 * 1024;
16
+ var PROVISIONING_JOURNAL_PATH = path.join(".swarm", "worktree-provisioning-lifecycle.json");
17
+ var MAX_PROVISIONING_JOURNAL_BYTES = 256 * 1024;
18
+ var MAX_PROVISIONING_JOURNAL_ENTRIES = 512;
19
+ var WORKTREE_PROVISIONING_OWNER_LEASE_MS = 5 * 60 * 1000;
20
+ var WORKTREE_LIFECYCLE_LOCK_FILE = ".swarm/locks/init-orphan-recovery.lock";
21
+ var WORKTREE_PROVISIONING_LIFECYCLE_STATES = [
22
+ "OWNER_PUBLISHED",
23
+ "OWNER_REMOVED"
24
+ ];
25
+ function ownerDirectory(directory) {
26
+ return path.dirname(validateSwarmPath(directory, path.join(PROVISIONING_OWNER_DIR, ".containment-anchor")));
27
+ }
28
+ function ownerPath(directory, callID) {
29
+ const digest = createHash("sha256").update(callID).digest("hex");
30
+ return validateSwarmPath(directory, path.join(PROVISIONING_OWNER_DIR, `${digest}.json`));
31
+ }
32
+ function journalPath(directory) {
33
+ return validateSwarmPath(directory, PROVISIONING_JOURNAL_PATH);
34
+ }
35
+ function isOwner(value) {
36
+ if (!value || typeof value !== "object" || Array.isArray(value))
37
+ return false;
38
+ const candidate = value;
39
+ const schemaVersion = candidate.schemaVersion;
40
+ const validTaskIdentity = schemaVersion === 1 ? candidate.taskId === undefined && candidate.reservationId === undefined && candidate.generation === undefined && candidate.branchName === undefined : schemaVersion === 2 && typeof candidate.taskId === "string" && candidate.taskId.length > 0 && candidate.taskId.length <= 512 && candidate.reservationId === undefined && candidate.generation === undefined && candidate.branchName === undefined;
41
+ const validV3Identity = schemaVersion === 3 && typeof candidate.taskId === "string" && candidate.taskId.length > 0 && candidate.taskId.length <= 512 && typeof candidate.reservationId === "string" && candidate.reservationId.length > 0 && candidate.reservationId.length <= 512 && typeof candidate.generation === "number" && Number.isInteger(candidate.generation) && candidate.generation > 0 && typeof candidate.branchName === "string" && candidate.branchName.length > 0 && candidate.branchName.length <= 1024;
42
+ return (schemaVersion === 1 || schemaVersion === 2 || schemaVersion === 3) && (validTaskIdentity || validV3Identity) && typeof candidate.callID === "string" && candidate.callID.length > 0 && candidate.callID.length <= 512 && typeof candidate.parentSessionId === "string" && candidate.parentSessionId.length > 0 && candidate.parentSessionId.length <= 512 && typeof candidate.worktreeSessionId === "string" && candidate.worktreeSessionId.length > 0 && candidate.worktreeSessionId.length <= 512 && typeof candidate.createdAt === "number" && Number.isFinite(candidate.createdAt) && candidate.createdAt >= 0;
43
+ }
44
+ function isLifecycleEntry(value) {
45
+ if (!value || typeof value !== "object" || Array.isArray(value))
46
+ return false;
47
+ const candidate = value;
48
+ const validState = WORKTREE_PROVISIONING_LIFECYCLE_STATES.includes(candidate.state);
49
+ return candidate.schemaVersion === 1 && validState && typeof candidate.callID === "string" && candidate.callID.length > 0 && candidate.callID.length <= 512 && typeof candidate.parentSessionId === "string" && candidate.parentSessionId.length > 0 && candidate.parentSessionId.length <= 512 && typeof candidate.worktreeSessionId === "string" && candidate.worktreeSessionId.length > 0 && candidate.worktreeSessionId.length <= 512 && (candidate.taskId === undefined || typeof candidate.taskId === "string" && candidate.taskId.length > 0 && candidate.taskId.length <= 512) && (candidate.reservationId === undefined || typeof candidate.reservationId === "string" && candidate.reservationId.length > 0 && candidate.reservationId.length <= 512) && (candidate.generation === undefined || typeof candidate.generation === "number" && Number.isInteger(candidate.generation) && candidate.generation > 0) && (candidate.branchName === undefined || typeof candidate.branchName === "string" && candidate.branchName.length > 0 && candidate.branchName.length <= 1024) && typeof candidate.recordedAt === "number" && Number.isFinite(candidate.recordedAt) && candidate.recordedAt >= 0;
50
+ }
51
+ function readBoundedJsonFile(filePath, maxBytes) {
52
+ try {
53
+ const stat = fs.statSync(filePath);
54
+ if (stat.size > maxBytes) {
55
+ return {
56
+ ok: false,
57
+ reason: `${path.basename(filePath)} exceeds the ${maxBytes}-byte safety bound`
58
+ };
59
+ }
60
+ const raw = fs.readFileSync(filePath, "utf8");
61
+ if (Buffer.byteLength(raw, "utf8") > maxBytes) {
62
+ return {
63
+ ok: false,
64
+ reason: `${path.basename(filePath)} changed beyond the ${maxBytes}-byte safety bound`
65
+ };
66
+ }
67
+ return { ok: true, value: JSON.parse(raw) };
68
+ } catch (error) {
69
+ if (error.code === "ENOENT") {
70
+ return { ok: true, value: undefined };
71
+ }
72
+ return {
73
+ ok: false,
74
+ reason: `${path.basename(filePath)} is unreadable or malformed: ${error instanceof Error ? error.message : String(error)}`
75
+ };
76
+ }
77
+ }
78
+ function readOwner(directory, callID) {
79
+ const absolutePath = ownerPath(directory, callID);
80
+ const loaded = readBoundedJsonFile(absolutePath, MAX_PROVISIONING_OWNER_BYTES);
81
+ if (!loaded.ok || loaded.value === undefined)
82
+ return null;
83
+ return isOwner(loaded.value) ? loaded.value : null;
84
+ }
85
+ function loadLifecycleJournal(directory) {
86
+ const loaded = readBoundedJsonFile(journalPath(directory), MAX_PROVISIONING_JOURNAL_BYTES);
87
+ if (!loaded.ok)
88
+ return { status: "uncertain", reason: loaded.reason };
89
+ if (loaded.value === undefined)
90
+ return { status: "ok", entries: [] };
91
+ const parsed = loaded.value;
92
+ if (parsed.schemaVersion !== 1 || !Array.isArray(parsed.entries)) {
93
+ return {
94
+ status: "uncertain",
95
+ reason: "worktree provisioning lifecycle journal is malformed"
96
+ };
97
+ }
98
+ if (parsed.entries.length > MAX_PROVISIONING_JOURNAL_ENTRIES) {
99
+ return {
100
+ status: "uncertain",
101
+ reason: `worktree provisioning lifecycle journal exceeds the ${MAX_PROVISIONING_JOURNAL_ENTRIES}-entry safety bound`
102
+ };
103
+ }
104
+ const entries = [];
105
+ for (const entry of parsed.entries) {
106
+ if (!isLifecycleEntry(entry)) {
107
+ return {
108
+ status: "uncertain",
109
+ reason: "worktree provisioning lifecycle journal contains an invalid entry"
110
+ };
111
+ }
112
+ entries.push(entry);
113
+ }
114
+ return { status: "ok", entries };
115
+ }
116
+ function appendLifecycleEntry(directory, owner, state) {
117
+ const loaded = loadLifecycleJournal(directory);
118
+ if (loaded.status === "uncertain") {
119
+ throw new Error(loaded.reason);
120
+ }
121
+ const entries = [
122
+ ...loaded.entries,
123
+ {
124
+ schemaVersion: 1,
125
+ state,
126
+ callID: owner.callID,
127
+ parentSessionId: owner.parentSessionId,
128
+ worktreeSessionId: owner.worktreeSessionId,
129
+ ...owner.taskId ? { taskId: owner.taskId } : {},
130
+ ...owner.reservationId ? { reservationId: owner.reservationId } : {},
131
+ ...owner.generation !== undefined ? { generation: owner.generation } : {},
132
+ ...owner.branchName ? { branchName: owner.branchName } : {},
133
+ recordedAt: Date.now()
134
+ }
135
+ ];
136
+ const journal = {
137
+ schemaVersion: 1,
138
+ entries: entries.slice(-MAX_PROVISIONING_JOURNAL_ENTRIES)
139
+ };
140
+ atomicWriteSwarmFileSync(journalPath(directory), JSON.stringify(journal, null, 2));
141
+ }
142
+ function recordWorktreeProvisioningOwner(directory, input) {
143
+ const wantsV3 = input.reservationId !== undefined || input.generation !== undefined || input.branchName !== undefined;
144
+ if (wantsV3 && (!input.taskId || !input.reservationId || input.generation === undefined || !input.branchName)) {
145
+ throw new Error("worktree provisioning owner v3 requires taskId, reservationId, generation, and branchName");
146
+ }
147
+ const owner = {
148
+ schemaVersion: wantsV3 ? 3 : input.taskId ? 2 : 1,
149
+ callID: input.callID,
150
+ parentSessionId: input.parentSessionId,
151
+ worktreeSessionId: input.worktreeSessionId,
152
+ ...input.taskId ? { taskId: input.taskId } : {},
153
+ ...input.reservationId ? { reservationId: input.reservationId } : {},
154
+ ...input.generation !== undefined ? { generation: input.generation } : {},
155
+ ...input.branchName ? { branchName: input.branchName } : {},
156
+ createdAt: Date.now()
157
+ };
158
+ if (!isOwner(owner)) {
159
+ throw new Error("invalid worktree provisioning owner");
160
+ }
161
+ const absolutePath = ownerPath(directory, input.callID);
162
+ fs.mkdirSync(path.dirname(absolutePath), { recursive: true });
163
+ atomicWriteSwarmFileSync(absolutePath, `${JSON.stringify(owner)}
164
+ `);
165
+ appendLifecycleEntry(directory, owner, "OWNER_PUBLISHED");
166
+ return owner;
167
+ }
168
+ function removeWorktreeProvisioningOwner(directory, callID, expected) {
169
+ try {
170
+ const owner = readOwner(directory, callID);
171
+ if (owner?.schemaVersion === 3 && (!expected || expected.reservationId !== owner.reservationId || expected.generation !== owner.generation || expected.branchName !== owner.branchName)) {
172
+ return false;
173
+ }
174
+ fs.unlinkSync(ownerPath(directory, callID));
175
+ if (owner)
176
+ appendLifecycleEntry(directory, owner, "OWNER_REMOVED");
177
+ return true;
178
+ } catch (error) {
179
+ return error.code === "ENOENT";
180
+ }
181
+ }
182
+ function scanWorktreeProvisioningOwnersForRecovery(directory) {
183
+ let directoryPath;
184
+ let entries;
185
+ try {
186
+ directoryPath = ownerDirectory(directory);
187
+ entries = fs.readdirSync(directoryPath, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json"));
188
+ } catch (error) {
189
+ if (error.code === "ENOENT") {
190
+ return { status: "ok", owners: [] };
191
+ }
192
+ return {
193
+ status: "uncertain",
194
+ reason: `worktree provisioning-owner directory is unreadable: ${error instanceof Error ? error.message : String(error)}`
195
+ };
196
+ }
197
+ if (entries.length > MAX_PROVISIONING_OWNERS) {
198
+ return {
199
+ status: "uncertain",
200
+ reason: `worktree provisioning-owner count exceeds the ${MAX_PROVISIONING_OWNERS}-marker safety bound`
201
+ };
202
+ }
203
+ const owners = [];
204
+ for (const entry of entries) {
205
+ const absolutePath = path.join(directoryPath, entry.name);
206
+ try {
207
+ const stat = fs.statSync(absolutePath);
208
+ if (stat.size > MAX_PROVISIONING_OWNER_BYTES) {
209
+ return {
210
+ status: "uncertain",
211
+ reason: `worktree provisioning owner "${entry.name}" exceeds the recovery size bound`
212
+ };
213
+ }
214
+ const raw = fs.readFileSync(absolutePath, "utf8");
215
+ if (Buffer.byteLength(raw, "utf8") > MAX_PROVISIONING_OWNER_BYTES) {
216
+ return {
217
+ status: "uncertain",
218
+ reason: `worktree provisioning owner "${entry.name}" changed beyond the recovery size bound`
219
+ };
220
+ }
221
+ const parsed = JSON.parse(raw);
222
+ if (!isOwner(parsed)) {
223
+ return {
224
+ status: "uncertain",
225
+ reason: `worktree provisioning owner "${entry.name}" is invalid`
226
+ };
227
+ }
228
+ owners.push(parsed);
229
+ } catch (error) {
230
+ return {
231
+ status: "uncertain",
232
+ reason: `worktree provisioning owner "${entry.name}" is unreadable or malformed: ${error instanceof Error ? error.message : String(error)}`
233
+ };
234
+ }
235
+ }
236
+ return { status: "ok", owners };
237
+ }
238
+
239
+ export { WORKTREE_PROVISIONING_OWNER_LEASE_MS, WORKTREE_LIFECYCLE_LOCK_FILE, recordWorktreeProvisioningOwner, removeWorktreeProvisioningOwner, scanWorktreeProvisioningOwnersForRecovery };
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  init_loader,
4
4
  loadPluginConfigWithMeta
5
- } from "./index-e2hs0bh7.js";
5
+ } from "./index-5zp4c36c.js";
6
6
  import {
7
7
  init_schema
8
- } from "./index-3z5jtyan.js";
8
+ } from "./index-a58nmnmz.js";
9
9
  import {
10
10
  DEFAULT_WORKTREE_ISOLATION_CONFIG,
11
11
  init_constants
@@ -7,7 +7,7 @@ import {
7
7
  readLinkPointer,
8
8
  resolveKnowledgeStoreDir,
9
9
  resolveLinkDir
10
- } from "./index-qgfnd206.js";
10
+ } from "./index-x3y6zhgj.js";
11
11
 
12
12
  // src/knowledge/curation-policy.ts
13
13
  import { appendFile, mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-9gjbe4e4.js";
12
+ } from "./index-1gzdnjg9.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  authorizeCuration
4
- } from "./index-1yfpw7w0.js";
4
+ } from "./index-3ttktt56.js";
5
5
  import {
6
6
  findNearDuplicate,
7
7
  inferTags,
@@ -9,13 +9,13 @@ import {
9
9
  resolveSwarmKnowledgePath,
10
10
  resolveSwarmRejectedPath,
11
11
  transactKnowledge
12
- } from "./index-77xy577c.js";
12
+ } from "./index-bw55r5bz.js";
13
13
  import {
14
14
  resolveKnowledgeStoreDir
15
- } from "./index-qgfnd206.js";
15
+ } from "./index-x3y6zhgj.js";
16
16
  import {
17
17
  atomicWriteFile
18
- } from "./index-0n7nm9e8.js";
18
+ } from "./index-zppxpc3y.js";
19
19
  import {
20
20
  require_proper_lockfile
21
21
  } from "./index-7g4c7s5r.js";
@@ -2,14 +2,14 @@
2
2
  import {
3
3
  readKnowledge,
4
4
  transactKnowledge
5
- } from "./index-77xy577c.js";
5
+ } from "./index-bw55r5bz.js";
6
6
  import {
7
7
  init_git_executable,
8
8
  resolveGitExecutableAsync
9
9
  } from "./index-9e6fdz2h.js";
10
10
  import {
11
11
  resolveKnowledgeStoreDir
12
- } from "./index-qgfnd206.js";
12
+ } from "./index-x3y6zhgj.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
@@ -6,7 +6,7 @@ import {
6
6
  PluginConfigSchema,
7
7
  init_schema,
8
8
  resolveExternalSkillsConfig
9
- } from "./index-3z5jtyan.js";
9
+ } from "./index-a58nmnmz.js";
10
10
  import {
11
11
  GIT_BINARY_ENV_VAR,
12
12
  init_git_executable
@@ -14,14 +14,14 @@ import {
14
14
  detectWindowsWrites,
15
15
  getSharedClassifierGuardrailBlock,
16
16
  resolveWriteTargets
17
- } from "./index-95qra69h.js";
17
+ } from "./index-j4f8sz67.js";
18
18
  import {
19
19
  checkFileAuthority,
20
20
  classifyFile,
21
21
  isInDeclaredScope,
22
22
  redactPath,
23
23
  redactShellCommand
24
- } from "./index-6v77adf7.js";
24
+ } from "./index-h3zhb18p.js";
25
25
 
26
26
  // src/services/guardrail-explain-service.ts
27
27
  import path from "path";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  emit
4
- } from "./index-aw492hpn.js";
4
+ } from "./index-x8vw6ap1.js";
5
5
  import {
6
6
  require_proper_lockfile
7
7
  } from "./index-7g4c7s5r.js";
@@ -21,7 +21,7 @@ var package_default;
21
21
  var init_package = __esm(() => {
22
22
  package_default = {
23
23
  name: "opencode-swarm",
24
- version: "7.153.0",
24
+ version: "7.153.2",
25
25
  description: "Architect-centric agentic swarm plugin for OpenCode - hub-and-spoke orchestration with SME consultation, code generation, and QA review",
26
26
  main: "dist/index.js",
27
27
  types: "dist/index.d.ts",
@@ -132,7 +132,14 @@ var init_package = __esm(() => {
132
132
  "check:retention": "bun run scripts/check-retention-registry.ts",
133
133
  "check:core-events": "bun run scripts/check-core-events-usage.ts",
134
134
  "check:shell-audit": "bun run scripts/check-shell-audit-usage.ts",
135
+ "check:trajectory-store": "bun run scripts/check-trajectory-store-usage.ts",
136
+ "check:mock-cleanup": "bun run scripts/check-mock-cleanup.ts",
137
+ "check:invariants": "bun run scripts/check-invariants.ts",
138
+ "check:cross-contamination": "bun run scripts/check-cross-contamination.ts",
139
+ "check:test-clock": "bun run scripts/check-test-clock.ts",
135
140
  "check:test-file-cap": "bun run scripts/check-test-file-cap.ts",
141
+ "check:test-tmpdir": "bun run scripts/check-test-tmpdir.ts",
142
+ "check:bash-portability": "bun run scripts/check-bash-portability.ts",
136
143
  "check:pending-fragment": "bun run scripts/check-pending-fragment.ts",
137
144
  "check:gate-portability": "bun run scripts/check-gate-portability.ts",
138
145
  "check:bare-spawn": "bun run scripts/check-bare-executable-spawn.ts",
@@ -1349,7 +1356,7 @@ var init_schema = __esm(() => {
1349
1356
  stuck_on_test: 3,
1350
1357
  context_thrash: 10
1351
1358
  })),
1352
- max_trajectory_lines: exports_external.number().min(10).default(1000),
1359
+ max_trajectory_lines: exports_external.number().min(10).max(1e4).default(1000),
1353
1360
  escalation_enabled: exports_external.boolean().default(true),
1354
1361
  detection_timeout_ms: exports_external.number().min(10).default(100)
1355
1362
  });
@@ -6,20 +6,20 @@ import {
6
6
  } from "./index-ae75rja9.js";
7
7
  import {
8
8
  resolveKnowledgeStoreDir
9
- } from "./index-qgfnd206.js";
9
+ } from "./index-x3y6zhgj.js";
10
10
  import {
11
11
  atomicWriteFile
12
- } from "./index-0n7nm9e8.js";
12
+ } from "./index-zppxpc3y.js";
13
13
  import {
14
14
  init_knowledge_types,
15
15
  isActiveStatus
16
16
  } from "./index-bk5tah7q.js";
17
- import {
18
- require_proper_lockfile
19
- } from "./index-7g4c7s5r.js";
20
17
  import {
21
18
  readCachedParsedFile
22
19
  } from "./index-ed5ykebp.js";
20
+ import {
21
+ require_proper_lockfile
22
+ } from "./index-7g4c7s5r.js";
23
23
  import {
24
24
  init_logger,
25
25
  log
@@ -713,7 +713,7 @@ async function applyConfidenceFloorAction(directory, touched, options) {
713
713
  const {
714
714
  readAuthoritativeKnowledgeCounterRollups,
715
715
  effectiveRetrievalOutcomes
716
- } = await import("./knowledge-events-79cak7eb.js");
716
+ } = await import("./knowledge-events-nvkhtqvn.js");
717
717
  const rollups = await readAuthoritativeKnowledgeCounterRollups(directory);
718
718
  const flagIds = new Set;
719
719
  for (const e of atFloor) {
@@ -780,11 +780,11 @@ async function applyConfidenceFloorAction(directory, touched, options) {
780
780
  });
781
781
  }
782
782
  if (action === "quarantine" && toQuarantine.length > 0) {
783
- const { quarantineEntry } = await import("./knowledge-validator-qsecnt2d.js");
784
- const { KnowledgeConfigSchema } = await import("./schema-19qsv6fw.js");
783
+ const { quarantineEntry } = await import("./knowledge-validator-4bphyrec.js");
784
+ const { KnowledgeConfigSchema } = await import("./schema-83tbte2g.js");
785
785
  let config;
786
786
  try {
787
- const { loadPluginConfigWithMeta } = await import("./index-hexhzq5j.js");
787
+ const { loadPluginConfigWithMeta } = await import("./index-kvk65qzz.js");
788
788
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
789
789
  config = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
790
790
  } catch {