@intentic/sandbox-contract 1.431.0 → 1.432.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (362) hide show
  1. package/README.md +10 -3
  2. package/dist/briefs/agent-ask.d.ts +10 -0
  3. package/dist/briefs/agent-ask.d.ts.map +1 -0
  4. package/dist/briefs/agent-ask.js +2 -0
  5. package/dist/briefs/agent-ask.js.map +1 -0
  6. package/dist/{chores/extension-update.d.ts → briefs/extension-update-brief.d.ts} +1 -1
  7. package/dist/briefs/extension-update-brief.d.ts.map +1 -0
  8. package/dist/{chores/extension-update.js → briefs/extension-update-brief.js} +2 -2
  9. package/dist/briefs/extension-update-brief.js.map +1 -0
  10. package/dist/chores/digest.d.ts.map +1 -1
  11. package/dist/chores/digest.js.map +1 -1
  12. package/dist/chores/index.d.ts +2 -2
  13. package/dist/chores/index.d.ts.map +1 -1
  14. package/dist/chores/index.js +1 -1
  15. package/dist/chores/index.js.map +1 -1
  16. package/dist/chores/prompt.d.ts +1 -9
  17. package/dist/chores/prompt.d.ts.map +1 -1
  18. package/dist/chores/prompt.js +1 -1
  19. package/dist/chores/prompt.js.map +1 -1
  20. package/dist/chores/stack.d.ts.map +1 -1
  21. package/dist/chores/stack.js.map +1 -1
  22. package/dist/chores/verdict.d.ts.map +1 -1
  23. package/dist/chores/verdict.js.map +1 -1
  24. package/dist/chores/workspace-scope.d.ts +1 -3
  25. package/dist/chores/workspace-scope.d.ts.map +1 -1
  26. package/dist/chores/workspace-scope.js +1 -3
  27. package/dist/chores/workspace-scope.js.map +1 -1
  28. package/dist/contracts/agent.contract.d.ts +869 -12
  29. package/dist/contracts/agent.contract.d.ts.map +1 -1
  30. package/dist/contracts/agents.contract.d.ts +291 -4
  31. package/dist/contracts/agents.contract.d.ts.map +1 -1
  32. package/dist/contracts/automations.contract.d.ts +59 -8
  33. package/dist/contracts/automations.contract.d.ts.map +1 -1
  34. package/dist/contracts/capabilities.contract.d.ts +37 -0
  35. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  36. package/dist/contracts/capabilities.contract.js +21 -0
  37. package/dist/contracts/capabilities.contract.js.map +1 -1
  38. package/dist/contracts/ci.contract.d.ts +222 -95
  39. package/dist/contracts/ci.contract.d.ts.map +1 -1
  40. package/dist/contracts/ci.contract.js +87 -26
  41. package/dist/contracts/ci.contract.js.map +1 -1
  42. package/dist/contracts/device-stacks.contract.d.ts +129 -0
  43. package/dist/contracts/device-stacks.contract.d.ts.map +1 -0
  44. package/dist/contracts/device-stacks.contract.js +66 -0
  45. package/dist/contracts/device-stacks.contract.js.map +1 -0
  46. package/dist/contracts/device.contract.d.ts +47 -0
  47. package/dist/contracts/device.contract.d.ts.map +1 -1
  48. package/dist/contracts/extensions.contract.d.ts +603 -0
  49. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  50. package/dist/contracts/extensions.contract.js +10 -1
  51. package/dist/contracts/extensions.contract.js.map +1 -1
  52. package/dist/contracts/needs.contract.d.ts +689 -18
  53. package/dist/contracts/needs.contract.d.ts.map +1 -1
  54. package/dist/contracts/offload.contract.d.ts +21 -0
  55. package/dist/contracts/offload.contract.d.ts.map +1 -1
  56. package/dist/contracts/runner.contract.d.ts +501 -8
  57. package/dist/contracts/runner.contract.d.ts.map +1 -1
  58. package/dist/contracts/seal.contract.d.ts +15 -0
  59. package/dist/contracts/seal.contract.d.ts.map +1 -1
  60. package/dist/contracts/secrets.contract.d.ts +15 -0
  61. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  62. package/dist/contracts/secrets.contract.js +21 -1
  63. package/dist/contracts/secrets.contract.js.map +1 -1
  64. package/dist/contracts/sessions.contract.d.ts +111 -2
  65. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  66. package/dist/contracts/settings.contract.d.ts +57 -42
  67. package/dist/contracts/settings.contract.d.ts.map +1 -1
  68. package/dist/contracts/settings.contract.js +18 -0
  69. package/dist/contracts/settings.contract.js.map +1 -1
  70. package/dist/contracts/stack-grants.contract.d.ts +418 -0
  71. package/dist/contracts/stack-grants.contract.d.ts.map +1 -0
  72. package/dist/contracts/stack-grants.contract.js +46 -0
  73. package/dist/contracts/stack-grants.contract.js.map +1 -0
  74. package/dist/contracts/system.contract.d.ts +188 -69
  75. package/dist/contracts/system.contract.d.ts.map +1 -1
  76. package/dist/contracts/system.contract.js +12 -42
  77. package/dist/contracts/system.contract.js.map +1 -1
  78. package/dist/contracts/workspace.contract.d.ts +0 -55
  79. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  80. package/dist/contracts/workspace.contract.js +0 -19
  81. package/dist/contracts/workspace.contract.js.map +1 -1
  82. package/dist/events/agent-events.d.ts +421 -8
  83. package/dist/events/agent-events.d.ts.map +1 -1
  84. package/dist/events/agent-transcript.d.ts +111 -2
  85. package/dist/events/agent-transcript.d.ts.map +1 -1
  86. package/dist/events/agent-words.d.ts.map +1 -1
  87. package/dist/events/agent-words.js +2 -1
  88. package/dist/events/agent-words.js.map +1 -1
  89. package/dist/events/child-news.d.ts +32 -0
  90. package/dist/events/child-news.d.ts.map +1 -0
  91. package/dist/events/child-news.js +171 -0
  92. package/dist/events/child-news.js.map +1 -0
  93. package/dist/events/prompt-origins.d.ts +42 -0
  94. package/dist/events/prompt-origins.d.ts.map +1 -1
  95. package/dist/events/prompt-origins.js +28 -0
  96. package/dist/events/prompt-origins.js.map +1 -1
  97. package/dist/events/requests.d.ts +14 -0
  98. package/dist/events/requests.d.ts.map +1 -1
  99. package/dist/events/requests.js +12 -0
  100. package/dist/events/requests.js.map +1 -1
  101. package/dist/events/system-events.d.ts +12 -0
  102. package/dist/events/system-events.d.ts.map +1 -1
  103. package/dist/events/transcript.d.ts +559 -10
  104. package/dist/events/transcript.d.ts.map +1 -1
  105. package/dist/events/transcript.js +2 -1
  106. package/dist/events/transcript.js.map +1 -1
  107. package/dist/index.d.ts +2 -4
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +2 -4
  110. package/dist/index.js.map +1 -1
  111. package/dist/models/model-roles.d.ts +91 -37
  112. package/dist/models/model-roles.d.ts.map +1 -1
  113. package/dist/models/model-roles.js +106 -35
  114. package/dist/models/model-roles.js.map +1 -1
  115. package/dist/models/model-setups.d.ts +10 -8
  116. package/dist/models/model-setups.d.ts.map +1 -1
  117. package/dist/models/model-setups.js +15 -15
  118. package/dist/models/model-setups.js.map +1 -1
  119. package/dist/policy/approvals-execution.d.ts +5 -2
  120. package/dist/policy/approvals-execution.d.ts.map +1 -1
  121. package/dist/policy/approvals-execution.js +3 -4
  122. package/dist/policy/approvals-execution.js.map +1 -1
  123. package/dist/policy/batch-runs.d.ts +1 -1
  124. package/dist/policy/batch-runs.d.ts.map +1 -1
  125. package/dist/policy/batch-runs.js +2 -1
  126. package/dist/policy/batch-runs.js.map +1 -1
  127. package/dist/policy/message-limits.d.ts.map +1 -1
  128. package/dist/policy/message-limits.js.map +1 -1
  129. package/dist/policy/org-locks.d.ts +1 -1
  130. package/dist/policy/org-locks.d.ts.map +1 -1
  131. package/dist/policy/org-locks.js +1 -0
  132. package/dist/policy/org-locks.js.map +1 -1
  133. package/dist/policy/shell/workspace-root-exclude.d.ts +4 -0
  134. package/dist/policy/shell/workspace-root-exclude.d.ts.map +1 -0
  135. package/dist/policy/shell/workspace-root-exclude.js +4 -0
  136. package/dist/policy/shell/workspace-root-exclude.js.map +1 -0
  137. package/dist/protocol/doors/listener-protocol.d.ts +7 -0
  138. package/dist/protocol/doors/listener-protocol.d.ts.map +1 -1
  139. package/dist/protocol/doors/listener-protocol.js +1 -0
  140. package/dist/protocol/doors/listener-protocol.js.map +1 -1
  141. package/dist/protocol/doors/webext-links.d.ts.map +1 -1
  142. package/dist/protocol/doors/webext-links.js.map +1 -1
  143. package/dist/protocol/raw/extension-protocol.d.ts +518 -0
  144. package/dist/protocol/raw/extension-protocol.d.ts.map +1 -1
  145. package/dist/protocol/raw/extension-protocol.js +276 -0
  146. package/dist/protocol/raw/extension-protocol.js.map +1 -1
  147. package/dist/protocol/raw/raw-json-routes.d.ts +60 -0
  148. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  149. package/dist/protocol/raw/raw-routes.d.ts +81 -1
  150. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  151. package/dist/protocol/raw/raw-routes.js +16 -1
  152. package/dist/protocol/raw/raw-routes.js.map +1 -1
  153. package/dist/schemas/activity.d.ts.map +1 -1
  154. package/dist/schemas/activity.js.map +1 -1
  155. package/dist/schemas/agent.d.ts +4 -0
  156. package/dist/schemas/agent.d.ts.map +1 -1
  157. package/dist/schemas/agent.js +4 -2
  158. package/dist/schemas/agent.js.map +1 -1
  159. package/dist/schemas/agents-list.d.ts +6 -0
  160. package/dist/schemas/agents-list.d.ts.map +1 -1
  161. package/dist/schemas/agents.d.ts +12 -0
  162. package/dist/schemas/agents.d.ts.map +1 -1
  163. package/dist/schemas/automations.d.ts +87 -27
  164. package/dist/schemas/automations.d.ts.map +1 -1
  165. package/dist/schemas/automations.js +15 -33
  166. package/dist/schemas/automations.js.map +1 -1
  167. package/dist/schemas/ci-deployments.d.ts +30 -0
  168. package/dist/schemas/ci-deployments.d.ts.map +1 -0
  169. package/dist/schemas/ci-deployments.js +18 -0
  170. package/dist/schemas/ci-deployments.js.map +1 -0
  171. package/dist/schemas/ci.d.ts +348 -21
  172. package/dist/schemas/ci.d.ts.map +1 -1
  173. package/dist/schemas/ci.js +110 -19
  174. package/dist/schemas/ci.js.map +1 -1
  175. package/dist/schemas/command-run.d.ts +29 -0
  176. package/dist/schemas/command-run.d.ts.map +1 -0
  177. package/dist/schemas/command-run.js +20 -0
  178. package/dist/schemas/command-run.js.map +1 -0
  179. package/dist/schemas/data-protection.d.ts +15 -2
  180. package/dist/schemas/data-protection.d.ts.map +1 -1
  181. package/dist/schemas/data-protection.js +15 -23
  182. package/dist/schemas/data-protection.js.map +1 -1
  183. package/dist/schemas/device-stacks.d.ts +131 -0
  184. package/dist/schemas/device-stacks.d.ts.map +1 -1
  185. package/dist/schemas/device-stacks.js +81 -0
  186. package/dist/schemas/device-stacks.js.map +1 -1
  187. package/dist/schemas/devices.d.ts +73 -0
  188. package/dist/schemas/devices.d.ts.map +1 -1
  189. package/dist/schemas/devices.js +6 -2
  190. package/dist/schemas/devices.js.map +1 -1
  191. package/dist/schemas/extension-updates.d.ts +1184 -0
  192. package/dist/schemas/extension-updates.d.ts.map +1 -1
  193. package/dist/schemas/extension-updates.js +18 -4
  194. package/dist/schemas/extension-updates.js.map +1 -1
  195. package/dist/schemas/host-power.d.ts +22 -0
  196. package/dist/schemas/host-power.d.ts.map +1 -1
  197. package/dist/schemas/host-power.js +55 -0
  198. package/dist/schemas/host-power.js.map +1 -1
  199. package/dist/schemas/hosts.d.ts +226 -0
  200. package/dist/schemas/hosts.d.ts.map +1 -1
  201. package/dist/schemas/hosts.js +24 -0
  202. package/dist/schemas/hosts.js.map +1 -1
  203. package/dist/schemas/issues.d.ts +35 -249
  204. package/dist/schemas/issues.d.ts.map +1 -1
  205. package/dist/schemas/issues.js +9 -43
  206. package/dist/schemas/issues.js.map +1 -1
  207. package/dist/schemas/maintenance.d.ts.map +1 -1
  208. package/dist/schemas/maintenance.js.map +1 -1
  209. package/dist/schemas/metrics.d.ts +25 -0
  210. package/dist/schemas/metrics.d.ts.map +1 -1
  211. package/dist/schemas/metrics.js +18 -0
  212. package/dist/schemas/metrics.js.map +1 -1
  213. package/dist/schemas/need-kinds.d.ts +19 -0
  214. package/dist/schemas/need-kinds.d.ts.map +1 -0
  215. package/dist/schemas/need-kinds.js +7 -0
  216. package/dist/schemas/need-kinds.js.map +1 -0
  217. package/dist/schemas/needs.d.ts +523 -30
  218. package/dist/schemas/needs.d.ts.map +1 -1
  219. package/dist/schemas/needs.js +36 -6
  220. package/dist/schemas/needs.js.map +1 -1
  221. package/dist/schemas/offload.d.ts +52 -0
  222. package/dist/schemas/offload.d.ts.map +1 -1
  223. package/dist/schemas/offload.js +12 -0
  224. package/dist/schemas/offload.js.map +1 -1
  225. package/dist/schemas/outward-action.d.ts +39 -0
  226. package/dist/schemas/outward-action.d.ts.map +1 -0
  227. package/dist/schemas/outward-action.js +40 -0
  228. package/dist/schemas/outward-action.js.map +1 -0
  229. package/dist/schemas/providers/plan-limits.d.ts +1 -0
  230. package/dist/schemas/providers/plan-limits.d.ts.map +1 -1
  231. package/dist/schemas/providers/plan-limits.js +1 -0
  232. package/dist/schemas/providers/plan-limits.js.map +1 -1
  233. package/dist/schemas/secrets.d.ts +17 -0
  234. package/dist/schemas/secrets.d.ts.map +1 -1
  235. package/dist/schemas/secrets.js +12 -5
  236. package/dist/schemas/secrets.js.map +1 -1
  237. package/dist/schemas/settings-history.d.ts +1 -1
  238. package/dist/schemas/settings-history.d.ts.map +1 -1
  239. package/dist/schemas/settings-history.js +5 -4
  240. package/dist/schemas/settings-history.js.map +1 -1
  241. package/dist/schemas/settings-savings.d.ts +58 -0
  242. package/dist/schemas/settings-savings.d.ts.map +1 -1
  243. package/dist/schemas/settings-savings.js +22 -0
  244. package/dist/schemas/settings-savings.js.map +1 -1
  245. package/dist/schemas/settings.d.ts +2 -42
  246. package/dist/schemas/settings.d.ts.map +1 -1
  247. package/dist/schemas/settings.js +5 -6
  248. package/dist/schemas/settings.js.map +1 -1
  249. package/dist/schemas/stack-grants.d.ts +60 -0
  250. package/dist/schemas/stack-grants.d.ts.map +1 -0
  251. package/dist/schemas/stack-grants.js +33 -0
  252. package/dist/schemas/stack-grants.js.map +1 -0
  253. package/dist/schemas/watch-sources.d.ts +72 -0
  254. package/dist/schemas/watch-sources.d.ts.map +1 -0
  255. package/dist/schemas/watch-sources.js +88 -0
  256. package/dist/schemas/watch-sources.js.map +1 -0
  257. package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
  258. package/dist/schemas/workspace/workspace-search.js +1 -1
  259. package/dist/schemas/workspace/workspace-search.js.map +1 -1
  260. package/dist/schemas/wsl-memory.d.ts +76 -0
  261. package/dist/schemas/wsl-memory.d.ts.map +1 -0
  262. package/dist/schemas/wsl-memory.js +36 -0
  263. package/dist/schemas/wsl-memory.js.map +1 -0
  264. package/dist/state/auth-state.d.ts.map +1 -1
  265. package/dist/state/auth-state.js +2 -0
  266. package/dist/state/auth-state.js.map +1 -1
  267. package/dist/state/definition.d.ts +4 -8
  268. package/dist/state/definition.d.ts.map +1 -1
  269. package/dist/state/workspace-state.d.ts +8 -3
  270. package/dist/state/workspace-state.d.ts.map +1 -1
  271. package/dist/state/workspace-state.js +8 -3
  272. package/dist/state/workspace-state.js.map +1 -1
  273. package/package.json +5 -5
  274. package/src/briefs/agent-ask.ts +23 -0
  275. package/src/{chores/extension-update.ts → briefs/extension-update-brief.ts} +3 -2
  276. package/src/chores/digest.ts +1 -0
  277. package/src/chores/index.ts +13 -2
  278. package/src/chores/prompt.ts +3 -18
  279. package/src/chores/stack.ts +1 -0
  280. package/src/chores/verdict.ts +1 -0
  281. package/src/chores/workspace-scope.ts +3 -8
  282. package/src/contracts/capabilities.contract.ts +24 -0
  283. package/src/contracts/ci.contract.ts +119 -37
  284. package/src/contracts/device-stacks.contract.ts +97 -0
  285. package/src/contracts/extensions.contract.ts +11 -0
  286. package/src/contracts/secrets.contract.ts +27 -0
  287. package/src/contracts/settings.contract.ts +24 -0
  288. package/src/contracts/stack-grants.contract.ts +51 -0
  289. package/src/contracts/system.contract.ts +16 -59
  290. package/src/contracts/workspace.contract.ts +0 -22
  291. package/src/events/agent-words.ts +3 -1
  292. package/src/events/child-news.test.ts +91 -0
  293. package/src/events/child-news.ts +269 -0
  294. package/src/events/prompt-origins.ts +35 -0
  295. package/src/events/requests.ts +18 -0
  296. package/src/events/transcript.ts +10 -1
  297. package/src/index.ts +3 -6
  298. package/src/models/model-roles.test.ts +61 -4
  299. package/src/models/model-roles.ts +153 -49
  300. package/src/models/model-setups.ts +49 -26
  301. package/src/policy/approvals-execution.ts +11 -6
  302. package/src/policy/batch-runs.ts +2 -2
  303. package/src/policy/message-limits.ts +8 -4
  304. package/src/policy/org-locks.ts +1 -0
  305. package/src/policy/shell/workspace-root-exclude.ts +11 -0
  306. package/src/protocol/doors/listener-protocol.ts +14 -0
  307. package/src/protocol/doors/webext-links.ts +3 -1
  308. package/src/protocol/raw/extension-protocol.ts +469 -2
  309. package/src/protocol/raw/raw-routes.ts +45 -4
  310. package/src/schemas/activity.ts +2 -1
  311. package/src/schemas/agent.test.ts +3 -0
  312. package/src/schemas/agent.ts +10 -4
  313. package/src/schemas/automations.ts +25 -41
  314. package/src/schemas/ci-deployments.ts +26 -0
  315. package/src/schemas/ci.ts +185 -45
  316. package/src/schemas/command-run.ts +44 -0
  317. package/src/schemas/data-protection.ts +28 -34
  318. package/src/schemas/device-stacks.ts +162 -3
  319. package/src/schemas/devices.ts +13 -2
  320. package/src/schemas/extension-updates.ts +27 -7
  321. package/src/schemas/host-power.test.ts +53 -0
  322. package/src/schemas/host-power.ts +96 -2
  323. package/src/schemas/hosts.test.ts +32 -0
  324. package/src/schemas/hosts.ts +62 -0
  325. package/src/schemas/issues.ts +29 -86
  326. package/src/schemas/maintenance.ts +4 -3
  327. package/src/schemas/metrics.ts +35 -0
  328. package/src/schemas/need-kinds.ts +13 -0
  329. package/src/schemas/needs.ts +57 -16
  330. package/src/schemas/offload.ts +31 -0
  331. package/src/schemas/outward-action.ts +47 -0
  332. package/src/schemas/providers/plan-limits.ts +1 -0
  333. package/src/schemas/secrets.ts +23 -5
  334. package/src/schemas/settings-history.ts +10 -5
  335. package/src/schemas/settings-savings.ts +29 -0
  336. package/src/schemas/settings.test.ts +23 -23
  337. package/src/schemas/settings.ts +10 -12
  338. package/src/schemas/stack-grants.ts +59 -0
  339. package/src/schemas/version-seam.test.ts +4 -1
  340. package/src/schemas/watch-sources.ts +127 -0
  341. package/src/schemas/workspace/workspace-search.ts +5 -2
  342. package/src/schemas/wsl-memory.ts +59 -0
  343. package/src/state/auth-state.ts +7 -0
  344. package/src/state/workspace-state.ts +18 -18
  345. package/src/text/embed.ts +2 -2
  346. package/dist/chores/extension-update.d.ts.map +0 -1
  347. package/dist/chores/extension-update.js.map +0 -1
  348. package/dist/contracts/chores.contract.d.ts +0 -213
  349. package/dist/contracts/chores.contract.d.ts.map +0 -1
  350. package/dist/contracts/chores.contract.js +0 -32
  351. package/dist/contracts/chores.contract.js.map +0 -1
  352. package/dist/contracts/issues.contract.d.ts +0 -106
  353. package/dist/contracts/issues.contract.d.ts.map +0 -1
  354. package/dist/contracts/issues.contract.js +0 -50
  355. package/dist/contracts/issues.contract.js.map +0 -1
  356. package/src/chores/chores.test.ts +0 -24
  357. package/src/chores/digest.test.ts +0 -27
  358. package/src/chores/probes.integration.test.ts +0 -494
  359. package/src/chores/stack.test.ts +0 -140
  360. package/src/chores/verdict.test.ts +0 -761
  361. package/src/contracts/chores.contract.ts +0 -39
  362. package/src/contracts/issues.contract.ts +0 -53
@@ -1,761 +0,0 @@
1
- import type {
2
- Bundle,
3
- ChoreLedgerEntry,
4
- ChorePackage,
5
- ChoreShape,
6
- ChoreSignals,
7
- ChoresReport,
8
- Duplication,
9
- ProbeResult,
10
- UiScan,
11
- } from "../schemas/maintenance.js";
12
- import { choreById, CHORES } from "./chores.js";
13
- import { digestOf } from "./digest.js";
14
- import { assessReport, choreAnswer, choreAnswered, ledgerKey, unseenVerdicts } from "./verdict.js";
15
-
16
- // The chore verdict state machine, tested at the distinctions a simpler design gets wrong: reporting an unmeasured repo
17
- // clean, badging the same finding repeatedly, a snooze becoming permanent, or a false-positive report being forgotten.
18
-
19
- const DAY = 86_400_000;
20
- const NOW = Date.UTC(2026, 6, 31);
21
-
22
- const pkg = (over: Partial<ChorePackage> = {}): ChorePackage => ({
23
- dir: `_libs/thing`,
24
- name: `@x/thing`,
25
- dependencies: [],
26
- devDependencies: [],
27
- documented: true,
28
- ...over,
29
- });
30
-
31
- // A repo where every chore applies by default, so an applicability test only has to toggle the one fact it's about.
32
- const shape = (over: Partial<ChoreShape> = {}): ChoreShape => ({
33
- docs: [`docs/architecture/repo.md`],
34
- dockerfiles: [`Dockerfile`],
35
- ci: [`.github/workflows/ci.yml`],
36
- lockfile: true,
37
- packageManifest: true,
38
- deps: [`tailwindcss`, `vue`],
39
- ...over,
40
- });
41
-
42
- const signals = (over: Partial<ChoreSignals> = {}): ChoreSignals => ({
43
- packages: [pkg()],
44
- shape: shape(),
45
- hotspots: [],
46
- keyModules: [],
47
- totals: { files: 100, symbols: 0, complexity: 0, hotspots: 0 },
48
- indexed: false,
49
- ...over,
50
- });
51
-
52
- const probe = (over: Partial<ProbeResult> & Pick<ProbeResult, "id">): ProbeResult => ({ state: `ok`, ranAt: NOW - DAY, tookMs: 1000, ...over });
53
-
54
- const auditProbe = (names: readonly string[]): ProbeResult =>
55
- probe({
56
- id: `audit`,
57
- facts: {
58
- id: `audit`,
59
- advisories: names.map((name) => ({ name, severity: `high` as const, title: `${name} is bad`, patched: `>=2`, dev: false })),
60
- },
61
- });
62
-
63
- const report = (over: Partial<ChoresReport> = {}): ChoresReport => ({
64
- repos: [{ repo: `app`, probes: [], signals: signals() }],
65
- ledger: [],
66
- // Verdicts are about evidence, not work in flight; empty here since no test in this file depends on it.
67
- running: [],
68
- node: `v24.18.0`,
69
- ...over,
70
- });
71
-
72
- const verdictFor = (input: ChoresReport, chore: string, repo = `app`) => {
73
- const found = assessReport(input, NOW).find((verdict) => verdict.chore.id === chore && verdict.repo === repo);
74
- if (found === undefined) {
75
- throw new Error(`no verdict for ${chore} in ${repo}`);
76
- }
77
- return found;
78
- };
79
-
80
- describe(`what "we have not measured this" means`, () => {
81
- test(`a chore whose probe never ran is unavailable, not clear`, () => {
82
- const verdict = verdictFor(report(), `security-advisories`);
83
- expect(verdict.state).toBe(`unavailable`);
84
- expect(verdict.detail.join(` `)).toContain(`Security advisories`);
85
- });
86
-
87
- test(`a probe the repository cannot run says so, and never badges`, () => {
88
- const knipReason = `knip is not a devDependency`;
89
- const input = report({
90
- repos: [{ repo: `app`, probes: [probe({ id: `knip`, state: `unavailable`, reason: knipReason })], signals: signals() }],
91
- });
92
- const verdict = verdictFor(input, `dead-code`);
93
- expect(verdict.state).toBe(`unavailable`);
94
- expect(verdict.detail[0]).toContain(knipReason);
95
- expect(unseenVerdicts([verdict], {})).toEqual([]);
96
- });
97
-
98
- test(`a probe that ran and found nothing is clear, with no prompt to spend a turn on`, () => {
99
- const verdict = verdictFor(report({ repos: [{ repo: `app`, probes: [auditProbe([])], signals: signals() }] }), `security-advisories`);
100
- expect(verdict.state).toBe(`clear`);
101
- expect(verdict.prompt).toBeUndefined();
102
- });
103
- });
104
-
105
- // A package the pnpm workspace leaves out is fixed in its own folder, so its findings have to say which folder; the
106
- // workspace's own findings keep the digest they always had, so adding the field rebadges nothing already settled.
107
- describe(`findings from a package the workspace leaves out`, () => {
108
- const advisory = (name: string, standalone?: string) => ({
109
- name,
110
- severity: `critical` as const,
111
- title: `${name} is bad`,
112
- patched: `>=2`,
113
- dev: false,
114
- ...(standalone === undefined ? {} : { standalone }),
115
- });
116
- const withFacts = (advisories: ReturnType<typeof advisory>[]) =>
117
- report({ repos: [{ repo: `app`, probes: [probe({ id: `audit`, facts: { id: `audit`, advisories } })], signals: signals() }] });
118
-
119
- test(`name their folder in the panel and in the prompt`, () => {
120
- const verdict = verdictFor(withFacts([advisory(`@capacitor/ios`, `_editor/ios-app`)]), `security-advisories`);
121
- expect(verdict.detail).toEqual([`critical · @capacitor/ios in _editor/ios-app, @capacitor/ios is bad`]);
122
- expect(verdict.prompt).toContain(`@capacitor/ios in _editor/ios-app (critical`);
123
- });
124
-
125
- test(`are a different finding from the same package in the workspace, which keeps its old digest`, () => {
126
- const workspace = verdictFor(withFacts([advisory(`left-pad`)]), `security-advisories`);
127
- const standalone = verdictFor(withFacts([advisory(`left-pad`, `shell`)]), `security-advisories`);
128
- expect(workspace.digest).toBe(digestOf(`left-pad@critical`));
129
- expect(standalone.digest).not.toBe(workspace.digest);
130
- });
131
- });
132
-
133
- describe(`the ledger debounces; it cannot hide`, () => {
134
- const withAdvisories = report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] });
135
- const ledgerEntry = (over: Partial<ChoreLedgerEntry> = {}): ChoreLedgerEntry => ({
136
- repo: `app`,
137
- chore: `security-advisories`,
138
- ranAt: NOW - DAY,
139
- runId: `r1`,
140
- outcome: `acted`,
141
- digest: verdictFor(withAdvisories, `security-advisories`).digest,
142
- ...over,
143
- });
144
-
145
- test(`a run against this exact evidence leaves the chore due but settled: shown, never badged`, () => {
146
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry()] }, `security-advisories`);
147
- expect(verdict.state).toBe(`due`);
148
- expect(verdict.settled).toBe(true);
149
- expect(unseenVerdicts([verdict], {})).toEqual([]);
150
- });
151
-
152
- test(`evidence that has moved since the run is unsettled again`, () => {
153
- const moved = report({
154
- repos: [{ repo: `app`, probes: [auditProbe([`left-pad`, `minimist`])], signals: signals() }],
155
- ledger: [ledgerEntry()],
156
- });
157
- const verdict = verdictFor(moved, `security-advisories`);
158
- expect(verdict.state).toBe(`due`);
159
- expect(verdict.settled).toBe(false);
160
- expect(unseenVerdicts([verdict], {})).toHaveLength(1);
161
- });
162
-
163
- test(`an agent reporting the findings did not hold up clears the chore until the evidence changes`, () => {
164
- const due = verdictFor(withAdvisories, `security-advisories`);
165
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ outcome: `clean` })] }, `security-advisories`);
166
- expect(verdict.state).toBe(`clear`);
167
- expect(verdict.headline).not.toBe(due.headline);
168
- });
169
-
170
- test(`a snooze silences a due chore without hiding it, and lapses on its own`, () => {
171
- const snoozed = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ snoozedUntil: NOW + DAY })] }, `security-advisories`);
172
- expect(snoozed.state).toBe(`snoozed`);
173
- expect(snoozed.detail).not.toEqual([]);
174
- expect(unseenVerdicts([snoozed], {})).toEqual([]);
175
-
176
- const lapsed = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ snoozedUntil: NOW - 1 })] }, `security-advisories`);
177
- expect(lapsed.state).toBe(`due`);
178
- });
179
-
180
- test(`settlement expires with the chore's cadence, and persists for the chores that have none`, () => {
181
- const dependencies = choreById(`dependencies-outdated`);
182
- expect(dependencies?.cadenceMs).toBeGreaterThan(0);
183
- expect(choreById(`security-advisories`)?.cadenceMs).toBe(0);
184
-
185
- const old = { ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 400 * DAY })] };
186
- expect(verdictFor(old, `security-advisories`).settled).toBe(true);
187
- });
188
- });
189
-
190
- // Guards the case an unchanged digest alone can't tell apart: a probe that never re-ran looks identical to a fix
191
- // that didn't work, and both used to read as a confident `due`.
192
- describe(`a measurement older than the work is not evidence about the work`, () => {
193
- const withAdvisories = report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] });
194
- const ledgerEntry = (over: Partial<ChoreLedgerEntry> = {}): ChoreLedgerEntry => ({
195
- repo: `app`,
196
- chore: `security-advisories`,
197
- ranAt: NOW - DAY,
198
- runId: `r1`,
199
- outcome: `acted`,
200
- digest: verdictFor(withAdvisories, `security-advisories`).digest,
201
- ...over,
202
- });
203
-
204
- // Probe ran a day ago, the ledger entry an hour ago: nothing has looked since the entry.
205
- test(`a turn that landed after the measurement steps the chore down from due`, () => {
206
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000 })] }, `security-advisories`);
207
- expect(verdict.state).toBe(`stale`);
208
- expect(verdict.detail).not.toEqual([]);
209
- expect(verdict.settled).toBe(false);
210
- });
211
-
212
- test(`a stale chore offers no turn and never badges`, () => {
213
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000 })] }, `security-advisories`);
214
- expect(verdict.prompt).toBeUndefined();
215
- expect(unseenVerdicts([verdict], {})).toEqual([]);
216
- });
217
-
218
- test(`re-measuring after the turn restores the verdict: due, and now genuinely settled`, () => {
219
- const remeasured = report({
220
- repos: [{ repo: `app`, probes: [{ ...auditProbe([`left-pad`]), ranAt: NOW - 60_000 }], signals: signals() }],
221
- ledger: [ledgerEntry({ ranAt: NOW - 3_600_000 })],
222
- });
223
- const verdict = verdictFor(remeasured, `security-advisories`);
224
- expect(verdict.state).toBe(`due`);
225
- expect(verdict.settled).toBe(true);
226
- });
227
-
228
- test(`an agent reporting the findings did not hold up still clears the chore`, () => {
229
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000, outcome: `clean` })] }, `security-advisories`);
230
- expect(verdict.state).toBe(`clear`);
231
- });
232
-
233
- test(`a snooze still wins`, () => {
234
- const verdict = verdictFor(
235
- { ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000, snoozedUntil: NOW + DAY })] },
236
- `security-advisories`,
237
- );
238
- expect(verdict.state).toBe(`snoozed`);
239
- });
240
-
241
- test(`every measured verdict says when it was measured, and the unmeasurable ones say nothing`, () => {
242
- expect(verdictFor(withAdvisories, `security-advisories`).measuredAt).toBe(NOW - DAY);
243
- expect(verdictFor(report(), `standardize-patterns`).measuredAt).toBeUndefined();
244
- expect(verdictFor(report(), `security-advisories`).measuredAt).toBeUndefined();
245
- });
246
- });
247
-
248
- describe(`surveys are due because time passed, and say so`, () => {
249
- const surveyLedger = (ranAt: number): ChoreLedgerEntry => ({
250
- repo: `app`,
251
- chore: `standardize-patterns`,
252
- ranAt,
253
- runId: `r1`,
254
- outcome: `reported`,
255
- digest: `whatever`,
256
- });
257
-
258
- test(`never run is due`, () => {
259
- expect(verdictFor(report(), `standardize-patterns`).state).toBe(`due`);
260
- });
261
-
262
- test(`run inside the period is clear, and reports when it was read rather than claiming nothing to do`, () => {
263
- const daysAgo = 10;
264
- const verdict = verdictFor({ ...report(), ledger: [surveyLedger(NOW - daysAgo * DAY)] }, `standardize-patterns`);
265
- expect(verdict.state).toBe(`clear`);
266
- expect(verdict.headline).toContain(String(daysAgo));
267
- });
268
-
269
- test(`run longer ago than the cadence is due again`, () => {
270
- expect(verdictFor({ ...report(), ledger: [surveyLedger(NOW - 200 * DAY)] }, `standardize-patterns`).state).toBe(`due`);
271
- });
272
- });
273
-
274
- describe(`the badge speaks about transitions, not about statistics`, () => {
275
- const withAdvisories = report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] });
276
-
277
- test(`acknowledging a digest silences it, and the next distinct finding still gets through`, () => {
278
- const first = verdictFor(withAdvisories, `security-advisories`);
279
- expect(unseenVerdicts([first], {})).toHaveLength(1);
280
-
281
- const seen = { [ledgerKey(`app`, `security-advisories`)]: first.digest };
282
- expect(unseenVerdicts([first], seen)).toEqual([]);
283
-
284
- const next = verdictFor(
285
- report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`, `tar`])], signals: signals() }] }),
286
- `security-advisories`,
287
- );
288
- expect(unseenVerdicts([next], seen)).toHaveLength(1);
289
- });
290
-
291
- test(`a standing backlog of undocumented packages goes quiet once seen, but a new package speaks`, () => {
292
- const undocumented = (dirs: readonly string[]): ChoresReport =>
293
- report({
294
- repos: [{ repo: `app`, probes: [], signals: signals({ packages: dirs.map((dir) => pkg({ dir, name: dir, documented: false })) }) }],
295
- });
296
-
297
- const backlog = verdictFor(undocumented([`_libs/a`, `_libs/b`]), `documentation-refresh`);
298
- expect(backlog.state).toBe(`due`);
299
- const seen = { [ledgerKey(`app`, `documentation-refresh`)]: backlog.digest };
300
- expect(unseenVerdicts([backlog], seen)).toEqual([]);
301
-
302
- const grown = verdictFor(undocumented([`_libs/a`, `_libs/b`, `_libs/new`]), `documentation-refresh`);
303
- expect(unseenVerdicts([grown], seen)).toHaveLength(1);
304
- });
305
- });
306
-
307
- describe(`the findings themselves`, () => {
308
- test(`two libraries for one job is the finding; one is not`, () => {
309
- const one = report({ repos: [{ repo: `app`, probes: [], signals: signals({ packages: [pkg({ dependencies: [`zod`] })] }) }] });
310
- expect(verdictFor(one, `library-overlap`).state).toBe(`clear`);
311
-
312
- const two = report({ repos: [{ repo: `app`, probes: [], signals: signals({ packages: [pkg({ dependencies: [`zod`, `yup`] })] }) }] });
313
- const verdict = verdictFor(two, `library-overlap`);
314
- expect(verdict.state).toBe(`due`);
315
- expect(verdict.detail[0]).toContain(`schema validation`);
316
- });
317
-
318
- test(`an unknown node major is not reported as end-of-life`, () => {
319
- expect(verdictFor({ ...report(), node: `v99.0.0` }, `runtime-eol`).state).toBe(`clear`);
320
- });
321
-
322
- test(`a runtime past its end-of-life date is the one ordinary finding that reaches warning`, () => {
323
- const verdict = verdictFor({ ...report(), node: `v18.20.0` }, `runtime-eol`);
324
- expect(verdict.state).toBe(`due`);
325
- expect(verdict.severity).toBe(`warning`);
326
- });
327
-
328
- test(`a supported runtime is clear`, () => {
329
- expect(verdictFor({ ...report(), node: `v24.18.0` }, `runtime-eol`).state).toBe(`clear`);
330
- });
331
- });
332
-
333
- describe(`the prompts`, () => {
334
- const dueVerdict = () =>
335
- verdictFor(report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] }), `security-advisories`);
336
-
337
- test(`name the artefacts, not just how many there were`, () => {
338
- const verdict = dueVerdict();
339
- expect(verdict.prompt).toContain(`left-pad`);
340
- expect(verdict.prompt).toContain(`app`);
341
- });
342
-
343
- test(`tell an acting chore to keep the diff reviewable and a reporting chore not to edit at all`, () => {
344
- const acting = dueVerdict().prompt ?? ``;
345
- const survey = verdictFor(report(), `standardize-patterns`);
346
- expect(acting).toContain(`left-pad`);
347
- expect(acting).not.toBe(survey.prompt);
348
- expect(survey.prompt).not.toBe(acting);
349
- });
350
-
351
- test(`every chore that can be due can produce a prompt`, () => {
352
- const verdicts = assessReport(
353
- report({
354
- repos: [
355
- {
356
- repo: `app`,
357
- probes: [
358
- auditProbe([`left-pad`]),
359
- probe({
360
- id: `outdated`,
361
- facts: {
362
- id: `outdated`,
363
- packages: [{ name: `vue`, current: `1.0.0`, latest: `2.0.0`, kind: `major`, section: `dependencies` }],
364
- },
365
- }),
366
- probe({
367
- id: `knip`,
368
- facts: {
369
- id: `knip`,
370
- deadCode: { files: 3, exports: 2, types: 0, dependencies: 1, devDependencies: 0, sample: [`a.ts`] },
371
- },
372
- }),
373
- probe({
374
- id: `jscpd`,
375
- facts: {
376
- id: `jscpd`,
377
- duplication: { percentage: 9, clones: 4, top: [{ lines: 20, first: `a.ts`, second: `b.ts` }] },
378
- },
379
- }),
380
- ],
381
- signals: signals({ packages: [pkg({ documented: false, dependencies: [`zod`, `joi`] })] }),
382
- },
383
- ],
384
- node: `v18.20.0`,
385
- }),
386
- NOW,
387
- );
388
- const due = verdicts.filter((verdict) => verdict.state === `due`);
389
- expect(due.length).toBeGreaterThanOrEqual(8);
390
- for (const verdict of due) {
391
- expect(verdict.prompt, verdict.chore.id).toBeTypeOf(`string`);
392
- expect(verdict.digest, verdict.chore.id).not.toBe(``);
393
- }
394
- const promptFor = (chore: string) => due.find((verdict) => verdict.chore.id === chore)?.prompt ?? ``;
395
- expect(promptFor(`security-advisories`)).toContain(`left-pad`);
396
- expect(promptFor(`dependencies-outdated`)).toContain(`vue 1.0.0 → 2.0.0`);
397
- expect(promptFor(`dead-code`)).toContain(`a.ts`);
398
- expect(promptFor(`duplication`)).toContain(`a.ts ↔ b.ts`);
399
- expect(promptFor(`documentation-refresh`)).toContain(`_libs/thing`);
400
- expect(promptFor(`library-overlap`)).toContain(`zod`);
401
- expect(promptFor(`runtime-eol`)).toContain(`v18.20.0`);
402
- });
403
- });
404
-
405
- // Applicability: whether the chore is a question worth asking here, as against whether the answer is yes. Each
406
- // case is a row the previous design could never act on (re-reading documentation that doesn't exist, slimming an image
407
- // that isn't there).
408
- describe(`what does not apply here`, () => {
409
- const withShape = (over: Partial<ChoreShape>): ChoresReport =>
410
- report({ repos: [{ repo: `app`, probes: [], signals: signals({ shape: shape(over) }) }] });
411
-
412
- test(`a repository with no documents is not asked to re-read its documentation`, () => {
413
- const verdict = verdictFor(withShape({ docs: [] }), `documentation-drift`);
414
- expect(verdict.state).toBe(`not-applicable`);
415
- expect(verdict.headline).toContain(`document`);
416
- expect(verdict.prompt).toBeUndefined();
417
- });
418
-
419
- test(`a repository with no Dockerfile is not asked to slim its image`, () => {
420
- expect(verdictFor(withShape({ dockerfiles: [] }), `docker-image`).state).toBe(`not-applicable`);
421
- });
422
-
423
- test(`a repository with no pipeline is not asked to tighten one`, () => {
424
- expect(verdictFor(withShape({ ci: [] }), `ci-hygiene`).state).toBe(`not-applicable`);
425
- });
426
-
427
- test(`a repository that is not a Node project is not offered the npm-shaped chores`, () => {
428
- const foreign = withShape({ packageManifest: false, lockfile: false });
429
- for (const chore of [`dependencies-outdated`, `runtime-eol`, `dead-code`, `security-advisories`, `deprecated-apis`]) {
430
- expect(verdictFor(foreign, chore).state, chore).toBe(`not-applicable`);
431
- }
432
- });
433
-
434
- test(`a repository that is not a workspace is not asked about per-package documents or library overlap`, () => {
435
- const single = report({ repos: [{ repo: `app`, probes: [], signals: signals({ packages: [] }) }] });
436
- expect(verdictFor(single, `documentation-refresh`).state).toBe(`not-applicable`);
437
- expect(verdictFor(single, `library-overlap`).state).toBe(`not-applicable`);
438
- });
439
-
440
- test(`a tiny repository is not surveyed for cross-cutting patterns it cannot have`, () => {
441
- const fileCount = 4;
442
- const tiny = report({
443
- repos: [{ repo: `app`, probes: [], signals: signals({ totals: { files: fileCount, symbols: 0, complexity: 0, hotspots: 0 } }) }],
444
- });
445
- const verdict = verdictFor(tiny, `standardize-patterns`);
446
- expect(verdict.state).toBe(`not-applicable`);
447
- expect(verdict.headline).toContain(String(fileCount));
448
- });
449
-
450
- test(`applicability is decided before measurement, so a missing probe never masks it`, () => {
451
- expect(verdictFor(withShape({ packageManifest: false }), `dead-code`).state).toBe(`not-applicable`);
452
- });
453
-
454
- test(`a chore that does not apply can never reach the rail`, () => {
455
- const verdicts = assessReport(withShape({ docs: [], dockerfiles: [], ci: [] }), NOW).filter((verdict) => verdict.state === `not-applicable`);
456
- expect(verdicts.length).toBeGreaterThanOrEqual(3);
457
- expect(unseenVerdicts(verdicts, {})).toEqual([]);
458
- });
459
-
460
- test(`a fully-equipped repository rules nothing out`, () => {
461
- expect(assessReport(withShape({}), NOW).filter((verdict) => verdict.state === `not-applicable`)).toEqual([]);
462
- });
463
-
464
- test(`applicability reasons are bare causes, so the ones that mean the same thing group`, () => {
465
- const bare = withShape({ packageManifest: false, lockfile: false, docs: [], ci: [], dockerfiles: [], deps: [] });
466
- const causes = assessReport(bare, NOW)
467
- .filter((verdict) => verdict.state === `not-applicable`)
468
- .map((verdict) => verdict.headline);
469
- for (const cause of causes) {
470
- expect(cause, cause).toMatch(/^[a-z]/);
471
- expect(cause.split(` `).length, cause).toBeLessThanOrEqual(4);
472
- }
473
- // Four chores are ruled out by one absent file; the strip says so once rather than four times.
474
- expect(causes.filter((cause) => cause === `no package.json`)).toHaveLength(4);
475
- });
476
- });
477
-
478
- // Four chores over two probes, tested where they decide something: the share that makes a bundle a finding, the
479
- // names that make two components one, and the digests, since three of the four measure things that move on every markup
480
- // edit.
481
- const uiProbe = (scan: Partial<UiScan> = {}): ProbeResult =>
482
- probe({ id: `ui`, facts: { id: `ui`, scan: { components: [], bypasses: [], idioms: [], ...scan } } });
483
-
484
- const bundleProbe = (assets: Bundle["assets"]): ProbeResult =>
485
- probe({
486
- id: `bundle`,
487
- facts: {
488
- id: `bundle`,
489
- bundle: {
490
- dir: `dist`,
491
- assets,
492
- totalBytes: assets.reduce((sum, asset) => sum + asset.bytes, 0),
493
- totalGzip: assets.reduce((sum, asset) => sum + asset.gzip, 0),
494
- },
495
- },
496
- });
497
-
498
- const jscpdProbe = (top: Duplication["top"]): ProbeResult =>
499
- probe({ id: `jscpd`, facts: { id: `jscpd`, duplication: { percentage: 1, clones: top.length, top } } });
500
-
501
- const withProbes = (probes: readonly ProbeResult[], over: Partial<ChoreShape> = {}): ChoresReport =>
502
- report({ repos: [{ repo: `app`, probes: [...probes], signals: signals({ shape: shape(over) }) }] });
503
-
504
- const chunk = (path: string, gzip: number): Bundle["assets"][number] => ({ path, bytes: gzip * 3, gzip });
505
-
506
- describe(`what the browser downloads`, () => {
507
- test(`one chunk over half the transfer is the finding, and the headline names it`, () => {
508
- const verdict = verdictFor(
509
- withProbes([bundleProbe([chunk(`dist/vendor-DlAUqK2U.js`, 800), chunk(`dist/index-a1.js`, 100), chunk(`dist/s-b2.css`, 50)])]),
510
- `bundle-weight`,
511
- );
512
- expect(verdict.state).toBe(`due`);
513
- expect(verdict.headline).toContain(`dist/vendor-DlAUqK2U.js`);
514
- expect(verdict.headline).toContain(`84%`);
515
- });
516
-
517
- test(`a build that is actually split says nothing`, () => {
518
- const even = [chunk(`dist/a-1.js`, 100), chunk(`dist/b-2.js`, 100), chunk(`dist/c-3.js`, 100), chunk(`dist/d-4.js`, 100)];
519
- expect(verdictFor(withProbes([bundleProbe(even)]), `bundle-weight`).state).toBe(`clear`);
520
- });
521
-
522
- test(`too few assets to have a shape is clear, not due`, () => {
523
- expect(verdictFor(withProbes([bundleProbe([chunk(`dist/a-1.js`, 900), chunk(`dist/b-2.js`, 10)])]), `bundle-weight`).state).toBe(`clear`);
524
- });
525
-
526
- test(`rebuilding the same code does not read as new evidence`, () => {
527
- const before = verdictFor(
528
- withProbes([bundleProbe([chunk(`dist/vendor-DlAUqK2U.js`, 800), chunk(`dist/index-a1b2c3d4.js`, 100), chunk(`dist/s.css`, 50)])]),
529
- `bundle-weight`,
530
- );
531
- const after = verdictFor(
532
- withProbes([bundleProbe([chunk(`dist/vendor-Zq99XxYw.js`, 802), chunk(`dist/index-9z8y7x6w.js`, 101), chunk(`dist/s.css`, 50)])]),
533
- `bundle-weight`,
534
- );
535
- expect(after.digest).toBe(before.digest);
536
- });
537
-
538
- test(`a genuinely different chunk appearing does`, () => {
539
- const before = verdictFor(
540
- withProbes([bundleProbe([chunk(`dist/vendor-DlAUqK2U.js`, 800), chunk(`dist/index-a1b2c3d4.js`, 100), chunk(`dist/s.css`, 50)])]),
541
- `bundle-weight`,
542
- );
543
- const after = verdictFor(
544
- withProbes([bundleProbe([chunk(`dist/vendor-DlAUqK2U.js`, 800), chunk(`dist/charting-a1b2c3d4.js`, 100), chunk(`dist/s.css`, 50)])]),
545
- `bundle-weight`,
546
- );
547
- expect(after.digest).not.toBe(before.digest);
548
- });
549
- });
550
-
551
- describe(`idioms the framework has replaced`, () => {
552
- const idioms = (id: string, count: number) => ({ id, files: Array.from({ length: count }, (_, index) => `src/C${index}.vue`) });
553
-
554
- test(`names what is still in use and what replaced it`, () => {
555
- const verdict = verdictFor(withProbes([uiProbe({ idioms: [idioms(`vue-options-api`, 3)] })]), `framework-idiom`);
556
- expect(verdict.state).toBe(`due`);
557
- expect(verdict.detail[0]).toContain(`3 files`);
558
- expect(verdict.detail[0]).toContain(`Options API`);
559
- expect(verdict.detail[0]).toContain(`script setup`);
560
- });
561
-
562
- test(`one more file in a large migration is not news`, () => {
563
- const before = verdictFor(withProbes([uiProbe({ idioms: [idioms(`vue-options-api`, 40)] })]), `framework-idiom`);
564
- const after = verdictFor(withProbes([uiProbe({ idioms: [idioms(`vue-options-api`, 41)] })]), `framework-idiom`);
565
- expect(after.digest).toBe(before.digest);
566
- });
567
-
568
- test(`a kind of legacy code the repository did not have before is`, () => {
569
- const before = verdictFor(withProbes([uiProbe({ idioms: [idioms(`vue-options-api`, 40)] })]), `framework-idiom`);
570
- const after = verdictFor(withProbes([uiProbe({ idioms: [idioms(`vue-options-api`, 40), idioms(`vue-global-api`, 1)] })]), `framework-idiom`);
571
- expect(after.digest).not.toBe(before.digest);
572
- });
573
-
574
- test(`an idiom this build of the book does not know is dropped, not shown unnamed`, () => {
575
- expect(verdictFor(withProbes([uiProbe({ idioms: [idioms(`react-from-2029`, 5)] })]), `framework-idiom`).state).toBe(`clear`);
576
- });
577
-
578
- test(`an idiom from a framework the repository does not declare is not its problem`, () => {
579
- const vue = withProbes([uiProbe({ idioms: [idioms(`angular-ngmodule`, 4)] })], { deps: [`vue`] });
580
- const angular = withProbes([uiProbe({ idioms: [idioms(`angular-ngmodule`, 4)] })], { deps: [`@angular/core`] });
581
- expect(verdictFor(vue, `framework-idiom`).state).toBe(`clear`);
582
- expect(verdictFor(angular, `framework-idiom`).state).toBe(`due`);
583
- });
584
- });
585
-
586
- describe(`components built twice`, () => {
587
- const components = (...paths: readonly string[]) => uiProbe({ components: [...paths] });
588
-
589
- test(`a shared name across two directories is a family, whatever each file is called`, () => {
590
- const verdict = verdictFor(
591
- withProbes([components(`src/ui/BaseButton.vue`, `src/checkout/ButtonV2.tsx`), jscpdProbe([])]),
592
- `component-overlap`,
593
- );
594
- expect(verdict.state).toBe(`due`);
595
- expect(verdict.headline).toContain(`1 name`);
596
- expect(verdict.detail[0]).toContain(`button`);
597
- expect(verdict.detail[0]).toContain(`ButtonV2.tsx`);
598
- });
599
-
600
- test(`components that merely coexist are not a finding`, () => {
601
- expect(verdictFor(withProbes([components(`src/Button.vue`, `src/Card.vue`), jscpdProbe([])]), `component-overlap`).state).toBe(`clear`);
602
- });
603
-
604
- test(`a clone counts only when a component sits on both sides of it`, () => {
605
- const ui = components(`src/Chart.vue`, `src/Graph.vue`);
606
- const shared = verdictFor(
607
- withProbes([ui, jscpdProbe([{ lines: 40, first: `./src/Chart.vue`, second: `./src/Graph.vue` }])]),
608
- `component-overlap`,
609
- );
610
- const oneSided = verdictFor(
611
- withProbes([ui, jscpdProbe([{ lines: 40, first: `./src/Chart.vue`, second: `./src/utils/format.ts` }])]),
612
- `component-overlap`,
613
- );
614
- expect(shared.state).toBe(`due`);
615
- expect(shared.headline).toContain(`clone`);
616
- expect(oneSided.state).toBe(`clear`);
617
- });
618
-
619
- test(`without the clone sweep the chore is unavailable, not clear`, () => {
620
- expect(verdictFor(withProbes([components(`src/Button.vue`, `src/ui/Button.vue`)]), `component-overlap`).state).toBe(`unavailable`);
621
- });
622
- });
623
-
624
- describe(`hard-coded styles`, () => {
625
- test(`counts the values and leads with the heaviest files`, () => {
626
- const verdict = verdictFor(
627
- withProbes([
628
- uiProbe({
629
- bypasses: [
630
- { path: `src/Checkout.vue`, count: 11 },
631
- { path: `src/Nav.vue`, count: 2 },
632
- ],
633
- }),
634
- ]),
635
- `tailwind-arbitrary-values`,
636
- );
637
- expect(verdict.state).toBe(`due`);
638
- expect(verdict.headline).toContain(`13`);
639
- expect(verdict.headline).toContain(`2 files`);
640
- expect(verdict.detail[0]).toContain(`Checkout.vue`);
641
- expect(verdict.detail[0]).toContain(`11`);
642
- });
643
-
644
- test(`a repository without Tailwind is not asked the question at all`, () => {
645
- const verdict = verdictFor(
646
- withProbes([uiProbe({ bypasses: [{ path: `src/Nav.vue`, count: 2 }] })], { deps: [`vue`] }),
647
- `tailwind-arbitrary-values`,
648
- );
649
- expect(verdict.state).toBe(`not-applicable`);
650
- expect(verdict.headline).toContain(`Tailwind`);
651
- });
652
-
653
- // The framework gate all four share reads `deps` from shape, not from `packages`: a single-package app has no
654
- // workspace packages at all.
655
- test(`a repository with no framework rules the front-end chores out entirely`, () => {
656
- const states = [`bundle-weight`, `framework-idiom`, `component-overlap`, `tailwind-arbitrary-values`].map(
657
- (id) => verdictFor(withProbes([], { deps: [`pino`] }), id).state,
658
- );
659
- expect(states).toEqual([`not-applicable`, `not-applicable`, `not-applicable`, `not-applicable`]);
660
- });
661
- });
662
-
663
- // The second axis: has anyone already answered this, and does the answer still stand; what the panel demotes on
664
- // (mark, tint, counts) has to match this exactly.
665
- describe(`whether a chore has already been answered`, () => {
666
- const withAdvisories = report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] });
667
- const ledgerEntry = (over: Partial<ChoreLedgerEntry> = {}): ChoreLedgerEntry => ({
668
- repo: `app`,
669
- chore: `security-advisories`,
670
- ranAt: NOW - DAY,
671
- runId: `r1`,
672
- outcome: `reported`,
673
- digest: verdictFor(withAdvisories, `security-advisories`).digest,
674
- ...over,
675
- });
676
-
677
- test(`a settled chore carries its answer, and the answer stands`, () => {
678
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry()] }, `security-advisories`);
679
- expect(verdict.state).toBe(`due`);
680
- expect(choreAnswer(verdict)).toEqual({ outcome: `reported`, ranAt: NOW - DAY });
681
- expect(choreAnswered(verdict)).toBe(true);
682
- });
683
-
684
- test(`a stale chore carries its answer too`, () => {
685
- const verdict = verdictFor({ ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000, outcome: `acted` })] }, `security-advisories`);
686
- expect(verdict.state).toBe(`stale`);
687
- expect(choreAnswer(verdict)?.outcome).toBe(`acted`);
688
- expect(choreAnswered(verdict)).toBe(true);
689
- });
690
-
691
- test(`a stale chore with nothing to show is still nothing to start`, () => {
692
- const verdict = verdictFor(
693
- { ...withAdvisories, ledger: [ledgerEntry({ ranAt: NOW - 3_600_000, digest: `answered-something-else` })] },
694
- `security-advisories`,
695
- );
696
- expect(verdict.state).toBe(`stale`);
697
- expect(verdict.prompt).toBeUndefined();
698
- expect(choreAnswer(verdict)).toBeUndefined();
699
- expect(choreAnswered(verdict)).toBe(true);
700
- });
701
-
702
- test(`a run against evidence that has since moved has answered nothing`, () => {
703
- const moved = report({
704
- repos: [{ repo: `app`, probes: [auditProbe([`left-pad`, `minimist`])], signals: signals() }],
705
- ledger: [ledgerEntry()],
706
- });
707
- const verdict = verdictFor(moved, `security-advisories`);
708
- expect(verdict.state).toBe(`due`);
709
- expect(choreAnswer(verdict)).toBeUndefined();
710
- expect(choreAnswered(verdict)).toBe(false);
711
- });
712
-
713
- test(`a lapsed chore still shows what was concluded, and no longer counts as answered`, () => {
714
- const dependencies = choreById(`dependencies-outdated`);
715
- expect(dependencies?.cadenceMs).toBeGreaterThan(0);
716
- const lapsedAt = NOW - (dependencies?.cadenceMs ?? 0) - DAY;
717
-
718
- const outdatedProbe = probe({
719
- id: `outdated`,
720
- facts: { id: `outdated`, packages: [{ name: `vue`, current: `1.0.0`, latest: `2.0.0`, kind: `major`, section: `dependencies` }] },
721
- });
722
- const repos = [{ repo: `app`, probes: [outdatedProbe], signals: signals() }];
723
- // The digest comes from the verdict itself, not a transcription, so this stays a test about the cadence, not a
724
- // mismatched fingerprint.
725
- const digest = verdictFor(report({ repos }), `dependencies-outdated`).digest;
726
- const entry: ChoreLedgerEntry = { repo: `app`, chore: `dependencies-outdated`, ranAt: lapsedAt, runId: `r0`, outcome: `acted`, digest };
727
-
728
- const verdict = verdictFor(report({ repos, ledger: [entry] }), `dependencies-outdated`);
729
- expect(verdict.state).toBe(`due`);
730
- // Same evidence: the run did answer this; only the cadence lapsing asks again.
731
- expect(verdict.settled).toBe(false);
732
- expect(choreAnswer(verdict)?.outcome).toBe(`acted`);
733
- expect(choreAnswered(verdict)).toBe(false);
734
- });
735
-
736
- test(`a row with no finding of its own has no answer`, () => {
737
- const clear = verdictFor(
738
- report({ repos: [{ repo: `app`, probes: [auditProbe([])], signals: signals() }], ledger: [ledgerEntry()] }),
739
- `security-advisories`,
740
- );
741
- expect(clear.state).toBe(`clear`);
742
- expect(clear.digest).toBe(``);
743
- expect(choreAnswer(clear)).toBeUndefined();
744
- });
745
- });
746
-
747
- // The criterion: the rule in words beside the evidence that met it. A row reporting a number without it is
748
- // asking to be trusted, and one wrong row costs the list its credibility.
749
- describe(`every chore says what would make it due`, () => {
750
- test(`every entry in the book carries a criterion`, () => {
751
- for (const chore of CHORES) {
752
- expect(chore.criterion, chore.id).toBeTypeOf(`string`);
753
- expect(chore.criterion.length, chore.id).toBeGreaterThan(20);
754
- }
755
- });
756
-
757
- test(`the criterion reaches the prompt, so the agent can tell us the rule was wrong`, () => {
758
- const due = verdictFor(report({ repos: [{ repo: `app`, probes: [auditProbe([`left-pad`])], signals: signals() }] }), `security-advisories`);
759
- expect(due.prompt).toContain(due.chore.criterion);
760
- });
761
- });