opencode-swarm 7.153.1 → 7.154.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 (76) hide show
  1. package/dist/background/pending-delegations.d.ts +29 -0
  2. package/dist/background/pr-subscriptions.d.ts +258 -27
  3. package/dist/cli/{config-doctor-ze21qs6b.js → config-doctor-8p9y543t.js} +2 -2
  4. package/dist/cli/{core-qdmhh1kx.js → core-1h6x6k59.js} +1 -1
  5. package/dist/cli/{curation-policy-twa6agf8.js → curation-policy-9r902jw4.js} +6 -6
  6. package/dist/cli/{curator-llm-factory-s8atmc2n.js → curator-llm-factory-ypwf3a90.js} +29 -29
  7. package/dist/cli/{curator-hxb3wsxr.js → curator-yj00z1qz.js} +29 -29
  8. package/dist/cli/{evidence-summary-service-wzzym9r7.js → evidence-summary-service-npq04240.js} +12 -12
  9. package/dist/cli/{gate-evidence-f71dn9vv.js → gate-evidence-4b6t0ycn.js} +6 -6
  10. package/dist/cli/{guardrail-explain-5kzeem4m.js → guardrail-explain-dyxbhrdj.js} +30 -30
  11. package/dist/cli/{guardrail-log-38jnajpa.js → guardrail-log-eyecsekk.js} +5 -5
  12. package/dist/cli/{guardrail-reset-wzvtmpn2.js → guardrail-reset-269jdwhd.js} +29 -29
  13. package/dist/cli/{hive-promoter-55qcqgfx.js → hive-promoter-5936am48.js} +29 -29
  14. package/dist/cli/{index-0tyc8kdg.js → index-10zvxqra.js} +1 -1
  15. package/dist/cli/{index-6ybjrqf7.js → index-1tdsddab.js} +284 -107
  16. package/dist/cli/{index-23rneydq.js → index-2kzxkx50.js} +31 -31
  17. package/dist/cli/{index-tdzbm974.js → index-2mbs5q26.js} +108 -8
  18. package/dist/cli/{index-x3y6zhgj.js → index-3db7xza0.js} +1 -1
  19. package/dist/cli/{index-gn26q90p.js → index-3hdnfmhp.js} +2 -2
  20. package/dist/cli/{index-0tzv5zg2.js → index-3mhgv8d6.js} +2 -2
  21. package/dist/cli/{index-6vgb5fyb.js → index-48m4841x.js} +1 -1
  22. package/dist/cli/{index-mb7b1gye.js → index-4g00jhbs.js} +3 -3
  23. package/dist/cli/{index-1akn19mp.js → index-4y7g04py.js} +1 -1
  24. package/dist/cli/{index-n5pxkera.js → index-68w5jxv5.js} +4 -4
  25. package/dist/cli/{index-4pjkdcgc.js → index-6yc06dx9.js} +1 -1
  26. package/dist/cli/{index-2mqmvxac.js → index-7jnh1sgb.js} +7 -1
  27. package/dist/cli/{index-pk1gbqmq.js → index-c6dfyzdh.js} +1 -1
  28. package/dist/cli/{index-td0jz8xe.js → index-c809a69b.js} +2 -2
  29. package/dist/cli/{index-af0cqe6n.js → index-dwh02jmv.js} +7 -7
  30. package/dist/cli/{index-3cegckkq.js → index-garsang6.js} +1 -1
  31. package/dist/cli/{index-k10qtq71.js → index-hk4wa0v1.js} +6 -6
  32. package/dist/cli/{index-8v9sj4aq.js → index-mddgkqg9.js} +2 -2
  33. package/dist/cli/{index-4g0g3dqz.js → index-nkr634n6.js} +1 -1
  34. package/dist/cli/{index-ajkxx2k6.js → index-p4y7jefb.js} +2 -2
  35. package/dist/cli/{index-xkjrg9k4.js → index-pcj7jk4t.js} +3 -3
  36. package/dist/cli/{index-v689bmr2.js → index-qcz4xprd.js} +4 -4
  37. package/dist/cli/{index-zppxpc3y.js → index-s0a4ewkb.js} +2 -2
  38. package/dist/cli/{index-1dtshrzg.js → index-s70tmqn3.js} +5 -5
  39. package/dist/cli/{index-smqsp8hs.js → index-snnps1vm.js} +5 -5
  40. package/dist/cli/{index-n823qsae.js → index-tnm9bb8b.js} +11 -3
  41. package/dist/cli/{index-x8vw6ap1.js → index-ttqnhxxq.js} +59 -42
  42. package/dist/cli/{index-891g7hbf.js → index-vtdwkfbv.js} +1 -1
  43. package/dist/cli/index-wfxg3s7n.js +1158 -0
  44. package/dist/cli/{index-9v8d3c0k.js → index-wpstzk85.js} +4 -4
  45. package/dist/cli/{index-1gzdnjg9.js → index-y64jrbch.js} +2 -2
  46. package/dist/cli/{index-3ttktt56.js → index-yve4e8fx.js} +1 -1
  47. package/dist/cli/index.js +29 -29
  48. package/dist/cli/{knowledge-escalator-w05ztgvk.js → knowledge-escalator-bxpzeth0.js} +11 -11
  49. package/dist/cli/{knowledge-events-pwm9jc0m.js → knowledge-events-jxdpg2hj.js} +9 -9
  50. package/dist/cli/{knowledge-link-ge0rddxw.js → knowledge-link-nwxykjya.js} +5 -5
  51. package/dist/cli/{knowledge-store-4xv65tj2.js → knowledge-store-336hyzs8.js} +6 -6
  52. package/dist/cli/{knowledge-validator-0ttfsca7.js → knowledge-validator-9wkvnsv0.js} +8 -8
  53. package/dist/cli/{pending-delegations-nk78wx7h.js → pending-delegations-0fmj1qy6.js} +3 -3
  54. package/dist/cli/{pr-subscriptions-dq1f61ye.js → pr-subscriptions-1ndwgtbw.js} +15 -4
  55. package/dist/cli/{runner-n50w1y4w.js → runner-06dvm53x.js} +6 -6
  56. package/dist/cli/{scan-cursor-b6n15w8d.js → scan-cursor-3xxqtxwx.js} +7 -7
  57. package/dist/cli/{schema-jkbfwqr2.js → schema-jdx83m4m.js} +1 -1
  58. package/dist/cli/{scope-persistence-5xt2m5ep.js → scope-persistence-wgxn2kba.js} +8 -8
  59. package/dist/cli/{skill-generator-3keadpf7.js → skill-generator-vmxsc2fm.js} +13 -13
  60. package/dist/cli/{telemetry-hh1j99za.js → telemetry-q2km2zrz.js} +1 -1
  61. package/dist/cli/{worktree-collision-ownership-4drcjymy.js → worktree-collision-ownership-gsay5210.js} +5 -5
  62. package/dist/cli/{worktree-isolation-1ymaxn4h.js → worktree-isolation-peb4bkg3.js} +29 -29
  63. package/dist/commands/pr-monitor-status.d.ts +8 -1
  64. package/dist/commands/registry.d.ts +1 -1
  65. package/dist/commands/reset-session.d.ts +8 -2
  66. package/dist/config/schema.d.ts +8 -0
  67. package/dist/hooks/knowledge-application-gate.d.ts +10 -1
  68. package/dist/hooks/knowledge-receipt-ledger.d.ts +1 -1
  69. package/dist/hooks/pr-review-resilience-circuit.d.ts +232 -0
  70. package/dist/hooks/pr-workflow-gate.d.ts +10 -11
  71. package/dist/index.js +249 -240
  72. package/dist/observability/catalog.d.ts +6 -3
  73. package/dist/state.d.ts +6 -4
  74. package/dist/telemetry.d.ts +21 -1
  75. package/package.json +7 -1
  76. package/dist/cli/index-meg33yyv.js +0 -247
@@ -6,13 +6,13 @@ import {
6
6
  protectedRoots,
7
7
  redactDecisionLineForArchive,
8
8
  stableCanonicalStringify
9
- } from "./index-gn26q90p.js";
9
+ } from "./index-3hdnfmhp.js";
10
10
  import {
11
11
  detectStraySwarmDirs,
12
12
  readDoctorArtifact,
13
13
  removeStraySwarmDir,
14
14
  runConfigDoctor
15
- } from "./index-0tyc8kdg.js";
15
+ } from "./index-10zvxqra.js";
16
16
  import {
17
17
  MAX_TRANSIENT_RETRIES,
18
18
  archiveEvidence,
@@ -59,7 +59,7 @@ import {
59
59
  validateProjectRoot,
60
60
  validateSymlinkBoundary,
61
61
  validateTargetWithinRoot
62
- } from "./index-af0cqe6n.js";
62
+ } from "./index-dwh02jmv.js";
63
63
  import {
64
64
  loadDatabaseCtor
65
65
  } from "./index-134d35c1.js";
@@ -79,7 +79,7 @@ import {
79
79
  resolveExecutableFromPath,
80
80
  runEvaluation,
81
81
  runExternalTool
82
- } from "./index-4pjkdcgc.js";
82
+ } from "./index-6yc06dx9.js";
83
83
  import {
84
84
  EvaluationTaskV1Schema,
85
85
  GateAuditManifestV1Schema,
@@ -96,7 +96,7 @@ import {
96
96
  saveGateAuditResult,
97
97
  savePromotionDecision,
98
98
  saveTaskSetSnapshot
99
- } from "./index-1gzdnjg9.js";
99
+ } from "./index-y64jrbch.js";
100
100
  import {
101
101
  canonicalHash,
102
102
  canonicalJson,
@@ -112,7 +112,7 @@ import {
112
112
  alreadyCuratedThisGeneration,
113
113
  claimNextScanBatch,
114
114
  resolveCohortId
115
- } from "./index-8v9sj4aq.js";
115
+ } from "./index-mddgkqg9.js";
116
116
  import {
117
117
  CURATOR_INIT_PROMPT,
118
118
  CURATOR_PHASE_PROMPT,
@@ -158,10 +158,11 @@ import {
158
158
  } from "./index-vnn7qq8c.js";
159
159
  import {
160
160
  buildCorrelationId,
161
+ getPrSubscriptionHealth,
161
162
  listActive,
162
163
  subscribe,
163
164
  unsubscribe
164
- } from "./index-meg33yyv.js";
165
+ } from "./index-wfxg3s7n.js";
165
166
  import {
166
167
  BUNDLED_PROJECT_SKILL_ROOT,
167
168
  DEFAULT_SKILL_MIN_CONFIDENCE,
@@ -182,10 +183,10 @@ import {
182
183
  retireSkill,
183
184
  selectCandidateEntries,
184
185
  syncBundledProjectSkillsIfMissingAsync
185
- } from "./index-n5pxkera.js";
186
+ } from "./index-68w5jxv5.js";
186
187
  import {
187
188
  readRecentEscalations
188
- } from "./index-smqsp8hs.js";
189
+ } from "./index-snnps1vm.js";
189
190
  import {
190
191
  appendUnactionable,
191
192
  quarantineEntry,
@@ -196,11 +197,11 @@ import {
196
197
  validateActionableFields,
197
198
  validateLesson,
198
199
  validateSkillPath
199
- } from "./index-v689bmr2.js";
200
+ } from "./index-qcz4xprd.js";
200
201
  import {
201
202
  authorizeCuration,
202
203
  buildConfigFingerprintInput
203
- } from "./index-3ttktt56.js";
204
+ } from "./index-yve4e8fx.js";
204
205
  import {
205
206
  cohortConfigFingerprint
206
207
  } from "./index-rtry5xyf.js";
@@ -208,7 +209,7 @@ import {
208
209
  WORKTREE_LIFECYCLE_LOCK_FILE,
209
210
  recordWorktreeProvisioningOwner,
210
211
  removeWorktreeProvisioningOwner
211
- } from "./index-3cegckkq.js";
212
+ } from "./index-garsang6.js";
212
213
  import {
213
214
  clearWorktreeMergeStatus,
214
215
  getAllWorktreeMergeFailures,
@@ -243,12 +244,12 @@ import {
243
244
  transitionTaskWorkflowEvidence,
244
245
  withTaskEvidenceTransaction,
245
246
  writeWorkflowWalFile
246
- } from "./index-9v8d3c0k.js";
247
+ } from "./index-wpstzk85.js";
247
248
  import {
248
249
  makeWorktreeBranchName,
249
250
  provisionWorktree,
250
251
  removeWorktree
251
- } from "./index-4g0g3dqz.js";
252
+ } from "./index-nkr634n6.js";
252
253
  import {
253
254
  DEFAULT_STALE_DELEGATION_TIMEOUT_MS,
254
255
  DELEGATION_COMPACTION_HIGH_WATER_BYTES,
@@ -263,14 +264,14 @@ import {
263
264
  scanBackgroundCoderReservationsForAdmission,
264
265
  scanDelegationsForRecovery,
265
266
  sweepStaleDelegations
266
- } from "./index-2mqmvxac.js";
267
+ } from "./index-7jnh1sgb.js";
267
268
  import {
268
269
  MAX_PENDING_SCOPE_BINDINGS,
269
270
  canonicalWorkspaceIdentity,
270
271
  clearAllScopes,
271
272
  clearScopeBindingFromDisk,
272
273
  clearScopeBindings
273
- } from "./index-1dtshrzg.js";
274
+ } from "./index-s70tmqn3.js";
274
275
  import {
275
276
  appendLedgerEvent,
276
277
  computePlanHash,
@@ -285,7 +286,7 @@ import {
285
286
  readPlanEpochIdentity,
286
287
  replayFromLedgerWithStatus,
287
288
  takeSnapshotEvent
288
- } from "./index-mb7b1gye.js";
289
+ } from "./index-4g00jhbs.js";
289
290
  import {
290
291
  CORE_EVENT_LOCKED,
291
292
  appendCoreEventSync,
@@ -295,7 +296,7 @@ import {
295
296
  hasSpecDriftAuditEvent,
296
297
  hasTaskRepairAuditEvent,
297
298
  readCoreEvents
298
- } from "./index-pk1gbqmq.js";
299
+ } from "./index-c6dfyzdh.js";
299
300
  import {
300
301
  isPathWithinDeclaredScope,
301
302
  sanitizeDiagnosticText
@@ -345,12 +346,14 @@ import {
345
346
  transactFile,
346
347
  transactKnowledge,
347
348
  wordBigrams
348
- } from "./index-k10qtq71.js";
349
+ } from "./index-hk4wa0v1.js";
349
350
  import {
350
351
  MAX_EVENT_LOG_ENTRIES,
351
352
  _internals as _internals2,
353
+ commitGateReleaseBatch,
352
354
  effectiveRetrievalOutcomes,
353
355
  queryHistoricalOutcomes,
356
+ queryLiveMemberships,
354
357
  readAuthoritativeKnowledgeCounterRollups,
355
358
  readKnowledgeCounterRollups,
356
359
  readKnowledgeEvents,
@@ -359,10 +362,10 @@ import {
359
362
  recordKnowledgeEvent,
360
363
  recordPhaseCloseIntent,
361
364
  resolveKnowledgeEventsPath
362
- } from "./index-tdzbm974.js";
365
+ } from "./index-2mbs5q26.js";
363
366
  import {
364
367
  resolveWorktreeIsolationConfig
365
- } from "./index-ajkxx2k6.js";
368
+ } from "./index-p4y7jefb.js";
366
369
  import {
367
370
  RetrospectiveEvidenceSchema
368
371
  } from "./index-gprxjmm7.js";
@@ -384,7 +387,7 @@ import {
384
387
  init_loader,
385
388
  loadPluginConfig,
386
389
  loadPluginConfigWithMeta
387
- } from "./index-1akn19mp.js";
390
+ } from "./index-4y7g04py.js";
388
391
  import {
389
392
  DEFAULT_PR_REVIEW_RESILIENCE_CONFIG,
390
393
  DEFAULT_SKILL_OPT_CONFIG,
@@ -399,7 +402,7 @@ import {
399
402
  package_default,
400
403
  resolveAutoReviewConfig,
401
404
  stripKnownSwarmPrefix
402
- } from "./index-n823qsae.js";
405
+ } from "./index-tnm9bb8b.js";
403
406
  import {
404
407
  AGENT_TOOL_MAP,
405
408
  ALL_AGENT_NAMES,
@@ -439,10 +442,10 @@ import {
439
442
  resolveLinkDir,
440
443
  sanitizeLinkId,
441
444
  writeLinkPointer
442
- } from "./index-x3y6zhgj.js";
445
+ } from "./index-3db7xza0.js";
443
446
  import {
444
447
  atomicWriteFile
445
- } from "./index-zppxpc3y.js";
448
+ } from "./index-s0a4ewkb.js";
446
449
  import {
447
450
  KNOWLEDGE_SCHEMA_VERSION,
448
451
  OUTCOME_BLOCK_THRESHOLD,
@@ -454,7 +457,7 @@ import {
454
457
  atomicWriteSwarmFileSync,
455
458
  matchTempGrammar,
456
459
  parseTargetBasename
457
- } from "./index-td0jz8xe.js";
460
+ } from "./index-c809a69b.js";
458
461
  import {
459
462
  assertProjectRoot,
460
463
  hasExplicitProjectBoundary,
@@ -462,7 +465,7 @@ import {
462
465
  listActiveLocks,
463
466
  tryAcquireLock,
464
467
  withEvidenceLock
465
- } from "./index-891g7hbf.js";
468
+ } from "./index-vtdwkfbv.js";
466
469
  import {
467
470
  invalidateCachedArtifact,
468
471
  resetSwarmArtifactCache
@@ -471,7 +474,7 @@ import {
471
474
  emit,
472
475
  getLastHeartbeat,
473
476
  telemetry
474
- } from "./index-x8vw6ap1.js";
477
+ } from "./index-ttqnhxxq.js";
475
478
  import {
476
479
  require_proper_lockfile
477
480
  } from "./index-7g4c7s5r.js";
@@ -6824,7 +6827,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
6824
6827
  awaitingMergeByCallID,
6825
6828
  cleanupStandardWorktreeForCallId,
6826
6829
  standardWorktreeByCallID
6827
- } = await import("./worktree-isolation-1ymaxn4h.js");
6830
+ } = await import("./worktree-isolation-peb4bkg3.js");
6828
6831
  standardWorktreeByCallID.delete(descriptor.callID);
6829
6832
  if (hasResidue)
6830
6833
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -6930,7 +6933,7 @@ async function recoverCoderSettlement(directory, taskId) {
6930
6933
  awaitingMergeByCallID,
6931
6934
  finishStandardWorktreeDispatch,
6932
6935
  standardWorktreeByCallID
6933
- } = await import("./worktree-isolation-1ymaxn4h.js");
6936
+ } = await import("./worktree-isolation-peb4bkg3.js");
6934
6937
  const descriptor = wal.worktree;
6935
6938
  const reconstructedDispatch = {
6936
6939
  callID: descriptor.callID,
@@ -9758,6 +9761,91 @@ var _internals16 = {
9758
9761
  // src/hooks/pr-workflow-gate.ts
9759
9762
  init_tool_metadata();
9760
9763
  init_logger();
9764
+
9765
+ // src/hooks/pr-review-resilience-circuit.ts
9766
+ init_zod();
9767
+ var PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT = 768;
9768
+ var PrReviewCircuitLegacyRecordSchema = exports_external.object({
9769
+ signature: exports_external.string().min(1).max(512),
9770
+ count: exports_external.number().int().min(2).max(PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT),
9771
+ contributors: exports_external.array(exports_external.object({ batchId: exports_external.string().min(1), laneId: exports_external.string().min(1) }).strict()).min(2).max(PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT),
9772
+ openedAt: exports_external.string().min(1)
9773
+ }).strict();
9774
+ var PrReviewCircuitRecordV2Schema = exports_external.object({
9775
+ version: exports_external.literal(2),
9776
+ state: exports_external.enum(["CLOSED", "OPEN", "HALF_OPEN"]),
9777
+ generation: exports_external.number().int().min(1),
9778
+ providerClass: exports_external.string().min(1).max(128).optional(),
9779
+ contributors: exports_external.array(exports_external.object({
9780
+ batchId: exports_external.string().min(1),
9781
+ laneId: exports_external.string().min(1),
9782
+ terminalAt: exports_external.string().min(1)
9783
+ }).strict()).max(PR_REVIEW_CIRCUIT_CONTRIBUTOR_LIMIT),
9784
+ openedAt: exports_external.string().min(1).optional(),
9785
+ openUntil: exports_external.string().min(1).optional(),
9786
+ evidenceWaterline: exports_external.string().min(1).optional(),
9787
+ probe: exports_external.object({
9788
+ batchId: exports_external.string().min(1),
9789
+ laneId: exports_external.string().min(1),
9790
+ admittedAt: exports_external.string().min(1)
9791
+ }).strict().optional()
9792
+ }).strict();
9793
+ var PrReviewCircuitRecordSchema = exports_external.union([
9794
+ PrReviewCircuitLegacyRecordSchema,
9795
+ PrReviewCircuitRecordV2Schema
9796
+ ]);
9797
+ var CIRCUIT_TERMINAL_DELEGATION_STATUSES = new Set([
9798
+ "completed",
9799
+ "error",
9800
+ "cancelled",
9801
+ "stale"
9802
+ ]);
9803
+ function zeroOutputResult(result) {
9804
+ const outputRef = result.outputRef?.trim();
9805
+ const text = result.text?.trim() ?? "";
9806
+ return !outputRef && text.length === 0 && (result.chars ?? 0) === 0;
9807
+ }
9808
+ function classifyPrReviewCircuitSignal(record) {
9809
+ if (!CIRCUIT_TERMINAL_DELEGATION_STATUSES.has(record.status))
9810
+ return null;
9811
+ const result = record.terminalResult?.result ?? record.result;
9812
+ const providerClass = result?.terminalErrorClass?.category;
9813
+ if (result?.terminalErrorClass && providerClass) {
9814
+ if (record.status !== "error") {
9815
+ return { kind: "ignored", reason: "cancellation" };
9816
+ }
9817
+ if (result.terminalErrorClass.kind === "provider") {
9818
+ return {
9819
+ kind: "provider_terminal",
9820
+ providerClass,
9821
+ batchId: record.batchId ?? "",
9822
+ laneId: record.laneId ?? "",
9823
+ terminalAtMs: record.terminalResult?.recordedAt ?? record.completedAt ?? record.updatedAt ?? record.createdAt ?? 0
9824
+ };
9825
+ }
9826
+ if (result.terminalErrorClass.kind === "aborted") {
9827
+ return { kind: "ignored", reason: "cancellation" };
9828
+ }
9829
+ if (result.terminalErrorClass.kind === "output_length") {
9830
+ return { kind: "ignored", reason: "validation" };
9831
+ }
9832
+ return { kind: "ignored", reason: "unknown" };
9833
+ }
9834
+ switch (record.status) {
9835
+ case "error":
9836
+ return { kind: "ignored", reason: "unknown" };
9837
+ case "stale":
9838
+ return { kind: "ignored", reason: "stale_observation" };
9839
+ case "cancelled":
9840
+ return { kind: "ignored", reason: "cancellation" };
9841
+ case "completed":
9842
+ return zeroOutputResult(result ?? {}) ? { kind: "ignored", reason: "parser" } : null;
9843
+ default:
9844
+ return null;
9845
+ }
9846
+ }
9847
+
9848
+ // src/hooks/pr-workflow-gate.ts
9761
9849
  var PR_REVIEW_BASE_DIMENSION_IDS = [
9762
9850
  "intent-architecture",
9763
9851
  "correctness-state",
@@ -9826,7 +9914,8 @@ var PrReviewResiliencePolicyRecordSchema = exports_external.object({
9826
9914
  canaryProbeMs: exports_external.number().int().positive(),
9827
9915
  statusProbeTimeoutMs: exports_external.number().int().positive(),
9828
9916
  correlatedFailureThreshold: exports_external.number().int().min(2).max(8),
9829
- maxRetryAttemptsAfterInitial: exports_external.number().int().min(0).max(2)
9917
+ maxRetryAttemptsAfterInitial: exports_external.number().int().min(0).max(2),
9918
+ circuitOpenDurationMs: exports_external.number().int().min(1000).max(1800000).optional()
9830
9919
  }).strict();
9831
9920
  var PrReviewResilienceAttemptRecordSchema = exports_external.object({
9832
9921
  attempt: exports_external.union([exports_external.literal(0), exports_external.literal(1), exports_external.literal(2)]),
@@ -9837,19 +9926,10 @@ var PrReviewResilienceAttemptRecordSchema = exports_external.object({
9837
9926
  admittedAt: exports_external.string().min(1),
9838
9927
  fanoutBatchId: exports_external.string().min(1).optional()
9839
9928
  }).strict();
9840
- var PrReviewResilienceCircuitRecordSchema = exports_external.object({
9841
- signature: exports_external.string().min(1).max(512),
9842
- count: exports_external.number().int().min(2).max(MAX_PR_REVIEW_RESILIENCE_CIRCUIT_CONTRIBUTORS),
9843
- contributors: exports_external.array(exports_external.object({
9844
- batchId: exports_external.string().min(1),
9845
- laneId: exports_external.string().min(1)
9846
- }).strict()).min(2).max(MAX_PR_REVIEW_RESILIENCE_CIRCUIT_CONTRIBUTORS),
9847
- openedAt: exports_external.string().min(1)
9848
- }).strict();
9849
9929
  var PrReviewResilienceStateRecordSchema = exports_external.object({
9850
9930
  policy: PrReviewResiliencePolicyRecordSchema,
9851
9931
  attempts: exports_external.array(PrReviewResilienceAttemptRecordSchema).max(3),
9852
- circuit: PrReviewResilienceCircuitRecordSchema.optional()
9932
+ circuit: PrReviewCircuitRecordSchema.optional()
9853
9933
  }).strict();
9854
9934
  var PrReviewPartialBaseCoverageRecordSchema = exports_external.object({
9855
9935
  runId: exports_external.string().min(1).max(128),
@@ -10555,34 +10635,14 @@ function snapshotPrReviewResiliencePolicy(policy) {
10555
10635
  canaryProbeMs: policy?.canary_probe_ms ?? 300000,
10556
10636
  statusProbeTimeoutMs: policy?.status_probe_timeout_ms ?? 2000,
10557
10637
  correlatedFailureThreshold: policy?.correlated_failure_threshold ?? 2,
10558
- maxRetryAttemptsAfterInitial: policy?.max_retry_attempts_after_initial ?? 2
10638
+ maxRetryAttemptsAfterInitial: policy?.max_retry_attempts_after_initial ?? 2,
10639
+ circuitOpenDurationMs: policy?.circuit_open_duration_ms ?? DEFAULT_PR_REVIEW_RESILIENCE_CONFIG.circuit_open_duration_ms
10559
10640
  };
10560
10641
  }
10561
10642
  function effectivePrReviewResiliencePolicy(state, requestedPolicy) {
10562
10643
  return state.prReviewResilience?.policy ?? snapshotPrReviewResiliencePolicy(requestedPolicy);
10563
10644
  }
10564
- function normalizeFailureSignatureText(value) {
10565
- return value.toLowerCase().replace(/\b\d{4}-\d{2}-\d{2}t\d{2}:\d{2}:\d{2}(?:\.\d{1,6})?(?:z|[+-]\d{2}:\d{2})\b/g, "<iso-timestamp>").replace(/\b\d{10,16}\b/g, "<epoch>").replace(/\b((?:session|request|trace|correlation|run)(?:[_-]?id)?)\s*[:=]\s*([a-z0-9._:-]*[0-9_-][a-z0-9._:-]*)\b/g, "$1=<id>").replace(/\b((?:session|sess|request|req|trace|correlation|corr|run)(?:[_-]?id)?)\s+((?:(?:sess?|req|trace|corr|run)[_-][a-z0-9._:-]+|[a-z][a-z0-9._:-]*\d[a-z0-9._:-]*))\b/g, "$1 <id>").replace(/\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b/g, "<uuid>").replace(/\b[0-9a-f]{16,64}\b/g, "<hex>").replace(/[a-z]:\\[^\s)]+/gi, "<path>").replace(/(?:\/[\w.@:-]+)+/g, "<path>").replace(/\s+/g, " ").trim().slice(0, 160);
10566
- }
10567
- function classifyTerminalFailureSignature(record) {
10568
- if (!TERMINAL_FAILED_DELEGATION_STATUSES.has(record.status))
10569
- return null;
10570
- const result = record.terminalResult?.result ?? record.result;
10571
- if (!result)
10572
- return `terminal-zero-output:${record.status}`;
10573
- const outputRef = result.outputRef?.trim();
10574
- const text = result.text?.trim() ?? "";
10575
- if (!outputRef && text.length === 0 && (result.chars ?? 0) === 0) {
10576
- return `terminal-zero-output:${record.status}`;
10577
- }
10578
- const errorText = result.error?.trim();
10579
- if (errorText) {
10580
- return `terminal-error-output:${record.status}:${normalizeFailureSignatureText(errorText)}`;
10581
- }
10582
- if (record.status === "completed")
10583
- return null;
10584
- return `terminal-nonzero-output:${record.status}`;
10585
- }
10645
+ var malformedCircuitDiagnosticsSeen = new Set;
10586
10646
  var TERMINAL_FAILED_DELEGATION_STATUSES = new Set([
10587
10647
  "completed",
10588
10648
  "error",
@@ -11194,7 +11254,7 @@ async function transitionPrReviewToFeedback(directory, sessionID, request) {
11194
11254
  }));
11195
11255
  }
11196
11256
  var _test_exports2 = {
11197
- classifyTerminalFailureSignature,
11257
+ classifyPrReviewCircuitSignal,
11198
11258
  minimumConsolidatedLaneCover,
11199
11259
  analyzePrReviewBatchRecordIntegrity,
11200
11260
  MAX_COVER_UNIVERSE_BITS,
@@ -11213,6 +11273,7 @@ var _test_exports2 = {
11213
11273
  pendingStateMutationsByProjectSession.clear();
11214
11274
  pendingCheckoutMutationsByProject.clear();
11215
11275
  completedCheckoutLockOwners.clear();
11276
+ malformedCircuitDiagnosticsSeen.clear();
11216
11277
  _test_exports2.beforeTerminalClear = undefined;
11217
11278
  _test_exports2.beforeAbortClear = undefined;
11218
11279
  _test_exports2.beforePrFeedbackTransitionLock = undefined;
@@ -20064,7 +20125,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
20064
20125
  };
20065
20126
  }
20066
20127
  async function sweepActiveNearDuplicates(directory, options = {}) {
20067
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xkjrg9k4.js");
20128
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-pcj7jk4t.js");
20068
20129
  const { config } = loadPluginConfigWithMeta2(directory);
20069
20130
  const sweepConfig = config.learning?.dedup_sweep;
20070
20131
  if (sweepConfig?.enabled === false)
@@ -21194,7 +21255,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
21194
21255
  }
21195
21256
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
21196
21257
  try {
21197
- const skillModule = await import("./skill-generator-3keadpf7.js");
21258
+ const skillModule = await import("./skill-generator-vmxsc2fm.js");
21198
21259
  for (const cand of skillCandidates) {
21199
21260
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
21200
21261
  continue;
@@ -21666,7 +21727,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
21666
21727
  } catch {}
21667
21728
  }
21668
21729
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
21669
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-w05ztgvk.js");
21730
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-bxpzeth0.js");
21670
21731
  for (const { id } of contradictedEntries) {
21671
21732
  try {
21672
21733
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -22485,7 +22546,7 @@ async function runCuratorPostMortem(directory, options = {}) {
22485
22546
  warnings.push("Failed to collect knowledge summary.");
22486
22547
  }
22487
22548
  try {
22488
- const { getScanStatus } = await import("./scan-cursor-b6n15w8d.js");
22549
+ const { getScanStatus } = await import("./scan-cursor-3xxqtxwx.js");
22489
22550
  const scanStatus = await getScanStatus(directory);
22490
22551
  if (scanStatus.remaining_estimate > 0) {
22491
22552
  warnings.push(`Fair scan: reviewed ${knowledgeSummary.length} entries this sweep (generation ${scanStatus.generation}); ${scanStatus.remaining_estimate} more eligible entries will be visited in future curation sweeps.`);
@@ -22657,9 +22718,9 @@ var _internals27 = {
22657
22718
  verifyPostMortemKnowledgeActions,
22658
22719
  repairPostMortemActions,
22659
22720
  loadDefaultKnowledgeConfig: async (directory) => {
22660
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jkbfwqr2.js");
22721
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jdx83m4m.js");
22661
22722
  try {
22662
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xkjrg9k4.js");
22723
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-pcj7jk4t.js");
22663
22724
  const loaded = loadPluginConfigWithMeta2(directory);
22664
22725
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
22665
22726
  } catch {
@@ -22667,11 +22728,11 @@ var _internals27 = {
22667
22728
  }
22668
22729
  },
22669
22730
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
22670
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-hxb3wsxr.js");
22731
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-yj00z1qz.js");
22671
22732
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
22672
22733
  },
22673
22734
  checkHivePromotions: async (entries, knowledgeConfig, directory) => {
22674
- const { checkHivePromotions } = await import("./hive-promoter-55qcqgfx.js");
22735
+ const { checkHivePromotions } = await import("./hive-promoter-5936am48.js");
22675
22736
  return checkHivePromotions(entries, knowledgeConfig, directory);
22676
22737
  },
22677
22738
  applyProposalTriage: async (directory, triage) => {
@@ -22680,7 +22741,7 @@ var _internals27 = {
22680
22741
  activateProposal,
22681
22742
  listSkills: listSkills2,
22682
22743
  sanitizeSlug
22683
- } = await import("./skill-generator-3keadpf7.js");
22744
+ } = await import("./skill-generator-vmxsc2fm.js");
22684
22745
  const result = {
22685
22746
  approved: [],
22686
22747
  rejected: [],
@@ -24010,9 +24071,9 @@ function hashContent(content) {
24010
24071
  return createHash12("sha1").update(content).digest("hex");
24011
24072
  }
24012
24073
  async function loadConfigForPolicyCurator(directory) {
24013
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jkbfwqr2.js");
24074
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jdx83m4m.js");
24014
24075
  try {
24015
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xkjrg9k4.js");
24076
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-pcj7jk4t.js");
24016
24077
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
24017
24078
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
24018
24079
  } catch {
@@ -36056,7 +36117,7 @@ async function runFinalizeStage(ctx) {
36056
36117
  }
36057
36118
  }
36058
36119
  try {
36059
- const { CuratorConfigSchema: CCS } = await import("./schema-jkbfwqr2.js");
36120
+ const { CuratorConfigSchema: CCS } = await import("./schema-jdx83m4m.js");
36060
36121
  const { config: pmLoadedConfig } = _internals42.loadPluginConfigWithMeta(ctx.directory);
36061
36122
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
36062
36123
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -36932,7 +36993,7 @@ var _internals42 = {
36932
36993
  closePlanTerminalState: reconcileCloseTerminalStateForPlan,
36933
36994
  endAgentSession,
36934
36995
  flushAndDrainTelemetry: async () => {
36935
- const { flushAndDrainTelemetry } = await import("./telemetry-hh1j99za.js");
36996
+ const { flushAndDrainTelemetry } = await import("./telemetry-q2km2zrz.js");
36936
36997
  return flushAndDrainTelemetry();
36937
36998
  },
36938
36999
  finalizeContextTelemetry: (directory) => {
@@ -38269,9 +38330,9 @@ var _internals46 = {
38269
38330
  loadPluginConfigWithMeta,
38270
38331
  loadCuratorDeps: async () => {
38271
38332
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
38272
- import("./schema-jkbfwqr2.js"),
38273
- import("./curator-hxb3wsxr.js"),
38274
- import("./curator-llm-factory-s8atmc2n.js")
38333
+ import("./schema-jdx83m4m.js"),
38334
+ import("./curator-yj00z1qz.js"),
38335
+ import("./curator-llm-factory-ypwf3a90.js")
38275
38336
  ]);
38276
38337
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
38277
38338
  }
@@ -39280,7 +39341,7 @@ async function computeCurationDiagnostics(directory, entries) {
39280
39341
  let scanCompleted = false;
39281
39342
  let scanRemaining = 0;
39282
39343
  try {
39283
- const { getScanStatus } = await import("./scan-cursor-b6n15w8d.js");
39344
+ const { getScanStatus } = await import("./scan-cursor-3xxqtxwx.js");
39284
39345
  const status = await getScanStatus(directory);
39285
39346
  scanGeneration = status.generation;
39286
39347
  scanCompleted = status.completed;
@@ -39288,19 +39349,19 @@ async function computeCurationDiagnostics(directory, entries) {
39288
39349
  } catch {}
39289
39350
  let configMatch = null;
39290
39351
  try {
39291
- const { isLinked: isLinked2 } = await import("./knowledge-link-ge0rddxw.js");
39352
+ const { isLinked: isLinked2 } = await import("./knowledge-link-nwxykjya.js");
39292
39353
  if (isLinked2(directory)) {
39293
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jkbfwqr2.js");
39354
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-jdx83m4m.js");
39294
39355
  let config;
39295
39356
  try {
39296
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-xkjrg9k4.js");
39357
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-pcj7jk4t.js");
39297
39358
  const loaded = loadPluginConfigWithMeta2(directory);
39298
39359
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
39299
39360
  } catch {
39300
39361
  config = KnowledgeConfigSchema2.parse({});
39301
39362
  }
39302
39363
  const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
39303
- const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-twa6agf8.js");
39364
+ const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-9r902jw4.js");
39304
39365
  const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
39305
39366
  const cohortFp = await readCohortConfigFingerprint(directory);
39306
39367
  configMatch = cohortFp === null ? null : currentFp === cohortFp;
@@ -40613,7 +40674,7 @@ async function handleDoctorCommand(directory, args) {
40613
40674
  const result = runConfigDoctor(config, directory);
40614
40675
  let output;
40615
40676
  if (enableAutoFix && result.hasAutoFixableIssues) {
40616
- const { runConfigDoctorWithFixes } = await import("./config-doctor-ze21qs6b.js");
40677
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-8p9y543t.js");
40617
40678
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
40618
40679
  applyLossy: true
40619
40680
  });
@@ -41553,7 +41614,7 @@ async function handleEvidenceCommand(directory, args) {
41553
41614
  return formatTaskEvidenceMarkdown(evidenceData);
41554
41615
  }
41555
41616
  async function handleEvidenceSummaryCommand(directory) {
41556
- const { buildEvidenceSummary } = await import("./evidence-summary-service-wzzym9r7.js");
41617
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-npq04240.js");
41557
41618
  const artifact = await buildEvidenceSummary(directory);
41558
41619
  if (!artifact) {
41559
41620
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -59874,19 +59935,47 @@ function formatMergeGroupStatus(status, conclusion, htmlUrl) {
59874
59935
  }
59875
59936
  return parts.join(" ");
59876
59937
  }
59938
+ function formatStorageHealth(health) {
59939
+ const age = health.checkpointAgeMs === null ? "n/a" : health.checkpointAgeMs < 5000 ? "now" : `${Math.floor(health.checkpointAgeMs / 1000)}s ago`;
59940
+ const parts = [
59941
+ `checkpoint seq ${health.sequence} (${age})`,
59942
+ `active ${health.activeCount} \xB7 removed ${health.removedCount} \xB7 expired ${health.expiredCount}`,
59943
+ `store ${health.checkpointBytes}/${health.checkpointLimitBytes} B (${health.pressurePct}%)`,
59944
+ `audit ${health.auditLines} lines`,
59945
+ `compactions ${health.compactions} \xB7 corrupt ${health.corruptLegacyRecords} \xB7 dropped-audit ${health.droppedAuditTransitions}`,
59946
+ `source ${health.recoverySource}`
59947
+ ];
59948
+ const lines = [`Storage: ${parts.join(" \xB7 ")}`];
59949
+ if (health.legacyOverLimit) {
59950
+ lines.push("Warning: the legacy subscriptions log exceeds the migration size limit and was NOT loaded. Archive or split .swarm/pr-monitor/subscriptions.jsonl (subscriptions can be re-created with /swarm pr subscribe), then remove it.");
59951
+ }
59952
+ return lines.join(`
59953
+ `);
59954
+ }
59877
59955
  var _internals74 = {
59878
59956
  formatRelativeTime,
59879
59957
  formatMergeGroupStatus,
59958
+ formatStorageHealth,
59880
59959
  listActive,
59881
59960
  listMergeGroupRuns,
59882
- parseMergeGroupRuns
59961
+ parseMergeGroupRuns,
59962
+ getPrSubscriptionHealth
59883
59963
  };
59884
59964
  async function handlePrMonitorStatusCommand(directory, _args, sessionID, source) {
59885
59965
  const allActive = await _internals74.listActive(directory);
59886
59966
  const allSessions = source === "cli";
59887
59967
  const subs = allSessions ? allActive : allActive.filter((record) => record.sessionID === sessionID);
59968
+ let storageFooter = "";
59969
+ try {
59970
+ const health = await _internals74.getPrSubscriptionHealth(directory);
59971
+ if (health)
59972
+ storageFooter = _internals74.formatStorageHealth(health);
59973
+ } catch {}
59888
59974
  if (subs.length === 0) {
59889
- return allSessions ? "No active PR subscriptions." : "No active PR subscriptions for this session.";
59975
+ const empty = allSessions ? "No active PR subscriptions." : "No active PR subscriptions for this session.";
59976
+ return storageFooter ? `${empty}
59977
+
59978
+ ${storageFooter}` : empty;
59890
59979
  }
59891
59980
  const lines = [];
59892
59981
  lines.push(allSessions ? "PR Monitor Status \u2014 all sessions" : `PR Monitor Status \u2014 Session: ${sessionID}`);
@@ -59930,6 +60019,9 @@ async function handlePrMonitorStatusCommand(directory, _args, sessionID, source)
59930
60019
  if (!allSessions && totalActive !== subs.length) {
59931
60020
  lines.push(`Total active across all sessions: ${totalActive}`);
59932
60021
  }
60022
+ if (storageFooter) {
60023
+ lines.push(storageFooter);
60024
+ }
59933
60025
  return lines.join(`
59934
60026
  `);
59935
60027
  }
@@ -67388,14 +67480,87 @@ function clearTrajectoryStep(sessionId) {
67388
67480
  var _internals84 = {
67389
67481
  cleanupOrphanedBranches,
67390
67482
  backupSwarmStateBeforeReset,
67391
- recoverStaleCoderSettlements
67483
+ recoverStaleCoderSettlements,
67484
+ queryLiveMemberships,
67485
+ commitGateReleaseBatch,
67486
+ releaseKnowledgeGateObligations
67392
67487
  };
67393
67488
  function errorMessage(err) {
67394
67489
  if (err instanceof Error)
67395
67490
  return err.message;
67396
67491
  return String(err);
67397
67492
  }
67398
- async function handleResetSessionCommand(directory, _args) {
67493
+ async function releaseKnowledgeGateObligations(directory, sessionID) {
67494
+ const results = [];
67495
+ let live;
67496
+ try {
67497
+ live = await _internals84.queryLiveMemberships(directory, {
67498
+ session_id: sessionID,
67499
+ include_terminal: true
67500
+ });
67501
+ } catch (err) {
67502
+ return [
67503
+ `\u26A0\uFE0F Knowledge gate state not cleared: receipt authority unavailable (${errorMessage(err)})`
67504
+ ];
67505
+ }
67506
+ if (!live.ok) {
67507
+ return [
67508
+ `\u26A0\uFE0F Knowledge gate state not cleared: receipt authority unavailable (${live.code})`
67509
+ ];
67510
+ }
67511
+ const pending = live.memberships.filter((membership) => membership.exposure_kind === "architect_directive" && !membership.application_marker && membership.gate_release?.membership_event_id !== membership.membership_event_id);
67512
+ if (pending.length === 0) {
67513
+ return ["\u23ED\uFE0F No pending knowledge gate obligations for this session"];
67514
+ }
67515
+ const byTrace = new Map;
67516
+ for (const membership of pending) {
67517
+ const group = byTrace.get(membership.trace_id) ?? [];
67518
+ group.push(membership);
67519
+ byTrace.set(membership.trace_id, group);
67520
+ }
67521
+ let committedCount = 0;
67522
+ const releasedPairs = [];
67523
+ for (const [traceId, group] of byTrace) {
67524
+ const committed = await _internals84.commitGateReleaseBatch(directory, {
67525
+ trace_id: traceId,
67526
+ session_id: sessionID,
67527
+ items: group.map((membership) => ({
67528
+ entry_id: membership.entry_id,
67529
+ source: "application_gate_session_reset_release",
67530
+ reason: "/swarm reset-session operator escape (#2398)"
67531
+ }))
67532
+ });
67533
+ if (!committed.ok) {
67534
+ results.push(`\u26A0\uFE0F Failed to release knowledge gate obligations on trace ${sanitizeDiagnosticText(traceId, 64)}: ${committed.code}`);
67535
+ continue;
67536
+ }
67537
+ committedCount += committed.committed.length;
67538
+ for (const item of committed.committed) {
67539
+ releasedPairs.push(`${traceId}/${item.entry_id}`);
67540
+ }
67541
+ if (committed.rejected.length > 0) {
67542
+ results.push(`\u26A0\uFE0F Partially released trace ${sanitizeDiagnosticText(traceId, 64)}: ${committed.rejected.map((item) => item.reason).join("; ")}`);
67543
+ }
67544
+ }
67545
+ if (committedCount === 0) {
67546
+ return results;
67547
+ }
67548
+ if (committedCount < pending.length) {
67549
+ results.push(`\u26A0\uFE0F Released ${committedCount} of ${pending.length} pending knowledge gate obligation(s) \u2014 ${pending.length - committedCount} not released; see warnings above`);
67550
+ } else {
67551
+ results.push(`\u2705 Released ${committedCount} pending knowledge gate obligation(s) for this session`);
67552
+ }
67553
+ try {
67554
+ appendCoreEventSync(directory, {
67555
+ timestamp: new Date().toISOString(),
67556
+ event: "knowledge_application_gate_session_reset_clear",
67557
+ sessionID,
67558
+ released_pairs: releasedPairs
67559
+ });
67560
+ } catch {}
67561
+ return results;
67562
+ }
67563
+ async function handleResetSessionCommand(directory, _args, sessionID) {
67399
67564
  const results = [];
67400
67565
  try {
67401
67566
  const backup = _internals84.backupSwarmStateBeforeReset(directory, "reset-session", ["session"]);
@@ -67458,6 +67623,18 @@ async function handleResetSessionCommand(directory, _args) {
67458
67623
  const activeAgentCount = swarmState.activeAgent.size;
67459
67624
  swarmState.activeAgent.clear();
67460
67625
  results.push(`\u2705 Cleared ${activeAgentCount} active-agent mapping(s)`);
67626
+ if (sessionID) {
67627
+ try {
67628
+ results.push(...await _internals84.releaseKnowledgeGateObligations(directory, sessionID));
67629
+ } catch (err) {
67630
+ results.push(`\u26A0\uFE0F Knowledge gate state not cleared: ${errorMessage(err)}`);
67631
+ }
67632
+ } else {
67633
+ results.push("\u26A0\uFE0F Knowledge gate obligations not released: no session context on this invocation");
67634
+ }
67635
+ swarmState.gateDenialCounts.clear();
67636
+ swarmState.currentCriticalShownIds.clear();
67637
+ results.push("\u2705 Cleared in-memory knowledge gate denial state");
67461
67638
  let preserveWorktrees = false;
67462
67639
  try {
67463
67640
  const { results: settlementResults, truncated } = await _internals84.recoverStaleCoderSettlements(directory, {
@@ -73992,7 +74169,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
73992
74169
  if (!input.dispatcher) {
73993
74170
  throw new Error("no evaluation dispatcher available (cannot run validation)");
73994
74171
  }
73995
- const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-n50w1y4w.js");
74172
+ const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-06dvm53x.js");
73996
74173
  const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
73997
74174
  const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () => _internals98.evaluateCandidateV1({
73998
74175
  projectRoot: input.directory,
@@ -76033,7 +76210,7 @@ function buildDetailedHelp(commandName, entry) {
76033
76210
  async function handleHelpCommand(ctx) {
76034
76211
  const targetCommand = ctx.args.join(" ");
76035
76212
  if (!targetCommand) {
76036
- const { buildHelpText } = await import("./index-23rneydq.js");
76213
+ const { buildHelpText } = await import("./index-2kzxkx50.js");
76037
76214
  return buildHelpText();
76038
76215
  }
76039
76216
  const tokens = targetCommand.split(/\s+/);
@@ -76042,7 +76219,7 @@ async function handleHelpCommand(ctx) {
76042
76219
  return _internals101.buildDetailedHelp(resolved.key, resolved.entry);
76043
76220
  }
76044
76221
  const similar = _internals101.findSimilarCommands(targetCommand);
76045
- const { buildHelpText: fullHelp } = await import("./index-23rneydq.js");
76222
+ const { buildHelpText: fullHelp } = await import("./index-2kzxkx50.js");
76046
76223
  if (similar.length > 0) {
76047
76224
  return `Command '/swarm ${targetCommand}' not found.
76048
76225
 
@@ -76229,7 +76406,7 @@ var COMMAND_REGISTRY = {
76229
76406
  },
76230
76407
  "guardrail explain": {
76231
76408
  handler: async (ctx) => {
76232
- const { handleGuardrailExplain } = await import("./guardrail-explain-5kzeem4m.js");
76409
+ const { handleGuardrailExplain } = await import("./guardrail-explain-dyxbhrdj.js");
76233
76410
  return handleGuardrailExplain(ctx.directory, ctx.args);
76234
76411
  },
76235
76412
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -76239,7 +76416,7 @@ var COMMAND_REGISTRY = {
76239
76416
  },
76240
76417
  "guardrail reset": {
76241
76418
  handler: async (ctx) => {
76242
- const { handleGuardrailReset } = await import("./guardrail-reset-wzvtmpn2.js");
76419
+ const { handleGuardrailReset } = await import("./guardrail-reset-269jdwhd.js");
76243
76420
  return handleGuardrailReset(ctx.args, ctx.sessionID);
76244
76421
  },
76245
76422
  description: "Reset one exact active invocation/action circuit after repair",
@@ -76248,7 +76425,7 @@ var COMMAND_REGISTRY = {
76248
76425
  },
76249
76426
  "guardrail-explain": {
76250
76427
  handler: async (ctx) => {
76251
- const { handleGuardrailExplain } = await import("./guardrail-explain-5kzeem4m.js");
76428
+ const { handleGuardrailExplain } = await import("./guardrail-explain-dyxbhrdj.js");
76252
76429
  return handleGuardrailExplain(ctx.directory, ctx.args);
76253
76430
  },
76254
76431
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -76258,7 +76435,7 @@ var COMMAND_REGISTRY = {
76258
76435
  },
76259
76436
  "guardrail-reset": {
76260
76437
  handler: async (ctx) => {
76261
- const { handleGuardrailReset } = await import("./guardrail-reset-wzvtmpn2.js");
76438
+ const { handleGuardrailReset } = await import("./guardrail-reset-269jdwhd.js");
76262
76439
  return handleGuardrailReset(ctx.args, ctx.sessionID);
76263
76440
  },
76264
76441
  description: "Reset one exact active invocation/action circuit after repair",
@@ -76268,7 +76445,7 @@ var COMMAND_REGISTRY = {
76268
76445
  },
76269
76446
  "guardrail-log": {
76270
76447
  handler: async (ctx) => {
76271
- const { handleGuardrailLog } = await import("./guardrail-log-38jnajpa.js");
76448
+ const { handleGuardrailLog } = await import("./guardrail-log-eyecsekk.js");
76272
76449
  return handleGuardrailLog(ctx.directory, ctx.args);
76273
76450
  },
76274
76451
  description: "Read the guardrail decision log (use --blocks-only for blocks)",
@@ -76503,7 +76680,7 @@ var COMMAND_REGISTRY = {
76503
76680
  deprecated: true
76504
76681
  },
76505
76682
  clear: {
76506
- handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args),
76683
+ handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args, ctx.sessionID),
76507
76684
  description: "Clear session state while preserving plan, evidence, and knowledge",
76508
76685
  category: "utility",
76509
76686
  aliasOf: "reset-session",
@@ -76918,9 +77095,9 @@ Subcommands:
76918
77095
  toolPolicy: "restricted"
76919
77096
  },
76920
77097
  "reset-session": {
76921
- handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args),
77098
+ handler: (ctx) => handleResetSessionCommand(ctx.directory, ctx.args, ctx.sessionID),
76922
77099
  description: "Clear session state while preserving plan, evidence, and knowledge",
76923
- details: "Deletes only .swarm/session/state.json and any other session files. Clears in-memory agent sessions, delegation chains, and active-agent mappings. Preserves plan, evidence, and knowledge for cross-session continuity. Also recovers stale coder settlements, releasing in-flight ownership held by this process, so dispatches cannot stay wedged on CODER_DISPATCH_IN_PROGRESS (issue #2268). Before deleting, auto-backs up the session files it removes to .swarm/reset-backups/<timestamp>/ (newest 5 kept).",
77100
+ details: "Deletes only .swarm/session/state.json and other session files. Clears in-memory agent sessions, delegation chains, and active-agent mappings. Preserves plan, evidence, and knowledge. Also releases this session's pending knowledge-gate obligations (#2398) and recovers stale coder settlements so dispatches cannot wedge on CODER_DISPATCH_IN_PROGRESS (#2268). Auto-backs up removed files to .swarm/reset-backups/ (newest 5 kept).",
76924
77101
  args: "",
76925
77102
  category: "utility",
76926
77103
  toolPolicy: "restricted"
@@ -82229,7 +82406,7 @@ function getDisplayBudget() {
82229
82406
  async function rehydratePrSubscriptions(sessionID, directory) {
82230
82407
  const map = new Map;
82231
82408
  try {
82232
- const { listActive: listActive2 } = await import("./pr-subscriptions-dq1f61ye.js");
82409
+ const { listActive: listActive2 } = await import("./pr-subscriptions-1ndwgtbw.js");
82233
82410
  const records = await listActive2(directory);
82234
82411
  for (const record of records) {
82235
82412
  if (record.sessionID !== sessionID)
@@ -82675,7 +82852,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
82675
82852
  return extracted === expectedSessionId;
82676
82853
  }
82677
82854
  async function inspectStandardWorktreeCollisionOwnership(identity) {
82678
- const collisionOwnership = await import("./worktree-collision-ownership-4drcjymy.js");
82855
+ const collisionOwnership = await import("./worktree-collision-ownership-gsay5210.js");
82679
82856
  return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
82680
82857
  }
82681
82858
  async function runRecoveryGit(directory, args, timeoutMs = 15000) {
@@ -83084,7 +83261,7 @@ async function precreateStandardWorktreeSession(args) {
83084
83261
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
83085
83262
  if (laneProfile) {
83086
83263
  try {
83087
- const { writeLaneProfileToDiskReal } = await import("./core-qdmhh1kx.js");
83264
+ const { writeLaneProfileToDiskReal } = await import("./core-1h6x6k59.js");
83088
83265
  await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
83089
83266
  } catch {}
83090
83267
  }
@@ -84009,7 +84186,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
84009
84186
  }
84010
84187
  clearWorktreeMergeStatus(statusKey);
84011
84188
  try {
84012
- const { removeLaneProfileFromDiskReal } = await import("./core-qdmhh1kx.js");
84189
+ const { removeLaneProfileFromDiskReal } = await import("./core-1h6x6k59.js");
84013
84190
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
84014
84191
  } catch {}
84015
84192
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);