@reqvire-org/ads 0.4.0 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -87
- package/dist/a11y.mjs +133 -48
- package/dist/analysis/compiler-options.mjs +13 -0
- package/dist/analysis/context.mjs +46 -0
- package/dist/analysis/file-tree.mjs +52 -0
- package/dist/analysis/helpers.mjs +142 -0
- package/dist/analysis/impact.mjs +20 -0
- package/dist/analysis/inputs.mjs +22 -0
- package/dist/analysis/module-resolvers.mjs +46 -0
- package/dist/analysis/native-adapter.mjs +180 -0
- package/dist/analysis/native-project.mjs +323 -0
- package/dist/analysis/queries.mjs +133 -0
- package/dist/analysis/service.mjs +153 -0
- package/dist/analysis/standalone.mjs +57 -0
- package/dist/analysis/syntax.mjs +179 -0
- package/dist/analysis/worker.mjs +182 -0
- package/dist/assets.mjs +6 -6
- package/dist/atomic-composition.mjs +191 -70
- package/dist/atomic-trace.mjs +120 -50
- package/dist/behavior-libraries.mjs +106 -37
- package/dist/behaviors.mjs +219 -77
- package/dist/boundaries.mjs +140 -41
- package/dist/brand-assets.mjs +219 -47
- package/dist/brands.mjs +86 -27
- package/dist/bun-compiler.mjs +28 -14
- package/dist/bun-worker.mjs +7 -5
- package/dist/capture/worker.mjs +15 -4
- package/dist/capture-store.mjs +4 -2
- package/dist/capture.mjs +17 -14
- package/dist/check-service.mjs +44 -58
- package/dist/check.mjs +754 -188
- package/dist/cli.mjs +200 -99
- package/dist/color-values.mjs +21 -21
- package/dist/component-contrast.mjs +127 -9
- package/dist/config.mjs +303 -135
- package/dist/construction-styles.cjs +10 -0
- package/dist/contrast-composition.mjs +134 -0
- package/dist/control-padding.mjs +45 -25
- package/dist/css-values.mjs +3 -2
- package/dist/declarative-flow.mjs +209 -109
- package/dist/design-values.mjs +136 -51
- package/dist/development-runtime.mjs +4 -6
- package/dist/draft-boundary.mjs +11 -6
- package/dist/evidence.mjs +1 -1
- package/dist/finding-rules.mjs +9 -5
- package/dist/font-rules.mjs +22 -17
- package/dist/fonts-generated.mjs +23 -16
- package/dist/foundation-views.mjs +242 -0
- package/dist/foundation.mjs +63 -39
- package/dist/generated-entries.mjs +101 -34
- package/dist/icons.mjs +79 -32
- package/dist/image-attributes.mjs +143 -66
- package/dist/image-size.mjs +1 -1
- package/dist/index.mjs +0 -2
- package/dist/init.mjs +122 -41
- package/dist/investigations.mjs +2 -2
- package/dist/layers.mjs +298 -129
- package/dist/layout-widths.mjs +180 -85
- package/dist/linaria/preserve-values.cjs +7 -0
- package/dist/linaria/spatial-inputs.cjs +56 -0
- package/dist/lockup-composition.mjs +44 -0
- package/dist/lockup-model.cjs +64 -0
- package/dist/mcp/THIRD_PARTY_NOTICES.md +51 -1
- package/dist/mcp/apps.mjs +4 -30
- package/dist/mcp/behavior-pages.mjs +72 -24
- package/dist/mcp/build-status.mjs +257 -64
- package/dist/mcp/catalog.mjs +90 -26
- package/dist/mcp/context.mjs +17 -18
- package/dist/mcp/draft-discovery.mjs +44 -21
- package/dist/mcp/drafts.mjs +903 -281
- package/dist/mcp/execution-coordinator.mjs +417 -167
- package/dist/mcp/execution-results.mjs +7 -7
- package/dist/mcp/mutations.mjs +673 -234
- package/dist/mcp/preview-watch.mjs +448 -170
- package/dist/mcp/preview-widget.bundle.js +44 -50
- package/dist/mcp/prompts.mjs +5 -5
- package/dist/mcp/result-pages.mjs +1 -1
- package/dist/mcp/sandbox-host.mjs +1 -1
- package/dist/mcp/server.mjs +2409 -577
- package/dist/mcp/showcase-host.mjs +165 -41
- package/dist/mcp/skills.mjs +1 -1
- package/dist/mcp/text-diff.mjs +29 -10
- package/dist/paint-contracts.mjs +174 -81
- package/dist/palette-generated.mjs +2 -2
- package/dist/pictogram-model.mjs +59 -0
- package/dist/pictograms.mjs +52 -0
- package/dist/preview-bun.mjs +494 -187
- package/dist/preview-failure.mjs +1 -1
- package/dist/preview-files.mjs +13 -13
- package/dist/preview-imports.mjs +104 -55
- package/dist/preview-inputs.mjs +2 -2
- package/dist/preview-requests.mjs +24 -0
- package/dist/preview-resources.mjs +288 -147
- package/dist/preview-scope.mjs +5 -4
- package/dist/program-cache.mjs +8 -34
- package/dist/project-documents.mjs +1 -1
- package/dist/public-api.mjs +69 -31
- package/dist/public-props.mjs +39 -22
- package/dist/{browser-audit → render-audit}/axe-run.mjs +3 -3
- package/dist/{browser-audit → render-audit}/image-shape.mjs +15 -5
- package/dist/{browser-audit → render-audit}/layout-overflow.mjs +86 -23
- package/dist/{browser-audit → render-audit}/non-text-contrast.mjs +86 -27
- package/dist/render-audit/pictograms.mjs +88 -0
- package/dist/{browser-audit → render-audit}/render-states.mjs +208 -52
- package/dist/{browser-audit → render-audit}/worker.mjs +98 -30
- package/dist/render-audit.mjs +838 -0
- package/dist/render-color-probe.mjs +96 -42
- package/dist/render-composition.mjs +164 -0
- package/dist/resource-limits.mjs +229 -97
- package/dist/runtime-contracts.mjs +467 -185
- package/dist/scenario-groups.mjs +22 -10
- package/dist/scenario-inspector.mjs +6 -43
- package/dist/scenario-program.mjs +8 -25
- package/dist/scenario-registry.mjs +72 -30
- package/dist/scenario-selectors.mjs +161 -64
- package/dist/scenario-slots.mjs +149 -56
- package/dist/scenario-trace.mjs +215 -109
- package/dist/scenarios-compiler.mjs +719 -378
- package/dist/scenarios-vite.d.mts +1 -3
- package/dist/scenarios-vite.mjs +2 -81
- package/dist/scenarios.mjs +421 -157
- package/dist/selector-match.mjs +2 -2
- package/dist/showcase/client.bundle.js +57 -56
- package/dist/showcase/draft-navigation.js +21 -3
- package/dist/showcase/favicon.ico +0 -0
- package/dist/showcase/favicon.svg +1 -0
- package/dist/showcase/foundation-view.css +58 -0
- package/dist/showcase/foundation-view.mjs +255 -0
- package/dist/showcase/guide-controls.ads.review.mjs +32 -0
- package/dist/showcase/icons.js +1 -145
- package/dist/showcase/index.html +3 -31
- package/dist/showcase/pictogram-view.mjs +53 -0
- package/dist/showcase/preview-frame.ads.review.css +46 -0
- package/dist/showcase/preview-frame.ads.review.d.mts +11 -0
- package/dist/showcase/preview-frame.ads.review.mjs +22 -0
- package/dist/showcase/preview-state.js +0 -9
- package/dist/showcase/refresh-scheduler.js +23 -0
- package/dist/showcase/style.css +5 -47
- package/dist/showcase/ui/ui.css +1353 -0
- package/dist/showcase/ui/ui.js +1064 -0
- package/dist/showcase-coverage.mjs +58 -37
- package/dist/skills/README.md +24 -23
- package/dist/skills/ads-designer/README.md +8 -2
- package/dist/skills/ads-designer/SKILL.md +143 -120
- package/dist/skills/ads-designer/references/accessibility.md +78 -15
- package/dist/skills/ads-designer/references/atomic-styles.md +4 -4
- package/dist/skills/ads-designer/references/behaviors.md +30 -27
- package/dist/skills/ads-designer/references/branding.md +101 -24
- package/dist/skills/ads-designer/references/captures.md +25 -0
- package/dist/skills/ads-designer/references/cli.md +21 -24
- package/dist/skills/ads-designer/references/contracts.md +7 -6
- package/dist/skills/ads-designer/references/design-data.md +49 -52
- package/dist/skills/ads-designer/references/drafts.md +20 -17
- package/dist/skills/ads-designer/references/evidence.md +1 -5
- package/dist/skills/ads-designer/references/guarded-editing.md +14 -18
- package/dist/skills/ads-designer/references/layers.md +1 -1
- package/dist/skills/ads-designer/references/layout.md +347 -0
- package/dist/skills/ads-designer/references/mobile.md +2 -1
- package/dist/skills/{ads-motion/references/performance.md → ads-designer/references/motion-performance.md} +5 -1
- package/dist/skills/{ads-motion/references/build.md → ads-designer/references/motion.md} +73 -5
- package/dist/skills/ads-designer/references/performance.md +3 -2
- package/dist/skills/ads-designer/references/pictograms.md +131 -0
- package/dist/skills/ads-designer/references/review.md +37 -34
- package/dist/skills/ads-designer/references/runtimes.md +33 -30
- package/dist/skills/ads-designer/references/scenarios.md +16 -18
- package/dist/skills/{ads-break-ui/references/catalog.md → ads-designer/references/stress-catalog.md} +3 -1
- package/dist/skills/ads-designer/references/stress-test.md +68 -0
- package/dist/skills/ads-designer/references/validation.md +83 -75
- package/dist/skills/ads-designer/references/workflows.md +8 -33
- package/dist/skills/ads-import/SKILL.md +43 -325
- package/dist/skills/ads-import/references/atomic-styles.md +4 -4
- package/dist/skills/ads-import/references/behaviors.md +30 -27
- package/dist/skills/ads-import/references/branding.md +5 -5
- package/dist/skills/ads-import/references/captures.md +25 -0
- package/dist/skills/ads-import/references/cli.md +21 -24
- package/dist/skills/ads-import/references/compatibility.md +1 -1
- package/dist/skills/ads-import/references/contracts.md +7 -6
- package/dist/skills/ads-import/references/design-data.md +49 -52
- package/dist/skills/ads-import/references/drafts.md +20 -17
- package/dist/skills/ads-import/references/evidence.md +1 -5
- package/dist/skills/ads-import/references/guarded-editing.md +14 -18
- package/dist/skills/ads-import/references/implementation.md +2 -1
- package/dist/skills/ads-import/references/layers.md +1 -1
- package/dist/skills/ads-import/references/layout.md +347 -0
- package/dist/skills/ads-import/references/review.md +37 -34
- package/dist/skills/ads-import/references/runtimes.md +33 -30
- package/dist/skills/ads-import/references/scenarios.md +16 -18
- package/dist/skills/ads-import/references/tokens.md +3 -3
- package/dist/skills/ads-import/references/validation.md +83 -75
- package/dist/skills/ads-import/references/workflows.md +8 -33
- package/dist/skills/ads-migrate/SKILL.md +56 -0
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +602 -0
- package/dist/skills/ads-port/SKILL.md +58 -344
- package/dist/skills/ads-port/references/atomic-styles.md +4 -4
- package/dist/skills/ads-port/references/behaviors.md +30 -27
- package/dist/skills/ads-port/references/captures.md +25 -0
- package/dist/skills/ads-port/references/cli.md +21 -24
- package/dist/skills/ads-port/references/contracts.md +7 -6
- package/dist/skills/ads-port/references/design-data.md +49 -52
- package/dist/skills/ads-port/references/drafts.md +20 -17
- package/dist/skills/ads-port/references/evidence.md +1 -5
- package/dist/skills/ads-port/references/guarded-editing.md +14 -18
- package/dist/skills/ads-port/references/layers.md +1 -1
- package/dist/skills/ads-port/references/layout.md +347 -0
- package/dist/skills/ads-port/references/lint-and-docs.md +8 -11
- package/dist/skills/ads-port/references/native-implementation.md +2 -1
- package/dist/skills/ads-port/references/review.md +37 -34
- package/dist/skills/ads-port/references/runtimes.md +33 -30
- package/dist/skills/ads-port/references/scenarios.md +16 -18
- package/dist/skills/ads-port/references/validation.md +83 -75
- package/dist/skills/ads-port/references/workflows.md +8 -33
- package/dist/source-symbols.mjs +1 -8
- package/dist/source-values.mjs +270 -129
- package/dist/spatial-composition.mjs +322 -0
- package/dist/spatial-contexts.cjs +56 -0
- package/dist/spatial-css.cjs +351 -0
- package/dist/spatial-inputs.cjs +80 -0
- package/dist/spatial-metadata.mjs +18 -0
- package/dist/spatial-model.cjs +322 -0
- package/dist/spatial.mjs +21 -0
- package/dist/stage-timing.cjs +20 -0
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +275 -0
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +8 -0
- package/dist/starters/preact/ds.config.json +25 -6
- package/dist/starters/preact/package.json +4 -8
- package/dist/starters/preact/tsconfig.json +4 -5
- package/dist/starters/preact/vite.config.ts +3 -3
- package/dist/starters/react/ADS.md +42 -47
- package/dist/starters/react/README.md +47 -49
- package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +13 -0
- package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +7 -0
- package/dist/starters/react/design-system/assets/pictograms/journey.svg +7 -0
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +18 -2
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +3 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +1 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +7 -0
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +26 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +5 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +13 -0
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +22 -0
- package/dist/starters/react/design-system/index.ts +2 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +7 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +15 -0
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +105 -0
- package/dist/starters/react/design-system/patterns/Conversation/README.md +9 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/README.md +43 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +5 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +21 -0
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +274 -0
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +7 -0
- package/dist/starters/react/design-system/review/index.ads.review.ts +4 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +1 -0
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +6 -0
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +1 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +10 -0
- package/dist/starters/react/design-system/showcase/mcp/{main.tsx → main.ads.mount.tsx} +4 -2
- package/dist/starters/react/design-system/tokens/catalog.ads.json +1221 -0
- package/dist/starters/react/design-system/tokens/colors.css +1 -1
- package/dist/starters/react/design-system/tokens/spacing.css +22 -32
- package/dist/starters/react/design-system/tokens/spatial.ads.json +70 -0
- package/dist/starters/react/design-system/tokens/themes.generated.ts +1 -1
- package/dist/starters/react/ds.config.json +25 -6
- package/dist/starters/react/package.json +2 -6
- package/dist/starters/react/tsconfig.json +2 -3
- package/dist/starters/react/vite.config.ts +3 -3
- package/dist/style-boundaries.mjs +70 -25
- package/dist/task-cache.mjs +173 -72
- package/dist/task-worker.mjs +22 -11
- package/dist/test-boundaries.mjs +132 -59
- package/dist/themes-generated.mjs +1 -1
- package/dist/themes-watch.mjs +57 -22
- package/dist/themes.mjs +176 -73
- package/dist/token-export.mjs +39 -14
- package/dist/token-policy.mjs +6 -3
- package/dist/token-quality.mjs +6 -6
- package/dist/token-samples.mjs +16 -5
- package/dist/tokens.mjs +71 -26
- package/dist/ui-framework.mjs +16 -14
- package/dist/unit-contracts.mjs +251 -104
- package/dist/units.mjs +209 -99
- package/dist/usage.mjs +138 -38
- package/dist/validation-checks.mjs +115 -38
- package/dist/validation-inputs.mjs +191 -78
- package/dist/validation.mjs +268 -102
- package/dist/verification/browser.mjs +27 -5
- package/dist/verification.mjs +711 -187
- package/docs/ADS.md +96 -80
- package/docs/ARCHITECTURE.md +368 -137
- package/docs/BEHAVIORS.md +29 -25
- package/docs/CACHING.md +77 -17
- package/docs/CHANGELOG.md +332 -17
- package/docs/CONTRACTS.md +12 -4
- package/docs/DESIGN-REFERENCES.md +40 -0
- package/docs/GUIDE.md +300 -263
- package/docs/MCP.md +187 -324
- package/docs/SPATIAL-CHECKS.md +69 -0
- package/docs/benchmarks/README.md +39 -0
- package/package.json +43 -34
- package/dist/browser-audit.mjs +0 -429
- package/dist/create.mjs +0 -48
- package/dist/lint-config.mjs +0 -50
- package/dist/mcp/project-widget.bundle.js +0 -114
- package/dist/mcp/reports.mjs +0 -101
- package/dist/mcp/widget.bundle.js +0 -147
- package/dist/oxlint.mjs +0 -89
- package/dist/preview-builder.mjs +0 -133
- package/dist/preview-workers.mjs +0 -184
- package/dist/showcase.mjs +0 -77
- package/dist/skills/ads-break-ui/LICENSE.upstream +0 -21
- package/dist/skills/ads-break-ui/README.md +0 -16
- package/dist/skills/ads-break-ui/SKILL.md +0 -412
- package/dist/skills/ads-break-ui/agents/openai.yaml +0 -4
- package/dist/skills/ads-break-ui/references/atomic-styles.md +0 -293
- package/dist/skills/ads-break-ui/references/behaviors.md +0 -412
- package/dist/skills/ads-break-ui/references/captures.md +0 -135
- package/dist/skills/ads-break-ui/references/contracts.md +0 -317
- package/dist/skills/ads-break-ui/references/design-data.md +0 -354
- package/dist/skills/ads-break-ui/references/drafts.md +0 -194
- package/dist/skills/ads-break-ui/references/evidence.md +0 -128
- package/dist/skills/ads-break-ui/references/guarded-editing.md +0 -165
- package/dist/skills/ads-break-ui/references/layers.md +0 -145
- package/dist/skills/ads-break-ui/references/reporting.md +0 -101
- package/dist/skills/ads-break-ui/references/review.md +0 -97
- package/dist/skills/ads-break-ui/references/runtimes.md +0 -203
- package/dist/skills/ads-break-ui/references/scenarios.md +0 -246
- package/dist/skills/ads-break-ui/references/validation.md +0 -166
- package/dist/skills/ads-break-ui/references/verification.md +0 -58
- package/dist/skills/ads-break-ui/references/workflows.md +0 -90
- package/dist/skills/ads-designer/references/reporting.md +0 -101
- package/dist/skills/ads-import/references/reporting.md +0 -101
- package/dist/skills/ads-motion/LICENSE.upstream +0 -21
- package/dist/skills/ads-motion/README.md +0 -22
- package/dist/skills/ads-motion/SKILL.md +0 -385
- package/dist/skills/ads-motion/agents/openai.yaml +0 -4
- package/dist/skills/ads-motion/references/atomic-styles.md +0 -293
- package/dist/skills/ads-motion/references/audit.md +0 -44
- package/dist/skills/ads-motion/references/behaviors.md +0 -412
- package/dist/skills/ads-motion/references/captures.md +0 -135
- package/dist/skills/ads-motion/references/contracts.md +0 -317
- package/dist/skills/ads-motion/references/design-data.md +0 -354
- package/dist/skills/ads-motion/references/drafts.md +0 -194
- package/dist/skills/ads-motion/references/evidence.md +0 -128
- package/dist/skills/ads-motion/references/guarded-editing.md +0 -165
- package/dist/skills/ads-motion/references/layers.md +0 -145
- package/dist/skills/ads-motion/references/motion-review.md +0 -35
- package/dist/skills/ads-motion/references/reporting.md +0 -101
- package/dist/skills/ads-motion/references/review.md +0 -97
- package/dist/skills/ads-motion/references/runtimes.md +0 -203
- package/dist/skills/ads-motion/references/scenarios.md +0 -246
- package/dist/skills/ads-motion/references/validation.md +0 -166
- package/dist/skills/ads-motion/references/verification.md +0 -39
- package/dist/skills/ads-motion/references/workflows.md +0 -90
- package/dist/skills/ads-port/references/reporting.md +0 -101
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/components/Layout/Grid/Grid.tsx +0 -76
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/preact/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/preact/design-system/showcase/mcp/main.tsx +0 -6
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Icons/AppIcon/AppIcon.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/brand/Identity/Logo/Logo.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.fixture.ts +0 -12
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.ads.scenario.tsx +0 -17
- package/dist/starters/react/design-system/components/Layout/Grid/Grid.tsx +0 -75
- package/dist/starters/react/design-system/components/Layout/Grid/README.md +0 -21
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/brand-preview/BrandPreview.tsx +0 -112
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.tsx +0 -29
- package/dist/starters/react/design-system/review/grid-cell/GridCell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/grid-cell/GridCell.tsx +0 -18
- package/dist/starters/react/design-system/review/index.ts +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.tsx +0 -34
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.contract.ts +0 -6
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/token-preview/TokenPreview.tsx +0 -137
- package/dist/starters/react/design-system/showcase/mcp/index.html +0 -1
- package/dist/starters/react/design-system/tokens/Color.ads.fixture.ts +0 -124
- package/dist/starters/react/design-system/tokens/Color.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Layout.ads.fixture.ts +0 -39
- package/dist/starters/react/design-system/tokens/Layout.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Motion.ads.fixture.ts +0 -18
- package/dist/starters/react/design-system/tokens/Motion.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Shape.ads.fixture.ts +0 -30
- package/dist/starters/react/design-system/tokens/Shape.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Space.ads.fixture.ts +0 -37
- package/dist/starters/react/design-system/tokens/Space.ads.scenario.tsx +0 -4
- package/dist/starters/react/design-system/tokens/Type.ads.fixture.ts +0 -29
- package/dist/starters/react/design-system/tokens/Type.ads.scenario.tsx +0 -4
- package/dist/starters/react/package-lock.json +0 -4707
- package/dist/token-fixtures.mjs +0 -30
- package/docs/benchmarks/bun-previews.md +0 -91
- package/docs/benchmarks/preview-memory.md +0 -147
- package/docs/benchmarks/turbo-poc.md +0 -284
- package/docs/plans/execution-coordination.md +0 -57
- /package/dist/{browser-audit → render-audit}/first-render.mjs +0 -0
- /package/dist/{browser-audit → render-audit}/layout-shift.mjs +0 -0
package/dist/verification.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { eachChild, filterAsync, flatMapAsync, mapAsync, someAsync, walkAsync, walkValuesAsync } from "./analysis/queries.mjs";
|
|
1
2
|
import { finishExecutionGuard, trackExecutionArtifact, trackExecutionChild } from "./mcp/execution-context.mjs";
|
|
2
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
4
|
import { spawn } from "node:child_process";
|
|
4
5
|
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import ts from "
|
|
8
|
+
import ts from "./analysis/syntax.mjs";
|
|
8
9
|
import postcss from "postcss";
|
|
9
10
|
import valueParser from "postcss-value-parser";
|
|
10
11
|
import { loadConfig, sourceFiles, isInside } from "./config.mjs";
|
|
@@ -17,35 +18,81 @@ import { readPreviewManifest } from "./preview-resources.mjs";
|
|
|
17
18
|
import { acceptance, failure, failureCategories } from "./evidence.mjs";
|
|
18
19
|
import { investigationArtifacts, investigationUri, saveInvestigations } from "./investigations.mjs";
|
|
19
20
|
import { developmentExecutable, developmentRuntime } from "./development-runtime.mjs";
|
|
21
|
+
import { sourceAst, sourceText, memoFact } from "./analysis/helpers.mjs";
|
|
22
|
+
import { affectedInGraph } from "./analysis/impact.mjs";
|
|
23
|
+
import { currentAnalysis } from "./analysis/context.mjs";
|
|
24
|
+
import { analyze } from "./analysis/service.mjs";
|
|
20
25
|
|
|
21
26
|
export const BEHAVIOR_URI = "ads://project/behaviors";
|
|
22
|
-
const hash = bytes => createHash("sha256").update(bytes).digest("hex");
|
|
23
|
-
const slash = file => file.replaceAll("\\", "/");
|
|
24
|
-
const resultFile = root => path.join(root, ".ds/behavior-results.json");
|
|
27
|
+
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
28
|
+
const slash = (file) => file.replaceAll("\\", "/");
|
|
29
|
+
const resultFile = (root) => path.join(root, ".ds/behavior-results.json");
|
|
25
30
|
|
|
26
31
|
/** Follow real project imports; package/configuration changes also invalidate evidence. */
|
|
27
|
-
function inputContext(options) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
async function inputContext(options) {
|
|
33
|
+
return memoFact(options, "verification-input-context", async () => createInputContext(options));
|
|
34
|
+
}
|
|
35
|
+
async function createInputContext(options) {
|
|
36
|
+
const sources = new Map(),
|
|
37
|
+
digests = new Map(),
|
|
38
|
+
packages = new Map(),
|
|
39
|
+
resolve = await importResolver(options),
|
|
40
|
+
resolutions = new Map();
|
|
41
|
+
return {
|
|
42
|
+
inventory: await inspectUnits(options),
|
|
43
|
+
scenarios: (await inspectScenarios(options)).scenarios,
|
|
44
|
+
seeds: [...(await configurationFiles(options))]
|
|
45
|
+
.map((file) => path.join(options.root, file))
|
|
46
|
+
.concat(sourceFiles(path.join(options.dsRoot, options.config.tokenDir)), path.join(options.dsRoot, options.config.stylesEntry)),
|
|
47
|
+
digest(file) {
|
|
48
|
+
if (!digests.has(file)) digests.set(file, hash(readFileSync(file)));
|
|
49
|
+
return digests.get(file);
|
|
50
|
+
},
|
|
51
|
+
async ast(file) {
|
|
52
|
+
if (!sources.has(file)) sources.set(file, sourceAst(file));
|
|
53
|
+
return sources.get(file);
|
|
54
|
+
},
|
|
55
|
+
async resolve(specifier, file) {
|
|
56
|
+
const key = `${file}\0${specifier}`;
|
|
57
|
+
if (!resolutions.has(key)) resolutions.set(key, resolve(specifier, file));
|
|
58
|
+
return resolutions.get(key);
|
|
59
|
+
},
|
|
60
|
+
async hasSideEffects(file, record) {
|
|
35
61
|
let directory = path.dirname(file);
|
|
36
62
|
while (isInside(options.root, directory)) {
|
|
37
63
|
const manifest = path.join(directory, "package.json");
|
|
38
64
|
if (existsSync(manifest)) {
|
|
39
|
-
record(manifest);
|
|
40
|
-
if (!packages.has(manifest)) {
|
|
41
|
-
|
|
65
|
+
await record(manifest);
|
|
66
|
+
if (!packages.has(manifest)) {
|
|
67
|
+
try {
|
|
68
|
+
packages.set(manifest, JSON.parse(sourceText(manifest)).sideEffects);
|
|
69
|
+
} catch {
|
|
70
|
+
packages.set(manifest, true);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const policy = packages.get(manifest),
|
|
74
|
+
relative = slash(path.relative(directory, file));
|
|
42
75
|
if (policy === false) return false;
|
|
43
76
|
// Only the simple package sideEffects glob subset is narrowed. Unknown
|
|
44
77
|
// syntax and undeclared policies preserve the entire dependency graph.
|
|
45
|
-
if (!Array.isArray(policy) || policy.some(pattern => typeof pattern !== "string" || !/^[\w./*?-]+$/.test(pattern))) return true;
|
|
46
|
-
return policy.some(pattern => {
|
|
47
|
-
pattern = pattern.replace(/^\.\//, "");
|
|
48
|
-
|
|
78
|
+
if (!Array.isArray(policy) || policy.some((pattern) => typeof pattern !== "string" || !/^[\w./*?-]+$/.test(pattern))) return true;
|
|
79
|
+
return policy.some((pattern) => {
|
|
80
|
+
pattern = pattern.replace(/^\.\//, "");
|
|
81
|
+
if (!pattern.includes("/")) pattern = `**/${pattern}`;
|
|
82
|
+
const expression = pattern
|
|
83
|
+
.match(/\*\*\/|\*\*|\*|\?|[^*?]+/g)
|
|
84
|
+
?.map((part) =>
|
|
85
|
+
part === "**/"
|
|
86
|
+
? "(?:.*/)?"
|
|
87
|
+
: part === "**"
|
|
88
|
+
? ".*"
|
|
89
|
+
: part === "*"
|
|
90
|
+
? "[^/]*"
|
|
91
|
+
: part === "?"
|
|
92
|
+
? "[^/]"
|
|
93
|
+
: part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
94
|
+
)
|
|
95
|
+
.join("");
|
|
49
96
|
return new RegExp(`^${expression}$`).test(relative);
|
|
50
97
|
});
|
|
51
98
|
}
|
|
@@ -57,85 +104,160 @@ function inputContext(options) {
|
|
|
57
104
|
}
|
|
58
105
|
|
|
59
106
|
/** Project files reachable from the given entry files through real imports, CSS imports and local assets. */
|
|
60
|
-
function inputClosure(options, context, entries) {
|
|
61
|
-
const files = new Set(),
|
|
107
|
+
async function inputClosure(options, context, entries) {
|
|
108
|
+
const files = new Set(),
|
|
109
|
+
demands = new Map(),
|
|
110
|
+
effectsVisited = new Set();
|
|
62
111
|
const resolve = context.resolve;
|
|
63
|
-
function effects(file) {
|
|
112
|
+
async function effects(file) {
|
|
64
113
|
if (effectsVisited.has(file) || !isInside(options.root, file) || file.includes(`${path.sep}node_modules${path.sep}`) || !existsSync(file)) return;
|
|
65
114
|
effectsVisited.add(file);
|
|
66
|
-
if (context.hasSideEffects(file, visit)) {
|
|
115
|
+
if (await context.hasSideEffects(file, visit)) {
|
|
116
|
+
await visit(file);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
67
119
|
if (!/\.[cm]?[jt]sx?$/.test(file) || !lstatSync(file).isFile()) return;
|
|
68
120
|
if (lstatSync(file).isSymbolicLink() || realpathSync(file) !== file) throw new Error(`Behavior inputs cannot resolve through symlinks: ${file}`);
|
|
69
|
-
for (const statement of context.ast(file).statements)
|
|
121
|
+
for (const statement of (await context.ast(file)).statements)
|
|
122
|
+
if (
|
|
123
|
+
(ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) &&
|
|
124
|
+
statement.moduleSpecifier &&
|
|
125
|
+
ts.isStringLiteralLike(statement.moduleSpecifier)
|
|
126
|
+
)
|
|
127
|
+
for (const target of await resolve(statement.moduleSpecifier.text, file)) await effects(target);
|
|
70
128
|
}
|
|
71
|
-
function visit(file, names = null) {
|
|
129
|
+
async function visit(file, names = null) {
|
|
72
130
|
file = path.resolve(file);
|
|
73
131
|
if (!isInside(options.root, file) || file.includes(`${path.sep}node_modules${path.sep}`) || !existsSync(file)) return;
|
|
74
132
|
const prior = demands.get(file);
|
|
75
|
-
if (demands.has(file) && (prior === null || names && names.every(name => prior.has(name)))) return;
|
|
133
|
+
if (demands.has(file) && (prior === null || (names && names.every((name) => prior.has(name))))) return;
|
|
76
134
|
demands.set(file, names === null ? null : new Set([...(prior ?? []), ...names]));
|
|
77
135
|
if (lstatSync(file).isSymbolicLink() || realpathSync(file) !== file) throw new Error(`Behavior inputs cannot resolve through symlinks: ${file}`);
|
|
78
136
|
if (!lstatSync(file).isFile()) return;
|
|
79
137
|
files.add(file);
|
|
80
|
-
const localAsset = specifier => {
|
|
138
|
+
const localAsset = async (specifier) => {
|
|
81
139
|
if (!specifier || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(specifier)) return;
|
|
82
|
-
visit(path.resolve(path.dirname(file), specifier.replace(/[?#].*$/, "")));
|
|
140
|
+
await visit(path.resolve(path.dirname(file), specifier.replace(/[?#].*$/, "")));
|
|
83
141
|
};
|
|
84
142
|
if (file.endsWith(".css")) {
|
|
85
|
-
const css = postcss.parse(
|
|
86
|
-
css
|
|
87
|
-
|
|
143
|
+
const css = postcss.parse(sourceText(file), { from: file });
|
|
144
|
+
await walkAsync(css, "walkAtRules", "import", async (rule) => {
|
|
145
|
+
const first = valueParser(rule.params).nodes.find((node) => node.type !== "space" && node.type !== "comment");
|
|
146
|
+
if (first?.type === "string") await localAsset(first.value);
|
|
147
|
+
});
|
|
148
|
+
await walkAsync(css, "walk", async (node) => {
|
|
149
|
+
if (node.type === "decl" || node.type === "atrule")
|
|
150
|
+
await walkValuesAsync(valueParser(node.type === "decl" ? node.value : node.params), async (value) => {
|
|
151
|
+
if (value.type === "function" && value.value.toLowerCase() === "url")
|
|
152
|
+
await localAsset(
|
|
153
|
+
value.nodes
|
|
154
|
+
.filter((part) => part.type !== "space")
|
|
155
|
+
.map((part) => part.value)
|
|
156
|
+
.join(""),
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
88
160
|
}
|
|
89
161
|
if (!/\.[cm]?[jt]sx?$/.test(file)) return;
|
|
90
|
-
const ast = context.ast(file);
|
|
91
|
-
const barrel =
|
|
162
|
+
const ast = await context.ast(file);
|
|
163
|
+
const barrel =
|
|
164
|
+
names &&
|
|
165
|
+
ast.statements.every(
|
|
166
|
+
(statement) =>
|
|
167
|
+
ts.isEmptyStatement(statement) ||
|
|
168
|
+
(ts.isImportDeclaration(statement) && !statement.importClause) ||
|
|
169
|
+
(ts.isExportDeclaration(statement) &&
|
|
170
|
+
(!statement.exportClause || ts.isNamedExports(statement.exportClause)) &&
|
|
171
|
+
(!statement.exportClause || !statement.exportClause.elements.length || statement.moduleSpecifier)),
|
|
172
|
+
);
|
|
92
173
|
if (barrel) {
|
|
93
174
|
for (const statement of ast.statements) {
|
|
94
175
|
if (!statement.moduleSpecifier || !ts.isStringLiteralLike(statement.moduleSpecifier)) continue;
|
|
95
|
-
for (const target of resolve(statement.moduleSpecifier.text, file)) {
|
|
96
|
-
if (ts.isImportDeclaration(statement) || !statement.exportClause) visit(target);
|
|
176
|
+
for (const target of await resolve(statement.moduleSpecifier.text, file)) {
|
|
177
|
+
if (ts.isImportDeclaration(statement) || !statement.exportClause) await visit(target);
|
|
97
178
|
else {
|
|
98
|
-
const imported = statement.exportClause.elements
|
|
99
|
-
|
|
100
|
-
|
|
179
|
+
const imported = statement.exportClause.elements
|
|
180
|
+
.filter((entry) => names.includes(entry.name.text))
|
|
181
|
+
.map((entry) => (entry.propertyName ?? entry.name).text);
|
|
182
|
+
if (imported.length) await visit(target, imported);
|
|
183
|
+
await effects(target);
|
|
101
184
|
}
|
|
102
185
|
}
|
|
103
186
|
}
|
|
104
187
|
return;
|
|
105
188
|
}
|
|
106
|
-
function walk(node) {
|
|
189
|
+
async function walk(node) {
|
|
107
190
|
let specifier;
|
|
108
|
-
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier))
|
|
109
|
-
|
|
191
|
+
if ((ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier))
|
|
192
|
+
specifier = node.moduleSpecifier.text;
|
|
193
|
+
if (
|
|
194
|
+
ts.isCallExpression(node) &&
|
|
195
|
+
(node.expression.kind === ts.SyntaxKind.ImportKeyword || (ts.isIdentifier(node.expression) && node.expression.text === "require")) &&
|
|
196
|
+
node.arguments[0] &&
|
|
197
|
+
ts.isStringLiteralLike(node.arguments[0])
|
|
198
|
+
)
|
|
199
|
+
specifier = node.arguments[0].text;
|
|
110
200
|
if (specifier) {
|
|
111
201
|
const clause = ts.isImportDeclaration(node) && node.importClause;
|
|
112
|
-
const names =
|
|
113
|
-
|
|
202
|
+
const names =
|
|
203
|
+
clause && !clause.namedBindings
|
|
204
|
+
? clause.name
|
|
205
|
+
? ["default"]
|
|
206
|
+
: null
|
|
207
|
+
: clause?.namedBindings && ts.isNamedImports(clause.namedBindings)
|
|
208
|
+
? [...(clause.name ? ["default"] : []), ...clause.namedBindings.elements.map((entry) => (entry.propertyName ?? entry.name).text)]
|
|
209
|
+
: null;
|
|
210
|
+
for (const target of await resolve(specifier, file)) await visit(target, names);
|
|
114
211
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
212
|
+
if (
|
|
213
|
+
ts.isNewExpression(node) &&
|
|
214
|
+
ts.isIdentifier(node.expression) &&
|
|
215
|
+
node.expression.text === "URL" &&
|
|
216
|
+
node.arguments?.[0] &&
|
|
217
|
+
ts.isStringLiteralLike(node.arguments[0])
|
|
218
|
+
)
|
|
219
|
+
await localAsset(node.arguments[0].text);
|
|
220
|
+
if (
|
|
221
|
+
ts.isCallExpression(node) &&
|
|
222
|
+
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
|
223
|
+
(!node.arguments[0] || !ts.isStringLiteralLike(node.arguments[0]))
|
|
224
|
+
) {
|
|
117
225
|
// Computed module selection cannot provide a precise dependency closure.
|
|
118
226
|
// Conservatively invalidate against every owned ADS input instead.
|
|
119
|
-
for (const unit of context.inventory.units) for (const owned of unit.files) visit(path.join(options.root, owned));
|
|
227
|
+
for (const unit of context.inventory.units) for (const owned of unit.files) await visit(path.join(options.root, owned));
|
|
120
228
|
}
|
|
121
|
-
|
|
229
|
+
await eachChild(node, walk);
|
|
122
230
|
}
|
|
123
|
-
walk(ast);
|
|
231
|
+
await walk(ast);
|
|
124
232
|
}
|
|
125
|
-
for (const file of entries) visit(file);
|
|
233
|
+
for (const file of entries) await visit(file);
|
|
126
234
|
return files;
|
|
127
235
|
}
|
|
128
236
|
|
|
129
|
-
export function behaviorInputs(options, contract, check, context
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
...context.
|
|
237
|
+
export async function behaviorInputs(options, contract, check, context) {
|
|
238
|
+
if (context === undefined) context = await inputContext(options);
|
|
239
|
+
const scenario = check.scenario && context.scenarios.find((item) => item.id === check.scenario);
|
|
240
|
+
const files = await inputClosure(options, context, [
|
|
241
|
+
...(context.inventory.units.find((unit) => unit.id === contract.unit)?.files ?? []).map((file) => path.join(options.root, file)),
|
|
242
|
+
...context.seeds,
|
|
243
|
+
...(scenario ? [path.join(options.root, scenario.file)] : []),
|
|
134
244
|
]);
|
|
135
|
-
const rows = [...files].sort().map(file => [slash(path.relative(options.root, file)), context.digest(file)]);
|
|
136
|
-
for (const file of ["package-lock.json", "bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "node_modules/.package-lock.json"])
|
|
137
|
-
|
|
138
|
-
|
|
245
|
+
const rows = [...files].sort().map((file) => [slash(path.relative(options.root, file)), context.digest(file)]);
|
|
246
|
+
for (const file of ["package-lock.json", "bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "node_modules/.package-lock.json"])
|
|
247
|
+
rows.push([file, existsSync(path.join(options.root, file)) ? context.digest(path.join(options.root, file)) : null]);
|
|
248
|
+
rows.push(
|
|
249
|
+
["profile", JSON.stringify(options.config.mcp.behaviorProfiles[check.profile])],
|
|
250
|
+
["runtime", JSON.stringify(currentAnalysis()?.runtime ?? developmentRuntime())],
|
|
251
|
+
);
|
|
252
|
+
for (const file of [
|
|
253
|
+
"./verification.mjs",
|
|
254
|
+
"./development-runtime.mjs",
|
|
255
|
+
"./verification/browser.mjs",
|
|
256
|
+
"./verification/playwright-reporter.cjs",
|
|
257
|
+
"./evidence.mjs",
|
|
258
|
+
"./investigations.mjs",
|
|
259
|
+
])
|
|
260
|
+
rows.push([`tool:${file}`, hash(readFileSync(new URL(file, import.meta.url)))]);
|
|
139
261
|
return { revision: hash(JSON.stringify(rows)), files: rows.map(([file]) => file) };
|
|
140
262
|
}
|
|
141
263
|
|
|
@@ -145,39 +267,109 @@ function saved(root) {
|
|
|
145
267
|
if (realpathSync(file) !== file || lstatSync(file).size > 2 * 1024 * 1024) return {};
|
|
146
268
|
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
147
269
|
return value.schemaVersion === 1 && value.results && typeof value.results === "object" && !Array.isArray(value.results) ? value.results : {};
|
|
148
|
-
} catch {
|
|
270
|
+
} catch {
|
|
271
|
+
return {};
|
|
272
|
+
}
|
|
149
273
|
}
|
|
150
274
|
const identity = (unit, check) => `${unit}#${check}`;
|
|
151
275
|
function verificationResult(diagnostics, results) {
|
|
152
|
-
const ok=diagnostics.length===0&&results.length>0&&results.every(result=>result.status==="passed"&&result.current);
|
|
153
|
-
return {
|
|
154
|
-
|
|
276
|
+
const ok = diagnostics.length === 0 && results.length > 0 && results.every((result) => result.status === "passed" && result.current);
|
|
277
|
+
return {
|
|
278
|
+
ok,
|
|
279
|
+
diagnostics: diagnostics.map((diagnostic) => ({ ...diagnostic, failure: diagnostic.failure ?? failure("runner", "verification", diagnostic.rule) })),
|
|
280
|
+
results,
|
|
281
|
+
acceptance: acceptance(
|
|
282
|
+
"selected-behavior-checks",
|
|
283
|
+
ok,
|
|
284
|
+
results.filter((result) => result.status === "passed" && result.current).map((result) => `${result.unit}#${result.check}`),
|
|
285
|
+
["unselected-checks", "unasserted-behavior", "visual-parity", "accessibility-audit"],
|
|
286
|
+
),
|
|
287
|
+
};
|
|
155
288
|
}
|
|
156
289
|
|
|
157
|
-
export function behaviorStatus(options) {
|
|
158
|
-
const inventory = inspectBehaviors(options),
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
290
|
+
export async function behaviorStatus(options) {
|
|
291
|
+
const inventory = await inspectBehaviors(options),
|
|
292
|
+
evidence = saved(options.root);
|
|
293
|
+
const context = inventory.contracts.length ? await inputContext(options) : null;
|
|
294
|
+
return {
|
|
295
|
+
...inventory,
|
|
296
|
+
contracts: await mapAsync(inventory.contracts, async (contract) => {
|
|
297
|
+
const checks = Object.fromEntries(
|
|
298
|
+
await mapAsync(Object.entries(contract.checks), async ([id, check]) => {
|
|
299
|
+
const previous = evidence[identity(contract.unit, id)];
|
|
300
|
+
const revision = (await behaviorInputs(options, contract, check, context)).revision;
|
|
301
|
+
const current = previous?.revision === revision && previous.profile === check.profile && previous.file === check.file && previous.case === check.case;
|
|
302
|
+
return [
|
|
303
|
+
id,
|
|
304
|
+
{ ...check, result: previous ? { ...previous, current, status: current ? previous.status : "stale" } : { status: "not_run", current: false } },
|
|
305
|
+
];
|
|
306
|
+
}),
|
|
307
|
+
);
|
|
308
|
+
return {
|
|
309
|
+
...contract,
|
|
310
|
+
checks,
|
|
311
|
+
guarantees: contract.guarantees.map((guarantee) => {
|
|
312
|
+
const results = guarantee.checks.map((id) => checks[id]?.result ?? { status: "unavailable", current: false });
|
|
313
|
+
const status = results.every((result) => result.current && result.status === "passed")
|
|
314
|
+
? "passed"
|
|
315
|
+
: (results.find((result) => result.status !== "passed")?.status ?? "not_run");
|
|
316
|
+
return { ...guarantee, result: { status, current: results.every((result) => result.current) } };
|
|
317
|
+
}),
|
|
318
|
+
};
|
|
319
|
+
}),
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/** Whether any check of these units renders a scenario in a browser, so it needs built previews. */
|
|
324
|
+
export async function needsBrowserPreviews(options, units) {
|
|
325
|
+
const profiles = options.config.mcp.behaviorProfiles;
|
|
326
|
+
return (await inspectBehaviors(options)).contracts
|
|
327
|
+
.filter((contract) => units.includes(contract.unit))
|
|
328
|
+
.some((contract) => Object.values(contract.checks).some((check) => check.scenario && profiles[check.profile]?.mode === "browser"));
|
|
173
329
|
}
|
|
174
330
|
|
|
175
|
-
export function affectedBehaviorUnits(options, changedFiles) {
|
|
176
|
-
const changed = new Set(changedFiles.map(file => slash(path.relative(options.root, path.resolve(options.root, file)))));
|
|
177
|
-
const contracts = inspectBehaviors(options).contracts;
|
|
331
|
+
export async function affectedBehaviorUnits(options, changedFiles, before) {
|
|
332
|
+
const changed = new Set(changedFiles.map((file) => slash(path.relative(options.root, path.resolve(options.root, file)))));
|
|
333
|
+
const contracts = (await inspectBehaviors(options)).contracts;
|
|
178
334
|
if (!contracts.length) return [];
|
|
179
|
-
|
|
180
|
-
|
|
335
|
+
if (!before && [...changed].some((file) => !existsSync(path.resolve(options.root, file)))) return contracts.map((contract) => contract.unit);
|
|
336
|
+
const context = await inputContext(options);
|
|
337
|
+
const prior = affectedInGraph(before, "behaviors", changed) ?? new Set();
|
|
338
|
+
return (
|
|
339
|
+
await filterAsync(
|
|
340
|
+
contracts,
|
|
341
|
+
async (contract) =>
|
|
342
|
+
prior.has(contract.unit) ||
|
|
343
|
+
(await someAsync(Object.values(contract.checks), async (check) =>
|
|
344
|
+
(await behaviorInputs(options, contract, check, context)).files.some((file) => changed.has(file)),
|
|
345
|
+
)),
|
|
346
|
+
)
|
|
347
|
+
).map((contract) => contract.unit);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/** The exact closures used for selection, retained with a successful baseline. */
|
|
351
|
+
export async function selectionInputs(options) {
|
|
352
|
+
return memoFact(options, "selection-inputs", async () => {
|
|
353
|
+
const context = await inputContext(options),
|
|
354
|
+
inventory = context.inventory;
|
|
355
|
+
const relative = (files) => [...files].map((file) => slash(path.relative(options.root, file))).sort();
|
|
356
|
+
const owned = (unit) => (inventory.units.find((item) => item.id === unit)?.files ?? []).map((file) => path.join(options.root, file));
|
|
357
|
+
const scenarios = Object.fromEntries(
|
|
358
|
+
await mapAsync(context.scenarios, async (scenario) => [
|
|
359
|
+
scenario.id,
|
|
360
|
+
relative(await inputClosure(options, context, [path.join(options.root, scenario.file), ...owned(inventory.owner(inventory.relative(scenario.file)))])),
|
|
361
|
+
]),
|
|
362
|
+
);
|
|
363
|
+
const behaviors = Object.fromEntries(
|
|
364
|
+
await mapAsync((await inspectBehaviors(options)).contracts, async (contract) => [
|
|
365
|
+
contract.unit,
|
|
366
|
+
[
|
|
367
|
+
...new Set(await flatMapAsync(Object.values(contract.checks), async (check) => (await behaviorInputs(options, contract, check, context)).files)),
|
|
368
|
+
].sort(),
|
|
369
|
+
]),
|
|
370
|
+
);
|
|
371
|
+
return { schemaVersion: 1, scenarios, behaviors };
|
|
372
|
+
});
|
|
181
373
|
}
|
|
182
374
|
|
|
183
375
|
/**
|
|
@@ -186,43 +378,115 @@ export function affectedBehaviorUnits(options, changedFiles) {
|
|
|
186
378
|
* changed file. Shared configuration, foundation and token inputs are not traced here; callers
|
|
187
379
|
* treat changes to them as affecting every scenario.
|
|
188
380
|
*/
|
|
189
|
-
export function affectedScenarios(options, changedFiles, scenarios
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
381
|
+
export async function affectedScenarios(options, changedFiles, scenarios, before) {
|
|
382
|
+
if (scenarios === undefined) scenarios = (await inspectScenarios(options)).scenarios;
|
|
383
|
+
const changed = new Set(changedFiles.map((file) => slash(path.relative(options.root, path.resolve(options.root, file)))));
|
|
384
|
+
const context = await inputContext(options),
|
|
385
|
+
inventory = context.inventory;
|
|
386
|
+
const owners = new Set([...changed].map((file) => inventory.owner(inventory.relative(file))).filter(Boolean));
|
|
387
|
+
const prior = affectedInGraph(before, "scenarios", changed) ?? new Set();
|
|
388
|
+
return (
|
|
389
|
+
await filterAsync(
|
|
390
|
+
scenarios,
|
|
391
|
+
async (scenario) =>
|
|
392
|
+
prior.has(scenario.id) ||
|
|
393
|
+
owners.has(inventory.owner(inventory.relative(scenario.file))) ||
|
|
394
|
+
[...(await inputClosure(options, context, [path.join(options.root, scenario.file)]))].some((file) =>
|
|
395
|
+
changed.has(slash(path.relative(options.root, file))),
|
|
396
|
+
),
|
|
397
|
+
)
|
|
398
|
+
).map((scenario) => scenario.id);
|
|
195
399
|
}
|
|
196
400
|
|
|
197
401
|
export function executeDevelopmentCommand(profile, args, root, env, signal) {
|
|
198
402
|
return new Promise((resolve, reject) => {
|
|
199
403
|
const label = profile.label ?? "Behavior verification";
|
|
200
|
-
if (signal.aborted) {
|
|
201
|
-
|
|
202
|
-
|
|
404
|
+
if (signal.aborted) {
|
|
405
|
+
reject(new Error(`${label} cancelled.`));
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
const startedAt = activeNow(),
|
|
409
|
+
timeoutMs = profile.timeoutMs ?? 60000;
|
|
410
|
+
let output = "",
|
|
411
|
+
failure,
|
|
412
|
+
child,
|
|
413
|
+
guard,
|
|
414
|
+
done = false;
|
|
203
415
|
const kill = () => {
|
|
204
416
|
if (!child?.pid) return;
|
|
205
|
-
if (process.platform === "win32") {
|
|
206
|
-
|
|
417
|
+
if (process.platform === "win32") {
|
|
418
|
+
const stop = spawn("taskkill", ["/pid", String(child.pid), "/T", "/F"], { stdio: "ignore" });
|
|
419
|
+
stop.on("error", () => child.kill("SIGKILL"));
|
|
420
|
+
} else
|
|
421
|
+
try {
|
|
422
|
+
process.kill(-child.pid, "SIGKILL");
|
|
423
|
+
} catch (error) {
|
|
424
|
+
if (error.code !== "ESRCH") failure ??= error;
|
|
425
|
+
}
|
|
207
426
|
};
|
|
208
|
-
child = spawn(developmentExecutable(profile.command), args, {
|
|
209
|
-
|
|
427
|
+
child = spawn(developmentExecutable(profile.command), args, {
|
|
428
|
+
cwd: root,
|
|
429
|
+
detached: process.platform !== "win32",
|
|
430
|
+
shell: false,
|
|
431
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
432
|
+
windowsHide: true,
|
|
433
|
+
// A parent test runner's worker marker (bun test and Jest set JEST_WORKER_ID) would make Playwright refuse to run.
|
|
434
|
+
env: {
|
|
435
|
+
...process.env,
|
|
436
|
+
JEST_WORKER_ID: undefined,
|
|
437
|
+
...env,
|
|
438
|
+
PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter),
|
|
439
|
+
},
|
|
440
|
+
});
|
|
210
441
|
trackExecutionChild(child);
|
|
211
442
|
if (child.pid) {
|
|
212
|
-
guard = spawn(process.execPath, [fileURLToPath(new URL("./mcp/preview-owner-guard.mjs", import.meta.url)), String(child.pid), "--tree"], {
|
|
443
|
+
guard = spawn(process.execPath, [fileURLToPath(new URL("./mcp/preview-owner-guard.mjs", import.meta.url)), String(child.pid), "--tree"], {
|
|
444
|
+
detached: process.platform !== "win32",
|
|
445
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
446
|
+
windowsHide: true,
|
|
447
|
+
});
|
|
213
448
|
guard.stdin.on("error", () => {});
|
|
214
|
-
guard.once("error", error => {
|
|
215
|
-
|
|
449
|
+
guard.once("error", (error) => {
|
|
450
|
+
failure = error;
|
|
451
|
+
kill();
|
|
452
|
+
});
|
|
453
|
+
guard.once("exit", () => {
|
|
454
|
+
if (!done) {
|
|
455
|
+
failure ??= new Error("Verification ownership guard exited unexpectedly.");
|
|
456
|
+
kill();
|
|
457
|
+
}
|
|
458
|
+
});
|
|
216
459
|
}
|
|
217
|
-
const abort = () => {
|
|
460
|
+
const abort = () => {
|
|
461
|
+
failure = Object.assign(new Error(`${label} cancelled.`), { reason: "cancelled" });
|
|
462
|
+
kill();
|
|
463
|
+
};
|
|
218
464
|
signal.addEventListener("abort", abort, { once: true });
|
|
219
|
-
const timeout = setActiveTimeout(() => {
|
|
220
|
-
|
|
221
|
-
|
|
465
|
+
const timeout = setActiveTimeout(() => {
|
|
466
|
+
failure = Object.assign(new Error(`${label} timed out after ${timeoutMs} ms for the complete profile run, not each check.`), {
|
|
467
|
+
reason: "timeout",
|
|
468
|
+
timeoutMs,
|
|
469
|
+
});
|
|
470
|
+
kill();
|
|
471
|
+
}, timeoutMs);
|
|
472
|
+
for (const stream of [child.stdout, child.stderr])
|
|
473
|
+
stream.on("data", (chunk) => {
|
|
474
|
+
output = (output + chunk.toString()).slice(-12000);
|
|
475
|
+
});
|
|
476
|
+
child.once("error", (error) => {
|
|
477
|
+
failure = error;
|
|
478
|
+
});
|
|
222
479
|
child.once("exit", kill);
|
|
223
|
-
child.once("close", async code => {
|
|
224
|
-
done = true;
|
|
225
|
-
|
|
480
|
+
child.once("close", async (code) => {
|
|
481
|
+
done = true;
|
|
482
|
+
kill();
|
|
483
|
+
timeout.clear();
|
|
484
|
+
signal.removeEventListener("abort", abort);
|
|
485
|
+
try {
|
|
486
|
+
await finishExecutionGuard(guard);
|
|
487
|
+
} catch (error) {
|
|
488
|
+
failure ??= error;
|
|
489
|
+
}
|
|
226
490
|
const elapsedMs = Math.round(activeNow() - startedAt);
|
|
227
491
|
if (failure) reject(Object.assign(failure, { output, elapsedMs }));
|
|
228
492
|
else resolve({ code, output, elapsedMs });
|
|
@@ -231,157 +495,417 @@ export function executeDevelopmentCommand(profile, args, root, env, signal) {
|
|
|
231
495
|
}
|
|
232
496
|
|
|
233
497
|
function readReport(file, runId) {
|
|
234
|
-
if (!existsSync(file) || realpathSync(file) !== file || !lstatSync(file).isFile() || lstatSync(file).size > 1024 * 1024)
|
|
498
|
+
if (!existsSync(file) || realpathSync(file) !== file || !lstatSync(file).isFile() || lstatSync(file).size > 1024 * 1024)
|
|
499
|
+
throw new Error("Runner produced no valid bounded verification report. A successful exit alone is not passing evidence.");
|
|
235
500
|
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
236
|
-
if (
|
|
501
|
+
if (
|
|
502
|
+
value.schemaVersion !== 1 ||
|
|
503
|
+
value.runId !== runId ||
|
|
504
|
+
!Array.isArray(value.cases) ||
|
|
505
|
+
value.cases.length > 500 ||
|
|
506
|
+
(value.active !== undefined && (!Array.isArray(value.active) || value.active.length > 100))
|
|
507
|
+
)
|
|
508
|
+
throw new Error("Runner report has the wrong run ID/schema or too many cases.");
|
|
237
509
|
return value;
|
|
238
510
|
}
|
|
239
511
|
|
|
240
512
|
function runProgress(group, report, startedAt, profile, timeoutMs) {
|
|
241
|
-
const selected = group.map(check => ({
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
513
|
+
const selected = group.map((check) => ({
|
|
514
|
+
unit: check.unit,
|
|
515
|
+
check: check.id,
|
|
516
|
+
id: check.case,
|
|
517
|
+
file: slash(path.posix.join(path.posix.dirname(slash(check.contract.file)), check.file)),
|
|
518
|
+
}));
|
|
519
|
+
const cases = selected.map((check) => {
|
|
520
|
+
const matches = report?.cases.filter((item) => item?.id === check.id && item.file === check.file) ?? [];
|
|
521
|
+
const running = report?.active?.find((item) => item?.id === check.id && item.file === check.file);
|
|
522
|
+
return {
|
|
523
|
+
unit: check.unit,
|
|
524
|
+
check: check.check,
|
|
525
|
+
state: running ? "running" : matches.length ? "completed" : Array.isArray(report?.active) ? "not_started" : "not_reported",
|
|
526
|
+
...(running ? { elapsedMs: Math.max(0, Date.now() - Date.parse(running.startedAt)) || 0, workerIndex: running.workerIndex } : {}),
|
|
527
|
+
...(matches.length
|
|
528
|
+
? {
|
|
529
|
+
reportedStatus: matches.at(-1).status,
|
|
530
|
+
durationMs: matches.reduce((sum, item) => sum + (Number.isFinite(item.durationMs) ? Math.max(0, item.durationMs) : 0), 0),
|
|
531
|
+
}
|
|
532
|
+
: {}),
|
|
533
|
+
};
|
|
246
534
|
});
|
|
247
|
-
return {
|
|
535
|
+
return {
|
|
536
|
+
profile,
|
|
537
|
+
elapsedMs: Date.now() - startedAt,
|
|
538
|
+
timeoutMs,
|
|
539
|
+
total: cases.length,
|
|
540
|
+
completed: cases.filter((item) => item.state === "completed").length,
|
|
541
|
+
active: cases.filter((item) => item.state === "running"),
|
|
542
|
+
pending: cases.filter((item) => ["not_started", "not_reported"].includes(item.state)).length,
|
|
543
|
+
cases,
|
|
544
|
+
...(Number.isSafeInteger(report?.workers) ? { workers: report.workers } : {}),
|
|
545
|
+
};
|
|
248
546
|
}
|
|
249
547
|
|
|
250
548
|
/** Registered development commands are trusted project code, never model-supplied commands. */
|
|
549
|
+
export async function verificationPlan(options, { unit, units, checks } = {}) {
|
|
550
|
+
const inventory = await inspectBehaviors(options);
|
|
551
|
+
const fail = (diagnostics) => ({ inventory, selection: [], diagnostics });
|
|
552
|
+
if (inventory.diagnostics.length)
|
|
553
|
+
return fail(inventory.diagnostics.map((diagnostic) => ({ ...diagnostic, failure: failure("architecture", "behavior-contract", diagnostic.rule) })));
|
|
554
|
+
const selectedUnits = new Set(units ?? (unit ? [unit] : inventory.contracts.map((item) => item.unit)));
|
|
555
|
+
const contracts = inventory.contracts.filter((item) => selectedUnits.has(item.unit));
|
|
556
|
+
if (!contracts.length || [...selectedUnits].some((id) => !contracts.some((contract) => contract.unit === id)))
|
|
557
|
+
return fail([
|
|
558
|
+
{ rule: "behavior-selection", message: "No behavior contract matches the complete selection. Discover exact owner/check IDs with ads_behaviors." },
|
|
559
|
+
]);
|
|
560
|
+
const context = await inputContext(options);
|
|
561
|
+
const selection = await flatMapAsync(contracts, async (contract) =>
|
|
562
|
+
mapAsync(
|
|
563
|
+
Object.entries(contract.checks).filter(([id]) => !checks || checks.includes(id)),
|
|
564
|
+
async ([id, check]) => ({
|
|
565
|
+
unit: contract.unit,
|
|
566
|
+
id,
|
|
567
|
+
...check,
|
|
568
|
+
inputRevision: (await behaviorInputs(options, contract, check, context)).revision,
|
|
569
|
+
contract,
|
|
570
|
+
}),
|
|
571
|
+
),
|
|
572
|
+
);
|
|
573
|
+
if (!selection.length || checks?.some((id) => !selection.some((check) => check.id === id)))
|
|
574
|
+
return fail([{ rule: "behavior-selection", message: "Unknown check selection. Use check IDs returned by ads_behaviors." }]);
|
|
575
|
+
return { inventory, selection, diagnostics: [] };
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export async function behaviorRevisions(options, checks) {
|
|
579
|
+
const context = await inputContext(options);
|
|
580
|
+
return mapAsync(checks, async (check) => (await behaviorInputs(options, check.contract, check, context)).revision);
|
|
581
|
+
}
|
|
582
|
+
|
|
251
583
|
export function createVerificationController(root, { reportRoot = root, onProgress, previewWork, previewHost } = {}) {
|
|
252
584
|
root = path.resolve(root);
|
|
253
585
|
reportRoot = path.resolve(reportRoot);
|
|
254
|
-
|
|
586
|
+
// Without a caller's host, one preview host serves every run of this controller; a run that is
|
|
587
|
+
// cancelled or breaks replaces it.
|
|
588
|
+
let active, progress, owned;
|
|
589
|
+
const closeOwned = async () => {
|
|
590
|
+
const current = owned;
|
|
591
|
+
owned = undefined;
|
|
592
|
+
await current?.close();
|
|
593
|
+
};
|
|
255
594
|
return {
|
|
256
595
|
status: () => ({ running: !!active, ...(active && progress ? { progress: { ...progress, elapsedMs: Date.now() - progress.startedAt } } : {}) }),
|
|
257
|
-
async close() {
|
|
596
|
+
async close() {
|
|
597
|
+
active?.abort();
|
|
598
|
+
await active?.completion;
|
|
599
|
+
await closeOwned();
|
|
600
|
+
},
|
|
258
601
|
async run({ unit, units, checks, persist = true } = {}, signal, notifyProgress) {
|
|
259
|
-
if (active) return verificationResult([{ rule: "behavior-busy", message: "A behavior verification is already running." }],[]);
|
|
602
|
+
if (active) return verificationResult([{ rule: "behavior-busy", message: "A behavior verification is already running." }], []);
|
|
260
603
|
active = new AbortController();
|
|
261
604
|
const controller = active;
|
|
262
605
|
signal = signal ? AbortSignal.any([signal, active.signal]) : active.signal;
|
|
263
|
-
let finish;
|
|
264
|
-
|
|
265
|
-
|
|
606
|
+
let finish;
|
|
607
|
+
controller.completion = new Promise((resolve) => {
|
|
608
|
+
finish = resolve;
|
|
609
|
+
});
|
|
610
|
+
let host,
|
|
611
|
+
releasePreview,
|
|
612
|
+
broken = false;
|
|
613
|
+
const results = [],
|
|
614
|
+
diagnostics = [];
|
|
266
615
|
try {
|
|
267
616
|
if (previewWork) releasePreview = await previewWork.acquire(signal);
|
|
268
|
-
const options = loadConfig(root)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
const context = inputContext(options);
|
|
274
|
-
const selection = contracts.flatMap(contract => Object.entries(contract.checks).filter(([id]) => !checks || checks.includes(id)).map(([id, check]) => ({ unit: contract.unit, id, ...check, inputRevision: behaviorInputs(options, contract, check, context).revision, contract })));
|
|
275
|
-
if (!selection.length || checks?.some(id => !selection.some(check => check.id === id))) return verificationResult([{ rule: "behavior-selection", message: "Unknown check selection. Use check IDs returned by ads_behaviors." }],results);
|
|
276
|
-
for (const profileName of new Set(selection.map(check => check.profile))) {
|
|
617
|
+
const options = loadConfig(root);
|
|
618
|
+
const plan = await analyze(root, "verification-plan", [{ unit, units, checks }], signal);
|
|
619
|
+
if (plan.diagnostics.length) return verificationResult(plan.diagnostics, results);
|
|
620
|
+
const { inventory, selection } = plan;
|
|
621
|
+
for (const profileName of new Set(selection.map((check) => check.profile))) {
|
|
277
622
|
const profile = options.config.mcp.behaviorProfiles[profileName];
|
|
278
|
-
const group = selection.filter(check => check.profile === profileName);
|
|
623
|
+
const group = selection.filter((check) => check.profile === profileName);
|
|
279
624
|
const directory = path.join(reportRoot, ".ds/verification", randomUUID());
|
|
280
625
|
mkdirSync(directory, { recursive: true });
|
|
281
|
-
trackExecutionArtifact(reportRoot,directory);
|
|
626
|
+
trackExecutionArtifact(reportRoot, directory);
|
|
282
627
|
if (realpathSync(directory) !== directory) throw new Error("Verification output cannot resolve through a symlink.");
|
|
283
|
-
const runId = randomUUID(),
|
|
628
|
+
const runId = randomUUID(),
|
|
629
|
+
report = path.join(directory, "report.json"),
|
|
630
|
+
request = path.join(directory, "request.json");
|
|
284
631
|
const scenarios = {};
|
|
285
|
-
if (profile.mode === "browser" && group.some(check => check.scenario)) {
|
|
632
|
+
if (profile.mode === "browser" && group.some((check) => check.scenario)) {
|
|
286
633
|
const { startAdsMcp } = await import("./mcp/server.mjs");
|
|
287
|
-
host ??= previewHost ?? await startAdsMcp(root, { stdio: false, showcase: true });
|
|
634
|
+
host ??= previewHost ?? (owned ??= await startAdsMcp(root, { stdio: false, showcase: true }));
|
|
288
635
|
// Queue all selected roots before parallel browser workers open. A
|
|
289
636
|
// single graph avoids repeated compilation and startup handovers.
|
|
290
|
-
await host.warmScenarios([...new Set(group.map(check => check.scenario).filter(Boolean))], signal);
|
|
291
|
-
for (const check of group.filter(check => check.scenario)) {
|
|
637
|
+
await host.warmScenarios([...new Set(group.map((check) => check.scenario).filter(Boolean))], signal);
|
|
638
|
+
for (const check of group.filter((check) => check.scenario)) {
|
|
292
639
|
const url = new URL(host.url);
|
|
293
640
|
url.searchParams.set("scenario", check.scenario);
|
|
294
641
|
url.searchParams.set("waitFor", "verified");
|
|
295
642
|
scenarios[check.scenario] = url.href;
|
|
296
643
|
}
|
|
297
644
|
}
|
|
298
|
-
const requestContext = {
|
|
645
|
+
const requestContext = {
|
|
646
|
+
schemaVersion: 1,
|
|
647
|
+
runId,
|
|
648
|
+
projectRoot: root,
|
|
649
|
+
framework: options.config.framework,
|
|
650
|
+
profile: profileName,
|
|
651
|
+
mode: profile.mode ?? "unit",
|
|
652
|
+
checks: group.map(({ contract: _contract, ...check }) => check),
|
|
653
|
+
scenarios,
|
|
654
|
+
};
|
|
299
655
|
writeFileSync(request, JSON.stringify(requestContext));
|
|
300
656
|
const args = [...profile.args];
|
|
301
657
|
if (profile.runner === "playwright") {
|
|
302
|
-
const tags = [...new Set(group.map(check => check.case))].map(id => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
303
|
-
args.push(
|
|
658
|
+
const tags = [...new Set(group.map((check) => check.case))].map((id) => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
659
|
+
args.push(
|
|
660
|
+
...new Set(group.map((check) => slash(path.relative(root, path.resolve(root, path.dirname(check.contract.file), check.file))))),
|
|
661
|
+
`--grep=(?:^|\\s)@ads:(?:${tags.join("|")})(?=\\s|$)`,
|
|
662
|
+
`--reporter=${fileURLToPath(new URL("./verification/playwright-reporter.cjs", import.meta.url))}`,
|
|
663
|
+
`--output=${path.join(directory, "artifacts")}`,
|
|
664
|
+
);
|
|
304
665
|
}
|
|
305
666
|
let run, reportValue, runnerError;
|
|
306
667
|
const startedAt = Date.now();
|
|
307
|
-
const update = value => {
|
|
668
|
+
const update = (value) => {
|
|
308
669
|
progress = { ...runProgress(group, value, startedAt, profileName, profile.timeoutMs ?? 60000), startedAt };
|
|
309
|
-
onProgress?.(progress);
|
|
670
|
+
onProgress?.(progress);
|
|
671
|
+
notifyProgress?.(progress);
|
|
310
672
|
};
|
|
311
673
|
update();
|
|
312
|
-
let lastSnapshot = "",
|
|
674
|
+
let lastSnapshot = "",
|
|
675
|
+
lastUpdate = Date.now();
|
|
313
676
|
const monitor = setInterval(() => {
|
|
314
677
|
let value;
|
|
315
|
-
try {
|
|
678
|
+
try {
|
|
679
|
+
value = readReport(report, runId);
|
|
680
|
+
} catch {
|
|
681
|
+
/* An absent/invalid intermediate snapshot cannot provide evidence. */
|
|
682
|
+
}
|
|
316
683
|
const snapshot = JSON.stringify(value);
|
|
317
|
-
if (snapshot !== lastSnapshot || Date.now() - lastUpdate >= 5000) {
|
|
684
|
+
if (snapshot !== lastSnapshot || Date.now() - lastUpdate >= 5000) {
|
|
685
|
+
lastSnapshot = snapshot;
|
|
686
|
+
lastUpdate = Date.now();
|
|
687
|
+
update(value);
|
|
688
|
+
}
|
|
318
689
|
}, 250);
|
|
319
690
|
try {
|
|
320
|
-
run = await executeDevelopmentCommand(
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
691
|
+
run = await executeDevelopmentCommand(
|
|
692
|
+
profile,
|
|
693
|
+
args,
|
|
694
|
+
root,
|
|
695
|
+
{ ADS_VERIFY_REQUEST: request, ADS_VERIFY_REPORT: report, ADS_VERIFY_MODE: requestContext.mode },
|
|
696
|
+
signal,
|
|
697
|
+
);
|
|
698
|
+
} catch (error) {
|
|
699
|
+
runnerError = error;
|
|
700
|
+
} finally {
|
|
701
|
+
clearInterval(monitor);
|
|
702
|
+
}
|
|
703
|
+
try {
|
|
704
|
+
reportValue = readReport(report, runId);
|
|
705
|
+
} catch (error) {
|
|
706
|
+
runnerError ??= error;
|
|
707
|
+
}
|
|
325
708
|
update(reportValue);
|
|
326
709
|
if (runnerError) {
|
|
327
|
-
const detail = `${progress.completed}/${progress.total} checks completed; ${progress.pending} without a completed/active result. Active: ${progress.active.map(item => `${item.unit}#${item.check} (${Math.round(item.elapsedMs)} ms)`).join(", ") || "none reported"}.`;
|
|
328
|
-
diagnostics.push({
|
|
710
|
+
const detail = `${progress.completed}/${progress.total} checks completed; ${progress.pending} without a completed/active result. Active: ${progress.active.map((item) => `${item.unit}#${item.check} (${Math.round(item.elapsedMs)} ms)`).join(", ") || "none reported"}.`;
|
|
711
|
+
diagnostics.push({
|
|
712
|
+
rule: "behavior-runner",
|
|
713
|
+
message: `${runnerError.message} ${detail}`,
|
|
714
|
+
reason: runnerError.reason,
|
|
715
|
+
elapsedMs: runnerError.elapsedMs ?? Date.now() - startedAt,
|
|
716
|
+
progress,
|
|
717
|
+
output: runnerError.output?.slice(-4000),
|
|
718
|
+
profile: profileName,
|
|
719
|
+
});
|
|
329
720
|
}
|
|
330
|
-
const suiteErrors = Array.isArray(reportValue?.errors) ? reportValue.errors.slice(0, 5).map(error => String(error).slice(0, 1000)) : [];
|
|
721
|
+
const suiteErrors = Array.isArray(reportValue?.errors) ? reportValue.errors.slice(0, 5).map((error) => String(error).slice(0, 1000)) : [];
|
|
331
722
|
const incompleteReport = reportValue?.complete === false || progress.pending > 0 || progress.active.length > 0;
|
|
332
723
|
// Exit 1 is the normal test-failure exit. A complete report with actual
|
|
333
724
|
// assertion failures still contains independent, valid passing outcomes.
|
|
334
725
|
// Unexplained exits, suite errors and interrupted reports grant no pass.
|
|
335
|
-
const caseFailureExit =
|
|
336
|
-
|
|
726
|
+
const caseFailureExit =
|
|
727
|
+
run?.code === 1 && !runnerError && !suiteErrors.length && !incompleteReport && reportValue?.cases.some((item) => item?.status === "failed");
|
|
728
|
+
const runnerFailure =
|
|
729
|
+
run && (run.code !== 0 || suiteErrors.length || incompleteReport)
|
|
730
|
+
? `Registered runner ${profileName} ${run.code !== 0 ? `exited with code ${run.code ?? "unknown"}` : incompleteReport ? "left an incomplete report" : "reported a suite error"}. ${
|
|
731
|
+
suiteErrors.join("; ") ||
|
|
732
|
+
reportValue?.cases
|
|
733
|
+
.filter((item) => item?.status === "failed")
|
|
734
|
+
.slice(0, 3)
|
|
735
|
+
.map((item) => `${item.id}: ${item.message || "failed without a case diagnostic"}`)
|
|
736
|
+
.join("; ") ||
|
|
737
|
+
"Inspect the runner output and verification report."
|
|
738
|
+
}`.slice(0, 3000)
|
|
739
|
+
: undefined;
|
|
337
740
|
if (runnerFailure) {
|
|
338
|
-
const caseFailures=
|
|
339
|
-
|
|
340
|
-
|
|
741
|
+
const caseFailures =
|
|
742
|
+
reportValue?.cases.filter((item) => item.status === "failed" && failureCategories.has(item.failure?.category)).map((item) => item.failure) ?? [];
|
|
743
|
+
diagnostics.push({
|
|
744
|
+
rule: "behavior-runner",
|
|
745
|
+
message: runnerFailure,
|
|
746
|
+
output: run.output?.slice(-4000),
|
|
747
|
+
profile: profileName,
|
|
748
|
+
failure:
|
|
749
|
+
caseFailureExit && caseFailures.length
|
|
750
|
+
? { ...caseFailures[0], phase: "case-results", relatedCategories: [...new Set(caseFailures.map((item) => item.category))] }
|
|
751
|
+
: failure("runner", "profile-execution", "ADS_RUNNER_EXIT", { certainty: caseFailureExit ? "unclassified" : "observed-boundary" }),
|
|
752
|
+
});
|
|
341
753
|
}
|
|
342
|
-
const
|
|
343
|
-
for (const check of group) {
|
|
754
|
+
const afterRevisions = await analyze(root, "behavior-revisions", [group]);
|
|
755
|
+
for (const [checkIndex, check] of group.entries()) {
|
|
344
756
|
const file = slash(path.relative(root, path.resolve(root, path.dirname(check.contract.file), check.file)));
|
|
345
|
-
const matches = reportValue?.cases.filter(item => item && item.id === check.case && item.file === file) ?? [];
|
|
346
|
-
const reportedStatus =
|
|
347
|
-
|
|
348
|
-
|
|
757
|
+
const matches = reportValue?.cases.filter((item) => item && item.id === check.case && item.file === file) ?? [];
|
|
758
|
+
const reportedStatus =
|
|
759
|
+
matches.length && matches.every((item) => item.status === "passed")
|
|
760
|
+
? "passed"
|
|
761
|
+
: matches.length && matches.every((item) => item.status === "skipped")
|
|
762
|
+
? "skipped"
|
|
763
|
+
: "failed";
|
|
764
|
+
const blockedRun = !!runnerError || (!!runnerFailure && !caseFailureExit);
|
|
765
|
+
let status = matches.some((item) => item.status === "failed")
|
|
766
|
+
? "failed"
|
|
767
|
+
: !matches.length || blockedRun
|
|
768
|
+
? reportValue
|
|
769
|
+
? "incomplete"
|
|
770
|
+
: "failed"
|
|
771
|
+
: reportedStatus;
|
|
349
772
|
if (runnerError?.code === "ENOENT") status = "unavailable";
|
|
350
|
-
const current =
|
|
773
|
+
const current = afterRevisions[checkIndex] === check.inputRevision;
|
|
351
774
|
if (!current) status = "stale";
|
|
352
775
|
if (signal.aborted) status = "cancelled";
|
|
353
|
-
const caseDetail=matches.find(item=>item.status!=="passed")??matches.at(-1);
|
|
354
|
-
const reportedFailure=caseDetail?.failure;
|
|
355
|
-
const checkFailure=
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
776
|
+
const caseDetail = matches.find((item) => item.status !== "passed") ?? matches.at(-1);
|
|
777
|
+
const reportedFailure = caseDetail?.failure;
|
|
778
|
+
const checkFailure =
|
|
779
|
+
status === "passed"
|
|
780
|
+
? undefined
|
|
781
|
+
: status === "stale" || status === "cancelled"
|
|
782
|
+
? failure("runner", "verification", `ADS_${status.toUpperCase()}`)
|
|
783
|
+
: caseDetail?.status === "failed" && failureCategories.has(reportedFailure?.category)
|
|
784
|
+
? reportedFailure
|
|
785
|
+
: blockedRun
|
|
786
|
+
? failure("runner", "profile-execution", runnerError?.reason ?? "ADS_RUNNER_INCOMPLETE", { certainty: "observed-boundary" })
|
|
787
|
+
: failure("runner", "test-execution", "ADS_CASE_UNCLASSIFIED", { certainty: "unclassified" });
|
|
788
|
+
const accepted = acceptance(
|
|
789
|
+
"registered-case",
|
|
790
|
+
status === "passed" && current,
|
|
791
|
+
status === "passed" && current ? ["registered-case-completed"] : [],
|
|
792
|
+
["unasserted-behavior", "visual-parity", "accessibility-audit"],
|
|
793
|
+
);
|
|
794
|
+
const investigation = {
|
|
795
|
+
unit: check.unit,
|
|
796
|
+
check: check.id,
|
|
797
|
+
status,
|
|
798
|
+
runId,
|
|
799
|
+
resourceUri: investigationUri({ unit: check.unit, check: check.id }),
|
|
800
|
+
target: root === reportRoot ? "project" : "candidate",
|
|
801
|
+
framework: options.config.framework,
|
|
802
|
+
profile: profileName,
|
|
803
|
+
mode: profile.mode ?? "unit",
|
|
804
|
+
scenario: check.scenario ?? null,
|
|
805
|
+
inputRevision: check.inputRevision,
|
|
806
|
+
inputsCurrentAtCompletion: current,
|
|
807
|
+
source: caseDetail?.source ?? { file },
|
|
808
|
+
failingStep: caseDetail?.failingStep ?? null,
|
|
809
|
+
viewport: caseDetail?.viewport ?? null,
|
|
810
|
+
viewportSource: caseDetail?.viewportSource ?? null,
|
|
811
|
+
observedPreviewRevision:
|
|
812
|
+
matches.flatMap((item) => item.diagnostics ?? []).findLast((item) => item.kind === "preview-startup")?.previewRevision ?? null,
|
|
813
|
+
requests: matches
|
|
814
|
+
.flatMap((item) => item.diagnostics ?? [])
|
|
815
|
+
.flatMap((item) => item.requests ?? [])
|
|
816
|
+
.slice(0, 8),
|
|
817
|
+
browserErrors: matches
|
|
818
|
+
.flatMap((item) => item.diagnostics ?? [])
|
|
819
|
+
.flatMap((item) => item.errors ?? [])
|
|
820
|
+
.slice(0, 3),
|
|
821
|
+
artifacts: investigationArtifacts(
|
|
822
|
+
reportRoot,
|
|
823
|
+
report,
|
|
824
|
+
matches.flatMap((item) => item.artifacts ?? []),
|
|
825
|
+
),
|
|
826
|
+
acceptance: accepted,
|
|
827
|
+
...(checkFailure ? { failure: checkFailure } : {}),
|
|
828
|
+
completedAt: new Date().toISOString(),
|
|
829
|
+
};
|
|
830
|
+
results.push({
|
|
831
|
+
unit: check.unit,
|
|
832
|
+
check: check.id,
|
|
833
|
+
file: check.file,
|
|
834
|
+
case: check.case,
|
|
835
|
+
profile: profileName,
|
|
836
|
+
status,
|
|
837
|
+
current,
|
|
838
|
+
revision: check.inputRevision,
|
|
839
|
+
runId,
|
|
840
|
+
completedAt: investigation.completedAt,
|
|
841
|
+
...(checkFailure ? { failure: checkFailure } : {}),
|
|
842
|
+
acceptance: accepted,
|
|
843
|
+
investigation,
|
|
844
|
+
previewRevision: profile.mode === "browser" ? (host?.previewRevision() ?? readPreviewManifest(options)?.revision ?? null) : null,
|
|
845
|
+
...(matches.length
|
|
846
|
+
? { reportedStatus, durationMs: matches.reduce((sum, item) => sum + (Number.isFinite(item.durationMs) ? Math.max(0, item.durationMs) : 0), 0) }
|
|
847
|
+
: {}),
|
|
848
|
+
...(matches.some((item) => item.diagnostics?.length)
|
|
849
|
+
? { startupDiagnostics: matches.flatMap((item) => (Array.isArray(item.diagnostics) ? item.diagnostics.slice(0, 5) : [])).slice(0, 10) }
|
|
850
|
+
: {}),
|
|
367
851
|
...(runnerFailure ? { runnerExitCode: run.code } : {}),
|
|
368
|
-
execution: progress.cases.find(item => item.unit === check.unit && item.check === check.id)?.state,
|
|
369
|
-
message: [
|
|
852
|
+
execution: progress.cases.find((item) => item.unit === check.unit && item.check === check.id)?.state,
|
|
853
|
+
message: [
|
|
854
|
+
matches
|
|
855
|
+
.filter((item) => item.status !== "passed")
|
|
856
|
+
.map((item) => String(item.message || `Case reported ${item.status} without a diagnostic.`).slice(0, 2000))
|
|
857
|
+
.join("\n"),
|
|
858
|
+
runnerError
|
|
859
|
+
? `${runnerError.message} This check ${matches.length ? `reported ${reportedStatus}` : `was ${progress.cases.find((item) => item.unit === check.unit && item.check === check.id)?.state ?? "not reported"}`}; the complete run did not pass.`
|
|
860
|
+
: !matches.length
|
|
861
|
+
? "The selected case did not execute/report. Missing and skipped cases do not pass."
|
|
862
|
+
: runnerFailure
|
|
863
|
+
? `This case reported ${reportedStatus}, but the complete run did not pass. ${runnerFailure}`
|
|
864
|
+
: "",
|
|
865
|
+
]
|
|
866
|
+
.filter(Boolean)
|
|
867
|
+
.join("\n"),
|
|
868
|
+
report: slash(path.relative(reportRoot, report)),
|
|
869
|
+
});
|
|
370
870
|
}
|
|
371
871
|
if (signal.aborted) break;
|
|
372
872
|
}
|
|
373
|
-
saveInvestigations(
|
|
873
|
+
saveInvestigations(
|
|
874
|
+
reportRoot,
|
|
875
|
+
results.map((result) => result.investigation),
|
|
876
|
+
inventory.contracts.flatMap((contract) => Object.keys(contract.checks).map((id) => identity(contract.unit, id))),
|
|
877
|
+
);
|
|
374
878
|
if (persist) {
|
|
375
879
|
const evidence = saved(root);
|
|
376
880
|
for (const result of results) evidence[identity(result.unit, result.check)] = result;
|
|
377
|
-
const file = resultFile(root),
|
|
881
|
+
const file = resultFile(root),
|
|
882
|
+
temporary = `${file}.${randomUUID()}.tmp`;
|
|
378
883
|
const content = JSON.stringify({ schemaVersion: 1, results: evidence });
|
|
379
|
-
if (Buffer.byteLength(content) > 2 * 1024 * 1024)
|
|
380
|
-
|
|
884
|
+
if (Buffer.byteLength(content) > 2 * 1024 * 1024)
|
|
885
|
+
throw new Error("Verification evidence exceeds 2 MiB. Remove obsolete generated evidence and retry.");
|
|
886
|
+
try {
|
|
887
|
+
writeFileSync(temporary, content);
|
|
888
|
+
renameSync(temporary, file);
|
|
889
|
+
} finally {
|
|
890
|
+
rmSync(temporary, { force: true });
|
|
891
|
+
}
|
|
381
892
|
}
|
|
382
|
-
return verificationResult(diagnostics,results);
|
|
383
|
-
} catch (error) {
|
|
384
|
-
|
|
893
|
+
return verificationResult(diagnostics, results);
|
|
894
|
+
} catch (error) {
|
|
895
|
+
broken = true;
|
|
896
|
+
return verificationResult([{ rule: "behavior-verification", message: error.message }], results);
|
|
897
|
+
} finally {
|
|
898
|
+
try {
|
|
899
|
+
if (host && host === owned && (broken || signal.aborted)) await closeOwned();
|
|
900
|
+
} finally {
|
|
901
|
+
releasePreview?.();
|
|
902
|
+
if (active === controller) {
|
|
903
|
+
active = undefined;
|
|
904
|
+
progress = undefined;
|
|
905
|
+
}
|
|
906
|
+
finish();
|
|
907
|
+
}
|
|
908
|
+
}
|
|
385
909
|
},
|
|
386
910
|
};
|
|
387
911
|
}
|