@sema-ai/core 1.275.1

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 (962) hide show
  1. package/CHANGELOG.md +5433 -0
  2. package/LICENSE +27 -0
  3. package/NOTICE.md +30 -0
  4. package/README.md +1040 -0
  5. package/dist/agents/agent-definition.d.ts +10 -0
  6. package/dist/agents/agent-definition.d.ts.map +1 -0
  7. package/dist/agents/agent-definition.js +18 -0
  8. package/dist/agents/agent-definition.js.map +1 -0
  9. package/dist/agents/builtin-agents.d.ts +69 -0
  10. package/dist/agents/builtin-agents.d.ts.map +1 -0
  11. package/dist/agents/builtin-agents.js +177 -0
  12. package/dist/agents/builtin-agents.js.map +1 -0
  13. package/dist/agents/cascade.d.ts +101 -0
  14. package/dist/agents/cascade.d.ts.map +1 -0
  15. package/dist/agents/cascade.js +189 -0
  16. package/dist/agents/cascade.js.map +1 -0
  17. package/dist/agents/observer.d.ts +209 -0
  18. package/dist/agents/observer.d.ts.map +1 -0
  19. package/dist/agents/observer.js +495 -0
  20. package/dist/agents/observer.js.map +1 -0
  21. package/dist/agents/repair-loop.d.ts +236 -0
  22. package/dist/agents/repair-loop.d.ts.map +1 -0
  23. package/dist/agents/repair-loop.js +293 -0
  24. package/dist/agents/repair-loop.js.map +1 -0
  25. package/dist/agents/session-util.d.ts +8 -0
  26. package/dist/agents/session-util.d.ts.map +1 -0
  27. package/dist/agents/session-util.js +9 -0
  28. package/dist/agents/session-util.js.map +1 -0
  29. package/dist/agents/subagent-steps.d.ts +93 -0
  30. package/dist/agents/subagent-steps.d.ts.map +1 -0
  31. package/dist/agents/subagent-steps.js +206 -0
  32. package/dist/agents/subagent-steps.js.map +1 -0
  33. package/dist/agents/subagent.d.ts +441 -0
  34. package/dist/agents/subagent.d.ts.map +1 -0
  35. package/dist/agents/subagent.js +2492 -0
  36. package/dist/agents/subagent.js.map +1 -0
  37. package/dist/agents/suspend-guard.d.ts +35 -0
  38. package/dist/agents/suspend-guard.d.ts.map +1 -0
  39. package/dist/agents/suspend-guard.js +48 -0
  40. package/dist/agents/suspend-guard.js.map +1 -0
  41. package/dist/agents/teacher.d.ts +137 -0
  42. package/dist/agents/teacher.d.ts.map +1 -0
  43. package/dist/agents/teacher.js +575 -0
  44. package/dist/agents/teacher.js.map +1 -0
  45. package/dist/agents/team.d.ts +211 -0
  46. package/dist/agents/team.d.ts.map +1 -0
  47. package/dist/agents/team.js +293 -0
  48. package/dist/agents/team.js.map +1 -0
  49. package/dist/agents/tool-filter.d.ts +29 -0
  50. package/dist/agents/tool-filter.d.ts.map +1 -0
  51. package/dist/agents/tool-filter.js +50 -0
  52. package/dist/agents/tool-filter.js.map +1 -0
  53. package/dist/agents/verify.d.ts +177 -0
  54. package/dist/agents/verify.d.ts.map +1 -0
  55. package/dist/agents/verify.js +305 -0
  56. package/dist/agents/verify.js.map +1 -0
  57. package/dist/bench/metrics.d.ts +714 -0
  58. package/dist/bench/metrics.d.ts.map +1 -0
  59. package/dist/bench/metrics.js +618 -0
  60. package/dist/bench/metrics.js.map +1 -0
  61. package/dist/bin/sema-tb.d.ts +3 -0
  62. package/dist/bin/sema-tb.d.ts.map +1 -0
  63. package/dist/bin/sema-tb.js +516 -0
  64. package/dist/bin/sema-tb.js.map +1 -0
  65. package/dist/bin/tb-env.d.ts +13 -0
  66. package/dist/bin/tb-env.d.ts.map +1 -0
  67. package/dist/bin/tb-env.js +26 -0
  68. package/dist/bin/tb-env.js.map +1 -0
  69. package/dist/brain/anthropic.d.ts +46 -0
  70. package/dist/brain/anthropic.d.ts.map +1 -0
  71. package/dist/brain/anthropic.js +830 -0
  72. package/dist/brain/anthropic.js.map +1 -0
  73. package/dist/brain/circuit-breaker.d.ts +46 -0
  74. package/dist/brain/circuit-breaker.d.ts.map +1 -0
  75. package/dist/brain/circuit-breaker.js +173 -0
  76. package/dist/brain/circuit-breaker.js.map +1 -0
  77. package/dist/brain/degrading.d.ts +98 -0
  78. package/dist/brain/degrading.d.ts.map +1 -0
  79. package/dist/brain/degrading.js +249 -0
  80. package/dist/brain/degrading.js.map +1 -0
  81. package/dist/brain/errors.d.ts +31 -0
  82. package/dist/brain/errors.d.ts.map +1 -0
  83. package/dist/brain/errors.js +58 -0
  84. package/dist/brain/errors.js.map +1 -0
  85. package/dist/brain/failover.d.ts +18 -0
  86. package/dist/brain/failover.d.ts.map +1 -0
  87. package/dist/brain/failover.js +118 -0
  88. package/dist/brain/failover.js.map +1 -0
  89. package/dist/brain/model-presets.d.ts +36 -0
  90. package/dist/brain/model-presets.d.ts.map +1 -0
  91. package/dist/brain/model-presets.js +54 -0
  92. package/dist/brain/model-presets.js.map +1 -0
  93. package/dist/brain/openai.d.ts +43 -0
  94. package/dist/brain/openai.d.ts.map +1 -0
  95. package/dist/brain/openai.js +784 -0
  96. package/dist/brain/openai.js.map +1 -0
  97. package/dist/brain/reasoning.d.ts +138 -0
  98. package/dist/brain/reasoning.d.ts.map +1 -0
  99. package/dist/brain/reasoning.js +146 -0
  100. package/dist/brain/reasoning.js.map +1 -0
  101. package/dist/brain/repetition.d.ts +60 -0
  102. package/dist/brain/repetition.d.ts.map +1 -0
  103. package/dist/brain/repetition.js +121 -0
  104. package/dist/brain/repetition.js.map +1 -0
  105. package/dist/brain/request-params.d.ts +29 -0
  106. package/dist/brain/request-params.d.ts.map +1 -0
  107. package/dist/brain/request-params.js +78 -0
  108. package/dist/brain/request-params.js.map +1 -0
  109. package/dist/brain/retry.d.ts +18 -0
  110. package/dist/brain/retry.d.ts.map +1 -0
  111. package/dist/brain/retry.js +42 -0
  112. package/dist/brain/retry.js.map +1 -0
  113. package/dist/brain/routing.d.ts +19 -0
  114. package/dist/brain/routing.d.ts.map +1 -0
  115. package/dist/brain/routing.js +44 -0
  116. package/dist/brain/routing.js.map +1 -0
  117. package/dist/brain/status-sink.d.ts +46 -0
  118. package/dist/brain/status-sink.d.ts.map +1 -0
  119. package/dist/brain/status-sink.js +36 -0
  120. package/dist/brain/status-sink.js.map +1 -0
  121. package/dist/brain/stream-engine.d.ts +85 -0
  122. package/dist/brain/stream-engine.d.ts.map +1 -0
  123. package/dist/brain/stream-engine.js +391 -0
  124. package/dist/brain/stream-engine.js.map +1 -0
  125. package/dist/brain/timeout.d.ts +44 -0
  126. package/dist/brain/timeout.d.ts.map +1 -0
  127. package/dist/brain/timeout.js +41 -0
  128. package/dist/brain/timeout.js.map +1 -0
  129. package/dist/brain/tool-call-repair.d.ts +15 -0
  130. package/dist/brain/tool-call-repair.d.ts.map +1 -0
  131. package/dist/brain/tool-call-repair.js +67 -0
  132. package/dist/brain/tool-call-repair.js.map +1 -0
  133. package/dist/brain/walltime.d.ts +14 -0
  134. package/dist/brain/walltime.d.ts.map +1 -0
  135. package/dist/brain/walltime.js +14 -0
  136. package/dist/brain/walltime.js.map +1 -0
  137. package/dist/core/arg-summary.d.ts +19 -0
  138. package/dist/core/arg-summary.d.ts.map +1 -0
  139. package/dist/core/arg-summary.js +96 -0
  140. package/dist/core/arg-summary.js.map +1 -0
  141. package/dist/core/ask-question.d.ts +113 -0
  142. package/dist/core/ask-question.d.ts.map +1 -0
  143. package/dist/core/ask-question.js +246 -0
  144. package/dist/core/ask-question.js.map +1 -0
  145. package/dist/core/auto-compaction.d.ts +341 -0
  146. package/dist/core/auto-compaction.d.ts.map +1 -0
  147. package/dist/core/auto-compaction.js +495 -0
  148. package/dist/core/auto-compaction.js.map +1 -0
  149. package/dist/core/auto-promote.d.ts +126 -0
  150. package/dist/core/auto-promote.d.ts.map +1 -0
  151. package/dist/core/auto-promote.js +171 -0
  152. package/dist/core/auto-promote.js.map +1 -0
  153. package/dist/core/background-shell.d.ts +128 -0
  154. package/dist/core/background-shell.d.ts.map +1 -0
  155. package/dist/core/background-shell.js +42 -0
  156. package/dist/core/background-shell.js.map +1 -0
  157. package/dist/core/cache-break-detector.d.ts +63 -0
  158. package/dist/core/cache-break-detector.d.ts.map +1 -0
  159. package/dist/core/cache-break-detector.js +0 -0
  160. package/dist/core/cache-break-detector.js.map +1 -0
  161. package/dist/core/canonical-json.d.ts +45 -0
  162. package/dist/core/canonical-json.d.ts.map +1 -0
  163. package/dist/core/canonical-json.js +132 -0
  164. package/dist/core/canonical-json.js.map +1 -0
  165. package/dist/core/checkpoint-store.d.ts +1101 -0
  166. package/dist/core/checkpoint-store.d.ts.map +1 -0
  167. package/dist/core/checkpoint-store.js +514 -0
  168. package/dist/core/checkpoint-store.js.map +1 -0
  169. package/dist/core/consolidate-scope.d.ts +94 -0
  170. package/dist/core/consolidate-scope.d.ts.map +1 -0
  171. package/dist/core/consolidate-scope.js +158 -0
  172. package/dist/core/consolidate-scope.js.map +1 -0
  173. package/dist/core/context-edit.d.ts +82 -0
  174. package/dist/core/context-edit.d.ts.map +1 -0
  175. package/dist/core/context-edit.js +149 -0
  176. package/dist/core/context-edit.js.map +1 -0
  177. package/dist/core/context-guard.d.ts +43 -0
  178. package/dist/core/context-guard.d.ts.map +1 -0
  179. package/dist/core/context-guard.js +171 -0
  180. package/dist/core/context-guard.js.map +1 -0
  181. package/dist/core/dynamic-recall.d.ts +100 -0
  182. package/dist/core/dynamic-recall.d.ts.map +1 -0
  183. package/dist/core/dynamic-recall.js +108 -0
  184. package/dist/core/dynamic-recall.js.map +1 -0
  185. package/dist/core/exec-gate.d.ts +74 -0
  186. package/dist/core/exec-gate.d.ts.map +1 -0
  187. package/dist/core/exec-gate.js +143 -0
  188. package/dist/core/exec-gate.js.map +1 -0
  189. package/dist/core/exec-output-tail.d.ts +37 -0
  190. package/dist/core/exec-output-tail.d.ts.map +1 -0
  191. package/dist/core/exec-output-tail.js +63 -0
  192. package/dist/core/exec-output-tail.js.map +1 -0
  193. package/dist/core/file-snapshot-store.d.ts +137 -0
  194. package/dist/core/file-snapshot-store.d.ts.map +1 -0
  195. package/dist/core/file-snapshot-store.js +319 -0
  196. package/dist/core/file-snapshot-store.js.map +1 -0
  197. package/dist/core/git-worktree-env.d.ts +41 -0
  198. package/dist/core/git-worktree-env.d.ts.map +1 -0
  199. package/dist/core/git-worktree-env.js +64 -0
  200. package/dist/core/git-worktree-env.js.map +1 -0
  201. package/dist/core/hooks.d.ts +372 -0
  202. package/dist/core/hooks.d.ts.map +1 -0
  203. package/dist/core/hooks.js +269 -0
  204. package/dist/core/hooks.js.map +1 -0
  205. package/dist/core/lsp-diagnostics.d.ts +74 -0
  206. package/dist/core/lsp-diagnostics.d.ts.map +1 -0
  207. package/dist/core/lsp-diagnostics.js +125 -0
  208. package/dist/core/lsp-diagnostics.js.map +1 -0
  209. package/dist/core/lsp-protocol.d.ts +28 -0
  210. package/dist/core/lsp-protocol.d.ts.map +1 -0
  211. package/dist/core/lsp-protocol.js +179 -0
  212. package/dist/core/lsp-protocol.js.map +1 -0
  213. package/dist/core/lsp-session.d.ts +56 -0
  214. package/dist/core/lsp-session.d.ts.map +1 -0
  215. package/dist/core/lsp-session.js +185 -0
  216. package/dist/core/lsp-session.js.map +1 -0
  217. package/dist/core/lsp.d.ts +132 -0
  218. package/dist/core/lsp.d.ts.map +1 -0
  219. package/dist/core/lsp.js +147 -0
  220. package/dist/core/lsp.js.map +1 -0
  221. package/dist/core/mcp.d.ts +294 -0
  222. package/dist/core/mcp.d.ts.map +1 -0
  223. package/dist/core/mcp.js +992 -0
  224. package/dist/core/mcp.js.map +1 -0
  225. package/dist/core/media-byte-cap.d.ts +34 -0
  226. package/dist/core/media-byte-cap.d.ts.map +1 -0
  227. package/dist/core/media-byte-cap.js +76 -0
  228. package/dist/core/media-byte-cap.js.map +1 -0
  229. package/dist/core/memory-engine/data-plane.d.ts +103 -0
  230. package/dist/core/memory-engine/data-plane.d.ts.map +1 -0
  231. package/dist/core/memory-engine/data-plane.js +272 -0
  232. package/dist/core/memory-engine/data-plane.js.map +1 -0
  233. package/dist/core/memory-engine/dual-root.d.ts +40 -0
  234. package/dist/core/memory-engine/dual-root.d.ts.map +1 -0
  235. package/dist/core/memory-engine/dual-root.js +95 -0
  236. package/dist/core/memory-engine/dual-root.js.map +1 -0
  237. package/dist/core/memory-engine/engine.d.ts +161 -0
  238. package/dist/core/memory-engine/engine.d.ts.map +1 -0
  239. package/dist/core/memory-engine/engine.js +1110 -0
  240. package/dist/core/memory-engine/engine.js.map +1 -0
  241. package/dist/core/memory-engine/file-backend.d.ts +162 -0
  242. package/dist/core/memory-engine/file-backend.d.ts.map +1 -0
  243. package/dist/core/memory-engine/file-backend.js +948 -0
  244. package/dist/core/memory-engine/file-backend.js.map +1 -0
  245. package/dist/core/memory-engine/frontmatter.d.ts +24 -0
  246. package/dist/core/memory-engine/frontmatter.d.ts.map +1 -0
  247. package/dist/core/memory-engine/frontmatter.js +135 -0
  248. package/dist/core/memory-engine/frontmatter.js.map +1 -0
  249. package/dist/core/memory-engine/index.d.ts +13 -0
  250. package/dist/core/memory-engine/index.d.ts.map +1 -0
  251. package/dist/core/memory-engine/index.js +28 -0
  252. package/dist/core/memory-engine/index.js.map +1 -0
  253. package/dist/core/memory-engine/layout.d.ts +123 -0
  254. package/dist/core/memory-engine/layout.d.ts.map +1 -0
  255. package/dist/core/memory-engine/layout.js +643 -0
  256. package/dist/core/memory-engine/layout.js.map +1 -0
  257. package/dist/core/memory-engine/memory-backend-contract.d.ts +22 -0
  258. package/dist/core/memory-engine/memory-backend-contract.d.ts.map +1 -0
  259. package/dist/core/memory-engine/memory-backend-contract.js +271 -0
  260. package/dist/core/memory-engine/memory-backend-contract.js.map +1 -0
  261. package/dist/core/memory-engine/migrate.d.ts +17 -0
  262. package/dist/core/memory-engine/migrate.d.ts.map +1 -0
  263. package/dist/core/memory-engine/migrate.js +35 -0
  264. package/dist/core/memory-engine/migrate.js.map +1 -0
  265. package/dist/core/memory-engine/scan.d.ts +20 -0
  266. package/dist/core/memory-engine/scan.d.ts.map +1 -0
  267. package/dist/core/memory-engine/scan.js +84 -0
  268. package/dist/core/memory-engine/scan.js.map +1 -0
  269. package/dist/core/memory-engine/scope-contract.d.ts +104 -0
  270. package/dist/core/memory-engine/scope-contract.d.ts.map +1 -0
  271. package/dist/core/memory-engine/scope-contract.js +288 -0
  272. package/dist/core/memory-engine/scope-contract.js.map +1 -0
  273. package/dist/core/memory-engine/sync-client.d.ts +100 -0
  274. package/dist/core/memory-engine/sync-client.d.ts.map +1 -0
  275. package/dist/core/memory-engine/sync-client.js +328 -0
  276. package/dist/core/memory-engine/sync-client.js.map +1 -0
  277. package/dist/core/memory-engine/sync.d.ts +97 -0
  278. package/dist/core/memory-engine/sync.d.ts.map +1 -0
  279. package/dist/core/memory-engine/sync.js +91 -0
  280. package/dist/core/memory-engine/sync.js.map +1 -0
  281. package/dist/core/memory-engine/types.d.ts +279 -0
  282. package/dist/core/memory-engine/types.d.ts.map +1 -0
  283. package/dist/core/memory-engine/types.js +9 -0
  284. package/dist/core/memory-engine/types.js.map +1 -0
  285. package/dist/core/memory-recall.d.ts +261 -0
  286. package/dist/core/memory-recall.d.ts.map +1 -0
  287. package/dist/core/memory-recall.js +600 -0
  288. package/dist/core/memory-recall.js.map +1 -0
  289. package/dist/core/memory-vector.d.ts +24 -0
  290. package/dist/core/memory-vector.d.ts.map +1 -0
  291. package/dist/core/memory-vector.js +51 -0
  292. package/dist/core/memory-vector.js.map +1 -0
  293. package/dist/core/memory.d.ts +502 -0
  294. package/dist/core/memory.d.ts.map +1 -0
  295. package/dist/core/memory.js +881 -0
  296. package/dist/core/memory.js.map +1 -0
  297. package/dist/core/message-utils.d.ts +7 -0
  298. package/dist/core/message-utils.d.ts.map +1 -0
  299. package/dist/core/message-utils.js +10 -0
  300. package/dist/core/message-utils.js.map +1 -0
  301. package/dist/core/oracle-isolation.d.ts +85 -0
  302. package/dist/core/oracle-isolation.d.ts.map +1 -0
  303. package/dist/core/oracle-isolation.js +121 -0
  304. package/dist/core/oracle-isolation.js.map +1 -0
  305. package/dist/core/permission-rules.d.ts +102 -0
  306. package/dist/core/permission-rules.d.ts.map +1 -0
  307. package/dist/core/permission-rules.js +357 -0
  308. package/dist/core/permission-rules.js.map +1 -0
  309. package/dist/core/present-plan-tool.d.ts +28 -0
  310. package/dist/core/present-plan-tool.d.ts.map +1 -0
  311. package/dist/core/present-plan-tool.js +119 -0
  312. package/dist/core/present-plan-tool.js.map +1 -0
  313. package/dist/core/pricing.d.ts +48 -0
  314. package/dist/core/pricing.d.ts.map +1 -0
  315. package/dist/core/pricing.js +46 -0
  316. package/dist/core/pricing.js.map +1 -0
  317. package/dist/core/property-harness.d.ts +126 -0
  318. package/dist/core/property-harness.d.ts.map +1 -0
  319. package/dist/core/property-harness.js +192 -0
  320. package/dist/core/property-harness.js.map +1 -0
  321. package/dist/core/push-queue.d.ts +10 -0
  322. package/dist/core/push-queue.d.ts.map +1 -0
  323. package/dist/core/push-queue.js +42 -0
  324. package/dist/core/push-queue.js.map +1 -0
  325. package/dist/core/remote-env.d.ts +432 -0
  326. package/dist/core/remote-env.d.ts.map +1 -0
  327. package/dist/core/remote-env.js +77 -0
  328. package/dist/core/remote-env.js.map +1 -0
  329. package/dist/core/roles.d.ts +74 -0
  330. package/dist/core/roles.d.ts.map +1 -0
  331. package/dist/core/roles.js +272 -0
  332. package/dist/core/roles.js.map +1 -0
  333. package/dist/core/runner/active-skill-scope.d.ts +64 -0
  334. package/dist/core/runner/active-skill-scope.d.ts.map +1 -0
  335. package/dist/core/runner/active-skill-scope.js +197 -0
  336. package/dist/core/runner/active-skill-scope.js.map +1 -0
  337. package/dist/core/runner/assemble-result.d.ts +191 -0
  338. package/dist/core/runner/assemble-result.d.ts.map +1 -0
  339. package/dist/core/runner/assemble-result.js +250 -0
  340. package/dist/core/runner/assemble-result.js.map +1 -0
  341. package/dist/core/runner/call-cap.d.ts +130 -0
  342. package/dist/core/runner/call-cap.d.ts.map +1 -0
  343. package/dist/core/runner/call-cap.js +151 -0
  344. package/dist/core/runner/call-cap.js.map +1 -0
  345. package/dist/core/runner/grounding-signal.d.ts +12 -0
  346. package/dist/core/runner/grounding-signal.d.ts.map +1 -0
  347. package/dist/core/runner/grounding-signal.js +94 -0
  348. package/dist/core/runner/grounding-signal.js.map +1 -0
  349. package/dist/core/runner/image.d.ts +23 -0
  350. package/dist/core/runner/image.d.ts.map +1 -0
  351. package/dist/core/runner/image.js +151 -0
  352. package/dist/core/runner/image.js.map +1 -0
  353. package/dist/core/runner/memory-consolidation.d.ts +112 -0
  354. package/dist/core/runner/memory-consolidation.d.ts.map +1 -0
  355. package/dist/core/runner/memory-consolidation.js +372 -0
  356. package/dist/core/runner/memory-consolidation.js.map +1 -0
  357. package/dist/core/runner/prepare-task.d.ts +583 -0
  358. package/dist/core/runner/prepare-task.d.ts.map +1 -0
  359. package/dist/core/runner/prepare-task.js +3612 -0
  360. package/dist/core/runner/prepare-task.js.map +1 -0
  361. package/dist/core/runner/prompt-suggestions.d.ts +33 -0
  362. package/dist/core/runner/prompt-suggestions.d.ts.map +1 -0
  363. package/dist/core/runner/prompt-suggestions.js +116 -0
  364. package/dist/core/runner/prompt-suggestions.js.map +1 -0
  365. package/dist/core/runner/runtask.d.ts +274 -0
  366. package/dist/core/runner/runtask.d.ts.map +1 -0
  367. package/dist/core/runner/runtask.js +4606 -0
  368. package/dist/core/runner/runtask.js.map +1 -0
  369. package/dist/core/runner/session-rule-policy.d.ts +28 -0
  370. package/dist/core/runner/session-rule-policy.d.ts.map +1 -0
  371. package/dist/core/runner/session-rule-policy.js +110 -0
  372. package/dist/core/runner/session-rule-policy.js.map +1 -0
  373. package/dist/core/runner/strict-output-schema.d.ts +36 -0
  374. package/dist/core/runner/strict-output-schema.d.ts.map +1 -0
  375. package/dist/core/runner/strict-output-schema.js +365 -0
  376. package/dist/core/runner/strict-output-schema.js.map +1 -0
  377. package/dist/core/runner/synthetic-tools.d.ts +72 -0
  378. package/dist/core/runner/synthetic-tools.d.ts.map +1 -0
  379. package/dist/core/runner/synthetic-tools.js +203 -0
  380. package/dist/core/runner/synthetic-tools.js.map +1 -0
  381. package/dist/core/runner/tool-disclosure.d.ts +117 -0
  382. package/dist/core/runner/tool-disclosure.d.ts.map +1 -0
  383. package/dist/core/runner/tool-disclosure.js +0 -0
  384. package/dist/core/runner/tool-disclosure.js.map +1 -0
  385. package/dist/core/runner/turn-attachments.d.ts +381 -0
  386. package/dist/core/runner/turn-attachments.d.ts.map +1 -0
  387. package/dist/core/runner/turn-attachments.js +596 -0
  388. package/dist/core/runner/turn-attachments.js.map +1 -0
  389. package/dist/core/runner/usage-accounting.d.ts +35 -0
  390. package/dist/core/runner/usage-accounting.d.ts.map +1 -0
  391. package/dist/core/runner/usage-accounting.js +45 -0
  392. package/dist/core/runner/usage-accounting.js.map +1 -0
  393. package/dist/core/runtime.d.ts +9 -0
  394. package/dist/core/runtime.d.ts.map +1 -0
  395. package/dist/core/runtime.js +17 -0
  396. package/dist/core/runtime.js.map +1 -0
  397. package/dist/core/safety-axis-vocab.d.ts +33 -0
  398. package/dist/core/safety-axis-vocab.d.ts.map +1 -0
  399. package/dist/core/safety-axis-vocab.js +35 -0
  400. package/dist/core/safety-axis-vocab.js.map +1 -0
  401. package/dist/core/safety-merge-corpus.d.ts +48 -0
  402. package/dist/core/safety-merge-corpus.d.ts.map +1 -0
  403. package/dist/core/safety-merge-corpus.js +203 -0
  404. package/dist/core/safety-merge-corpus.js.map +1 -0
  405. package/dist/core/scheduler.d.ts +126 -0
  406. package/dist/core/scheduler.d.ts.map +1 -0
  407. package/dist/core/scheduler.js +54 -0
  408. package/dist/core/scheduler.js.map +1 -0
  409. package/dist/core/secret-env.d.ts +23 -0
  410. package/dist/core/secret-env.d.ts.map +1 -0
  411. package/dist/core/secret-env.js +35 -0
  412. package/dist/core/secret-env.js.map +1 -0
  413. package/dist/core/select-model.d.ts +26 -0
  414. package/dist/core/select-model.d.ts.map +1 -0
  415. package/dist/core/select-model.js +58 -0
  416. package/dist/core/select-model.js.map +1 -0
  417. package/dist/core/sensitive-path-policy.d.ts +24 -0
  418. package/dist/core/sensitive-path-policy.d.ts.map +1 -0
  419. package/dist/core/sensitive-path-policy.js +96 -0
  420. package/dist/core/sensitive-path-policy.js.map +1 -0
  421. package/dist/core/session-policy-store.d.ts +102 -0
  422. package/dist/core/session-policy-store.d.ts.map +1 -0
  423. package/dist/core/session-policy-store.js +177 -0
  424. package/dist/core/session-policy-store.js.map +1 -0
  425. package/dist/core/session-reconcile.d.ts +63 -0
  426. package/dist/core/session-reconcile.d.ts.map +1 -0
  427. package/dist/core/session-reconcile.js +71 -0
  428. package/dist/core/session-reconcile.js.map +1 -0
  429. package/dist/core/session-store.d.ts +99 -0
  430. package/dist/core/session-store.d.ts.map +1 -0
  431. package/dist/core/session-store.js +298 -0
  432. package/dist/core/session-store.js.map +1 -0
  433. package/dist/core/session.d.ts +144 -0
  434. package/dist/core/session.d.ts.map +1 -0
  435. package/dist/core/session.js +56 -0
  436. package/dist/core/session.js.map +1 -0
  437. package/dist/core/spec-contract.d.ts +147 -0
  438. package/dist/core/spec-contract.d.ts.map +1 -0
  439. package/dist/core/spec-contract.js +340 -0
  440. package/dist/core/spec-contract.js.map +1 -0
  441. package/dist/core/strategy-store.d.ts +50 -0
  442. package/dist/core/strategy-store.d.ts.map +1 -0
  443. package/dist/core/strategy-store.js +100 -0
  444. package/dist/core/strategy-store.js.map +1 -0
  445. package/dist/core/stub-env.d.ts +35 -0
  446. package/dist/core/stub-env.d.ts.map +1 -0
  447. package/dist/core/stub-env.js +69 -0
  448. package/dist/core/stub-env.js.map +1 -0
  449. package/dist/core/task-notification.d.ts +115 -0
  450. package/dist/core/task-notification.d.ts.map +1 -0
  451. package/dist/core/task-notification.js +247 -0
  452. package/dist/core/task-notification.js.map +1 -0
  453. package/dist/core/task-outcome.d.ts +80 -0
  454. package/dist/core/task-outcome.d.ts.map +1 -0
  455. package/dist/core/task-outcome.js +40 -0
  456. package/dist/core/task-outcome.js.map +1 -0
  457. package/dist/core/task-registry.d.ts +349 -0
  458. package/dist/core/task-registry.d.ts.map +1 -0
  459. package/dist/core/task-registry.js +1751 -0
  460. package/dist/core/task-registry.js.map +1 -0
  461. package/dist/core/tighten-task-spec.d.ts +27 -0
  462. package/dist/core/tighten-task-spec.d.ts.map +1 -0
  463. package/dist/core/tighten-task-spec.js +95 -0
  464. package/dist/core/tighten-task-spec.js.map +1 -0
  465. package/dist/core/tool-detach.d.ts +31 -0
  466. package/dist/core/tool-detach.d.ts.map +1 -0
  467. package/dist/core/tool-detach.js +62 -0
  468. package/dist/core/tool-detach.js.map +1 -0
  469. package/dist/core/tool-errors.d.ts +72 -0
  470. package/dist/core/tool-errors.d.ts.map +1 -0
  471. package/dist/core/tool-errors.js +194 -0
  472. package/dist/core/tool-errors.js.map +1 -0
  473. package/dist/core/tool-name-aliases.d.ts +5 -0
  474. package/dist/core/tool-name-aliases.d.ts.map +1 -0
  475. package/dist/core/tool-name-aliases.js +130 -0
  476. package/dist/core/tool-name-aliases.js.map +1 -0
  477. package/dist/core/tool-policy.d.ts +295 -0
  478. package/dist/core/tool-policy.d.ts.map +1 -0
  479. package/dist/core/tool-policy.js +567 -0
  480. package/dist/core/tool-policy.js.map +1 -0
  481. package/dist/core/tool-result-budget.d.ts +44 -0
  482. package/dist/core/tool-result-budget.d.ts.map +1 -0
  483. package/dist/core/tool-result-budget.js +140 -0
  484. package/dist/core/tool-result-budget.js.map +1 -0
  485. package/dist/core/tool-result-store.d.ts +136 -0
  486. package/dist/core/tool-result-store.d.ts.map +1 -0
  487. package/dist/core/tool-result-store.js +219 -0
  488. package/dist/core/tool-result-store.js.map +1 -0
  489. package/dist/core/tools.d.ts +14 -0
  490. package/dist/core/tools.d.ts.map +1 -0
  491. package/dist/core/tools.js +98 -0
  492. package/dist/core/tools.js.map +1 -0
  493. package/dist/core/trace.d.ts +340 -0
  494. package/dist/core/trace.d.ts.map +1 -0
  495. package/dist/core/trace.js +12 -0
  496. package/dist/core/trace.js.map +1 -0
  497. package/dist/core/types.d.ts +2828 -0
  498. package/dist/core/types.d.ts.map +1 -0
  499. package/dist/core/types.js +2 -0
  500. package/dist/core/types.js.map +1 -0
  501. package/dist/core/untrusted-egress.d.ts +32 -0
  502. package/dist/core/untrusted-egress.d.ts.map +1 -0
  503. package/dist/core/untrusted-egress.js +49 -0
  504. package/dist/core/untrusted-egress.js.map +1 -0
  505. package/dist/core/untrusted-text.d.ts +64 -0
  506. package/dist/core/untrusted-text.d.ts.map +1 -0
  507. package/dist/core/untrusted-text.js +119 -0
  508. package/dist/core/untrusted-text.js.map +1 -0
  509. package/dist/core/warm-resume.d.ts +23 -0
  510. package/dist/core/warm-resume.d.ts.map +1 -0
  511. package/dist/core/warm-resume.js +28 -0
  512. package/dist/core/warm-resume.js.map +1 -0
  513. package/dist/core/with-retry.d.ts +43 -0
  514. package/dist/core/with-retry.d.ts.map +1 -0
  515. package/dist/core/with-retry.js +59 -0
  516. package/dist/core/with-retry.js.map +1 -0
  517. package/dist/core/workflow-journal-store.d.ts +44 -0
  518. package/dist/core/workflow-journal-store.d.ts.map +1 -0
  519. package/dist/core/workflow-journal-store.js +47 -0
  520. package/dist/core/workflow-journal-store.js.map +1 -0
  521. package/dist/core/workflow-run-store-contract.d.ts +31 -0
  522. package/dist/core/workflow-run-store-contract.d.ts.map +1 -0
  523. package/dist/core/workflow-run-store-contract.js +191 -0
  524. package/dist/core/workflow-run-store-contract.js.map +1 -0
  525. package/dist/core/workflow-run-store.d.ts +149 -0
  526. package/dist/core/workflow-run-store.d.ts.map +1 -0
  527. package/dist/core/workflow-run-store.js +110 -0
  528. package/dist/core/workflow-run-store.js.map +1 -0
  529. package/dist/engine/compaction/compaction.d.ts +139 -0
  530. package/dist/engine/compaction/compaction.d.ts.map +1 -0
  531. package/dist/engine/compaction/compaction.js +1030 -0
  532. package/dist/engine/compaction/compaction.js.map +1 -0
  533. package/dist/engine/compaction/utils.d.ts +45 -0
  534. package/dist/engine/compaction/utils.d.ts.map +1 -0
  535. package/dist/engine/compaction/utils.js +203 -0
  536. package/dist/engine/compaction/utils.js.map +1 -0
  537. package/dist/engine/execution-env/kill-tree.d.ts +20 -0
  538. package/dist/engine/execution-env/kill-tree.d.ts.map +1 -0
  539. package/dist/engine/execution-env/kill-tree.js +183 -0
  540. package/dist/engine/execution-env/kill-tree.js.map +1 -0
  541. package/dist/engine/execution-env/node-execution-env.d.ts +133 -0
  542. package/dist/engine/execution-env/node-execution-env.d.ts.map +1 -0
  543. package/dist/engine/execution-env/node-execution-env.js +1031 -0
  544. package/dist/engine/execution-env/node-execution-env.js.map +1 -0
  545. package/dist/engine/harness/agent-harness.d.ts +174 -0
  546. package/dist/engine/harness/agent-harness.d.ts.map +1 -0
  547. package/dist/engine/harness/agent-harness.js +1053 -0
  548. package/dist/engine/harness/agent-harness.js.map +1 -0
  549. package/dist/engine/harness/messages.d.ts +17 -0
  550. package/dist/engine/harness/messages.d.ts.map +1 -0
  551. package/dist/engine/harness/messages.js +122 -0
  552. package/dist/engine/harness/messages.js.map +1 -0
  553. package/dist/engine/harness/types.d.ts +713 -0
  554. package/dist/engine/harness/types.d.ts.map +1 -0
  555. package/dist/engine/harness/types.js +100 -0
  556. package/dist/engine/harness/types.js.map +1 -0
  557. package/dist/engine/llm/diagnostics.d.ts +23 -0
  558. package/dist/engine/llm/diagnostics.d.ts.map +1 -0
  559. package/dist/engine/llm/diagnostics.js +32 -0
  560. package/dist/engine/llm/diagnostics.js.map +1 -0
  561. package/dist/engine/llm/event-stream.d.ts +25 -0
  562. package/dist/engine/llm/event-stream.d.ts.map +1 -0
  563. package/dist/engine/llm/event-stream.js +103 -0
  564. package/dist/engine/llm/event-stream.js.map +1 -0
  565. package/dist/engine/llm/index.d.ts +12 -0
  566. package/dist/engine/llm/index.d.ts.map +1 -0
  567. package/dist/engine/llm/index.js +12 -0
  568. package/dist/engine/llm/index.js.map +1 -0
  569. package/dist/engine/llm/types.d.ts +753 -0
  570. package/dist/engine/llm/types.d.ts.map +1 -0
  571. package/dist/engine/llm/types.js +2 -0
  572. package/dist/engine/llm/types.js.map +1 -0
  573. package/dist/engine/llm/validation.d.ts +8 -0
  574. package/dist/engine/llm/validation.d.ts.map +1 -0
  575. package/dist/engine/llm/validation.js +318 -0
  576. package/dist/engine/llm/validation.js.map +1 -0
  577. package/dist/engine/loop/agent-loop.d.ts +74 -0
  578. package/dist/engine/loop/agent-loop.d.ts.map +1 -0
  579. package/dist/engine/loop/agent-loop.js +1490 -0
  580. package/dist/engine/loop/agent-loop.js.map +1 -0
  581. package/dist/engine/loop/runtime-deps.d.ts +17 -0
  582. package/dist/engine/loop/runtime-deps.d.ts.map +1 -0
  583. package/dist/engine/loop/runtime-deps.js +21 -0
  584. package/dist/engine/loop/runtime-deps.js.map +1 -0
  585. package/dist/engine/loop/types.d.ts +609 -0
  586. package/dist/engine/loop/types.d.ts.map +1 -0
  587. package/dist/engine/loop/types.js +2 -0
  588. package/dist/engine/loop/types.js.map +1 -0
  589. package/dist/engine/lsp/frame-decoder.d.ts +16 -0
  590. package/dist/engine/lsp/frame-decoder.d.ts.map +1 -0
  591. package/dist/engine/lsp/frame-decoder.js +53 -0
  592. package/dist/engine/lsp/frame-decoder.js.map +1 -0
  593. package/dist/engine/lsp/node-lsp-manager.d.ts +105 -0
  594. package/dist/engine/lsp/node-lsp-manager.d.ts.map +1 -0
  595. package/dist/engine/lsp/node-lsp-manager.js +343 -0
  596. package/dist/engine/lsp/node-lsp-manager.js.map +1 -0
  597. package/dist/engine/lsp/stdio-lsp-transport.d.ts +37 -0
  598. package/dist/engine/lsp/stdio-lsp-transport.d.ts.map +1 -0
  599. package/dist/engine/lsp/stdio-lsp-transport.js +185 -0
  600. package/dist/engine/lsp/stdio-lsp-transport.js.map +1 -0
  601. package/dist/engine/session/import-validate.d.ts +44 -0
  602. package/dist/engine/session/import-validate.d.ts.map +1 -0
  603. package/dist/engine/session/import-validate.js +92 -0
  604. package/dist/engine/session/import-validate.js.map +1 -0
  605. package/dist/engine/session/memory-repo.d.ts +25 -0
  606. package/dist/engine/session/memory-repo.d.ts.map +1 -0
  607. package/dist/engine/session/memory-repo.js +59 -0
  608. package/dist/engine/session/memory-repo.js.map +1 -0
  609. package/dist/engine/session/memory-storage.d.ts +14 -0
  610. package/dist/engine/session/memory-storage.d.ts.map +1 -0
  611. package/dist/engine/session/memory-storage.js +17 -0
  612. package/dist/engine/session/memory-storage.js.map +1 -0
  613. package/dist/engine/session/repo-utils.d.ts +11 -0
  614. package/dist/engine/session/repo-utils.d.ts.map +1 -0
  615. package/dist/engine/session/repo-utils.js +40 -0
  616. package/dist/engine/session/repo-utils.js.map +1 -0
  617. package/dist/engine/session/session.d.ts +34 -0
  618. package/dist/engine/session/session.d.ts.map +1 -0
  619. package/dist/engine/session/session.js +227 -0
  620. package/dist/engine/session/session.js.map +1 -0
  621. package/dist/engine/session/storage-base.d.ts +38 -0
  622. package/dist/engine/session/storage-base.d.ts.map +1 -0
  623. package/dist/engine/session/storage-base.js +157 -0
  624. package/dist/engine/session/storage-base.js.map +1 -0
  625. package/dist/engine/session/timestamps.d.ts +3 -0
  626. package/dist/engine/session/timestamps.d.ts.map +1 -0
  627. package/dist/engine/session/timestamps.js +15 -0
  628. package/dist/engine/session/timestamps.js.map +1 -0
  629. package/dist/engine/session/uuid.d.ts +2 -0
  630. package/dist/engine/session/uuid.d.ts.map +1 -0
  631. package/dist/engine/session/uuid.js +50 -0
  632. package/dist/engine/session/uuid.js.map +1 -0
  633. package/dist/index.d.ts +160 -0
  634. package/dist/index.d.ts.map +1 -0
  635. package/dist/index.js +374 -0
  636. package/dist/index.js.map +1 -0
  637. package/dist/internal/harness.d.ts +26 -0
  638. package/dist/internal/harness.d.ts.map +1 -0
  639. package/dist/internal/harness.js +24 -0
  640. package/dist/internal/harness.js.map +1 -0
  641. package/dist/internal/llm.d.ts +9 -0
  642. package/dist/internal/llm.d.ts.map +1 -0
  643. package/dist/internal/llm.js +8 -0
  644. package/dist/internal/llm.js.map +1 -0
  645. package/dist/orchestration/builtin-workflows.d.ts +44 -0
  646. package/dist/orchestration/builtin-workflows.d.ts.map +1 -0
  647. package/dist/orchestration/builtin-workflows.js +165 -0
  648. package/dist/orchestration/builtin-workflows.js.map +1 -0
  649. package/dist/orchestration/dev-vm-script-runner.d.ts +24 -0
  650. package/dist/orchestration/dev-vm-script-runner.d.ts.map +1 -0
  651. package/dist/orchestration/dev-vm-script-runner.js +106 -0
  652. package/dist/orchestration/dev-vm-script-runner.js.map +1 -0
  653. package/dist/orchestration/goal.d.ts +97 -0
  654. package/dist/orchestration/goal.d.ts.map +1 -0
  655. package/dist/orchestration/goal.js +248 -0
  656. package/dist/orchestration/goal.js.map +1 -0
  657. package/dist/orchestration/run-spec.d.ts +63 -0
  658. package/dist/orchestration/run-spec.d.ts.map +1 -0
  659. package/dist/orchestration/run-spec.js +274 -0
  660. package/dist/orchestration/run-spec.js.map +1 -0
  661. package/dist/orchestration/run-workflow-tool.d.ts +187 -0
  662. package/dist/orchestration/run-workflow-tool.d.ts.map +1 -0
  663. package/dist/orchestration/run-workflow-tool.js +612 -0
  664. package/dist/orchestration/run-workflow-tool.js.map +1 -0
  665. package/dist/orchestration/workflow-governance.d.ts +70 -0
  666. package/dist/orchestration/workflow-governance.d.ts.map +1 -0
  667. package/dist/orchestration/workflow-governance.js +176 -0
  668. package/dist/orchestration/workflow-governance.js.map +1 -0
  669. package/dist/orchestration/workflow-meta.d.ts +41 -0
  670. package/dist/orchestration/workflow-meta.d.ts.map +1 -0
  671. package/dist/orchestration/workflow-meta.js +426 -0
  672. package/dist/orchestration/workflow-meta.js.map +1 -0
  673. package/dist/orchestration/workflow-observe.d.ts +77 -0
  674. package/dist/orchestration/workflow-observe.d.ts.map +1 -0
  675. package/dist/orchestration/workflow-observe.js +177 -0
  676. package/dist/orchestration/workflow-observe.js.map +1 -0
  677. package/dist/orchestration/workflow-primitives.d.ts +31 -0
  678. package/dist/orchestration/workflow-primitives.d.ts.map +1 -0
  679. package/dist/orchestration/workflow-primitives.js +104 -0
  680. package/dist/orchestration/workflow-primitives.js.map +1 -0
  681. package/dist/orchestration/workflow-sandbox-conformance.d.ts +34 -0
  682. package/dist/orchestration/workflow-sandbox-conformance.d.ts.map +1 -0
  683. package/dist/orchestration/workflow-sandbox-conformance.js +301 -0
  684. package/dist/orchestration/workflow-sandbox-conformance.js.map +1 -0
  685. package/dist/orchestration/workflow-script-runner.d.ts +127 -0
  686. package/dist/orchestration/workflow-script-runner.d.ts.map +1 -0
  687. package/dist/orchestration/workflow-script-runner.js +48 -0
  688. package/dist/orchestration/workflow-script-runner.js.map +1 -0
  689. package/dist/orchestration/workflow-script-store.d.ts +99 -0
  690. package/dist/orchestration/workflow-script-store.d.ts.map +1 -0
  691. package/dist/orchestration/workflow-script-store.js +133 -0
  692. package/dist/orchestration/workflow-script-store.js.map +1 -0
  693. package/dist/orchestration/workflow-size-guideline.d.ts +50 -0
  694. package/dist/orchestration/workflow-size-guideline.d.ts.map +1 -0
  695. package/dist/orchestration/workflow-size-guideline.js +78 -0
  696. package/dist/orchestration/workflow-size-guideline.js.map +1 -0
  697. package/dist/orchestration/workflow.d.ts +624 -0
  698. package/dist/orchestration/workflow.d.ts.map +1 -0
  699. package/dist/orchestration/workflow.js +1596 -0
  700. package/dist/orchestration/workflow.js.map +1 -0
  701. package/dist/prompts/default.d.ts +474 -0
  702. package/dist/prompts/default.d.ts.map +1 -0
  703. package/dist/prompts/default.js +676 -0
  704. package/dist/prompts/default.js.map +1 -0
  705. package/dist/prompts/supervisor.d.ts +60 -0
  706. package/dist/prompts/supervisor.d.ts.map +1 -0
  707. package/dist/prompts/supervisor.js +162 -0
  708. package/dist/prompts/supervisor.js.map +1 -0
  709. package/dist/scenarios/env.d.ts +41 -0
  710. package/dist/scenarios/env.d.ts.map +1 -0
  711. package/dist/scenarios/env.js +65 -0
  712. package/dist/scenarios/env.js.map +1 -0
  713. package/dist/scenarios/full-body.d.ts +47 -0
  714. package/dist/scenarios/full-body.d.ts.map +1 -0
  715. package/dist/scenarios/full-body.js +36 -0
  716. package/dist/scenarios/full-body.js.map +1 -0
  717. package/dist/scenarios/scenario-registry.d.ts +107 -0
  718. package/dist/scenarios/scenario-registry.d.ts.map +1 -0
  719. package/dist/scenarios/scenario-registry.js +192 -0
  720. package/dist/scenarios/scenario-registry.js.map +1 -0
  721. package/dist/scenarios/teacher-quickstart.d.ts +41 -0
  722. package/dist/scenarios/teacher-quickstart.d.ts.map +1 -0
  723. package/dist/scenarios/teacher-quickstart.js +32 -0
  724. package/dist/scenarios/teacher-quickstart.js.map +1 -0
  725. package/dist/server/http.d.ts +36 -0
  726. package/dist/server/http.d.ts.map +1 -0
  727. package/dist/server/http.js +144 -0
  728. package/dist/server/http.js.map +1 -0
  729. package/dist/stores/file/checkpoint-store.d.ts +62 -0
  730. package/dist/stores/file/checkpoint-store.d.ts.map +1 -0
  731. package/dist/stores/file/checkpoint-store.js +250 -0
  732. package/dist/stores/file/checkpoint-store.js.map +1 -0
  733. package/dist/stores/file/file-snapshot-store.d.ts +43 -0
  734. package/dist/stores/file/file-snapshot-store.d.ts.map +1 -0
  735. package/dist/stores/file/file-snapshot-store.js +374 -0
  736. package/dist/stores/file/file-snapshot-store.js.map +1 -0
  737. package/dist/stores/file/fs-atomic.d.ts +95 -0
  738. package/dist/stores/file/fs-atomic.d.ts.map +1 -0
  739. package/dist/stores/file/fs-atomic.js +415 -0
  740. package/dist/stores/file/fs-atomic.js.map +1 -0
  741. package/dist/stores/file/index.d.ts +98 -0
  742. package/dist/stores/file/index.d.ts.map +1 -0
  743. package/dist/stores/file/index.js +109 -0
  744. package/dist/stores/file/index.js.map +1 -0
  745. package/dist/stores/file/memory-store.d.ts +95 -0
  746. package/dist/stores/file/memory-store.d.ts.map +1 -0
  747. package/dist/stores/file/memory-store.js +393 -0
  748. package/dist/stores/file/memory-store.js.map +1 -0
  749. package/dist/stores/file/session-policy-store.d.ts +24 -0
  750. package/dist/stores/file/session-policy-store.d.ts.map +1 -0
  751. package/dist/stores/file/session-policy-store.js +123 -0
  752. package/dist/stores/file/session-policy-store.js.map +1 -0
  753. package/dist/stores/file/session-store.d.ts +34 -0
  754. package/dist/stores/file/session-store.d.ts.map +1 -0
  755. package/dist/stores/file/session-store.js +175 -0
  756. package/dist/stores/file/session-store.js.map +1 -0
  757. package/dist/stores/file/tool-result-store.d.ts +23 -0
  758. package/dist/stores/file/tool-result-store.d.ts.map +1 -0
  759. package/dist/stores/file/tool-result-store.js +61 -0
  760. package/dist/stores/file/tool-result-store.js.map +1 -0
  761. package/dist/stores/file/workflow-journal-store.d.ts +36 -0
  762. package/dist/stores/file/workflow-journal-store.d.ts.map +1 -0
  763. package/dist/stores/file/workflow-journal-store.js +157 -0
  764. package/dist/stores/file/workflow-journal-store.js.map +1 -0
  765. package/dist/stores/file/workflow-run-store.d.ts +58 -0
  766. package/dist/stores/file/workflow-run-store.d.ts.map +1 -0
  767. package/dist/stores/file/workflow-run-store.js +178 -0
  768. package/dist/stores/file/workflow-run-store.js.map +1 -0
  769. package/dist/stores/pg.d.ts +210 -0
  770. package/dist/stores/pg.d.ts.map +1 -0
  771. package/dist/stores/pg.js +652 -0
  772. package/dist/stores/pg.js.map +1 -0
  773. package/dist/tools/fs/encoding.d.ts +51 -0
  774. package/dist/tools/fs/encoding.d.ts.map +1 -0
  775. package/dist/tools/fs/encoding.js +74 -0
  776. package/dist/tools/fs/encoding.js.map +1 -0
  777. package/dist/tools/fs/gh-rate-limit.d.ts +19 -0
  778. package/dist/tools/fs/gh-rate-limit.d.ts.map +1 -0
  779. package/dist/tools/fs/gh-rate-limit.js +35 -0
  780. package/dist/tools/fs/gh-rate-limit.js.map +1 -0
  781. package/dist/tools/fs/index.d.ts +246 -0
  782. package/dist/tools/fs/index.d.ts.map +1 -0
  783. package/dist/tools/fs/index.js +2130 -0
  784. package/dist/tools/fs/index.js.map +1 -0
  785. package/dist/tools/fs/pdf.d.ts +106 -0
  786. package/dist/tools/fs/pdf.d.ts.map +1 -0
  787. package/dist/tools/fs/pdf.js +178 -0
  788. package/dist/tools/fs/pdf.js.map +1 -0
  789. package/dist/tools/fs/repo-map.d.ts +15 -0
  790. package/dist/tools/fs/repo-map.d.ts.map +1 -0
  791. package/dist/tools/fs/repo-map.js +251 -0
  792. package/dist/tools/fs/repo-map.js.map +1 -0
  793. package/dist/tools/fs/safety.d.ts +168 -0
  794. package/dist/tools/fs/safety.d.ts.map +1 -0
  795. package/dist/tools/fs/safety.js +479 -0
  796. package/dist/tools/fs/safety.js.map +1 -0
  797. package/dist/tools/fs/search.d.ts +118 -0
  798. package/dist/tools/fs/search.d.ts.map +1 -0
  799. package/dist/tools/fs/search.js +650 -0
  800. package/dist/tools/fs/search.js.map +1 -0
  801. package/dist/tools/gitea-issue.d.ts +39 -0
  802. package/dist/tools/gitea-issue.d.ts.map +1 -0
  803. package/dist/tools/gitea-issue.js +91 -0
  804. package/dist/tools/gitea-issue.js.map +1 -0
  805. package/dist/tools/monitor.d.ts +64 -0
  806. package/dist/tools/monitor.d.ts.map +1 -0
  807. package/dist/tools/monitor.js +135 -0
  808. package/dist/tools/monitor.js.map +1 -0
  809. package/dist/tools/scheduler-tools.d.ts +48 -0
  810. package/dist/tools/scheduler-tools.d.ts.map +1 -0
  811. package/dist/tools/scheduler-tools.js +449 -0
  812. package/dist/tools/scheduler-tools.js.map +1 -0
  813. package/dist/tools/sql-adapters.d.ts +32 -0
  814. package/dist/tools/sql-adapters.d.ts.map +1 -0
  815. package/dist/tools/sql-adapters.js +31 -0
  816. package/dist/tools/sql-adapters.js.map +1 -0
  817. package/dist/tools/sql.d.ts +36 -0
  818. package/dist/tools/sql.d.ts.map +1 -0
  819. package/dist/tools/sql.js +131 -0
  820. package/dist/tools/sql.js.map +1 -0
  821. package/dist/tools/task-list.d.ts +26 -0
  822. package/dist/tools/task-list.d.ts.map +1 -0
  823. package/dist/tools/task-list.js +352 -0
  824. package/dist/tools/task-list.js.map +1 -0
  825. package/dist/tools/todo.d.ts +11 -0
  826. package/dist/tools/todo.d.ts.map +1 -0
  827. package/dist/tools/todo.js +126 -0
  828. package/dist/tools/todo.js.map +1 -0
  829. package/dist/tools/web.d.ts +59 -0
  830. package/dist/tools/web.d.ts.map +1 -0
  831. package/dist/tools/web.js +607 -0
  832. package/dist/tools/web.js.map +1 -0
  833. package/dist/tools/worktree.d.ts +88 -0
  834. package/dist/tools/worktree.d.ts.map +1 -0
  835. package/dist/tools/worktree.js +434 -0
  836. package/dist/tools/worktree.js.map +1 -0
  837. package/docs/A1-ATTRIBUTION-ROUND1-2026-07-09.md +181 -0
  838. package/docs/AB-ORACLE-GATE-VERDICT-2026-07-10.md +100 -0
  839. package/docs/ANCHOR-GAP-INVENTORY-2026-07-09.md +143 -0
  840. package/docs/ARCHITECTURE.md +125 -0
  841. package/docs/BUGHUNT-2026-07-05-NIGHT.md +98 -0
  842. package/docs/BUILD.md +63 -0
  843. package/docs/CANCEL-ASYNC-ATTRIBUTION-2026-07-09.md +98 -0
  844. package/docs/CC-198-VS-201-DRIFT-2026-07-09.md +70 -0
  845. package/docs/CC-BASELINE-FAKE-ZERO-AUDIT-2026-07-09.md +51 -0
  846. package/docs/CC-DRIFT-198-206-AGENT-TYPES-2026-07-10.md +82 -0
  847. package/docs/CC-DRIFT-198-206-CHANGELOG-2026-07-10.md +82 -0
  848. package/docs/CC-DRIFT-198-206-REMINDERS-2026-07-10.md +96 -0
  849. package/docs/CC-DRIFT-198-206-ROADMAP-2026-07-10.md +110 -0
  850. package/docs/CC-DRIFT-198-206-TOOL-INVENTORY-2026-07-10.md +53 -0
  851. package/docs/CC-DRIFT-198-206-USAGE-CONSTANTS-2026-07-10.md +64 -0
  852. package/docs/CC-DRIFT-198-206-WORKFLOW-2026-07-10.md +83 -0
  853. package/docs/CC-PARITY-CHECKLIST.md +220 -0
  854. package/docs/CC-PARITY-DEEP-SWEEP-2026-07-07.md +149 -0
  855. package/docs/CC-SUBAGENT-PROMPT-STUDY-2026-07-09.md +219 -0
  856. package/docs/CC-TASK-REMINDER-CADENCE-STUDY-2026-07-09.md +396 -0
  857. package/docs/CC-TOOL-PARITY-SWEEP-2026-07.md +56 -0
  858. package/docs/CC-TOOL-PROMPT-DEEP-DIFF-2026-07-08.md +274 -0
  859. package/docs/CC-TOOLSURFACE-DEEP-DIVE-2026-07-07.md +197 -0
  860. package/docs/CC206-OBSERVER-ANCHORS-2026-07-11.md +463 -0
  861. package/docs/CC207-CORE-SWEEP-BACKLOG-2026-07-12.md +155 -0
  862. package/docs/CENTER-CONTROL-PLANE-SEAM.md +86 -0
  863. package/docs/CLEANUP-CONTRACT-ANCHOR-2026-07-09.md +83 -0
  864. package/docs/COLD-START-RSI-2026-07-09.md +72 -0
  865. package/docs/COMPACTION-LIVE-AUDIT-2026-07-09.md +114 -0
  866. package/docs/CONTEXT-lifecycle-extension-points-and-stop-attribution.md +71 -0
  867. package/docs/COREWARS-POLYGLOT-TRIAGE-2026-07-09.md +85 -0
  868. package/docs/DEADTARGET-OVERFULL-HBOX-2026-07-10.md +92 -0
  869. package/docs/DEADTARGET-PATH-TRACING-REVERSE-2026-07-10.md +87 -0
  870. package/docs/DEADTARGET-WINNING-AVG-COREWARS-2026-07-10.md +96 -0
  871. package/docs/DEEPSEEK-API-LIMITS-PROBE-2026-07-09.md +118 -0
  872. package/docs/DESIGN-140-MOCK-VERIFY-2026-07-11.md +79 -0
  873. package/docs/DESIGN-140-VERIFICATION-2026-07-11.md +43 -0
  874. package/docs/DESIGN-DRAFT-workflow-collab-2026-07-11.md +56 -0
  875. package/docs/DESIGN-ORACLE-GROUNDING-GATE-2026-07-10.md +167 -0
  876. package/docs/DESIGN-TFRAG-RECONCILE-SCAFFOLD-2026-07-09.md +102 -0
  877. package/docs/EXP-PA2-PE-DESIGN-2026-07-11.md +220 -0
  878. package/docs/EXT-DOGFOOD-2026-07-12.md +50 -0
  879. package/docs/FINAL-VERIFY-SURFACE-AUDIT-2026-07-09.md +44 -0
  880. package/docs/FRAG-RECON-INVESTIGATION-2026-07-09.md +183 -0
  881. package/docs/HANDOFF.md +121 -0
  882. package/docs/KNOWN-ISSUES.md +96 -0
  883. package/docs/LEGW-WINDOW-TAX-2026-07-10.md +82 -0
  884. package/docs/LIVE-PROBE-BATCH-2026-07-11.md +207 -0
  885. package/docs/M2-CERT-ATTRIBUTION-2026-07-10.md +61 -0
  886. package/docs/M25-LEG-VARIANCE-ATTRIBUTION-2026-07-10.md +81 -0
  887. package/docs/MAILMAN-TIMEOUT-ATTRIBUTION-2026-07-10.md +88 -0
  888. package/docs/MEMORY-BACKEND-DIALECT-NOTES.md +69 -0
  889. package/docs/MTEB-ESCAPE-HATCH-ATTRIBUTION-2026-07-09.md +57 -0
  890. package/docs/MTEB-LEADERBOARD-ATTRIBUTION-2026-07-10.md +134 -0
  891. package/docs/ORACLE-GATE-NEGATIVE-SAMPLE-2026-07-11.md +28 -0
  892. package/docs/PARITY-CONTEXT-TRANSACTIONS-2026-07-10.md +67 -0
  893. package/docs/PARITY-PROGRESS-MATRIX-2026-07-10.md +37 -0
  894. package/docs/PARITY-SPOT-AGENT-TYPES-2026-07-10.md +70 -0
  895. package/docs/PARITY-SPOT-REMINDERS-2026-07-10.md +144 -0
  896. package/docs/PARITY-SPOT-TOOL-INVENTORY-2026-07-10.md +61 -0
  897. package/docs/PARITY-SPOT-USAGE-CONSTANTS-2026-07-10.md +95 -0
  898. package/docs/PARITY-SPOT-WORKFLOW-2026-07-10.md +93 -0
  899. package/docs/PASSWORD-RECOVERY-PANEL-VERDICT-2026-07-10.md +62 -0
  900. package/docs/R8-R9-FINALIZE-COORDINATION-2026-07-09.md +124 -0
  901. package/docs/REPL-CODE-MODE-EVALUATION-2026-07-10.md +187 -0
  902. package/docs/REPORT-1249-TARGETED.md +48 -0
  903. package/docs/RESEARCH-3P-MEMORY-SWAP-2026-07-12.md +273 -0
  904. package/docs/ROADMAP.md +111 -0
  905. package/docs/RSI-CLOUD-DEPLOY-2026-07-06.md +289 -0
  906. package/docs/RSI-PROCESS-AI-COLDSTART-2026-07-11.md +68 -0
  907. package/docs/S18-THOROUGHNESS-AUDIT-2026-07-09.md +113 -0
  908. package/docs/SERVICE-INTEGRATION-GUIDE.md +298 -0
  909. package/docs/SUBAGENT-STREAM-RESILIENCE-PARITY-2026-07-10.md +118 -0
  910. package/docs/SWEBENCH-PRO-RECON-2026-07-11.md +31 -0
  911. package/docs/TB-EFFICIENCY-TELEMETRY-2026-07-08.md +114 -0
  912. package/docs/TB-FAILURE-AUTOPSY-2026-07-05-RERUN.md +67 -0
  913. package/docs/TB-FAIRNESS-AUDIT-2026-07-08.md +141 -0
  914. package/docs/TB-FULL-1257-2026-07-08.md +77 -0
  915. package/docs/TB-LEG-GAP-ATTRIBUTION-1261-1263-2026-07-11.md +154 -0
  916. package/docs/TB-REGRESSION-DAEMON-KILL-2026-07-08.md +58 -0
  917. package/docs/TB-RSI-CROSSCHECK-2026-07-06.md +68 -0
  918. package/docs/TB-RSI-LEDGER.md +30 -0
  919. package/docs/TB-STABLE-SET-2026-07-08.md +127 -0
  920. package/docs/TB21-RECON-2026-07-11.md +28 -0
  921. package/docs/TEST-DESIGN-BATCH-1-2-3.md +97 -0
  922. package/docs/THIRD-PARTY-INTEGRATION.md +45 -0
  923. package/docs/TOKEN-ESTIMATE-CALIBRATION-LIVE-2026-07-09.md +102 -0
  924. package/docs/audit-2026-06-10-/347/254/254/344/272/214/350/275/256-/347/251/272/347/231/275/345/214/272/344/270/216/345/277/230/346/216/245/347/272/277.md +147 -0
  925. package/docs/audit-2026-06-10-/350/256/241/347/256/227bug/346/211/253/346/217/217.md +163 -0
  926. package/docs/audit-2026-06-11-/344/277/256/345/244/215/345/244/215/345/256/241/344/270/216/345/233/236/345/275/222/344/270/223/346/211/253.md +95 -0
  927. package/docs/audit-2026-06-12-design71-P1/346/275/234/344/274/217/351/235/242/350/243/201/345/206/263/344/270/216/345/220/236/351/224/231/345/256/241/350/256/241.md +45 -0
  928. package/docs/audit-2026-06-12-/345/205/254/345/274/200/346/227/213/351/222/256/346/264/273/346/200/247/344/270/216vendored/346/255/273/350/267/257.md +63 -0
  929. package/docs/audit-2026-06-15/ADDENDUM-second-pass.md +88 -0
  930. package/docs/audit-2026-06-15/ARCHITECTURE-AND-ROADMAP.md +187 -0
  931. package/docs/audit-2026-06-15/DOC-CORRECTIONS.md +105 -0
  932. package/docs/audit-2026-06-15/INDEX.md +49 -0
  933. package/docs/audit-2026-06-15/ORCHESTRATION-STATUS.md +98 -0
  934. package/docs/audit-2026-06-15/PRODUCTION-ISSUES.md +189 -0
  935. package/docs/audit-2026-06-15/REFERENCES-literature.md +139 -0
  936. package/docs/audit-2026-06-15/VENDOR-REFACTOR-PLAN.md +96 -0
  937. package/docs/cc-probe-198/README.md +72 -0
  938. package/docs/cc-probe-198/STABILITY-AUDIT.md +118 -0
  939. package/docs/cc-probe-198/live-schema-monitor-worktree-2026-07-09.json +56 -0
  940. package/docs/cc-probe-198/mount-variants.json +536 -0
  941. package/docs/cc-probe-198/plan-mode-run.json +1 -0
  942. package/docs/cc-probe-198/probe-bash-bg.json +224 -0
  943. package/docs/cc-probe-198/probe-edit-mismatch.json +120 -0
  944. package/docs/cc-probe-198/probe-read-missing.json +62 -0
  945. package/docs/cc-probe-198/probe-search-empty.json +127 -0
  946. package/docs/cc-probe-198/probe-task-family.json +227 -0
  947. package/docs/cc-probe-198/probes.status +6 -0
  948. package/docs/cc-probe-198/raw-capture-interactive.json +948 -0
  949. package/docs/cc-probe-198/raw-capture-print.json +787 -0
  950. package/docs/cc-probe-198/raw-capture2-interactive.json +948 -0
  951. package/docs/cc-probe-198/raw-capture2-print.json +787 -0
  952. package/docs/cc-probe-198/system-prompt.txt +135 -0
  953. package/docs/cc-probe-198/tools-array.json +962 -0
  954. package/docs/durability-boundary.md +63 -0
  955. package/docs/fix-2026-06-10-/350/256/241/347/256/227bug/344/277/256/345/244/215-search/346/211/271.md +75 -0
  956. package/docs/fix-2026-06-11-/347/254/254/344/272/214/350/275/256-/344/277/256/345/244/215-search/346/211/271.md +62 -0
  957. package/docs/parity-sweep/REPORT-DYNAMIC.md +97 -0
  958. package/docs/parity-sweep/REPORT-STATIC-GGB.md +127 -0
  959. package/docs/parity-sweep/REPORT-STATIC-RWE.md +133 -0
  960. package/docs/vendor-history.md +385 -0
  961. package/docs/vendored-upstream-diff-2026-07.md +83 -0
  962. package/package.json +70 -0
@@ -0,0 +1,495 @@
1
+ import { DEFAULT_CHARS_PER_TOKEN, DEFAULT_COMPACTION_SETTINGS, compact, computeFileLists, estimateContextTokens, estimateTokens, prepareCompaction, shouldCompact, } from "../internal/harness.js";
2
+ import { EDIT_FRACTION } from "./context-edit.js";
3
+ import { brainToRuntime } from "./runtime.js";
4
+ /**
5
+ * Default summarization focus, applied when a task does not provide `compaction.instructions`.
6
+ * Addresses the common fidelity failure where summaries drop specific facts.
7
+ */
8
+ export const DEFAULT_COMPACTION_INSTRUCTIONS = "Preserve verbatim every code, identifier, name, number, file path, error message, credential " +
9
+ "reference, and explicit user instruction or decision mentioned anywhere in the conversation. " +
10
+ "When in doubt, keep the specific detail rather than generalizing it.";
11
+ // Fallback reserve fraction used ONLY when the configured reserve is pathological for the window.
12
+ const FALLBACK_RESERVE_FRACTION = 0.15;
13
+ /**
14
+ * SEMA-ONLY (trim-seam defense, no CC analogue) — stale-anchor freshness margin: a usage anchor is
15
+ * trusted only while the anchored estimate stays within `structural × margin + overhead` of the
16
+ * current message list. 2 covers the worst measured structural under-count (charsPerToken=3 vs a
17
+ * measured ~2.18 true ratio ⇒ ≤ ~1.4x) plus reasoning-block accounting slop, while still catching
18
+ * the live deception band (anchored estimates 2.9x–18x over the real context — docs/TOKEN-ESTIMATE-
19
+ * CALIBRATION-LIVE-2026-07-09.md §3/§4).
20
+ */
21
+ export const STALE_ANCHOR_STRUCTURAL_MARGIN = 2;
22
+ /**
23
+ * Repair compaction settings that are PATHOLOGICAL for the model's context window — without touching
24
+ * self-consistent explicit configuration (a deliberately large `reserveTokens` is a legitimate
25
+ * "compact early" knob, e.g. for long-run testing).
26
+ *
27
+ * DEFAULT_COMPACTION_SETTINGS (reserve 16384 / keepRecent 20000) are tuned for ≥100K windows; on a
28
+ * small window W they break in two compounding ways (found via LONGRUN-1's 12K declared window):
29
+ * 1. threshold = W - reserve ≤ 0 → `shouldCompact` fires at EVERY turn boundary;
30
+ * 2. keepRecent ≥ threshold → even a successful compaction leaves the kept tail at/over the
31
+ * threshold; worse, `findCutPoint` with keepRecent ≥ the whole history falls back to the
32
+ * EARLIEST valid cut point, summarizing a sliver of the head. Together: one real LLM summary
33
+ * call per boundary, forever (thrash + cost explosion).
34
+ * 3. (design/64 §26.4 fix 2 — the prefix-cache "death band") threshold ABOVE the clearStale point
35
+ * (`EDIT_FRACTION` = 0.7W): between 0.7W and the threshold, every request advances the
36
+ * tool-result clearing frontier → breaks the prefix cache at the frontier → ~0.7W re-prefilled
37
+ * PER REQUEST (at a 262K window with the default reserve that band is ~40 turns × ~183K tokens
38
+ * per compaction cycle). Verified on the real vLLM gateway (search [87]-[89]: post-compaction
39
+ * collapse + steady-state block reuse + stable-stub frontier mechanics).
40
+ * Repairs: (1) → reserve falls back to 15% of the window; (3) → threshold is clamped to ≤ 0.7W
41
+ * (compaction always fires before clearStale can engage — summarize-then-never-clear beats
42
+ * clear-then-summarize on both cache reuse AND fidelity); (2) → keepRecent drops to half the
43
+ * (post-clamp) threshold. (3) applies to explicit settings too: `editAt` is not user-configurable,
44
+ * so a threshold above it can never express consistent intent — compacting at 0.7W is strictly
45
+ * better for that caller (content is summarized, not stub-cleared). Settings already satisfying all
46
+ * three pass through unchanged (same object).
47
+ */
48
+ export function sanitizeCompactionSettings(settings, contextWindow) {
49
+ if (!contextWindow || !Number.isFinite(contextWindow) || contextWindow <= 0) {
50
+ return settings;
51
+ }
52
+ let reserveTokens = settings.reserveTokens;
53
+ if (contextWindow - reserveTokens <= 0) {
54
+ reserveTokens = Math.ceil(contextWindow * FALLBACK_RESERVE_FRACTION); // pathology 1: threshold ≤ 0
55
+ }
56
+ const editAt = Math.floor(contextWindow * EDIT_FRACTION);
57
+ if (contextWindow - reserveTokens > editAt) {
58
+ reserveTokens = contextWindow - editAt; // pathology 3: threshold above clearStale = death band
59
+ }
60
+ const threshold = contextWindow - reserveTokens;
61
+ let keepRecentTokens = settings.keepRecentTokens;
62
+ if (keepRecentTokens >= threshold) {
63
+ keepRecentTokens = Math.max(1, Math.floor(threshold / 2)); // pathology 2: kept tail alone re-triggers
64
+ }
65
+ if (reserveTokens === settings.reserveTokens && keepRecentTokens === settings.keepRecentTokens) {
66
+ return settings;
67
+ }
68
+ return { ...settings, reserveTokens, keepRecentTokens };
69
+ }
70
+ /**
71
+ * Compact the session in place when context usage exceeds the threshold.
72
+ *
73
+ * Two call sites, same policy: the within-task `turn_boundary` hook (design/64 §25 (A) — after the
74
+ * session flush, before the next request's context rebuild) and `finish()` at task end. The caller
75
+ * must ensure no session write is in flight (both sites are between model requests, post-flush).
76
+ *
77
+ * THROWS (council §26.6 #6 contract note): a summarization failure — including a summary that came
78
+ * back EMPTY after the analysis-block strip (a real LLM call was burned, history left untouched) —
79
+ * is thrown, not swallowed; callers are expected to catch, count it toward the §17.4 breaker, and
80
+ * surface it via onError. A legitimate nothing-to-compact (under threshold/floor, no cut point)
81
+ * returns `{compacted:false}` quietly.
82
+ * Honors an optional cheaper `compactionModel` without mutating the harness's active model.
83
+ * Zero-config: uses DEFAULT_COMPACTION_SETTINGS unless overridden; settings pathological for the
84
+ * model's window are repaired via {@link sanitizeCompactionSettings}.
85
+ */
86
+ export async function maybeCompact(opts) {
87
+ const compactStartAt = Date.now();
88
+ const rawSettings = opts.settings ?? DEFAULT_COMPACTION_SETTINGS;
89
+ if (!rawSettings.enabled) {
90
+ return { compacted: false, disabled: true }; // MF-18 修①: distinguishable from a structural no-op
91
+ }
92
+ const ctx = await opts.session.buildContext();
93
+ // design/123 D2: structural coefficient of the model whose window bounds this budget (the one
94
+ // that runs the next turn) — every structural quantity in this function lives in that coordinate.
95
+ const cpt = opts.model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
96
+ const est = estimateContextTokens(ctx.messages, cpt);
97
+ const overhead = opts.overheadTokens ?? 0;
98
+ // SEMA-ONLY stale-anchor freshness gate (trim-seam derived; no CC analogue — CC has no request-layer
99
+ // trim, so its anchors cannot outlive the context they measured). Live anchor: docs/TOKEN-ESTIMATE-
100
+ // CALIBRATION-LIVE-2026-07-09.md §4 — after a cache-break + trim collapse the real context was 2888
101
+ // tokens while the anchored estimate extrapolated est=52925 (18x) from a stale ~44k pre-collapse
102
+ // usage anchor; 21/23 live compactions (91%) fired prematurely on such over-estimates (est/real
103
+ // 2.9x–18x). The D1 strip (buildSessionContext) only retires anchors replayed across a COMPACTION
104
+ // boundary; an anchor whose surrounding context collapsed via trim/cache-break survives the scan
105
+ // (the compaction.ts stale-anchor note warned exactly this, but the gate had no invalidity check).
106
+ // Freshness invariant: a usage anchor bills the request that PRODUCED it — that request can only
107
+ // have contained what the current message list still holds (structural), plus the fixed prompt
108
+ // overhead. When the anchored estimate exceeds that ceiling with margin (structural under-counts
109
+ // by ≤ ~1.4x on real tokenizers: charsPerToken=3 vs measured ~2.18 — same doc §2), the context the
110
+ // anchor described no longer exists ⇒ the anchor is stale ⇒ fall back to the pure structural
111
+ // estimate (+ overhead), which is what the next request can actually contain.
112
+ const structuralTokens = ctx.messages.reduce((sum, m) => sum + estimateTokens(m, cpt), 0);
113
+ const anchorStale = est.usageTokens > 0 && est.tokens > structuralTokens * STALE_ANCHOR_STRUCTURAL_MARGIN + overhead;
114
+ // Anchor-less fallback (and the stale-anchor fallback) count messages only — add the fixed prompt
115
+ // overhead so the threshold comparison is like-for-like (see `overheadTokens`). Anchored (fresh):
116
+ // the overhead is already billed in.
117
+ const tokens = anchorStale || est.usageTokens === 0 ? structuralTokens + overhead : est.tokens;
118
+ const window = opts.model.contextTokens ?? opts.model.contextWindow;
119
+ // Small-window sanity: repair settings that are pathological for this window (threshold ≤ 0 /
120
+ // keepRecent ≥ threshold) so compaction neither always-triggers nor thrashes; self-consistent
121
+ // explicit settings pass through unchanged (see sanitizeCompactionSettings).
122
+ const settings = sanitizeCompactionSettings(rawSettings, window);
123
+ // `force` (manual /compact) bypasses the auto-threshold + anti-thrash floor; it still falls through to
124
+ // prepareCompaction, which returns `{compacted:false}` if there is no valid cut point (nothing to compact).
125
+ // design/123 D4 (r5): `forceUnderThreshold` (trim pressure) forces exactly when the NATURAL gate would
126
+ // not fire — est < max(threshold, minTokens-floor). See the option doc for the two regimes it rescues.
127
+ const wantsCompact = shouldCompact(tokens, window, settings);
128
+ const naturalTrigger = wantsCompact && tokens >= (opts.minTokens ?? 0);
129
+ const force = opts.force || (opts.forceUnderThreshold === true && !naturalTrigger);
130
+ if (!force && !naturalTrigger) {
131
+ // service [398] C3: over the threshold but UNDER the anti-thrash floor — compaction WANTED to
132
+ // fire and was suppressed. The success-only onCompaction path never fires here, so without this
133
+ // signal a run drifts into the request-trim / prefix-cache-collapse band with zero telemetry.
134
+ if (wantsCompact) {
135
+ return { compacted: false, suppressedByFloor: { estTokens: tokens, floor: opts.minTokens ?? 0 } };
136
+ }
137
+ return { compacted: false };
138
+ }
139
+ const branch = await opts.session.getBranch();
140
+ const prep = prepareCompaction(branch, settings, cpt);
141
+ if (!prep.ok) {
142
+ throw prep.error;
143
+ }
144
+ if (!prep.value) {
145
+ return { compacted: false };
146
+ }
147
+ // design/134 §3.2 (R3 LOW): preCompact fires HERE — after the trigger gate AND a confirmed valid
148
+ // cut point (never a "would not have compacted anyway" invocation, so every preCompact pairs with
149
+ // a compaction that actually proceeds unless the callback itself blocks), and before the
150
+ // provider/summary call. Swallow a throwing callback on EVERY path (R3 MED: an observer bug must
151
+ // not surface as a compaction failure — the caller's breaker / PTL recovery must be unaffected).
152
+ const trigger = opts.trigger ?? "auto";
153
+ let hookInstructions;
154
+ if (opts.preCompact) {
155
+ let pre;
156
+ try {
157
+ pre =
158
+ (await opts.preCompact({
159
+ trigger,
160
+ ...(opts.customInstructions !== undefined ? { customInstructions: opts.customInstructions } : {}),
161
+ })) ?? undefined;
162
+ }
163
+ catch {
164
+ // treated as no-block/no-instructions; tracing is the caller wrapper's job (it has the sink)
165
+ }
166
+ if (pre?.block !== undefined && pre.block !== "") {
167
+ // "forced" (PTL recovery / trim pressure) is not optional: ignore the block (the caller's
168
+ // wrapper traces the ignore) and proceed. auto/manual: skip this compaction — a deliberate
169
+ // decision, not a failure (`blocked:true` tells the caller apart from a structural no-op).
170
+ if (trigger !== "forced") {
171
+ return { compacted: false, blocked: true };
172
+ }
173
+ }
174
+ if (pre?.additionalInstructions) {
175
+ hookInstructions = pre.additionalInstructions;
176
+ }
177
+ }
178
+ // CC mergeHookInstructions shape: the hook's instructions EXTEND the configured ones (append,
179
+ // never replace) — a deployment's fidelity defaults survive a hook that only adds a focus.
180
+ const effectiveInstructions = hookInstructions
181
+ ? opts.customInstructions
182
+ ? `${opts.customInstructions}\n\n${hookInstructions}`
183
+ : hookInstructions
184
+ : opts.customInstructions;
185
+ // design/84 Seam C — provider reuse (data-gated; thin seam only, no provider implemented in core).
186
+ // Reuse guard (c): once the caller has reused the provider's summary `maxConsecutiveProviderReuse`
187
+ // times IN A ROW, bypass the provider for THIS one boundary so a real summary is forced (bounds drift
188
+ // from indefinite reuse). Default cap = 3 (CC parity); only the consult is bypassed — the rest of the
189
+ // path (LLM summarize) is unchanged. With no provider at all this whole block is dead and behavior is
190
+ // byte-for-byte the current path.
191
+ const maxReuse = opts.maxConsecutiveProviderReuse ?? 3;
192
+ const forceRealSummary = (opts.consecutiveProviderReuse ?? 0) >= maxReuse;
193
+ let providerSummary;
194
+ // Split-turn fidelity guard (HARDENER MAJOR): on a SPLIT turn the boundary carries `turnPrefixMessages`
195
+ // (turnStartIndex..firstKeptEntryIndex) that the LLM path summarizes and folds into the summary as
196
+ // "**Turn Context (split turn):**" (compaction.ts). The provider path only sees `messagesToSummarize`
197
+ // (the history BEFORE the split turn) and uses its return verbatim as the WHOLE summary, with
198
+ // firstKeptEntryId = the suffix start — so the turn-prefix work would be dropped from history AND never
199
+ // captured by the provider. Bypass the provider for any split-turn boundary so the prefix-preserving
200
+ // LLM path always runs. (Option (a) from the finding: the minimal safe seam.)
201
+ if (opts.summaryProvider && !forceRealSummary && !prep.value.isSplitTurn) {
202
+ // Provider sees the same boundary inputs the LLM path would. `modifiedFiles` is the recency-ordered
203
+ // list derived from the prepared file ops (same source the working-file attachments use below).
204
+ const providerModifiedFiles = computeFileLists(prep.value.fileOps).modifiedFilesByRecency;
205
+ try {
206
+ const raw = await opts.summaryProvider({
207
+ messagesToSummarize: prep.value.messagesToSummarize,
208
+ previousSummary: prep.value.previousSummary,
209
+ modifiedFiles: providerModifiedFiles,
210
+ });
211
+ // Reuse guard (a) — over the empty-summary guard: a null/undefined/empty/whitespace-only provider
212
+ // result is NOT a reuse hit, it FALLS BACK to the LLM path (treated exactly as if no provider). This
213
+ // reuses the same "never persist an empty summary" invariant the LLM path enforces below.
214
+ const trimmed = typeof raw === "string" ? raw.trim() : "";
215
+ if (trimmed) {
216
+ providerSummary = trimmed;
217
+ }
218
+ }
219
+ catch {
220
+ // Provider failure guard (HARDENER MAJOR): the summaryProvider is an OPTIMIZATION. A throw/rejection
221
+ // must DEGRADE to the existing LLM `generateSummary` path (treated exactly as a miss), never abort
222
+ // compaction. Without this, the rejection would propagate to the caller's catch, trip the §17.4
223
+ // breaker, skip compaction, and — after MAX_CONSECUTIVE_COMPACTION_FAILURES throws — disable
224
+ // within-task compaction entirely (strictly worse than having no provider). providerSummary stays
225
+ // undefined → LLM fallback.
226
+ }
227
+ }
228
+ let summary;
229
+ let firstKeptEntryId;
230
+ let summaryTokensBefore;
231
+ let details;
232
+ const reused = providerSummary !== undefined;
233
+ if (providerSummary !== undefined) {
234
+ // Provider hit: skip the LLM `generateSummary` call entirely; reuse the provided summary verbatim.
235
+ // firstKeptEntryId / tokensBefore come from the prepared boundary (the same values compact() would
236
+ // have returned). details (modifiedFiles) derived from prep.value.fileOps for parity with the LLM
237
+ // path's persisted CompactionDetails (so working-file attachments + downstream consumers are unchanged).
238
+ summary = providerSummary;
239
+ firstKeptEntryId = prep.value.firstKeptEntryId;
240
+ summaryTokensBefore = prep.value.tokensBefore;
241
+ details = computeFileLists(prep.value.fileOps);
242
+ }
243
+ else {
244
+ const summaryModel = opts.compactionModel ?? opts.model;
245
+ const auth = await opts.getApiKeyAndHeaders?.(summaryModel);
246
+ const runtime = brainToRuntime(opts.brain);
247
+ const res = await compact(prep.value, summaryModel, auth?.apiKey, auth?.headers, effectiveInstructions, opts.signal, opts.thinking, undefined, runtime, undefined, opts.onInputTruncated);
248
+ if (!res.ok) {
249
+ throw res.error;
250
+ }
251
+ // design/66 D #1: the summarization prompt asks the model to think first inside an <analysis>...</analysis>
252
+ // scratch block (improves coverage), which must be stripped before the summary is persisted/injected. The
253
+ // strip is idempotent and safe if the model didn't emit the block (no-op). Paired blocks only — an
254
+ // unterminated tag is left intact rather than swallowing the whole summary.
255
+ summary = (res.value.summary ?? "").replace(/<analysis>[\s\S]*?<\/analysis>\s*/gi, "").trim();
256
+ // Never replace real history with an empty/whitespace summary (a flaky gateway turn, output that was
257
+ // ONLY an analysis block, or a thinking-enabled model whose reasoning consumed the whole output
258
+ // budget). This is a FAILED attempt, not a no-op: it burned a real summary LLM call and left the
259
+ // session over-threshold, so it would silently repeat at every boundary. THROW so the caller's
260
+ // breaker (§17.4) counts it and `onError(phase:"compaction")` surfaces it — a probe that watched
261
+ // only `compacted` events once mistook exactly this silence for "compaction never triggered"
262
+ // (design/64 §26.7 / search [88]'s light arm).
263
+ if (!summary) {
264
+ throw new Error("compaction produced an empty summary (reasoning may have consumed the output budget; history left untouched)");
265
+ }
266
+ // Oversized guard (design/118 follow-up, codex review): the reasoning floor lets the summary call's
267
+ // OUTPUT budget exceed the reserve-derived cap, so a summary SIGNIFICANTLY larger than the entire
268
+ // pre-compaction context (a model hallucinating/expanding instead of summarizing at full floor budget)
269
+ // must never REPLACE that history — pure fact-loss with negative token gain. Throw so the §17.4
270
+ // breaker counts it (same contract as the empty-summary guard above). Threshold 1.5×, NOT 1×: a
271
+ // merely-ineffective summary (≈ the original size) is the §25.2 regrowth-floor's job — it LANDS once
272
+ // and the freed-aware floor spaces out further attempts (pinned by the anti-thrash test); throwing
273
+ // there would bypass the floor and burn a call per boundary until the breaker.
274
+ // design/123 D2 (应改): the summary lives in the TASK model's context, so compare in that
275
+ // model's structural coordinate (tokensBefore is already cpt-based via prepareCompaction).
276
+ if (Math.ceil(summary.length / cpt) > res.value.tokensBefore * 1.5) {
277
+ throw new Error(`compaction produced an oversized summary (≈${Math.ceil(summary.length / cpt)} tokens vs ` +
278
+ `${res.value.tokensBefore} before compaction; history left untouched)`);
279
+ }
280
+ firstKeptEntryId = res.value.firstKeptEntryId;
281
+ summaryTokensBefore = res.value.tokensBefore;
282
+ details = res.value.details;
283
+ }
284
+ // Working-file attachments (see MaybeCompactOptions.workingFileAttachments): append bounded
285
+ // CURRENT contents of the files the summarized region modified. Best-effort per file — a reader
286
+ // failure (deleted/renamed/remote hiccup) skips that file and must never fail a successful
287
+ // compaction. Appended INTO the summary text so it lives inside the same compaction entry
288
+ // (renders inside the <summary> framing; clearly labeled as a fresh on-disk snapshot).
289
+ let summaryWithAttachments = summary;
290
+ const attachedFiles = [];
291
+ const att = opts.workingFileAttachments;
292
+ // Selection set (CC 198 parity, blackboard 2026-07-03): most recently READ files when the caller
293
+ // tracks reads (CC's post-compact restore reads readFileState by timestamp — wider than the
294
+ // modified set, includes consulted reference files); else fall back to modified-by-recency
295
+ // (design/71 P2-①; alphabetical modifiedFiles remains the last fallback for old persisted details).
296
+ const recentlyRead = att?.recentlyReadFiles?.() ?? [];
297
+ const candidateFiles = recentlyRead.length > 0 ? recentlyRead : (details?.modifiedFilesByRecency ?? details?.modifiedFiles);
298
+ if (att && Array.isArray(candidateFiles) && candidateFiles.length > 0) {
299
+ const maxFiles = Math.max(1, att.maxFiles ?? 3);
300
+ const perFileCap = Math.max(200, att.maxCharsPerFile ?? 16_000);
301
+ // Total budget self-scales to the window (~15% of it, chars ≈ tokens×charsPerToken — design/123
302
+ // D2) so a small window is never drowned in attachments regardless of the per-file caps.
303
+ let remaining = Math.min(maxFiles * perFileCap, Math.floor(window * 0.15) * cpt);
304
+ const blocks = [];
305
+ for (const path of candidateFiles.slice(0, maxFiles)) {
306
+ if (remaining <= 0)
307
+ break;
308
+ let content = null;
309
+ try {
310
+ content = await att.readFile(path);
311
+ }
312
+ catch {
313
+ content = null;
314
+ }
315
+ if (content === null)
316
+ continue;
317
+ const cap = Math.min(perFileCap, remaining);
318
+ const wasClipped = content.length > cap;
319
+ const clipped = wasClipped
320
+ ? `${content.slice(0, cap)}\n[... ${content.length - cap} more characters truncated — read the file for the rest]`
321
+ : content;
322
+ remaining -= clipped.length;
323
+ blocks.push(`<working-file path="${path}">\n${clipped}\n</working-file>`);
324
+ // Structured record for the `compacted` wire event (blackboard ask ②: the shell renders CC's
325
+ // post-compact `Read {path} (…)` cards from this — it cannot parse <working-file> out of the summary).
326
+ attachedFiles.push({ path, chars: Math.min(content.length, cap), truncated: wasClipped });
327
+ }
328
+ if (blocks.length > 0) {
329
+ summaryWithAttachments +=
330
+ "\n\nCurrent on-disk contents of files touched in the summarized work (re-read at compaction time — trust these over any excerpts in the summary above):\n" +
331
+ blocks.join("\n");
332
+ }
333
+ }
334
+ // §25.2 effectiveness measurement for the caller's anti-thrash floor: how much MESSAGE mass the
335
+ // compaction actually freed, in structural (char-heuristic) units. Deliberately NOT the usage-based
336
+ // estimate — post-compaction, the kept tail's last assistant usage still reflects the PRE-compaction
337
+ // request, so a usage-based "after" would overstate. A structural pre/post delta is truthful and
338
+ // translates ≈1:1 into the trigger estimate's units (any usage/system offset cancels in the delta).
339
+ let preChars = 0;
340
+ for (const m of ctx.messages)
341
+ preChars += estimateTokens(m, cpt);
342
+ await opts.session.appendCompaction(summaryWithAttachments, firstKeptEntryId, summaryTokensBefore, details, false);
343
+ let freedTokens = preChars; // failure default = "fully effective": the caller's floor stays low, never suppressing
344
+ // P-13: the §25.2 anti-thrash floor must live in the SAME coordinate as `triggerTokens` (estimate +
345
+ // anchor-less overhead). Reporting the post-compaction size DIRECTLY in that coordinate — rather than letting
346
+ // the caller subtract a chars/4 `freedTokens` delta from a possibly usage-anchored `triggerTokens` — stops
347
+ // the mixed-coordinate subtraction that inflated the floor (suppressing in-task compaction) on code-dense
348
+ // real models, where chars/4 underestimates the real freed tokens. `undefined` ⇒ caller keeps its legacy
349
+ // `triggerTokens − freedTokens` fallback.
350
+ let postTriggerTokens;
351
+ try {
352
+ const post = (await opts.session.buildContext()).messages;
353
+ let postChars = 0;
354
+ for (const m of post)
355
+ postChars += estimateTokens(m, cpt);
356
+ freedTokens = Math.max(0, preChars - postChars);
357
+ // STRUCTURAL, deliberately NOT estimateContextTokens(post): the kept tail's last assistant usage
358
+ // still reflects the PRE-compaction request (the same staleness :434 documents for freedTokens),
359
+ // so a usage-anchored "post size" ≈ the trigger point itself — and the caller's ×1.5 regrowth
360
+ // floor then lands at ~1.5× the PREVIOUS trigger. Each compaction ratchets the next trigger up
361
+ // ~50%; once the floor exceeds what the window can reach, within-task compaction is permanently
362
+ // suppressed and the run silently rides the request-layer trim (the §26.4 prefix-cache death
363
+ // band — measured live: 3 compactions at 12.4k/18.9k/28.4k on a 24k window, then 7 straight
364
+ // over-window turns with a cache collapse and no 4th compaction). The structural sum is the
365
+ // truthful post size; the caller's next-boundary trigger re-anchors on FRESH usage anyway.
366
+ postTriggerTokens = postChars + (opts.overheadTokens ?? 0);
367
+ }
368
+ catch {
369
+ /* keep the non-suppressing default — never fail a successful compaction on the measurement */
370
+ }
371
+ // design/84 Seam C observer (pure, no control-flow effect): fired only on a successful compaction.
372
+ // `reused` lets the caller advance/reset its consecutive-reuse counter for reuse guard (c), and
373
+ // `freedTokens` lets it apply reuse guard (b) — treat freed<ε as no-effective-compaction and NOT raise
374
+ // the anti-thrash floor (a reused summary that frees ~nothing must not suppress future real summaries).
375
+ // The floor/freed semantics live in the caller (runtask.ts §25.2); core just reports the measurements.
376
+ // Observer isolation (HARDENER MAJOR): the compaction has ALREADY succeeded (history mutated above). The
377
+ // observer is documented as control-flow-free, so a throw here MUST NOT escape — otherwise it would
378
+ // propagate to the caller's catch (runtask §17.4) and convert a SUCCESSFUL compaction into a counted
379
+ // breaker failure (and skip the caller's post-compaction bookkeeping: cacheBreakDetector reset + floor
380
+ // update). Swallow best-effort, exactly like the freedTokens measurement above.
381
+ try {
382
+ opts.onCompaction?.({
383
+ messagesCompacted: prep.value.messagesToSummarize.length,
384
+ freedTokens,
385
+ tokensBefore: summaryTokensBefore,
386
+ reused,
387
+ });
388
+ }
389
+ catch {
390
+ /* observer is a pure observer — never let it affect the return value or the caller's accounting */
391
+ }
392
+ // design/134: postCompact fires only after the compaction LANDED (appendCompaction above), with the
393
+ // post measurement already taken so `tokensAfter` rides along when available. `summary` is the
394
+ // conversation summary the compaction produced (CC compact_summary parity) — deliberately WITHOUT
395
+ // the working-file attachment blocks (those are a separate re-read mechanism, not summary content).
396
+ // Observe-only + swallowed throw: same isolation contract as the onCompaction observer above.
397
+ if (opts.postCompact) {
398
+ try {
399
+ await opts.postCompact({
400
+ trigger,
401
+ summary,
402
+ tokensBefore: summaryTokensBefore,
403
+ ...(postTriggerTokens !== undefined ? { tokensAfter: postTriggerTokens } : {}),
404
+ });
405
+ }
406
+ catch {
407
+ /* observe-only: a throwing postCompact must never fail a landed compaction */
408
+ }
409
+ }
410
+ // audit B-1: `triggerTokens` = the exact quantity the trigger gate compared (estimate + anchor-less
411
+ // overhead). The caller's §25.2 regrowth floor must live in THIS coordinate system, not in
412
+ // prepareCompaction's `tokensBefore` (which lacks the overhead term).
413
+ return {
414
+ compacted: true,
415
+ tokensBefore: summaryTokensBefore,
416
+ freedTokens,
417
+ triggerTokens: tokens,
418
+ postTriggerTokens,
419
+ firstKeptEntryId,
420
+ reused,
421
+ naturalTrigger,
422
+ durationMs: Date.now() - compactStartAt,
423
+ ...(postTriggerTokens !== undefined
424
+ ? { postOverThreshold: shouldCompact(postTriggerTokens, window, settings) }
425
+ : {}),
426
+ ...(attachedFiles.length > 0 ? { attachedFiles } : {}),
427
+ };
428
+ }
429
+ /**
430
+ * design/123 D4 (r5) — trim-force BACKOFF transition (pure; the run-scoped bit lives in the caller).
431
+ * Spiral protection replacing the §25.2 floor's role on the trim-force path: trim pressure re-arms
432
+ * every request while the transcript is oversized, so an unconditional force would burn a summary
433
+ * call at every boundary when summaries CANNOT shrink the context (the LONGRUN-1b incompressible
434
+ * shape). The invariant: trim-force is permitted only while the LATEST landed compaction proved it
435
+ * can bring the context back under the threshold (or no compaction has landed yet). Transitions,
436
+ * evaluated after each maybeCompact result:
437
+ * 1. no compaction landed → state unchanged (a structural no-op proves nothing either way);
438
+ * 2. a landed compaction with `postOverThreshold` → "压不动": BACKOFF ON — compaction demonstrably
439
+ * cannot reach under-threshold, so forcing more of them only burns summary calls; the §25.2
440
+ * floor policy takes back over (natural triggers are never gated by this bit);
441
+ * 3. a landed compaction that posted UNDER the threshold → summaries compress again: BACKOFF OFF
442
+ * (this is how the natural floor-crossing compaction of design/123 D4's reset clause re-enables
443
+ * the trim-force — its healthy landing posts under threshold);
444
+ * 4. post measurement unavailable → state unchanged (never flip on missing evidence);
445
+ * 5. (COMPACTION-LIVE-AUDIT D-1, evaluated BEFORE rule 3) a TRIM-FORCED landing with
446
+ * `freedTokens ≤ 0` → negative-yield: BACKOFF ON. The trim layer deceives the usage-anchored
447
+ * estimate down into the sawtooth trough (live: est 18807 on a ~55k session), the forced pass
448
+ * finds little compressible history, and summary + working-file attachments make the transcript
449
+ * LARGER (live: 18807→44609, 12679→35214). `freedTokens` is the structural pre/post delta
450
+ * (clamped ≥0, so ≤0 means "freed nothing") — orthogonal to rule 2/3's threshold test, which
451
+ * misses this shape because the bloated post (44609) can still sit UNDER the threshold (44800),
452
+ * so rule 3 alone would re-enable the force and repeat the negative-yield pass every boundary.
453
+ * SEMA-ONLY DEFENSE, not a CC port: CC's full compact keeps tail 0 and monotonically shrinks
454
+ * (capture §A4), and CC has no request-layer trim, so this regime cannot exist there — it is a
455
+ * derived interaction of our trim seam × keep-tail × attachment mass. Scoped to trim-forced
456
+ * passes only (`trimForced`), so Seam C reused-summary landings (freed≈0 by design) on the
457
+ * natural/manual paths never trip it. Release path unchanged: backoff gates only the FORCE, a
458
+ * later natural landing that posts under threshold (rule 3, non-trim-forced) turns it back off.
459
+ */
460
+ export function nextTrimForceBackoff(prev, comp, trimForced = false) {
461
+ // rule 5 guard: `trimForced` from the call site means "trim force was PERMITTED", not "this landing
462
+ // was trim-forced" — a landing that fired on the natural threshold (naturalTrigger) while trim
463
+ // pressure happened to be armed is NOT a trim-forced pass, and its negative yield must not back off
464
+ // the trim-force escape hatch (verify leg F3: armed + natural + freed<=0 mis-charged rule 5).
465
+ if (trimForced && comp.naturalTrigger !== true && comp.compacted && comp.freedTokens !== undefined && comp.freedTokens <= 0) {
466
+ return true; // rule 5: negative-yield trim-forced pass — back off immediately, don't wait for rule 2
467
+ }
468
+ if (!comp.compacted || comp.postOverThreshold === undefined) {
469
+ return prev;
470
+ }
471
+ return comp.postOverThreshold;
472
+ }
473
+ /** Fresh tracking state (no compaction seen yet). */
474
+ export function createRapidRefillState() {
475
+ return { lastCompactionTurn: Number.NEGATIVE_INFINITY, count: 0 };
476
+ }
477
+ /**
478
+ * design/119 S3 (CC 2.1.198 rapid_refill_breaker, :229717/:476338): record that a compaction just
479
+ * happened at `turn` and report whether the thrash breaker should TRIP. A compaction landing within
480
+ * `minGapTurns` of the previous one is a "rapid refill"; `tripAt` consecutive rapid refills = the
481
+ * context is dominated by incompressible content and further compaction only burns summary calls.
482
+ * CC terminates the task; sema's caller (runtask) deviates conservatively — it opens the existing
483
+ * compaction breaker (no more compaction this task) and lets budget/PTL/turn limits end the run.
484
+ */
485
+ export function recordCompactionAndCheckRapidRefill(state, turn, minGapTurns = 3, tripAt = 3) {
486
+ if (turn - state.lastCompactionTurn < minGapTurns) {
487
+ state.count += 1;
488
+ }
489
+ else {
490
+ state.count = 0;
491
+ }
492
+ state.lastCompactionTurn = turn;
493
+ return state.count >= tripAt;
494
+ }
495
+ //# sourceMappingURL=auto-compaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auto-compaction.js","source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