opencode-swarm 7.166.2 → 7.166.3

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 (100) hide show
  1. package/binaries/win32-arm64/swarm-sandbox-runner.exe +0 -0
  2. package/binaries/win32-x64/swarm-sandbox-runner.exe +0 -0
  3. package/dist/cli/{coder-settlement-pv86n7n4.js → coder-settlement-nx8ff9k1.js} +11 -11
  4. package/dist/cli/{config-doctor-fy1aytwt.js → config-doctor-n9cjh11e.js} +2 -2
  5. package/dist/cli/{core-1d9vqbt4.js → core-cbwrwhcz.js} +1 -1
  6. package/dist/cli/{curation-policy-gnpgc3z7.js → curation-policy-bvxf5pxv.js} +9 -6
  7. package/dist/cli/{curator-a4rbehfr.js → curator-c7amtass.js} +37 -36
  8. package/dist/cli/{curator-drift-efmgp1v2.js → curator-drift-20m2ab5w.js} +4 -4
  9. package/dist/cli/curator-llm-factory-2gv6kt1v.js +71 -0
  10. package/dist/cli/{evidence-summary-service-dvp1kbm4.js → evidence-summary-service-5th3zm9c.js} +15 -15
  11. package/dist/cli/{gate-evidence-qf27gdfx.js → gate-evidence-py8v0w28.js} +6 -6
  12. package/dist/cli/guardrail-explain-qzhjhtyk.js +72 -0
  13. package/dist/cli/{guardrail-log-qhw3knjt.js → guardrail-log-rtdpk545.js} +7 -7
  14. package/dist/cli/{guardrail-reset-84ydxdg3.js → guardrail-reset-s27fehv6.js} +37 -36
  15. package/dist/cli/{hive-promoter-y2daybf6.js → hive-promoter-56mfysq6.js} +37 -36
  16. package/dist/cli/{index-0a0jsbhg.js → index-0jpv5z94.js} +1 -1
  17. package/dist/cli/{index-bysyj3z4.js → index-1aex5zd9.js} +1 -1
  18. package/dist/cli/{index-p0r5fn7y.js → index-251vrmge.js} +2 -2
  19. package/dist/cli/{index-sxsyd7kf.js → index-2c7eabkr.js} +6 -6
  20. package/dist/cli/{index-sxe3t040.js → index-2w0beg3s.js} +2 -2
  21. package/dist/cli/{index-kd68b6mg.js → index-3a2xznmd.js} +2 -2
  22. package/dist/cli/{index-9ccxcjdm.js → index-3f1tr4ha.js} +4 -4
  23. package/dist/cli/{index-jr6tppv9.js → index-3nm1b3t2.js} +7 -7
  24. package/dist/cli/{index-3wtfrjcx.js → index-4c50tm9j.js} +3 -3
  25. package/dist/cli/{index-e0bjbadr.js → index-4mgggb8x.js} +8 -3
  26. package/dist/cli/{index-ft1tnx0e.js → index-5bd84nxc.js} +1 -1
  27. package/dist/cli/{index-7pp8fz4j.js → index-6d4dc99f.js} +1 -1
  28. package/dist/cli/{index-nthqfxzz.js → index-75f9jj3h.js} +2 -2
  29. package/dist/cli/{index-x4azb6qj.js → index-87wqes24.js} +2 -2
  30. package/dist/cli/{index-22sannyk.js → index-8cky7ksv.js} +36 -10
  31. package/dist/cli/{index-x8cvbkjs.js → index-9wv6a3jx.js} +2 -2
  32. package/dist/cli/{index-qmp4gxac.js → index-b7ra4hwj.js} +1 -1
  33. package/dist/cli/{index-8nv3bc9h.js → index-bwvbj3fp.js} +4 -4
  34. package/dist/cli/{index-st47knj6.js → index-ch293kd3.js} +3 -3
  35. package/dist/cli/{index-ytsts0zj.js → index-d5gvr6z4.js} +1 -1
  36. package/dist/cli/{index-gy55mc55.js → index-dvhecfa9.js} +3369 -2820
  37. package/dist/cli/{index-bks56jbg.js → index-f6zgz02s.js} +3 -3
  38. package/dist/cli/{index-z1kmkh72.js → index-gbv76wf7.js} +2 -2
  39. package/dist/cli/{index-2n1v8ft1.js → index-gk1w1h9k.js} +5 -1
  40. package/dist/cli/{index-ty0wg9yp.js → index-h92cqbqa.js} +5 -5
  41. package/dist/cli/{index-hbjax6hy.js → index-hfrb77tj.js} +8 -8
  42. package/dist/cli/{index-19hjpqsy.js → index-m21x1bkx.js} +17 -9
  43. package/dist/cli/{index-j81kpway.js → index-m3tx1q9v.js} +1 -1
  44. package/dist/cli/{index-7mxrqy4r.js → index-ms16gaa4.js} +7 -7
  45. package/dist/cli/{index-jgtje76m.js → index-qa7t42e7.js} +94 -29
  46. package/dist/cli/{index-hgphhnrp.js → index-qd619x3r.js} +2 -2
  47. package/dist/cli/{index-fkk7x6sy.js → index-qd726agw.js} +2 -2
  48. package/dist/cli/{index-c23w8t46.js → index-qww0h314.js} +11 -6
  49. package/dist/cli/{index-y3dtdn2f.js → index-rk10x4zr.js} +1 -1
  50. package/dist/cli/{index-4kwxpnf8.js → index-sahf5yz3.js} +1 -1
  51. package/dist/cli/{index-14z9en94.js → index-t8tw1bhs.js} +1 -1
  52. package/dist/cli/{index-wz258yje.js → index-t9kjxzdr.js} +11 -11
  53. package/dist/cli/{index-3nww2vnx.js → index-tzq6t9wc.js} +8 -8
  54. package/dist/cli/index-vzm6zre7.js +167 -0
  55. package/dist/cli/{index-nrdj94za.js → index-w50dk71y.js} +39 -38
  56. package/dist/cli/{index-c0eyq4rp.js → index-xn16akay.js} +4 -4
  57. package/dist/cli/index.js +37 -36
  58. package/dist/cli/{knowledge-escalator-aq7gzhpd.js → knowledge-escalator-stnveccq.js} +13 -12
  59. package/dist/cli/{knowledge-events-9z5sskyv.js → knowledge-events-ph6txm8h.js} +10 -10
  60. package/dist/cli/{knowledge-link-ps2v4s18.js → knowledge-link-w1fwqts4.js} +4 -4
  61. package/dist/cli/{knowledge-store-1hzt2a0t.js → knowledge-store-tgyhr9nf.js} +8 -5
  62. package/dist/cli/{knowledge-validator-xe1fza7c.js → knowledge-validator-2g547bcn.js} +8 -7
  63. package/dist/cli/{pending-delegations-0nfjg7vp.js → pending-delegations-873dtyw6.js} +12 -11
  64. package/dist/cli/{pr-subscriptions-8974hwa0.js → pr-subscriptions-xmxdrj1z.js} +12 -11
  65. package/dist/cli/{pr-workflow-gate-xgak5wvz.js → pr-workflow-gate-h7644byf.js} +37 -36
  66. package/dist/cli/{runner-7zqbp81n.js → runner-nmrjv7te.js} +5 -5
  67. package/dist/cli/{scan-cursor-hc4v0c90.js → scan-cursor-tx72gxp0.js} +7 -6
  68. package/dist/cli/{schema-w1hsvw1h.js → schema-cpc92vq0.js} +3 -1
  69. package/dist/cli/{scope-persistence-k17003v4.js → scope-persistence-xy3xs55f.js} +15 -14
  70. package/dist/cli/{skill-generator-tbxgpc9x.js → skill-generator-4f1v5zwx.js} +15 -14
  71. package/dist/cli/{snapshot-coordination-init-vaf34wf0.js → snapshot-coordination-init-w2nw33pn.js} +37 -36
  72. package/dist/cli/{telemetry-8qn4eag5.js → telemetry-ce0tx41h.js} +1 -1
  73. package/dist/cli/{workspace-snapshot-y85jy6gs.js → workspace-snapshot-0kxj2grt.js} +3 -3
  74. package/dist/cli/{worktree-collision-ownership-r3jdke7h.js → worktree-collision-ownership-1g1qz8wc.js} +13 -12
  75. package/dist/cli/{worktree-isolation-sa1tbqff.js → worktree-isolation-jwxtrh3z.js} +37 -36
  76. package/dist/commands/close.d.ts +82 -0
  77. package/dist/config/schema.d.ts +9 -0
  78. package/dist/context-map/capsule-persistence.d.ts +13 -8
  79. package/dist/hooks/delegate-ack-collector.d.ts +7 -0
  80. package/dist/hooks/knowledge-store.d.ts +7 -0
  81. package/dist/hooks/review-receipt.d.ts +29 -1
  82. package/dist/index.js +554 -551
  83. package/dist/knowledge/curation-policy.d.ts +7 -0
  84. package/dist/memory/consolidation-log.d.ts +9 -0
  85. package/dist/memory/injector.d.ts +7 -0
  86. package/dist/memory/run-log.d.ts +8 -0
  87. package/dist/retention/caps.d.ts +33 -0
  88. package/dist/retention/dir-prune.d.ts +72 -0
  89. package/dist/retention/jsonl-cap.d.ts +84 -0
  90. package/dist/retention/sweep.d.ts +67 -0
  91. package/dist/services/compaction-service.d.ts +14 -0
  92. package/dist/services/skill-changelog.d.ts +20 -0
  93. package/dist/summaries/manager.d.ts +41 -4
  94. package/dist/test-impact/history-store.d.ts +16 -0
  95. package/dist/turbo/epic/calibration.d.ts +16 -1
  96. package/dist/turbo/epic/divergence-recorder.d.ts +11 -0
  97. package/opencode-swarm.schema.json +15 -0
  98. package/package.json +1 -1
  99. package/dist/cli/curator-llm-factory-cwg62ynw.js +0 -70
  100. package/dist/cli/guardrail-explain-zskpzgsr.js +0 -71
@@ -223,7 +223,7 @@ var CATALOG_SOURCE = [
223
223
  category: "delegation",
224
224
  severity: "info",
225
225
  privacyClass: "pseudonymous",
226
- producer: "src/index.ts:758",
226
+ producer: "src/index.ts:768",
227
227
  consumers: CONSUMER_COST_CORRECTION,
228
228
  retentionOwnerIssue: ISSUE_COST_RETENTION,
229
229
  requiredWorkflowIds: REQUIRE_SESSION_AND_TASK,
@@ -236,7 +236,7 @@ var CATALOG_SOURCE = [
236
236
  category: "delegation",
237
237
  severity: "info",
238
238
  privacyClass: "pseudonymous",
239
- producer: "src/index.ts:1700",
239
+ producer: "src/index.ts:1752",
240
240
  consumers: NO_CONSUMERS,
241
241
  futureOwnerIssue: ISSUE_SINK,
242
242
  retentionOwnerIssue: ISSUE_COST_RETENTION,
@@ -250,7 +250,7 @@ var CATALOG_SOURCE = [
250
250
  category: "delegation",
251
251
  severity: "notice",
252
252
  privacyClass: "pseudonymous",
253
- producer: "src/index.ts:1720",
253
+ producer: "src/index.ts:1772",
254
254
  consumers: CONSUMER_COST_JOIN,
255
255
  retentionOwnerIssue: ISSUE_COST_RETENTION,
256
256
  requiredWorkflowIds: REQUIRE_SESSION,
@@ -14,14 +14,14 @@ import {
14
14
  detectWindowsWrites,
15
15
  getSharedClassifierGuardrailBlock,
16
16
  resolveWriteTargets
17
- } from "./index-gy55mc55.js";
17
+ } from "./index-dvhecfa9.js";
18
18
  import {
19
19
  checkFileAuthority,
20
20
  classifyFile,
21
21
  isInDeclaredScope,
22
22
  redactPath,
23
23
  redactShellCommand
24
- } from "./index-3wtfrjcx.js";
24
+ } from "./index-4c50tm9j.js";
25
25
 
26
26
  // src/services/guardrail-explain-service.ts
27
27
  import path from "path";
@@ -12,7 +12,7 @@ import {
12
12
  PluginConfigSchema,
13
13
  init_schema,
14
14
  stripKnownSwarmPrefix
15
- } from "./index-e0bjbadr.js";
15
+ } from "./index-4mgggb8x.js";
16
16
  import {
17
17
  ALL_AGENT_NAMES,
18
18
  TOOL_NAME_SET,
@@ -1024,6 +1024,10 @@ function validateConfigKey(path2, value) {
1024
1024
  emitObjectTypeMismatch("repo_graph", value, findings);
1025
1025
  break;
1026
1026
  }
1027
+ case "retention": {
1028
+ emitObjectTypeMismatch("retention", value, findings);
1029
+ break;
1030
+ }
1027
1031
  case "review_passes": {
1028
1032
  emitObjectTypeMismatch("review_passes", value, findings);
1029
1033
  break;
@@ -3,7 +3,7 @@ import {
3
3
  queryHistoricalOutcomes,
4
4
  readKnowledgeEvents,
5
5
  recordKnowledgeEvent
6
- } from "./index-3nww2vnx.js";
6
+ } from "./index-tzq6t9wc.js";
7
7
  import {
8
8
  jaccardBigram,
9
9
  readKnowledge,
@@ -11,7 +11,7 @@ import {
11
11
  resolveSwarmKnowledgePath,
12
12
  transactKnowledge,
13
13
  wordBigrams
14
- } from "./index-22sannyk.js";
14
+ } from "./index-8cky7ksv.js";
15
15
  import {
16
16
  init_knowledge_types,
17
17
  isActiveStatus
@@ -224,11 +224,11 @@ async function maybeQuarantineOnContradiction(directory, entryId, threshold, win
224
224
  alreadyInactive: true
225
225
  };
226
226
  }
227
- const { quarantineEntry } = await import("./knowledge-validator-xe1fza7c.js");
227
+ const { quarantineEntry } = await import("./knowledge-validator-2g547bcn.js");
228
228
  let policyConfig;
229
229
  try {
230
- const { KnowledgeConfigSchema } = await import("./schema-w1hsvw1h.js");
231
- const { loadPluginConfigWithMeta } = await import("./index-st47knj6.js");
230
+ const { KnowledgeConfigSchema } = await import("./schema-cpc92vq0.js");
231
+ const { loadPluginConfigWithMeta } = await import("./index-ch293kd3.js");
232
232
  const { config: loadedConfig } = loadPluginConfigWithMeta(directory);
233
233
  policyConfig = KnowledgeConfigSchema.parse(loadedConfig.knowledge ?? {});
234
234
  } catch {
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  captureWorkspaceSnapshotAsync,
4
4
  changedFilesSinceSnapshotAsync
5
- } from "./index-p0r5fn7y.js";
5
+ } from "./index-251vrmge.js";
6
6
  import {
7
7
  removeWorktreeProvisioningOwner
8
- } from "./index-x8cvbkjs.js";
8
+ } from "./index-9wv6a3jx.js";
9
9
  import {
10
10
  SOURCE_WORKTREE_GONE_STAGE,
11
11
  ensureTaskGateRequirementsReceiptForSettledTransition,
@@ -14,16 +14,16 @@ import {
14
14
  reconcileLandedMerge,
15
15
  withTaskEvidenceTransaction,
16
16
  writeWorkflowWalFile
17
- } from "./index-c0eyq4rp.js";
17
+ } from "./index-xn16akay.js";
18
18
  import {
19
19
  validateSwarmPath
20
- } from "./index-4kwxpnf8.js";
20
+ } from "./index-sahf5yz3.js";
21
21
  import {
22
22
  appendCoreEventSync
23
- } from "./index-hgphhnrp.js";
23
+ } from "./index-qd619x3r.js";
24
24
  import {
25
25
  tryAcquireLock
26
- } from "./index-sxe3t040.js";
26
+ } from "./index-2w0beg3s.js";
27
27
  import {
28
28
  canonicalRootKeyFresh
29
29
  } from "./index-7qefgq4j.js";
@@ -489,7 +489,7 @@ async function cleanupRecoveredWorktree(directory, descriptor) {
489
489
  awaitingMergeByCallID,
490
490
  cleanupStandardWorktreeForCallId,
491
491
  standardWorktreeByCallID
492
- } = await import("./worktree-isolation-sa1tbqff.js");
492
+ } = await import("./worktree-isolation-jwxtrh3z.js");
493
493
  standardWorktreeByCallID.delete(descriptor.callID);
494
494
  if (hasResidue)
495
495
  awaitingMergeByCallID.set(descriptor.callID, {
@@ -613,7 +613,7 @@ async function recoverCoderSettlement(directory, taskId) {
613
613
  awaitingMergeByCallID,
614
614
  finishStandardWorktreeDispatch,
615
615
  standardWorktreeByCallID
616
- } = await import("./worktree-isolation-sa1tbqff.js");
616
+ } = await import("./worktree-isolation-jwxtrh3z.js");
617
617
  const descriptor = wal.worktree;
618
618
  const reconstructedDispatch = {
619
619
  callID: descriptor.callID,
@@ -234,15 +234,15 @@ var SWARM_TEMP_GRAMMARS = [
234
234
  "src/plan/manager.ts:1832",
235
235
  "src/review/evidence.ts:175",
236
236
  "src/turbo/lean/evidence.ts:182",
237
- "src/summaries/manager.ts:122",
237
+ "src/summaries/manager.ts:123",
238
238
  "src/evidence/manager.ts:288",
239
239
  "src/evidence/manager.ts:456",
240
240
  "src/tools/sast-baseline.ts:199",
241
241
  "src/tools/repo-graph/storage.ts:524",
242
242
  "src/memory/reflection-service.ts (pre-#2035; migrated-to=src/memory/reflection-service.ts:atomicWrite)",
243
- "src/hooks/review-receipt.ts:608",
244
- "src/hooks/review-receipt.ts:674",
245
- "src/hooks/review-receipt.ts:812",
243
+ "src/hooks/review-receipt.ts:609",
244
+ "src/hooks/review-receipt.ts:675",
245
+ "src/hooks/review-receipt.ts:894",
246
246
  "src/knowledge/identity.ts:209",
247
247
  "src/evidence/phase-participation.ts (pre-#2035; migrated-to=src/evidence/phase-participation.ts:atomicWriteBytes)",
248
248
  "src/turbo/lean/integration.ts:428",
@@ -251,7 +251,7 @@ var SWARM_TEMP_GRAMMARS = [
251
251
  "src/services/synonym-map.ts:389",
252
252
  "src/services/skill-optimizer/store.ts:340",
253
253
  "src/services/skill-optimizer/store.ts:503",
254
- "src/turbo/epic/calibration.ts:202",
254
+ "src/turbo/epic/calibration.ts:234",
255
255
  "src/commands/archive-sqlite.ts:318",
256
256
  "src/memory/jsonl-migration.ts:161"
257
257
  ],
@@ -288,7 +288,10 @@ var SWARM_TEMP_GRAMMARS = [
288
288
  "src/background/pending-delegations.ts:1443",
289
289
  "src/background/delegation-health.ts:391",
290
290
  "src/tools/submit-phase-council-verdicts.ts:458",
291
- "src/summaries/store.ts (pre-#2035; migrated-to=src/summaries/store.ts:writeRawSidecar)"
291
+ "src/summaries/store.ts (pre-#2035; migrated-to=src/summaries/store.ts:writeRawSidecar)",
292
+ "src/retention/jsonl-cap.ts:213",
293
+ "src/services/skill-changelog.ts:58",
294
+ "src/turbo/epic/divergence-recorder.ts:108"
292
295
  ],
293
296
  note: "background lane/delegation stores keep bounded-retry rename semantics wired into their callers (#2034/#2276 delivery contracts); migration candidates for a follow-up but grammars registered"
294
297
  },
@@ -413,9 +416,11 @@ var SWARM_TEMP_GRAMMARS = [
413
416
  "src/tools/checkpoint.ts:195",
414
417
  "src/full-auto/state.ts:460",
415
418
  "src/context-map/persistence.ts:119",
416
- "src/context-map/capsule-persistence.ts:109",
417
- "src/test-impact/history-store.ts:225",
418
- "src/test-impact/history-store.ts:353",
419
+ "src/context-map/capsule-persistence.ts:111",
420
+ "src/test-impact/history-store.ts:297",
421
+ "src/test-impact/history-store.ts:302",
422
+ "src/test-impact/history-store.ts:429",
423
+ "src/test-impact/history-store.ts:435",
419
424
  "src/hooks/promotion-evidence-store.ts:112",
420
425
  "src/hooks/skill-usage-log.ts:1165",
421
426
  "src/hooks/skill-usage-log.ts:1675",
@@ -456,6 +461,9 @@ var WRITER_CLASSIFICATION = Object.freeze({
456
461
  "src/services/skill-improver.ts": "migrated",
457
462
  "src/summaries/store.ts": "migrated",
458
463
  "src/prm/trajectory-store.ts": "migrated",
464
+ "src/retention/jsonl-cap.ts": "registered-bespoke",
465
+ "src/services/skill-changelog.ts": "registered-bespoke",
466
+ "src/turbo/epic/divergence-recorder.ts": "registered-bespoke",
459
467
  "src/background/delegation-health.ts": "registered-bespoke",
460
468
  "src/background/lane-output-store.ts": "registered-bespoke",
461
469
  "src/background/pending-delegations.ts": "registered-bespoke",
@@ -9,7 +9,7 @@ import {
9
9
  readEvaluationRun,
10
10
  saveEvaluationRun,
11
11
  saveTaskSetSnapshot
12
- } from "./index-ft1tnx0e.js";
12
+ } from "./index-5bd84nxc.js";
13
13
  import {
14
14
  canonicalHash,
15
15
  computeCandidateInputContentHash,
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  computePlanStructureHash
4
- } from "./index-9ccxcjdm.js";
4
+ } from "./index-3f1tr4ha.js";
5
5
  import {
6
6
  appendCoreEventSync
7
- } from "./index-hgphhnrp.js";
7
+ } from "./index-qd619x3r.js";
8
8
  import {
9
9
  deleteCoordinationState,
10
10
  derivePlanId,
@@ -13,27 +13,27 @@ import {
13
13
  transitionCoordinationState,
14
14
  transitionCoordinationStateWithinTransaction,
15
15
  withCoordinationTransaction
16
- } from "./index-7pp8fz4j.js";
16
+ } from "./index-6d4dc99f.js";
17
17
  import {
18
18
  getProjectDb
19
- } from "./index-y3dtdn2f.js";
19
+ } from "./index-rk10x4zr.js";
20
20
  import {
21
21
  canonicalExistingFilesystemPath,
22
22
  legacyCanonicalExistingFilesystemPath
23
23
  } from "./index-ry16d01s.js";
24
24
  import {
25
25
  assertProjectRoot
26
- } from "./index-sxe3t040.js";
26
+ } from "./index-2w0beg3s.js";
27
27
  import {
28
28
  atomicWriteSwarmFile,
29
29
  atomicWriteSwarmFileSync
30
- } from "./index-19hjpqsy.js";
30
+ } from "./index-m21x1bkx.js";
31
31
  import {
32
32
  require_proper_lockfile
33
33
  } from "./index-7g4c7s5r.js";
34
34
  import {
35
35
  PlanSchema
36
- } from "./index-0a0jsbhg.js";
36
+ } from "./index-0jpv5z94.js";
37
37
  import {
38
38
  init_path_identity,
39
39
  unsafePathTextReason
@@ -5,22 +5,26 @@ import {
5
5
  import {
6
6
  effectiveRetrievalOutcomes,
7
7
  readAuthoritativeKnowledgeCounterRollups
8
- } from "./index-3nww2vnx.js";
8
+ } from "./index-tzq6t9wc.js";
9
9
  import {
10
10
  ALLOWED_SKILL_PATH_PREFIXES,
11
11
  validateSkillPath
12
- } from "./index-8nv3bc9h.js";
12
+ } from "./index-bwvbj3fp.js";
13
13
  import {
14
14
  computeOutcomeSignal,
15
15
  readKnowledge,
16
16
  resolveHiveKnowledgePath,
17
17
  resolveSwarmKnowledgePath,
18
18
  transactKnowledge
19
- } from "./index-22sannyk.js";
19
+ } from "./index-8cky7ksv.js";
20
+ import {
21
+ appendCappedJsonl,
22
+ resolveRetentionCap
23
+ } from "./index-vzm6zre7.js";
20
24
  import {
21
25
  atomicWriteFileAnyRoot,
22
26
  atomicWriteSwarmFile
23
- } from "./index-19hjpqsy.js";
27
+ } from "./index-m21x1bkx.js";
24
28
  import {
25
29
  canonicalRootKeyFresh
26
30
  } from "./index-7qefgq4j.js";
@@ -43,7 +47,7 @@ import {
43
47
 
44
48
  // src/services/skill-generator.ts
45
49
  import { existsSync as existsSync2, unlinkSync } from "fs";
46
- import { mkdir as mkdir4, readFile as readFile4, unlink, writeFile as writeFile3 } from "fs/promises";
50
+ import { mkdir as mkdir3, readFile as readFile4, unlink as unlink2, writeFile as writeFile3 } from "fs/promises";
47
51
  import * as path4 from "path";
48
52
 
49
53
  // src/config/bundled-skills.ts
@@ -406,34 +410,95 @@ init_knowledge_types();
406
410
  init_logger();
407
411
 
408
412
  // src/services/skill-changelog.ts
409
- init_logger();
410
- import { appendFile, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
413
+ import { readdir as readdir2, readFile as readFile2, rename as rename2, unlink, writeFile as writeFile2 } from "fs/promises";
411
414
  import * as path2 from "path";
412
- var MAX_CHANGELOG_ENTRIES_PER_SKILL = 200;
415
+ init_logger();
416
+ var MAX_SKILL_CHANGELOG_ENTRIES_PER_SKILL = 200;
417
+ var MAX_SKILL_CHANGELOG_GLOBAL_ENTRIES = 1e4;
413
418
  function resolveSkillChangelogPath(directory, slug) {
414
419
  if (slug.includes("..") || slug.includes("/") || slug.includes("\\")) {
415
420
  throw new Error(`Invalid skill slug: ${slug} \u2014 must not contain "..", "/" or "\\"`);
416
421
  }
417
422
  return path2.join(directory, ".swarm", "skill-changelogs", `${slug}.jsonl`);
418
423
  }
419
- async function appendSkillChangelog(directory, slug, entry) {
420
- const filePath = resolveSkillChangelogPath(directory, slug);
421
- const dirPath = path2.dirname(filePath);
422
- await mkdir2(dirPath, { recursive: true });
423
- await appendFile(filePath, `${JSON.stringify(entry)}
424
+ async function rewriteLinesAtomically(filePath, lines) {
425
+ const tmpPath = `${filePath}.tmp-${process.pid}-${Math.random().toString(36).slice(2, 8)}`;
426
+ await writeFile2(tmpPath, `${lines.join(`
427
+ `)}
424
428
  `, "utf-8");
425
429
  try {
426
- const content = await readFile2(filePath, "utf-8");
430
+ await rename2(tmpPath, filePath);
431
+ } catch (err) {
432
+ await unlink(tmpPath).catch(() => {});
433
+ throw err;
434
+ }
435
+ }
436
+ async function enforceGlobalEntryCap(dirPath) {
437
+ const cap = resolveRetentionCap("MAX_SKILL_CHANGELOG_GLOBAL_ENTRIES", MAX_SKILL_CHANGELOG_GLOBAL_ENTRIES);
438
+ let files;
439
+ try {
440
+ files = (await readdir2(dirPath)).filter((name) => name.endsWith(".jsonl"));
441
+ } catch {
442
+ return;
443
+ }
444
+ const linesByFile = new Map;
445
+ const stamped = [];
446
+ for (const file of files) {
447
+ let content;
448
+ try {
449
+ content = await readFile2(path2.join(dirPath, file), "utf-8");
450
+ } catch {
451
+ continue;
452
+ }
427
453
  const lines = content.split(`
428
454
  `).filter((line) => line.trim().length > 0);
429
- if (lines.length > MAX_CHANGELOG_ENTRIES_PER_SKILL) {
430
- const trimmed = lines.slice(lines.length - MAX_CHANGELOG_ENTRIES_PER_SKILL);
431
- await writeFile2(filePath, `${trimmed.join(`
432
- `)}
433
- `, "utf-8");
455
+ linesByFile.set(file, lines);
456
+ for (let i = 0;i < lines.length; i++) {
457
+ let timestamp = "";
458
+ try {
459
+ const parsed = JSON.parse(lines[i]);
460
+ if (typeof parsed.timestamp === "string")
461
+ timestamp = parsed.timestamp;
462
+ } catch {}
463
+ stamped.push({ file, index: i, timestamp });
434
464
  }
465
+ }
466
+ if (stamped.length <= cap)
467
+ return;
468
+ stamped.sort((a, b) => {
469
+ if (a.timestamp !== b.timestamp) {
470
+ return a.timestamp < b.timestamp ? -1 : 1;
471
+ }
472
+ if (a.file !== b.file)
473
+ return a.file < b.file ? -1 : 1;
474
+ return a.index - b.index;
475
+ });
476
+ const drop = new Set;
477
+ for (let i = 0;i < stamped.length - cap; i++) {
478
+ const item = stamped[i];
479
+ drop.add(`${item.file}\x00${item.index}`);
480
+ }
481
+ for (const [file, lines] of linesByFile) {
482
+ const kept = lines.filter((_, index) => !drop.has(`${file}\x00${index}`));
483
+ if (kept.length === lines.length)
484
+ continue;
485
+ const filePath = path2.join(dirPath, file);
486
+ if (kept.length === 0) {
487
+ await unlink(filePath).catch(() => {});
488
+ continue;
489
+ }
490
+ await rewriteLinesAtomically(filePath, kept);
491
+ }
492
+ }
493
+ async function appendSkillChangelog(directory, slug, entry) {
494
+ const filePath = resolveSkillChangelogPath(directory, slug);
495
+ await appendCappedJsonl(filePath, JSON.stringify(entry), {
496
+ maxEntries: resolveRetentionCap("MAX_SKILL_CHANGELOG_ENTRIES_PER_SKILL", MAX_SKILL_CHANGELOG_ENTRIES_PER_SKILL)
497
+ });
498
+ try {
499
+ await enforceGlobalEntryCap(path2.dirname(filePath));
435
500
  } catch (err) {
436
- warn(`[skill-changelog] FIFO trim failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
501
+ warn(`[skill-changelog] global ceiling enforcement failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`);
437
502
  }
438
503
  }
439
504
 
@@ -442,8 +507,8 @@ import { createHash } from "crypto";
442
507
  import { existsSync } from "fs";
443
508
  import {
444
509
  lstat as lstat2,
445
- mkdir as mkdir3,
446
- readdir as readdir2,
510
+ mkdir as mkdir2,
511
+ readdir as readdir3,
447
512
  readFile as readFile3,
448
513
  realpath,
449
514
  stat as stat2
@@ -559,7 +624,7 @@ async function loadEvalSet(directory, slug) {
559
624
  }
560
625
  let entries;
561
626
  try {
562
- entries = await readdir2(root);
627
+ entries = await readdir3(root);
563
628
  } catch (err) {
564
629
  return {
565
630
  status: "invalid",
@@ -760,7 +825,7 @@ async function evaluateSkillChange(req) {
760
825
  };
761
826
  }
762
827
  async function atomicWrite(filePath, content) {
763
- await mkdir3(path3.dirname(filePath), { recursive: true });
828
+ await mkdir2(path3.dirname(filePath), { recursive: true });
764
829
  await atomicWriteSwarmFile(filePath, content);
765
830
  }
766
831
  async function appendRejectedSkillEdit(req, evaluation) {
@@ -871,7 +936,7 @@ async function writeEvalStub(directory, slug, cases) {
871
936
  return { written: false, path: stubPath, reason: "no directive fields" };
872
937
  }
873
938
  try {
874
- await mkdir4(path4.dirname(stubPath), { recursive: true });
939
+ await mkdir3(path4.dirname(stubPath), { recursive: true });
875
940
  await atomicWrite2(stubPath, `${JSON.stringify({ cases })}
876
941
  `);
877
942
  return { written: true, path: stubPath };
@@ -1106,7 +1171,7 @@ function escapeMarkdown(s) {
1106
1171
  return s.replace(/[\r\n]+/g, " ").slice(0, 280);
1107
1172
  }
1108
1173
  async function atomicWrite2(p, content) {
1109
- await mkdir4(path4.dirname(p), { recursive: true });
1174
+ await mkdir3(path4.dirname(p), { recursive: true });
1110
1175
  await atomicWriteFileAnyRoot(p, content);
1111
1176
  }
1112
1177
  async function generateSkills(req) {
@@ -1864,7 +1929,7 @@ async function retireSkill(directory, slug, reason) {
1864
1929
  retiredAt: new Date().toISOString(),
1865
1930
  reason: reason ?? "manual_retire"
1866
1931
  });
1867
- await mkdir4(markerDir, { recursive: true });
1932
+ await mkdir3(markerDir, { recursive: true });
1868
1933
  await writeFile3(markerPath, markerContent, "utf-8");
1869
1934
  let clearedLinks = [];
1870
1935
  try {
@@ -1954,13 +2019,13 @@ async function clearSkillLinks(directory, skillFilePath, slug, mode) {
1954
2019
  return cleared;
1955
2020
  }
1956
2021
  async function markSkillStale(skillDir, reason) {
1957
- await mkdir4(skillDir, { recursive: true });
2022
+ await mkdir3(skillDir, { recursive: true });
1958
2023
  await writeFile3(path4.join(skillDir, "stale.marker"), reason, "utf-8");
1959
2024
  }
1960
2025
  async function clearSkillStale(skillDir) {
1961
2026
  const markerPath = path4.join(skillDir, "stale.marker");
1962
2027
  try {
1963
- await unlink(markerPath);
2028
+ await unlink2(markerPath);
1964
2029
  } catch (err) {
1965
2030
  if (err instanceof Error && "code" in err && err.code === "ENOENT") {
1966
2031
  return;
@@ -1,10 +1,10 @@
1
1
  // @bun
2
2
  import {
3
3
  observeStoreHealth
4
- } from "./index-fkk7x6sy.js";
4
+ } from "./index-qd726agw.js";
5
5
  import {
6
6
  telemetry
7
- } from "./index-bks56jbg.js";
7
+ } from "./index-f6zgz02s.js";
8
8
  import {
9
9
  init_logger,
10
10
  warn
@@ -1,12 +1,12 @@
1
1
  // @bun
2
2
  import {
3
3
  atomicWriteSwarmFile
4
- } from "./index-19hjpqsy.js";
4
+ } from "./index-m21x1bkx.js";
5
5
  import {
6
6
  pseudonymousRef,
7
7
  resolveLineageSalt,
8
8
  telemetry
9
- } from "./index-bks56jbg.js";
9
+ } from "./index-f6zgz02s.js";
10
10
  import {
11
11
  canonicalRootKeyFresh
12
12
  } from "./index-7qefgq4j.js";
@@ -2,15 +2,19 @@
2
2
  import {
3
3
  cohortConfigFingerprint
4
4
  } from "./index-rtry5xyf.js";
5
+ import {
6
+ appendCappedJsonl,
7
+ resolveRetentionCap
8
+ } from "./index-vzm6zre7.js";
5
9
  import {
6
10
  isLinked,
7
11
  readLinkPointer,
8
12
  resolveKnowledgeStoreDir,
9
13
  resolveLinkDir
10
- } from "./index-14z9en94.js";
14
+ } from "./index-t8tw1bhs.js";
11
15
 
12
16
  // src/knowledge/curation-policy.ts
13
- import { appendFile, mkdir as mkdir2, readFile as readFile2 } from "fs/promises";
17
+ import { readFile as readFile2 } from "fs/promises";
14
18
  import * as path2 from "path";
15
19
 
16
20
  // src/knowledge/worktree-identity.ts
@@ -85,6 +89,7 @@ async function resolveWorktreeId(directory) {
85
89
 
86
90
  // src/knowledge/curation-policy.ts
87
91
  var DEFAULT_QUORUM = { minCohortEvidence: 3 };
92
+ var MAX_CURATION_PROPOSALS = 200;
88
93
  async function authorizeCuration(input, context, quorum = DEFAULT_QUORUM) {
89
94
  const { directory, action, entryId } = input;
90
95
  const proposal = {
@@ -99,9 +104,9 @@ async function authorizeCuration(input, context, quorum = DEFAULT_QUORUM) {
99
104
  queueMicrotask(async () => {
100
105
  try {
101
106
  const storeDir = _internals2.resolveKnowledgeStoreDir(directory);
102
- await mkdir2(storeDir, { recursive: true });
103
- await appendFile(path2.join(storeDir, "curation-proposals.jsonl"), `${JSON.stringify(p)}
104
- `, "utf-8");
107
+ await appendCappedJsonl(path2.join(storeDir, "curation-proposals.jsonl"), JSON.stringify(p), {
108
+ maxEntries: resolveRetentionCap("MAX_CURATION_PROPOSALS", MAX_CURATION_PROPOSALS)
109
+ });
105
110
  } catch {}
106
111
  });
107
112
  };
@@ -241,4 +246,4 @@ var _internals2 = {
241
246
  resolveKnowledgeStoreDir
242
247
  };
243
248
 
244
- export { authorizeCuration, buildConfigFingerprintInput, readCohortConfigFingerprint, _internals2 as _internals };
249
+ export { MAX_CURATION_PROPOSALS, authorizeCuration, buildConfigFingerprintInput, readCohortConfigFingerprint, _internals2 as _internals };
@@ -7,7 +7,7 @@ import {
7
7
  } from "./index-n4fzmqz8.js";
8
8
  import {
9
9
  atomicWriteSwarmFileSync
10
- } from "./index-19hjpqsy.js";
10
+ } from "./index-m21x1bkx.js";
11
11
  import {
12
12
  canonicalRootKeyFresh,
13
13
  lexicalRootAliasKey
@@ -7,7 +7,7 @@ import {
7
7
  readCachedTextFile,
8
8
  wasObservedToExist,
9
9
  wasRecentlyWrittenByThisProcess
10
- } from "./index-19hjpqsy.js";
10
+ } from "./index-m21x1bkx.js";
11
11
  import {
12
12
  SwarmError
13
13
  } from "./index-ee6ydtfe.js";
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  atomicWriteFile
4
- } from "./index-sxe3t040.js";
4
+ } from "./index-2w0beg3s.js";
5
5
  import {
6
6
  canonicalRootKeyFresh
7
7
  } from "./index-7qefgq4j.js";