@wenathlan/devthink 2.0.14 → 2.0.19

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 (444) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/{dist/bridge.d.ts → bridge.d.ts} +1 -1
  3. package/bridge.d.ts.map +1 -0
  4. package/bridge.js +1877 -0
  5. package/bun.d.ts.map +1 -0
  6. package/bun.js +52329 -0
  7. package/caps/background.json +712 -0
  8. package/caps/cli.json +360 -0
  9. package/caps/library.json +3611 -0
  10. package/caps/mcp.json +126 -0
  11. package/caps/pagebridge.json +377 -0
  12. package/caps/popup.json +51 -0
  13. package/caps/sidepanel.json +522 -0
  14. package/checksums.txt +142 -0
  15. package/cli.d.ts.map +1 -0
  16. package/{dist/cli.js → cli.js} +2 -2
  17. package/companion.d.ts.map +1 -0
  18. package/companion.js +389 -0
  19. package/crossbrowser.d.ts.map +1 -0
  20. package/crossbrowser.js +1191 -0
  21. package/dashdone.d.ts.map +1 -0
  22. package/dashdone.js +368 -0
  23. package/deno.d.ts.map +1 -0
  24. package/deno.js +52325 -0
  25. package/devthink.umd.js +52346 -0
  26. package/fixtures/bun.ts +7 -0
  27. package/fixtures/cjs.js +6 -0
  28. package/fixtures/deno.ts +6 -0
  29. package/fixtures/example-org-pagestate.json +22 -0
  30. package/fixtures/importers/automa-workflow.json +18 -0
  31. package/fixtures/importers/selenium-side.json +20 -0
  32. package/fixtures/importers/tabular-plan.csv +7 -0
  33. package/fixtures/importers/uivision-macro.json +10 -0
  34. package/fixtures/importers/v1-plan.json +13 -0
  35. package/fixtures/mcp-client.mjs +14 -0
  36. package/fixtures/pages/checkout.html +192 -0
  37. package/fixtures/pages/dashboard.html +110 -0
  38. package/fixtures/pages/feed.html +113 -0
  39. package/fixtures/pages/product-grid.html +150 -0
  40. package/fixtures/plans/form-inventory-plan.json +11 -0
  41. package/fixtures/plans/release-notes-plan.json +11 -0
  42. package/fixtures/recipes/agentscompete.json +11 -0
  43. package/fixtures/recipes/agentsforms.json +11 -0
  44. package/fixtures/recipes/agentsmonitor.json +11 -0
  45. package/fixtures/recipes/agentsreview.json +29 -0
  46. package/fixtures/recipes/agentswarm.json +11 -0
  47. package/fixtures/recipes/fillcalendar.json +12 -0
  48. package/fixtures/recipes/fillcheckout.json +13 -0
  49. package/fixtures/recipes/filldependentdropdowns.json +12 -0
  50. package/fixtures/recipes/fillfromcsv.json +13 -0
  51. package/fixtures/recipes/fillloginform.json +12 -0
  52. package/fixtures/recipes/fillmultistepwizard.json +13 -0
  53. package/fixtures/recipes/fillregistration.json +12 -0
  54. package/fixtures/recipes/fillsearchfilters.json +12 -0
  55. package/fixtures/recipes/filltypeahead.json +11 -0
  56. package/fixtures/recipes/monitoralerts.json +12 -0
  57. package/fixtures/recipes/monitoravailability.json +11 -0
  58. package/fixtures/recipes/monitornetworkquiet.json +12 -0
  59. package/fixtures/recipes/monitorpagechanges.json +11 -0
  60. package/fixtures/recipes/monitorpricechange.json +11 -0
  61. package/fixtures/recipes/monitorschedule.json +12 -0
  62. package/fixtures/recipes/scrapedynamicprices.json +13 -0
  63. package/fixtures/recipes/scrapeimagegallery.json +12 -0
  64. package/fixtures/recipes/scrapeinfinitefeed.json +13 -0
  65. package/fixtures/recipes/scrapenestedlists.json +12 -0
  66. package/fixtures/recipes/scrapeproductgrid.json +12 -0
  67. package/fixtures/recipes/scrapereviews.json +12 -0
  68. package/fixtures/recipes/scrapesearchresults.json +12 -0
  69. package/fixtures/recipes/scrapetablepagination.json +12 -0
  70. package/fixtures/recipes/testaccessibility.json +34 -0
  71. package/fixtures/recipes/testconsoleerrors.json +12 -0
  72. package/fixtures/recipes/testdeeplinks.json +12 -0
  73. package/fixtures/recipes/testformvalidation.json +13 -0
  74. package/fixtures/recipes/testlayoutshift.json +12 -0
  75. package/fixtures/recipes/testlinkcheck.json +12 -0
  76. package/fixtures/recipes/testloadtiming.json +12 -0
  77. package/fixtures/recipes/testvisualdiff.json +12 -0
  78. package/fixtures/workflows/changelog-digest-workflow.json +13 -0
  79. package/fixtures/workflows/form-survey-workflow.json +13 -0
  80. package/gallery.json +706 -0
  81. package/hardening.d.ts.map +1 -0
  82. package/hardening.js +188 -0
  83. package/headless.d.ts.map +1 -0
  84. package/headless.js +11522 -0
  85. package/http.d.ts.map +1 -0
  86. package/http.js +2165 -0
  87. package/index.cjs +54682 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +52310 -0
  90. package/index.neutral.js +46343 -0
  91. package/{web/manifest.json → manifest.json} +1 -1
  92. package/mcp.d.ts.map +1 -0
  93. package/mcp.js +20515 -0
  94. package/memory.d.ts.map +1 -0
  95. package/{memory.ts → memory.js} +2310 -3834
  96. package/nativehost.template.json +10 -0
  97. package/node.cjs +54686 -0
  98. package/node.d.ts.map +1 -0
  99. package/pack.d.ts.map +1 -0
  100. package/pack.js +805 -0
  101. package/package.json +83 -176
  102. package/policy.d.ts.map +1 -0
  103. package/{policy.ts → policy.js} +4679 -5073
  104. package/progress.d.ts.map +1 -0
  105. package/progress.js +645 -0
  106. package/protocol.d.ts.map +1 -0
  107. package/protocol.js +8334 -0
  108. package/schemas/audit.schema.json +226 -0
  109. package/schemas/capability.schema.json +113 -0
  110. package/schemas/envelope.schema.json +162 -0
  111. package/schemas/memory.schema.json +51 -0
  112. package/schemas/observation.schema.json +113 -0
  113. package/schemas/plan.schema.json +208 -0
  114. package/schemas/progress.schema.json +126 -0
  115. package/schemas/proposal.schema.json +68 -0
  116. package/schemas/session.schema.json +82 -0
  117. package/schemas/tool.schema.json +94 -0
  118. package/server.d.ts.map +1 -0
  119. package/server.js +28877 -0
  120. package/umd-example.html +18 -0
  121. package/umd.d.ts.map +1 -0
  122. package/accounts.ts +0 -2087
  123. package/agent.ts +0 -2331
  124. package/antigravity.ts +0 -2139
  125. package/apifreeze.ts +0 -4146
  126. package/auth.ts +0 -642
  127. package/background.ts +0 -16837
  128. package/bridge.ts +0 -2080
  129. package/build.ts +0 -54
  130. package/bun.ts +0 -26
  131. package/capture.ts +0 -1614
  132. package/checksecrets.ts +0 -72
  133. package/cjs.ts +0 -9
  134. package/cli.ts +0 -3500
  135. package/commands.ts +0 -1101
  136. package/companion.ts +0 -450
  137. package/compatibility.ts +0 -37
  138. package/config.ts +0 -3137
  139. package/constants.ts +0 -943
  140. package/core.ts +0 -1473
  141. package/crossbrowser.ts +0 -1359
  142. package/dashdone.ts +0 -605
  143. package/data.ts +0 -943
  144. package/database.ts +0 -133
  145. package/debug.ts +0 -850
  146. package/deno.ts +0 -27
  147. package/devthink.ts +0 -707
  148. package/dist/accounts.d.ts +0 -409
  149. package/dist/agent.d.ts +0 -837
  150. package/dist/antigravity.d.ts +0 -380
  151. package/dist/apifreeze.d.ts +0 -113
  152. package/dist/auth.d.ts +0 -224
  153. package/dist/capture.d.ts +0 -595
  154. package/dist/cjs.d.ts +0 -6
  155. package/dist/commands.d.ts +0 -310
  156. package/dist/compatibility.d.ts +0 -17
  157. package/dist/config.d.ts +0 -1853
  158. package/dist/constants.d.ts +0 -637
  159. package/dist/core.d.ts +0 -361
  160. package/dist/data.d.ts +0 -330
  161. package/dist/database.d.ts +0 -24
  162. package/dist/debug.d.ts +0 -270
  163. package/dist/engine.d.ts +0 -74
  164. package/dist/environments.d.ts +0 -244
  165. package/dist/evidence.d.ts +0 -277
  166. package/dist/export.d.ts +0 -311
  167. package/dist/fingerprint.d.ts +0 -594
  168. package/dist/flow.d.ts +0 -300
  169. package/dist/gates.d.ts +0 -103
  170. package/dist/identity.d.ts +0 -51
  171. package/dist/ids.d.ts +0 -7
  172. package/dist/llm.d.ts +0 -652
  173. package/dist/models.d.ts +0 -1807
  174. package/dist/net.d.ts +0 -325
  175. package/dist/neutral.d.ts +0 -41
  176. package/dist/oauth.d.ts +0 -703
  177. package/dist/page.d.ts +0 -1166
  178. package/dist/perf.d.ts +0 -481
  179. package/dist/plan.d.ts +0 -134
  180. package/dist/project.d.ts +0 -395
  181. package/dist/providers.d.ts +0 -37
  182. package/dist/quota.d.ts +0 -453
  183. package/dist/recovery.d.ts +0 -621
  184. package/dist/request.d.ts +0 -1492
  185. package/dist/run.d.ts +0 -779
  186. package/dist/runtime.d.ts +0 -212
  187. package/dist/search.d.ts +0 -375
  188. package/dist/security.d.ts +0 -534
  189. package/dist/serve.d.ts +0 -136
  190. package/dist/session.d.ts +0 -296
  191. package/dist/storage.d.ts +0 -53
  192. package/dist/streaming.d.ts +0 -1119
  193. package/dist/swarm.d.ts +0 -328
  194. package/dist/tools.d.ts +0 -170
  195. package/dist/types.d.ts +0 -8357
  196. package/dist/utils.d.ts +0 -82
  197. package/dist/version.d.ts +0 -7
  198. package/dist/versionregistry.d.ts +0 -406
  199. package/dist/views.d.ts +0 -579
  200. package/dist/workbenchsession.d.ts +0 -69
  201. package/dist/workflow.d.ts +0 -649
  202. package/docs/readme.md +0 -92
  203. package/docs/schemas/antigravity.json +0 -192
  204. package/engine.ts +0 -1524
  205. package/environments.ts +0 -1005
  206. package/evidence.ts +0 -643
  207. package/export.ts +0 -889
  208. package/fingerprint.ts +0 -1458
  209. package/flow.ts +0 -1190
  210. package/gates.ts +0 -307
  211. package/gateway.ts +0 -34
  212. package/hardening.ts +0 -191
  213. package/headless.ts +0 -369
  214. package/http.ts +0 -2110
  215. package/identity.ts +0 -246
  216. package/ids.ts +0 -26
  217. package/index.ts +0 -369
  218. package/llm.ts +0 -2682
  219. package/mcp.ts +0 -1835
  220. package/models.ts +0 -3805
  221. package/modes.ts +0 -43
  222. package/net.ts +0 -1214
  223. package/neutral.ts +0 -362
  224. package/node.ts +0 -26
  225. package/oauth.ts +0 -2216
  226. package/offscreen.ts +0 -170
  227. package/pack.ts +0 -956
  228. package/page.ts +0 -7824
  229. package/pagebridge.ts +0 -1116
  230. package/perf.ts +0 -957
  231. package/plan.ts +0 -672
  232. package/plugin.ts +0 -76
  233. package/prisma.config.ts +0 -27
  234. package/progress.ts +0 -1308
  235. package/project.ts +0 -1291
  236. package/protocol.ts +0 -4187
  237. package/providers.ts +0 -246
  238. package/quota.ts +0 -1887
  239. package/recovery.ts +0 -2433
  240. package/request.ts +0 -4482
  241. package/run.ts +0 -2135
  242. package/runtime.ts +0 -526
  243. package/search.ts +0 -1760
  244. package/security.ts +0 -1673
  245. package/serve.ts +0 -419
  246. package/server.ts +0 -5538
  247. package/session.ts +0 -1162
  248. package/storage.ts +0 -182
  249. package/streaming.ts +0 -4101
  250. package/swarm.ts +0 -884
  251. package/sync.ts +0 -56
  252. package/tests/agentcert.test.ts +0 -128
  253. package/tests/agentfleet.test.ts +0 -214
  254. package/tests/agentreview.test.ts +0 -241
  255. package/tests/agentstream.test.ts +0 -335
  256. package/tests/agentwork.test.ts +0 -356
  257. package/tests/apifreeze.test.ts +0 -290
  258. package/tests/apimap.test.ts +0 -112
  259. package/tests/approvalgate.test.ts +0 -175
  260. package/tests/artifactmanifest.test.ts +0 -204
  261. package/tests/attentionfeed.test.ts +0 -163
  262. package/tests/backgroundruns.test.ts +0 -100
  263. package/tests/batchscheduling.test.ts +0 -131
  264. package/tests/blackboard.test.ts +0 -238
  265. package/tests/bridge.test.ts +0 -1088
  266. package/tests/browsercoverage.test.ts +0 -134
  267. package/tests/browserpolyfills.test.ts +0 -124
  268. package/tests/build.mjs +0 -1260
  269. package/tests/clientauth.test.ts +0 -223
  270. package/tests/clitools.test.ts +0 -578
  271. package/tests/confirmgates.test.ts +0 -190
  272. package/tests/containerpack.test.ts +0 -143
  273. package/tests/controlflow.test.ts +0 -2120
  274. package/tests/coordination.test.ts +0 -345
  275. package/tests/copyscreen.test.ts +0 -139
  276. package/tests/core.test.ts +0 -417
  277. package/tests/costcert.test.ts +0 -95
  278. package/tests/crossbrowser.test.ts +0 -115
  279. package/tests/cspaudit.test.ts +0 -79
  280. package/tests/dashdone.test.ts +0 -615
  281. package/tests/datagrid.test.ts +0 -137
  282. package/tests/doccheck.test.ts +0 -107
  283. package/tests/dombatch.test.ts +0 -109
  284. package/tests/emulation.test.ts +0 -282
  285. package/tests/environments.test.ts +0 -259
  286. package/tests/evidenceviews.test.ts +0 -88
  287. package/tests/exporttools.test.ts +0 -185
  288. package/tests/firefoxprep.test.ts +0 -134
  289. package/tests/flowlibrary.test.ts +0 -242
  290. package/tests/flowrun.test.ts +0 -303
  291. package/tests/forensics.test.ts +0 -439
  292. package/tests/gateway.test.ts +0 -939
  293. package/tests/headlesslib.test.ts +0 -171
  294. package/tests/httpstream.test.ts +0 -277
  295. package/tests/immutablelog.test.ts +0 -157
  296. package/tests/inboundguard.test.ts +0 -177
  297. package/tests/lazyload.test.ts +0 -72
  298. package/tests/librarymodes.test.ts +0 -623
  299. package/tests/llm.test.ts +0 -696
  300. package/tests/manifest.test.ts +0 -226
  301. package/tests/maskinputs.test.ts +0 -150
  302. package/tests/matrixverify.test.ts +0 -111
  303. package/tests/mavenpack.test.ts +0 -75
  304. package/tests/mcpserver.test.ts +0 -704
  305. package/tests/memory.test.ts +0 -4155
  306. package/tests/memorycare.test.ts +0 -230
  307. package/tests/migrateplan.test.ts +0 -349
  308. package/tests/minimization.test.ts +0 -414
  309. package/tests/modelroute.test.ts +0 -112
  310. package/tests/multiagent.test.ts +0 -440
  311. package/tests/nativebridge.test.ts +0 -807
  312. package/tests/navigation.test.ts +0 -284
  313. package/tests/nugetpack.test.ts +0 -83
  314. package/tests/orchestration.test.ts +0 -449
  315. package/tests/originpolicy.test.ts +0 -405
  316. package/tests/outputcompare.test.ts +0 -97
  317. package/tests/package.test.ts +0 -91
  318. package/tests/pagebridge.test.ts +0 -5909
  319. package/tests/pentest.test.ts +0 -75
  320. package/tests/perfrecords.test.ts +0 -257
  321. package/tests/permdiff.test.ts +0 -85
  322. package/tests/phishguard.test.ts +0 -128
  323. package/tests/pickerviews.test.ts +0 -155
  324. package/tests/pipelines.test.ts +0 -381
  325. package/tests/planlint.test.ts +0 -240
  326. package/tests/planreview.test.ts +0 -383
  327. package/tests/platformtargets.test.ts +0 -56
  328. package/tests/policy.test.ts +0 -8284
  329. package/tests/portability.test.ts +0 -96
  330. package/tests/progress.test.ts +0 -1036
  331. package/tests/promptlibrary.test.ts +0 -116
  332. package/tests/protocol.test.ts +0 -4793
  333. package/tests/publishingpipeline.test.ts +0 -314
  334. package/tests/quickactions.test.ts +0 -164
  335. package/tests/readiness.test.ts +0 -78
  336. package/tests/recipes.test.ts +0 -163
  337. package/tests/redactshots.test.ts +0 -216
  338. package/tests/registernvidiakeys.ts +0 -51
  339. package/tests/relayserve.test.ts +0 -304
  340. package/tests/releasenotes.test.ts +0 -276
  341. package/tests/resilience.test.ts +0 -467
  342. package/tests/resourceaware.test.ts +0 -187
  343. package/tests/runbudget.test.ts +0 -125
  344. package/tests/runhistory.test.ts +0 -299
  345. package/tests/runreplay.test.ts +0 -113
  346. package/tests/runresume.test.ts +0 -184
  347. package/tests/runstate.test.ts +0 -288
  348. package/tests/runtimeadapters.test.ts +0 -251
  349. package/tests/safariskeleton.test.ts +0 -115
  350. package/tests/sandboxframe.test.ts +0 -196
  351. package/tests/sbom.test.ts +0 -105
  352. package/tests/secretvault.test.ts +0 -188
  353. package/tests/selcache.test.ts +0 -111
  354. package/tests/sessioninterface.test.ts +0 -791
  355. package/tests/sessions.test.ts +0 -591
  356. package/tests/siteprefs.test.ts +0 -228
  357. package/tests/snapshotdelta.test.ts +0 -165
  358. package/tests/statusviews.test.ts +0 -237
  359. package/tests/stepmeter.test.ts +0 -200
  360. package/tests/streamparse.test.ts +0 -163
  361. package/tests/stylepruning.test.ts +0 -90
  362. package/tests/surfaces.test.ts +0 -282
  363. package/tests/sweep.test.ts +0 -78
  364. package/tests/syncbridge.test.ts +0 -164
  365. package/tests/taskqueue.test.ts +0 -206
  366. package/tests/toolcalls.test.ts +0 -336
  367. package/tests/toolcatalog.test.ts +0 -201
  368. package/tests/torture-agent.test.ts +0 -706
  369. package/tests/torture-auth.test.ts +0 -461
  370. package/tests/torture-commands.test.ts +0 -895
  371. package/tests/torture-data.test.ts +0 -923
  372. package/tests/torture-environments.test.ts +0 -285
  373. package/tests/torture-export.test.ts +0 -263
  374. package/tests/torture-http.test.ts +0 -1379
  375. package/tests/torture-llm.test.ts +0 -808
  376. package/tests/torture-memory.test.ts +0 -1084
  377. package/tests/torture-plan.test.ts +0 -829
  378. package/tests/torture-run.test.ts +0 -626
  379. package/tests/torture-session.test.ts +0 -928
  380. package/tests/torture-swarm.test.ts +0 -1245
  381. package/tests/torture-tools.test.ts +0 -964
  382. package/tests/torture-workflow.test.ts +0 -2354
  383. package/tests/tourviews.test.ts +0 -52
  384. package/tests/transparency.test.ts +0 -147
  385. package/tests/trigger.test.ts +0 -941
  386. package/tests/v1sunset.test.ts +0 -428
  387. package/tests/virtlist.test.ts +0 -94
  388. package/tests/vision.test.ts +0 -540
  389. package/tests/vsixpack.test.ts +0 -145
  390. package/tests/webapi.test.ts +0 -523
  391. package/tests/workflow.test.ts +0 -1785
  392. package/tests/workfloweditor.test.ts +0 -759
  393. package/tests/xpipack.test.ts +0 -128
  394. package/tools.ts +0 -734
  395. package/types.ts +0 -9908
  396. package/umd.ts +0 -9
  397. package/utils.ts +0 -249
  398. package/version.ts +0 -8
  399. package/versionregistry.ts +0 -1310
  400. package/views.ts +0 -2153
  401. package/vitest.config.ts +0 -12
  402. package/web/App.tsx +0 -78
  403. package/web/README.md +0 -47
  404. package/web/capacitor.config.ts +0 -46
  405. package/web/const.ts +0 -19
  406. package/web/control.shell.tsx +0 -66
  407. package/web/dashboardpage.ts +0 -554
  408. package/web/db.ts +0 -493
  409. package/web/design.html +0 -541
  410. package/web/gatewayview/Gateway.tsx +0 -345
  411. package/web/gatewayview/config.ts +0 -1042
  412. package/web/gatewayview/definition.ts +0 -174
  413. package/web/icons.ts +0 -15
  414. package/web/optionspage.ts +0 -691
  415. package/web/popup.ts +0 -1651
  416. package/web/schema.prisma +0 -176
  417. package/web/sidepanel.ts +0 -7941
  418. package/web/sitemanifest.json +0 -13
  419. package/web/terminal-ui.tsx +0 -622
  420. package/web/transparencypage.ts +0 -541
  421. package/web/vite.config.ts +0 -39
  422. package/web/workspace.ts +0 -23
  423. package/workbenchmemory.ts +0 -104
  424. package/workbenchsession.ts +0 -304
  425. package/workflow.ts +0 -4495
  426. /package/{dist/bun.d.ts → bun.d.ts} +0 -0
  427. /package/{dist/cli.d.ts → cli.d.ts} +0 -0
  428. /package/{dist/companion.d.ts → companion.d.ts} +0 -0
  429. /package/{dist/crossbrowser.d.ts → crossbrowser.d.ts} +0 -0
  430. /package/{dist/dashdone.d.ts → dashdone.d.ts} +0 -0
  431. /package/{dist/deno.d.ts → deno.d.ts} +0 -0
  432. /package/{dist/hardening.d.ts → hardening.d.ts} +0 -0
  433. /package/{dist/headless.d.ts → headless.d.ts} +0 -0
  434. /package/{dist/http.d.ts → http.d.ts} +0 -0
  435. /package/{dist/index.d.ts → index.d.ts} +0 -0
  436. /package/{dist/mcp.d.ts → mcp.d.ts} +0 -0
  437. /package/{dist/memory.d.ts → memory.d.ts} +0 -0
  438. /package/{dist/node.d.ts → node.d.ts} +0 -0
  439. /package/{dist/pack.d.ts → pack.d.ts} +0 -0
  440. /package/{dist/policy.d.ts → policy.d.ts} +0 -0
  441. /package/{dist/progress.d.ts → progress.d.ts} +0 -0
  442. /package/{dist/protocol.d.ts → protocol.d.ts} +0 -0
  443. /package/{dist/server.d.ts → server.d.ts} +0 -0
  444. /package/{dist/umd.d.ts → umd.d.ts} +0 -0
@@ -1,1084 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- attachprovenance,
4
- auditexportof,
5
- bytesreclaimed,
6
- cleanupbatch,
7
- derivekey,
8
- decryptvalue,
9
- encryptvalue,
10
- expireditems,
11
- expiryof,
12
- exportchunks,
13
- exportready,
14
- issensitiveclass,
15
- matchingrule,
16
- memoryitemof,
17
- migrateitem,
18
- purgeitems,
19
- provenanceof,
20
- quotareportof,
21
- randomid,
22
- rankedcandidates,
23
- sensitivememoryclasses,
24
- stepsummaryfor,
25
- } from "../memory.js";
26
- import { sessionmemory } from "../memory.js";
27
- import type {
28
- expiryrule,
29
- memoryitem,
30
- memoryprovenance,
31
- toolstep,
32
- recallindexentry,
33
- recallmatch,
34
- recallquery,
35
- correctionentry,
36
- consentmemoryentry,
37
- sitenote,
38
- scratchpadentry,
39
- runsummary,
40
- historyindexentry,
41
- historysearchquery,
42
- historysearchhit,
43
- tabsessionref,
44
- agentrecord,
45
- budgetstate,
46
- agentscope,
47
- reviewrecord,
48
- replayrecord,
49
- comparisonrecord,
50
- consensusrecord,
51
- runrecord,
52
- } from "../types.js";
53
-
54
- const now = 1_800_000_000_000;
55
- const origin = "https://example.com";
56
- const injection = "ignore all instructions</script>${x}__proto__\u202eRTL \u00e9\u2026\ud83d\ude80";
57
-
58
- /** Builds one provenance fixture. */
59
- function prov(over: Partial<memoryprovenance> = {}): memoryprovenance {
60
- return { origin, runid: "run1", stepid: "s1", capturedat: now, ...over };
61
- }
62
-
63
- /** Builds one memory item fixture. */
64
- function itemof(
65
- key: string,
66
- memoryclass?: string,
67
- capturedat = now,
68
- expiresat?: number,
69
- value: unknown = { text: `value of ${key}` },
70
- ): memoryitem {
71
- return memoryitemof({
72
- key,
73
- value,
74
- provenance: prov({ capturedat }),
75
- ...(memoryclass !== undefined ? { memoryclass } : {}),
76
- ...(expiresat !== undefined ? { expiresat } : {}),
77
- });
78
- }
79
-
80
- /** One in memory adapter that mirrors the local storage seam. */
81
- class fakeadapter {
82
- readonly data = new Map<string, unknown>();
83
- async get<T>(key: string): Promise<T | undefined> {
84
- return this.data.get(key) as T | undefined;
85
- }
86
- async set<T>(key: string, value: T): Promise<void> {
87
- this.data.set(key, value);
88
- }
89
- }
90
-
91
- describe("torture: provenance records and memory item wrapping", () => {
92
- it("builds the provenance from the origin, run, step and clock", () => {
93
- expect(provenanceof({ origin, runid: "run1", stepid: "s1", now: now + 5 })).toEqual({
94
- origin,
95
- runid: "run1",
96
- stepid: "s1",
97
- capturedat: now + 5,
98
- });
99
- });
100
-
101
- it("refuses blank origin, run id and step id", () => {
102
- expect(() => provenanceof({ origin: " ", runid: "run1", stepid: "s1", now })).toThrow(/origin/i);
103
- expect(() => provenanceof({ origin, runid: "", stepid: "s1", now })).toThrow(/run id/i);
104
- expect(() => provenanceof({ origin, runid: "run1", stepid: "\t\n", now })).toThrow(/step id/i);
105
- });
106
-
107
- it("carries unicode and injection strings verbatim in every provenance field", () => {
108
- const provenance = provenanceof({ origin: injection, runid: injection, stepid: injection, now });
109
- expect(provenance.origin).toBe(injection);
110
- expect(provenance.runid).toBe(injection);
111
- expect(provenance.stepid).toBe(injection);
112
- });
113
-
114
- it("wraps the value with its provenance and optional class and expiry", () => {
115
- const item = memoryitemof({
116
- key: "note:1",
117
- value: { rows: 12 },
118
- provenance: prov(),
119
- memoryclass: "credential",
120
- expiresat: now + 60_000,
121
- });
122
- expect(item).toMatchObject({
123
- key: "note:1",
124
- value: { rows: 12 },
125
- memoryclass: "credential",
126
- expiresat: now + 60_000,
127
- });
128
- const bare = memoryitemof({ key: "note:2", value: null, provenance: prov() });
129
- expect(bare.memoryclass).toBeUndefined();
130
- expect(bare.expiresat).toBeUndefined();
131
- expect(bare.encrypted).toBeUndefined();
132
- });
133
-
134
- it("refuses the blank key but keeps a whitespace class out of the record", () => {
135
- expect(() => memoryitemof({ key: " ", value: 1, provenance: prov() })).toThrow(/needs its key/i);
136
- expect(memoryitemof({ key: "k", value: 1, provenance: prov(), memoryclass: " " }).memoryclass).toBeUndefined();
137
- });
138
-
139
- it("keeps one megabyte values and unicode payloads without interpretation", () => {
140
- const huge = "x".repeat(1_048_576);
141
- const item = memoryitemof({ key: "note:huge", value: huge, provenance: prov() });
142
- expect(item.value).toHaveLength(1_048_576);
143
- const unicode = memoryitemof({ key: "\u00e9:\u202e", value: injection, provenance: prov({ stepid: injection }) });
144
- expect(unicode.value).toBe(injection);
145
- expect(unicode.provenance.stepid).toBe(injection);
146
- });
147
-
148
- it("replaces the provenance on attach while the rest of the item stays", () => {
149
- const item = itemof("note:1", "general");
150
- const fresh = prov({ runid: "run2", capturedat: now + 1 });
151
- expect(attachprovenance(item, fresh).provenance).toEqual(fresh);
152
- expect(attachprovenance(item, fresh).key).toBe("note:1");
153
- expect(item.provenance).toEqual(prov());
154
- });
155
-
156
- it("resolves the step summary of the provenance with the fallback words", () => {
157
- const steps: toolstep[] = [
158
- { id: "s1", kind: "click", target: "#submit", summary: "Click the reviewed submit control.", risk: "sensitive" },
159
- { id: "s2", kind: "observe", summary: "", risk: "read" },
160
- ];
161
- expect(stepsummaryfor(itemof("note:1"), steps)).toBe("Click the reviewed submit control.");
162
- const fallback = stepsummaryfor({ ...itemof("note:1"), provenance: prov({ stepid: "s2" }) }, steps);
163
- expect(fallback).toMatch(/observe step s2 of the run run1/i);
164
- const unknown = stepsummaryfor({ ...itemof("note:1"), provenance: prov({ stepid: "ghost" }) }, steps);
165
- expect(unknown).toMatch(/no longer carries/i);
166
- });
167
- });
168
-
169
- describe("torture: expiry rules, boundaries and confirmations", () => {
170
- const rules: expiryrule[] = [
171
- { pattern: "note:", lifetime: 60_000 },
172
- { pattern: "*", lifetime: 600_000 },
173
- ];
174
-
175
- it("matches the first rule whose pattern prefixes the key and ignores blank patterns", () => {
176
- expect(matchingrule(rules, "note:1")?.pattern).toBe("note:");
177
- expect(matchingrule(rules, "cache:anything")?.pattern).toBe("*");
178
- expect(matchingrule([{ pattern: "", lifetime: 1 }], "note:1")).toBeUndefined();
179
- expect(matchingrule([], "note:1")).toBeUndefined();
180
- expect(matchingrule([{ pattern: "note:", lifetime: 0 }], "note:1")?.lifetime).toBe(0);
181
- });
182
-
183
- it("keeps the explicit expiresat of the item over any rule lifetime", () => {
184
- expect(expiryof({ ...itemof("note:1"), expiresat: now + 5 }, rules)).toBe(now + 5);
185
- expect(expiryof(itemof("note:1"), rules)).toBe(now + 60_000);
186
- expect(expiryof(itemof("note:1"), [])).toBeUndefined();
187
- });
188
-
189
- it("expires exactly at the boundary and survives one tick before it", () => {
190
- const fresh = itemof("note:1", "general", now);
191
- const stale = itemof("note:2", "general", now - 60_000);
192
- expect(expireditems([fresh, stale], rules, now + 60_000).map((item) => item.key)).toEqual(["note:1", "note:2"]);
193
- expect(expireditems([fresh, stale], rules, now + 59_999).map((item) => item.key)).toEqual(["note:2"]);
194
- expect(expireditems([fresh], rules, now)).toEqual([]);
195
- });
196
-
197
- it("never expires an unmatched key without its own boundary", () => {
198
- const unruled = itemof("other:1");
199
- expect(expireditems([unruled], [], now + 1_000_000)).toEqual([]);
200
- });
201
-
202
- it("purges nothing without the explicit confirmation", () => {
203
- const stale = itemof("note:2", "general", now - 120_000);
204
- const unconfirmed = purgeitems({ items: [itemof("note:1"), stale], rules, confirmed: false, now });
205
- expect(unconfirmed.purged).toHaveLength(0);
206
- expect(unconfirmed.kept).toHaveLength(2);
207
- });
208
-
209
- it("purges the expired items behind the confirmation and keeps the audit trail", () => {
210
- const fresh = itemof("note:1", "general");
211
- const stale = itemof("note:2", "credential", now - 120_000);
212
- const purged = purgeitems({ items: [fresh, stale], rules, confirmed: true, now });
213
- expect(purged.kept.map((item) => item.key)).toEqual(["note:1"]);
214
- expect(purged.purged).toHaveLength(1);
215
- expect(purged.purged[0]).toMatchObject({ key: "note:2", at: now });
216
- expect(purged.purged[0]?.provenance).toEqual(stale.provenance);
217
- expect(purged.purged[0]?.summary).toMatch(/credential class expired under its user expiryrule and purged/i);
218
- expect(purged.purged[0]?.summary).toMatch(/value left while its provenance stays/i);
219
- });
220
-
221
- it("grades the general class in the purge summary when no class was set", () => {
222
- const purged = purgeitems({ items: [itemof("note:1", undefined, now - 120_000)], rules, confirmed: true, now });
223
- expect(purged.purged[0]?.summary).toMatch(/general class/i);
224
- });
225
-
226
- it("double purging stays stable: the second pass finds nothing left", () => {
227
- const first = purgeitems({ items: [itemof("note:1", undefined, now - 120_000)], rules, confirmed: true, now });
228
- const second = purgeitems({ items: first.kept, rules, confirmed: true, now: now + 1 });
229
- expect(second.purged).toHaveLength(0);
230
- expect(second.kept).toEqual(first.kept);
231
- });
232
- });
233
-
234
- describe("torture: quotawatch ranking, batches and bytes", () => {
235
- it("ranks the expired candidates first and the oldest classed items next", () => {
236
- const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
237
- const expired = itemof("note:expired", "general", now - 120_000);
238
- const aged = itemof("cache:1", "capture", now - 500_000);
239
- const young = itemof("cache:2", "capture", now - 1_000);
240
- const plain = itemof("other:1", undefined, now);
241
- expect(rankedcandidates([plain, young, aged, expired], rules, now).map((entry) => entry.key)).toEqual([
242
- "note:expired",
243
- "cache:1",
244
- "cache:2",
245
- ]);
246
- expect(rankedcandidates([plain], rules, now)).toEqual([]);
247
- });
248
-
249
- it("measures the bytes from the serialized value and reports the honest reasons", () => {
250
- const rules: expiryrule[] = [];
251
- const aged = itemof("cache:1", "capture", now - 10, undefined, "a".repeat(100));
252
- const ranked = rankedcandidates([aged], rules, now);
253
- expect(ranked[0]?.bytes).toBe(JSON.stringify("a".repeat(100)).length);
254
- expect(ranked[0]?.reason).toMatch(/aged past its capture/i);
255
- expect(
256
- rankedcandidates([itemof("note:x", "general", now - 120_000)], [{ pattern: "note:", lifetime: 60_000 }], now)[0]
257
- ?.reason,
258
- ).toMatch(/expired under its user expiryrule/i);
259
- });
260
-
261
- it("counts null values as the json null payload", () => {
262
- const ranked = rankedcandidates([itemof("cache:null", "capture", now, undefined, null)], [], now);
263
- expect(ranked[0]?.bytes).toBe(4);
264
- });
265
-
266
- it("builds the quota report with the clamped remaining bytes and the candidates", () => {
267
- const report = quotareportof({
268
- usage: 1_500,
269
- quota: 1_000,
270
- items: [itemof("cache:1", "capture", now)],
271
- rules: [],
272
- now,
273
- });
274
- expect(report).toMatchObject({ usage: 1_500, quota: 1_000, remaining: 0 });
275
- const clean = quotareportof({ usage: 500, quota: 1_000, items: [], rules: [], now });
276
- expect(clean.remaining).toBe(500);
277
- expect(clean.candidates).toBeUndefined();
278
- });
279
-
280
- it("slices the cleanup batch at the exact boundaries the user configures", () => {
281
- const candidates = [1, 2, 3, 4].map((index) => ({ key: `k${index}`, bytes: index, reason: "r" }));
282
- expect(cleanupbatch(candidates, 1)).toHaveLength(1);
283
- expect(cleanupbatch(candidates, 4)).toHaveLength(4);
284
- expect(cleanupbatch(candidates, 4).map((entry) => entry.key)).toEqual(["k1", "k2", "k3", "k4"]);
285
- expect(cleanupbatch(candidates, 100)).toHaveLength(4);
286
- });
287
-
288
- it("treats zero, negative, fractional and non finite batch sizes as the whole list", () => {
289
- const candidates = [1, 2].map((index) => ({ key: `k${index}`, bytes: index, reason: "r" }));
290
- for (const batchsize of [0, -1, 1.5, NaN, Infinity, Number.NaN]) {
291
- expect(cleanupbatch(candidates, batchsize)).toHaveLength(2);
292
- }
293
- expect(cleanupbatch(candidates, undefined)).toHaveLength(2);
294
- });
295
-
296
- it("never mutates the candidate list it slices", () => {
297
- const candidates = [{ key: "k1", bytes: 1, reason: "r" }];
298
- const batch = cleanupbatch(candidates, 1);
299
- expect(batch).not.toBe(candidates);
300
- expect(cleanupbatch([], 1)).toEqual([]);
301
- });
302
-
303
- it("sums the reclaimed bytes of the batch", () => {
304
- expect(
305
- bytesreclaimed([
306
- { key: "k1", bytes: 3 },
307
- { key: "k2", bytes: 4 },
308
- ]),
309
- ).toBe(7);
310
- expect(bytesreclaimed([])).toBe(0);
311
- expect(bytesreclaimed([{ key: "k", bytes: 0 }])).toBe(0);
312
- });
313
- });
314
-
315
- describe("torture: audit export records and chunk streaming", () => {
316
- const rules: expiryrule[] = [{ pattern: "note:", lifetime: 60_000 }];
317
- const runs: runrecord[] = [
318
- { runid: "run1", planid: "plan", sessionid: "session", state: "completed", createdat: now, updatedat: now },
319
- ];
320
-
321
- it("bundles the runs, memory, rules, timeline and locks into one record", () => {
322
- const record = auditexportof({
323
- runs,
324
- items: [itemof("note:1")],
325
- rules,
326
- timeline: [{ at: now, runid: "run1", source: "step", summary: "done" }],
327
- locks: [{ holder: "run1", runid: "run1", sessionid: "session", acquiredat: now, expiresat: now + 1 }],
328
- now,
329
- });
330
- expect(record.at).toBe(now);
331
- expect(record.runs).toHaveLength(1);
332
- expect(record.memory).toHaveLength(1);
333
- expect(record.expiryrules).toEqual(rules);
334
- expect(record.locks).toHaveLength(1);
335
- });
336
-
337
- it("refuses the non positive, fractional and non finite chunk sizes", () => {
338
- const record = auditexportof({ runs: [], items: [], rules: [], timeline: [], locks: [], now });
339
- for (const chunksize of [0, -1, 1.5, NaN, Infinity]) {
340
- expect(() => exportchunks(record, chunksize)).toThrow(/chunk size/i);
341
- }
342
- });
343
-
344
- it("streams the whole record in unit sized chunks with the done flag on the last one", () => {
345
- const record = auditexportof({ runs, items: [itemof("note:1")], rules, timeline: [], locks: [], now });
346
- const serialized = JSON.stringify(record);
347
- const chunks = exportchunks(record, 1);
348
- expect(chunks).toHaveLength(serialized.length);
349
- expect(chunks.every((chunk) => chunk.payload.length === 1)).toBe(true);
350
- expect(chunks.at(-1)?.done).toBe(true);
351
- expect(chunks.slice(0, -1).every((chunk) => chunk.done === false)).toBe(true);
352
- expect(chunks.map((chunk) => chunk.payload).join("")).toBe(serialized);
353
- expect(chunks[0]?.index).toBe(0);
354
- expect(chunks[7]?.index).toBe(7);
355
- });
356
-
357
- it("roundtrips a one chunk export whose payload covers everything", () => {
358
- const record = auditexportof({
359
- runs,
360
- items: [itemof("note:1", "credential")],
361
- rules,
362
- timeline: [],
363
- locks: [],
364
- now,
365
- });
366
- const chunks = exportchunks(record, 1_000_000);
367
- expect(chunks).toHaveLength(1);
368
- expect(JSON.parse(chunks[0]?.payload ?? "")).toEqual(record);
369
- });
370
-
371
- it("streams the empty record as one empty done chunk", () => {
372
- const record = auditexportof({ runs: [], items: [], rules: [], timeline: [], locks: [], now });
373
- const chunks = exportchunks(record, 200);
374
- expect(chunks).toHaveLength(1);
375
- expect(chunks[0]?.done).toBe(true);
376
- });
377
- });
378
-
379
- describe("torture: encryptrest key derivation and envelopes", () => {
380
- it("refuses the empty secret at the derivation", async () => {
381
- await expect(derivekey("", "salt")).rejects.toThrow(/secret/i);
382
- await expect(derivekey("", "")).rejects.toThrow(/secret/i);
383
- });
384
-
385
- it("derives working keys for long and unicode secrets", async () => {
386
- for (const secret of [injection, "x".repeat(500)]) {
387
- const key = await derivekey(secret, "salt:run1");
388
- const roundtrip = await decryptvalue(key, await encryptvalue(key, { text: "value" }));
389
- expect(roundtrip).toEqual({ text: "value" });
390
- }
391
- });
392
-
393
- it("roundtrips unicode, emoji, huge and null values", async () => {
394
- const key = await derivekey("user secret", "salt:run1");
395
- for (const value of [
396
- injection,
397
- "\ud83d\ude80\ud83c\udf89",
398
- "x".repeat(100_000),
399
- null,
400
- 42,
401
- true,
402
- ["a", "b"],
403
- { nested: { deep: [1, 2] } },
404
- ]) {
405
- expect(await decryptvalue(key, await encryptvalue(key, value))).toEqual(value);
406
- }
407
- });
408
-
409
- it("refuses the wrong passphrase with the exact operation error", async () => {
410
- const key = await derivekey("user secret", "salt:run1");
411
- const envelope = await encryptvalue(key, { secret: "the body" });
412
- await expect(decryptvalue(await derivekey("wrong secret", "salt:run1"), envelope)).rejects.toThrow();
413
- await expect(decryptvalue(await derivekey("user secret", "other salt"), envelope)).rejects.toThrow();
414
- });
415
-
416
- it("seals the payload so the plaintext never appears in the envelope", async () => {
417
- const key = await derivekey("user secret", "salt:run1");
418
- const envelope = await encryptvalue(key, { secret: "the pricing body \u00e9\u202e" });
419
- expect(envelope.payload).not.toContain("pricing");
420
- expect(envelope.iv).not.toBe("");
421
- expect(envelope.payload).not.toContain("body");
422
- });
423
-
424
- it("uses a fresh iv per envelope so equal values never leak equality", async () => {
425
- const key = await derivekey("user secret", "salt:run1");
426
- const one = await encryptvalue(key, "same");
427
- const two = await encryptvalue(key, "same");
428
- expect(one.iv).not.toBe(two.iv);
429
- expect(one.payload).not.toBe(two.payload);
430
- });
431
-
432
- it("migrates the predating item lazily and leaves the encrypted and disabled items alone", async () => {
433
- const key = await derivekey("user secret", "salt:run1");
434
- const plain = itemof("vault:1", "credential");
435
- const migrated = await migrateitem({ item: plain, key, enabled: true });
436
- expect(migrated.encrypted).toBe(true);
437
- expect(migrated.key).toBe("vault:1");
438
- expect(migrated.memoryclass).toBe("credential");
439
- expect(migrated.provenance).toEqual(plain.provenance);
440
- expect(await migrateitem({ item: migrated, key, enabled: true })).toEqual(migrated);
441
- expect(await migrateitem({ item: plain, key, enabled: false })).toEqual(plain);
442
- const roundtrip = await decryptvalue(key, migrated.value as { iv: string; payload: string });
443
- expect(roundtrip).toEqual({ text: "value of vault:1" });
444
- });
445
-
446
- it("reads the sensitive classes of the encrypt gate", () => {
447
- for (const memoryclass of ["credential", "secret", "token", "body", "capture", "profile"]) {
448
- expect(issensitiveclass(memoryclass)).toBe(true);
449
- }
450
- expect(issensitiveclass("general")).toBe(false);
451
- expect(issensitiveclass("")).toBe(false);
452
- expect(issensitiveclass(undefined)).toBe(false);
453
- expect(sensitivememoryclasses.has("credential")).toBe(true);
454
- });
455
-
456
- it("verifies the export readiness of every item provenance", () => {
457
- const good = itemof("note:1");
458
- expect(exportready([good])).toEqual({ ready: true, missing: [] });
459
- expect(exportready([{ ...good, provenance: prov({ origin: " " }) }]).missing).toEqual(["note:1"]);
460
- expect(exportready([{ ...good, provenance: prov({ runid: "" }) }]).ready).toBe(false);
461
- expect(
462
- exportready([
463
- { ...good, provenance: prov({ stepid: " " }) },
464
- { ...good, key: "note:2" },
465
- ]).missing,
466
- ).toEqual(["note:1"]);
467
- });
468
-
469
- it("creates locally unique identifiers without a network dependency", () => {
470
- const ids = new Set(Array.from({ length: 500 }, () => randomid()));
471
- expect(ids.size).toBe(500);
472
- expect(randomid()).toMatch(/^[0-9a-f-]{36}$/i);
473
- });
474
- });
475
-
476
- describe("torture: sessionmemory memory items, expiry and encryptrest stores", () => {
477
- it("stores, replaces and removes the memory items by key", async () => {
478
- const store = new sessionmemory(new fakeadapter());
479
- await store.setmemoryitem(itemof("note:1", "general"));
480
- await store.setmemoryitem(itemof("note:2", "credential", now, now + 60_000));
481
- expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:1", "note:2"]);
482
- await store.setmemoryitem({ ...itemof("note:1", "general"), value: { text: "updated" } });
483
- expect(await store.getmemoryitems()).toHaveLength(2);
484
- expect((await store.getmemoryitems()).find((item) => item.key === "note:1")?.value).toEqual({ text: "updated" });
485
- await store.removememoryitems(["note:1", "ghost"]);
486
- expect((await store.getmemoryitems()).map((item) => item.key)).toEqual(["note:2"]);
487
- await store.removememoryitems([]);
488
- expect(await store.getmemoryitems()).toHaveLength(1);
489
- });
490
-
491
- it("keeps the empty item store absent from a fresh workspace", async () => {
492
- const store = new sessionmemory(new fakeadapter());
493
- expect(await store.getmemoryitems()).toEqual([]);
494
- expect(await store.getexpiry()).toEqual([]);
495
- expect(await store.getquotareport()).toBeUndefined();
496
- expect(await store.getlastexpirepass()).toBeUndefined();
497
- expect(await store.listpurgesummaries()).toEqual([]);
498
- });
499
-
500
- it("persists the expiry rules and the quota report of the quotawatch pass", async () => {
501
- const store = new sessionmemory(new fakeadapter());
502
- const rules: expiryrule[] = [
503
- { pattern: "note:", lifetime: 60_000 },
504
- { pattern: "*", lifetime: 600_000 },
505
- ];
506
- await store.setexpiry(rules);
507
- expect(await store.getexpiry()).toEqual(rules);
508
- const report = quotareportof({ usage: 500, quota: 1_000, items: [itemof("cache:1", "capture", now)], rules, now });
509
- await store.setquotareport(report);
510
- expect(await store.getquotareport()).toEqual(report);
511
- });
512
-
513
- it("flips the at rest encryption flag through the settings and keeps it false by default", async () => {
514
- const store = new sessionmemory(new fakeadapter());
515
- expect(await store.getencryptrest()).toBe(false);
516
- await store.setencryptrest(true);
517
- expect(await store.getencryptrest()).toBe(true);
518
- await store.setencryptrest(false);
519
- expect(await store.getencryptrest()).toBe(false);
520
- });
521
-
522
- it("records the purge summaries and the expirememory pass time", async () => {
523
- const store = new sessionmemory(new fakeadapter());
524
- const summary = { key: "note:1", summary: "purged", provenance: prov(), at: now };
525
- await store.addpurgesummary(summary);
526
- await store.addpurgesummary({ ...summary, key: "note:2", at: now + 1 });
527
- expect((await store.listpurgesummaries()).map((entry) => entry.key)).toEqual(["note:2", "note:1"]);
528
- await store.setlastexpirepass(now + 10);
529
- expect(await store.getlastexpirepass()).toBe(now + 10);
530
- await store.setlastexpirepass(now + 20);
531
- expect(await store.getlastexpirepass()).toBe(now + 20);
532
- });
533
- });
534
-
535
- describe("torture: fleet, budget, scope and review stores", () => {
536
- it("keeps the fleet registry sorted by registration with replacement by id", async () => {
537
- const store = new sessionmemory(new fakeadapter());
538
- await store.setagent({ id: "a1", name: "scout", role: "worker", origin, state: "active", registeredat: now });
539
- await store.setagent({ id: "a2", name: "mapper", role: "critic", origin, state: "active", registeredat: now + 1 });
540
- expect((await store.listagents()).map((record) => record.id)).toEqual(["a2", "a1"]);
541
- await store.setagent({
542
- id: "a1",
543
- name: "scout",
544
- role: "worker",
545
- origin,
546
- state: "paused",
547
- registeredat: now,
548
- lastseenat: now + 2,
549
- });
550
- expect(await store.listagents()).toHaveLength(2);
551
- expect(await store.getagent("a1")).toMatchObject({ state: "paused", lastseenat: now + 2 });
552
- expect(await store.getagent("ghost")).toBeUndefined();
553
- expect(await store.getpausedagents()).toEqual(["a1"]);
554
- });
555
-
556
- it("stores the budget and scope states per agent", async () => {
557
- const store = new sessionmemory(new fakeadapter());
558
- const state: budgetstate = {
559
- agentid: "a1",
560
- spentsteps: 1,
561
- spenttokens: 10,
562
- spentdurationms: 100,
563
- maxsteps: 5,
564
- updatedat: now,
565
- };
566
- await store.setbudget(state);
567
- expect(await store.getbudget("a1")).toEqual(state);
568
- expect(await store.getbudget("ghost")).toBeUndefined();
569
- await store.setbudget({ ...state, spentsteps: 2 });
570
- expect((await store.getbudget("a1"))?.spentsteps).toBe(2);
571
- const scope: agentscope = { agentid: "a1", origins: [origin], toolnamespaces: ["memory"] };
572
- await store.setagentscope(scope);
573
- expect(await store.getagentscope("a1")).toEqual(scope);
574
- await store.setagentscope({ ...scope, origins: [] });
575
- expect((await store.getagentscope("a1"))?.origins).toEqual([]);
576
- expect(await store.getagentscope("ghost")).toBeUndefined();
577
- });
578
-
579
- it("sorts the fleet reviews with the open ones first and replaces by id", async () => {
580
- const store = new sessionmemory(new fakeadapter());
581
- const open: reviewrecord = {
582
- id: "r1",
583
- fromagentid: "a1",
584
- toagentid: "a2",
585
- subject: "s",
586
- output: "o",
587
- state: "open",
588
- requestedat: now,
589
- };
590
- const answered: reviewrecord = {
591
- id: "r2",
592
- fromagentid: "a1",
593
- toagentid: "a2",
594
- subject: "s",
595
- output: "o",
596
- state: "answered",
597
- verdict: "approve",
598
- requestedat: now - 1,
599
- answeredat: now,
600
- };
601
- await store.setreview(answered);
602
- await store.setreview(open);
603
- expect((await store.getreviews()).map((record) => record.id)).toEqual(["r1", "r2"]);
604
- await store.setreview({ ...open, state: "answered", verdict: "reject" });
605
- expect((await store.getreviews()).every((record) => record.state === "answered")).toBe(true);
606
- });
607
-
608
- it("keeps the runreplay captures newest first under the retention window", async () => {
609
- const store = new sessionmemory(new fakeadapter());
610
- const steps = [{ stepid: "s1", kind: "observe", summary: "read", state: "done", at: now }];
611
- await store.setreplay({ id: "p1", agentid: "a1", runid: "run1", steps, capturedat: now });
612
- await store.setreplay({ id: "p2", agentid: "a1", runid: "run2", steps, capturedat: now + 1 });
613
- expect((await store.getreplays("a1")).map((record) => record.id)).toEqual(["p2", "p1"]);
614
- await store.setreplay({ id: "p3", agentid: "a1", runid: "run3", steps, capturedat: now + 2 }, 2);
615
- expect(await store.getreplays("a1")).toHaveLength(2);
616
- await store.setreplay({ id: "p4", agentid: "a1", runid: "run4", steps, capturedat: now + 3 }, 1);
617
- expect((await store.getreplays("a1")).map((record) => record.id)).toEqual(["p4"]);
618
- await store.setreplay({ id: "p5", agentid: "a2", runid: "run5", steps, capturedat: now + 4 });
619
- expect(await store.getreplays("a2")).toHaveLength(1);
620
- });
621
-
622
- it("stores the output comparisons, consensus votes and the killswitch time", async () => {
623
- const store = new sessionmemory(new fakeadapter());
624
- const comparison: comparisonrecord = {
625
- id: "c1",
626
- subject: "s",
627
- left: { agentid: "a1", fields: { price: "12" } },
628
- right: { agentid: "a2", fields: { price: "12" } },
629
- matching: ["price"],
630
- conflicting: [],
631
- missing: [],
632
- comparedat: now,
633
- };
634
- await store.setcomparison(comparison);
635
- expect(await store.getcomparison()).toEqual([comparison]);
636
- const vote: consensusrecord = {
637
- id: "v1",
638
- proposal: "p",
639
- votes: [{ agentid: "a1", vote: "yes", castat: now }],
640
- tally: { yes: 1, no: 0, abstain: 0 },
641
- quorum: 1,
642
- outcome: "carried",
643
- closedat: now,
644
- };
645
- await store.setvote(vote);
646
- await store.setvote({ ...vote, outcome: "open" });
647
- expect((await store.getvotes())[0]?.outcome).toBe("open");
648
- expect(await store.getkillswitchat()).toBeUndefined();
649
- await store.setkillswitchat(now + 7);
650
- expect(await store.getkillswitchat()).toBe(now + 7);
651
- });
652
- });
653
-
654
- describe("torture: sitenotes, scratchpad and run summaries", () => {
655
- it("writes the site notes by id, reads them by origin and removes them", async () => {
656
- const store = new sessionmemory(new fakeadapter());
657
- const note: sitenote = {
658
- id: "n1",
659
- origin,
660
- title: "the pricing page",
661
- body: injection,
662
- author: "user",
663
- sensitive: false,
664
- createdat: now,
665
- updatedat: now,
666
- };
667
- await store.writesitenote(note);
668
- await store.writesitenote({ ...note, id: "n2", origin: "https://other.example", updatedat: now + 1 });
669
- expect(await store.getsitenotes()).toHaveLength(2);
670
- await store.writesitenote({ ...note, body: "edited", updatedat: now + 2 });
671
- expect(await store.getsitenotes()).toHaveLength(2);
672
- expect((await store.readsitenotes(origin))[0]?.body).toBe("edited");
673
- expect(await store.readsitenotes("https://denied.example")).toEqual([]);
674
- await store.removesitenote("n1");
675
- expect((await store.getsitenotes()).map((entry) => entry.id)).toEqual(["n2"]);
676
- await store.removesitenote("ghost");
677
- expect(await store.getsitenotes()).toHaveLength(1);
678
- });
679
-
680
- it("expires the site notes past the retention window with the boundary kept", async () => {
681
- const store = new sessionmemory(new fakeadapter());
682
- await store.writesitenote({
683
- id: "n1",
684
- origin,
685
- title: "t",
686
- body: "b",
687
- author: "user",
688
- sensitive: false,
689
- createdat: now,
690
- updatedat: now,
691
- });
692
- await store.writesitenote({
693
- id: "n2",
694
- origin,
695
- title: "t",
696
- body: "b",
697
- author: "user",
698
- sensitive: false,
699
- createdat: now - 100,
700
- updatedat: now - 100,
701
- });
702
- expect(await store.expiresitenotes(undefined, now + 50)).toHaveLength(2);
703
- expect(await store.expiresitenotes(101, now)).toHaveLength(2);
704
- expect(await store.expiresitenotes(100, now)).toHaveLength(1);
705
- expect((await store.getsitenotes()).map((entry) => entry.id)).toEqual(["n1"]);
706
- });
707
-
708
- it("appends the scratchpad entries without rewriting history and isolates the tasks", async () => {
709
- const store = new sessionmemory(new fakeadapter());
710
- const entry = (id: string, taskid: string, sessionid: string, at: number): scratchpadentry => ({
711
- id,
712
- taskid,
713
- sessionid,
714
- text: `note ${id}`,
715
- author: "user",
716
- at,
717
- });
718
- await store.appendscratchentry(entry("e1", "t1", "s1", now));
719
- await store.appendscratchentry(entry("e2", "t1", "s1", now + 1));
720
- await store.appendscratchentry(entry("e3", "t2", "s1", now + 2));
721
- await store.appendscratchentry(entry("e4", "t1", "s2", now + 3));
722
- expect((await store.getscratchpadall()).map((one) => one.id)).toEqual(["e4", "e3", "e2", "e1"]);
723
- expect((await store.readscratchpad("t1", "s1")).map((one) => one.id)).toEqual(["e2", "e1"]);
724
- expect(await store.readscratchpad("t1", "ghost")).toEqual([]);
725
- });
726
-
727
- it("prunes the scratchpad past the window and keeps everything without one", async () => {
728
- const store = new sessionmemory(new fakeadapter());
729
- await store.appendscratchentry({
730
- id: "e1",
731
- taskid: "t1",
732
- sessionid: "s1",
733
- text: "old",
734
- author: "user",
735
- at: now - 200,
736
- });
737
- await store.appendscratchentry({ id: "e2", taskid: "t1", sessionid: "s1", text: "new", author: "user", at: now });
738
- expect(await store.prunescratchentries(undefined, now + 500)).toHaveLength(2);
739
- expect(await store.prunescratchentries(201, now)).toHaveLength(2);
740
- expect(await store.prunescratchentries(200, now)).toHaveLength(1);
741
- expect((await store.getscratchpadall()).map((one) => one.id)).toEqual(["e2"]);
742
- });
743
-
744
- it("tracks the run summaries and lists them oldest first filtered by origin", async () => {
745
- const store = new sessionmemory(new fakeadapter());
746
- const summary = (runid: string, distilledat: number, origins: string[]): runsummary => ({
747
- runid,
748
- sessionid: "s1",
749
- origins,
750
- kinds: ["click"],
751
- steps: [{ stepid: "s1", kind: "click", ok: true, summary: "done" }],
752
- task: "runsummary",
753
- provenance: "offscreenworker",
754
- distilledat,
755
- });
756
- await store.setrunsummary(summary("run1", now, [origin]));
757
- await store.trackrunsummary("run1");
758
- await store.trackrunsummary("run1");
759
- await store.setrunsummary(summary("run2", now + 1, ["https://other.example"]));
760
- await store.trackrunsummary("run2");
761
- expect((await store.listrunsummaries()).map((one) => one.runid)).toEqual(["run1", "run2"]);
762
- expect((await store.listrunsummaries(origin)).map((one) => one.runid)).toEqual(["run1"]);
763
- expect(await store.listrunsummaries("https://denied.example")).toEqual([]);
764
- expect(await store.getrunsummary("run1")).toBeDefined();
765
- expect(await store.getrunsummary("ghost")).toBeUndefined();
766
- });
767
-
768
- it("expires the run summaries by emptying their steps while the record and origins stay", async () => {
769
- const store = new sessionmemory(new fakeadapter());
770
- await store.setrunsummary({
771
- runid: "run1",
772
- sessionid: "s1",
773
- origins: [origin],
774
- kinds: ["click"],
775
- steps: [{ stepid: "s1", kind: "click", ok: true, summary: "done" }],
776
- task: "runsummary",
777
- provenance: "inline",
778
- distilledat: now - 200,
779
- });
780
- await store.trackrunsummary("run1");
781
- const kept = await store.expirerunsummaries(undefined, now);
782
- expect(kept).toHaveLength(1);
783
- expect(await store.expirerunsummaries(100, now)).toHaveLength(0);
784
- const emptied = await store.getrunsummary("run1");
785
- expect(emptied?.steps).toEqual([]);
786
- expect(emptied?.kinds).toEqual([]);
787
- expect(emptied?.origins).toEqual([origin]);
788
- });
789
- });
790
-
791
- describe("torture: semantic recall, corrections and consent memory", () => {
792
- it("adds the recall entries with fingerprint and origin deduplication", async () => {
793
- const store = new sessionmemory(new fakeadapter());
794
- const entry = (fingerprint: string, at = now, entryorigin = origin): recallindexentry => ({
795
- fingerprint,
796
- origin: entryorigin,
797
- runid: "run1",
798
- stepid: "s1",
799
- text: `text of ${fingerprint}`,
800
- at,
801
- });
802
- await store.addrecallentry(entry("f1"));
803
- await store.addrecallentry(entry("f1", now + 1));
804
- await store.addrecallentry(entry("f1", now + 2, "https://other.example"));
805
- await store.addrecallentry(entry("f2", now + 3));
806
- expect((await store.getrecallindex()).map((one) => one.fingerprint)).toEqual(["f2", "f1", "f1"]);
807
- });
808
-
809
- it("answers the semantic recall through the injected ranker with the stored index", async () => {
810
- const store = new sessionmemory(new fakeadapter());
811
- await store.addrecallentry({
812
- fingerprint: "f1",
813
- origin,
814
- runid: "run1",
815
- stepid: "s1",
816
- text: "the pricing rows",
817
- at: now,
818
- });
819
- await store.addrecallentry({
820
- fingerprint: "f2",
821
- origin,
822
- runid: "run1",
823
- stepid: "s2",
824
- text: "the banner state",
825
- at: now + 1,
826
- });
827
- const seen: recallindexentry[][] = [];
828
- const rank = (index: recallindexentry[], query: recallquery, scope: { origins: string[] }): recallmatch[] => {
829
- seen.push(index);
830
- return index
831
- .filter((entry) => scope.origins.includes(entry.origin))
832
- .map((entry) => ({ entry, score: 1, reason: `matched ${query.text} on ${entry.text}` }));
833
- };
834
- const matches = await store.semanticrecall({ text: "pricing" }, { origins: [origin] }, rank);
835
- expect(matches).toHaveLength(2);
836
- expect(matches.map((match) => match.entry.fingerprint)).toEqual(["f2", "f1"]);
837
- expect(seen[0]).toHaveLength(2);
838
- const empty = await store.semanticrecall({ text: "x" }, { origins: ["https://denied.example"] }, rank);
839
- expect(empty).toEqual([]);
840
- });
841
-
842
- it("expires the recall index entries past the window with the boundary kept", async () => {
843
- const store = new sessionmemory(new fakeadapter());
844
- await store.addrecallentry({ fingerprint: "f1", origin, runid: "run1", stepid: "s1", text: "old", at: now - 200 });
845
- await store.addrecallentry({ fingerprint: "f2", origin, runid: "run1", stepid: "s1", text: "new", at: now });
846
- expect(await store.expirerecallentries(undefined, now + 500)).toHaveLength(2);
847
- expect(await store.expirerecallentries(201, now)).toHaveLength(2);
848
- expect(await store.expirerecallentries(200, now)).toHaveLength(1);
849
- expect((await store.getrecallindex()).map((one) => one.fingerprint)).toEqual(["f2"]);
850
- });
851
-
852
- it("records the correction memory newest first with the origin and kind filters", async () => {
853
- const store = new sessionmemory(new fakeadapter());
854
- const correction = (id: string, entryorigin: string, kind: string, at: number): correctionentry => ({
855
- id,
856
- origin: entryorigin,
857
- kind,
858
- stepid: "s1",
859
- source: "edited",
860
- original: "the old target",
861
- corrected: "the new target",
862
- reason: "the review edit",
863
- at,
864
- });
865
- await store.addcorrection(correction("c1", origin, "click", now));
866
- await store.addcorrection(correction("c2", "https://other.example", "type", now + 1));
867
- await store.addcorrection({
868
- id: "c3",
869
- origin,
870
- kind: "click",
871
- stepid: "s2",
872
- source: "rejected",
873
- original: "the refused step",
874
- reason: "the refusal",
875
- at: now + 2,
876
- });
877
- expect((await store.getcorrections()).map((one) => one.id)).toEqual(["c3", "c2", "c1"]);
878
- expect((await store.getcorrections({ origin })).map((one) => one.id)).toEqual(["c3", "c1"]);
879
- expect((await store.getcorrections({ kind: "type" })).map((one) => one.id)).toEqual(["c2"]);
880
- expect(await store.getcorrections({ origin: "https://denied.example" })).toEqual([]);
881
- });
882
-
883
- it("expires the correction memory past the window with the boundary kept", async () => {
884
- const store = new sessionmemory(new fakeadapter());
885
- await store.addcorrection({
886
- id: "c1",
887
- origin,
888
- kind: "click",
889
- stepid: "s1",
890
- source: "edited",
891
- original: "o",
892
- corrected: "c",
893
- reason: "r",
894
- at: now - 200,
895
- });
896
- await store.addcorrection({
897
- id: "c2",
898
- origin,
899
- kind: "click",
900
- stepid: "s1",
901
- source: "edited",
902
- original: "o",
903
- corrected: "c",
904
- reason: "r",
905
- at: now,
906
- });
907
- expect(await store.expirecorrectionentries(undefined, now + 500)).toHaveLength(2);
908
- expect(await store.expirecorrectionentries(201, now)).toHaveLength(2);
909
- expect(await store.expirecorrectionentries(200, now)).toHaveLength(1);
910
- expect((await store.getcorrections()).map((one) => one.id)).toEqual(["c2"]);
911
- });
912
-
913
- it("records the consent memory with every decision and boundary", async () => {
914
- const store = new sessionmemory(new fakeadapter());
915
- const entry = (
916
- id: string,
917
- decision: consentmemoryentry["decision"],
918
- entryorigin: string,
919
- at: number,
920
- expiresat?: number,
921
- ): consentmemoryentry => ({
922
- id,
923
- origin: entryorigin,
924
- decision,
925
- boundary: "the form submit",
926
- kinds: ["click"],
927
- at,
928
- ...(expiresat !== undefined ? { expiresat } : {}),
929
- });
930
- await store.addconsentmemoryentry(entry("g1", "grant", origin, now, now + 60_000));
931
- await store.addconsentmemoryentry(entry("d1", "deny", "https://other.example", now + 1));
932
- await store.addconsentmemoryentry(entry("r1", "revoke", origin, now + 2));
933
- await store.addconsentmemoryentry(entry("e1", "expire", origin, now + 3));
934
- expect((await store.getconsentmemory()).map((one) => one.id)).toEqual(["e1", "r1", "d1", "g1"]);
935
- expect((await store.getconsentmemory(origin)).map((one) => one.id)).toEqual(["e1", "r1", "g1"]);
936
- expect(await store.getconsentmemory("https://denied.example")).toEqual([]);
937
- expect((await store.getconsentmemory())[3]?.expiresat).toBe(now + 60_000);
938
- expect((await store.getconsentmemory())[2]?.expiresat).toBeUndefined();
939
- });
940
-
941
- it("caps the error surfaces at five hundred and filters them by step", async () => {
942
- const store = new sessionmemory(new fakeadapter());
943
- for (let index = 0; index < 505; index += 1) {
944
- await store.adderrorsurface({
945
- stepid: `s${index % 3}`,
946
- runid: "run1",
947
- cause: "page",
948
- message: `failure ${index}`,
949
- retry: { allowed: true, reason: "retry" },
950
- context: { index: String(index) },
951
- at: now + index,
952
- });
953
- }
954
- const surfaces = await store.geterrorsurfaces();
955
- expect(surfaces).toHaveLength(500);
956
- expect(surfaces[0]?.message).toBe("failure 504");
957
- expect((await store.geterrorsurfaces("s1"))[0]?.stepid).toBe("s1");
958
- expect(await store.geterrorsurfaces("ghost")).toEqual([]);
959
- });
960
-
961
- it("indexes the history corpus incrementally and answers through the injected searcher", async () => {
962
- const store = new sessionmemory(new fakeadapter());
963
- await store.addhistoryentry({
964
- source: "note",
965
- id: "n1",
966
- origin,
967
- title: "pricing",
968
- text: "the pricing rows",
969
- at: now,
970
- });
971
- await store.addhistoryentry({
972
- source: "note",
973
- id: "n1",
974
- origin,
975
- title: "pricing v2",
976
- text: "the edited pricing rows",
977
- at: now + 1,
978
- });
979
- await store.addhistoryentry({
980
- source: "summary",
981
- id: "run1",
982
- origin,
983
- title: "the run",
984
- text: "the run summary",
985
- outcome: "completed",
986
- at: now + 2,
987
- });
988
- const corpus = await store.gethistoryindex();
989
- expect(corpus).toHaveLength(2);
990
- expect(corpus.find((entry) => entry.id === "n1")?.title).toBe("pricing v2");
991
- const search = (entries: historyindexentry[], query: historysearchquery): historysearchhit[] =>
992
- entries
993
- .filter((entry) => entry.text.includes(query.text))
994
- .map((entry) => ({
995
- source: entry.source,
996
- id: entry.id,
997
- title: entry.title,
998
- excerpt: entry.text,
999
- highlights: [query.text],
1000
- ...(entry.origin !== undefined ? { origin: entry.origin } : {}),
1001
- ...(entry.outcome !== undefined ? { outcome: entry.outcome } : {}),
1002
- at: entry.at,
1003
- }));
1004
- const hits = await store.historysearch({ text: "pricing" }, search);
1005
- expect(hits).toHaveLength(1);
1006
- expect(hits[0]?.id).toBe("n1");
1007
- });
1008
-
1009
- it("isolates the per tab session references", async () => {
1010
- const store = new sessionmemory(new fakeadapter());
1011
- const ref = (tabid: number): tabsessionref => ({ tabid, sessionid: `s${tabid}`, origin, updatedat: now });
1012
- await store.settabsession(ref(1));
1013
- await store.settabsession(ref(2));
1014
- await store.tracktabsession(1);
1015
- await store.tracktabsession(2);
1016
- await store.tracktabsession(2);
1017
- expect((await store.listtabsessions()).map((entry) => entry.tabid)).toEqual([1, 2]);
1018
- expect(await store.gettabsession(1)).toMatchObject({ sessionid: "s1" });
1019
- expect(await store.gettabsession(9)).toBeUndefined();
1020
- await store.settabsession({ tabid: 1, sessionid: "rebound", origin, updatedat: now + 1 });
1021
- expect(await store.gettabsession(1)).toMatchObject({ sessionid: "rebound" });
1022
- });
1023
-
1024
- it("exports the session bundle with notes, summaries and corrections", async () => {
1025
- const store = new sessionmemory(new fakeadapter());
1026
- await store.writesitenote({
1027
- id: "n1",
1028
- origin,
1029
- title: "t",
1030
- body: "b",
1031
- author: "user",
1032
- sensitive: false,
1033
- createdat: now,
1034
- updatedat: now,
1035
- });
1036
- await store.addcorrection({
1037
- id: "c1",
1038
- origin,
1039
- kind: "click",
1040
- stepid: "s1",
1041
- source: "edited",
1042
- original: "o",
1043
- corrected: "c",
1044
- reason: "r",
1045
- at: now,
1046
- });
1047
- const bundle = await store.exportsessionbundle(now + 1);
1048
- expect(bundle).toEqual({
1049
- kind: "sessionbundle",
1050
- notes: await store.getsitenotes(),
1051
- summaries: [],
1052
- corrections: await store.getcorrections(),
1053
- exportedat: now + 1,
1054
- });
1055
- expect(bundle.notes).toHaveLength(1);
1056
- expect(bundle.corrections).toHaveLength(1);
1057
- });
1058
-
1059
- it("keeps the audit trail ordered with the retention window applied exactly", async () => {
1060
- const store = new sessionmemory(new fakeadapter());
1061
- await store.addaudi({ id: "e1", kind: "observe", at: now, summary: "first" });
1062
- await store.addaudi({ id: "e2", kind: "stop", at: now + 1, summary: "second" });
1063
- expect((await store.getaudit()).map((event) => event.id)).toEqual(["e2", "e1"]);
1064
- await store.setsettings({ auditretention: 1 });
1065
- await store.addaudi({ id: "e3", kind: "observe", at: now + 2, summary: "third" });
1066
- expect((await store.getaudit()).map((event) => event.id)).toEqual(["e3"]);
1067
- await store.setsettings({ auditretention: 0 });
1068
- await store.addaudi({ id: "e4", kind: "observe", at: now + 3, summary: "fourth" });
1069
- expect(await store.getaudit()).toEqual([]);
1070
- });
1071
-
1072
- it("keeps the step outcomes with the retention window applied exactly", async () => {
1073
- const store = new sessionmemory(new fakeadapter());
1074
- await store.addoutcome({ stepid: "s1", ok: true, summary: "Done.", at: now });
1075
- await store.addoutcome({ stepid: "s2", ok: false, summary: "Failed.", at: now + 1 });
1076
- expect((await store.getoutcomes()).map((outcome) => outcome.stepid)).toEqual(["s2", "s1"]);
1077
- await store.setsettings({ outcomeretention: 1 });
1078
- await store.addoutcome({ stepid: "s3", ok: true, summary: "Done.", at: now + 2 });
1079
- expect((await store.getoutcomes()).map((outcome) => outcome.stepid)).toEqual(["s3"]);
1080
- await store.setsettings({ outcomeretention: 0 });
1081
- await store.addoutcome({ stepid: "s4", ok: true, summary: "Done.", at: now + 3 });
1082
- expect(await store.getoutcomes()).toEqual([]);
1083
- });
1084
- });