@smthrs/harness 0.0.0-stage → 1.0.0-rc.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 (476) hide show
  1. package/CHANGELOG.md +387 -0
  2. package/LICENSE +21 -0
  3. package/README.md +138 -2
  4. package/dist/cjs/AgentEvent.d.ts +3092 -0
  5. package/dist/cjs/AgentEvent.d.ts.map +1 -0
  6. package/dist/cjs/AgentEvent.js +1116 -0
  7. package/dist/cjs/AgentEvent.js.map +7 -0
  8. package/dist/cjs/CallLedger.d.ts +378 -0
  9. package/dist/cjs/CallLedger.d.ts.map +1 -0
  10. package/dist/cjs/CallLedger.js +240 -0
  11. package/dist/cjs/CallLedger.js.map +7 -0
  12. package/dist/cjs/Cell.d.ts +774 -0
  13. package/dist/cjs/Cell.d.ts.map +1 -0
  14. package/dist/cjs/Cell.js +431 -0
  15. package/dist/cjs/Cell.js.map +7 -0
  16. package/dist/cjs/CellCalls.d.ts +115 -0
  17. package/dist/cjs/CellCalls.d.ts.map +1 -0
  18. package/dist/cjs/CellCalls.js +98 -0
  19. package/dist/cjs/CellCalls.js.map +7 -0
  20. package/dist/cjs/CellHistory.d.ts +102 -0
  21. package/dist/cjs/CellHistory.d.ts.map +1 -0
  22. package/dist/cjs/CellHistory.js +54 -0
  23. package/dist/cjs/CellHistory.js.map +7 -0
  24. package/dist/cjs/CellTurn.d.ts +1071 -0
  25. package/dist/cjs/CellTurn.d.ts.map +1 -0
  26. package/dist/cjs/CellTurn.js +2618 -0
  27. package/dist/cjs/CellTurn.js.map +7 -0
  28. package/dist/cjs/CellValidation.d.ts +94 -0
  29. package/dist/cjs/CellValidation.d.ts.map +1 -0
  30. package/dist/cjs/CellValidation.js +218 -0
  31. package/dist/cjs/CellValidation.js.map +7 -0
  32. package/dist/cjs/Compaction.d.ts +158 -0
  33. package/dist/cjs/Compaction.d.ts.map +1 -0
  34. package/dist/cjs/Compaction.js +189 -0
  35. package/dist/cjs/Compaction.js.map +7 -0
  36. package/dist/cjs/CompletionClaim.d.ts +801 -0
  37. package/dist/cjs/CompletionClaim.d.ts.map +1 -0
  38. package/dist/cjs/CompletionClaim.js +303 -0
  39. package/dist/cjs/CompletionClaim.js.map +7 -0
  40. package/dist/cjs/ContextWindow.d.ts +435 -0
  41. package/dist/cjs/ContextWindow.d.ts.map +1 -0
  42. package/dist/cjs/ContextWindow.js +319 -0
  43. package/dist/cjs/ContextWindow.js.map +7 -0
  44. package/dist/cjs/EngineLike.d.ts +546 -0
  45. package/dist/cjs/EngineLike.d.ts.map +1 -0
  46. package/dist/cjs/EngineLike.js +114 -0
  47. package/dist/cjs/EngineLike.js.map +7 -0
  48. package/dist/cjs/ExternalTranscript.d.ts +349 -0
  49. package/dist/cjs/ExternalTranscript.d.ts.map +1 -0
  50. package/dist/cjs/ExternalTranscript.js +826 -0
  51. package/dist/cjs/ExternalTranscript.js.map +7 -0
  52. package/dist/cjs/FailedCall.d.ts +132 -0
  53. package/dist/cjs/FailedCall.d.ts.map +1 -0
  54. package/dist/cjs/FailedCall.js +53 -0
  55. package/dist/cjs/FailedCall.js.map +7 -0
  56. package/dist/cjs/FlowBinding.d.ts +289 -0
  57. package/dist/cjs/FlowBinding.d.ts.map +1 -0
  58. package/dist/cjs/FlowBinding.js +251 -0
  59. package/dist/cjs/FlowBinding.js.map +7 -0
  60. package/dist/cjs/HarnessError.d.ts +57 -0
  61. package/dist/cjs/HarnessError.d.ts.map +1 -0
  62. package/dist/cjs/HarnessError.js +75 -0
  63. package/dist/cjs/HarnessError.js.map +7 -0
  64. package/dist/cjs/Judgement.d.ts +289 -0
  65. package/dist/cjs/Judgement.d.ts.map +1 -0
  66. package/dist/cjs/Judgement.js +240 -0
  67. package/dist/cjs/Judgement.js.map +7 -0
  68. package/dist/cjs/Monitor.d.ts +374 -0
  69. package/dist/cjs/Monitor.d.ts.map +1 -0
  70. package/dist/cjs/Monitor.js +233 -0
  71. package/dist/cjs/Monitor.js.map +7 -0
  72. package/dist/cjs/NarrowedCheck.d.ts +523 -0
  73. package/dist/cjs/NarrowedCheck.d.ts.map +1 -0
  74. package/dist/cjs/NarrowedCheck.js +263 -0
  75. package/dist/cjs/NarrowedCheck.js.map +7 -0
  76. package/dist/cjs/Notifications.d.ts +42 -0
  77. package/dist/cjs/Notifications.d.ts.map +1 -0
  78. package/dist/cjs/Notifications.js +177 -0
  79. package/dist/cjs/Notifications.js.map +7 -0
  80. package/dist/cjs/Plan.d.ts +127 -0
  81. package/dist/cjs/Plan.d.ts.map +1 -0
  82. package/dist/cjs/Plan.js +77 -0
  83. package/dist/cjs/Plan.js.map +7 -0
  84. package/dist/cjs/QuickJSSandbox.d.ts +151 -0
  85. package/dist/cjs/QuickJSSandbox.d.ts.map +1 -0
  86. package/dist/cjs/QuickJSSandbox.js +987 -0
  87. package/dist/cjs/QuickJSSandbox.js.map +7 -0
  88. package/dist/cjs/Relevance.d.ts +213 -0
  89. package/dist/cjs/Relevance.d.ts.map +1 -0
  90. package/dist/cjs/Relevance.js +183 -0
  91. package/dist/cjs/Relevance.js.map +7 -0
  92. package/dist/cjs/Sandbox.d.ts +637 -0
  93. package/dist/cjs/Sandbox.d.ts.map +1 -0
  94. package/dist/cjs/Sandbox.js +260 -0
  95. package/dist/cjs/Sandbox.js.map +7 -0
  96. package/dist/cjs/Steering.d.ts +464 -0
  97. package/dist/cjs/Steering.d.ts.map +1 -0
  98. package/dist/cjs/Steering.js +153 -0
  99. package/dist/cjs/Steering.js.map +7 -0
  100. package/dist/cjs/StructuredOutput.d.ts +252 -0
  101. package/dist/cjs/StructuredOutput.d.ts.map +1 -0
  102. package/dist/cjs/StructuredOutput.js +266 -0
  103. package/dist/cjs/StructuredOutput.js.map +7 -0
  104. package/dist/cjs/Sufficiency.d.ts +195 -0
  105. package/dist/cjs/Sufficiency.d.ts.map +1 -0
  106. package/dist/cjs/Sufficiency.js +110 -0
  107. package/dist/cjs/Sufficiency.js.map +7 -0
  108. package/dist/cjs/Supervisor.d.ts +719 -0
  109. package/dist/cjs/Supervisor.d.ts.map +1 -0
  110. package/dist/cjs/Supervisor.js +313 -0
  111. package/dist/cjs/Supervisor.js.map +7 -0
  112. package/dist/cjs/Tokens.d.ts +86 -0
  113. package/dist/cjs/Tokens.d.ts.map +1 -0
  114. package/dist/cjs/Tokens.js +72 -0
  115. package/dist/cjs/Tokens.js.map +7 -0
  116. package/dist/cjs/Transcript.d.ts +171 -0
  117. package/dist/cjs/Transcript.d.ts.map +1 -0
  118. package/dist/cjs/Transcript.js +342 -0
  119. package/dist/cjs/Transcript.js.map +7 -0
  120. package/dist/cjs/TruncatedOutput.d.ts +186 -0
  121. package/dist/cjs/TruncatedOutput.d.ts.map +1 -0
  122. package/dist/cjs/TruncatedOutput.js +143 -0
  123. package/dist/cjs/TruncatedOutput.js.map +7 -0
  124. package/dist/cjs/UnmovedTree.d.ts +113 -0
  125. package/dist/cjs/UnmovedTree.d.ts.map +1 -0
  126. package/dist/cjs/UnmovedTree.js +38 -0
  127. package/dist/cjs/UnmovedTree.js.map +7 -0
  128. package/dist/cjs/UnresolvedFailure.d.ts +196 -0
  129. package/dist/cjs/UnresolvedFailure.d.ts.map +1 -0
  130. package/dist/cjs/UnresolvedFailure.js +77 -0
  131. package/dist/cjs/UnresolvedFailure.js.map +7 -0
  132. package/dist/cjs/VacuousVerification.d.ts +237 -0
  133. package/dist/cjs/VacuousVerification.d.ts.map +1 -0
  134. package/dist/cjs/VacuousVerification.js +91 -0
  135. package/dist/cjs/VacuousVerification.js.map +7 -0
  136. package/dist/cjs/VariablesPanel.d.ts +117 -0
  137. package/dist/cjs/VariablesPanel.d.ts.map +1 -0
  138. package/dist/cjs/VariablesPanel.js +108 -0
  139. package/dist/cjs/VariablesPanel.js.map +7 -0
  140. package/dist/cjs/index.d.ts +172 -0
  141. package/dist/cjs/index.d.ts.map +1 -0
  142. package/dist/cjs/index.js +99 -0
  143. package/dist/cjs/index.js.map +7 -0
  144. package/dist/cjs/internal/bytes.d.ts +36 -0
  145. package/dist/cjs/internal/bytes.d.ts.map +1 -0
  146. package/dist/cjs/internal/bytes.js +57 -0
  147. package/dist/cjs/internal/bytes.js.map +7 -0
  148. package/dist/cjs/internal/cellPrompt.d.ts +122 -0
  149. package/dist/cjs/internal/cellPrompt.d.ts.map +1 -0
  150. package/dist/cjs/internal/cellPrompt.js +146 -0
  151. package/dist/cjs/internal/cellPrompt.js.map +7 -0
  152. package/dist/cjs/internal/compactable.d.ts +44 -0
  153. package/dist/cjs/internal/compactable.d.ts.map +1 -0
  154. package/dist/cjs/internal/compactable.js +56 -0
  155. package/dist/cjs/internal/compactable.js.map +7 -0
  156. package/dist/cjs/internal/compactionMarks.d.ts +278 -0
  157. package/dist/cjs/internal/compactionMarks.d.ts.map +1 -0
  158. package/dist/cjs/internal/compactionMarks.js +212 -0
  159. package/dist/cjs/internal/compactionMarks.js.map +7 -0
  160. package/dist/cjs/internal/demandText.d.ts +95 -0
  161. package/dist/cjs/internal/demandText.d.ts.map +1 -0
  162. package/dist/cjs/internal/demandText.js +70 -0
  163. package/dist/cjs/internal/demandText.js.map +7 -0
  164. package/dist/cjs/internal/elide.d.ts +109 -0
  165. package/dist/cjs/internal/elide.d.ts.map +1 -0
  166. package/dist/cjs/internal/elide.js +59 -0
  167. package/dist/cjs/internal/elide.js.map +7 -0
  168. package/dist/cjs/internal/frame.d.ts +463 -0
  169. package/dist/cjs/internal/frame.d.ts.map +1 -0
  170. package/dist/cjs/internal/frame.js +514 -0
  171. package/dist/cjs/internal/frame.js.map +7 -0
  172. package/dist/cjs/internal/nonNegativeSafeInt.d.ts +20 -0
  173. package/dist/cjs/internal/nonNegativeSafeInt.d.ts.map +1 -0
  174. package/dist/cjs/internal/nonNegativeSafeInt.js +29 -0
  175. package/dist/cjs/internal/nonNegativeSafeInt.js.map +7 -0
  176. package/dist/cjs/internal/paidUsage.d.ts +52 -0
  177. package/dist/cjs/internal/paidUsage.d.ts.map +1 -0
  178. package/dist/cjs/internal/paidUsage.js +70 -0
  179. package/dist/cjs/internal/paidUsage.js.map +7 -0
  180. package/dist/cjs/internal/printChannel.d.ts +233 -0
  181. package/dist/cjs/internal/printChannel.d.ts.map +1 -0
  182. package/dist/cjs/internal/printChannel.js +165 -0
  183. package/dist/cjs/internal/printChannel.js.map +7 -0
  184. package/dist/cjs/internal/printsObservation.d.ts +26 -0
  185. package/dist/cjs/internal/printsObservation.d.ts.map +1 -0
  186. package/dist/cjs/internal/printsObservation.js +27 -0
  187. package/dist/cjs/internal/printsObservation.js.map +7 -0
  188. package/dist/cjs/internal/refusal.d.ts +40 -0
  189. package/dist/cjs/internal/refusal.d.ts.map +1 -0
  190. package/dist/cjs/internal/refusal.js +45 -0
  191. package/dist/cjs/internal/refusal.js.map +7 -0
  192. package/dist/cjs/internal/supervision.d.ts +174 -0
  193. package/dist/cjs/internal/supervision.d.ts.map +1 -0
  194. package/dist/cjs/internal/supervision.js +402 -0
  195. package/dist/cjs/internal/supervision.js.map +7 -0
  196. package/dist/cjs/internal/unfinishedWork.d.ts +99 -0
  197. package/dist/cjs/internal/unfinishedWork.d.ts.map +1 -0
  198. package/dist/cjs/internal/unfinishedWork.js +80 -0
  199. package/dist/cjs/internal/unfinishedWork.js.map +7 -0
  200. package/dist/cjs/internal/unobservedCall.d.ts +112 -0
  201. package/dist/cjs/internal/unobservedCall.d.ts.map +1 -0
  202. package/dist/cjs/internal/unobservedCall.js +345 -0
  203. package/dist/cjs/internal/unobservedCall.js.map +7 -0
  204. package/dist/cjs/internal/untrustedData.d.ts +14 -0
  205. package/dist/cjs/internal/untrustedData.d.ts.map +1 -0
  206. package/dist/cjs/internal/untrustedData.js +30 -0
  207. package/dist/cjs/internal/untrustedData.js.map +7 -0
  208. package/dist/cjs/package.json +1 -0
  209. package/dist/esm/AgentEvent.d.ts +3092 -0
  210. package/dist/esm/AgentEvent.d.ts.map +1 -0
  211. package/dist/esm/AgentEvent.js +1610 -0
  212. package/dist/esm/AgentEvent.js.map +1 -0
  213. package/dist/esm/CallLedger.d.ts +378 -0
  214. package/dist/esm/CallLedger.d.ts.map +1 -0
  215. package/dist/esm/CallLedger.js +506 -0
  216. package/dist/esm/CallLedger.js.map +1 -0
  217. package/dist/esm/Cell.d.ts +774 -0
  218. package/dist/esm/Cell.d.ts.map +1 -0
  219. package/dist/esm/Cell.js +772 -0
  220. package/dist/esm/Cell.js.map +1 -0
  221. package/dist/esm/CellCalls.d.ts +115 -0
  222. package/dist/esm/CellCalls.d.ts.map +1 -0
  223. package/dist/esm/CellCalls.js +97 -0
  224. package/dist/esm/CellCalls.js.map +1 -0
  225. package/dist/esm/CellHistory.d.ts +102 -0
  226. package/dist/esm/CellHistory.d.ts.map +1 -0
  227. package/dist/esm/CellHistory.js +91 -0
  228. package/dist/esm/CellHistory.js.map +1 -0
  229. package/dist/esm/CellTurn.d.ts +1071 -0
  230. package/dist/esm/CellTurn.d.ts.map +1 -0
  231. package/dist/esm/CellTurn.js +3410 -0
  232. package/dist/esm/CellTurn.js.map +1 -0
  233. package/dist/esm/CellValidation.d.ts +94 -0
  234. package/dist/esm/CellValidation.d.ts.map +1 -0
  235. package/dist/esm/CellValidation.js +335 -0
  236. package/dist/esm/CellValidation.js.map +1 -0
  237. package/dist/esm/Compaction.d.ts +158 -0
  238. package/dist/esm/Compaction.d.ts.map +1 -0
  239. package/dist/esm/Compaction.js +216 -0
  240. package/dist/esm/Compaction.js.map +1 -0
  241. package/dist/esm/CompletionClaim.d.ts +801 -0
  242. package/dist/esm/CompletionClaim.d.ts.map +1 -0
  243. package/dist/esm/CompletionClaim.js +833 -0
  244. package/dist/esm/CompletionClaim.js.map +1 -0
  245. package/dist/esm/ContextWindow.d.ts +435 -0
  246. package/dist/esm/ContextWindow.d.ts.map +1 -0
  247. package/dist/esm/ContextWindow.js +427 -0
  248. package/dist/esm/ContextWindow.js.map +1 -0
  249. package/dist/esm/EngineLike.d.ts +546 -0
  250. package/dist/esm/EngineLike.d.ts.map +1 -0
  251. package/dist/esm/EngineLike.js +218 -0
  252. package/dist/esm/EngineLike.js.map +1 -0
  253. package/dist/esm/ExternalTranscript.d.ts +349 -0
  254. package/dist/esm/ExternalTranscript.d.ts.map +1 -0
  255. package/dist/esm/ExternalTranscript.js +987 -0
  256. package/dist/esm/ExternalTranscript.js.map +1 -0
  257. package/dist/esm/FailedCall.d.ts +132 -0
  258. package/dist/esm/FailedCall.d.ts.map +1 -0
  259. package/dist/esm/FailedCall.js +131 -0
  260. package/dist/esm/FailedCall.js.map +1 -0
  261. package/dist/esm/FlowBinding.d.ts +289 -0
  262. package/dist/esm/FlowBinding.d.ts.map +1 -0
  263. package/dist/esm/FlowBinding.js +376 -0
  264. package/dist/esm/FlowBinding.js.map +1 -0
  265. package/dist/esm/HarnessError.d.ts +57 -0
  266. package/dist/esm/HarnessError.d.ts.map +1 -0
  267. package/dist/esm/HarnessError.js +85 -0
  268. package/dist/esm/HarnessError.js.map +1 -0
  269. package/dist/esm/Judgement.d.ts +289 -0
  270. package/dist/esm/Judgement.d.ts.map +1 -0
  271. package/dist/esm/Judgement.js +305 -0
  272. package/dist/esm/Judgement.js.map +1 -0
  273. package/dist/esm/Monitor.d.ts +374 -0
  274. package/dist/esm/Monitor.d.ts.map +1 -0
  275. package/dist/esm/Monitor.js +370 -0
  276. package/dist/esm/Monitor.js.map +1 -0
  277. package/dist/esm/NarrowedCheck.d.ts +523 -0
  278. package/dist/esm/NarrowedCheck.d.ts.map +1 -0
  279. package/dist/esm/NarrowedCheck.js +612 -0
  280. package/dist/esm/NarrowedCheck.js.map +1 -0
  281. package/dist/esm/Notifications.d.ts +42 -0
  282. package/dist/esm/Notifications.d.ts.map +1 -0
  283. package/dist/esm/Notifications.js +215 -0
  284. package/dist/esm/Notifications.js.map +1 -0
  285. package/dist/esm/Plan.d.ts +127 -0
  286. package/dist/esm/Plan.d.ts.map +1 -0
  287. package/dist/esm/Plan.js +97 -0
  288. package/dist/esm/Plan.js.map +1 -0
  289. package/dist/esm/QuickJSSandbox.d.ts +151 -0
  290. package/dist/esm/QuickJSSandbox.d.ts.map +1 -0
  291. package/dist/esm/QuickJSSandbox.js +1364 -0
  292. package/dist/esm/QuickJSSandbox.js.map +1 -0
  293. package/dist/esm/Relevance.d.ts +213 -0
  294. package/dist/esm/Relevance.d.ts.map +1 -0
  295. package/dist/esm/Relevance.js +254 -0
  296. package/dist/esm/Relevance.js.map +1 -0
  297. package/dist/esm/Sandbox.d.ts +637 -0
  298. package/dist/esm/Sandbox.d.ts.map +1 -0
  299. package/dist/esm/Sandbox.js +464 -0
  300. package/dist/esm/Sandbox.js.map +1 -0
  301. package/dist/esm/Steering.d.ts +464 -0
  302. package/dist/esm/Steering.d.ts.map +1 -0
  303. package/dist/esm/Steering.js +193 -0
  304. package/dist/esm/Steering.js.map +1 -0
  305. package/dist/esm/StructuredOutput.d.ts +252 -0
  306. package/dist/esm/StructuredOutput.d.ts.map +1 -0
  307. package/dist/esm/StructuredOutput.js +430 -0
  308. package/dist/esm/StructuredOutput.js.map +1 -0
  309. package/dist/esm/Sufficiency.d.ts +195 -0
  310. package/dist/esm/Sufficiency.d.ts.map +1 -0
  311. package/dist/esm/Sufficiency.js +207 -0
  312. package/dist/esm/Sufficiency.js.map +1 -0
  313. package/dist/esm/Supervisor.d.ts +719 -0
  314. package/dist/esm/Supervisor.d.ts.map +1 -0
  315. package/dist/esm/Supervisor.js +575 -0
  316. package/dist/esm/Supervisor.js.map +1 -0
  317. package/dist/esm/Tokens.d.ts +86 -0
  318. package/dist/esm/Tokens.d.ts.map +1 -0
  319. package/dist/esm/Tokens.js +92 -0
  320. package/dist/esm/Tokens.js.map +1 -0
  321. package/dist/esm/Transcript.d.ts +171 -0
  322. package/dist/esm/Transcript.d.ts.map +1 -0
  323. package/dist/esm/Transcript.js +424 -0
  324. package/dist/esm/Transcript.js.map +1 -0
  325. package/dist/esm/TruncatedOutput.d.ts +186 -0
  326. package/dist/esm/TruncatedOutput.d.ts.map +1 -0
  327. package/dist/esm/TruncatedOutput.js +257 -0
  328. package/dist/esm/TruncatedOutput.js.map +1 -0
  329. package/dist/esm/UnmovedTree.d.ts +113 -0
  330. package/dist/esm/UnmovedTree.d.ts.map +1 -0
  331. package/dist/esm/UnmovedTree.js +90 -0
  332. package/dist/esm/UnmovedTree.js.map +1 -0
  333. package/dist/esm/UnresolvedFailure.d.ts +196 -0
  334. package/dist/esm/UnresolvedFailure.d.ts.map +1 -0
  335. package/dist/esm/UnresolvedFailure.js +218 -0
  336. package/dist/esm/UnresolvedFailure.js.map +1 -0
  337. package/dist/esm/VacuousVerification.d.ts +237 -0
  338. package/dist/esm/VacuousVerification.d.ts.map +1 -0
  339. package/dist/esm/VacuousVerification.js +245 -0
  340. package/dist/esm/VacuousVerification.js.map +1 -0
  341. package/dist/esm/VariablesPanel.d.ts +117 -0
  342. package/dist/esm/VariablesPanel.d.ts.map +1 -0
  343. package/dist/esm/VariablesPanel.js +142 -0
  344. package/dist/esm/VariablesPanel.js.map +1 -0
  345. package/dist/esm/index.d.ts +172 -0
  346. package/dist/esm/index.d.ts.map +1 -0
  347. package/dist/esm/index.js +172 -0
  348. package/dist/esm/index.js.map +1 -0
  349. package/dist/esm/internal/bytes.d.ts +36 -0
  350. package/dist/esm/internal/bytes.d.ts.map +1 -0
  351. package/dist/esm/internal/bytes.js +70 -0
  352. package/dist/esm/internal/bytes.js.map +1 -0
  353. package/dist/esm/internal/cellPrompt.d.ts +122 -0
  354. package/dist/esm/internal/cellPrompt.d.ts.map +1 -0
  355. package/dist/esm/internal/cellPrompt.js +276 -0
  356. package/dist/esm/internal/cellPrompt.js.map +1 -0
  357. package/dist/esm/internal/compactable.d.ts +44 -0
  358. package/dist/esm/internal/compactable.d.ts.map +1 -0
  359. package/dist/esm/internal/compactable.js +71 -0
  360. package/dist/esm/internal/compactable.js.map +1 -0
  361. package/dist/esm/internal/compactionMarks.d.ts +278 -0
  362. package/dist/esm/internal/compactionMarks.d.ts.map +1 -0
  363. package/dist/esm/internal/compactionMarks.js +317 -0
  364. package/dist/esm/internal/compactionMarks.js.map +1 -0
  365. package/dist/esm/internal/demandText.d.ts +95 -0
  366. package/dist/esm/internal/demandText.d.ts.map +1 -0
  367. package/dist/esm/internal/demandText.js +128 -0
  368. package/dist/esm/internal/demandText.js.map +1 -0
  369. package/dist/esm/internal/elide.d.ts +109 -0
  370. package/dist/esm/internal/elide.d.ts.map +1 -0
  371. package/dist/esm/internal/elide.js +123 -0
  372. package/dist/esm/internal/elide.js.map +1 -0
  373. package/dist/esm/internal/frame.d.ts +463 -0
  374. package/dist/esm/internal/frame.d.ts.map +1 -0
  375. package/dist/esm/internal/frame.js +861 -0
  376. package/dist/esm/internal/frame.js.map +1 -0
  377. package/dist/esm/internal/nonNegativeSafeInt.d.ts +20 -0
  378. package/dist/esm/internal/nonNegativeSafeInt.d.ts.map +1 -0
  379. package/dist/esm/internal/nonNegativeSafeInt.js +20 -0
  380. package/dist/esm/internal/nonNegativeSafeInt.js.map +1 -0
  381. package/dist/esm/internal/paidUsage.d.ts +52 -0
  382. package/dist/esm/internal/paidUsage.d.ts.map +1 -0
  383. package/dist/esm/internal/paidUsage.js +72 -0
  384. package/dist/esm/internal/paidUsage.js.map +1 -0
  385. package/dist/esm/internal/printChannel.d.ts +233 -0
  386. package/dist/esm/internal/printChannel.d.ts.map +1 -0
  387. package/dist/esm/internal/printChannel.js +376 -0
  388. package/dist/esm/internal/printChannel.js.map +1 -0
  389. package/dist/esm/internal/printsObservation.d.ts +26 -0
  390. package/dist/esm/internal/printsObservation.d.ts.map +1 -0
  391. package/dist/esm/internal/printsObservation.js +29 -0
  392. package/dist/esm/internal/printsObservation.js.map +1 -0
  393. package/dist/esm/internal/refusal.d.ts +40 -0
  394. package/dist/esm/internal/refusal.d.ts.map +1 -0
  395. package/dist/esm/internal/refusal.js +47 -0
  396. package/dist/esm/internal/refusal.js.map +1 -0
  397. package/dist/esm/internal/supervision.d.ts +174 -0
  398. package/dist/esm/internal/supervision.d.ts.map +1 -0
  399. package/dist/esm/internal/supervision.js +485 -0
  400. package/dist/esm/internal/supervision.js.map +1 -0
  401. package/dist/esm/internal/unfinishedWork.d.ts +99 -0
  402. package/dist/esm/internal/unfinishedWork.d.ts.map +1 -0
  403. package/dist/esm/internal/unfinishedWork.js +85 -0
  404. package/dist/esm/internal/unfinishedWork.js.map +1 -0
  405. package/dist/esm/internal/unobservedCall.d.ts +112 -0
  406. package/dist/esm/internal/unobservedCall.d.ts.map +1 -0
  407. package/dist/esm/internal/unobservedCall.js +501 -0
  408. package/dist/esm/internal/unobservedCall.js.map +1 -0
  409. package/dist/esm/internal/untrustedData.d.ts +14 -0
  410. package/dist/esm/internal/untrustedData.d.ts.map +1 -0
  411. package/dist/esm/internal/untrustedData.js +15 -0
  412. package/dist/esm/internal/untrustedData.js.map +1 -0
  413. package/docs/README.md +129 -0
  414. package/docs/api.md +1869 -0
  415. package/docs/concepts.md +238 -0
  416. package/docs/external-transcripts.md +245 -0
  417. package/docs/guides/bind-flows.md +167 -0
  418. package/docs/guides/drive-the-loop.md +265 -0
  419. package/docs/guides/run-cells.md +262 -0
  420. package/docs/guides/workerd.md +144 -0
  421. package/docs/installation.md +69 -0
  422. package/docs/quickstart.md +121 -0
  423. package/docs/reference.md +954 -0
  424. package/docs/troubleshooting.md +177 -0
  425. package/package.json +463 -3
  426. package/src/AgentEvent.ts +1772 -0
  427. package/src/CallLedger.ts +560 -0
  428. package/src/Cell.ts +926 -0
  429. package/src/CellCalls.ts +198 -0
  430. package/src/CellHistory.ts +128 -0
  431. package/src/CellTurn.ts +4450 -0
  432. package/src/CellValidation.ts +382 -0
  433. package/src/Compaction.ts +330 -0
  434. package/src/CompletionClaim.ts +1013 -0
  435. package/src/ContextWindow.ts +669 -0
  436. package/src/EngineLike.ts +614 -0
  437. package/src/ExternalTranscript.ts +1143 -0
  438. package/src/FailedCall.ts +163 -0
  439. package/src/FlowBinding.ts +603 -0
  440. package/src/HarnessError.ts +98 -0
  441. package/src/Judgement.ts +526 -0
  442. package/src/Monitor.ts +579 -0
  443. package/src/NarrowedCheck.ts +694 -0
  444. package/src/Notifications.ts +262 -0
  445. package/src/Plan.ts +113 -0
  446. package/src/QuickJSSandbox.ts +1557 -0
  447. package/src/Relevance.ts +352 -0
  448. package/src/Sandbox.ts +908 -0
  449. package/src/Steering.ts +405 -0
  450. package/src/StructuredOutput.ts +484 -0
  451. package/src/Sufficiency.ts +247 -0
  452. package/src/Supervisor.ts +798 -0
  453. package/src/Tokens.ts +108 -0
  454. package/src/Transcript.ts +513 -0
  455. package/src/TruncatedOutput.ts +297 -0
  456. package/src/UnmovedTree.ts +121 -0
  457. package/src/UnresolvedFailure.ts +240 -0
  458. package/src/VacuousVerification.ts +280 -0
  459. package/src/VariablesPanel.ts +165 -0
  460. package/src/index.ts +204 -0
  461. package/src/internal/bytes.ts +70 -0
  462. package/src/internal/cellPrompt.ts +337 -0
  463. package/src/internal/compactable.ts +76 -0
  464. package/src/internal/compactionMarks.ts +454 -0
  465. package/src/internal/demandText.ts +145 -0
  466. package/src/internal/elide.ts +130 -0
  467. package/src/internal/frame.ts +1178 -0
  468. package/src/internal/nonNegativeSafeInt.ts +24 -0
  469. package/src/internal/paidUsage.ts +90 -0
  470. package/src/internal/printChannel.ts +434 -0
  471. package/src/internal/printsObservation.ts +31 -0
  472. package/src/internal/refusal.ts +53 -0
  473. package/src/internal/supervision.ts +652 -0
  474. package/src/internal/unfinishedWork.ts +123 -0
  475. package/src/internal/unobservedCall.ts +536 -0
  476. package/src/internal/untrustedData.ts +19 -0
@@ -0,0 +1,694 @@
1
+ /**
2
+ * The narrowing ledger: which checks this run has run, and over which tree.
3
+ *
4
+ * A run finishes by claiming its work is done. The evidence for that claim is
5
+ * the checks it actually ran, and a check is only evidence for the tree it ran
6
+ * over. The failure this module names is a completion whose last check is a
7
+ * *narrowed* version of one the run had already run in full, taken after the
8
+ * workspace moved and never followed by the broad one: the narrow result is
9
+ * true, the broad one is unknown, and the run reports the unknown half as
10
+ * proven.
11
+ *
12
+ * It is not hypothetical, and it is not one instance's accident. On a graded
13
+ * benchmark the same run shape decided the same instance twice, in two
14
+ * consecutive waves, identically. The journal of the second reads: the run ran
15
+ * `pytest -rA testing/test_collection.py` in full, used its three failures to
16
+ * discard a wrong candidate, edited two source files, re-ran the *same command
17
+ * with a `-k` filter selecting four of seventy-two names* — "4 passed, 68
18
+ * deselected" — and completed on that frame. The graded patch passed both
19
+ * target tests and 144 of 145 neighbours; the one it broke was among the 68 the
20
+ * filter dropped, and the run had watched that exact test pass, on the exact
21
+ * command, before the change that broke it.
22
+ *
23
+ * The harness does not re-run anything to find this out. It compares two things
24
+ * it already records — the input of every call, and the workspace digest each
25
+ * frame closed on — and hands the run one sentence naming the check it is
26
+ * missing. What the run does with that is the run's business: re-run the broad
27
+ * check, or say why it no longer applies. The loop asks once and accepts what
28
+ * comes back, because a harness that verified completions itself would be
29
+ * grading the agent's work with its own, and that hack was removed on purpose.
30
+ *
31
+ * The module names two shapes of the same failure, and the second is here
32
+ * because the first was escaped from the other side. {@link find} is
33
+ * broad-then-narrow, above. {@link findOnly} is narrow-only: the next wave of
34
+ * the same instance ran a filtered reading of the right file, ran nothing else,
35
+ * and completed — so there was no broader check in the ledger and nothing to
36
+ * narrow. Both readings deselected the one neighbour the patch broke.
37
+ *
38
+ * @since 0.1.0
39
+ */
40
+
41
+ import * as CanonicalJson from "@smthrs/model/CanonicalJson"
42
+ import { Effect, Schema } from "effect"
43
+ import * as DemandText from "./internal/demandText.ts"
44
+ import * as elide from "./internal/elide.ts"
45
+
46
+ /**
47
+ * How many distinct checks one run carries forward.
48
+ *
49
+ * The ledger is controller state, so it is bounded. Thirty-two covers a whole
50
+ * run at the rate a graded wave actually calls flows — its longest run issued
51
+ * 43 calls across 24 frames, most of them reads of one file — so the broad
52
+ * check a run ran early is still recognisable when it completes. A run that
53
+ * outlives the bound forgets its oldest checks first, which can cost a demand
54
+ * and can never invent one.
55
+ *
56
+ * @category constants
57
+ * @since 0.1.0
58
+ */
59
+ export const retained = 32
60
+
61
+ /**
62
+ * Most distinct terms one recorded check may carry.
63
+ *
64
+ * A ledger entry stores the terms of a call's input, so an input that is mostly
65
+ * *content* — a patch, a file body, a generated document — would store that
66
+ * content twice over. Such a call is also not a check anybody narrows: nothing
67
+ * re-runs a file write with an added filter. The largest input any flow issued
68
+ * across five graded runs carried 119 terms, so the bound is more than twice
69
+ * the observed ceiling and drops only inputs that are payloads.
70
+ *
71
+ * @category constants
72
+ * @since 0.1.0
73
+ */
74
+ export const maxTerms = 256
75
+
76
+ /**
77
+ * Characters that are part of a term; everything else separates two.
78
+ *
79
+ * The set keeps together every shape that names one thing — `src/_pytest/main.py`,
80
+ * `-rA`, `--include=*.py` minus its glob, a version, a container name — and cuts
81
+ * at whitespace, quotes, brackets, colons, and JSON punctuation. It is the only
82
+ * lexical assumption in this module, and it is about text rather than about any
83
+ * tool: nothing here knows what a test runner, a flag, or a path is.
84
+ *
85
+ * A colon separates because it is what joins a target to a selector inside it —
86
+ * a test id, a line number, a range. Cutting there leaves the file as a target
87
+ * and the selector as an added condition, which is what selecting one case out
88
+ * of a file is; keeping them together would make the pair a target of its own
89
+ * and the narrowing invisible.
90
+ */
91
+ const separator = /[^A-Za-z0-9_./@+-]+/
92
+
93
+ /**
94
+ * How many UTF-8 bytes of a check's input the demand may quote back.
95
+ *
96
+ * The demand has to name the check the run is missing, and a name it cannot
97
+ * read is not a name. Bounded because the label lives in controller state,
98
+ * once per retained entry. The honest-elision notice may exceed this content
99
+ * bound so it can say how many bytes are missing and where the whole input is.
100
+ *
101
+ * @category constants
102
+ * @since 1.0.0-rc.0
103
+ */
104
+ export const labelWidth = 512
105
+
106
+ /**
107
+ * An input as its label quotes it: canonical JSON, except that an object's
108
+ * longest string member comes last.
109
+ *
110
+ * The label is clipped to {@link labelWidth}, and a call routed into a task
111
+ * container carries its route beside its program. For a `script` the route
112
+ * already sorts first; for a `command` it sorts after the program and the clip
113
+ * can take the route. Two graded runs of 2026-09-26 listed their scripts as
114
+ * the route plus the first two hundred bytes of the program. So the short
115
+ * members, the route among them, come first in every input, and the longest
116
+ * string, which is the program in every such input, fills the rest of a wider
117
+ * label.
118
+ *
119
+ * @category conversions
120
+ * @since 1.0.0-rc.0
121
+ */
122
+ export const label = (input: Schema.Json): string => {
123
+ if (input === null || typeof input !== "object" || Array.isArray(input)) return CanonicalJson.stringify(input)
124
+ const record = input as Readonly<Record<string, Schema.Json>>
125
+ let last: string | undefined
126
+ for (const [key, value] of Object.entries(record)) {
127
+ if (typeof value !== "string") continue
128
+ const current = last === undefined ? undefined : record[last]
129
+ if (typeof current !== "string" || value.length > current.length) last = key
130
+ }
131
+ if (last === undefined) return CanonicalJson.stringify(input)
132
+ const rest = CanonicalJson.stringify(Object.fromEntries(Object.entries(record).filter(([key]) => key !== last)))
133
+ const tail = `${JSON.stringify(last)}:${CanonicalJson.stringify(record[last]!)}`
134
+ return rest === "{}" ? `{${tail}}` : `${rest.slice(0, -1)},${tail}}`
135
+ }
136
+
137
+ /**
138
+ * Whether a term names a target rather than a condition.
139
+ *
140
+ * The distinction is what keeps {@link narrows} one-directional. A call that
141
+ * repeats every term of an earlier call and adds a *condition* — a filter, a
142
+ * selector, a flag — asks for a subset of what the earlier call covered. A call
143
+ * that adds a *target* asks about something the earlier call never looked at,
144
+ * which is a broader question, not a narrower one; running two files where one
145
+ * ran before is not a narrowing and must not be demanded as one.
146
+ *
147
+ * A term is read as a target when it carries a separator inside it — a slash or
148
+ * a dot. That covers paths, file names, dotted module names, and node ids, and
149
+ * it reads a version number or a decimal as a target too. Both errors are in
150
+ * the same direction: a term wrongly read as a target suppresses a demand, and
151
+ * a demand this module does not issue costs nothing.
152
+ *
153
+ * Exported because `UnresolvedFailure` asks a different question of the same
154
+ * distinction — whether a later call came back to what an earlier one was about
155
+ * — and a second copy of this predicate would be a second thing to keep true.
156
+ *
157
+ * @category predicates
158
+ * @since 0.1.0
159
+ */
160
+ export const targeting = (term: string): boolean => term.includes("/") || term.includes(".")
161
+
162
+ /**
163
+ * A separator with a real character on both sides of it.
164
+ *
165
+ * {@link targeting} accepts any term carrying a slash or a dot, which is the
166
+ * right rule for {@link narrows} — a term wrongly read as a target only
167
+ * suppresses a demand there. The predicate below needs the stricter one.
168
+ */
169
+ const anchored = /[A-Za-z0-9_@+-][./][A-Za-z0-9_@+-]/
170
+
171
+ /**
172
+ * Whether a term names a target a reader would recognise as one.
173
+ *
174
+ * {@link targeting} is the relation's own rule and is deliberately generous:
175
+ * `.py`, `/`, and a bare `tests/` all satisfy it, and each of them only ever
176
+ * costs a demand. Two callers need the answer to a different question — which
177
+ * of a call's terms is the thing it is *about* — and for that a term nobody can
178
+ * read is worse than no term at all. This is that stricter reading: the
179
+ * separator has a real character on both sides, so `tests/test_a.py` and
180
+ * `django.contrib.admin.sites` qualify while a glob's leftover `/` and a bare
181
+ * `.py` do not.
182
+ *
183
+ * One lexical rule, not two: `CallLedger` names a call's subject with it and
184
+ * {@link findOnly} reads a check's subjects with it.
185
+ *
186
+ * @category predicates
187
+ * @since 0.1.0
188
+ */
189
+ export const names = (term: string): boolean => targeting(term) && anchored.test(term)
190
+
191
+ /**
192
+ * The terms of one call input in the order the canonical document states them.
193
+ *
194
+ * The whole canonical input is lexed, keys included, so the relation works for
195
+ * a shell command, a structured search, and any host flow this harness has
196
+ * never heard of.
197
+ *
198
+ * Exported in document order because `CallLedger` asks a positional question of
199
+ * the same lexer — which term this call is *about*, which is the first one that
200
+ * {@link targeting} accepts — and a second copy of the separator would be a
201
+ * second thing to keep true. {@link terms} is the set view of the same lex.
202
+ *
203
+ * @category conversions
204
+ * @since 0.1.0
205
+ */
206
+ export const lex = (input: Schema.Json): ReadonlyArray<string> =>
207
+ CanonicalJson.stringify(input).split(separator).filter((term) => term.length > 0)
208
+
209
+ /**
210
+ * The distinct terms of one call input, sorted.
211
+ *
212
+ * Sorted and de-duplicated because the only questions asked of it are set
213
+ * questions.
214
+ *
215
+ * @category conversions
216
+ * @since 0.1.0
217
+ */
218
+ export const terms = (input: Schema.Json): ReadonlyArray<string> => [...new Set(lex(input))].sort()
219
+
220
+ /** A term that is only digits: a magnitude, never a name. */
221
+ const numeral = /^[0-9]+$/
222
+
223
+ /** Every key name the input document carries, at any depth. */
224
+ const structure = (input: Schema.Json, into: Set<string>): Set<string> => {
225
+ if (Array.isArray(input)) { for (const item of input) structure(item, into) }
226
+ else if (input !== null && typeof input === "object") {
227
+ for (const [key, item] of Object.entries(input)) {
228
+ into.add(key)
229
+ structure(item, into)
230
+ }
231
+ }
232
+ return into
233
+ }
234
+
235
+ /**
236
+ * The terms of one call input that could be conditions its author added.
237
+ *
238
+ * The whole document is lexed, so three kinds of term come out of the lexer
239
+ * that are part of how the call is *written* rather than a constraint on what
240
+ * it covers, and each is removed here:
241
+ *
242
+ * - a term that names a target ({@link targeting}) is what the call is about,
243
+ * not a condition on it;
244
+ * - a term that is a key of the input document itself is the call's shape —
245
+ * `command`, `timeoutMs` — which the author fills in, not adds;
246
+ * - a term that is only digits is a magnitude — a timeout, a limit, an offset
247
+ * — and a condition that subsets a check names cases rather than counting
248
+ * them. The flag carrying such a number is still read as a condition, so a
249
+ * stop-early flag does not hide behind its argument.
250
+ *
251
+ * All three exclusions err in one direction: a term wrongly removed here can
252
+ * suppress a demand and can never invent one.
253
+ *
254
+ * @category conversions
255
+ * @since 0.1.0
256
+ */
257
+ export const conditions = (input: Schema.Json): ReadonlyArray<string> => {
258
+ const keys = structure(input, new Set())
259
+ return terms(input).filter((term) => !targeting(term) && !keys.has(term) && !numeral.test(term))
260
+ }
261
+
262
+ /**
263
+ * One check this run has run, and the tree it ran over.
264
+ *
265
+ * A call becomes a check when it settled successfully and declared no write.
266
+ * "Successfully" is about the call and not about the result: a command that
267
+ * exits non-zero settled successfully, and its output — clean or informative —
268
+ * is exactly what a run reads before deciding what to change. The graded run
269
+ * this module was built from used the three failures its broad check reported
270
+ * to discard a wrong candidate; a rule that only remembered green checks would
271
+ * have forgotten the most useful thing that run ever ran. A call the flow could
272
+ * not run at all observed nothing, and a call that changes the workspace is not
273
+ * an observation of it.
274
+ *
275
+ * @category models
276
+ * @since 0.1.0
277
+ */
278
+ export class Check extends Schema.Class<Check>("flows/harness/NarrowedCheck/Check")({
279
+ /** The flow the call named. */
280
+ flow: Schema.String,
281
+ /** The call's identity, as the controller's own signature names it. */
282
+ signature: Schema.String,
283
+ /** The distinct terms of the call's input, sorted; see {@link terms}. */
284
+ terms: Schema.Array(Schema.String),
285
+ /**
286
+ * The subset of {@link Check.terms} that could be conditions the call's
287
+ * author added; see {@link conditions}.
288
+ *
289
+ * Stored rather than recomputed because it is a fact about the input
290
+ * document — its key names — and the ledger keeps terms, not documents.
291
+ * Defaults empty, so an entry journaled before the field decodes; the only
292
+ * reader is {@link findOnly}, where an empty set means the check carries no
293
+ * added condition, which suppresses a demand and never invents one.
294
+ */
295
+ conditions: Schema.Array(Schema.String).pipe(
296
+ Schema.withConstructorDefault(Effect.succeed<ReadonlyArray<string>>([])),
297
+ Schema.withDecodingDefaultKey(Effect.succeed<ReadonlyArray<string>>([]))
298
+ ),
299
+ /**
300
+ * Content address of the workspace the frame that ran this check closed on.
301
+ *
302
+ * The *closing* digest, and not the opening one, because a frame's calls are
303
+ * not ordered against its edits in anything the harness records. A check that
304
+ * ran in the same frame as an edit is therefore stamped as if it ran after
305
+ * that edit, which reads a stale check as current and suppresses a demand.
306
+ * Conservative on purpose: the whole module errs towards asking nothing.
307
+ *
308
+ * Empty when the frame had no complete measurement to stamp it with, which
309
+ * makes the entry inert — an unmeasured tree cannot say anything moved.
310
+ */
311
+ digest: Schema.String,
312
+ /** The call's input as it was written, clipped, for the demand to quote. */
313
+ label: Schema.String,
314
+ /**
315
+ * Whether the call's own result reported a failing exit status.
316
+ *
317
+ * Nothing in this module reads it: a check that reported failures is exactly
318
+ * as good evidence of what the tree does as one that reported none, and the
319
+ * narrowing relation is about the shape of a question rather than its answer.
320
+ * It is recorded here because `UnresolvedFailure` asks about the answer, and
321
+ * two ledgers over the same calls would be two things to keep true. See
322
+ * `UnresolvedFailure` `failed` for what "reported" means, and why a flow that
323
+ * declares no exit status is neither failing nor passing.
324
+ */
325
+ failing: Schema.Boolean.pipe(
326
+ Schema.withConstructorDefault(Effect.succeed(false)),
327
+ Schema.withDecodingDefaultKey(Effect.succeed(false))
328
+ ),
329
+ /**
330
+ * Whether the call's own result reported a passing exit status.
331
+ *
332
+ * Not the negation of {@link Check.failing}, and that is the whole reason it
333
+ * is a second field: a flow that reports no exit status at all — a read, a
334
+ * search — is neither failing nor passing, and reading its silence as a pass
335
+ * would let `Sufficiency` build a completion signal out of a file read. Both
336
+ * default false, so a result that says nothing about a subject says nothing
337
+ * here either. See `UnresolvedFailure` `passed`.
338
+ */
339
+ passing: Schema.Boolean.pipe(
340
+ Schema.withConstructorDefault(Effect.succeed(false)),
341
+ Schema.withDecodingDefaultKey(Effect.succeed(false))
342
+ ),
343
+ /**
344
+ * Whether {@link Check.digest} is the tree this check actually read.
345
+ *
346
+ * A check is stamped with its frame's closing digest, and a frame may both
347
+ * edit and check. The frame's writes are calls, though, and calls settle in
348
+ * order, so the question has an answer rather than a guess: a check with no
349
+ * standing write after it read the tree the frame closed on and is stable; a
350
+ * check with a write after it read a tree that is gone and is not. A frame
351
+ * whose measurement moved with no call declaring it — a shell redirect —
352
+ * cannot place the move among its calls at all, so nothing in it is stable.
353
+ *
354
+ * What it buys each reader: for {@link find} an unstable reading is a stale
355
+ * check read as current, which costs a demand; for a *failure* carried by
356
+ * one the stamp would attribute a result to a tree the check never ran over,
357
+ * so `UnresolvedFailure` requires this. A reading attributed to a checkpoint
358
+ * is stable by pin rather than by position.
359
+ */
360
+ stable: Schema.Boolean.pipe(
361
+ Schema.withConstructorDefault(Effect.succeed(false)),
362
+ Schema.withDecodingDefaultKey(Effect.succeed(false))
363
+ )
364
+ }) {}
365
+
366
+ /**
367
+ * A check this frame ran, paired with the broader one it stands in for.
368
+ *
369
+ * @category models
370
+ * @since 0.1.0
371
+ */
372
+ export interface Narrowing {
373
+ /** The broader check, last run over a tree that has since changed. */
374
+ readonly earlier: Check
375
+ /** This frame's check, which repeats it and adds conditions. */
376
+ readonly later: Check
377
+ }
378
+
379
+ /**
380
+ * Records one settled call as a check, unless its input is a payload.
381
+ *
382
+ * `undefined` is not a failure: it is an input with more distinct terms than
383
+ * {@link maxTerms}, which is a call carrying content rather than a question.
384
+ *
385
+ * @category constructors
386
+ * @since 0.1.0
387
+ */
388
+ export const check = (options: {
389
+ readonly flow: string
390
+ readonly signature: string
391
+ readonly input: Schema.Json
392
+ readonly digest: string
393
+ /** Whether the call's result reported a failing exit status. */
394
+ readonly failing?: boolean | undefined
395
+ /** Whether the call's result reported a passing exit status. */
396
+ readonly passing?: boolean | undefined
397
+ /** Whether the frame that ran it left the workspace as it found it. */
398
+ readonly stable?: boolean | undefined
399
+ }): Check | undefined => {
400
+ const collected = terms(options.input)
401
+ if (collected.length > maxTerms) return undefined
402
+ return new Check({
403
+ flow: options.flow,
404
+ signature: options.signature,
405
+ terms: collected,
406
+ conditions: conditions(options.input),
407
+ digest: options.digest,
408
+ label: elide.head(
409
+ label(options.input),
410
+ labelWidth,
411
+ "the issuing cell in the run record has the whole input"
412
+ ),
413
+ failing: options.failing ?? false,
414
+ passing: options.passing ?? false,
415
+ stable: options.stable ?? false
416
+ })
417
+ }
418
+
419
+ /**
420
+ * Whether one call's terms are a strict narrowing of another's.
421
+ *
422
+ * The relation is: every term the earlier call carried is carried again, at
423
+ * least one term is added, and no added term names a target
424
+ * ({@link targeting}). In words — same question, more conditions on it. It is
425
+ * deliberately syntactic. It parses no flag, knows no test runner, and would
426
+ * hold identically for a search flow, a linter, or a host flow written after
427
+ * this one; the moment it started reading `-k` it would be a rule about pytest
428
+ * rather than a rule about evidence.
429
+ *
430
+ * @category predicates
431
+ * @since 0.1.0
432
+ */
433
+ export const narrows = (
434
+ later: ReadonlyArray<string>,
435
+ earlier: ReadonlyArray<string>
436
+ ): boolean => {
437
+ const carried = new Set(later)
438
+ for (const term of earlier) if (!carried.has(term)) return false
439
+ const known = new Set(earlier)
440
+ let added = false
441
+ for (const term of later) {
442
+ if (known.has(term)) continue
443
+ if (targeting(term)) return false
444
+ added = true
445
+ }
446
+ return added
447
+ }
448
+
449
+ /**
450
+ * Finds the broadest check a completing frame narrowed and did not re-run.
451
+ *
452
+ * All four conditions have to hold, and each of them is read off something the
453
+ * harness already records rather than off anything a cell said about itself:
454
+ *
455
+ * 1. the frame closed on a complete measurement, so a digest means something;
456
+ * 2. some earlier check was last run over a *different* tree, which is what
457
+ * "you have changed something since" means with no timestamps involved;
458
+ * 3. this frame issued no call with that check's exact signature, so the run
459
+ * did not simply re-run it here;
460
+ * 4. some call this frame issued names the same flow and {@link narrows} it.
461
+ *
462
+ * The broadest such earlier check wins — fewest terms, which under this
463
+ * module's own relation is the least constrained question — so the demand names
464
+ * the strongest evidence the completion is missing rather than the first one
465
+ * found. Ties go to the more recently run check.
466
+ *
467
+ * @category conversions
468
+ * @since 0.1.0
469
+ */
470
+ export const find = (options: {
471
+ /** Checks this run ran before this frame, oldest first. */
472
+ readonly ledger: ReadonlyArray<Check>
473
+ /** Checks this frame ran. */
474
+ readonly frame: ReadonlyArray<Check>
475
+ /** The workspace digest this frame closed on; empty when unmeasured. */
476
+ readonly digest: string
477
+ }): Narrowing | undefined => {
478
+ if (options.digest === "") return undefined
479
+ const reran = new Set(options.frame.map((entry) => entry.signature))
480
+ let found: Narrowing | undefined = undefined
481
+ for (const earlier of options.ledger) {
482
+ if (reran.has(earlier.signature)) continue
483
+ if (earlier.digest === "") continue
484
+ if (earlier.digest === options.digest) continue
485
+ if (found !== undefined && found.earlier.terms.length < earlier.terms.length) continue
486
+ for (const later of options.frame) {
487
+ if (later.flow !== earlier.flow) continue
488
+ if (!narrows(later.terms, earlier.terms)) continue
489
+ found = { earlier, later }
490
+ break
491
+ }
492
+ }
493
+ return found
494
+ }
495
+
496
+ /**
497
+ * States which check a completion is standing on, and which one it is missing.
498
+ *
499
+ * The text asks for a decision and names both ways out as equals, in the shape
500
+ * the read-only demand already uses: re-run the check that was skipped, or say
501
+ * why it does not apply. It never asserts the run is wrong — a filter can be
502
+ * the right check after a change that removed cases — it asserts only what is
503
+ * true from the record: the broad result the run is relying on was measured on
504
+ * a tree that no longer exists.
505
+ *
506
+ * It also says plainly that nothing re-runs the check for the run, and that the
507
+ * next answer stands. Anything softer invites a re-submission of the same
508
+ * frame; anything harder would be the harness pretending it will keep score.
509
+ *
510
+ * @category constructors
511
+ * @since 0.1.0
512
+ */
513
+ export const demand = (found: Narrowing): string =>
514
+ DemandText.narrowed(found.earlier.flow, found.earlier.label, found.later.label)
515
+
516
+ /**
517
+ * The reading a completion stands on, when the run holds no other reading of
518
+ * what it names.
519
+ *
520
+ * @category models
521
+ * @since 0.1.0
522
+ */
523
+ export interface Only {
524
+ /** The last check the completing frame ran. */
525
+ readonly later: Check
526
+ /** The subjects it names, as {@link names} reads them, sorted. */
527
+ readonly targets: ReadonlyArray<string>
528
+ }
529
+
530
+ /**
531
+ * Finds a completion standing on the run's only reading of its own subjects.
532
+ *
533
+ * {@link find} names the completion whose check *narrows* an earlier, broader
534
+ * one. This names the case that escapes it from the other side: a completion
535
+ * whose check narrows nothing because the run never took the broader reading at
536
+ * all. On a graded benchmark the same instance was lost both ways in two
537
+ * consecutive waves — one run took a broad reading of the wrong file, the next
538
+ * took a filtered reading of the right one and ran nothing else — and the
539
+ * second escaped {@link find} because there was nothing in the ledger to
540
+ * narrow. The filtered reading deselected the one neighbour the patch broke.
541
+ *
542
+ * The harness cannot see that a filter is a filter without learning one test
543
+ * runner's flags, so it does not try. It asks the question the record can
544
+ * answer: is this reading the only one this run has of what it names, and does
545
+ * it carry a phrase this run alone put there.
546
+ *
547
+ * Five conditions, each read off the run's own record:
548
+ *
549
+ * 1. the completing frame ran at least one check, and the subject is its
550
+ * *last* one — the reading the completion stands closest to, as
551
+ * `UnresolvedFailure` reads its own ledger;
552
+ * 2. that check names at least one subject ({@link names}) and carries at
553
+ * least one condition ({@link conditions}) the run itself added: a term
554
+ * that is not in the text the run was handed (`taught`) and not in any
555
+ * other check the run has made. A term the harness taught the run — the
556
+ * runner its task names, a flag the task prescribes, an envelope value its
557
+ * own example shows — is the run doing as it was told, and a term the run
558
+ * uses in its other checks is how this run phrases a question. Neither is
559
+ * a condition this check put on its subjects, and a check whose every
560
+ * non-target term is accounted for one of those two ways carries nothing
561
+ * the demand could ask to see removed;
562
+ * 3. the run never ran this exact call before this frame. A call replayed from
563
+ * an earlier frame is the run's own baseline re-run byte for byte, which is
564
+ * the discipline the contract asks for and the opposite of the failure here;
565
+ * 4. every subject it names is named by some other check of this run, so these
566
+ * are subjects the run has been working on rather than a container path or a
567
+ * scratch directory that one command creates and uses;
568
+ * 5. no other check of this run names all of them together, so nothing in the
569
+ * record says what they report as one.
570
+ *
571
+ * ## What it deliberately cannot see
572
+ *
573
+ * Conditions 4 and 5 together mean a check naming exactly *one* subject is
574
+ * never named: if the run read that subject anywhere else, that reading covers
575
+ * this one, and if it did not, there is nothing to corroborate against. So the
576
+ * demand is about a *combination* the run has read only through one command,
577
+ * and a single filtered file with no other mention of the file in the run goes
578
+ * unremarked.
579
+ *
580
+ * That is a chosen floor rather than an oversight. Three benchmark waves
581
+ * produced fifteen completions between them, and the shapes are not separable
582
+ * above it: the losing run's `check <file> -k "<two cases>"` and a resolved
583
+ * run's `check <file-a> <file-b>` differ only in what the flag means, which is
584
+ * a fact about one test runner. Every weaker condition tried against those
585
+ * fifteen runs fired on one or both of the two best rounds the harness has ever
586
+ * scored — a demand costing a correct round a frame to ask about a check that
587
+ * carries no condition at all. This one speaks once, to the run that lost its
588
+ * instance to a filter, naming the command that carried it, and says nothing to
589
+ * the other fourteen.
590
+ *
591
+ * Condition 2's second half was measured in, not reasoned in. The r97 wave
592
+ * fired this demand five times: twice on completions standing on a `-k`
593
+ * filter — the failure the module exists to catch — and three times on runs
594
+ * whose last check ran a whole test module exactly as their task text
595
+ * prescribed, `<interpreter> -m <runner> <flag> <file>`. Each of those three
596
+ * answered the demand by re-issuing the identical completion with a sentence
597
+ * saying the check carried no filter, and each was accepted: the demand
598
+ * taught the harness nothing and cost a correct run one full-context frame.
599
+ * What separates the five in the record is exactly condition 2: every
600
+ * non-target term of the three was taught by the run's own prompt, part of
601
+ * the input's own shape, or already in the run's other checks, and the two
602
+ * that deserved the demand each carried a filter phrase found nowhere else in
603
+ * the run. The residual errors both suppress: a run whose task text happens
604
+ * to contain a term it later uses as a filter, or whose earlier checks
605
+ * carried the same filter flag over other subjects, completes unasked — and a
606
+ * demand this module does not issue costs nothing.
607
+ *
608
+ * @category conversions
609
+ * @since 0.1.0
610
+ */
611
+ export const findOnly = (options: {
612
+ /** Every check this run has run, this frame's included, oldest first. */
613
+ readonly ledger: ReadonlyArray<Check>
614
+ /** Signatures the run had already issued before this frame. */
615
+ readonly before: ReadonlyArray<string>
616
+ /** Checks this frame ran, in the order they settled. */
617
+ readonly frame: ReadonlyArray<Check>
618
+ /**
619
+ * The distinct terms of the text the run was handed — its teaching, its
620
+ * catalog, its task — as {@link terms} lexes it.
621
+ *
622
+ * The prefix of the run's own context window is that text and nothing else:
623
+ * nothing model-authored lands there, so a run cannot teach itself a term
624
+ * by using it.
625
+ */
626
+ readonly taught: ReadonlyArray<string>
627
+ }): Only | undefined => {
628
+ const later = options.frame[options.frame.length - 1]
629
+ if (later === undefined) return undefined
630
+ const targets = later.terms.filter(names)
631
+ if (targets.length === 0) return undefined
632
+ if (later.conditions.length === 0) return undefined
633
+ if (options.before.includes(later.signature)) return undefined
634
+ const others = options.ledger.filter((entry) => entry.signature !== later.signature)
635
+ const covered = others.some((entry) => targets.every((target) => entry.terms.includes(target)))
636
+ if (covered) return undefined
637
+ const known = targets.every((target) => others.some((entry) => entry.terms.includes(target)))
638
+ if (!known) return undefined
639
+ const excused = new Set(options.taught)
640
+ for (const entry of others) for (const term of entry.terms) excused.add(term)
641
+ if (!later.conditions.some((term) => !excused.has(term))) return undefined
642
+ return { later, targets }
643
+ }
644
+
645
+ /**
646
+ * States that the completion has one reading of its subjects, and asks for the
647
+ * other one.
648
+ *
649
+ * It quotes the check, names the subjects, and says exactly what the record
650
+ * establishes: no other call of this run covers them. It does not claim the
651
+ * reading is filtered — the harness cannot read a flag — so it names what a
652
+ * condition is and leaves the run to say whether it has one. The two ways out
653
+ * are equals, as they are in every demand here, and the second answer stands.
654
+ *
655
+ * @category constructors
656
+ * @since 0.1.0
657
+ */
658
+ export const demandOnly = (found: Only): string =>
659
+ DemandText.narrowOnly(found.later.flow, found.later.label, found.targets)
660
+
661
+ /**
662
+ * Folds this frame's checks into the run's ledger, newest last and bounded.
663
+ *
664
+ * A repeated signature moves to the newest position rather than taking a second
665
+ * slot, so a run looping on one command cannot push the broad check it ran
666
+ * early out of the ledger — and its digest is restamped, which is how re-running
667
+ * a check answers the demand it caused.
668
+ *
669
+ * @category conversions
670
+ * @since 0.1.0
671
+ */
672
+ export const remember = (
673
+ ledger: ReadonlyArray<Check>,
674
+ added: ReadonlyArray<Check>
675
+ ): ReadonlyArray<Check> => {
676
+ const newest = new Map(ledger.map((entry) => [entry.signature, entry]))
677
+ for (const entry of added) {
678
+ newest.delete(entry.signature)
679
+ newest.set(entry.signature, entry)
680
+ }
681
+ const distinct = [...newest.values()]
682
+ return distinct.slice(Math.max(0, distinct.length - retained))
683
+ }
684
+
685
+ /**
686
+ * The ledger schema carried in controller state.
687
+ *
688
+ * @category schemas
689
+ * @since 0.1.0
690
+ */
691
+ export const Ledger = Schema.Array(Check).pipe(
692
+ Schema.withConstructorDefault(Effect.succeed<ReadonlyArray<Check>>([])),
693
+ Schema.withDecodingDefaultKey(Effect.succeed<ReadonlyArray<Check>>([]))
694
+ )