@reqvire-org/ads 0.3.53 → 0.4.2

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 (401) hide show
  1. package/README.md +114 -94
  2. package/dist/a11y.mjs +108 -29
  3. package/dist/analysis/compiler-options.mjs +13 -0
  4. package/dist/analysis/context.mjs +46 -0
  5. package/dist/analysis/file-tree.mjs +52 -0
  6. package/dist/analysis/helpers.mjs +140 -0
  7. package/dist/analysis/impact.mjs +20 -0
  8. package/dist/analysis/inputs.mjs +15 -0
  9. package/dist/analysis/native-adapter.mjs +180 -0
  10. package/dist/analysis/native-project.mjs +323 -0
  11. package/dist/analysis/queries.mjs +133 -0
  12. package/dist/analysis/service.mjs +146 -0
  13. package/dist/analysis/standalone.mjs +57 -0
  14. package/dist/analysis/syntax.mjs +164 -0
  15. package/dist/analysis/worker.mjs +182 -0
  16. package/dist/assets.mjs +6 -6
  17. package/dist/atomic-composition.mjs +191 -70
  18. package/dist/atomic-trace.mjs +120 -50
  19. package/dist/behavior-libraries.mjs +106 -37
  20. package/dist/behaviors.mjs +222 -79
  21. package/dist/boundaries.mjs +137 -40
  22. package/dist/brand-assets.mjs +219 -47
  23. package/dist/brands.mjs +86 -27
  24. package/dist/bun-compiler.mjs +34 -13
  25. package/dist/bun-worker.mjs +7 -5
  26. package/dist/capture/worker.mjs +15 -4
  27. package/dist/capture-store.mjs +4 -2
  28. package/dist/capture.mjs +17 -14
  29. package/dist/check-service.mjs +66 -0
  30. package/dist/check.mjs +756 -196
  31. package/dist/cli.mjs +203 -100
  32. package/dist/color-values.mjs +21 -21
  33. package/dist/component-contrast.mjs +2 -2
  34. package/dist/config.mjs +308 -163
  35. package/dist/construction-styles.cjs +10 -0
  36. package/dist/contracts.d.mts +9 -0
  37. package/dist/control-padding.mjs +45 -25
  38. package/dist/css-values.mjs +3 -2
  39. package/dist/declarative-flow.mjs +209 -109
  40. package/dist/design-values.mjs +136 -51
  41. package/dist/development-runtime.mjs +4 -6
  42. package/dist/draft-boundary.mjs +11 -6
  43. package/dist/evidence.mjs +1 -1
  44. package/dist/finding-rules.mjs +7 -5
  45. package/dist/font-rules.mjs +2 -2
  46. package/dist/fonts-generated.mjs +4 -2
  47. package/dist/foundation-views.mjs +238 -0
  48. package/dist/foundation.mjs +63 -39
  49. package/dist/generated-entries.mjs +198 -0
  50. package/dist/icons.mjs +80 -33
  51. package/dist/image-attributes.mjs +109 -36
  52. package/dist/image-size.mjs +1 -1
  53. package/dist/index.mjs +0 -2
  54. package/dist/init.mjs +128 -68
  55. package/dist/investigations.mjs +2 -2
  56. package/dist/layers.mjs +300 -127
  57. package/dist/layout-widths.mjs +180 -85
  58. package/dist/linaria/preserve-values.cjs +7 -0
  59. package/dist/linaria/spatial-inputs.cjs +56 -0
  60. package/dist/lockup-composition.mjs +44 -0
  61. package/dist/lockup-model.cjs +64 -0
  62. package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
  63. package/dist/mcp/apps.mjs +4 -30
  64. package/dist/mcp/behavior-pages.mjs +72 -24
  65. package/dist/mcp/build-status.mjs +257 -64
  66. package/dist/mcp/catalog.mjs +91 -26
  67. package/dist/mcp/context.mjs +17 -18
  68. package/dist/mcp/draft-discovery.mjs +44 -21
  69. package/dist/mcp/drafts.mjs +978 -343
  70. package/dist/mcp/execution-coordinator.mjs +417 -167
  71. package/dist/mcp/execution-results.mjs +7 -7
  72. package/dist/mcp/mutations.mjs +701 -219
  73. package/dist/mcp/preview-watch.mjs +465 -161
  74. package/dist/mcp/preview-widget.bundle.js +44 -50
  75. package/dist/mcp/prompts.mjs +6 -6
  76. package/dist/mcp/result-pages.mjs +1 -1
  77. package/dist/mcp/sandbox-host.mjs +1 -1
  78. package/dist/mcp/server.mjs +2436 -570
  79. package/dist/mcp/showcase-host.mjs +176 -39
  80. package/dist/mcp/skills.mjs +1 -1
  81. package/dist/mcp/text-diff.mjs +29 -10
  82. package/dist/paint-contracts.mjs +174 -81
  83. package/dist/palette-generated.mjs +2 -2
  84. package/dist/preview-bun.mjs +493 -187
  85. package/dist/preview-failure.mjs +1 -1
  86. package/dist/preview-files.mjs +13 -13
  87. package/dist/preview-imports.mjs +104 -55
  88. package/dist/preview-inputs.mjs +2 -2
  89. package/dist/preview-requests.mjs +24 -0
  90. package/dist/preview-resources.mjs +288 -147
  91. package/dist/preview-scope.mjs +5 -4
  92. package/dist/program-cache.mjs +10 -0
  93. package/dist/project-documents.mjs +1 -1
  94. package/dist/public-api.mjs +70 -31
  95. package/dist/public-props.mjs +39 -22
  96. package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
  97. package/dist/{browser-audit → render-audit}/image-shape.mjs +2 -2
  98. package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
  99. package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
  100. package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
  101. package/dist/{browser-audit → render-audit}/worker.mjs +86 -30
  102. package/dist/render-audit.mjs +828 -0
  103. package/dist/render-color-probe.mjs +96 -42
  104. package/dist/resource-limits.mjs +229 -97
  105. package/dist/runtime-contracts.mjs +467 -185
  106. package/dist/scenario-groups.mjs +22 -10
  107. package/dist/scenario-inspector.mjs +6 -43
  108. package/dist/scenario-program.mjs +8 -25
  109. package/dist/scenario-registry.mjs +72 -30
  110. package/dist/scenario-selectors.mjs +161 -64
  111. package/dist/scenario-slots.mjs +149 -56
  112. package/dist/scenario-trace.mjs +215 -109
  113. package/dist/scenarios-compiler.mjs +768 -359
  114. package/dist/scenarios-vite.d.mts +1 -3
  115. package/dist/scenarios-vite.mjs +2 -81
  116. package/dist/scenarios.mjs +424 -159
  117. package/dist/selector-match.mjs +2 -2
  118. package/dist/showcase/client.bundle.js +57 -56
  119. package/dist/showcase/draft-navigation.js +18 -0
  120. package/dist/showcase/favicon.ico +0 -0
  121. package/dist/showcase/favicon.svg +1 -0
  122. package/dist/showcase/foundation-view.css +55 -0
  123. package/dist/showcase/foundation-view.mjs +252 -0
  124. package/dist/showcase/guide-controls.ads.review.mjs +32 -0
  125. package/dist/showcase/icons.js +1 -145
  126. package/dist/showcase/index.html +3 -31
  127. package/dist/showcase/preview-frame.ads.review.css +46 -0
  128. package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
  129. package/dist/showcase/preview-frame.ads.review.mjs +22 -0
  130. package/dist/showcase/preview-state.js +0 -9
  131. package/dist/showcase/refresh-scheduler.js +23 -0
  132. package/dist/showcase/style.css +5 -47
  133. package/dist/showcase/ui/ui.css +1353 -0
  134. package/dist/showcase/ui/ui.js +1062 -0
  135. package/dist/showcase-coverage.mjs +58 -37
  136. package/dist/skills/README.md +24 -23
  137. package/dist/skills/ads-designer/README.md +8 -2
  138. package/dist/skills/ads-designer/SKILL.md +152 -144
  139. package/dist/skills/ads-designer/references/accessibility.md +14 -11
  140. package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
  141. package/dist/skills/ads-designer/references/behaviors.md +34 -30
  142. package/dist/skills/ads-designer/references/branding.md +98 -10
  143. package/dist/skills/ads-designer/references/captures.md +31 -31
  144. package/dist/skills/ads-designer/references/cli.md +21 -20
  145. package/dist/skills/ads-designer/references/contracts.md +63 -29
  146. package/dist/skills/ads-designer/references/design-data.md +49 -52
  147. package/dist/skills/ads-designer/references/drafts.md +71 -52
  148. package/dist/skills/ads-designer/references/evidence.md +1 -5
  149. package/dist/skills/ads-designer/references/guarded-editing.md +58 -51
  150. package/dist/skills/ads-designer/references/layers.md +1 -1
  151. package/dist/skills/ads-designer/references/layout.md +347 -0
  152. package/dist/skills/ads-designer/references/mobile.md +2 -1
  153. package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
  154. package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
  155. package/dist/skills/ads-designer/references/performance.md +3 -2
  156. package/dist/skills/ads-designer/references/review.md +42 -38
  157. package/dist/skills/ads-designer/references/runtimes.md +33 -30
  158. package/dist/skills/ads-designer/references/scenarios.md +17 -19
  159. package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
  160. package/dist/skills/ads-designer/references/stress-test.md +68 -0
  161. package/dist/skills/ads-designer/references/validation.md +83 -71
  162. package/dist/skills/ads-designer/references/workflows.md +19 -37
  163. package/dist/skills/ads-import/SKILL.md +43 -328
  164. package/dist/skills/ads-import/references/atomic-styles.md +4 -4
  165. package/dist/skills/ads-import/references/behaviors.md +34 -30
  166. package/dist/skills/ads-import/references/branding.md +5 -5
  167. package/dist/skills/ads-import/references/captures.md +31 -31
  168. package/dist/skills/ads-import/references/cli.md +21 -20
  169. package/dist/skills/ads-import/references/compatibility.md +1 -1
  170. package/dist/skills/ads-import/references/contracts.md +63 -29
  171. package/dist/skills/ads-import/references/design-data.md +49 -52
  172. package/dist/skills/ads-import/references/drafts.md +71 -52
  173. package/dist/skills/ads-import/references/evidence.md +1 -5
  174. package/dist/skills/ads-import/references/guarded-editing.md +58 -51
  175. package/dist/skills/ads-import/references/implementation.md +2 -1
  176. package/dist/skills/ads-import/references/layers.md +1 -1
  177. package/dist/skills/ads-import/references/layout.md +347 -0
  178. package/dist/skills/ads-import/references/review.md +42 -38
  179. package/dist/skills/ads-import/references/runtimes.md +33 -30
  180. package/dist/skills/ads-import/references/scenarios.md +17 -19
  181. package/dist/skills/ads-import/references/tokens.md +3 -3
  182. package/dist/skills/ads-import/references/validation.md +83 -71
  183. package/dist/skills/ads-import/references/workflows.md +19 -37
  184. package/dist/skills/ads-migrate/SKILL.md +56 -0
  185. package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
  186. package/dist/skills/ads-port/SKILL.md +54 -346
  187. package/dist/skills/ads-port/references/atomic-styles.md +4 -4
  188. package/dist/skills/ads-port/references/behaviors.md +34 -30
  189. package/dist/skills/ads-port/references/captures.md +31 -31
  190. package/dist/skills/ads-port/references/cli.md +21 -20
  191. package/dist/skills/ads-port/references/contracts.md +63 -29
  192. package/dist/skills/ads-port/references/design-data.md +49 -52
  193. package/dist/skills/ads-port/references/drafts.md +71 -52
  194. package/dist/skills/ads-port/references/evidence.md +1 -5
  195. package/dist/skills/ads-port/references/guarded-editing.md +58 -51
  196. package/dist/skills/ads-port/references/layers.md +1 -1
  197. package/dist/skills/ads-port/references/layout.md +347 -0
  198. package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
  199. package/dist/skills/ads-port/references/native-implementation.md +8 -7
  200. package/dist/skills/ads-port/references/review.md +42 -38
  201. package/dist/skills/ads-port/references/runtimes.md +33 -30
  202. package/dist/skills/ads-port/references/scenarios.md +17 -19
  203. package/dist/skills/ads-port/references/validation.md +83 -71
  204. package/dist/skills/ads-port/references/workflows.md +19 -37
  205. package/dist/source-symbols.mjs +1 -8
  206. package/dist/source-values.mjs +266 -128
  207. package/dist/spatial-composition.mjs +322 -0
  208. package/dist/spatial-contexts.cjs +56 -0
  209. package/dist/spatial-css.cjs +351 -0
  210. package/dist/spatial-inputs.cjs +80 -0
  211. package/dist/spatial-metadata.mjs +18 -0
  212. package/dist/spatial-model.cjs +322 -0
  213. package/dist/spatial.mjs +21 -0
  214. package/dist/stage-timing.cjs +20 -0
  215. package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
  216. package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
  217. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  218. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  219. package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
  220. package/dist/starters/preact/ds.config.json +24 -19
  221. package/dist/starters/preact/package.json +4 -8
  222. package/dist/starters/preact/tsconfig.json +4 -5
  223. package/dist/starters/preact/vite.config.ts +3 -3
  224. package/dist/starters/react/ADS.md +42 -47
  225. package/dist/starters/react/README.md +54 -52
  226. package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +1 -0
  227. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +1 -0
  228. package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
  229. package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
  230. package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +1 -0
  231. package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +1 -0
  232. package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +1 -0
  233. package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +1 -0
  234. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
  235. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
  236. package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
  237. package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +1 -0
  238. package/dist/starters/react/design-system/index.ts +5 -8
  239. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
  240. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
  241. package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
  242. package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
  243. package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
  244. package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +1 -0
  245. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
  246. package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
  247. package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
  248. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
  249. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
  250. package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
  251. package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
  252. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -0
  253. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
  254. package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
  255. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
  256. package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
  257. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -0
  258. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
  259. package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
  260. package/dist/starters/react/design-system/styles.css +1 -0
  261. package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
  262. package/dist/starters/react/design-system/tokens/colors.css +1 -1
  263. package/dist/starters/react/design-system/tokens/spacing.css +22 -32
  264. package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
  265. package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
  266. package/dist/starters/react/ds.config.json +24 -19
  267. package/dist/starters/react/package.json +2 -6
  268. package/dist/starters/react/tsconfig.json +2 -3
  269. package/dist/starters/react/vite.config.ts +3 -3
  270. package/dist/style-boundaries.mjs +73 -27
  271. package/dist/task-cache.mjs +173 -72
  272. package/dist/task-worker.mjs +22 -11
  273. package/dist/test-boundaries.mjs +133 -60
  274. package/dist/themes-generated.mjs +1 -1
  275. package/dist/themes-watch.mjs +60 -19
  276. package/dist/themes.mjs +176 -73
  277. package/dist/token-export.mjs +39 -14
  278. package/dist/token-policy.mjs +6 -3
  279. package/dist/token-quality.mjs +6 -6
  280. package/dist/token-samples.mjs +16 -5
  281. package/dist/tokens.mjs +71 -26
  282. package/dist/ui-framework.mjs +16 -14
  283. package/dist/unit-contracts.mjs +270 -89
  284. package/dist/units.mjs +215 -180
  285. package/dist/usage.mjs +138 -38
  286. package/dist/validation-checks.mjs +121 -38
  287. package/dist/validation-inputs.mjs +187 -78
  288. package/dist/validation.mjs +268 -102
  289. package/dist/verification/browser.mjs +27 -5
  290. package/dist/verification.mjs +711 -187
  291. package/docs/ADS.md +100 -89
  292. package/docs/ARCHITECTURE.md +353 -159
  293. package/docs/BEHAVIORS.md +33 -28
  294. package/docs/CACHING.md +55 -11
  295. package/docs/CHANGELOG.md +358 -17
  296. package/docs/COMPARISON.md +1 -1
  297. package/docs/CONTRACTS.md +22 -29
  298. package/docs/DESIGN-REFERENCES.md +40 -0
  299. package/docs/GUIDE.md +313 -292
  300. package/docs/MCP.md +261 -439
  301. package/docs/SPATIAL-CHECKS.md +69 -0
  302. package/docs/benchmarks/README.md +39 -0
  303. package/package.json +42 -34
  304. package/dist/browser-audit.mjs +0 -424
  305. package/dist/contract-migration.mjs +0 -110
  306. package/dist/create.mjs +0 -48
  307. package/dist/lint-config.mjs +0 -48
  308. package/dist/mcp/draft-exports.mjs +0 -40
  309. package/dist/mcp/edit-preparation.mjs +0 -115
  310. package/dist/mcp/project-widget.bundle.js +0 -114
  311. package/dist/mcp/reports.mjs +0 -101
  312. package/dist/mcp/widget.bundle.js +0 -147
  313. package/dist/oxlint.mjs +0 -88
  314. package/dist/preview-builder.mjs +0 -133
  315. package/dist/preview-workers.mjs +0 -184
  316. package/dist/showcase.mjs +0 -77
  317. package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
  318. package/dist/skills/ads-break-ui/README.md +0 -16
  319. package/dist/skills/ads-break-ui/SKILL.md +0 -415
  320. package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
  321. package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
  322. package/dist/skills/ads-break-ui/references/behaviors.md +0 -411
  323. package/dist/skills/ads-break-ui/references/captures.md +0 -160
  324. package/dist/skills/ads-break-ui/references/contracts.md +0 -284
  325. package/dist/skills/ads-break-ui/references/design-data.md +0 -354
  326. package/dist/skills/ads-break-ui/references/drafts.md +0 -178
  327. package/dist/skills/ads-break-ui/references/evidence.md +0 -128
  328. package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -154
  329. package/dist/skills/ads-break-ui/references/layers.md +0 -145
  330. package/dist/skills/ads-break-ui/references/reporting.md +0 -101
  331. package/dist/skills/ads-break-ui/references/review.md +0 -96
  332. package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
  333. package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
  334. package/dist/skills/ads-break-ui/references/validation.md +0 -162
  335. package/dist/skills/ads-break-ui/references/verification.md +0 -58
  336. package/dist/skills/ads-break-ui/references/workflows.md +0 -83
  337. package/dist/skills/ads-designer/references/reporting.md +0 -101
  338. package/dist/skills/ads-import/references/reporting.md +0 -101
  339. package/dist/skills/ads-motion/LICENSE.upstream +0 -21
  340. package/dist/skills/ads-motion/README.md +0 -22
  341. package/dist/skills/ads-motion/SKILL.md +0 -388
  342. package/dist/skills/ads-motion/agents/openai.yaml +0 -4
  343. package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
  344. package/dist/skills/ads-motion/references/audit.md +0 -44
  345. package/dist/skills/ads-motion/references/behaviors.md +0 -411
  346. package/dist/skills/ads-motion/references/captures.md +0 -160
  347. package/dist/skills/ads-motion/references/contracts.md +0 -284
  348. package/dist/skills/ads-motion/references/design-data.md +0 -354
  349. package/dist/skills/ads-motion/references/drafts.md +0 -178
  350. package/dist/skills/ads-motion/references/evidence.md +0 -128
  351. package/dist/skills/ads-motion/references/guarded-editing.md +0 -154
  352. package/dist/skills/ads-motion/references/layers.md +0 -145
  353. package/dist/skills/ads-motion/references/motion-review.md +0 -35
  354. package/dist/skills/ads-motion/references/reporting.md +0 -101
  355. package/dist/skills/ads-motion/references/review.md +0 -96
  356. package/dist/skills/ads-motion/references/runtimes.md +0 -203
  357. package/dist/skills/ads-motion/references/scenarios.md +0 -246
  358. package/dist/skills/ads-motion/references/validation.md +0 -162
  359. package/dist/skills/ads-motion/references/verification.md +0 -39
  360. package/dist/skills/ads-motion/references/workflows.md +0 -83
  361. package/dist/skills/ads-port/references/reporting.md +0 -101
  362. package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
  363. package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  364. package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  365. package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
  366. package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
  367. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
  368. package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
  369. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
  370. package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
  371. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
  372. package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
  373. package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
  374. package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
  375. package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
  376. package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
  377. package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
  378. package/dist/starters/react/design-system/review/index.ts +0 -5
  379. package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
  380. package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
  381. package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
  382. package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
  383. package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
  384. package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
  385. package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
  386. package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
  387. package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
  388. package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
  389. package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
  390. package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
  391. package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
  392. package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
  393. package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
  394. package/dist/starters/react/package-lock.json +0 -4707
  395. package/dist/token-fixtures.mjs +0 -30
  396. package/docs/benchmarks/bun-previews.md +0 -91
  397. package/docs/benchmarks/preview-memory.md +0 -147
  398. package/docs/benchmarks/turbo-poc.md +0 -284
  399. package/docs/plans/execution-coordination.md +0 -57
  400. /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
  401. /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
@@ -1,16 +1,31 @@
1
+ import { mapAsync } from "../analysis/queries.mjs";
1
2
  import { trackExecutionWorkspace } from "./execution-context.mjs";
2
3
  import { createHash, randomUUID } from "node:crypto";
3
- import { cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
+ import {
5
+ cpSync,
6
+ existsSync,
7
+ lstatSync,
8
+ mkdirSync,
9
+ mkdtempSync,
10
+ readFileSync,
11
+ readdirSync,
12
+ realpathSync,
13
+ renameSync,
14
+ rmSync,
15
+ symlinkSync,
16
+ writeFileSync,
17
+ } from "node:fs";
4
18
  import path from "node:path";
5
19
  import { hasProjectConfig } from "../project-boundary.mjs";
6
- import ts from "typescript";
20
+ import ts from "../analysis/syntax.mjs";
7
21
  import { isInside, loadConfig } from "../config.mjs";
8
- import { affectedBehaviorUnits, createVerificationController } from "../verification.mjs";
22
+ import { createVerificationController } from "../verification.mjs";
23
+
9
24
  import { generateBrandAssets } from "../brand-assets.mjs";
10
25
  import { applyFilePatch, parseUnifiedPatch } from "./patch.mjs";
11
- import { createCaptureController, captureSelections } from "../capture.mjs";
26
+ import { createCaptureController } from "../capture.mjs";
12
27
  import { previewSourceRevision } from "../preview-inputs.mjs";
13
- import { inspectScenarios } from "../scenarios.mjs";
28
+
14
29
  import { checkUnitCandidate, checkUnitFiles, inspectUnits, validateUnitId } from "../units.mjs";
15
30
  import { acceptance, failure as evidenceFailure } from "../evidence.mjs";
16
31
  import { checkCandidate, checkCommand, projectChecks as checks } from "../validation-checks.mjs";
@@ -18,41 +33,70 @@ import { holdLivePreview, preparePreviewCache } from "../scenarios-compiler.mjs"
18
33
  import { validationInputFiles } from "../validation-inputs.mjs";
19
34
  import { mutationLimits } from "./mutation-limits.mjs";
20
35
  import { writeThemesCss } from "../themes-generated.mjs";
21
- import { inspectTokens } from "../tokens.mjs";
36
+ import { generatedEntries } from "../generated-entries.mjs";
37
+
38
+ import { analyze, registerAnalysisRevision, releaseAnalysisRevision, promoteAnalysisRevision } from "../analysis/service.mjs";
39
+ import { isAnalysisSource } from "../analysis/inputs.mjs";
22
40
 
23
41
  export { mutationLimits } from "./mutation-limits.mjs";
24
- const digest = bytes => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
42
+ const digest = (bytes) => `sha256:${createHash("sha256").update(bytes).digest("hex")}`;
25
43
  const ignored = new Set([".git", ".ds", "node_modules", ".vite", "coverage", ".playwright-cli", "test-results", "output"]);
26
- const textFile = file => /\.(?:[cm]?[jt]sx?|css|html|jsonc?|md|txt|svg)$/.test(file);
27
- const setupDotfile = file => /^\.(?:oxlintrc|linariarc|babelrc)(?:\.json)?$/.test(file);
44
+ const textFile = (file) => /\.(?:[cm]?[jt]sx?|css|html|jsonc?|md|txt|svg)$/.test(file);
45
+ const setupDotfile = (file) => /^\.(?:oxlintrc|linariarc|babelrc)(?:\.json)?$/.test(file);
28
46
 
29
- function fail(rule, message, file, boundary = evidenceFailure("architecture","mutation-policy",rule)) {
30
- return Object.assign(new Error(message), { diagnostic: { rule, message, failure:boundary, ...(file ? { file } : {}) } });
47
+ function fail(rule, message, file, boundary) {
48
+ if (boundary === undefined) boundary = evidenceFailure("architecture", "mutation-policy", rule);
49
+ return Object.assign(new Error(message), { diagnostic: { rule, message, failure: boundary, ...(file ? { file } : {}) } });
31
50
  }
32
51
 
33
52
  function address(options, file) {
34
- if (typeof file !== "string" || !file || file.includes("\\") || file.includes("\0") || file.split("/").some(part => !part || part === "." || part === "..") || path.isAbsolute(file)) throw fail("mutation-path", "Use a canonical project-relative ADS file path.", file);
53
+ if (
54
+ typeof file !== "string" ||
55
+ !file ||
56
+ file.includes("\\") ||
57
+ file.includes("\0") ||
58
+ file.split("/").some((part) => !part || part === "." || part === "..") ||
59
+ path.isAbsolute(file)
60
+ )
61
+ throw fail("mutation-path", "Use a canonical project-relative ADS file path.", file);
35
62
  const target = path.resolve(options.root, file);
36
63
  if (!isInside(options.root, target) || target === options.root) throw fail("mutation-path", "Mutation paths must stay inside the project.", file);
37
64
  for (let current = options.root; ; ) {
38
65
  const relative = path.relative(current, target).split(path.sep);
39
- if (relative.some(part => ignored.has(part) || part.startsWith(".") && !setupDotfile(part) && !(part === ".gitkeep" && path.basename(target) === part && isInside(options.dsRoot, target)))) throw fail("mutation-path", "Hidden, dependency and generated paths are not editable.", file);
66
+ if (
67
+ relative.some(
68
+ (part) =>
69
+ ignored.has(part) ||
70
+ (part.startsWith(".") && !setupDotfile(part) && !(part === ".gitkeep" && path.basename(target) === part && isInside(options.dsRoot, target))),
71
+ )
72
+ )
73
+ throw fail("mutation-path", "Hidden, dependency and generated paths are not editable.", file);
40
74
  current = path.join(current, relative[0]);
41
75
  const stat = lstatSync(current, { throwIfNoEntry: false });
42
- if (stat?.isSymbolicLink() || stat && current !== target && !stat.isDirectory() || stat && current === target && (!stat.isFile() || stat.nlink !== 1)) throw fail("mutation-path", "Mutation paths must contain ordinary directories and unlinked regular files.", file);
76
+ if (stat?.isSymbolicLink() || (stat && current !== target && !stat.isDirectory()) || (stat && current === target && (!stat.isFile() || stat.nlink !== 1)))
77
+ throw fail("mutation-path", "Mutation paths must contain ordinary directories and unlinked regular files.", file);
43
78
  if (current === target) break;
44
79
  }
45
- if (options.config.assets.generatedPaths.some(entry => isInside(path.resolve(options.root, entry), target))) throw fail("mutation-path", "Generated output is not editable.", file);
46
- if (options.config.assets.generatedFiles.some(entry => target === path.resolve(options.dsRoot, "assets", entry))) throw fail("mutation-path", "Generated brand files are outputs; edit their source instead.", file);
80
+ if (options.config.assets.generatedPaths.some((entry) => isInside(path.resolve(options.root, entry), target)))
81
+ throw fail("mutation-path", "Generated output is not editable.", file);
82
+ if (options.config.assets.generatedFiles.some((entry) => target === path.resolve(options.dsRoot, "assets", entry)))
83
+ throw fail("mutation-path", "Generated brand files are outputs; edit their source instead.", file);
47
84
  return target;
48
85
  }
49
86
 
50
- function readPatchFile(options, file) {
51
- if (typeof file !== "string" || file.includes("\\") || file.includes("\0") || !/^\.ds\/patches\/[^/]+\.(?:patch|diff)$/.test(file)) throw fail("mutation-patch", "Patch files must be regular .patch/.diff files in .ds/patches/.");
87
+ export function readPatchFile(options, file) {
88
+ if (typeof file !== "string" || file.includes("\\") || file.includes("\0") || !/^\.ds\/patches\/[^/]+\.(?:patch|diff)$/.test(file))
89
+ throw fail("mutation-patch", "Patch files must be regular .patch/.diff files in .ds/patches/.");
52
90
  const target = path.join(options.root, file);
53
91
  for (const current of [path.join(options.root, ".ds"), path.dirname(target), target]) {
54
92
  const stat = lstatSync(current, { throwIfNoEntry: false });
55
- if (!stat || stat.isSymbolicLink() || current !== target && !stat.isDirectory() || current === target && (!stat.isFile() || stat.nlink !== 1 || stat.size > mutationLimits.patchFileBytes)) throw fail("mutation-patch", "Patch files must be real files no larger than 16 MiB.");
93
+ if (
94
+ !stat ||
95
+ stat.isSymbolicLink() ||
96
+ (current !== target && !stat.isDirectory()) ||
97
+ (current === target && (!stat.isFile() || stat.nlink !== 1 || stat.size > mutationLimits.patchFileBytes))
98
+ )
99
+ throw fail("mutation-patch", "Patch files must be real files no larger than 16 MiB.");
56
100
  }
57
101
  const bytes = readFileSync(target);
58
102
  if (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)) throw fail("mutation-patch", "Patch files must contain UTF-8 Git diff text.");
@@ -68,61 +112,92 @@ function read(options, file) {
68
112
  return { path: file, exists: true, digest: digest(bytes), bytes: bytes.length, binary, content: binary ? bytes : bytes.toString("utf8") };
69
113
  }
70
114
 
71
- function validateContent(change, unit) {
115
+ async function validateContent(change, unit) {
72
116
  if (change.content === null) return;
73
117
  const bytes = Buffer.from(change.content);
74
118
  if (bytes.length > mutationLimits.fileBytes) throw fail("mutation-content", "The patched file exceeds 16 MiB.", change.path);
75
- if ((unit === "documentation" || textFile(change.path)) && (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes))) throw fail("mutation-content", "Text source and documentation must contain valid UTF-8 without NUL bytes.", change.path);
119
+ if ((unit === "documentation" || textFile(change.path)) && (bytes.includes(0) || !Buffer.from(bytes.toString("utf8")).equals(bytes)))
120
+ throw fail("mutation-content", "Text source and documentation must contain valid UTF-8 without NUL bytes.", change.path);
76
121
  if (/\.jsonc?$/.test(change.path)) {
77
- const content=bytes.toString("utf8");
78
- if (unit === "configuration" && !["package.json","ds.config.json"].includes(path.basename(change.path))) {
79
- if (ts.parseConfigFileTextToJson(change.path,content).error) throw fail("mutation-syntax", "Configuration must contain valid JSON/JSONC.", change.path);
80
- } else { try { JSON.parse(content); } catch { throw fail("mutation-syntax", "JSON source and configuration must be valid JSON.", change.path); } }
122
+ const content = bytes.toString("utf8");
123
+ if (unit === "configuration" && !["package.json", "ds.config.json"].includes(path.basename(change.path))) {
124
+ if ((await ts.parseConfigFileTextToJson(change.path, content)).error)
125
+ throw fail("mutation-syntax", "Configuration must contain valid JSON/JSONC.", change.path);
126
+ } else {
127
+ try {
128
+ JSON.parse(content);
129
+ } catch {
130
+ throw fail("mutation-syntax", "JSON source and configuration must be valid JSON.", change.path);
131
+ }
132
+ }
81
133
  }
82
- if (unit !== "configuration" && /\b(?:oxlint|eslint)-(?:disable|enable)|\bbiome-ignore|@ts-(?:ignore|nocheck|expect-error)/.test(bytes.toString("utf8"))) throw fail("mutation-policy", "Configure reviewed lint/typecheck exceptions through the configuration unit instead of source suppression directives.", change.path);
134
+ if (unit !== "configuration" && /\b(?:oxlint|eslint)-(?:disable|enable)|\bbiome-ignore|@ts-(?:ignore|nocheck|expect-error)/.test(bytes.toString("utf8")))
135
+ throw fail(
136
+ "mutation-policy",
137
+ "Configure reviewed lint/typecheck exceptions through the configuration unit instead of source suppression directives.",
138
+ change.path,
139
+ );
83
140
  }
84
141
 
85
- function candidateInputs(options,extraFiles=[]) {
86
- try { return validationInputFiles(options,extraFiles,{maxFiles:mutationLimits.snapshotFiles,maxBytes:mutationLimits.snapshotBytes}); }
87
- catch(error) { if(error.code==="ADS_INPUT_LIMIT")throw fail("mutation-snapshot",error.message);throw error; }
142
+ async function candidateInputs(options, extraFiles = [], onFile) {
143
+ try {
144
+ return await validationInputFiles(options, extraFiles, { maxFiles: mutationLimits.snapshotFiles, maxBytes: mutationLimits.snapshotBytes, onFile });
145
+ } catch (error) {
146
+ if (error.code === "ADS_INPUT_LIMIT") throw fail("mutation-snapshot", error.message);
147
+ throw error;
148
+ }
88
149
  }
89
- function copyInputs(options, destination, extraFiles, {baseline=new Map(),changed=new Set(),budget={bytes:0,files:0}}={}) {
90
- for (const [relative,value] of Object.entries(candidateInputs(options,extraFiles))) {
150
+ async function copyInputs(options, destination, extraFiles, { baseline = new Map(), changed = new Set(), budget = { bytes: 0, files: 0 }, contents } = {}) {
151
+ const buffers = new Map();
152
+ const inputs = await candidateInputs(options, extraFiles, (file, content) => buffers.set(file, content));
153
+ for (const [relative, value] of Object.entries(inputs)) {
91
154
  if (baseline.has(relative)) continue;
92
- if (relative==="installed-dependencies" || value===null) { baseline.set(relative,value);continue; }
93
- const file=path.resolve(options.root,relative),stat=lstatSync(file);
94
- if (budget.files+1>mutationLimits.snapshotFiles || budget.bytes+stat.size>mutationLimits.snapshotBytes) throw fail("mutation-snapshot","Relevant inputs exceed the bounded validation snapshot limit.");
95
- const content=readFileSync(file);budget.bytes+=content.length;budget.files++;
96
- if (budget.bytes>mutationLimits.snapshotBytes) throw fail("mutation-snapshot","Relevant inputs exceed the bounded validation snapshot limit.");
97
- baseline.set(relative,digest(content));
155
+ if (relative === "installed-dependencies" || value === null) {
156
+ baseline.set(relative, value);
157
+ continue;
158
+ }
159
+ const file = path.resolve(options.root, relative),
160
+ stat = lstatSync(file);
161
+ if (budget.files + 1 > mutationLimits.snapshotFiles || budget.bytes + stat.size > mutationLimits.snapshotBytes)
162
+ throw fail("mutation-snapshot", "Relevant inputs exceed the bounded validation snapshot limit.");
163
+ const content = buffers.get(relative);
164
+ budget.bytes += content.length;
165
+ budget.files++;
166
+ if (budget.bytes > mutationLimits.snapshotBytes) throw fail("mutation-snapshot", "Relevant inputs exceed the bounded validation snapshot limit.");
167
+ baseline.set(relative, digest(content));
168
+ if (contents && isAnalysisSource(relative)) contents.set(relative, content.toString("utf8"));
98
169
  if (!changed.has(relative)) {
99
- const target=path.join(destination,relative);mkdirSync(path.dirname(target),{recursive:true});
100
- writeFileSync(target,content,{mode:stat.mode});
170
+ const target = path.join(destination, relative);
171
+ mkdirSync(path.dirname(target), { recursive: true });
172
+ writeFileSync(target, content, { mode: stat.mode });
101
173
  }
102
174
  }
103
175
  return baseline;
104
176
  }
105
177
 
106
- function snapshot(options) {
178
+ async function snapshot(options) {
107
179
  // Scan the entire *candidate* to detect checking commands that rewrite source,
108
180
  // including files outside the input graph. Live projects are never copied here.
109
- candidateInputs(options);
181
+ await candidateInputs(options);
110
182
  const entries = [];
111
183
  let bytes = 0;
112
- const generated = options.config.assets.generatedPaths.map(file => path.resolve(options.root, file));
184
+ const generated = options.config.assets.generatedPaths.map((file) => path.resolve(options.root, file));
113
185
  function walk(folder) {
114
186
  for (const entry of readdirSync(folder, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
115
187
  if (ignored.has(entry.name)) continue;
116
188
  const file = path.join(folder, entry.name);
117
189
  const relative = path.relative(options.root, file);
118
- if (generated.some(base => isInside(base, file))) continue;
190
+ if (generated.some((base) => isInside(base, file))) continue;
119
191
  if (entry.isSymbolicLink()) continue;
120
- if (entry.isDirectory()) { if (!hasProjectConfig(file)) walk(file); }
121
- else if (entry.isFile()) {
122
- if (bytes + lstatSync(file).size > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles) throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
192
+ if (entry.isDirectory()) {
193
+ if (!hasProjectConfig(file)) walk(file);
194
+ } else if (entry.isFile()) {
195
+ if (bytes + lstatSync(file).size > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles)
196
+ throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
123
197
  const content = readFileSync(file);
124
198
  bytes += content.length;
125
- if (bytes > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles) throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
199
+ if (bytes > mutationLimits.snapshotBytes || entries.length >= mutationLimits.snapshotFiles)
200
+ throw fail("mutation-snapshot", "Project source exceeds the bounded validation snapshot limit.");
126
201
  entries.push([relative, digest(content)]);
127
202
  }
128
203
  }
@@ -134,16 +209,42 @@ function snapshot(options) {
134
209
  return JSON.stringify(entries);
135
210
  }
136
211
 
137
-
138
212
  function mutationEvidence(result, candidateRevision) {
139
- const diagnostics=(result.diagnostics??[]).map(diagnostic=>({...diagnostic,failure:diagnostic.failure??evidenceFailure("architecture","mutation-policy",diagnostic.rule)}));
140
- const failed=diagnostics[0];
141
- const accepted=acceptance("candidate-validation",result.ok,(result.checks??[]).filter(check=>check.passed&&!check.skipped).map(check=>check.name??[check.command,...(check.args??[])].join(" ")),["unregistered-checks","unselected-behavior-checks","post-application-preview-freshness","visual-parity","accessibility-audit"]);
142
- return {...result,...(result.diagnostics?{diagnostics}:{}),acceptance:accepted,investigation:{target:"candidate",candidateRevision:candidateRevision??null,...(failed?{failure:failed.failure,failingStep:failed.failure.phase,source:failed.file?{file:failed.file,line:failed.line,column:failed.column}:null,...(failed.command?{command:failed.command,args:failed.args,exitCode:failed.exitCode,output:failed.output}:{}),message:failed.message}:{}),acceptance:accepted}};
213
+ const diagnostics = (result.diagnostics ?? []).map((diagnostic) => ({
214
+ ...diagnostic,
215
+ failure: diagnostic.failure ?? evidenceFailure("architecture", "mutation-policy", diagnostic.rule),
216
+ }));
217
+ const failed = diagnostics[0];
218
+ const accepted = acceptance(
219
+ "candidate-validation",
220
+ result.ok,
221
+ (result.checks ?? []).filter((check) => check.passed && !check.skipped).map((check) => check.name ?? [check.command, ...(check.args ?? [])].join(" ")),
222
+ ["unregistered-checks", "unselected-behavior-checks", "post-application-preview-freshness", "visual-parity", "accessibility-audit"],
223
+ );
224
+ return {
225
+ ...result,
226
+ ...(result.diagnostics ? { diagnostics } : {}),
227
+ acceptance: accepted,
228
+ investigation: {
229
+ target: "candidate",
230
+ candidateRevision: candidateRevision ?? null,
231
+ ...(failed
232
+ ? {
233
+ failure: failed.failure,
234
+ failingStep: failed.failure.phase,
235
+ source: failed.file ? { file: failed.file, line: failed.line, column: failed.column } : null,
236
+ ...(failed.command ? { command: failed.command, args: failed.args, exitCode: failed.exitCode, output: failed.output } : {}),
237
+ message: failed.message,
238
+ }
239
+ : {}),
240
+ acceptance: accepted,
241
+ },
242
+ };
143
243
  }
144
244
 
145
-
146
245
  export function createMutationController(directory, { captures = createCaptureController(directory), previewWork } = {}) {
246
+ // A passing dry run's audit holds for accepting the same candidate: remembered by its revision and selection.
247
+ const audits = new Map();
147
248
  const root = path.resolve(directory);
148
249
  let busy = false;
149
250
  let lastResult = null;
@@ -152,53 +253,149 @@ export function createMutationController(directory, { captures = createCaptureCo
152
253
  return {
153
254
  status() {
154
255
  const options = loadConfig(root);
155
- let commands = [], diagnostics = [];
156
- try { commands = checks(options).map(check => [check.command, ...check.args].join(" ")); }
157
- catch (error) { diagnostics = [error.diagnostic ?? { rule: "mutation-check", message: error.message }]; }
158
- return { enabled: true, scope: "one-ds-unit", format: "git-unified-diff", transactions:{tool:"ads_apply_transaction",maxUnits:mutationLimits.units,finalCandidateChecks:true}, preparation:{owner:"ads_prepare_patch",tokenSamples:"ads_prepare_token_samples"}, dsDir: options.config.dsDir, limits: mutationLimits, checks: ["ads check", ...commands, ...options.config.mcp.previewManifest && options.config.mcp.previewWatch ? ["managed production previews"] : []], diagnostics, busy, ...(progress ? { progress } : {}), lastResult };
256
+ let commands = [],
257
+ diagnostics = [];
258
+ try {
259
+ commands = checks(options).map((check) => [check.command, ...check.args].join(" "));
260
+ } catch (error) {
261
+ diagnostics = [error.diagnostic ?? { rule: "mutation-check", message: error.message }];
262
+ }
263
+ return {
264
+ enabled: true,
265
+ scope: "one-ds-unit",
266
+ format: "git-unified-diff",
267
+ route: "draft",
268
+ drafts: {
269
+ create: "ads_create_draft",
270
+ edit: "ads_update_draft",
271
+ review: "ads_show_draft",
272
+ accept: "ads_accept",
273
+ maxUnits: mutationLimits.units,
274
+ finalCandidateChecks: true,
275
+ },
276
+ dsDir: options.config.dsDir,
277
+ limits: mutationLimits,
278
+ checks: ["ads check", ...commands, ...(options.config.framework ? ["managed production previews"] : [])],
279
+ diagnostics,
280
+ busy,
281
+ ...(progress ? { progress } : {}),
282
+ lastResult,
283
+ };
284
+ },
285
+ cancel() {
286
+ active?.abort();
287
+ },
288
+ async units() {
289
+ return (await inspectUnits(loadConfig(root))).units;
159
290
  },
160
- cancel() { active?.abort(); },
161
- units() { return inspectUnits(loadConfig(root)).units; },
162
- read(file, { offset = 0, limit = mutationLimits.readChars } = {}) {
163
- if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > mutationLimits.readChars) throw fail("mutation-range", "Use a non-negative character offset and a limit between 1 and 12000.", file);
164
- const options = loadConfig(root), source = read(options, file);
165
- const inventory = inspectUnits(options), unit = inventory.owner(inventory.relative(file));
166
- if (!unit && inventory.relative(file) !== inventory.publicEntry && inventory.relative(file) !== inventory.reviewEntry) throw fail("mutation-unit", "This file is outside the project's ADS and registered configuration/extension units.", file);
291
+ async read(file, { offset = 0, limit = mutationLimits.readChars } = {}) {
292
+ if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(limit) || limit < 1 || limit > mutationLimits.readChars)
293
+ throw fail("mutation-range", "Use a non-negative character offset and a limit between 1 and 12000.", file);
294
+ const options = loadConfig(root),
295
+ source = read(options, file);
296
+ const inventory = await inspectUnits(options),
297
+ unit = inventory.owner(inventory.relative(file));
298
+ if (!unit && inventory.relative(file) !== inventory.publicEntry && inventory.relative(file) !== inventory.reviewEntry)
299
+ throw fail("mutation-unit", "This file is outside the project's ADS and registered configuration/extension units.", file);
167
300
  if (!source.exists) return { ...source, offset: 0, nextOffset: null, totalChars: 0, startLine: 1 };
168
- if (source.binary) return { ...source, unit, content: null, note: "Binary asset: inspect its metadata or preview; edit using a Git binary patch, optionally through patchFile." };
301
+ if (source.binary)
302
+ return {
303
+ ...source,
304
+ unit,
305
+ content: null,
306
+ note: "Binary asset: inspect its metadata or preview; edit using a Git binary patch, optionally through patchFile.",
307
+ };
169
308
  if (offset > source.content.length) throw fail("mutation-range", "Read offset exceeds the current file length.", file);
170
- const content = source.content.slice(offset, offset + limit), end = offset + content.length;
171
- return { ...source, unit, content, offset, nextOffset: end < source.content.length ? end : null, totalChars: source.content.length,
172
- startLine: source.content.slice(0, offset).split("\n").length };
309
+ const content = source.content.slice(offset, offset + limit),
310
+ end = offset + content.length;
311
+ return {
312
+ ...source,
313
+ unit,
314
+ content,
315
+ offset,
316
+ nextOffset: end < source.content.length ? end : null,
317
+ totalChars: source.content.length,
318
+ startLine: source.content.slice(0, offset).split("\n").length,
319
+ };
173
320
  },
174
- async apply({ unit, patch, patchFile, patches, dryRun = false, screenshot = false, captures: selections }, signal, notifyProgress, { beforeApply } = {}) {
175
- if (busy) return mutationEvidence({ ok: false, applied: false, diagnostics: [{ rule: "mutation-busy", message: "Another mutation is validating; retry after it finishes.",failure:evidenceFailure("runner","mutation-execution","ADS_MUTATION_BUSY") }] });
321
+ async apply(
322
+ { unit, patch, patchFile, files, patches, checkRoot, previewHost: reviewedHost, dryRun = false },
323
+ signal,
324
+ notifyProgress,
325
+ { beforeApply } = {},
326
+ ) {
327
+ if (busy)
328
+ return mutationEvidence({
329
+ ok: false,
330
+ applied: false,
331
+ diagnostics: [
332
+ {
333
+ rule: "mutation-busy",
334
+ message: "Another mutation is validating; retry after it finishes.",
335
+ failure: evidenceFailure("runner", "mutation-execution", "ADS_MUTATION_BUSY"),
336
+ },
337
+ ],
338
+ });
176
339
  busy = true;
177
340
  active = new AbortController();
178
341
  signal = signal ? AbortSignal.any([signal, active.signal]) : active.signal;
179
342
  let temporary, candidateRevision, releasePreview, releasePublication, previewHost;
180
- let boundary=evidenceFailure("runner","mutation-execution","ADS_MUTATION_EXCEPTION",{certainty:"unclassified"});
343
+ const analysisRoots = new Set(),
344
+ analysisFiles = new Map();
345
+ let boundary = evidenceFailure("runner", "mutation-execution", "ADS_MUTATION_EXCEPTION", { certainty: "unclassified" });
181
346
  const verified = [];
182
347
  try {
183
348
  const options = loadConfig(root);
184
- if (screenshot && !dryRun || selections !== undefined && !screenshot) throw fail("mutation-capture", "Use screenshot:true only with dryRun:true and an explicit captures:[{scenario,target?,theme?,brand?,viewport?}] selection. Ordinary patches create no screenshots.");
185
- if (screenshot) selections = captureSelections(selections);
186
- if (patches !== undefined && (unit !== undefined || patch !== undefined || patchFile !== undefined || !Array.isArray(patches) || patches.length < 2 || patches.length > mutationLimits.units)) throw fail("mutation-batch", `A transaction requires 2–${mutationLimits.units} distinct owner patches, without a top-level unit/patch.`);
187
- const groups = patches ?? [{unit,patch,patchFile}];
188
- if (new Set(groups.map(group => group.unit)).size !== groups.length) throw fail("mutation-batch", "Use one patch per distinct unit in a transaction.");
349
+ if (
350
+ patches !== undefined &&
351
+ (unit !== undefined ||
352
+ patch !== undefined ||
353
+ patchFile !== undefined ||
354
+ !Array.isArray(patches) ||
355
+ patches.length < 2 ||
356
+ patches.length > mutationLimits.units)
357
+ )
358
+ throw fail("mutation-batch", `A transaction requires 2–${mutationLimits.units} distinct owner patches, without a top-level unit/patch.`);
359
+ const groups = patches ?? [{ unit, patch, patchFile, ...(files ? { files } : {}) }];
360
+ if (new Set(groups.map((group) => group.unit)).size !== groups.length)
361
+ throw fail("mutation-batch", "Use one patch per distinct unit in a transaction.");
189
362
  let patchBytes = 0;
190
- const plans = groups.map(group => {
363
+ const plans = groups.map((group) => {
191
364
  validateUnitId(group.unit);
192
- if ((typeof group.patch === "string") === (typeof group.patchFile === "string")) throw fail("mutation-patch", "Provide exactly one of patch or patchFile for each owner.");
193
- const value = group.patchFile === undefined ? group.patch : readPatchFile(options,group.patchFile);
365
+ // A draft hands over its proposed files as they are; no diff round trip.
366
+ if (group.files !== undefined) {
367
+ if (
368
+ group.patch !== undefined ||
369
+ group.patchFile !== undefined ||
370
+ !Array.isArray(group.files) ||
371
+ !group.files.length ||
372
+ group.files.length > mutationLimits.files
373
+ )
374
+ throw fail("mutation-batch", "Provide an owner's proposed files, or one patch, not both.");
375
+ return { unit: group.unit, entries: group.files.map((file) => ({ path: file.path, direct: true, content: file.content })) };
376
+ }
377
+ if ((typeof group.patch === "string") === (typeof group.patchFile === "string"))
378
+ throw fail("mutation-patch", "Provide exactly one of patch or patchFile for each owner.");
379
+ const value = group.patchFile === undefined ? group.patch : readPatchFile(options, group.patchFile);
194
380
  const maxPatch = group.patchFile === undefined ? mutationLimits.patchBytes : mutationLimits.patchFileBytes;
195
381
  patchBytes += Buffer.byteLength(value ?? "");
196
- if (typeof value !== "string" || value.includes("\0") || Buffer.from(value).toString("utf8") !== value || Buffer.byteLength(value) > maxPatch || patchBytes > mutationLimits.patchFileBytes) throw fail("mutation-patch", "Patch exceeds its UTF-8 Git diff size limit.");
197
- return {unit:group.unit,entries:parseUnifiedPatch(value,mutationLimits.files)};
382
+ if (
383
+ typeof value !== "string" ||
384
+ value.includes("\0") ||
385
+ Buffer.from(value).toString("utf8") !== value ||
386
+ Buffer.byteLength(value) > maxPatch ||
387
+ patchBytes > mutationLimits.patchFileBytes
388
+ )
389
+ throw fail("mutation-patch", "Patch exceeds its UTF-8 Git diff size limit.");
390
+ return { unit: group.unit, entries: parseUnifiedPatch(value, mutationLimits.files) };
198
391
  });
199
- const units = groups.map(group => group.unit), configuration = units.includes("configuration"), assets = units.some(unit => unit.startsWith("assets"));
200
- for (const plan of plans) for (const entry of plan.entries) address(options,entry.path);
201
- const changes = [], originals = [], byPath = new Map();
392
+ const units = groups.map((group) => group.unit),
393
+ configuration = units.includes("configuration"),
394
+ assets = units.some((unit) => unit.startsWith("assets"));
395
+ for (const plan of plans) for (const entry of plan.entries) address(options, entry.path);
396
+ const changes = [],
397
+ originals = [],
398
+ byPath = new Map();
202
399
  const cache = path.join(root, ".ds");
203
400
  mkdirSync(cache, { recursive: true });
204
401
  if (realpathSync(cache) !== path.join(realpathSync(root), ".ds")) throw fail("mutation-path", "The .ds directory cannot resolve through a symlink.");
@@ -206,210 +403,495 @@ export function createMutationController(directory, { captures = createCaptureCo
206
403
  trackExecutionWorkspace(temporary);
207
404
  const candidate = path.join(temporary, "project");
208
405
  mkdirSync(candidate);
209
- const patchPaths=plans.flatMap(plan=>plan.entries.map(entry=>entry.path));
210
- const copyBudget={bytes:0,files:0};
211
- const copiedInputs=copyInputs(options,candidate,patchPaths,{budget:copyBudget});
406
+ const patchPaths = plans.flatMap((plan) => plan.entries.map((entry) => entry.path));
407
+ const copyBudget = { bytes: 0, files: 0 };
408
+ const copiedInputs = await copyInputs(options, candidate, patchPaths, { budget: copyBudget, contents: analysisFiles });
409
+ const registerAnalysis = async (viewRoot = candidate) => {
410
+ await registerAnalysisRevision(
411
+ root,
412
+ viewRoot,
413
+ analysisFiles,
414
+ changes
415
+ .filter((change) => isAnalysisSource(change.path))
416
+ .map((change) => [change.path, change.content === null ? null : Buffer.from(change.content).toString("utf8")]),
417
+ copiedInputs.get("installed-dependencies") ?? "",
418
+ signal,
419
+ );
420
+ analysisRoots.add(viewRoot);
421
+ };
212
422
  const dependencies = path.join(root, "node_modules");
213
423
  if (!existsSync(dependencies)) throw fail("mutation-check", "Install project dependencies before using guarded mutations.");
214
424
  symlinkSync(realpathSync(dependencies), path.join(candidate, "node_modules"), process.platform === "win32" ? "junction" : "dir");
215
425
  // The tooling repository's own scripts run dist/cli.mjs. Preserve that
216
426
  // already-built runtime without treating generated output as source.
217
427
  if (existsSync(path.join(root, "dist")) && !existsSync(path.join(candidate, "dist"))) {
218
- let count = 0, bytes = 0;
219
- cpSync(path.join(root, "dist"), path.join(candidate, "dist"), { recursive: true, filter(file) {
220
- const stat = lstatSync(file);
221
- if (stat.isSymbolicLink()) throw fail("mutation-snapshot", "Generated runtime copies cannot contain symlinks.");
222
- if (stat.isFile()) { bytes += stat.size; ++count; }
223
- if (count > mutationLimits.snapshotFiles || bytes > mutationLimits.snapshotBytes) throw fail("mutation-snapshot", "Generated runtime exceeds the validation snapshot limit.");
224
- return true;
225
- } });
428
+ let count = 0,
429
+ bytes = 0;
430
+ cpSync(path.join(root, "dist"), path.join(candidate, "dist"), {
431
+ recursive: true,
432
+ filter(file) {
433
+ const stat = lstatSync(file);
434
+ if (stat.isSymbolicLink()) throw fail("mutation-snapshot", "Generated runtime copies cannot contain symlinks.");
435
+ if (stat.isFile()) {
436
+ bytes += stat.size;
437
+ ++count;
438
+ }
439
+ if (count > mutationLimits.snapshotFiles || bytes > mutationLimits.snapshotBytes)
440
+ throw fail("mutation-snapshot", "Generated runtime exceeds the validation snapshot limit.");
441
+ return true;
442
+ },
443
+ });
226
444
  }
227
- const entries = plans.flatMap(plan => plan.entries);
228
- if (entries.some(entry => entry.binary)) {
229
- const formats = new Set(entries.filter(entry=>entry.binary).map(entry=>entry.objectFormat));
445
+ const entries = plans.flatMap((plan) => plan.entries);
446
+ if (entries.some((entry) => entry.binary)) {
447
+ const formats = new Set(entries.filter((entry) => entry.binary).map((entry) => entry.objectFormat));
230
448
  if (formats.size !== 1) throw fail("mutation-patch", "Binary blocks in one Git diff must use the same object format.");
231
449
  await checkCommand("git", ["init", "--quiet", `--object-format=${[...formats][0]}`, candidate], root, signal);
232
450
  }
233
451
  for (const plan of plans) {
234
- const current = loadConfig(candidate), selected = plan.entries.map(entry => {
235
- address(options,entry.path);
236
- const before = read(current,entry.path);
237
- if (!entry.binary && before.binary) throw fail("mutation-patch", "Binary assets require a git diff --binary patch.", entry.path);
238
- const change = {path:entry.path, originalContent:before.content, content:entry.binary ? entry.operation === "delete" ? null : before.content ?? Buffer.alloc(0) : applyFilePatch(entry,before.content), ...(entry.binary ? {binaryPatch:entry.patch} : {})};
239
- if (!entry.binary) validateContent(change,plan.unit);
240
- if (!byPath.has(entry.path)) {
241
- const original = read(options,entry.path);
242
- // The candidate copy and live inputs must agree before any changes.
243
- if (original.digest !== before.digest) throw fail("mutation-conflict", "Source changed while preparing validation; regenerate the patch.", entry.path);
244
- originals.push({...original,mode:original.exists ? lstatSync(address(options,entry.path)).mode : undefined});
245
- byPath.set(entry.path,changes.length);
246
- changes.push({...change,expectedDigest:original.digest});
247
- if (changes.length > mutationLimits.files) throw fail("mutation-batch", `A transaction may change at most ${mutationLimits.files} distinct files.`);
248
- }
249
- return change;
250
- });
251
- const inventory = checkUnitFiles(current,plan.unit,selected,inspectUnits(current),true);
452
+ const current = loadConfig(candidate),
453
+ selected = await mapAsync(plan.entries, async (entry) => {
454
+ address(options, entry.path);
455
+ const before = read(current, entry.path);
456
+ if (!entry.binary && !entry.direct && before.binary) throw fail("mutation-patch", "Binary assets require a git diff --binary patch.", entry.path);
457
+ const change = {
458
+ path: entry.path,
459
+ originalContent: before.content,
460
+ content: entry.direct
461
+ ? entry.content
462
+ : entry.binary
463
+ ? entry.operation === "delete"
464
+ ? null
465
+ : (before.content ?? Buffer.alloc(0))
466
+ : applyFilePatch(entry, before.content),
467
+ ...(entry.binary ? { binaryPatch: entry.patch } : {}),
468
+ };
469
+ if (!entry.binary) await validateContent(change, plan.unit);
470
+ if (!byPath.has(entry.path)) {
471
+ const original = read(options, entry.path);
472
+ // The candidate copy and live inputs must agree before any changes.
473
+ if (original.digest !== before.digest)
474
+ throw fail("mutation-conflict", "Source changed while preparing validation; regenerate the patch.", entry.path);
475
+ originals.push({ ...original, mode: original.exists ? lstatSync(address(options, entry.path)).mode : undefined });
476
+ byPath.set(entry.path, changes.length);
477
+ changes.push({ ...change, expectedDigest: original.digest });
478
+ if (changes.length > mutationLimits.files)
479
+ throw fail("mutation-batch", `A transaction may change at most ${mutationLimits.files} distinct files.`);
480
+ }
481
+ return change;
482
+ });
483
+ const inventory = await checkUnitFiles(current, plan.unit, selected, await inspectUnits(current), true);
252
484
  for (const change of selected) {
253
- const file = path.join(candidate,change.path);
485
+ const file = path.join(candidate, change.path);
254
486
  if (change.binaryPatch) {
255
- for (const match of change.binaryPatch.matchAll(/^(?:literal|delta) (\d+)$/gm)) if (Number(match[1]) > mutationLimits.fileBytes) throw fail("mutation-content", "Binary patch blocks exceed 16 MiB.", change.path);
256
- await checkCommand("git",["apply","--binary","--whitespace=nowarn","-"],candidate,signal,change.binaryPatch);
487
+ for (const match of change.binaryPatch.matchAll(/^(?:literal|delta) (\d+)$/gm))
488
+ if (Number(match[1]) > mutationLimits.fileBytes) throw fail("mutation-content", "Binary patch blocks exceed 16 MiB.", change.path);
489
+ await checkCommand("git", ["apply", "--binary", "--whitespace=nowarn", "-"], candidate, signal, change.binaryPatch);
257
490
  change.content = existsSync(file) ? readFileSync(file) : null;
258
- validateContent(change,plan.unit);
491
+ await validateContent(change, plan.unit);
259
492
  } else if (change.content === null) rmSync(file);
260
- else {mkdirSync(path.dirname(file),{recursive:true});writeFileSync(file,change.content);}
493
+ else {
494
+ mkdirSync(path.dirname(file), { recursive: true });
495
+ writeFileSync(file, change.content);
496
+ }
261
497
  changes[byPath.get(change.path)].content = change.content;
262
498
  }
263
- checkUnitCandidate(loadConfig(candidate),plan.unit,selected,inventory);
499
+ await checkUnitCandidate(loadConfig(candidate), plan.unit, selected, inventory);
264
500
  }
265
- // Token sheet and theme/brand config patches carry the regenerated theme sheet with them.
501
+ // ADS removes an empty .gitkeep itself once accepted source is added beneath it.
502
+ for (const change of changes.filter((item) => item.originalContent === null && item.content !== null)) {
503
+ for (
504
+ let directory = path.posix.dirname(change.path);
505
+ directory !== "." && isInside(options.dsRoot, path.join(root, directory)) && path.join(root, directory) !== options.dsRoot;
506
+ directory = path.posix.dirname(directory)
507
+ ) {
508
+ const marker = `${directory}/.gitkeep`,
509
+ live = read(options, marker);
510
+ if (!live.exists || live.content !== "" || byPath.has(marker)) continue;
511
+ originals.push({ ...live, mode: lstatSync(address(options, marker)).mode });
512
+ byPath.set(marker, changes.length);
513
+ changes.push({ path: marker, originalContent: "", content: null, expectedDigest: live.digest });
514
+ // The live placeholder is part of the baseline the publication fences against.
515
+ copiedInputs.set(marker, digest(Buffer.from("")));
516
+ rmSync(path.join(candidate, marker), { force: true });
517
+ }
518
+ }
519
+ const candidateOptions = loadConfig(candidate);
520
+ // A proposed configuration may add roots or explicit inputs. Preserve
521
+ // already patched files while bringing those additional live inputs in.
522
+ const proposedInputs = Object.keys(await validationInputFiles(candidateOptions));
523
+ await copyInputs(
524
+ {
525
+ root,
526
+ config: candidateOptions.config,
527
+ dsRoot: path.resolve(root, candidateOptions.config.dsDir),
528
+ sourceRoot: path.resolve(root, candidateOptions.config.sourceDir),
529
+ },
530
+ candidate,
531
+ [...patchPaths, ...proposedInputs],
532
+ { baseline: copiedInputs, changed: new Set(changes.map((change) => change.path)), budget: copyBudget, contents: analysisFiles },
533
+ );
534
+ // Token sheet and theme/brand config changes carry the regenerated theme sheet with them,
535
+ // and exports file or token sheet changes carry the regenerated entries (barrels, styles entry).
266
536
  {
267
537
  const generatedOptions = loadConfig(candidate);
268
- for (const generated of writeThemesCss(generatedOptions, inspectTokens(candidate, generatedOptions)).files) {
269
- const relative = path.relative(candidate, generated.file).replaceAll("\\", "/"), current = generated.text !== undefined && read(options, relative);
538
+ await registerAnalysis();
539
+ // Theme files first: the public barrel publishes the generated font preloads when they exist.
540
+ const themes = writeThemesCss(generatedOptions, await analyze(candidate, "tokens", [], signal)).files;
541
+ const barrels = await generatedEntries(generatedOptions);
542
+ for (const barrel of barrels) {
543
+ mkdirSync(path.dirname(barrel.file), { recursive: true });
544
+ writeFileSync(barrel.file, barrel.text);
545
+ }
546
+ for (const generated of [...themes, ...barrels]) {
547
+ const relative = path.relative(candidate, generated.file).replaceAll("\\", "/"),
548
+ current = generated.text !== undefined && read(options, relative);
270
549
  if (current && current.content !== generated.text) {
271
550
  if (!byPath.has(relative)) {
272
- originals.push({...current,mode:current.exists ? lstatSync(address(options,relative)).mode : undefined});
273
- byPath.set(relative,changes.length);
274
- changes.push({path:relative,originalContent:current.content,content:generated.text,expectedDigest:current.digest});
551
+ originals.push({ ...current, mode: current.exists ? lstatSync(address(options, relative)).mode : undefined });
552
+ byPath.set(relative, changes.length);
553
+ changes.push({ path: relative, originalContent: current.content, content: generated.text, expectedDigest: current.digest });
275
554
  } else changes[byPath.get(relative)].content = generated.text;
276
555
  }
277
556
  }
278
557
  }
279
- const candidateOptions = loadConfig(candidate);
280
- // A proposed configuration may add roots or explicit inputs. Preserve
281
- // already patched files while bringing those additional live inputs in.
282
- const proposedInputs = Object.keys(validationInputFiles(candidateOptions));
283
- copyInputs({root,config:candidateOptions.config,dsRoot:path.resolve(root,candidateOptions.config.dsDir),sourceRoot:path.resolve(root,candidateOptions.config.sourceDir)},candidate,[...patchPaths,...proposedInputs],{baseline:copiedInputs,changed:new Set(changes.map(change=>change.path)),budget:copyBudget});
284
- const inputPaths = [...new Set([...changes.map(change=>change.path),...Object.keys(validationInputFiles(candidateOptions))])];
285
- const scopedInputs = () => {
558
+ await registerAnalysis();
559
+ const inputPaths = [...new Set([...changes.map((change) => change.path), ...Object.keys(await validationInputFiles(candidateOptions))])];
560
+ const scopedInputs = async () => {
286
561
  const files = {};
287
- for (const original of [options,candidateOptions]) {
288
- const rebased = { root, config: original.config, dsRoot: path.resolve(root,original.config.dsDir), sourceRoot: path.resolve(root,original.config.sourceDir) };
289
- Object.assign(files,validationInputFiles(rebased,inputPaths));
562
+ for (const original of [options, candidateOptions]) {
563
+ const rebased = {
564
+ root,
565
+ config: original.config,
566
+ dsRoot: path.resolve(root, original.config.dsDir),
567
+ sourceRoot: path.resolve(root, original.config.sourceDir),
568
+ };
569
+ Object.assign(files, await validationInputFiles(rebased, inputPaths));
290
570
  }
291
- return Object.fromEntries(Object.entries(files).sort(([a],[b])=>a.localeCompare(b)));
571
+ return Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)));
292
572
  };
293
- const currentInputs = scopedInputs();
294
- const before = JSON.stringify(Object.fromEntries(Object.keys(currentInputs).map(file=>[file,copiedInputs.get(file)??null])));
295
- if (JSON.stringify(currentInputs) !== before) throw fail("mutation-conflict","Relevant inputs changed while preparing validation; regenerate the patch.");
573
+ const currentInputs = await scopedInputs();
574
+ const before = JSON.stringify(Object.fromEntries(Object.keys(currentInputs).map((file) => [file, copiedInputs.get(file) ?? null])));
575
+ if (JSON.stringify(currentInputs) !== before)
576
+ throw fail("mutation-conflict", "Relevant inputs changed while preparing validation; regenerate the patch.");
296
577
  const extraChecks = checks(candidateOptions);
297
- const expected = snapshot(candidateOptions);
298
- candidateRevision=digest(Buffer.from(expected));
578
+ const expected = await snapshot(candidateOptions);
579
+ candidateRevision = digest(Buffer.from(expected));
299
580
  if (previewWork) releasePreview = await previewWork.acquire(signal);
300
- const result = await checkCandidate(candidate, signal, root);
301
- verified.push({name:"ads check",passed:result.ok,cache:result.cache});
302
- if (!result.ok) return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: result.diagnostics, total: result.diagnostics.length, checks: verified },candidateRevision);
581
+ // A reviewed draft's workspace holds exactly this candidate's inputs at a stable path, so
582
+ // its warm check (and a remembered report from a dry run) applies; otherwise check the copy.
583
+ // Compared over the project's own inputs plus the changed files.
584
+ const compared = [...new Set([...Object.keys(await validationInputFiles(options)), ...changes.map((change) => change.path)])];
585
+ const pick = (digests) => JSON.stringify(compared.map((file) => [file, digests[file] ?? null]));
586
+ const sameInputs =
587
+ checkRoot &&
588
+ existsSync(checkRoot) &&
589
+ pick(await validationInputFiles(loadConfig(checkRoot), compared)) === pick(await validationInputFiles(candidateOptions, compared));
590
+ // Browser checks of a reviewed draft render its workspace through the project's own host and
591
+ // compiler; only a candidate without one gets a preview host of its own.
592
+ const reviewRoot = sameInputs ? checkRoot : candidate,
593
+ sharedHost = sameInputs ? reviewedHost : undefined;
594
+ if (reviewRoot !== candidate) await registerAnalysis(reviewRoot);
595
+ const result = await checkCandidate(reviewRoot, signal, root);
596
+ verified.push({ name: "ads check", passed: result.ok, cache: result.cache });
597
+ if (!result.ok)
598
+ return (lastResult = mutationEvidence(
599
+ { ok: false, applied: false, diagnostics: result.diagnostics, total: result.diagnostics.length, checks: verified },
600
+ candidateRevision,
601
+ ));
303
602
  if (assets || configuration) {
304
- boundary=evidenceFailure("build","brand-assets","ADS_ASSET_BUILD");
603
+ boundary = evidenceFailure("build", "brand-assets", "ADS_ASSET_BUILD");
305
604
  const brand = await generateBrandAssets(candidate);
306
605
  verified.push({ name: "brand assets", passed: true, skipped: !!brand.skipped });
307
606
  }
308
- for (const [index,check] of extraChecks.entries()) {
309
- progress={stage:"project-checks",completed:index,total:extraChecks.length,message:`Checking ${check.command} ${check.args.join(" ")}`};notifyProgress?.(progress);
310
- verified.push(await checkCommand(check.command, check.args, candidate, signal, undefined, {category:"build",phase:`project-check:${check.args.at(-1)}`}, candidateOptions.config.mcp.mutationCheckTimeoutMs));
607
+ for (const [index, check] of extraChecks.entries()) {
608
+ progress = { stage: "project-checks", completed: index, total: extraChecks.length, message: `Checking ${check.command} ${check.args.join(" ")}` };
609
+ notifyProgress?.(progress);
610
+ verified.push(
611
+ await checkCommand(
612
+ check.command,
613
+ check.args,
614
+ candidate,
615
+ signal,
616
+ undefined,
617
+ { category: "build", phase: `project-check:${check.args.at(-1)}` },
618
+ candidateOptions.config.mcp.mutationCheckTimeoutMs,
619
+ ),
620
+ );
311
621
  }
312
- const behaviorUnits = candidateOptions.config.acceptance.behaviorChecks ? affectedBehaviorUnits(candidateOptions, changes.map(change => change.path)) : [];
313
- // acceptance.browserAudit (on unless false): axe-core audits the candidate's affected UI scenarios before any source is written.
314
- // It reuses the candidate preview host built for behavior checks/captures; on its own it starts a
315
- // candidate host that compiles only the selected scenarios.
316
- const audit = candidateOptions.config.acceptance.browserAudit ? await import("../browser-audit.mjs") : null;
317
- const auditSelection = audit?.auditScenarioSelection(candidateOptions, changes.map(change => change.path));
318
- if ((behaviorUnits.length || screenshot) && candidateOptions.config.mcp.previewManifest && candidateOptions.config.mcp.previewWatch) {
319
- boundary=evidenceFailure("build","preview-build","ADS_PREVIEW_BUILD");
320
- progress={stage:"preview-build",message:"Building all candidate previews"};notifyProgress?.(progress);
321
- const { startAdsMcp } = await import("./server.mjs");
322
- previewHost = await startAdsMcp(candidate, { stdio:false });
323
- await previewHost.buildAll(signal, {timeoutMs:candidateOptions.config.mcp.mutationCheckTimeoutMs});
324
- // Browser checks consume this immutable production graph. Keep its
325
- // resources hosted, release its compiler, and leave Explorer live.
326
- await previewHost.parkCompiler();
327
- verified.push({ name:"managed production previews", passed:true });
622
+ // Acceptance checks the draft's owners themselves: their own behavior tests (acceptance.behavior)
623
+ // and their own scenarios' render audit (acceptance.audit). What the change reaches beyond them is
624
+ // ads_validate's to check. The audit reuses the candidate preview host built for browser behavior
625
+ // checks; on its own it starts a candidate host that compiles only the selected scenarios.
626
+ const behaviorUnits = candidateOptions.config.acceptance.behavior
627
+ ? (await analyze(candidate, "behavior", [], signal)).contracts.map((contract) => contract.unit).filter((unit) => units.includes(unit))
628
+ : [];
629
+ const audit = candidateOptions.config.acceptance.audit ? await import("../render-audit.mjs") : null;
630
+ const auditSelection =
631
+ audit && (await analyze(candidate, "audit-selection", [changes.map((change) => change.path), { mode: "owners", owners: units }], signal));
632
+ // Previews are built only when a browser behavior check renders them.
633
+ if ((await analyze(candidate, "needs-browser", [behaviorUnits], signal)) && candidateOptions.config.framework) {
634
+ boundary = evidenceFailure("build", "preview-build", "ADS_PREVIEW_BUILD");
635
+ progress = { stage: "preview-build", message: "Building all candidate previews" };
636
+ notifyProgress?.(progress);
637
+ if (sharedHost) await sharedHost.buildAll(signal, { timeoutMs: candidateOptions.config.mcp.mutationCheckTimeoutMs });
638
+ else {
639
+ const { startAdsMcp } = await import("./server.mjs");
640
+ previewHost = await startAdsMcp(candidate, { stdio: false });
641
+ await previewHost.buildAll(signal, { timeoutMs: candidateOptions.config.mcp.mutationCheckTimeoutMs });
642
+ // Browser checks consume this immutable production graph. Keep its
643
+ // resources hosted, release its compiler, and leave Explorer live.
644
+ await previewHost.parkCompiler();
645
+ }
646
+ verified.push({ name: "managed production previews", passed: true });
328
647
  }
329
- boundary=evidenceFailure("runner","behavior-verification","ADS_BEHAVIOR_SETUP");
648
+ boundary = evidenceFailure("runner", "behavior-verification", "ADS_BEHAVIOR_SETUP");
330
649
  if (behaviorUnits.length) {
331
- const verification = createVerificationController(candidate, { reportRoot: root, previewHost, onProgress: value => { progress = { stage: "behavior", ...value }; notifyProgress?.(progress); } });
650
+ const verification = createVerificationController(reviewRoot, {
651
+ reportRoot: root,
652
+ previewHost: previewHost ?? sharedHost,
653
+ onProgress: (value) => {
654
+ progress = { stage: "behavior", ...value };
655
+ notifyProgress?.(progress);
656
+ },
657
+ });
332
658
  let evidence;
333
- try { evidence = await verification.run({ units: behaviorUnits, persist: false }, signal); }
334
- finally { await verification.close(); }
335
- if (!evidence.ok) return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: [...evidence.results.filter(item => item.status !== "passed").map(item => ({ rule: "behavior-check", failure:item.failure, message: `${item.unit}#${item.check}: ${item.status}. ${item.message}` })),...evidence.diagnostics], checks: verified, behavior: evidence },candidateRevision);
659
+ try {
660
+ evidence = await verification.run({ units: behaviorUnits, persist: false }, signal);
661
+ } finally {
662
+ await verification.close();
663
+ }
664
+ if (!evidence.ok)
665
+ return (lastResult = mutationEvidence(
666
+ {
667
+ ok: false,
668
+ applied: false,
669
+ diagnostics: [
670
+ ...evidence.results
671
+ .filter((item) => item.status !== "passed")
672
+ .map((item) => ({ rule: "behavior-check", failure: item.failure, message: `${item.unit}#${item.check}: ${item.status}. ${item.message}` })),
673
+ ...evidence.diagnostics,
674
+ ],
675
+ checks: verified,
676
+ behavior: evidence,
677
+ },
678
+ candidateRevision,
679
+ ));
336
680
  verified.push({ name: "registered behavior checks", passed: true, results: evidence.results });
337
- }
338
- else verified.push({name:"registered behavior checks",skipped:true,reason:candidateOptions.config.acceptance.behaviorChecks ? "No affected behavior contracts." : "Not required by acceptance policy."});
681
+ } else
682
+ verified.push({
683
+ name: "registered behavior checks",
684
+ skipped: true,
685
+ reason: candidateOptions.config.acceptance.behavior
686
+ ? "The draft's owners register no behavior checks."
687
+ : "Turned off by acceptance.behavior: false.",
688
+ });
339
689
  if (auditSelection) {
340
- boundary=evidenceFailure("runner","browser-audit","ADS_AUDIT_FAILED");
341
- const selection = {selection:auditSelection.mode,...(auditSelection.reason?{selectionReason:auditSelection.reason}:{}),auditedScenarios:auditSelection.scenarios};
342
- if (!auditSelection.scenarios.length) verified.push({name:"browser-accessibility-audit",skipped:true,reason:"No affected UI scenarios.",scenarios:0,...selection});
690
+ boundary = evidenceFailure("runner", "render-audit", "ADS_AUDIT_FAILED");
691
+ const selection = {
692
+ selection: auditSelection.mode,
693
+ ...(auditSelection.reason ? { selectionReason: auditSelection.reason } : {}),
694
+ auditedScenarios: auditSelection.scenarios,
695
+ };
696
+ if (!auditSelection.scenarios.length)
697
+ verified.push({ name: "render-audit", skipped: true, reason: "No affected UI scenarios.", scenarios: 0, ...selection });
343
698
  else {
344
- progress={stage:"browser-audit",message:`Accessibility audit of ${auditSelection.scenarios.length} candidate scenarios`};notifyProgress?.(progress);
345
- let result;
346
- try { result = await audit.runBrowserAudit(candidate, {scenarios:auditSelection.scenarios,previewHost,signal,onProgress:value=>{progress=value;notifyProgress?.(value);}}); }
347
- catch (error) {
348
- if (signal.aborted) throw error;
349
- verified.push({name:"browser-accessibility-audit",passed:false,...selection});
350
- return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: [{ rule: "browser-audit", message: error.message, failure: evidenceFailure("runner","browser-audit",error.code ?? "ADS_AUDIT_FAILED") }], checks: verified },candidateRevision);
699
+ progress = { stage: "render-audit", message: `Accessibility audit of ${auditSelection.scenarios.length} candidate scenarios` };
700
+ notifyProgress?.(progress);
701
+ const auditKey = `${candidateRevision}:${JSON.stringify(auditSelection.scenarios)}`,
702
+ remembered = audits.get(auditKey);
703
+ if (remembered) {
704
+ verified.push({ ...remembered.check, remembered: true });
705
+ if (!remembered.check.passed)
706
+ return (lastResult = mutationEvidence(
707
+ { ok: false, applied: false, diagnostics: remembered.diagnostics, total: remembered.diagnostics.length, checks: verified },
708
+ candidateRevision,
709
+ ));
710
+ } else {
711
+ let result;
712
+ try {
713
+ result = await audit.runRenderAudit(reviewRoot, {
714
+ scenarios: auditSelection.scenarios,
715
+ previewHost: previewHost ?? sharedHost,
716
+ signal,
717
+ onProgress: (value) => {
718
+ progress = value;
719
+ notifyProgress?.(value);
720
+ },
721
+ });
722
+ } catch (error) {
723
+ if (signal.aborted) throw error;
724
+ verified.push({ name: "render-audit", passed: false, ...selection });
725
+ return (lastResult = mutationEvidence(
726
+ {
727
+ ok: false,
728
+ applied: false,
729
+ diagnostics: [
730
+ { rule: "render-audit", message: error.message, failure: evidenceFailure("runner", "render-audit", error.code ?? "ADS_AUDIT_FAILED") },
731
+ ],
732
+ checks: verified,
733
+ },
734
+ candidateRevision,
735
+ ));
736
+ }
737
+ const { routed, check } = audit.auditCheck(result, selection);
738
+ audits.set(auditKey, {
739
+ check,
740
+ diagnostics: routed.diagnostics.map((item) => ({ ...item, failure: evidenceFailure("assertion", "render-audit", item.rule) })),
741
+ });
742
+ while (audits.size > 16) audits.delete(audits.keys().next().value);
743
+ verified.push(check);
744
+ if (!check.passed)
745
+ return (lastResult = mutationEvidence(
746
+ {
747
+ ok: false,
748
+ applied: false,
749
+ diagnostics: routed.diagnostics.map((item) => ({ ...item, failure: evidenceFailure("assertion", "render-audit", item.rule) })),
750
+ total: routed.diagnostics.length,
751
+ checks: verified,
752
+ ...(routed.advisories.length ? { advisories: routed.advisories, advisoryCount: routed.advisories.length } : {}),
753
+ },
754
+ candidateRevision,
755
+ ));
351
756
  }
352
- const {routed,check} = audit.auditCheck(result,selection);
353
- verified.push(check);
354
- if (!check.passed) return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: routed.diagnostics.map(item => ({...item,failure:evidenceFailure("assertion","browser-audit",item.rule)})), total: routed.diagnostics.length, checks: verified, ...(routed.advisories.length ? {advisories:routed.advisories,advisoryCount:routed.advisories.length} : {}) },candidateRevision);
355
757
  }
356
758
  }
357
- let screenshots;
358
- if (screenshot) {
359
- boundary=evidenceFailure("runner","capture","ADS_CAPTURE_FAILED");
360
- progress = { stage: "capture", total: selections.length, completed: 0, active: [], profile: "screenshots", elapsedMs: 0 };
361
- notifyProgress?.(progress);
362
- const proposal = digest(Buffer.from(JSON.stringify(changes.map(change => [change.path, change.content === null ? null : digest(Buffer.from(change.content))]))));
363
- screenshots = await captures.run({ captures: selections, candidateRoot: candidate, proposal, publish: false }, signal, value => { progress = value; notifyProgress?.(value); });
364
- }
365
759
  let preparedPreview;
366
- if(!dryRun){try{preparedPreview=preparePreviewCache(candidateOptions,loadConfig(root));}catch{/* A missing cache falls back to background compilation. */}}
367
- if (signal?.aborted) throw fail("mutation-cancelled", "Mutation cancelled before application.",undefined,evidenceFailure("runner","mutation-execution","ADS_CANCELLED"));
368
- if (snapshot(candidateOptions) !== expected) throw fail("mutation-check", "A validation command changed source files. Use checks without source-writing side effects.");
369
- if (JSON.stringify(scopedInputs()) !== before) throw fail("mutation-conflict", "ADS, consuming UI or declared validation inputs changed during validation; no changes were applied. Read current source and retry.");
370
- for (const change of changes) address(options, change.path);
371
- if (screenshots) {
372
- captures.store.commit(screenshots.records);
373
- const selected = new Set(screenshots.records.map(record => record.key));
374
- screenshots = { ok: true, captures: captures.store.list(inspectScenarios(loadConfig(root)).scenarios, screenshots.baseRevision).captures.filter(record => selected.has(record.key)) };
760
+ if (!dryRun) {
761
+ try {
762
+ preparedPreview = await preparePreviewCache(candidateOptions, loadConfig(root));
763
+ } catch {
764
+ /* A missing cache falls back to background compilation. */
765
+ }
375
766
  }
767
+ if (signal?.aborted)
768
+ throw fail(
769
+ "mutation-cancelled",
770
+ "Mutation cancelled before application.",
771
+ undefined,
772
+ evidenceFailure("runner", "mutation-execution", "ADS_CANCELLED"),
773
+ );
774
+ if ((await snapshot(candidateOptions)) !== expected)
775
+ throw fail("mutation-check", "A validation command changed source files. Use checks without source-writing side effects.");
776
+ if (JSON.stringify(await scopedInputs()) !== before)
777
+ throw fail(
778
+ "mutation-conflict",
779
+ "ADS, consuming UI or declared validation inputs changed during validation; no changes were applied. Read current source and retry.",
780
+ );
781
+ for (const change of changes) address(options, change.path);
376
782
  if (!dryRun) {
377
- beforeApply?.();
783
+ await beforeApply?.();
378
784
  if (preparedPreview) releasePublication = holdLivePreview(root);
379
785
  const written = [];
380
786
  const directories = [];
381
- function mkdir(directory) { if (!existsSync(directory)) { mkdir(path.dirname(directory)); mkdirSync(directory); directories.push(directory); } }
787
+ function mkdir(directory) {
788
+ if (!existsSync(directory)) {
789
+ mkdir(path.dirname(directory));
790
+ mkdirSync(directory);
791
+ directories.push(directory);
792
+ }
793
+ }
382
794
  function replace(file, content, mode) {
383
795
  mkdir(path.dirname(file));
384
796
  const staged = path.join(path.dirname(file), `.ads-edit-${randomUUID()}`);
385
- try { writeFileSync(staged, content, { mode }); renameSync(staged, file); }
386
- finally { rmSync(staged, { force: true }); }
797
+ try {
798
+ writeFileSync(staged, content, { mode });
799
+ renameSync(staged, file);
800
+ } finally {
801
+ rmSync(staged, { force: true });
802
+ }
387
803
  }
388
804
  try {
389
805
  changes.forEach((change, index) => {
390
806
  const file = address(options, change.path);
391
- if (change.content === null) rmSync(file); else replace(file, change.content, originals[index].mode);
807
+ if (change.content === null) rmSync(file);
808
+ else replace(file, change.content, originals[index].mode);
392
809
  written.push(index);
393
810
  });
394
811
  } catch (error) {
395
812
  for (const index of written.reverse()) {
396
- const original = originals[index], file = path.join(root, original.path);
397
- if (original.exists) replace(file, original.content, original.mode); else rmSync(file, { force: true });
813
+ const original = originals[index],
814
+ file = path.join(root, original.path);
815
+ if (original.exists) replace(file, original.content, original.mode);
816
+ else rmSync(file, { force: true });
398
817
  }
399
818
  for (const directory of directories.reverse()) if (!readdirSync(directory).length) rmSync(directory, { recursive: true });
400
819
  throw error;
401
820
  }
402
821
  }
403
822
  const warnings = [];
404
- if (!dryRun && (assets || configuration)) { try { await generateBrandAssets(root); } catch (error) { warnings.push({ rule: "mutation-assets", message: `Source was applied; generated brand output needs recovery: ${error.message}` }); } }
405
- if (!dryRun && captures.store.fingerprint()) { try { captures.store.promote(previewSourceRevision(loadConfig(root)), inspectScenarios(loadConfig(root)).scenarios); } catch (error) { warnings.push({ rule: "mutation-capture", message: `Source was applied; capture promotion needs recovery: ${error.message}` }); } }
406
- if (!dryRun && preparedPreview) { try { preparedPreview(); } catch (error) { warnings.push({rule:"mutation-preview-cache",message:`Source was applied; preview warming will rebuild instead: ${error.message}`}); } }
407
- return lastResult = mutationEvidence({ ok: true, ...(patches ? {units,transaction:true} : {unit}), applied: !dryRun, changes: changes.map(change => ({ path: change.path, operation: change.content === null ? "delete" : change.expectedDigest === null ? "create" : "update", digest: change.content === null ? null : digest(Buffer.from(change.content)) })), checks: verified, ...(result.advisories?.length ? { advisories: result.advisories, advisoryCount: result.advisories.length } : {}), ...(warnings.length ? { warnings } : {}),
408
- ...(screenshots ? { screenshots } : {}),
409
- preview: "Source validation passed. Inspect the managed preview build and rendered scenario after applying; validation is not visual verification." },candidateRevision);
823
+ if (!dryRun && (assets || configuration)) {
824
+ try {
825
+ await generateBrandAssets(root);
826
+ } catch (error) {
827
+ warnings.push({ rule: "mutation-assets", message: `Source was applied; generated brand output needs recovery: ${error.message}` });
828
+ }
829
+ }
830
+ if (!dryRun && captures.store.fingerprint()) {
831
+ try {
832
+ captures.store.promote(await previewSourceRevision(loadConfig(root)), (await analyze(root, "registry")).scenarios);
833
+ } catch (error) {
834
+ warnings.push({ rule: "mutation-capture", message: `Source was applied; capture promotion needs recovery: ${error.message}` });
835
+ }
836
+ }
837
+ if (!dryRun && preparedPreview) {
838
+ try {
839
+ await preparedPreview();
840
+ } catch (error) {
841
+ warnings.push({ rule: "mutation-preview-cache", message: `Source was applied; preview warming will rebuild instead: ${error.message}` });
842
+ }
843
+ }
844
+ if (!dryRun && analysisRoots.has(candidate)) {
845
+ try {
846
+ await promoteAnalysisRevision(candidate, root);
847
+ } catch {
848
+ await releaseAnalysisRevision(candidate).catch(() => {});
849
+ }
850
+ analysisRoots.delete(candidate);
851
+ }
852
+ return (lastResult = mutationEvidence(
853
+ {
854
+ ok: true,
855
+ ...(patches ? { units, transaction: true } : { unit }),
856
+ applied: !dryRun,
857
+ changes: changes.map((change) => ({
858
+ path: change.path,
859
+ operation: change.content === null ? "delete" : change.expectedDigest === null ? "create" : "update",
860
+ digest: change.content === null ? null : digest(Buffer.from(change.content)),
861
+ })),
862
+ checks: verified,
863
+ ...(result.advisories?.length ? { advisories: result.advisories, advisoryCount: result.advisories.length } : {}),
864
+ ...(warnings.length ? { warnings } : {}),
865
+ preview: "Source validation passed. Inspect the managed preview build and rendered scenario after applying; validation is not visual verification.",
866
+ },
867
+ candidateRevision,
868
+ ));
410
869
  } catch (error) {
411
- return lastResult = mutationEvidence({ ok: false, applied: false, diagnostics: [error.diagnostic ?? { rule: "mutation-error", message: error.message,failure:error.failure??boundary }], checks: verified },candidateRevision);
412
- } finally { releasePublication?.(); try { await previewHost?.close(); } finally { try { if (temporary) rmSync(temporary, { recursive: true, force: true }); } finally { releasePreview?.(); busy = false; active = undefined; progress = undefined; } } }
870
+ return (lastResult = mutationEvidence(
871
+ {
872
+ ok: false,
873
+ applied: false,
874
+ diagnostics: [error.diagnostic ?? { rule: "mutation-error", message: error.message, failure: error.failure ?? boundary }],
875
+ checks: verified,
876
+ },
877
+ candidateRevision,
878
+ ));
879
+ } finally {
880
+ for (const analysisRoot of analysisRoots) await releaseAnalysisRevision(analysisRoot).catch(() => {});
881
+ releasePublication?.();
882
+ try {
883
+ await previewHost?.close();
884
+ } finally {
885
+ try {
886
+ if (temporary) rmSync(temporary, { recursive: true, force: true });
887
+ } finally {
888
+ releasePreview?.();
889
+ busy = false;
890
+ active = undefined;
891
+ progress = undefined;
892
+ }
893
+ }
894
+ }
413
895
  },
414
896
  };
415
897
  }