opencode-swarm 7.159.2 → 7.160.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 (91) hide show
  1. package/dist/background/delegation-health.d.ts +1 -1
  2. package/dist/cli/{coder-settlement-hny3vh3e.js → coder-settlement-zn552sp9.js} +11 -10
  3. package/dist/cli/{config-doctor-00ex0s3k.js → config-doctor-ddtdz2g0.js} +3 -3
  4. package/dist/cli/{core-03tedwzg.js → core-embasn2j.js} +2 -2
  5. package/dist/cli/{curation-policy-z0a5akng.js → curation-policy-agr6ga1s.js} +6 -6
  6. package/dist/cli/{curator-n81nzdw8.js → curator-dgp6dxxn.js} +32 -31
  7. package/dist/cli/curator-llm-factory-7cwvmc46.js +67 -0
  8. package/dist/cli/{evidence-summary-service-nz7y1w2a.js → evidence-summary-service-sbnyann4.js} +14 -13
  9. package/dist/cli/{gate-evidence-dxafmzrn.js → gate-evidence-5v67a1dz.js} +7 -7
  10. package/dist/cli/guardrail-explain-2gwarnca.js +68 -0
  11. package/dist/cli/{guardrail-log-t8c7acxg.js → guardrail-log-zbnbff1y.js} +9 -6
  12. package/dist/cli/{guardrail-reset-0ft2gf03.js → guardrail-reset-3cnz54hx.js} +32 -31
  13. package/dist/cli/{hive-promoter-brq9cx7c.js → hive-promoter-7cr7t2kg.js} +32 -31
  14. package/dist/cli/{index-1xcve0gc.js → index-1f4n43yz.js} +2 -2
  15. package/dist/cli/{index-b5s1n149.js → index-3055dgzp.js} +7 -7
  16. package/dist/cli/{index-bmst1sje.js → index-3yh737hc.js} +6 -6
  17. package/dist/cli/{index-0zerbq1v.js → index-4mm22fzj.js} +23 -14
  18. package/dist/cli/{index-qypnqmcj.js → index-5m7qjj29.js} +24 -7
  19. package/dist/cli/{index-rq461prn.js → index-7qv869f0.js} +6 -6
  20. package/dist/cli/{index-ky2r092m.js → index-85qjc7b2.js} +2 -2
  21. package/dist/cli/{index-y55hqgcj.js → index-8bjv01t8.js} +4 -4
  22. package/dist/cli/{index-dgt8z19x.js → index-962jgzdq.js} +1 -1
  23. package/dist/cli/{index-vq4d1h7t.js → index-9fspg1xw.js} +1 -1
  24. package/dist/cli/{index-7tjamatf.js → index-9k3zc2t8.js} +7 -7
  25. package/dist/cli/{index-p2m1skjz.js → index-9q6w7kke.js} +1 -1
  26. package/dist/cli/{index-av3gnekk.js → index-b5adxpy6.js} +1 -1
  27. package/dist/cli/{index-w1rhyqw2.js → index-cn233hsy.js} +1 -1
  28. package/dist/cli/{index-mcan50mx.js → index-d9s5hb0m.js} +4 -4
  29. package/dist/cli/{index-prknc0xn.js → index-dke4wzkn.js} +108 -44
  30. package/dist/cli/index-e75bzfgd.js +785 -0
  31. package/dist/cli/{index-8gh97gkz.js → index-fzkx24q5.js} +2 -2
  32. package/dist/cli/{index-m0gfzxw1.js → index-gt8cxfbp.js} +2 -2
  33. package/dist/cli/{index-yt75r1er.js → index-h3re5c78.js} +1 -1
  34. package/dist/cli/{index-k7kvrwbj.js → index-jmths6jj.js} +34 -33
  35. package/dist/cli/{index-8ahjx7vt.js → index-kkfgygvn.js} +4 -4
  36. package/dist/cli/{index-q8yma345.js → index-p39xem8b.js} +5 -5
  37. package/dist/cli/{index-e1jcdpdg.js → index-py6bqwnb.js} +2 -2
  38. package/dist/cli/{index-6sheh3yp.js → index-q6gjwy7m.js} +19 -10
  39. package/dist/cli/{index-200myvdx.js → index-rhc8jve7.js} +2 -2
  40. package/dist/cli/{index-9ev0bbqh.js → index-rnyt2z5r.js} +346 -98
  41. package/dist/cli/{index-1e9rzhmr.js → index-rq7k03rk.js} +4 -4
  42. package/dist/cli/{index-egc8d995.js → index-s7w428r3.js} +1 -1
  43. package/dist/cli/{index-caqjwnak.js → index-sy5aeegg.js} +11 -2
  44. package/dist/cli/{index-b2dh37cf.js → index-va1edd2n.js} +5 -5
  45. package/dist/cli/{index-eh1gh043.js → index-w699ekk9.js} +4 -4
  46. package/dist/cli/{index-nmp47dmm.js → index-wzx6atbv.js} +13 -4
  47. package/dist/cli/{index-jd7mz4yg.js → index-xs15netk.js} +1 -1
  48. package/dist/cli/{index-wzc6vzq6.js → index-yrar1ask.js} +3 -3
  49. package/dist/cli/{index-v7wm4mw8.js → index-zjvf7edj.js} +3 -3
  50. package/dist/cli/index.js +32 -31
  51. package/dist/cli/{knowledge-escalator-rxagfxnk.js → knowledge-escalator-zksm9833.js} +13 -12
  52. package/dist/cli/{knowledge-events-ymwdv799.js → knowledge-events-ayta750w.js} +11 -10
  53. package/dist/cli/{knowledge-link-n1825n09.js → knowledge-link-7c7fjnzc.js} +5 -5
  54. package/dist/cli/{knowledge-store-nxm4xvvq.js → knowledge-store-q5axge8b.js} +6 -6
  55. package/dist/cli/{knowledge-validator-gtmq35k8.js → knowledge-validator-3rrbva2p.js} +8 -8
  56. package/dist/cli/{model-preflight-w85ecyxh.js → model-preflight-x9szw1v4.js} +1 -1
  57. package/dist/cli/{pending-delegations-zdgazhdf.js → pending-delegations-kc7tzxg9.js} +5 -3
  58. package/dist/cli/{pr-review-reentry-authorization-jgzb0pma.js → pr-review-reentry-authorization-vag5gh50.js} +32 -31
  59. package/dist/cli/{pr-subscriptions-pxv24d5k.js → pr-subscriptions-wbdw9a82.js} +5 -4
  60. package/dist/cli/{runner-fzgkhx6a.js → runner-p9wg6z34.js} +6 -6
  61. package/dist/cli/{scan-cursor-fasdj7kj.js → scan-cursor-4fjwtt1k.js} +7 -7
  62. package/dist/cli/{schema-3x28z3rp.js → schema-d0nbzj5k.js} +2 -2
  63. package/dist/cli/{scope-persistence-p8dnxfhx.js → scope-persistence-bckcbc8h.js} +10 -9
  64. package/dist/cli/{skill-generator-6tjyffgd.js → skill-generator-kebhevet.js} +15 -14
  65. package/dist/cli/{telemetry-3rh94wv3.js → telemetry-gpr9s3sm.js} +3 -1
  66. package/dist/cli/{worktree-collision-ownership-3bbn1n2r.js → worktree-collision-ownership-h8qswnrp.js} +6 -5
  67. package/dist/cli/{worktree-isolation-1470tnxc.js → worktree-isolation-q0kbmadz.js} +32 -31
  68. package/dist/config/context-window.d.ts +11 -4
  69. package/dist/config/evidence-schema.d.ts +6 -6
  70. package/dist/context-map/telemetry.d.ts +1 -1
  71. package/dist/health/learning-health.d.ts +356 -0
  72. package/dist/hooks/context-budget.d.ts +10 -1
  73. package/dist/hooks/curator.d.ts +2 -0
  74. package/dist/hooks/final-context-accounting.d.ts +2 -0
  75. package/dist/hooks/model-limits.d.ts +56 -25
  76. package/dist/hooks/skill-usage-pending.d.ts +1 -1
  77. package/dist/index.js +588 -587
  78. package/dist/observability/catalog.d.ts +2 -2
  79. package/dist/observability/ids.d.ts +17 -0
  80. package/dist/prm/trajectory-store.d.ts +1 -1
  81. package/dist/services/diagnose-service.d.ts +7 -0
  82. package/dist/services/status-service.d.ts +18 -0
  83. package/dist/telemetry.d.ts +52 -1
  84. package/dist/tools/context-status.d.ts +15 -1
  85. package/dist/tools/repo-graph/ontology.d.ts +6 -0
  86. package/dist/tools/repo-graph/pack-query.d.ts +36 -0
  87. package/dist/tools/repo-graph/types.d.ts +198 -1
  88. package/dist/tools/repo-graph.d.ts +5 -3
  89. package/package.json +1 -1
  90. package/dist/cli/curator-llm-factory-24bfn7h1.js +0 -66
  91. package/dist/cli/guardrail-explain-b3k9xrx9.js +0 -67
@@ -6,7 +6,7 @@ import {
6
6
  resolveExecutableFromPath,
7
7
  runEvaluation,
8
8
  runExternalTool
9
- } from "./index-jd7mz4yg.js";
9
+ } from "./index-xs15netk.js";
10
10
  import {
11
11
  finalizeShellAuditForClose,
12
12
  isPolicyProtectedPath,
@@ -15,13 +15,13 @@ import {
15
15
  protectedRoots,
16
16
  redactDecisionLineForArchive,
17
17
  stableCanonicalStringify
18
- } from "./index-nmp47dmm.js";
18
+ } from "./index-wzx6atbv.js";
19
19
  import {
20
20
  detectStraySwarmDirs,
21
21
  readDoctorArtifact,
22
22
  removeStraySwarmDir,
23
23
  runConfigDoctor
24
- } from "./index-e1jcdpdg.js";
24
+ } from "./index-py6bqwnb.js";
25
25
  import {
26
26
  MAX_TRANSIENT_RETRIES,
27
27
  archiveEvidence,
@@ -68,7 +68,7 @@ import {
68
68
  validateProjectRoot,
69
69
  validateSymlinkBoundary,
70
70
  validateTargetWithinRoot
71
- } from "./index-7tjamatf.js";
71
+ } from "./index-9k3zc2t8.js";
72
72
  import {
73
73
  EvaluationTaskV1Schema,
74
74
  GateAuditManifestV1Schema,
@@ -85,7 +85,7 @@ import {
85
85
  saveGateAuditResult,
86
86
  savePromotionDecision,
87
87
  saveTaskSetSnapshot
88
- } from "./index-ky2r092m.js";
88
+ } from "./index-85qjc7b2.js";
89
89
  import {
90
90
  canonicalHash,
91
91
  canonicalJson,
@@ -129,15 +129,15 @@ import {
129
129
  retireSkill,
130
130
  selectCandidateEntries,
131
131
  syncBundledProjectSkillsIfMissingAsync
132
- } from "./index-y55hqgcj.js";
132
+ } from "./index-8bjv01t8.js";
133
133
  import {
134
134
  readRecentEscalations
135
- } from "./index-b2dh37cf.js";
135
+ } from "./index-va1edd2n.js";
136
136
  import {
137
137
  alreadyCuratedThisGeneration,
138
138
  claimNextScanBatch,
139
139
  resolveCohortId
140
- } from "./index-m0gfzxw1.js";
140
+ } from "./index-gt8cxfbp.js";
141
141
  import {
142
142
  CURATOR_INIT_PROMPT,
143
143
  CURATOR_PHASE_PROMPT,
@@ -161,7 +161,7 @@ import {
161
161
  listActive,
162
162
  subscribe,
163
163
  unsubscribe
164
- } from "./index-6sheh3yp.js";
164
+ } from "./index-q6gjwy7m.js";
165
165
  import {
166
166
  clearWorktreeMergeStatus,
167
167
  getAllWorktreeMergeFailures,
@@ -173,7 +173,7 @@ import {
173
173
  listCoderSettlementWalStates,
174
174
  recoverCoderSettlement,
175
175
  recoverStaleCoderSettlements
176
- } from "./index-rq461prn.js";
176
+ } from "./index-7qv869f0.js";
177
177
  import {
178
178
  parsePorcelainV2Snapshot,
179
179
  resolveCommitCountSince,
@@ -206,7 +206,7 @@ import {
206
206
  WORKTREE_LIFECYCLE_LOCK_FILE,
207
207
  recordWorktreeProvisioningOwner,
208
208
  removeWorktreeProvisioningOwner
209
- } from "./index-w1rhyqw2.js";
209
+ } from "./index-cn233hsy.js";
210
210
  import {
211
211
  appendUnactionable,
212
212
  quarantineEntry,
@@ -217,11 +217,11 @@ import {
217
217
  validateActionableFields,
218
218
  validateLesson,
219
219
  validateSkillPath
220
- } from "./index-8ahjx7vt.js";
220
+ } from "./index-kkfgygvn.js";
221
221
  import {
222
222
  authorizeCuration,
223
223
  buildConfigFingerprintInput
224
- } from "./index-egc8d995.js";
224
+ } from "./index-s7w428r3.js";
225
225
  import {
226
226
  cohortConfigFingerprint
227
227
  } from "./index-rtry5xyf.js";
@@ -252,12 +252,12 @@ import {
252
252
  transitionTaskWorkflowEvidence,
253
253
  withTaskEvidenceTransaction,
254
254
  writeWorkflowWalFile
255
- } from "./index-eh1gh043.js";
255
+ } from "./index-w699ekk9.js";
256
256
  import {
257
257
  makeWorktreeBranchName,
258
258
  provisionWorktree,
259
259
  removeWorktree
260
- } from "./index-8gh97gkz.js";
260
+ } from "./index-fzkx24q5.js";
261
261
  import {
262
262
  DEFAULT_STALE_DELEGATION_TIMEOUT_MS,
263
263
  DELEGATION_COMPACTION_HIGH_WATER_BYTES,
@@ -272,7 +272,7 @@ import {
272
272
  scanBackgroundCoderReservationsForAdmission,
273
273
  scanDelegationsForRecovery,
274
274
  sweepStaleDelegations
275
- } from "./index-caqjwnak.js";
275
+ } from "./index-sy5aeegg.js";
276
276
  import {
277
277
  compositeSessionKey,
278
278
  sessionKeySuffix
@@ -283,7 +283,7 @@ import {
283
283
  clearAllScopes,
284
284
  clearScopeBindingFromDisk,
285
285
  clearScopeBindings
286
- } from "./index-b5s1n149.js";
286
+ } from "./index-3055dgzp.js";
287
287
  import {
288
288
  appendLedgerEvent,
289
289
  computePlanHash,
@@ -298,7 +298,7 @@ import {
298
298
  readPlanEpochIdentity,
299
299
  replayFromLedgerWithStatus,
300
300
  takeSnapshotEvent
301
- } from "./index-v7wm4mw8.js";
301
+ } from "./index-zjvf7edj.js";
302
302
  import {
303
303
  CORE_EVENT_LOCKED,
304
304
  appendCoreEventSync,
@@ -308,7 +308,7 @@ import {
308
308
  hasSpecDriftAuditEvent,
309
309
  hasTaskRepairAuditEvent,
310
310
  readCoreEvents
311
- } from "./index-0zerbq1v.js";
311
+ } from "./index-4mm22fzj.js";
312
312
  import {
313
313
  sanitizeDiagnosticText
314
314
  } from "./index-556ja8an.js";
@@ -357,7 +357,7 @@ import {
357
357
  transactFile,
358
358
  transactKnowledge,
359
359
  wordBigrams
360
- } from "./index-bmst1sje.js";
360
+ } from "./index-3yh737hc.js";
361
361
  import {
362
362
  MAX_EVENT_LOG_ENTRIES,
363
363
  _internals as _internals2,
@@ -373,10 +373,10 @@ import {
373
373
  recordKnowledgeEvent,
374
374
  recordPhaseCloseIntent,
375
375
  resolveKnowledgeEventsPath
376
- } from "./index-qypnqmcj.js";
376
+ } from "./index-5m7qjj29.js";
377
377
  import {
378
378
  resolveWorktreeIsolationConfig
379
- } from "./index-wzc6vzq6.js";
379
+ } from "./index-yrar1ask.js";
380
380
  import {
381
381
  RetrospectiveEvidenceSchema
382
382
  } from "./index-ebz97mks.js";
@@ -399,7 +399,7 @@ import {
399
399
  init_loader,
400
400
  loadPluginConfig,
401
401
  loadPluginConfigWithMeta
402
- } from "./index-dgt8z19x.js";
402
+ } from "./index-962jgzdq.js";
403
403
  import {
404
404
  DEFAULT_HARNESS_EVOLUTION_CONFIG,
405
405
  DEFAULT_PR_REVIEW_RESILIENCE_CONFIG,
@@ -415,7 +415,7 @@ import {
415
415
  package_default,
416
416
  resolveAutoReviewConfig,
417
417
  stripKnownSwarmPrefix
418
- } from "./index-1xcve0gc.js";
418
+ } from "./index-1f4n43yz.js";
419
419
  import {
420
420
  init_git_executable,
421
421
  resolveGitExecutable,
@@ -426,6 +426,12 @@ import {
426
426
  getDeferredWarnings,
427
427
  init_warning_buffer
428
428
  } from "./index-4rhhvd1a.js";
429
+ import {
430
+ observeCloseArchive,
431
+ observeCuratorCompliance,
432
+ observeStoreHealth,
433
+ readLearningHealth
434
+ } from "./index-e75bzfgd.js";
429
435
  import {
430
436
  AGENT_TOOL_MAP,
431
437
  ALL_AGENT_NAMES,
@@ -439,7 +445,7 @@ import {
439
445
  init_agent_names,
440
446
  init_constants,
441
447
  init_tool_metadata
442
- } from "./index-yt75r1er.js";
448
+ } from "./index-h3re5c78.js";
443
449
  import {
444
450
  resolveHiveDataDir,
445
451
  resolveHiveEventsPath,
@@ -455,22 +461,16 @@ import {
455
461
  resolveLinkDir,
456
462
  sanitizeLinkId,
457
463
  writeLinkPointer
458
- } from "./index-vq4d1h7t.js";
464
+ } from "./index-9fspg1xw.js";
459
465
  import {
460
466
  atomicWriteFile
461
- } from "./index-1e9rzhmr.js";
467
+ } from "./index-rq7k03rk.js";
462
468
  import {
463
469
  KNOWLEDGE_SCHEMA_VERSION,
464
470
  OUTCOME_BLOCK_THRESHOLD,
465
471
  init_knowledge_types,
466
472
  isActiveStatus
467
473
  } from "./index-bk5tah7q.js";
468
- import {
469
- atomicWriteSwarmFile,
470
- atomicWriteSwarmFileSync,
471
- matchTempGrammar,
472
- parseTargetBasename
473
- } from "./index-q8yma345.js";
474
474
  import {
475
475
  assertProjectRoot,
476
476
  hasExplicitProjectBoundary,
@@ -478,7 +478,13 @@ import {
478
478
  listActiveLocks,
479
479
  tryAcquireLock,
480
480
  withEvidenceLock
481
- } from "./index-av3gnekk.js";
481
+ } from "./index-b5adxpy6.js";
482
+ import {
483
+ atomicWriteSwarmFile,
484
+ atomicWriteSwarmFileSync,
485
+ matchTempGrammar,
486
+ parseTargetBasename
487
+ } from "./index-p39xem8b.js";
482
488
  import {
483
489
  invalidateCachedArtifact,
484
490
  resetSwarmArtifactCache
@@ -487,7 +493,7 @@ import {
487
493
  emit,
488
494
  getLastHeartbeat,
489
495
  telemetry
490
- } from "./index-prknc0xn.js";
496
+ } from "./index-dke4wzkn.js";
491
497
  import {
492
498
  require_proper_lockfile
493
499
  } from "./index-7g4c7s5r.js";
@@ -3561,9 +3567,17 @@ function buildSkillUsageHealthPayload(doc, trigger, gauges) {
3561
3567
  coverage: doc.coverage.complete
3562
3568
  };
3563
3569
  }
3564
- function emitSkillUsageHealth(doc, trigger, gauges) {
3570
+ function emitSkillUsageHealth(doc, trigger, gauges, directory) {
3565
3571
  try {
3566
- _internals7.emitHealth(buildSkillUsageHealthPayload(doc, trigger, gauges));
3572
+ const healthPayload = buildSkillUsageHealthPayload(doc, trigger, gauges);
3573
+ _internals7.emitHealth(healthPayload);
3574
+ if (directory) {
3575
+ observeStoreHealth({
3576
+ directory,
3577
+ kind: "skill_usage_health",
3578
+ payload: healthPayload
3579
+ });
3580
+ }
3567
3581
  } catch (err) {
3568
3582
  log("[skill-usage-pending] health emit failed (best-effort):", err instanceof Error ? err.message : String(err));
3569
3583
  }
@@ -4014,7 +4028,7 @@ function applyRetention(entries, maxEntriesPerSkill) {
4014
4028
  }
4015
4029
  let aged = entries;
4016
4030
  if (newestMs !== Number.NEGATIVE_INFINITY) {
4017
- const cutoff = newestMs - SKILL_USAGE_LIMITS.maxAgeMs;
4031
+ const cutoff = Math.min(newestMs, Date.now()) - SKILL_USAGE_LIMITS.maxAgeMs;
4018
4032
  aged = entries.filter((entry) => {
4019
4033
  const ms = Date.parse(entry.timestamp);
4020
4034
  return Number.isNaN(ms) ? true : ms >= cutoff;
@@ -4233,7 +4247,7 @@ function migrateLegacyLog(directory, doc) {
4233
4247
  emitSkillUsageHealth(doc, "migration", {
4234
4248
  bytes: queueByteSize(doc),
4235
4249
  limitBytes: SKILL_USAGE_LIMITS.queueMaxBytes
4236
- });
4250
+ }, directory);
4237
4251
  }
4238
4252
  function ensureMigrated(directory, doc) {
4239
4253
  if (!needsMigration(doc))
@@ -4365,7 +4379,7 @@ function pruneSkillUsageLog(directory, maxEntriesPerSkill = 500) {
4365
4379
  emitSkillUsageHealth(doc, "compaction", {
4366
4380
  bytes: content.length + (surviving.length > 0 ? 1 : 0),
4367
4381
  limitBytes: SKILL_USAGE_LIMITS.maxBytes
4368
- });
4382
+ }, directory);
4369
4383
  return { pruned: dropped, remaining: surviving.length };
4370
4384
  } finally {
4371
4385
  releaseSkillUsageLock(handle);
@@ -4480,7 +4494,7 @@ function commitFeedbackOutcomes(directory, commit) {
4480
4494
  emitSkillUsageHealth(doc, "consumption", {
4481
4495
  bytes: queueByteSize(doc),
4482
4496
  limitBytes: SKILL_USAGE_LIMITS.queueMaxBytes
4483
- });
4497
+ }, directory);
4484
4498
  } finally {
4485
4499
  releaseSkillUsageLock(handle);
4486
4500
  }
@@ -6280,11 +6294,17 @@ var _internals12 = {
6280
6294
  telemetry
6281
6295
  };
6282
6296
  var skippedLockAppends = 0;
6283
- function emitTrajectoryHealth(data) {
6297
+ function emitTrajectoryHealth(directory, data) {
6284
6298
  try {
6285
- _internals12.telemetry.trajectoryHealth({
6299
+ const healthPayload = {
6286
6300
  ...data,
6287
6301
  skipped_lock_count: skippedLockAppends
6302
+ };
6303
+ _internals12.telemetry.trajectoryHealth(healthPayload);
6304
+ observeStoreHealth({
6305
+ directory,
6306
+ kind: "trajectory_health",
6307
+ payload: healthPayload
6288
6308
  });
6289
6309
  } catch {}
6290
6310
  }
@@ -6520,7 +6540,7 @@ async function cleanupOldTrajectoryFiles(directory, maxAgeDays = TRAJECTORY_LIMI
6520
6540
  } catch {}
6521
6541
  }
6522
6542
  if (removed > 0) {
6523
- emitTrajectoryHealth({
6543
+ emitTrajectoryHealth(directory, {
6524
6544
  trigger: "cleanup",
6525
6545
  retained_count: retained,
6526
6546
  dropped_count: removed,
@@ -21454,7 +21474,7 @@ function planMerges(active, threshold, maxComparisons, maxMerges) {
21454
21474
  };
21455
21475
  }
21456
21476
  async function sweepActiveNearDuplicates(directory, options = {}) {
21457
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
21477
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-d9s5hb0m.js");
21458
21478
  const { config } = loadPluginConfigWithMeta2(directory);
21459
21479
  const sweepConfig = config.learning?.dedup_sweep;
21460
21480
  if (sweepConfig?.enabled === false)
@@ -21584,6 +21604,7 @@ var _internals26 = {
21584
21604
  checkPhaseCompliance,
21585
21605
  normalizeAgentName: normalizeAgentName2,
21586
21606
  autoRetireSkills,
21607
+ observeCuratorCompliance,
21587
21608
  readSkillUsageEntries,
21588
21609
  readSkillUsageEntriesWithCoverage,
21589
21610
  recordCuratorSkips,
@@ -22551,6 +22572,12 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
22551
22572
  }
22552
22573
  const sessionId = `session-${Date.now()}`;
22553
22574
  const now2 = new Date().toISOString();
22575
+ _internals26.observeCuratorCompliance({
22576
+ directory,
22577
+ phase,
22578
+ gapTypes: complianceObservations.map((observation) => observation.type),
22579
+ agentsUsed: Array.isArray(phaseDigest.agents_used) ? phaseDigest.agents_used.map(String) : []
22580
+ });
22554
22581
  const summaryUpdated = await _internals26.mergeCuratorPhaseSummary(directory, {
22555
22582
  phase,
22556
22583
  phaseDigest,
@@ -22584,7 +22611,7 @@ async function runCuratorPhase(directory, phase, agentsDispatched, config, knowl
22584
22611
  }
22585
22612
  if (config.skill_generation_enabled === true && skillCandidates.length > 0) {
22586
22613
  try {
22587
- const skillModule = await import("./skill-generator-6tjyffgd.js");
22614
+ const skillModule = await import("./skill-generator-kebhevet.js");
22588
22615
  for (const cand of skillCandidates) {
22589
22616
  if (cand.confidence < (config.min_skill_confidence ?? DEFAULT_SKILL_MIN_CONFIDENCE)) {
22590
22617
  continue;
@@ -23056,7 +23083,7 @@ async function applyCuratorKnowledgeUpdates(directory, recommendations, knowledg
23056
23083
  } catch {}
23057
23084
  }
23058
23085
  if (contradictedEntries.length > 0 && knowledgeConfig.contradiction_threshold_action === "quarantine") {
23059
- const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-rxagfxnk.js");
23086
+ const { maybeQuarantineOnContradiction } = await import("./knowledge-escalator-zksm9833.js");
23060
23087
  for (const { id } of contradictedEntries) {
23061
23088
  try {
23062
23089
  await maybeQuarantineOnContradiction(directory, id, knowledgeConfig.contradiction_quarantine_threshold, knowledgeConfig.contradiction_quarantine_window_days);
@@ -23875,7 +23902,7 @@ async function runCuratorPostMortem(directory, options = {}) {
23875
23902
  warnings.push("Failed to collect knowledge summary.");
23876
23903
  }
23877
23904
  try {
23878
- const { getScanStatus } = await import("./scan-cursor-fasdj7kj.js");
23905
+ const { getScanStatus } = await import("./scan-cursor-4fjwtt1k.js");
23879
23906
  const scanStatus = await getScanStatus(directory);
23880
23907
  if (scanStatus.remaining_estimate > 0) {
23881
23908
  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.`);
@@ -24047,9 +24074,9 @@ var _internals27 = {
24047
24074
  verifyPostMortemKnowledgeActions,
24048
24075
  repairPostMortemActions,
24049
24076
  loadDefaultKnowledgeConfig: async (directory) => {
24050
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
24077
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-d0nbzj5k.js");
24051
24078
  try {
24052
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
24079
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-d9s5hb0m.js");
24053
24080
  const loaded = loadPluginConfigWithMeta2(directory);
24054
24081
  return KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
24055
24082
  } catch {
@@ -24057,11 +24084,11 @@ var _internals27 = {
24057
24084
  }
24058
24085
  },
24059
24086
  applyCuratorKnowledgeUpdates: async (directory, recommendations, knowledgeConfig, generation) => {
24060
- const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-n81nzdw8.js");
24087
+ const { applyCuratorKnowledgeUpdates: applyCuratorKnowledgeUpdates2 } = await import("./curator-dgp6dxxn.js");
24061
24088
  return applyCuratorKnowledgeUpdates2(directory, recommendations, knowledgeConfig, generation);
24062
24089
  },
24063
24090
  checkHivePromotions: async (entries, knowledgeConfig, directory) => {
24064
- const { checkHivePromotions } = await import("./hive-promoter-brq9cx7c.js");
24091
+ const { checkHivePromotions } = await import("./hive-promoter-7cr7t2kg.js");
24065
24092
  return checkHivePromotions(entries, knowledgeConfig, directory);
24066
24093
  },
24067
24094
  applyProposalTriage: async (directory, triage) => {
@@ -24070,7 +24097,7 @@ var _internals27 = {
24070
24097
  activateProposal,
24071
24098
  listSkills: listSkills2,
24072
24099
  sanitizeSlug
24073
- } = await import("./skill-generator-6tjyffgd.js");
24100
+ } = await import("./skill-generator-kebhevet.js");
24074
24101
  const result = {
24075
24102
  approved: [],
24076
24103
  rejected: [],
@@ -25400,9 +25427,9 @@ function hashContent(content) {
25400
25427
  return createHash13("sha1").update(content).digest("hex");
25401
25428
  }
25402
25429
  async function loadConfigForPolicyCurator(directory) {
25403
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
25430
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-d0nbzj5k.js");
25404
25431
  try {
25405
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
25432
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-d9s5hb0m.js");
25406
25433
  const { config: loadedConfig } = loadPluginConfigWithMeta2(directory);
25407
25434
  return KnowledgeConfigSchema2.parse(loadedConfig.knowledge ?? {});
25408
25435
  } catch {
@@ -26480,7 +26507,7 @@ function safeRealpathSync(targetPath, fallback, realpathResolver = realpathSync3
26480
26507
  }
26481
26508
 
26482
26509
  // src/tools/repo-graph/types.ts
26483
- var GRAPH_SCHEMA_VERSION = "1.6.0";
26510
+ var GRAPH_SCHEMA_VERSION = "1.7.0";
26484
26511
  var DEFAULT_MAX_SOURCE_BYTES = 1024 * 1024;
26485
26512
  var FILE_ROLE_VALUES = [
26486
26513
  "api_route",
@@ -26542,6 +26569,22 @@ var ONTOLOGY_FINDING_SEVERITY_VALUES = [
26542
26569
  "medium",
26543
26570
  "high"
26544
26571
  ];
26572
+ var ONTOLOGY_LINK_KIND_VALUES = [
26573
+ "HANDLES_ROUTE",
26574
+ "READS",
26575
+ "WRITES",
26576
+ "DELETES",
26577
+ "VALIDATES",
26578
+ "AUTHORIZES",
26579
+ "TESTS",
26580
+ "USES_FIXTURE",
26581
+ "CONFIGURES"
26582
+ ];
26583
+ var ONTOLOGY_LINK_CONFIDENCE_VALUES = [
26584
+ "low",
26585
+ "medium",
26586
+ "high"
26587
+ ];
26545
26588
  var IMPORT_TYPE_VALUES = [
26546
26589
  "default",
26547
26590
  "named",
@@ -26620,6 +26663,8 @@ var DATA_ACCESS_SET = new Set(DATA_ACCESS_VALUES);
26620
26663
  var SECURITY_KIND_SET = new Set(SECURITY_KIND_VALUES);
26621
26664
  var SECURITY_CONFIDENCE_SET = new Set(SECURITY_CONFIDENCE_VALUES);
26622
26665
  var ONTOLOGY_FINDING_SEVERITY_SET = new Set(ONTOLOGY_FINDING_SEVERITY_VALUES);
26666
+ var ONTOLOGY_LINK_KIND_SET = new Set(ONTOLOGY_LINK_KIND_VALUES);
26667
+ var ONTOLOGY_LINK_CONFIDENCE_SET = new Set(ONTOLOGY_LINK_CONFIDENCE_VALUES);
26623
26668
  var IMPORT_TYPE_SET = new Set(IMPORT_TYPE_VALUES);
26624
26669
  var GRAPH_SYMBOL_KIND_SET = new Set(GRAPH_SYMBOL_KIND_VALUES);
26625
26670
  function validateWorkspace(workspace) {
@@ -27280,9 +27325,9 @@ function finalizeContextTelemetry(directory) {
27280
27325
  warnThrottled("finalize failed");
27281
27326
  }
27282
27327
  }
27283
- function emitContextTelemetryHealth(_directory, payload) {
27328
+ function emitContextTelemetryHealth(directory, payload) {
27284
27329
  try {
27285
- telemetry.contextTelemetryHealth({
27330
+ const healthPayload = {
27286
27331
  trigger: payload.trigger,
27287
27332
  accepted_count: payload.accepted,
27288
27333
  compacted_count: payload.compacted,
@@ -27293,6 +27338,12 @@ function emitContextTelemetryHealth(_directory, payload) {
27293
27338
  newest_timestamp: payload.newest,
27294
27339
  bytes: payload.bytes,
27295
27340
  limit_bytes: payload.limitBytes
27341
+ };
27342
+ telemetry.contextTelemetryHealth(healthPayload);
27343
+ observeStoreHealth({
27344
+ directory,
27345
+ kind: "context_telemetry_health",
27346
+ payload: healthPayload
27296
27347
  });
27297
27348
  } catch {}
27298
27349
  }
@@ -37345,6 +37396,34 @@ function emitCloseArchiveResult(ctx, cleanResult) {
37345
37396
  } catch (telemetryErr) {
37346
37397
  log("[close-command] close_archive_result telemetry emit failed:", telemetryErr);
37347
37398
  }
37399
+ observeCloseArchive({
37400
+ directory: ctx.directory,
37401
+ archiveValid,
37402
+ archiveEmpty,
37403
+ activityPredictsContent: archiveActivityPredictsContent(ctx.directory)
37404
+ });
37405
+ }
37406
+ function archiveActivityPredictsContent(directory) {
37407
+ try {
37408
+ for (const name of [
37409
+ "knowledge-events.jsonl",
37410
+ "telemetry.jsonl",
37411
+ "evidence"
37412
+ ]) {
37413
+ const target = path47.join(directory, ".swarm", name);
37414
+ const stat5 = fsSync3.statSync(target);
37415
+ if (target.endsWith("evidence")) {
37416
+ const entries = fsSync3.readdirSync(target);
37417
+ if (entries.length > 0)
37418
+ return true;
37419
+ } else if (stat5.size > 0) {
37420
+ return true;
37421
+ }
37422
+ }
37423
+ return false;
37424
+ } catch {
37425
+ return false;
37426
+ }
37348
37427
  }
37349
37428
  async function runFinalizeStage(ctx) {
37350
37429
  if (!ctx.planAlreadyDone) {
@@ -37655,7 +37734,7 @@ async function runFinalizeStage(ctx) {
37655
37734
  }
37656
37735
  }
37657
37736
  try {
37658
- const { CuratorConfigSchema: CCS } = await import("./schema-3x28z3rp.js");
37737
+ const { CuratorConfigSchema: CCS } = await import("./schema-d0nbzj5k.js");
37659
37738
  const { config: pmLoadedConfig } = _internals41.loadPluginConfigWithMeta(ctx.directory);
37660
37739
  const curatorCfg = CCS.parse(pmLoadedConfig.curator ?? {});
37661
37740
  if (curatorCfg.enabled && curatorCfg.postmortem_enabled) {
@@ -38541,7 +38620,7 @@ var _internals41 = {
38541
38620
  closePlanTerminalState: reconcileCloseTerminalStateForPlan,
38542
38621
  endAgentSession,
38543
38622
  flushAndDrainTelemetry: async () => {
38544
- const { flushAndDrainTelemetry } = await import("./telemetry-3rh94wv3.js");
38623
+ const { flushAndDrainTelemetry } = await import("./telemetry-gpr9s3sm.js");
38545
38624
  return flushAndDrainTelemetry();
38546
38625
  },
38547
38626
  finalizeContextTelemetry: (directory) => {
@@ -39879,9 +39958,9 @@ var _internals45 = {
39879
39958
  loadPluginConfigWithMeta,
39880
39959
  loadCuratorDeps: async () => {
39881
39960
  const [{ CuratorConfigSchema }, curator, { createCuratorLLMDelegate: createCuratorLLMDelegate2 }] = await Promise.all([
39882
- import("./schema-3x28z3rp.js"),
39883
- import("./curator-n81nzdw8.js"),
39884
- import("./curator-llm-factory-24bfn7h1.js")
39961
+ import("./schema-d0nbzj5k.js"),
39962
+ import("./curator-dgp6dxxn.js"),
39963
+ import("./curator-llm-factory-7cwvmc46.js")
39885
39964
  ]);
39886
39965
  return { CuratorConfigSchema, curator, createCuratorLLMDelegate: createCuratorLLMDelegate2 };
39887
39966
  }
@@ -40381,7 +40460,7 @@ ${USAGE9}`;
40381
40460
  // src/services/diagnose-service.ts
40382
40461
  init_package();
40383
40462
  import * as child_process5 from "child_process";
40384
- import { existsSync as existsSync32, readdirSync as readdirSync6, readFileSync as readFileSync23, statSync as statSync14 } from "fs";
40463
+ import { existsSync as existsSync32, readdirSync as readdirSync7, readFileSync as readFileSync23, statSync as statSync15 } from "fs";
40385
40464
  import * as path54 from "path";
40386
40465
  import { fileURLToPath } from "url";
40387
40466
 
@@ -40890,7 +40969,7 @@ async function computeCurationDiagnostics(directory, entries) {
40890
40969
  let scanCompleted = false;
40891
40970
  let scanRemaining = 0;
40892
40971
  try {
40893
- const { getScanStatus } = await import("./scan-cursor-fasdj7kj.js");
40972
+ const { getScanStatus } = await import("./scan-cursor-4fjwtt1k.js");
40894
40973
  const status = await getScanStatus(directory);
40895
40974
  scanGeneration = status.generation;
40896
40975
  scanCompleted = status.completed;
@@ -40898,19 +40977,19 @@ async function computeCurationDiagnostics(directory, entries) {
40898
40977
  } catch {}
40899
40978
  let configMatch = null;
40900
40979
  try {
40901
- const { isLinked: isLinked2 } = await import("./knowledge-link-n1825n09.js");
40980
+ const { isLinked: isLinked2 } = await import("./knowledge-link-7c7fjnzc.js");
40902
40981
  if (isLinked2(directory)) {
40903
- const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-3x28z3rp.js");
40982
+ const { KnowledgeConfigSchema: KnowledgeConfigSchema2 } = await import("./schema-d0nbzj5k.js");
40904
40983
  let config;
40905
40984
  try {
40906
- const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-mcan50mx.js");
40985
+ const { loadPluginConfigWithMeta: loadPluginConfigWithMeta2 } = await import("./index-d9s5hb0m.js");
40907
40986
  const loaded = loadPluginConfigWithMeta2(directory);
40908
40987
  config = KnowledgeConfigSchema2.parse(loaded.config.knowledge ?? {});
40909
40988
  } catch {
40910
40989
  config = KnowledgeConfigSchema2.parse({});
40911
40990
  }
40912
40991
  const { cohortConfigFingerprint: cohortConfigFingerprint2 } = await import("./config-fingerprint-v22xh5a2.js");
40913
- const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-z0a5akng.js");
40992
+ const { buildConfigFingerprintInput: buildConfigFingerprintInput2, readCohortConfigFingerprint } = await import("./curation-policy-agr6ga1s.js");
40914
40993
  const currentFp = cohortConfigFingerprint2(buildConfigFingerprintInput2(config));
40915
40994
  const cohortFp = await readCohortConfigFingerprint(directory);
40916
40995
  configMatch = cohortFp === null ? null : currentFp === cohortFp;
@@ -41286,7 +41365,7 @@ async function checkPlanSync(directory, plan) {
41286
41365
  }
41287
41366
  async function checkConfigBackups(directory) {
41288
41367
  try {
41289
- const files = readdirSync6(directory);
41368
+ const files = readdirSync7(directory);
41290
41369
  const backupCount = files.filter((f) => /\.opencode-swarm\.yaml\.bak/.test(f)).length;
41291
41370
  if (backupCount <= 5) {
41292
41371
  return {
@@ -41317,7 +41396,7 @@ async function checkConfigBackups(directory) {
41317
41396
  }
41318
41397
  async function checkGitRepository(directory) {
41319
41398
  try {
41320
- if (!existsSync32(directory) || !statSync14(directory).isDirectory()) {
41399
+ if (!existsSync32(directory) || !statSync15(directory).isDirectory()) {
41321
41400
  return {
41322
41401
  name: "Git Repository",
41323
41402
  status: "\u274C",
@@ -41599,6 +41678,33 @@ async function checkSteeringDirectives(directory) {
41599
41678
  };
41600
41679
  }
41601
41680
  }
41681
+ async function checkLearningHealth(directory) {
41682
+ try {
41683
+ const snapshot = await readLearningHealth(directory);
41684
+ if (snapshot.activeAlarms.length === 0) {
41685
+ return {
41686
+ name: "Learning health",
41687
+ status: "\u2705",
41688
+ detail: `No active alarms (${snapshot.totalTransitions} transitions recorded)`
41689
+ };
41690
+ }
41691
+ const detail = snapshot.activeAlarms.map((alarm) => {
41692
+ const ageMinutes = Math.floor(alarm.ageMs / 60000);
41693
+ return `${alarm.severity} ${alarm.alarm} [${alarm.scopeClass} ${alarm.scopeRef}] age ${ageMinutes}m coverage ${alarm.coverageFacts}`;
41694
+ }).join("; ");
41695
+ return {
41696
+ name: "Learning health",
41697
+ status: "\u26A0\uFE0F",
41698
+ detail: `${snapshot.activeAlarms.length} active alarm(s): ${detail}`
41699
+ };
41700
+ } catch {
41701
+ return {
41702
+ name: "Learning health",
41703
+ status: "\u2B1C",
41704
+ detail: "Learning-health artifact unreadable (fail-open)"
41705
+ };
41706
+ }
41707
+ }
41602
41708
  async function checkCurator(directory) {
41603
41709
  try {
41604
41710
  const config = loadPluginConfig(directory);
@@ -41892,10 +41998,11 @@ async function getDiagnoseData(directory, sessionID) {
41892
41998
  checks.push(await checkSteeringDirectives(directory));
41893
41999
  checks.push(await checkCurator(directory));
41894
42000
  checks.push(await checkKnowledgeHealth(directory));
42001
+ checks.push(await checkLearningHealth(directory));
41895
42002
  checks.push(await checkResidueInventory(directory));
41896
42003
  try {
41897
42004
  const evidenceDir = path54.join(directory, ".swarm", "evidence");
41898
- const snapshotFiles = existsSync32(evidenceDir) ? readdirSync6(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
42005
+ const snapshotFiles = existsSync32(evidenceDir) ? readdirSync7(evidenceDir).filter((f) => f.startsWith("agent-tools-") && f.endsWith(".json")) : [];
41899
42006
  if (snapshotFiles.length > 0) {
41900
42007
  const latest = snapshotFiles.sort().pop();
41901
42008
  checks.push({
@@ -42223,7 +42330,7 @@ async function handleDoctorCommand(directory, args) {
42223
42330
  const result = runConfigDoctor(config, directory);
42224
42331
  let output;
42225
42332
  if (enableAutoFix && result.hasAutoFixableIssues) {
42226
- const { runConfigDoctorWithFixes } = await import("./config-doctor-00ex0s3k.js");
42333
+ const { runConfigDoctorWithFixes } = await import("./config-doctor-ddtdz2g0.js");
42227
42334
  const fixResult = await runConfigDoctorWithFixes(directory, config, true, {
42228
42335
  applyLossy: true
42229
42336
  });
@@ -42261,7 +42368,7 @@ async function handleDoctorCommand(directory, args) {
42261
42368
  `;
42262
42369
  }
42263
42370
  try {
42264
- const { runModelPreflight } = await import("./model-preflight-w85ecyxh.js");
42371
+ const { runModelPreflight } = await import("./model-preflight-x9szw1v4.js");
42265
42372
  const preflight = await runModelPreflight(config, swarmState.opencodeClient);
42266
42373
  if (preflight.catalogAvailable) {
42267
42374
  const unresolved = preflight.resolutions.filter((resolution) => resolution.status === "unresolved");
@@ -43163,7 +43270,7 @@ async function handleEvidenceCommand(directory, args) {
43163
43270
  return formatTaskEvidenceMarkdown(evidenceData);
43164
43271
  }
43165
43272
  async function handleEvidenceSummaryCommand(directory) {
43166
- const { buildEvidenceSummary } = await import("./evidence-summary-service-nz7y1w2a.js");
43273
+ const { buildEvidenceSummary } = await import("./evidence-summary-service-sbnyann4.js");
43167
43274
  const artifact = await buildEvidenceSummary(directory);
43168
43275
  if (!artifact) {
43169
43276
  return "No plan found. Run `/swarm plan` to check plan status.";
@@ -51053,7 +51160,7 @@ import {
51053
51160
  readFileSync as readFileSync32,
51054
51161
  renameSync as renameSync12,
51055
51162
  rmSync as rmSync7,
51056
- statSync as statSync18,
51163
+ statSync as statSync19,
51057
51164
  unlinkSync as unlinkSync12,
51058
51165
  writeSync
51059
51166
  } from "fs";
@@ -56659,18 +56766,18 @@ var MIN_MAX_CYCLES = 1;
56659
56766
  var MAX_MAX_CYCLES = 5;
56660
56767
  async function readLatestLoopState(directory) {
56661
56768
  try {
56662
- const { readdirSync: readdirSync9, statSync: statSync20, readFileSync: readFileSync38 } = await import("fs");
56769
+ const { readdirSync: readdirSync10, statSync: statSync21, readFileSync: readFileSync38 } = await import("fs");
56663
56770
  const loopDir = `${directory}/.swarm/loop`;
56664
56771
  let latestMtime = 0;
56665
56772
  let latestPath = null;
56666
56773
  try {
56667
- const entries = readdirSync9(loopDir, { withFileTypes: true });
56774
+ const entries = readdirSync10(loopDir, { withFileTypes: true });
56668
56775
  for (const entry of entries) {
56669
56776
  if (!entry.isDirectory())
56670
56777
  continue;
56671
56778
  const statePath = `${loopDir}/${entry.name}/state.json`;
56672
56779
  try {
56673
- const mtime = statSync20(statePath).mtimeMs;
56780
+ const mtime = statSync21(statePath).mtimeMs;
56674
56781
  if (mtime > latestMtime) {
56675
56782
  latestMtime = mtime;
56676
56783
  latestPath = statePath;
@@ -57308,7 +57415,7 @@ import {
57308
57415
  openSync as openSync13,
57309
57416
  readSync as readSync7,
57310
57417
  realpathSync as realpathSync8,
57311
- statSync as statSync21
57418
+ statSync as statSync22
57312
57419
  } from "fs";
57313
57420
  var import_proper_lockfile9 = __toESM(require_proper_lockfile(), 1);
57314
57421
 
@@ -60602,6 +60709,8 @@ var HTTP_METHODS = [
60602
60709
  "HEAD"
60603
60710
  ];
60604
60711
  var MAX_FACTS_PER_KIND = 50;
60712
+ var MAX_LINKS_PER_FILE = 200;
60713
+ var MAX_CONFIGURES_PER_FILE = 20;
60605
60714
  function stripComments(content) {
60606
60715
  let out = "";
60607
60716
  let i = 0;
@@ -61022,7 +61131,7 @@ function buildFindings(roles, routes, dataOperations, security) {
61022
61131
  findings.push({
61023
61132
  code: "api_route_without_detected_auth",
61024
61133
  severity: "medium",
61025
- message: "No authentication, authorization, or CSRF guard was detected near this route.",
61134
+ message: "No authentication, authorization, or CSRF guard was detected anywhere in this file; absence of this finding does not prove an individual route is guarded.",
61026
61135
  line: routes[0]?.line
61027
61136
  });
61028
61137
  }
@@ -61044,6 +61153,112 @@ function buildFindings(roles, routes, dataOperations, security) {
61044
61153
  }
61045
61154
  return findings;
61046
61155
  }
61156
+ function routerCallHandlerSymbol(line) {
61157
+ if (line.length > 500)
61158
+ return null;
61159
+ const match = line.match(/\b(?:router|app|server)\s*\.\s*(?:get|post|put|patch|delete|options|head|all)\s*\([^(]*?([A-Za-z_$][\w$]*)\s*\)\s*[;,)]?\s*$/);
61160
+ return match?.[1] ?? null;
61161
+ }
61162
+ var CONFIG_KEY_PATTERN = /\bprocess\.env\.([A-Za-z_$][A-Za-z0-9_$]*)\b|\bprocess\.env\[\s*['"]([A-Za-z_$][A-Za-z0-9_$]*)['"]\s*\]|\bimport\.meta\.env\.([A-Za-z_$][A-Za-z0-9_$]*)\b|\bDeno\.env\.get\(\s*['"]([A-Za-z_$][A-Za-z0-9_$]*)['"]\s*\)/g;
61163
+ function extractLinks(content, routes, dataOperations, security) {
61164
+ const lines = content.split(/\r?\n/);
61165
+ const links = [];
61166
+ for (const route of routes) {
61167
+ if (route.source === "handler_export") {
61168
+ links.push({
61169
+ kind: "HANDLES_ROUTE",
61170
+ subject: `${route.method} ${route.path}`,
61171
+ ...route.line !== undefined ? { line: route.line } : {},
61172
+ ...route.line !== undefined ? { evidence: (lines[route.line - 1] ?? "").trim().slice(0, 160) } : {},
61173
+ confidence: "high",
61174
+ symbol: route.method
61175
+ });
61176
+ } else if (route.source === "router_call") {
61177
+ const handler = route.line !== undefined ? routerCallHandlerSymbol(lines[route.line - 1] ?? "") : null;
61178
+ links.push({
61179
+ kind: "HANDLES_ROUTE",
61180
+ subject: `${route.method} ${route.path}`,
61181
+ ...route.line !== undefined ? { line: route.line } : {},
61182
+ ...route.line !== undefined ? { evidence: (lines[route.line - 1] ?? "").trim().slice(0, 160) } : {},
61183
+ confidence: "medium",
61184
+ ...handler ? { symbol: handler } : {}
61185
+ });
61186
+ } else {
61187
+ links.push({
61188
+ kind: "HANDLES_ROUTE",
61189
+ subject: `${route.method} ${route.path}`,
61190
+ confidence: "low"
61191
+ });
61192
+ }
61193
+ }
61194
+ const operationKind = {
61195
+ read: "READS",
61196
+ write: "WRITES",
61197
+ delete: "DELETES",
61198
+ transaction: "WRITES",
61199
+ migration: "WRITES"
61200
+ };
61201
+ const dataLinks = [];
61202
+ for (const fact of dataOperations) {
61203
+ if (!fact.entity)
61204
+ continue;
61205
+ const kind = operationKind[fact.operation];
61206
+ if (!kind)
61207
+ continue;
61208
+ const confidence = fact.operation === "transaction" || fact.operation === "migration" ? "low" : "medium";
61209
+ dataLinks.push({
61210
+ kind,
61211
+ subject: fact.entity,
61212
+ line: fact.line,
61213
+ evidence: fact.evidence,
61214
+ confidence
61215
+ });
61216
+ }
61217
+ dataLinks.sort((a, b) => (a.line ?? 0) - (b.line ?? 0));
61218
+ links.push(...dataLinks);
61219
+ const securityLinks = [];
61220
+ for (const fact of security) {
61221
+ if (fact.kind === "input_validation") {
61222
+ securityLinks.push({
61223
+ kind: "VALIDATES",
61224
+ line: fact.line,
61225
+ evidence: fact.evidence,
61226
+ confidence: fact.confidence
61227
+ });
61228
+ } else if (fact.kind === "authorization") {
61229
+ securityLinks.push({
61230
+ kind: "AUTHORIZES",
61231
+ line: fact.line,
61232
+ evidence: fact.evidence,
61233
+ confidence: fact.confidence
61234
+ });
61235
+ }
61236
+ }
61237
+ securityLinks.sort((a, b) => (a.line ?? 0) - (b.line ?? 0));
61238
+ links.push(...securityLinks);
61239
+ const seenKeys = new Set;
61240
+ const configureLinks = [];
61241
+ for (let i = 0;i < lines.length && configureLinks.length < MAX_CONFIGURES_PER_FILE; i++) {
61242
+ const line = lines[i];
61243
+ for (const match of line.matchAll(CONFIG_KEY_PATTERN)) {
61244
+ if (configureLinks.length >= MAX_CONFIGURES_PER_FILE)
61245
+ break;
61246
+ const key = match[1] ?? match[2] ?? match[3] ?? match[4];
61247
+ if (!key || seenKeys.has(key))
61248
+ continue;
61249
+ seenKeys.add(key);
61250
+ configureLinks.push({
61251
+ kind: "CONFIGURES",
61252
+ subject: key,
61253
+ line: i + 1,
61254
+ evidence: line.trim().slice(0, 160),
61255
+ confidence: "medium"
61256
+ });
61257
+ }
61258
+ }
61259
+ links.push(...configureLinks);
61260
+ return links.slice(0, MAX_LINKS_PER_FILE);
61261
+ }
61047
61262
  function extractFileOntology(input) {
61048
61263
  const moduleName = normalizeModuleName(input.moduleName);
61049
61264
  const content = stripComments(input.content);
@@ -61053,6 +61268,7 @@ function extractFileOntology(input) {
61053
61268
  const security = extractSecurityFacts(content);
61054
61269
  const conventions = extractConventions(moduleName, roles, routes);
61055
61270
  const findings = buildFindings(roles, routes, dataOperations, security);
61271
+ const links = extractLinks(content, routes, dataOperations, security);
61056
61272
  return {
61057
61273
  roles,
61058
61274
  packageBoundary: sourceBoundaryForLanguage(input.language, content) ?? boundaryForModule(moduleName, input.hasManifest),
@@ -61060,7 +61276,8 @@ function extractFileOntology(input) {
61060
61276
  dataOperations,
61061
61277
  security,
61062
61278
  conventions,
61063
- findings
61279
+ findings,
61280
+ links
61064
61281
  };
61065
61282
  }
61066
61283
 
@@ -63116,8 +63333,8 @@ async function migrateMemoryFamily(destRoot, sourceRoot) {
63116
63333
  copyFileSync4(sourceDbPath, path82.join(backupDir, `memory.db.pre-merge-${stamp}`));
63117
63334
  } catch {}
63118
63335
  try {
63119
- const { readdirSync: readdirSync10, unlinkSync: rmFileSync } = await import("fs");
63120
- const backups = readdirSync10(backupDir).filter((f) => f.startsWith("memory.db.pre-merge-")).sort();
63336
+ const { readdirSync: readdirSync11, unlinkSync: rmFileSync } = await import("fs");
63337
+ const backups = readdirSync11(backupDir).filter((f) => f.startsWith("memory.db.pre-merge-")).sort();
63121
63338
  while (backups.length > MAX_BACKUPS) {
63122
63339
  const oldest = backups.shift();
63123
63340
  if (oldest)
@@ -76895,7 +77112,7 @@ import {
76895
77112
  openSync as openSync20,
76896
77113
  readFileSync as readFileSync46,
76897
77114
  renameSync as renameSync16,
76898
- statSync as statSync25,
77115
+ statSync as statSync26,
76899
77116
  unlinkSync as unlinkSync22,
76900
77117
  writeFileSync as writeFileSync18,
76901
77118
  writeFileSync as writeFileSyncAsync
@@ -76985,7 +77202,7 @@ var _internals93 = {
76985
77202
  renameSync: renameSync16,
76986
77203
  unlinkSync: unlinkSync22,
76987
77204
  existsSync: existsSync57,
76988
- statSync: statSync25
77205
+ statSync: statSync26
76989
77206
  };
76990
77207
  async function appendEvent2(directory, eventInput) {
76991
77208
  assertProjectRoot(directory);
@@ -78391,7 +78608,7 @@ async function runValidationWithTransientRetry(input, candidateContent, baseline
78391
78608
  if (!input.dispatcher) {
78392
78609
  throw new Error("no evaluation dispatcher available (cannot run validation)");
78393
78610
  }
78394
- const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-fzgkhx6a.js");
78611
+ const { createModelEvaluationExecutor: createModelEvaluationExecutor2 } = await import("./runner-p9wg6z34.js");
78395
78612
  const executor = createModelEvaluationExecutor2(input.dispatcher, input.sessionId);
78396
78613
  const result = await withProtectedSetIntegrity([evalInputRoot, ...protectedRoots(input.directory)], () => _internals98.evaluateCandidateV1({
78397
78614
  projectRoot: input.directory,
@@ -79548,6 +79765,23 @@ async function getStatusData(directory, agents, sessionId, options) {
79548
79765
  } catch {
79549
79766
  status.delegationLedgerHealth = undefined;
79550
79767
  }
79768
+ try {
79769
+ const snapshot = await readLearningHealth(directory);
79770
+ status.learningHealth = {
79771
+ activeAlarms: snapshot.activeAlarms.map((alarm) => ({
79772
+ alarm: alarm.alarm,
79773
+ severity: alarm.severity,
79774
+ scopeClass: alarm.scopeClass,
79775
+ scopeRef: alarm.scopeRef,
79776
+ ageMs: alarm.ageMs,
79777
+ coverageFacts: alarm.coverageFacts,
79778
+ transitionCount: alarm.transitionCount
79779
+ })),
79780
+ totalTransitions: snapshot.totalTransitions
79781
+ };
79782
+ } catch {
79783
+ status.learningHealth = undefined;
79784
+ }
79551
79785
  const backgroundSubagentsEnabled = options?.backgroundSubagents ?? (() => {
79552
79786
  try {
79553
79787
  return loadPluginConfig(directory)?.hooks?.background_subagents === true;
@@ -79838,6 +80072,19 @@ function formatStatusMarkdown(status) {
79838
80072
  if (consensusReports > 0)
79839
80073
  lines.push(` - Consensus reports: ${consensusReports} (read under \`.swarm/evolution/consensus/\`; each holds proposals-only recommendations)`);
79840
80074
  }
80075
+ if (status.learningHealth) {
80076
+ lines.push("", "**Learning Health**:");
80077
+ const active = status.learningHealth.activeAlarms;
80078
+ if (active.length === 0) {
80079
+ lines.push(` - \u2705 no active learning-health alarms (${status.learningHealth.totalTransitions} transitions recorded)`);
80080
+ } else {
80081
+ for (const alarm of active) {
80082
+ const ageMinutes = Math.floor(alarm.ageMs / 60000);
80083
+ lines.push(` - \u26A0 ${alarm.severity}: ${alarm.alarm} [${alarm.scopeClass} ${alarm.scopeRef}] age ${ageMinutes}m, coverage ${alarm.coverageFacts} facts (${alarm.transitionCount} transitions)`);
80084
+ }
80085
+ lines.push(` - run \`/swarm diagnose\` for the learning-health check detail`);
80086
+ }
80087
+ }
79841
80088
  if (status.cohort?.linked) {
79842
80089
  lines.push("", "**Knowledge Cohort**:");
79843
80090
  lines.push(` - \uD83D\uDD17 Linked to shared store "${status.cohort.linkId}"`);
@@ -80486,7 +80733,7 @@ function buildDetailedHelp(commandName, entry) {
80486
80733
  async function handleHelpCommand(ctx) {
80487
80734
  const targetCommand = ctx.args.join(" ");
80488
80735
  if (!targetCommand) {
80489
- const { buildHelpText } = await import("./index-k7kvrwbj.js");
80736
+ const { buildHelpText } = await import("./index-jmths6jj.js");
80490
80737
  return buildHelpText();
80491
80738
  }
80492
80739
  const tokens = targetCommand.split(/\s+/);
@@ -80495,7 +80742,7 @@ async function handleHelpCommand(ctx) {
80495
80742
  return _internals101.buildDetailedHelp(resolved.key, resolved.entry);
80496
80743
  }
80497
80744
  const similar = _internals101.findSimilarCommands(targetCommand);
80498
- const { buildHelpText: fullHelp } = await import("./index-k7kvrwbj.js");
80745
+ const { buildHelpText: fullHelp } = await import("./index-jmths6jj.js");
80499
80746
  if (similar.length > 0) {
80500
80747
  return `Command '/swarm ${targetCommand}' not found.
80501
80748
 
@@ -80826,7 +81073,7 @@ var COMMAND_REGISTRY = {
80826
81073
  },
80827
81074
  "guardrail explain": {
80828
81075
  handler: async (ctx) => {
80829
- const { handleGuardrailExplain } = await import("./guardrail-explain-b3k9xrx9.js");
81076
+ const { handleGuardrailExplain } = await import("./guardrail-explain-2gwarnca.js");
80830
81077
  return handleGuardrailExplain(ctx.directory, ctx.args);
80831
81078
  },
80832
81079
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -80836,7 +81083,7 @@ var COMMAND_REGISTRY = {
80836
81083
  },
80837
81084
  "guardrail reset": {
80838
81085
  handler: async (ctx) => {
80839
- const { handleGuardrailReset } = await import("./guardrail-reset-0ft2gf03.js");
81086
+ const { handleGuardrailReset } = await import("./guardrail-reset-3cnz54hx.js");
80840
81087
  return handleGuardrailReset(ctx.args, ctx.sessionID);
80841
81088
  },
80842
81089
  description: "Reset one exact active invocation/action circuit after repair",
@@ -80845,7 +81092,7 @@ var COMMAND_REGISTRY = {
80845
81092
  },
80846
81093
  "guardrail-explain": {
80847
81094
  handler: async (ctx) => {
80848
- const { handleGuardrailExplain } = await import("./guardrail-explain-b3k9xrx9.js");
81095
+ const { handleGuardrailExplain } = await import("./guardrail-explain-2gwarnca.js");
80849
81096
  return handleGuardrailExplain(ctx.directory, ctx.args);
80850
81097
  },
80851
81098
  description: "Dry-run: show what the guardrails would do to a command or write target (executes nothing)",
@@ -80855,7 +81102,7 @@ var COMMAND_REGISTRY = {
80855
81102
  },
80856
81103
  "guardrail-reset": {
80857
81104
  handler: async (ctx) => {
80858
- const { handleGuardrailReset } = await import("./guardrail-reset-0ft2gf03.js");
81105
+ const { handleGuardrailReset } = await import("./guardrail-reset-3cnz54hx.js");
80859
81106
  return handleGuardrailReset(ctx.args, ctx.sessionID);
80860
81107
  },
80861
81108
  description: "Reset one exact active invocation/action circuit after repair",
@@ -80865,7 +81112,7 @@ var COMMAND_REGISTRY = {
80865
81112
  },
80866
81113
  "guardrail-log": {
80867
81114
  handler: async (ctx) => {
80868
- const { handleGuardrailLog } = await import("./guardrail-log-t8c7acxg.js");
81115
+ const { handleGuardrailLog } = await import("./guardrail-log-zbnbff1y.js");
80869
81116
  return handleGuardrailLog(ctx.directory, ctx.args);
80870
81117
  },
80871
81118
  description: "Read the guardrail decision log (use --blocks-only for blocks)",
@@ -83787,6 +84034,7 @@ init_schema();
83787
84034
  init_context_window();
83788
84035
  var loggedFirstCalls = new Set;
83789
84036
  var warnedUndersizedDefaults = new Set;
84037
+ var invalidOverrideReports = new Set;
83790
84038
 
83791
84039
  // src/hooks/guardrails/nontransient-circuit.ts
83792
84040
  init_schema();
@@ -86858,7 +87106,7 @@ function getDisplayFinalPromptPressure() {
86858
87106
  async function rehydratePrSubscriptions(sessionID, directory) {
86859
87107
  const map = new Map;
86860
87108
  try {
86861
- const { listActive: listActive2 } = await import("./pr-subscriptions-pxv24d5k.js");
87109
+ const { listActive: listActive2 } = await import("./pr-subscriptions-wbdw9a82.js");
86862
87110
  const records = await listActive2(directory);
86863
87111
  for (const record of records) {
86864
87112
  if (record.sessionID !== sessionID)
@@ -87304,7 +87552,7 @@ function isLaneOwnedByCurrentSession(branchName, expectedSessionId) {
87304
87552
  return extracted === expectedSessionId;
87305
87553
  }
87306
87554
  async function inspectStandardWorktreeCollisionOwnership(identity) {
87307
- const collisionOwnership = await import("./worktree-collision-ownership-3bbn1n2r.js");
87555
+ const collisionOwnership = await import("./worktree-collision-ownership-h8qswnrp.js");
87308
87556
  return collisionOwnership.inspectStandardWorktreeCollisionOwnership(identity);
87309
87557
  }
87310
87558
  async function runRecoveryGit(directory, args, timeoutMs = 15000) {
@@ -87713,7 +87961,7 @@ async function precreateStandardWorktreeSession(args) {
87713
87961
  const laneProfile = computeLaneRuntimeProfile(worktreeConfig.runtime_isolation, laneIndex, handle.worktreePath);
87714
87962
  if (laneProfile) {
87715
87963
  try {
87716
- const { writeLaneProfileToDiskReal } = await import("./core-03tedwzg.js");
87964
+ const { writeLaneProfileToDiskReal } = await import("./core-embasn2j.js");
87717
87965
  await writeLaneProfileToDiskReal(handle.worktreePath, laneProfile.laneIndex, laneProfile.envOverrides);
87718
87966
  } catch {}
87719
87967
  }
@@ -88638,7 +88886,7 @@ async function finishStandardWorktreeDispatch(directory, dispatch, config, callI
88638
88886
  }
88639
88887
  clearWorktreeMergeStatus(statusKey);
88640
88888
  try {
88641
- const { removeLaneProfileFromDiskReal } = await import("./core-03tedwzg.js");
88889
+ const { removeLaneProfileFromDiskReal } = await import("./core-embasn2j.js");
88642
88890
  await removeLaneProfileFromDiskReal(dispatch.handle.worktreePath, dispatch.laneIndex);
88643
88891
  } catch {}
88644
88892
  const state = serializationStateBySessionID.get(dispatch.parentSessionID);