@reqvire-org/ads 0.4.7 → 0.5.1
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 +268 -420
- package/dist/accessibility-declarations.mjs +43 -0
- package/dist/active-clock.d.mts +30 -0
- package/dist/active-clock.mjs +26 -17
- package/dist/ads-errors.mjs +3684 -0
- package/dist/ads-view-choices.mjs +17 -0
- package/dist/ads-views.mjs +12 -0
- package/dist/analysis/captured-content.mjs +16 -0
- package/dist/analysis/compiler-options.mjs +3 -7
- package/dist/analysis/context.mjs +14 -20
- package/dist/analysis/controller-gates.mjs +119 -0
- package/dist/analysis/design-usage.mjs +142 -0
- package/dist/analysis/file-tree.mjs +44 -29
- package/dist/analysis/framework-imports.mjs +62 -0
- package/dist/analysis/glyph-macros.mjs +103 -0
- package/dist/analysis/helpers.mjs +119 -91
- package/dist/analysis/impact.mjs +25 -12
- package/dist/analysis/inputs.mjs +19 -13
- package/dist/analysis/mock-check.mjs +99 -0
- package/dist/analysis/module-graph.mjs +156 -0
- package/dist/analysis/module-resolvers.mjs +30 -28
- package/dist/analysis/native-adapter.mjs +139 -146
- package/dist/analysis/native-boundary.mjs +52 -0
- package/dist/analysis/native-project.mjs +331 -231
- package/dist/analysis/native-session.mjs +20 -0
- package/dist/analysis/owner-accessibility.mjs +74 -0
- package/dist/analysis/owner-analysis-cache.mjs +125 -0
- package/dist/analysis/owner-analysis-key.mjs +114 -0
- package/dist/analysis/owner-choices.mjs +896 -0
- package/dist/analysis/owner-composition.mjs +636 -0
- package/dist/analysis/owner-controls.mjs +27 -0
- package/dist/analysis/owner-discovery.mjs +164 -0
- package/dist/analysis/owner-failures.mjs +19 -0
- package/dist/analysis/owner-outcomes.mjs +42 -0
- package/dist/analysis/owner-reuse.mjs +100 -0
- package/dist/analysis/owner-source.mjs +1555 -0
- package/dist/analysis/prose-owners.mjs +57 -0
- package/dist/analysis/public-imports.mjs +31 -0
- package/dist/analysis/queries.mjs +72 -54
- package/dist/analysis/runtime-setters.mjs +114 -0
- package/dist/analysis/scenario-keys.mjs +151 -0
- package/dist/analysis/service.mjs +111 -70
- package/dist/analysis/standalone.mjs +40 -37
- package/dist/analysis/styling-ownership.mjs +298 -0
- package/dist/analysis/svg-attributes.mjs +199 -0
- package/dist/analysis/syntax.mjs +82 -78
- package/dist/analysis/visual-bindings.mjs +68 -0
- package/dist/analysis/worker-protocol.mjs +302 -0
- package/dist/analysis/worker.mjs +234 -166
- package/dist/api-signature.mjs +53 -0
- package/dist/app-icon-checks.mjs +298 -0
- package/dist/app-icon-declaration.d.mts +53 -0
- package/dist/app-icon-declaration.mjs +66 -0
- package/dist/asset-binding.mjs +35 -0
- package/dist/asset-catalog.mjs +83 -0
- package/dist/asset-declaration.d.mts +42 -0
- package/dist/asset-declaration.mjs +108 -0
- package/dist/asset-macro.d.mts +63 -0
- package/dist/asset-macro.mjs +22 -0
- package/dist/asset-model.mjs +74 -0
- package/dist/asset-usage.mjs +14 -0
- package/dist/asset-view-facts.mjs +41 -0
- package/dist/authoring-macro.d.mts +11 -0
- package/dist/authoring-macro.mjs +21 -0
- package/dist/autocomplete-hints.mjs +31 -0
- package/dist/availability.mjs +9 -0
- package/dist/behavior-macro.d.mts +31 -0
- package/dist/behavior-macro.mjs +3 -0
- package/dist/behavior-registry.mjs +358 -0
- package/dist/boundaries.mjs +50 -212
- package/dist/browser-runtime.mjs +73 -0
- package/dist/browser-test.d.mts +3 -0
- package/dist/browser-test.mjs +2 -0
- package/dist/bun-bundler.mjs +10 -0
- package/dist/bun-compiler.mjs +30 -18
- package/dist/bun-runtime.mjs +4 -0
- package/dist/bun-worker.mjs +10 -4
- package/dist/capture/request.mjs +81 -0
- package/dist/capture/worker.mjs +69 -40
- package/dist/capture/worker.page.mjs +6 -0
- package/dist/capture-store.mjs +159 -75
- package/dist/capture.mjs +232 -95
- package/dist/check-service.mjs +27 -33
- package/dist/check.mjs +206 -904
- package/dist/cli-arguments.mjs +278 -0
- package/dist/cli.mjs +374 -304
- package/dist/color-values.mjs +294 -242
- package/dist/composed-contrast.mjs +648 -0
- package/dist/composed-keyline.mjs +107 -0
- package/dist/config.mjs +162 -468
- package/dist/construction-output.mjs +345 -0
- package/dist/construction-spec.d.mts +915 -0
- package/dist/construction-spec.mjs +1178 -0
- package/dist/corner-overpaint.mjs +53 -0
- package/dist/css-length.mjs +80 -0
- package/dist/css-quantity.mjs +173 -0
- package/dist/deletion-model.mjs +56 -0
- package/dist/deletion-plan.mjs +364 -0
- package/dist/dependency-manifest.mjs +56 -0
- package/dist/design-context-model.d.mts +61 -0
- package/dist/design-context-model.mjs +79 -0
- package/dist/design-contexts.mjs +105 -0
- package/dist/design-foundation.mjs +532 -0
- package/dist/design-inputs.mjs +156 -0
- package/dist/design-modules.mjs +27 -0
- package/dist/design-rejection.d.mts +23 -0
- package/dist/design-rejection.mjs +29 -0
- package/dist/design-system-closure.mjs +108 -0
- package/dist/design-usage.mjs +54 -0
- package/dist/development-modules.mjs +2 -0
- package/dist/development-runtime.mjs +0 -7
- package/dist/digest.mjs +2 -0
- package/dist/draft-boundary.mjs +1 -27
- package/dist/draft-workspace.mjs +11 -5
- package/dist/emit/accept.mjs +33 -0
- package/dist/emit/app-icon-emission.mjs +124 -0
- package/dist/emit/app-icon-render.mjs +126 -0
- package/dist/emit/asset-imports.mjs +18 -0
- package/dist/emit/cli-report.mjs +97 -0
- package/dist/emit/contract.mjs +136 -0
- package/dist/emit/emission.mjs +182 -0
- package/dist/emit/font-emission.mjs +111 -0
- package/dist/emit/foundation-sheet.mjs +56 -0
- package/dist/emit/icon-containers.mjs +46 -0
- package/dist/emit/integrity.mjs +61 -0
- package/dist/emit/lock.mjs +66 -0
- package/dist/emit/namespace.mjs +79 -0
- package/dist/emit/operation-reply.mjs +3 -0
- package/dist/emit/operation.mjs +36 -0
- package/dist/emit/output-location.mjs +20 -0
- package/dist/emit/output-package.mjs +7 -0
- package/dist/emit/owner-emission-cache.mjs +52 -0
- package/dist/emit/palette-module.mjs +19 -0
- package/dist/emit/palette-refresh.mjs +77 -0
- package/dist/emit/preview-emitter.mjs +110 -0
- package/dist/emit/preview-tree.mjs +174 -0
- package/dist/emit/scheduler.mjs +75 -0
- package/dist/emit/service.mjs +249 -0
- package/dist/emit/sync.mjs +38 -0
- package/dist/emit/watch.mjs +74 -0
- package/dist/emit/writer.mjs +102 -0
- package/dist/evidence.mjs +6 -8
- package/dist/example-babel.mjs +7 -0
- package/dist/example-literals.mjs +88 -0
- package/dist/finding-rules.mjs +78 -77
- package/dist/focus-checks.mjs +93 -0
- package/dist/font-checks.mjs +185 -0
- package/dist/font-declaration.d.mts +64 -0
- package/dist/font-declaration.mjs +99 -0
- package/dist/font-fallback.d.mts +37 -0
- package/dist/font-fallback.mjs +25 -0
- package/dist/font-macro.d.mts +42 -0
- package/dist/font-macro.mjs +6 -0
- package/dist/font-metrics.d.mts +34 -0
- package/dist/font-metrics.mjs +314 -0
- package/dist/font-model.mjs +63 -0
- package/dist/form-states.mjs +82 -0
- package/dist/foundation-macro.d.mts +108 -0
- package/dist/foundation-macro.mjs +6 -0
- package/dist/frame-regions.mjs +253 -0
- package/dist/glyph-set-declaration.d.mts +27 -0
- package/dist/glyph-set-declaration.mjs +36 -0
- package/dist/grid-checks.mjs +94 -0
- package/dist/grid-facts.mjs +148 -0
- package/dist/grid-lowering.mjs +263 -0
- package/dist/guard/cli.mjs +51 -0
- package/dist/guard/config.mjs +67 -0
- package/dist/guard/files.mjs +31 -0
- package/dist/guard/index.mjs +3 -0
- package/dist/guard/run.mjs +56 -0
- package/dist/guard/tsconfig.declarations.json +13 -0
- package/dist/index.mjs +2 -7
- package/dist/init-project.mjs +134 -0
- package/dist/init.mjs +217 -264
- package/dist/input-digests.mjs +109 -163
- package/dist/input-scope.mjs +18 -41
- package/dist/inspected-svg.d.mts +28 -0
- package/dist/inspected-svg.mjs +40 -0
- package/dist/inventories.mjs +149 -0
- package/dist/inventory-query.mjs +15 -0
- package/dist/investigations.mjs +177 -99
- package/dist/json.d.mts +10 -0
- package/dist/json.mjs +36 -0
- package/dist/linaria/atomic-processor.json +96 -0
- package/dist/linaria/atomic-processor.mjs +2452 -0
- package/dist/linaria/backend-identity.mjs +26 -0
- package/dist/linaria/compatibility.json +61 -0
- package/dist/linaria/css-shape.mjs +94 -0
- package/dist/linaria/custom-property-css.mjs +56 -0
- package/dist/linaria/delivery.mjs +111 -0
- package/dist/linaria/direct-extract.mjs +43 -0
- package/dist/linaria/extraction-cache.mjs +31 -0
- package/dist/linaria/extraction-model.mjs +5 -0
- package/dist/linaria/fingerprint.mjs +183 -0
- package/dist/linaria/pair-manifest.json +2315 -0
- package/dist/linaria/persisted-extraction-cache.mjs +352 -0
- package/dist/linaria/preservation.mjs +13 -0
- package/dist/linaria/priority-emitted-rank.mjs +40 -0
- package/dist/linaria/priority-manifest.mjs +87 -0
- package/dist/linaria/priority-table.mjs +47 -0
- package/dist/linaria/priority-tiers.mjs +27 -0
- package/dist/linaria/processor-host.mjs +42 -0
- package/dist/linaria/processor-runtime.mjs +36 -0
- package/dist/linaria-processor-NOTICES.md +147 -0
- package/dist/lowering-components.mjs +14 -0
- package/dist/lowering-effects.mjs +38 -0
- package/dist/lowering-emitter.mjs +29 -0
- package/dist/lowering-enter.mjs +31 -0
- package/dist/lowering-hidden.mjs +30 -0
- package/dist/lowering-layer.mjs +141 -0
- package/dist/lowering-motion.mjs +37 -0
- package/dist/lowering-normalize.mjs +194 -0
- package/dist/lowering-overlaps.mjs +328 -0
- package/dist/lowering-paint.mjs +32 -0
- package/dist/lowering-properties.mjs +165 -0
- package/dist/lowering-region-layout.mjs +225 -0
- package/dist/lowering-sequence.mjs +89 -0
- package/dist/lowering-serialize.mjs +40 -0
- package/dist/lowering-session.mjs +137 -0
- package/dist/lowering-tiers.mjs +23 -0
- package/dist/lowering-transitions.mjs +53 -0
- package/dist/mcp/ads-mcp.mjs +423 -0
- package/dist/mcp/apps.mjs +3 -25
- package/dist/mcp/behavior-pages.mjs +58 -51
- package/dist/mcp/build-status.mjs +233 -267
- package/dist/mcp/catalog.mjs +21 -128
- package/dist/mcp/compiler-channel.mjs +218 -83
- package/dist/mcp/context.mjs +50 -40
- package/dist/mcp/deletions.mjs +147 -0
- package/dist/mcp/draft-discovery.mjs +43 -38
- package/dist/mcp/drafts.mjs +635 -691
- package/dist/mcp/execution-context.mjs +33 -22
- package/dist/mcp/execution-coordinator.mjs +367 -354
- package/dist/mcp/execution-results.mjs +440 -173
- package/dist/mcp/mutation-limits.mjs +1 -2
- package/dist/mcp/mutations.mjs +515 -553
- package/dist/mcp/patch.mjs +117 -75
- package/dist/mcp/preview-http.bundle.js +3 -7
- package/dist/mcp/preview-http.mjs +220 -107
- package/dist/mcp/preview-owner-guard.mjs +81 -43
- package/dist/mcp/preview-watch.mjs +428 -365
- package/dist/mcp/preview-widget.bundle.js +42 -46
- package/dist/mcp/preview-work.mjs +25 -13
- package/dist/mcp/prompts.mjs +22 -16
- package/dist/mcp/resource-loader.js +1 -1
- package/dist/mcp/result-pages.mjs +94 -54
- package/dist/mcp/sandbox-host.mjs +41 -19
- package/dist/mcp/server-discovery.mjs +96 -0
- package/dist/mcp/server-guides.mjs +43 -0
- package/dist/mcp/server-host.mjs +203 -0
- package/dist/mcp/server-observation.mjs +225 -0
- package/dist/mcp/server-project.mjs +371 -0
- package/dist/mcp/server-resources.mjs +466 -0
- package/dist/mcp/server-shared.mjs +79 -0
- package/dist/mcp/server-tools.mjs +791 -0
- package/dist/mcp/server.mjs +2 -2813
- package/dist/mcp/showcase-host.mjs +209 -135
- package/dist/mcp/showcase-http.mjs +50 -28
- package/dist/mcp/skills.mjs +32 -36
- package/dist/mcp/text-diff.mjs +18 -36
- package/dist/measured-geometry.mjs +157 -0
- package/dist/motion-model.mjs +52 -0
- package/dist/non-text-contrast.mjs +118 -0
- package/dist/owner-analysis-check.mjs +711 -0
- package/dist/owner-design.mjs +15 -0
- package/dist/owner-errors.mjs +216 -0
- package/dist/owner-lowering.mjs +206 -0
- package/dist/owner-scenarios.mjs +854 -0
- package/dist/ownership-model.d.mts +6 -0
- package/dist/ownership-model.mjs +143 -0
- package/dist/package-declarations.mjs +34 -0
- package/dist/paint-contrast.mjs +186 -0
- package/dist/palette-generated.mjs +101 -116
- package/dist/pictogram-model.mjs +13 -51
- package/dist/placeholder-contrast.mjs +35 -0
- package/dist/platform-features.mjs +401 -0
- package/dist/press-scale.mjs +26 -0
- package/dist/preview-bun.mjs +334 -404
- package/dist/preview-compile-inputs.mjs +78 -0
- package/dist/preview-contexts.mjs +7 -0
- package/dist/preview-controls.mjs +35 -0
- package/dist/preview-failure.mjs +20 -10
- package/dist/preview-files.mjs +18 -36
- package/dist/preview-imports.mjs +76 -70
- package/dist/preview-incremental.mjs +322 -222
- package/dist/preview-inputs.mjs +26 -26
- package/dist/preview-manifest-update.mjs +67 -49
- package/dist/preview-requests.mjs +10 -17
- package/dist/preview-resources.mjs +275 -323
- package/dist/preview-scope.mjs +15 -17
- package/dist/preview-source.mjs +182 -0
- package/dist/preview-spatial.mjs +27 -0
- package/dist/profile-macro.d.mts +56 -0
- package/dist/profile-macro.mjs +6 -0
- package/dist/profile-model.d.mts +65 -0
- package/dist/profile-model.mjs +213 -0
- package/dist/profile-view-facts.mjs +93 -0
- package/dist/program-cache.mjs +9 -7
- package/dist/project-boundary.mjs +8 -13
- package/dist/project-documents.mjs +25 -29
- package/dist/property-registrations.mjs +44 -35
- package/dist/prose-model.d.mts +81 -0
- package/dist/prose-model.mjs +101 -0
- package/dist/public-catalog.mjs +76 -0
- package/dist/recipe-defaults.mjs +117 -0
- package/dist/recipe-macro.d.mts +502 -0
- package/dist/recipe-macro.mjs +23 -0
- package/dist/recipe-model.d.mts +26 -0
- package/dist/recipe-model.mjs +214 -0
- package/dist/region-lowering.mjs +723 -0
- package/dist/registration-css.mjs +41 -0
- package/dist/registration-roles.mjs +35 -0
- package/dist/render-audit/axe-run.page.mjs +28 -0
- package/dist/render-audit/corner-overpaint.page.mjs +54 -0
- package/dist/render-audit/first-render.page.mjs +35 -0
- package/dist/render-audit/image-shape.page.mjs +42 -0
- package/dist/render-audit/layout-overflow.page.mjs +240 -0
- package/dist/render-audit/layout-shift.page.mjs +36 -0
- package/dist/render-audit/non-text-contrast.page.mjs +138 -0
- package/dist/render-audit/render-states.mjs +66 -293
- package/dist/render-audit/render-states.page.mjs +177 -0
- package/dist/render-audit/text-scale.mjs +42 -0
- package/dist/render-audit/text-scale.page.mjs +25 -0
- package/dist/render-audit/worker.mjs +130 -112
- package/dist/render-audit/worker.page.mjs +21 -0
- package/dist/render-audit.mjs +490 -500
- package/dist/resource-limits.mjs +174 -223
- package/dist/result.d.mts +34 -0
- package/dist/result.mjs +60 -0
- package/dist/role-vocabulary.d.mts +260 -0
- package/dist/role-vocabulary.mjs +258 -0
- package/dist/runtime-paint-contrast.mjs +97 -0
- package/dist/runtime-paint.mjs +42 -0
- package/dist/runtime-requirements.mjs +10 -11
- package/dist/runtime-style.mjs +21 -0
- package/dist/scenario-groups.mjs +42 -33
- package/dist/scenario-inspector.mjs +4 -4
- package/dist/scenario-kit.d.mts +85 -0
- package/dist/scenario-kit.mjs +18 -0
- package/dist/scenario-registry-model.mjs +2 -0
- package/dist/scenario-registry.mjs +89 -108
- package/dist/scenarios-compiler.mjs +875 -662
- package/dist/scheme-switch.d.mts +8 -0
- package/dist/scheme-switch.mjs +1 -0
- package/dist/showcase/ads-views.mjs +166 -0
- package/dist/showcase/assets-view.mjs +252 -0
- package/dist/showcase/client.bundle.js +211 -48
- package/dist/showcase/guide-controls.d.mts +28 -0
- package/dist/showcase/guide-controls.mjs +31 -0
- package/dist/showcase/http-client.bundle.js +172 -9
- package/dist/showcase/index.html +1 -1
- package/dist/showcase/preview-frame.css +18 -0
- package/dist/showcase/preview-frame.d.mts +5 -0
- package/dist/showcase/preview-frame.mjs +4 -0
- package/dist/showcase/preview-root.d.mts +2 -0
- package/dist/showcase/preview-root.mjs +9 -0
- package/dist/showcase/profiles-view.mjs +321 -0
- package/dist/showcase/project-rules.mjs +9 -0
- package/dist/showcase/sandbox.bundle.js +1 -1
- package/dist/showcase/scenario-page.d.mts +49 -0
- package/dist/showcase/scenario-page.mjs +105 -0
- package/dist/showcase/style.css +2 -0
- package/dist/showcase/token-sample.mjs +89 -0
- package/dist/showcase/tokens-view.mjs +233 -0
- package/dist/showcase/ui/apple-touch-icon-9zwv3w79.png +0 -0
- package/dist/showcase/{favicon.ico → ui/favicon-c2c9kvtf.ico} +0 -0
- package/dist/showcase/ui/icon-192-t5zh7mxx.png +0 -0
- package/dist/showcase/ui/icon-512-ed6yz0n0.png +0 -0
- package/dist/showcase/ui/ui.css +1 -1353
- package/dist/showcase/ui/ui.js +165 -1064
- package/dist/showcase-http-routes.mjs +28 -21
- package/dist/skills/README.md +28 -28
- package/dist/skills/ads-designer/README.md +1 -1
- package/dist/skills/ads-designer/SKILL.md +313 -551
- package/dist/skills/ads-designer/references/accessibility.md +162 -114
- package/dist/skills/ads-designer/references/atomic-styles.md +72 -277
- package/dist/skills/ads-designer/references/behaviors.md +144 -280
- package/dist/skills/ads-designer/references/branding.md +137 -222
- package/dist/skills/ads-designer/references/captures.md +13 -7
- package/dist/skills/ads-designer/references/cli.md +80 -63
- package/dist/skills/ads-designer/references/contracts.md +225 -286
- package/dist/skills/ads-designer/references/design-craft.md +2 -2
- package/dist/skills/ads-designer/references/design-data.md +299 -323
- package/dist/skills/ads-designer/references/drafts.md +83 -22
- package/dist/skills/ads-designer/references/evidence.md +2 -1
- package/dist/skills/ads-designer/references/forms.md +199 -0
- package/dist/skills/ads-designer/references/guarded-editing.md +37 -48
- package/dist/skills/ads-designer/references/layers.md +64 -76
- package/dist/skills/ads-designer/references/layout.md +224 -330
- package/dist/skills/ads-designer/references/mobile.md +2 -2
- package/dist/skills/ads-designer/references/motion.md +66 -25
- package/dist/skills/ads-designer/references/performance.md +55 -50
- package/dist/skills/ads-designer/references/pictograms.md +62 -127
- package/dist/skills/ads-designer/references/recipes.md +368 -0
- package/dist/skills/ads-designer/references/review.md +51 -95
- package/dist/skills/ads-designer/references/runtimes.md +34 -33
- package/dist/skills/ads-designer/references/scenarios.md +256 -216
- package/dist/skills/ads-designer/references/stress-test.md +13 -5
- package/dist/skills/ads-designer/references/validation.md +28 -21
- package/dist/skills/ads-designer/references/workflows.md +7 -5
- package/dist/skills/ads-import/SKILL.md +29 -29
- package/dist/skills/ads-import/references/atomic-styles.md +72 -277
- package/dist/skills/ads-import/references/behaviors.md +144 -280
- package/dist/skills/ads-import/references/branding.md +24 -41
- package/dist/skills/ads-import/references/captures.md +13 -7
- package/dist/skills/ads-import/references/cli.md +80 -63
- package/dist/skills/ads-import/references/compatibility.md +3 -3
- package/dist/skills/ads-import/references/contracts.md +225 -286
- package/dist/skills/ads-import/references/design-data.md +299 -323
- package/dist/skills/ads-import/references/drafts.md +83 -22
- package/dist/skills/ads-import/references/evidence.md +2 -1
- package/dist/skills/ads-import/references/forms.md +199 -0
- package/dist/skills/ads-import/references/guarded-editing.md +37 -48
- package/dist/skills/ads-import/references/implementation.md +20 -20
- package/dist/skills/ads-import/references/layers.md +64 -76
- package/dist/skills/ads-import/references/layout.md +224 -330
- package/dist/skills/ads-import/references/recipes.md +368 -0
- package/dist/skills/ads-import/references/review.md +51 -95
- package/dist/skills/ads-import/references/runtimes.md +34 -33
- package/dist/skills/ads-import/references/scenarios.md +256 -216
- package/dist/skills/ads-import/references/tokens.md +26 -17
- package/dist/skills/ads-import/references/validation.md +28 -21
- package/dist/skills/ads-import/references/workflows.md +7 -5
- package/dist/skills/ads-migrate/SKILL.md +20 -5
- package/dist/skills/ads-migrate/references/0.4.1-to-0.4.2.md +6 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-boundary.md +71 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0-grid.md +204 -0
- package/dist/skills/ads-migrate/references/0.4.7-to-0.5.0.md +727 -0
- package/dist/skills/ads-migrate/references/0.5.0-to-0.5.1.md +239 -0
- package/dist/skills/ads-port/SKILL.md +27 -28
- package/dist/skills/ads-port/references/atomic-styles.md +72 -277
- package/dist/skills/ads-port/references/behaviors.md +144 -280
- package/dist/skills/ads-port/references/captures.md +13 -7
- package/dist/skills/ads-port/references/cli.md +80 -63
- package/dist/skills/ads-port/references/contracts.md +225 -286
- package/dist/skills/ads-port/references/design-data.md +299 -323
- package/dist/skills/ads-port/references/drafts.md +83 -22
- package/dist/skills/ads-port/references/evidence.md +2 -1
- package/dist/skills/ads-port/references/forms.md +199 -0
- package/dist/skills/ads-port/references/guarded-editing.md +37 -48
- package/dist/skills/ads-port/references/layers.md +64 -76
- package/dist/skills/ads-port/references/layout.md +224 -330
- package/dist/skills/ads-port/references/lint-and-docs.md +2 -3
- package/dist/skills/ads-port/references/native-implementation.md +23 -33
- package/dist/skills/ads-port/references/recipes.md +368 -0
- package/dist/skills/ads-port/references/review.md +51 -95
- package/dist/skills/ads-port/references/runtimes.md +34 -33
- package/dist/skills/ads-port/references/scenarios.md +256 -216
- package/dist/skills/ads-port/references/validation.md +28 -21
- package/dist/skills/ads-port/references/workflows.md +7 -5
- package/dist/source-inventory.mjs +33 -0
- package/dist/source-values.mjs +272 -262
- package/dist/spatial-css.mjs +403 -0
- package/dist/spatial-metadata.mjs +11 -11
- package/dist/spatial-model.mjs +438 -0
- package/dist/spatial-reading.mjs +127 -0
- package/dist/stage-timing.mjs +27 -0
- package/dist/state-conditions.d.mts +80 -0
- package/dist/state-conditions.mjs +107 -0
- package/dist/static-values.mjs +94 -0
- package/dist/surface-contrast.mjs +252 -0
- package/dist/surface-effects.mjs +98 -0
- package/dist/target-size.mjs +177 -0
- package/dist/task-cache.mjs +142 -136
- package/dist/task-worker.mjs +18 -18
- package/dist/test-boundaries.mjs +50 -189
- package/dist/token-checks.mjs +21 -0
- package/dist/token-dtcg.mjs +136 -0
- package/dist/token-expression.mjs +19 -0
- package/dist/token-inventory.mjs +146 -0
- package/dist/token-operations.mjs +37 -0
- package/dist/token-overlap.mjs +29 -0
- package/dist/token-provenance.mjs +260 -0
- package/dist/token-references.mjs +71 -0
- package/dist/token-registrations.mjs +116 -0
- package/dist/token-resolution.mjs +38 -0
- package/dist/token-sections.mjs +123 -0
- package/dist/token-shapes.mjs +121 -0
- package/dist/token-sheet-check.mjs +54 -0
- package/dist/token-type-check.mjs +89 -0
- package/dist/token-view-facts.mjs +111 -0
- package/dist/tsconfig.declarations.json +24 -0
- package/dist/types/css-tree.d.ts +45 -0
- package/dist/ui-framework.mjs +34 -34
- package/dist/units.mjs +186 -226
- package/dist/unknown.d.mts +9 -0
- package/dist/unknown.mjs +13 -0
- package/dist/unreached-sources.mjs +5 -0
- package/dist/validation-checks.mjs +62 -71
- package/dist/validation-inputs.mjs +209 -279
- package/dist/validation.mjs +132 -159
- package/dist/verification/browser.d.mts +21 -25
- package/dist/verification/browser.mjs +281 -124
- package/dist/verification/browser.page.d.mts +22 -0
- package/dist/verification/browser.page.mjs +19 -0
- package/dist/verification/paint-audit.page.d.mts +55 -0
- package/dist/verification/paint-audit.page.mjs +144 -0
- package/dist/verification/playwright-reporter.mjs +160 -0
- package/dist/verification/preview-startup.d.mts +51 -0
- package/dist/verification/preview-startup.mjs +76 -0
- package/dist/verification/request.d.mts +28 -0
- package/dist/verification/request.mjs +30 -0
- package/dist/verification/unit-preload.mjs +37 -0
- package/dist/verification.mjs +574 -607
- package/docs/ADS.md +585 -565
- package/docs/ARCHITECTURE.md +2002 -1384
- package/docs/ASSETS.md +487 -0
- package/docs/BEHAVIORS.md +339 -370
- package/docs/CACHING.md +365 -154
- package/docs/CHANGELOG.md +462 -21
- package/docs/COMPARISON.md +21 -26
- package/docs/DESIGN-REFERENCES.md +40 -27
- package/docs/GUIDE.md +2473 -1292
- package/docs/LANGUAGE.md +1159 -0
- package/docs/LOWERING.md +180 -0
- package/docs/MCP.md +1461 -1179
- package/docs/MOTION.md +491 -0
- package/docs/PROFILE-KINDS.md +544 -0
- package/docs/PROFILES.md +176 -0
- package/docs/RULES.md +590 -0
- package/docs/TOKEN-ROLES.md +377 -0
- package/docs/benchmarks/README.md +26 -27
- package/package.json +59 -45
- package/dist/a11y.mjs +0 -187
- package/dist/assets.mjs +0 -159
- package/dist/atomic-composition.mjs +0 -337
- package/dist/atomic-trace.mjs +0 -162
- package/dist/behavior-libraries.mjs +0 -174
- package/dist/behaviors.mjs +0 -306
- package/dist/brand-assets.mjs +0 -458
- package/dist/brands.mjs +0 -141
- package/dist/component-contrast.mjs +0 -256
- package/dist/construction-styles.cjs +0 -10
- package/dist/contracts/foundation.json +0 -211
- package/dist/contracts/tokens.json +0 -52
- package/dist/contracts.d.mts +0 -30
- package/dist/contrast-composition.mjs +0 -80
- package/dist/contrast-styles.mjs +0 -88
- package/dist/control-padding.mjs +0 -113
- package/dist/css-values.mjs +0 -27
- package/dist/declarative-flow.mjs +0 -244
- package/dist/design-values.mjs +0 -173
- package/dist/font-rules.mjs +0 -108
- package/dist/fonts-generated.mjs +0 -112
- package/dist/foundation-views.mjs +0 -242
- package/dist/foundation.mjs +0 -154
- package/dist/generated-entries.mjs +0 -198
- package/dist/html.mjs +0 -30
- package/dist/icons.mjs +0 -154
- package/dist/image-attributes.mjs +0 -187
- package/dist/image-size.mjs +0 -28
- package/dist/layers.mjs +0 -461
- package/dist/layout-widths.mjs +0 -332
- package/dist/linaria/atomic-css.cjs +0 -2
- package/dist/linaria/atomic-styled.cjs +0 -2
- package/dist/linaria/preserve-values.cjs +0 -58
- package/dist/linaria/spatial-inputs.cjs +0 -56
- package/dist/linaria.d.mts +0 -1
- package/dist/linaria.mjs +0 -9
- package/dist/lockup-composition.mjs +0 -44
- package/dist/lockup-model.cjs +0 -64
- package/dist/paint-contracts.mjs +0 -216
- package/dist/pictograms.mjs +0 -52
- package/dist/public-api.mjs +0 -121
- package/dist/public-props.mjs +0 -91
- package/dist/render-audit/axe-run.mjs +0 -17
- package/dist/render-audit/first-render.mjs +0 -40
- package/dist/render-audit/image-shape.mjs +0 -46
- package/dist/render-audit/layout-overflow.mjs +0 -167
- package/dist/render-audit/layout-shift.mjs +0 -32
- package/dist/render-audit/non-text-contrast.mjs +0 -151
- package/dist/render-audit/pictograms.mjs +0 -88
- package/dist/render-color-probe.mjs +0 -202
- package/dist/render-composition.mjs +0 -186
- package/dist/runtime-contracts.mjs +0 -506
- package/dist/scenario-program.mjs +0 -19
- package/dist/scenario-selectors.mjs +0 -237
- package/dist/scenario-slots.mjs +0 -217
- package/dist/scenario-trace.mjs +0 -314
- package/dist/scenarios-vite.d.mts +0 -2
- package/dist/scenarios-vite.mjs +0 -2
- package/dist/scenarios.mjs +0 -616
- package/dist/selector-match.mjs +0 -94
- package/dist/showcase/comparison.js +0 -48
- package/dist/showcase/connection.js +0 -10
- package/dist/showcase/draft-navigation.js +0 -59
- package/dist/showcase/foundation-view.css +0 -58
- package/dist/showcase/foundation-view.mjs +0 -255
- package/dist/showcase/guide-controls.ads.review.mjs +0 -32
- package/dist/showcase/http-connection.js +0 -86
- package/dist/showcase/http-preview.js +0 -81
- package/dist/showcase/icons.js +0 -2
- package/dist/showcase/navigation.js +0 -13
- package/dist/showcase/pictogram-view.mjs +0 -53
- package/dist/showcase/preview-frame.ads.review.css +0 -46
- package/dist/showcase/preview-frame.ads.review.d.mts +0 -11
- package/dist/showcase/preview-frame.ads.review.mjs +0 -22
- package/dist/showcase/preview-state.js +0 -11
- package/dist/showcase/refresh-scheduler.js +0 -23
- package/dist/showcase/resource-reader.js +0 -37
- package/dist/showcase-coverage.mjs +0 -139
- package/dist/source-symbols.mjs +0 -4
- package/dist/spatial-composition.mjs +0 -322
- package/dist/spatial-contexts.cjs +0 -56
- package/dist/spatial-css.cjs +0 -351
- package/dist/spatial-inputs.cjs +0 -80
- package/dist/spatial-model.cjs +0 -322
- package/dist/spatial.mjs +0 -21
- package/dist/stage-timing.cjs +0 -21
- package/dist/starters/preact/design-system/patterns/Conversation/Conversation.tsx +0 -105
- package/dist/starters/preact/design-system/patterns/Shell/Shell.tsx +0 -275
- package/dist/starters/preact/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
- package/dist/starters/preact/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
- package/dist/starters/preact/design-system/showcase/mcp/main.ads.mount.tsx +0 -8
- package/dist/starters/preact/ds.config.json +0 -37
- package/dist/starters/preact/package.json +0 -35
- package/dist/starters/preact/src/vite-env.d.ts +0 -7
- package/dist/starters/preact/tsconfig.json +0 -35
- package/dist/starters/preact/vite.config.ts +0 -23
- package/dist/starters/react/ADS.md +0 -286
- package/dist/starters/react/README.md +0 -184
- package/dist/starters/react/biome.css.json +0 -21
- package/dist/starters/react/design-system/assets/brand/README.md +0 -41
- package/dist/starters/react/design-system/assets/brand/app-icon.svg +0 -4
- package/dist/starters/react/design-system/assets/brand/logo.dark.svg +0 -6
- package/dist/starters/react/design-system/assets/brand/logo.svg +0 -6
- package/dist/starters/react/design-system/assets/glyphs/README.md +0 -15
- package/dist/starters/react/design-system/assets/glyphs/aliases.json +0 -1
- package/dist/starters/react/design-system/assets/glyphs/check.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-down.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/chevron-right.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/close.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/external-link.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/info.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/menu.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/plus.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/search.svg +0 -1
- package/dist/starters/react/design-system/assets/glyphs/warning.svg +0 -1
- package/dist/starters/react/design-system/assets/pictograms/catalog.ads.json +0 -13
- package/dist/starters/react/design-system/assets/pictograms/journey.dark.svg +0 -7
- package/dist/starters/react/design-system/assets/pictograms/journey.svg +0 -7
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/Button/Button.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Actions/Button/Button.tsx +0 -56
- package/dist/starters/react/design-system/components/Actions/Button/README.md +0 -12
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.fixture.ts +0 -9
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/components/Actions/IconButton/IconButton.tsx +0 -60
- package/dist/starters/react/design-system/components/Actions/IconButton/README.md +0 -17
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.fixture.ts +0 -6
- package/dist/starters/react/design-system/components/Content/Icon/Icon.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/components/Content/Icon/Icon.tsx +0 -42
- package/dist/starters/react/design-system/components/Content/Icon/README.md +0 -17
- package/dist/starters/react/design-system/components/Content/Icon/glyphs.ts +0 -17
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.fixture.ts +0 -2
- package/dist/starters/react/design-system/components/Content/Image/Image.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Content/Image/Image.tsx +0 -51
- package/dist/starters/react/design-system/components/Content/Image/README.md +0 -20
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Logo/Logo.ads.scenario.tsx +0 -12
- package/dist/starters/react/design-system/components/Content/Logo/Logo.tsx +0 -35
- package/dist/starters/react/design-system/components/Content/Logo/README.md +0 -12
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.ads.scenario.tsx +0 -7
- package/dist/starters/react/design-system/components/Content/Pictogram/Pictogram.tsx +0 -26
- package/dist/starters/react/design-system/components/Forms/TextField/README.md +0 -14
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.fixture.ts +0 -6
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.ads.scenario.tsx +0 -13
- package/dist/starters/react/design-system/components/Forms/TextField/TextField.tsx +0 -61
- package/dist/starters/react/design-system/composition/Search/SearchPage/README.md +0 -4
- package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/composition/Search/SearchPage/SearchPage.ads.scenario.tsx +0 -16
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/README.md +0 -5
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.fixture.ts +0 -13
- package/dist/starters/react/design-system/composition/Workspace/WorkspacePage/WorkspacePage.ads.scenario.tsx +0 -22
- package/dist/starters/react/design-system/controllers/Palette/Palette.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/controllers/Palette/Palette.ts +0 -164
- package/dist/starters/react/design-system/index.ts +0 -12
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.fixture.ts +0 -7
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.ads.scenario.tsx +0 -15
- package/dist/starters/react/design-system/patterns/Conversation/Conversation.tsx +0 -105
- package/dist/starters/react/design-system/patterns/Conversation/README.md +0 -9
- package/dist/starters/react/design-system/patterns/Search/SearchBar/README.md +0 -12
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.fixture.ts +0 -1
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.ads.scenario.tsx +0 -11
- package/dist/starters/react/design-system/patterns/Search/SearchBar/SearchBar.tsx +0 -41
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.fixture.ts +0 -5
- package/dist/starters/react/design-system/patterns/Shell/Floating.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/patterns/Shell/README.md +0 -43
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.fixture.ts +0 -5
- package/dist/starters/react/design-system/patterns/Shell/Shell.ads.scenario.tsx +0 -21
- package/dist/starters/react/design-system/patterns/Shell/Shell.tsx +0 -274
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/demo-frame/DemoFrame.ads.review.tsx +0 -7
- package/dist/starters/react/design-system/review/index.ads.review.ts +0 -4
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/region-block/RegionBlock.ads.review.tsx +0 -6
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.exports.ts +0 -1
- package/dist/starters/react/design-system/review/screen-frame/ScreenFrame.ads.review.tsx +0 -10
- package/dist/starters/react/design-system/showcase/mcp/main.ads.mount.tsx +0 -10
- package/dist/starters/react/design-system/styles.css +0 -7
- package/dist/starters/react/design-system/tokens/base.css +0 -36
- package/dist/starters/react/design-system/tokens/catalog.ads.json +0 -1221
- package/dist/starters/react/design-system/tokens/colors.css +0 -215
- package/dist/starters/react/design-system/tokens/elevation.css +0 -53
- package/dist/starters/react/design-system/tokens/spacing.css +0 -87
- package/dist/starters/react/design-system/tokens/spatial.ads.json +0 -70
- package/dist/starters/react/design-system/tokens/themes.generated.css +0 -142
- package/dist/starters/react/design-system/tokens/themes.generated.ts +0 -402
- package/dist/starters/react/design-system/tokens/typography.css +0 -31
- package/dist/starters/react/ds.config.json +0 -37
- package/dist/starters/react/gitignore.template +0 -8
- package/dist/starters/react/package.json +0 -39
- package/dist/starters/react/scripts/build-mcp-previews.mjs +0 -3
- package/dist/starters/react/src/vite-env.d.ts +0 -7
- package/dist/starters/react/tsconfig.build.json +0 -20
- package/dist/starters/react/tsconfig.json +0 -34
- package/dist/starters/react/vite.config.ts +0 -23
- package/dist/style-boundaries.mjs +0 -106
- package/dist/style-token-rules.mjs +0 -51
- package/dist/themes-generated.mjs +0 -161
- package/dist/themes-watch.mjs +0 -83
- package/dist/themes.mjs +0 -360
- package/dist/token-export.mjs +0 -94
- package/dist/token-origins.mjs +0 -24
- package/dist/token-policy.mjs +0 -26
- package/dist/token-quality.mjs +0 -149
- package/dist/token-samples.mjs +0 -19
- package/dist/tokens.mjs +0 -194
- package/dist/unit-contracts.mjs +0 -396
- package/dist/usage.mjs +0 -184
- package/dist/verification/playwright-reporter.cjs +0 -87
- package/docs/CONTRACTS.md +0 -285
- package/docs/HTTP-SHOWCASE-POC.md +0 -397
- package/docs/SPATIAL-CHECKS.md +0 -69
- package/docs/benchmarks/http-showcase-optimized.json +0 -1879
- package/docs/benchmarks/http-showcase-profile.json +0 -308
- package/docs/benchmarks/http-showcase.json +0 -3069
- /package/dist/{starters/react/design-system/assets/fonts/.gitkeep → analysis/semantic.mjs} +0 -0
- /package/dist/{starters/react/design-system/controllers/.gitkeep → lowering-model.mjs} +0 -0
- /package/dist/showcase/{favicon.svg → ui/favicon-scavmehf.svg} +0 -0
package/dist/verification.mjs
CHANGED
|
@@ -2,60 +2,97 @@ import { eachChild, filterAsync, flatMapAsync, mapAsync, someAsync, walkAsync, w
|
|
|
2
2
|
import { finishExecutionGuard, trackExecutionArtifact, trackExecutionChild } from "./mcp/execution-context.mjs";
|
|
3
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { availableParallelism } from "node:os";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { fileURLToPath } from "node:url";
|
|
8
9
|
import ts from "./analysis/syntax.mjs";
|
|
9
10
|
import postcss from "postcss";
|
|
10
11
|
import valueParser from "postcss-value-parser";
|
|
11
|
-
import { loadConfig,
|
|
12
|
+
import { loadConfig, isInside } from "./config.mjs";
|
|
13
|
+
import { browserTestCli, ensureBrowser } from "./browser-runtime.mjs";
|
|
12
14
|
import { activeNow, setActiveTimeout } from "./active-clock.mjs";
|
|
13
15
|
import { importResolver } from "./boundaries.mjs";
|
|
14
16
|
import { inspectUnits, configurationFiles } from "./units.mjs";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
+
import { registeredBehaviors } from "./behavior-registry.mjs";
|
|
18
|
+
import { discoverScenarioRegistry } from "./scenario-registry.mjs";
|
|
19
|
+
import { FOUNDATION_DECLARATION } from "./design-contexts.mjs";
|
|
20
|
+
import { DESIGN_FOLDERS } from "./design-inputs.mjs";
|
|
21
|
+
import { notAvailable } from "./availability.mjs";
|
|
17
22
|
import { readPreviewManifest } from "./preview-resources.mjs";
|
|
18
23
|
import { acceptance, failure, failureCategories } from "./evidence.mjs";
|
|
19
24
|
import { investigationArtifacts, investigationUri, saveInvestigations } from "./investigations.mjs";
|
|
20
25
|
import { developmentExecutable, developmentRuntime } from "./development-runtime.mjs";
|
|
21
|
-
import { sourceAst, sourceText, memoFact } from "./analysis/helpers.mjs";
|
|
26
|
+
import { capturedTreeFiles, sourceAst, sourceText, memoFact } from "./analysis/helpers.mjs";
|
|
22
27
|
import { affectedInGraph } from "./analysis/impact.mjs";
|
|
23
28
|
import { currentAnalysis } from "./analysis/context.mjs";
|
|
24
29
|
import { analyze } from "./analysis/service.mjs";
|
|
25
|
-
|
|
30
|
+
import { thrownMessage } from "./result.mjs";
|
|
31
|
+
import { isRecord } from "./unknown.mjs";
|
|
26
32
|
export const BEHAVIOR_URI = "ads://project/behaviors";
|
|
27
|
-
const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
const checkStatuses = ["passed", "failed", "skipped", "incomplete", "unavailable", "stale", "cancelled"], isCheckStatus = (value) => checkStatuses.some((status) => status === value), isFailureCategory = (value) => [...failureCategories].some((category) => category === value), isReportedFailure = (value) => isRecord(value) && isFailureCategory(value.category), hash = (bytes) => createHash("sha256").update(bytes).digest("hex"), slash = (file) => file.replaceAll("\\", "/"), resultFile = (root) => path.join(root, ".ds/behavior-results.json"), identity = (unit, check) => `${unit}#${check}`, errorCode = (error) => isRecord(error) ? error.code : void 0, asError = (error) => error instanceof Error ? error : Error(String(error)), valueText = (node) => ("value" in node) && typeof node.value === "string" ? node.value : "", recordedList = (value) => value === void 0 || value === null ? [] : Array.isArray(value) ? value : [value], finiteDuration = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
34
|
+
export function declaresSideEffects(policy, relative) {
|
|
35
|
+
if (policy === !1)
|
|
36
|
+
return !1;
|
|
37
|
+
if (!Array.isArray(policy))
|
|
38
|
+
return !0;
|
|
39
|
+
const patterns = [], declared = policy;
|
|
40
|
+
for (const pattern of declared) {
|
|
41
|
+
if (typeof pattern !== "string" || !/^[\w./*?-]+$/.test(pattern))
|
|
42
|
+
return !0;
|
|
43
|
+
patterns.push(pattern);
|
|
44
|
+
}
|
|
45
|
+
return patterns.some((entry) => {
|
|
46
|
+
let pattern = entry.replace(/^\.\//, "");
|
|
47
|
+
if (!pattern.includes("/"))
|
|
48
|
+
pattern = `**/${pattern}`;
|
|
49
|
+
const expression = (pattern.match(/\*\*\/|\*\*|\*|\?|[^*?]+/g) ?? []).map((part) => part === "**/" ? "(?:.*/)?" : part === "**" ? ".*" : part === "*" ? "[^/]*" : part === "?" ? "[^/]" : part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("");
|
|
50
|
+
return new RegExp(`^${expression}$`).test(relative);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function designInputFiles(dsRoot) {
|
|
54
|
+
const files = [path.join(dsRoot, FOUNDATION_DECLARATION)];
|
|
55
|
+
for (const folder of DESIGN_FOLDERS) {
|
|
56
|
+
const directory = path.join(dsRoot, folder), captured = capturedTreeFiles(directory);
|
|
57
|
+
if (captured !== null)
|
|
58
|
+
files.push(...captured);
|
|
59
|
+
else if (existsSync(directory)) {
|
|
60
|
+
for (const entry of readdirSync(directory, { recursive: !0, withFileTypes: !0 }))
|
|
61
|
+
if (entry.isFile())
|
|
62
|
+
files.push(path.join(entry.parentPath, entry.name));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return files.sort();
|
|
66
|
+
}
|
|
32
67
|
async function inputContext(options) {
|
|
33
68
|
return memoFact(options, "verification-input-context", async () => createInputContext(options));
|
|
34
69
|
}
|
|
35
70
|
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();
|
|
71
|
+
const sources = new Map, digests = new Map, packages = new Map, resolve = await importResolver(options), resolutions = new Map;
|
|
41
72
|
return {
|
|
42
73
|
inventory: await inspectUnits(options),
|
|
43
|
-
scenarios: (await
|
|
44
|
-
seeds: [...
|
|
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)),
|
|
74
|
+
scenarios: (await discoverScenarioRegistry(options)).scenarios,
|
|
75
|
+
seeds: [...await configurationFiles(options)].map((file) => path.join(options.root, file)).concat(designInputFiles(options.dsRoot)),
|
|
47
76
|
digest(file) {
|
|
48
|
-
|
|
49
|
-
|
|
77
|
+
const known = digests.get(file);
|
|
78
|
+
if (known !== void 0)
|
|
79
|
+
return known;
|
|
80
|
+
const value = hash(readFileSync(file));
|
|
81
|
+
digests.set(file, value);
|
|
82
|
+
return value;
|
|
50
83
|
},
|
|
51
84
|
async ast(file) {
|
|
52
|
-
|
|
53
|
-
|
|
85
|
+
let source = sources.get(file);
|
|
86
|
+
if (!source)
|
|
87
|
+
sources.set(file, source = sourceAst(file));
|
|
88
|
+
return source;
|
|
54
89
|
},
|
|
55
90
|
async resolve(specifier, file) {
|
|
56
|
-
const key = `${file}\
|
|
57
|
-
|
|
58
|
-
|
|
91
|
+
const key = `${file}\x00${specifier}`;
|
|
92
|
+
let resolved = resolutions.get(key);
|
|
93
|
+
if (!resolved)
|
|
94
|
+
resolutions.set(key, resolved = resolve(specifier, file));
|
|
95
|
+
return resolved;
|
|
59
96
|
},
|
|
60
97
|
async hasSideEffects(file, record) {
|
|
61
98
|
let directory = path.dirname(file);
|
|
@@ -63,409 +100,302 @@ async function createInputContext(options) {
|
|
|
63
100
|
const manifest = path.join(directory, "package.json");
|
|
64
101
|
if (existsSync(manifest)) {
|
|
65
102
|
await record(manifest);
|
|
66
|
-
if (!packages.has(manifest))
|
|
103
|
+
if (!packages.has(manifest))
|
|
67
104
|
try {
|
|
68
|
-
|
|
105
|
+
const value = JSON.parse(sourceText(manifest));
|
|
106
|
+
packages.set(manifest, isRecord(value) ? value.sideEffects : void 0);
|
|
69
107
|
} catch {
|
|
70
|
-
packages.set(manifest,
|
|
108
|
+
packages.set(manifest, !0);
|
|
71
109
|
}
|
|
72
|
-
|
|
73
|
-
const policy = packages.get(manifest),
|
|
74
|
-
relative = slash(path.relative(directory, file));
|
|
75
|
-
if (policy === false) return false;
|
|
76
|
-
// Only the simple package sideEffects glob subset is narrowed. Unknown
|
|
77
|
-
// syntax and undeclared policies preserve the entire dependency graph.
|
|
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("");
|
|
96
|
-
return new RegExp(`^${expression}$`).test(relative);
|
|
97
|
-
});
|
|
110
|
+
return declaresSideEffects(packages.get(manifest), slash(path.relative(directory, file)));
|
|
98
111
|
}
|
|
99
112
|
directory = path.dirname(directory);
|
|
100
113
|
}
|
|
101
|
-
return
|
|
102
|
-
}
|
|
114
|
+
return !0;
|
|
115
|
+
}
|
|
103
116
|
};
|
|
104
117
|
}
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
const scriptFile = /\.[cm]?[jt]sx?$/, symlinked = (file) => lstatSync(file).isSymbolicLink() || realpathSync(file) !== file, outsideProject = (options, file) => !isInside(options.root, file) || file.includes(`${path.sep}node_modules${path.sep}`) || !existsSync(file), moduleSpecifierOf = (node) => (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) && node.moduleSpecifier && ts.isStringLiteralLike(node.moduleSpecifier) ? node.moduleSpecifier.text : void 0;
|
|
119
|
+
function importedNames(node) {
|
|
120
|
+
const clause = ts.isImportDeclaration(node) ? node.importClause : void 0;
|
|
121
|
+
if (clause && !clause.namedBindings)
|
|
122
|
+
return clause.name ? ["default"] : null;
|
|
123
|
+
if (clause?.namedBindings && ts.isNamedImports(clause.namedBindings))
|
|
124
|
+
return [...clause.name ? ["default"] : [], ...clause.namedBindings.elements.map((entry) => (entry.propertyName ?? entry.name).text)];
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
107
127
|
async function inputClosure(options, context, entries) {
|
|
108
|
-
const files = new Set
|
|
109
|
-
demands = new Map(),
|
|
110
|
-
effectsVisited = new Set();
|
|
111
|
-
const resolve = context.resolve;
|
|
128
|
+
const files = new Set, demands = new Map, effectsVisited = new Set, resolve = context.resolve;
|
|
112
129
|
async function effects(file) {
|
|
113
|
-
if (effectsVisited.has(file) ||
|
|
130
|
+
if (effectsVisited.has(file) || outsideProject(options, file))
|
|
131
|
+
return;
|
|
114
132
|
effectsVisited.add(file);
|
|
115
133
|
if (await context.hasSideEffects(file, visit)) {
|
|
116
134
|
await visit(file);
|
|
117
135
|
return;
|
|
118
136
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
if (!scriptFile.test(file) || !lstatSync(file).isFile())
|
|
138
|
+
return;
|
|
139
|
+
if (symlinked(file))
|
|
140
|
+
throw Error(`Behavior inputs cannot resolve through symlinks: ${file}`);
|
|
141
|
+
for (const statement of (await context.ast(file)).statements) {
|
|
142
|
+
const specifier = moduleSpecifierOf(statement);
|
|
143
|
+
if (specifier !== void 0)
|
|
144
|
+
for (const target of await resolve(specifier, file))
|
|
145
|
+
await effects(target);
|
|
146
|
+
}
|
|
128
147
|
}
|
|
129
|
-
async function visit(
|
|
130
|
-
file = path.resolve(
|
|
131
|
-
if (
|
|
148
|
+
async function visit(requested, names = null) {
|
|
149
|
+
const file = path.resolve(requested);
|
|
150
|
+
if (outsideProject(options, file))
|
|
151
|
+
return;
|
|
132
152
|
const prior = demands.get(file);
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (
|
|
153
|
+
if (prior !== void 0 && (prior === null || names !== null && names.every((name) => prior.has(name))))
|
|
154
|
+
return;
|
|
155
|
+
demands.set(file, names === null ? null : new Set([...prior ?? [], ...names]));
|
|
156
|
+
if (symlinked(file))
|
|
157
|
+
throw Error(`Behavior inputs cannot resolve through symlinks: ${file}`);
|
|
158
|
+
if (!lstatSync(file).isFile())
|
|
159
|
+
return;
|
|
137
160
|
files.add(file);
|
|
138
161
|
const localAsset = async (specifier) => {
|
|
139
|
-
if (!specifier || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(specifier))
|
|
162
|
+
if (!specifier || /^(?:[a-z][\w+.-]*:|\/|#)/i.test(specifier))
|
|
163
|
+
return;
|
|
140
164
|
await visit(path.resolve(path.dirname(file), specifier.replace(/[?#].*$/, "")));
|
|
141
165
|
};
|
|
142
166
|
if (file.endsWith(".css")) {
|
|
143
167
|
const css = postcss.parse(sourceText(file), { from: file });
|
|
144
168
|
await walkAsync(css, "walkAtRules", "import", async (rule) => {
|
|
145
169
|
const first = valueParser(rule.params).nodes.find((node) => node.type !== "space" && node.type !== "comment");
|
|
146
|
-
if (first?.type === "string")
|
|
170
|
+
if (first?.type === "string")
|
|
171
|
+
await localAsset(first.value);
|
|
147
172
|
});
|
|
148
173
|
await walkAsync(css, "walk", async (node) => {
|
|
149
174
|
if (node.type === "decl" || node.type === "atrule")
|
|
150
175
|
await walkValuesAsync(valueParser(node.type === "decl" ? node.value : node.params), async (value) => {
|
|
151
|
-
if (value.type === "function" && value.
|
|
152
|
-
await localAsset(
|
|
153
|
-
value.nodes
|
|
154
|
-
.filter((part) => part.type !== "space")
|
|
155
|
-
.map((part) => part.value)
|
|
156
|
-
.join(""),
|
|
157
|
-
);
|
|
176
|
+
if (value.type === "function" && valueText(value).toLowerCase() === "url")
|
|
177
|
+
await localAsset((value.nodes ?? []).filter((part) => part.type !== "space").map(valueText).join(""));
|
|
158
178
|
});
|
|
159
179
|
});
|
|
160
180
|
}
|
|
161
|
-
if (
|
|
181
|
+
if (!scriptFile.test(file))
|
|
182
|
+
return;
|
|
162
183
|
const ast = await context.ast(file);
|
|
163
|
-
|
|
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
|
-
);
|
|
173
|
-
if (barrel) {
|
|
184
|
+
if (names !== null && ast.statements.every((statement) => ts.isEmptyStatement(statement) || ts.isImportDeclaration(statement) && !statement.importClause || ts.isExportDeclaration(statement) && (!statement.exportClause || ts.isNamedExports(statement.exportClause)) && (!statement.exportClause || !ts.isNamedExports(statement.exportClause) || !statement.exportClause.elements.length || statement.moduleSpecifier))) {
|
|
174
185
|
for (const statement of ast.statements) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
186
|
+
const specifier = moduleSpecifierOf(statement);
|
|
187
|
+
if (specifier === void 0)
|
|
188
|
+
continue;
|
|
189
|
+
for (const target of await resolve(specifier, file))
|
|
190
|
+
if (!ts.isExportDeclaration(statement) || !statement.exportClause)
|
|
191
|
+
await visit(target);
|
|
192
|
+
else if (ts.isNamedExports(statement.exportClause)) {
|
|
193
|
+
const imported = statement.exportClause.elements.filter((entry) => names.includes(entry.name.text)).map((entry) => (entry.propertyName ?? entry.name).text);
|
|
194
|
+
if (imported.length)
|
|
195
|
+
await visit(target, imported);
|
|
183
196
|
await effects(target);
|
|
184
197
|
}
|
|
185
|
-
}
|
|
186
198
|
}
|
|
187
199
|
return;
|
|
188
200
|
}
|
|
189
201
|
async function walk(node) {
|
|
190
|
-
let specifier;
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
node.arguments[0] &&
|
|
197
|
-
ts.isStringLiteralLike(node.arguments[0])
|
|
198
|
-
)
|
|
199
|
-
specifier = node.arguments[0].text;
|
|
202
|
+
let specifier = moduleSpecifierOf(node);
|
|
203
|
+
if (ts.isCallExpression(node)) {
|
|
204
|
+
const [first] = node.arguments;
|
|
205
|
+
if ((node.expression.kind === ts.SyntaxKind.ImportKeyword || ts.isIdentifier(node.expression) && node.expression.text === "require") && first && ts.isStringLiteralLike(first))
|
|
206
|
+
specifier = first.text;
|
|
207
|
+
}
|
|
200
208
|
if (specifier) {
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
: null;
|
|
210
|
-
for (const target of await resolve(specifier, file)) await visit(target, names);
|
|
209
|
+
const demanded = importedNames(node);
|
|
210
|
+
for (const target of await resolve(specifier, file))
|
|
211
|
+
await visit(target, demanded);
|
|
212
|
+
}
|
|
213
|
+
if (ts.isNewExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "URL") {
|
|
214
|
+
const first = node.arguments?.[0];
|
|
215
|
+
if (first && ts.isStringLiteralLike(first))
|
|
216
|
+
await localAsset(first.text);
|
|
211
217
|
}
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
ts.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
) {
|
|
225
|
-
// Computed module selection cannot provide a precise dependency closure.
|
|
226
|
-
// Conservatively invalidate against every owned ADS input instead.
|
|
227
|
-
for (const unit of context.inventory.units) for (const owned of unit.files) await visit(path.join(options.root, owned));
|
|
218
|
+
if (ts.isCallExpression(node) && node.expression.kind === ts.SyntaxKind.ImportKeyword) {
|
|
219
|
+
const [first] = node.arguments;
|
|
220
|
+
if (!first || !ts.isStringLiteralLike(first))
|
|
221
|
+
for (const unit of context.inventory.units)
|
|
222
|
+
for (const owned of unit.files)
|
|
223
|
+
await visit(path.join(options.root, owned));
|
|
228
224
|
}
|
|
229
225
|
await eachChild(node, walk);
|
|
230
226
|
}
|
|
231
227
|
await walk(ast);
|
|
232
228
|
}
|
|
233
|
-
for (const file of entries)
|
|
229
|
+
for (const file of entries)
|
|
230
|
+
await visit(file);
|
|
234
231
|
return files;
|
|
235
232
|
}
|
|
236
|
-
|
|
233
|
+
const toolFiles = [
|
|
234
|
+
"./verification.mjs",
|
|
235
|
+
"./development-runtime.mjs",
|
|
236
|
+
"./verification/browser.mjs",
|
|
237
|
+
"./verification/playwright-reporter.mjs",
|
|
238
|
+
"./evidence.mjs",
|
|
239
|
+
"./investigations.mjs"
|
|
240
|
+
], lockFiles = ["package-lock.json", "bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "node_modules/.package-lock.json"];
|
|
237
241
|
export async function behaviorInputs(options, contract, check, context) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
...
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
for (const file of
|
|
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
|
-
])
|
|
242
|
+
const inputs = context ?? await inputContext(options), scenario = check.scenario ? inputs.scenarios.find((item) => item.id === check.scenario) : void 0, rows = [...await inputClosure(options, inputs, [
|
|
243
|
+
...(inputs.inventory.units.find((unit) => unit.id === contract.unit)?.files ?? []).map((file) => path.join(options.root, file)),
|
|
244
|
+
...inputs.seeds,
|
|
245
|
+
...scenario ? [path.join(options.root, scenario.file)] : []
|
|
246
|
+
])].sort().map((file) => [slash(path.relative(options.root, file)), inputs.digest(file)]);
|
|
247
|
+
for (const file of lockFiles)
|
|
248
|
+
rows.push([file, existsSync(path.join(options.root, file)) ? inputs.digest(path.join(options.root, file)) : null]);
|
|
249
|
+
rows.push(["profile", JSON.stringify(options.config.mcp.behaviorProfiles[check.profile])], ["runtime", JSON.stringify(currentAnalysis()?.runtime ?? developmentRuntime())]);
|
|
250
|
+
for (const file of toolFiles)
|
|
260
251
|
rows.push([`tool:${file}`, hash(readFileSync(new URL(file, import.meta.url)))]);
|
|
261
252
|
return { revision: hash(JSON.stringify(rows)), files: rows.map(([file]) => file) };
|
|
262
253
|
}
|
|
263
|
-
|
|
264
254
|
function saved(root) {
|
|
265
255
|
try {
|
|
266
256
|
const file = resultFile(root);
|
|
267
|
-
if (realpathSync(file) !== file || lstatSync(file).size >
|
|
268
|
-
|
|
269
|
-
|
|
257
|
+
if (realpathSync(file) !== file || lstatSync(file).size > 2097152)
|
|
258
|
+
return {};
|
|
259
|
+
const value = JSON.parse(readFileSync(file, "utf8")), results = isRecord(value) && value.schemaVersion === 1 ? value.results : void 0;
|
|
260
|
+
return isRecord(results) ? { ...results } : {};
|
|
270
261
|
} catch {
|
|
271
262
|
return {};
|
|
272
263
|
}
|
|
273
264
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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
|
-
};
|
|
265
|
+
function judgeEvidence(previous, check, revision) {
|
|
266
|
+
if (!isRecord(previous))
|
|
267
|
+
return { status: "not_run", current: !1 };
|
|
268
|
+
const status = previous.status, current = previous.revision === revision && previous.profile === check.profile && previous.file === check.file && previous.case === check.case && isCheckStatus(status);
|
|
269
|
+
return { ...previous, current, status: current ? status : "stale" };
|
|
270
|
+
}
|
|
271
|
+
function guaranteeResult(results) {
|
|
272
|
+
return { status: results.every((result) => result.current && result.status === "passed") ? "passed" : results.find((result) => result.status !== "passed")?.status ?? "not_run", current: results.every((result) => result.current) };
|
|
288
273
|
}
|
|
289
|
-
|
|
290
274
|
export async function behaviorStatus(options) {
|
|
291
|
-
const inventory = await
|
|
292
|
-
|
|
293
|
-
|
|
275
|
+
const inventory = await registeredBehaviors(options), evidence = saved(options.root);
|
|
276
|
+
if (!inventory.contracts.length && !inventory.diagnostics.length)
|
|
277
|
+
return { contracts: [], diagnostics: [], ...notAvailable("no-behavior-checks") };
|
|
278
|
+
const context = await inputContext(options);
|
|
294
279
|
return {
|
|
295
280
|
...inventory,
|
|
296
281
|
contracts: await mapAsync(inventory.contracts, async (contract) => {
|
|
297
|
-
const checks = Object.fromEntries(
|
|
298
|
-
await
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
);
|
|
282
|
+
const checks = Object.fromEntries(await mapAsync(Object.entries(contract.checks), async ([id, check]) => {
|
|
283
|
+
const revision = (await behaviorInputs(options, contract, check, context)).revision;
|
|
284
|
+
return [id, { ...check, result: judgeEvidence(evidence[identity(contract.unit, id)], check, revision) }];
|
|
285
|
+
}));
|
|
308
286
|
return {
|
|
309
287
|
...contract,
|
|
310
288
|
checks,
|
|
311
|
-
guarantees: contract.guarantees.map((guarantee) => {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
: (results.find((result) => result.status !== "passed")?.status ?? "not_run");
|
|
316
|
-
return { ...guarantee, result: { status, current: results.every((result) => result.current) } };
|
|
317
|
-
}),
|
|
289
|
+
guarantees: contract.guarantees.map((guarantee) => ({
|
|
290
|
+
...guarantee,
|
|
291
|
+
result: guaranteeResult(guarantee.checks.map((id) => checks[id]?.result ?? { status: "unavailable", current: !1 }))
|
|
292
|
+
}))
|
|
318
293
|
};
|
|
319
|
-
})
|
|
294
|
+
})
|
|
320
295
|
};
|
|
321
296
|
}
|
|
322
|
-
|
|
323
|
-
/** Whether any check of these units renders a scenario in a browser, so it needs built previews. */
|
|
324
297
|
export async function needsBrowserPreviews(options, units) {
|
|
325
298
|
const profiles = options.config.mcp.behaviorProfiles;
|
|
326
|
-
return (await
|
|
327
|
-
.filter((contract) => units.includes(contract.unit))
|
|
328
|
-
.some((contract) => Object.values(contract.checks).some((check) => check.scenario && profiles[check.profile]?.mode === "browser"));
|
|
299
|
+
return (await registeredBehaviors(options)).contracts.filter((contract) => units.includes(contract.unit)).some((contract) => Object.values(contract.checks).some((check) => check.scenario && profiles[check.profile]?.mode === "browser"));
|
|
329
300
|
}
|
|
330
|
-
|
|
301
|
+
const changedSet = (options, changedFiles) => new Set(changedFiles.map((file) => slash(path.relative(options.root, path.resolve(options.root, file)))));
|
|
331
302
|
export async function affectedBehaviorUnits(options, changedFiles, before) {
|
|
332
|
-
const changed =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (!before && [...changed].some((file) => !existsSync(path.resolve(options.root, file))))
|
|
336
|
-
|
|
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);
|
|
303
|
+
const changed = changedSet(options, changedFiles), contracts = (await registeredBehaviors(options)).contracts;
|
|
304
|
+
if (!contracts.length)
|
|
305
|
+
return [];
|
|
306
|
+
if (!before && [...changed].some((file) => !existsSync(path.resolve(options.root, file))))
|
|
307
|
+
return contracts.map((contract) => contract.unit);
|
|
308
|
+
const context = await inputContext(options), prior = affectedInGraph(before, "behaviors", changed) ?? new Set;
|
|
309
|
+
return (await filterAsync(contracts, async (contract) => prior.has(contract.unit) || await someAsync(Object.values(contract.checks), async (check) => (await behaviorInputs(options, contract, check, context)).files.some((file) => changed.has(file))))).map((contract) => contract.unit);
|
|
348
310
|
}
|
|
349
|
-
|
|
350
|
-
/** The exact closures used for selection, retained with a successful baseline. */
|
|
351
311
|
export async function selectionInputs(options) {
|
|
352
312
|
return memoFact(options, "selection-inputs", async () => {
|
|
353
|
-
const context = await inputContext(options),
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
);
|
|
313
|
+
const context = await inputContext(options), inventory = context.inventory, relative = (files) => [...files].map((file) => slash(path.relative(options.root, file))).sort(), owned = (unit) => (inventory.units.find((item) => item.id === unit)?.files ?? []).map((file) => path.join(options.root, file)), scenarios = Object.fromEntries(await mapAsync(context.scenarios, async (scenario) => [
|
|
314
|
+
scenario.id,
|
|
315
|
+
relative(await inputClosure(options, context, [path.join(options.root, scenario.file), ...owned(inventory.owner(inventory.relative(scenario.file)))]))
|
|
316
|
+
])), behaviors = Object.fromEntries(await mapAsync((await registeredBehaviors(options)).contracts, async (contract) => [
|
|
317
|
+
contract.unit,
|
|
318
|
+
[
|
|
319
|
+
...new Set(await flatMapAsync(Object.values(contract.checks), async (check) => (await behaviorInputs(options, contract, check, context)).files))
|
|
320
|
+
].sort()
|
|
321
|
+
]));
|
|
371
322
|
return { schemaVersion: 1, scenarios, behaviors };
|
|
372
323
|
});
|
|
373
324
|
}
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Scenarios whose rendering a change can affect: those owned by a changed unit and those whose
|
|
377
|
-
* import closure (scenario file, its fixture/component imports, CSS and local assets) reaches a
|
|
378
|
-
* changed file. Shared configuration, foundation and token inputs are not traced here; callers
|
|
379
|
-
* treat changes to them as affecting every scenario.
|
|
380
|
-
*/
|
|
381
325
|
export async function affectedScenarios(options, changedFiles, scenarios, before) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
await
|
|
390
|
-
|
|
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);
|
|
326
|
+
const candidates = scenarios ?? (await discoverScenarioRegistry(options)).scenarios, changed = changedSet(options, changedFiles), context = await inputContext(options), inventory = context.inventory, owners = new Set([...changed].flatMap((file) => inventory.owner(inventory.relative(file)) || [])), prior = affectedInGraph(before, "scenarios", changed) ?? new Set;
|
|
327
|
+
return (await filterAsync(candidates, async (scenario) => {
|
|
328
|
+
if (prior.has(scenario.id))
|
|
329
|
+
return !0;
|
|
330
|
+
const owner = inventory.owner(inventory.relative(scenario.file));
|
|
331
|
+
if (owner !== null && owners.has(owner))
|
|
332
|
+
return !0;
|
|
333
|
+
return [...await inputClosure(options, context, [path.join(options.root, scenario.file)])].some((file) => changed.has(slash(path.relative(options.root, file))));
|
|
334
|
+
})).map((scenario) => scenario.id);
|
|
399
335
|
}
|
|
400
|
-
|
|
401
336
|
export function executeDevelopmentCommand(profile, args, root, env, signal) {
|
|
402
337
|
return new Promise((resolve, reject) => {
|
|
403
338
|
const label = profile.label ?? "Behavior verification";
|
|
404
339
|
if (signal.aborted) {
|
|
405
|
-
reject(
|
|
340
|
+
reject(Error(`${label} cancelled.`));
|
|
406
341
|
return;
|
|
407
342
|
}
|
|
408
|
-
const startedAt = activeNow(),
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
failure,
|
|
412
|
-
child,
|
|
413
|
-
guard,
|
|
414
|
-
done = false;
|
|
415
|
-
const kill = () => {
|
|
416
|
-
if (!child?.pid) return;
|
|
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
|
-
}
|
|
426
|
-
};
|
|
427
|
-
child = spawn(developmentExecutable(profile.command), args, {
|
|
343
|
+
const startedAt = activeNow(), timeoutMs = profile.timeoutMs ?? 60000;
|
|
344
|
+
let output = "", stopError, done = !1;
|
|
345
|
+
const child = spawn(developmentExecutable(profile.command), args, {
|
|
428
346
|
cwd: root,
|
|
429
347
|
detached: process.platform !== "win32",
|
|
430
|
-
shell:
|
|
348
|
+
shell: !1,
|
|
431
349
|
stdio: ["ignore", "pipe", "pipe"],
|
|
432
|
-
windowsHide:
|
|
433
|
-
// A parent test runner's worker marker (bun test and Jest set JEST_WORKER_ID) would make Playwright refuse to run.
|
|
350
|
+
windowsHide: !0,
|
|
434
351
|
env: {
|
|
435
352
|
...process.env,
|
|
436
|
-
JEST_WORKER_ID:
|
|
353
|
+
JEST_WORKER_ID: void 0,
|
|
437
354
|
...env,
|
|
438
|
-
PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter)
|
|
439
|
-
}
|
|
440
|
-
})
|
|
355
|
+
PATH: [path.join(root, "node_modules/.bin"), path.dirname(process.execPath), process.env.PATH ?? ""].join(path.delimiter)
|
|
356
|
+
}
|
|
357
|
+
}), kill = () => {
|
|
358
|
+
const pid = child.pid;
|
|
359
|
+
if (!pid)
|
|
360
|
+
return;
|
|
361
|
+
if (process.platform === "win32")
|
|
362
|
+
spawn("taskkill", ["/pid", String(pid), "/T", "/F"], { stdio: "ignore" }).on("error", () => child.kill("SIGKILL"));
|
|
363
|
+
else
|
|
364
|
+
try {
|
|
365
|
+
process.kill(-pid, "SIGKILL");
|
|
366
|
+
} catch (error) {
|
|
367
|
+
if (errorCode(error) !== "ESRCH")
|
|
368
|
+
stopError ??= asError(error);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
441
371
|
trackExecutionChild(child);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
372
|
+
const guard = child.pid ? spawn(process.execPath, [fileURLToPath(new URL("./mcp/preview-owner-guard.mjs", import.meta.url)), String(child.pid), "--tree"], {
|
|
373
|
+
detached: process.platform !== "win32",
|
|
374
|
+
stdio: ["pipe", "ignore", "ignore"],
|
|
375
|
+
windowsHide: !0
|
|
376
|
+
}) : void 0;
|
|
377
|
+
if (guard) {
|
|
448
378
|
guard.stdin.on("error", () => {});
|
|
449
379
|
guard.once("error", (error) => {
|
|
450
|
-
|
|
380
|
+
stopError = error;
|
|
451
381
|
kill();
|
|
452
382
|
});
|
|
453
383
|
guard.once("exit", () => {
|
|
454
384
|
if (!done) {
|
|
455
|
-
|
|
385
|
+
stopError ??= Error("Verification ownership guard exited unexpectedly.");
|
|
456
386
|
kill();
|
|
457
387
|
}
|
|
458
388
|
});
|
|
459
389
|
}
|
|
460
390
|
const abort = () => {
|
|
461
|
-
|
|
391
|
+
stopError = Object.assign(Error(`${label} cancelled.`), { reason: "cancelled" });
|
|
462
392
|
kill();
|
|
463
393
|
};
|
|
464
|
-
signal.addEventListener("abort", abort, { once:
|
|
394
|
+
signal.addEventListener("abort", abort, { once: !0 });
|
|
465
395
|
const timeout = setActiveTimeout(() => {
|
|
466
|
-
|
|
396
|
+
stopError = Object.assign(Error(`${label} timed out after ${timeoutMs} ms for the complete profile run, not each check.`), {
|
|
467
397
|
reason: "timeout",
|
|
468
|
-
timeoutMs
|
|
398
|
+
timeoutMs
|
|
469
399
|
});
|
|
470
400
|
kill();
|
|
471
401
|
}, timeoutMs);
|
|
@@ -474,63 +404,147 @@ export function executeDevelopmentCommand(profile, args, root, env, signal) {
|
|
|
474
404
|
output = (output + chunk.toString()).slice(-12000);
|
|
475
405
|
});
|
|
476
406
|
child.once("error", (error) => {
|
|
477
|
-
|
|
407
|
+
stopError = error;
|
|
478
408
|
});
|
|
479
409
|
child.once("exit", kill);
|
|
480
|
-
|
|
481
|
-
done =
|
|
410
|
+
const settle = async (code) => {
|
|
411
|
+
done = !0;
|
|
482
412
|
kill();
|
|
483
413
|
timeout.clear();
|
|
484
414
|
signal.removeEventListener("abort", abort);
|
|
485
415
|
try {
|
|
486
416
|
await finishExecutionGuard(guard);
|
|
487
417
|
} catch (error) {
|
|
488
|
-
|
|
418
|
+
stopError ??= asError(error);
|
|
489
419
|
}
|
|
490
420
|
const elapsedMs = Math.round(activeNow() - startedAt);
|
|
491
|
-
if (
|
|
492
|
-
|
|
421
|
+
if (stopError)
|
|
422
|
+
reject(Object.assign(stopError, { output, elapsedMs }));
|
|
423
|
+
else
|
|
424
|
+
resolve({ code, output, elapsedMs });
|
|
425
|
+
};
|
|
426
|
+
child.once("close", (code) => {
|
|
427
|
+
settle(code);
|
|
493
428
|
});
|
|
494
429
|
});
|
|
495
430
|
}
|
|
496
|
-
|
|
431
|
+
function unitSpecArgs(root, group, junit, timeoutMs) {
|
|
432
|
+
const tags = [...new Set(group.map((check) => check.case))].map(escapeRegExp), files = [...new Set(group.map((check) => path.resolve(root, path.dirname(check.contract.file), check.file)))];
|
|
433
|
+
return [
|
|
434
|
+
"test",
|
|
435
|
+
`--preload=${fileURLToPath(new URL("./verification/unit-preload.mjs", import.meta.url))}`,
|
|
436
|
+
`--timeout=${timeoutMs}`,
|
|
437
|
+
"--reporter=junit",
|
|
438
|
+
`--reporter-outfile=${junit}`,
|
|
439
|
+
`--test-name-pattern=(?:^|\\s)@ads:(?:${tags.join("|")})(?=\\s|$)`,
|
|
440
|
+
...files
|
|
441
|
+
];
|
|
442
|
+
}
|
|
443
|
+
async function browserSpecArgs(root, directory, group, capture, timeoutMs, signal) {
|
|
444
|
+
const browser = capture.browser ?? "chromium";
|
|
445
|
+
await ensureBrowser(browser, { channel: capture.channel, signal });
|
|
446
|
+
const tags = [...new Set(group.map((check) => check.case))].map(escapeRegExp), files = [...new Set(group.map((check) => slash(path.relative(root, path.resolve(root, path.dirname(check.contract.file), check.file)))))], config = path.join(directory, "playwright.config.mjs"), settings = {
|
|
447
|
+
testDir: root,
|
|
448
|
+
testMatch: files,
|
|
449
|
+
timeout: Math.min(timeoutMs, 60000),
|
|
450
|
+
workers: Math.max(1, Math.min(files.length, Math.floor(availableParallelism() / 2))),
|
|
451
|
+
use: {
|
|
452
|
+
browserName: browser,
|
|
453
|
+
headless: !0,
|
|
454
|
+
trace: "retain-on-failure",
|
|
455
|
+
screenshot: "only-on-failure",
|
|
456
|
+
...capture.channel ? { channel: capture.channel } : {}
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
writeFileSync(config, `export default ${JSON.stringify(settings)};
|
|
460
|
+
`);
|
|
461
|
+
return [
|
|
462
|
+
browserTestCli(),
|
|
463
|
+
"test",
|
|
464
|
+
`--config=${config}`,
|
|
465
|
+
`--grep=(?:^|\\s)@ads:(?:${tags.join("|")})(?=\\s|$)`,
|
|
466
|
+
`--reporter=${fileURLToPath(new URL("./verification/playwright-reporter.mjs", import.meta.url))}`,
|
|
467
|
+
`--output=${path.join(directory, "artifacts")}`
|
|
468
|
+
];
|
|
469
|
+
}
|
|
470
|
+
async function emitForUnitSpecs(root, signal) {
|
|
471
|
+
const { emitPreviewTreeOnce } = await import("./emit/preview-emitter.mjs"), emitted = await emitPreviewTreeOnce(root, { signal });
|
|
472
|
+
if (emitted.kind === "ok")
|
|
473
|
+
return;
|
|
474
|
+
return {
|
|
475
|
+
message: `Unit behaviour specs run against the emitted design system, and the current revision was not emitted (${emitted.error.kind}): fix what ads check reports, then run them again.`,
|
|
476
|
+
reason: "not-emitted",
|
|
477
|
+
elapsedMs: void 0,
|
|
478
|
+
output: void 0,
|
|
479
|
+
code: void 0
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
const xmlText = (value) => value.replace(/&(#x?[0-9a-fA-F]+|amp|lt|gt|quot|apos);/g, (entity, name) => {
|
|
483
|
+
if (name.startsWith("#x"))
|
|
484
|
+
return String.fromCodePoint(Number.parseInt(name.slice(2), 16));
|
|
485
|
+
if (name.startsWith("#"))
|
|
486
|
+
return String.fromCodePoint(Number(name.slice(1)));
|
|
487
|
+
return { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" }[name] ?? entity;
|
|
488
|
+
}), xmlAttribute = (attributes, name) => {
|
|
489
|
+
const match = new RegExp(`\\b${name}="([^"]*)"`).exec(attributes);
|
|
490
|
+
return match?.[1] === void 0 ? void 0 : xmlText(match[1]);
|
|
491
|
+
};
|
|
492
|
+
function writeUnitReport(junit, report, runId, root) {
|
|
493
|
+
if (!existsSync(junit))
|
|
494
|
+
return;
|
|
495
|
+
const cases = [];
|
|
496
|
+
for (const match of readFileSync(junit, "utf8").matchAll(/<testcase\b([^>]*?)(?:\/>|>([\s\S]*?)<\/testcase>)/g)) {
|
|
497
|
+
const attributes = match[1] ?? "", body = match[2] ?? "", name = xmlAttribute(attributes, "name") ?? "", file = xmlAttribute(attributes, "file"), failure = /<(?:failure|error)\b([^>]*)/.exec(body), status = failure ? "failed" : /<skipped\b/.test(body) ? "skipped" : "passed", seconds = Number(xmlAttribute(attributes, "time"));
|
|
498
|
+
for (const tag of name.matchAll(/(?:^|\s)@ads:([\w.-]+)(?=\s|$)/g))
|
|
499
|
+
cases.push({
|
|
500
|
+
id: tag[1],
|
|
501
|
+
file: file === void 0 ? "" : slash(path.relative(root, path.resolve(root, file))),
|
|
502
|
+
status,
|
|
503
|
+
...failure ? { message: (xmlAttribute(failure[1] ?? "", "message") ?? "failed").slice(0, 2000) } : {},
|
|
504
|
+
...Number.isFinite(seconds) ? { durationMs: Math.round(seconds * 1000) } : {}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
writeFileSync(report, JSON.stringify({ schemaVersion: 1, runId, complete: !0, cases }));
|
|
508
|
+
}
|
|
509
|
+
function runnerFault(error) {
|
|
510
|
+
const field = (name) => isRecord(error) ? error[name] : void 0, elapsedMs = field("elapsedMs"), output = field("output");
|
|
511
|
+
return {
|
|
512
|
+
message: thrownMessage(error),
|
|
513
|
+
reason: field("reason"),
|
|
514
|
+
elapsedMs: typeof elapsedMs === "number" ? elapsedMs : void 0,
|
|
515
|
+
output: typeof output === "string" ? output : void 0,
|
|
516
|
+
code: field("code")
|
|
517
|
+
};
|
|
518
|
+
}
|
|
497
519
|
function readReport(file, runId) {
|
|
498
|
-
if (!existsSync(file) || realpathSync(file) !== file || !lstatSync(file).isFile() || lstatSync(file).size >
|
|
499
|
-
throw
|
|
500
|
-
const value = JSON.parse(readFileSync(file, "utf8"));
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
520
|
+
if (!existsSync(file) || realpathSync(file) !== file || !lstatSync(file).isFile() || lstatSync(file).size > 1048576)
|
|
521
|
+
throw Error("Runner produced no valid bounded verification report. A successful exit alone is not passing evidence.");
|
|
522
|
+
const value = JSON.parse(readFileSync(file, "utf8")), cases = isRecord(value) ? value.cases : void 0, active = isRecord(value) ? value.active : void 0;
|
|
523
|
+
if (!isRecord(value) || value.schemaVersion !== 1 || value.runId !== runId || !Array.isArray(cases) || cases.length > 500 || active !== void 0 && (!Array.isArray(active) || active.length > 100))
|
|
524
|
+
throw Error("Runner report has the wrong run ID/schema or too many cases.");
|
|
525
|
+
return {
|
|
526
|
+
cases: cases.filter(isRecord),
|
|
527
|
+
active: Array.isArray(active) ? active.filter(isRecord) : void 0,
|
|
528
|
+
complete: value.complete,
|
|
529
|
+
errors: value.errors,
|
|
530
|
+
workers: value.workers
|
|
531
|
+
};
|
|
510
532
|
}
|
|
511
|
-
|
|
533
|
+
const isRunning = (item) => item.state === "running", caseFile = (check) => slash(path.posix.join(path.posix.dirname(slash(check.contract.file)), check.file));
|
|
512
534
|
function runProgress(group, report, startedAt, profile, timeoutMs) {
|
|
513
|
-
const
|
|
514
|
-
unit: check.unit,
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
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
|
-
};
|
|
535
|
+
const cases = group.map((check) => {
|
|
536
|
+
const file = caseFile(check), matches = report?.cases.filter((item) => item.id === check.case && item.file === file) ?? [], running = report?.active?.find((item) => item.id === check.case && item.file === file), last = matches.at(-1), reported = last ? { reportedStatus: last.status, durationMs: matches.reduce((sum, item) => sum + finiteDuration(item.durationMs), 0) } : void 0, subject = { unit: check.unit, check: check.id };
|
|
537
|
+
if (running)
|
|
538
|
+
return {
|
|
539
|
+
...subject,
|
|
540
|
+
state: "running",
|
|
541
|
+
elapsedMs: Math.max(0, Date.now() - Date.parse(String(running.startedAt))) || 0,
|
|
542
|
+
workerIndex: running.workerIndex,
|
|
543
|
+
...reported
|
|
544
|
+
};
|
|
545
|
+
if (reported)
|
|
546
|
+
return { ...subject, state: "completed", ...reported };
|
|
547
|
+
return { ...subject, state: report?.active ? "not_started" : "not_reported" };
|
|
534
548
|
});
|
|
535
549
|
return {
|
|
536
550
|
profile,
|
|
@@ -538,108 +552,145 @@ function runProgress(group, report, startedAt, profile, timeoutMs) {
|
|
|
538
552
|
timeoutMs,
|
|
539
553
|
total: cases.length,
|
|
540
554
|
completed: cases.filter((item) => item.state === "completed").length,
|
|
541
|
-
active: cases.filter(
|
|
542
|
-
pending: cases.filter((item) =>
|
|
555
|
+
active: cases.filter(isRunning),
|
|
556
|
+
pending: cases.filter((item) => item.state === "not_started" || item.state === "not_reported").length,
|
|
543
557
|
cases,
|
|
544
|
-
...
|
|
558
|
+
...typeof report?.workers === "number" && Number.isSafeInteger(report.workers) ? { workers: report.workers } : {}
|
|
545
559
|
};
|
|
546
560
|
}
|
|
547
|
-
|
|
548
|
-
/** Registered development commands are trusted project code, never model-supplied commands. */
|
|
549
561
|
export async function verificationPlan(options, { unit, units, checks } = {}) {
|
|
550
|
-
const inventory = await
|
|
551
|
-
|
|
562
|
+
const inventory = await registeredBehaviors(options), fail = (diagnostics) => ({ inventory, selection: [], diagnostics });
|
|
563
|
+
if (!inventory.contracts.length && !inventory.diagnostics.length)
|
|
564
|
+
return { inventory, selection: [], diagnostics: [], ...notAvailable("no-behavior-checks") };
|
|
552
565
|
if (inventory.diagnostics.length)
|
|
553
566
|
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));
|
|
567
|
+
const selectedUnits = new Set(units ?? (unit ? [unit] : inventory.contracts.map((item) => item.unit))), contracts = inventory.contracts.filter((item) => selectedUnits.has(item.unit));
|
|
556
568
|
if (!contracts.length || [...selectedUnits].some((id) => !contracts.some((contract) => contract.unit === id)))
|
|
557
569
|
return fail([
|
|
558
|
-
{ rule: "behavior-selection", message: "No behavior
|
|
570
|
+
{ rule: "behavior-selection", message: "No registered behavior checks match the complete selection. Discover exact owner/check IDs with ads_behaviors." }
|
|
559
571
|
]);
|
|
560
|
-
const context = await inputContext(options)
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
...check,
|
|
568
|
-
inputRevision: (await behaviorInputs(options, contract, check, context)).revision,
|
|
569
|
-
contract,
|
|
570
|
-
}),
|
|
571
|
-
),
|
|
572
|
-
);
|
|
572
|
+
const context = await inputContext(options), selection = await flatMapAsync(contracts, async (contract) => mapAsync(Object.entries(contract.checks).filter(([id]) => !checks || checks.includes(id)), async ([id, check]) => ({
|
|
573
|
+
unit: contract.unit,
|
|
574
|
+
id,
|
|
575
|
+
...check,
|
|
576
|
+
inputRevision: (await behaviorInputs(options, contract, check, context)).revision,
|
|
577
|
+
contract
|
|
578
|
+
})));
|
|
573
579
|
if (!selection.length || checks?.some((id) => !selection.some((check) => check.id === id)))
|
|
574
580
|
return fail([{ rule: "behavior-selection", message: "Unknown check selection. Use check IDs returned by ads_behaviors." }]);
|
|
575
581
|
return { inventory, selection, diagnostics: [] };
|
|
576
582
|
}
|
|
577
|
-
|
|
578
583
|
export async function behaviorRevisions(options, checks) {
|
|
579
584
|
const context = await inputContext(options);
|
|
580
585
|
return mapAsync(checks, async (check) => (await behaviorInputs(options, check.contract, check, context)).revision);
|
|
581
586
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
587
|
+
const isWireDiagnostic = (value) => isRecord(value) && typeof value.rule === "string" && typeof value.message === "string" && (value.failure === void 0 || isReportedFailure(value.failure)), isPlannedContract = (value) => isRecord(value) && typeof value.unit === "string" && isRecord(value.checks), isPlannedCheckView = (value) => isRecord(value) && ["unit", "id", "file", "case", "profile", "inputRevision"].every((key) => typeof value[key] === "string") && (value.scenario === void 0 || typeof value.scenario === "string") && isRecord(value.contract) && typeof value.contract.file === "string";
|
|
588
|
+
function planView(value) {
|
|
589
|
+
if (isRecord(value) && value.status === "not-available")
|
|
590
|
+
return { kind: "unavailable", unavailable: notAvailable("no-behavior-checks") };
|
|
591
|
+
const diagnostics = isRecord(value) ? value.diagnostics : void 0;
|
|
592
|
+
if (Array.isArray(diagnostics) && diagnostics.length) {
|
|
593
|
+
if (diagnostics.every(isWireDiagnostic))
|
|
594
|
+
return { kind: "rejected", diagnostics };
|
|
595
|
+
} else if (isRecord(value)) {
|
|
596
|
+
const { inventory, selection } = value, contracts = isRecord(inventory) ? inventory.contracts : void 0;
|
|
597
|
+
if (Array.isArray(contracts) && contracts.every(isPlannedContract) && Array.isArray(selection) && selection.every(isPlannedCheckView))
|
|
598
|
+
return { kind: "planned", contracts, selection };
|
|
599
|
+
}
|
|
600
|
+
throw TypeError("The analysis worker returned no verification plan.");
|
|
601
|
+
}
|
|
602
|
+
function revisionsView(value) {
|
|
603
|
+
if (Array.isArray(value) && value.every((item) => typeof item === "string"))
|
|
604
|
+
return value;
|
|
605
|
+
throw TypeError("The analysis worker returned no behavior revisions.");
|
|
606
|
+
}
|
|
607
|
+
function verificationResult(diagnostics, results) {
|
|
608
|
+
const ok = diagnostics.length === 0 && results.length > 0 && results.every((result) => result.status === "passed" && result.current);
|
|
609
|
+
return {
|
|
610
|
+
ok,
|
|
611
|
+
diagnostics: diagnostics.map((diagnostic) => ({ ...diagnostic, failure: diagnostic.failure ?? failure("runner", "verification", diagnostic.rule) })),
|
|
612
|
+
results,
|
|
613
|
+
acceptance: acceptance("selected-behavior-checks", ok, results.filter((result) => result.status === "passed" && result.current).map((result) => `${result.unit}#${result.check}`), ["unselected-checks", "unasserted-behavior", "visual-parity", "accessibility-audit"])
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function foldReportedStatus(matches) {
|
|
617
|
+
return matches.length && matches.every((item) => item.status === "passed") ? "passed" : matches.length && matches.every((item) => item.status === "skipped") ? "skipped" : "failed";
|
|
618
|
+
}
|
|
619
|
+
function checkOutcome(matches, verdict) {
|
|
620
|
+
const blockedRun = !!verdict.runnerFault || verdict.runnerFailed && !verdict.caseFailureExit;
|
|
621
|
+
let status = matches.some((item) => item.status === "failed") ? "failed" : !matches.length || blockedRun ? verdict.reported ? "incomplete" : "failed" : foldReportedStatus(matches);
|
|
622
|
+
if (verdict.runnerFault?.code === "ENOENT")
|
|
623
|
+
status = "unavailable";
|
|
624
|
+
if (!verdict.current)
|
|
625
|
+
status = "stale";
|
|
626
|
+
if (verdict.cancelled)
|
|
627
|
+
status = "cancelled";
|
|
628
|
+
if (status === "passed")
|
|
629
|
+
return { status };
|
|
630
|
+
const caseDetail = matches.find((item) => item.status !== "passed") ?? matches.at(-1), reportedFailure = caseDetail?.failure, reason = verdict.runnerFault?.reason;
|
|
631
|
+
return {
|
|
632
|
+
status,
|
|
633
|
+
failure: status === "stale" || status === "cancelled" ? failure("runner", "verification", `ADS_${status.toUpperCase()}`) : caseDetail?.status === "failed" && isReportedFailure(reportedFailure) ? reportedFailure : blockedRun ? failure("runner", "profile-execution", typeof reason === "string" ? reason : "ADS_RUNNER_INCOMPLETE", { certainty: "observed-boundary" }) : failure("runner", "test-execution", "ADS_CASE_UNCLASSIFIED", { certainty: "unclassified" })
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
637
|
+
export function createVerificationController(directory, { reportRoot: reportDirectory = directory, onProgress, previewWork, previewHost } = {}) {
|
|
638
|
+
const root = path.resolve(directory), reportRoot = path.resolve(reportDirectory);
|
|
588
639
|
let active, progress, owned;
|
|
589
640
|
const closeOwned = async () => {
|
|
590
641
|
const current = owned;
|
|
591
|
-
owned =
|
|
642
|
+
owned = void 0;
|
|
592
643
|
await current?.close();
|
|
593
644
|
};
|
|
594
645
|
return {
|
|
595
|
-
status: () => ({ running: !!active, ...
|
|
646
|
+
status: () => ({ running: !!active, ...active && progress ? { progress: { ...progress, elapsedMs: Date.now() - progress.startedAt } } : {} }),
|
|
596
647
|
async close() {
|
|
597
|
-
active?.abort();
|
|
648
|
+
active?.controller.abort();
|
|
598
649
|
await active?.completion;
|
|
599
650
|
await closeOwned();
|
|
600
651
|
},
|
|
601
|
-
async run({ unit, units, checks, persist =
|
|
602
|
-
if (active)
|
|
603
|
-
|
|
604
|
-
const controller =
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
|
|
652
|
+
async run({ unit, units, checks, persist = !0 } = {}, outerSignal, notifyProgress) {
|
|
653
|
+
if (active)
|
|
654
|
+
return verificationResult([{ rule: "behavior-busy", message: "A behavior verification is already running." }], []);
|
|
655
|
+
const controller = new AbortController;
|
|
656
|
+
let finish = () => {};
|
|
657
|
+
const run = {
|
|
658
|
+
controller,
|
|
659
|
+
completion: new Promise((resolve) => {
|
|
660
|
+
finish = resolve;
|
|
661
|
+
})
|
|
662
|
+
};
|
|
663
|
+
active = run;
|
|
664
|
+
const signal = outerSignal ? AbortSignal.any([outerSignal, controller.signal]) : controller.signal;
|
|
665
|
+
let host, releasePreview, broken = !1;
|
|
666
|
+
const results = [], diagnostics = [];
|
|
615
667
|
try {
|
|
616
|
-
if (previewWork)
|
|
617
|
-
|
|
618
|
-
const plan = await analyze(root, "verification-plan", [{ unit, units, checks }], signal);
|
|
619
|
-
if (plan.
|
|
620
|
-
|
|
668
|
+
if (previewWork)
|
|
669
|
+
releasePreview = await previewWork.acquire(signal);
|
|
670
|
+
const options = loadConfig(root), plan = planView(await analyze(root, "verification-plan", [{ unit, units, checks }], signal));
|
|
671
|
+
if (plan.kind === "unavailable")
|
|
672
|
+
return { ...verificationResult([], results), ...plan.unavailable };
|
|
673
|
+
if (plan.kind === "rejected")
|
|
674
|
+
return verificationResult(plan.diagnostics, results);
|
|
675
|
+
const { contracts, selection } = plan;
|
|
621
676
|
for (const profileName of new Set(selection.map((check) => check.profile))) {
|
|
622
677
|
const profile = options.config.mcp.behaviorProfiles[profileName];
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
678
|
+
if (!profile)
|
|
679
|
+
throw Error(`Behavior profile ${profileName} is not one of ADS's built-in profiles.`);
|
|
680
|
+
const mode = profile.mode, timeoutMs = profile.timeoutMs ?? 60000, group = selection.filter((check) => check.profile === profileName), directory = path.join(reportRoot, ".ds/verification", randomUUID());
|
|
681
|
+
mkdirSync(directory, { recursive: !0 });
|
|
626
682
|
trackExecutionArtifact(reportRoot, directory);
|
|
627
|
-
if (realpathSync(directory) !== directory)
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
const
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
// single graph avoids repeated compilation and startup handovers.
|
|
637
|
-
await host.warmScenarios([...new Set(group.map((check) => check.scenario).filter(Boolean))], signal);
|
|
638
|
-
for (const check of group.filter((check) => check.scenario)) {
|
|
639
|
-
const url = new URL(host.url);
|
|
640
|
-
url.searchParams.set("scenario", check.scenario);
|
|
683
|
+
if (realpathSync(directory) !== directory)
|
|
684
|
+
throw Error("Verification output cannot resolve through a symlink.");
|
|
685
|
+
const runId = randomUUID(), report = path.join(directory, "report.json"), request = path.join(directory, "request.json"), scenarios = {}, scenarioIds = group.flatMap((check) => check.scenario ? [check.scenario] : []);
|
|
686
|
+
if (mode !== "unit" && scenarioIds.length) {
|
|
687
|
+
const { startAdsMcp } = await import("./mcp/server.mjs"), preview = host ??= previewHost ?? (owned ??= await startAdsMcp(root, { stdio: !1, showcase: !0 }));
|
|
688
|
+
await preview.warmScenarios([...new Set(scenarioIds)], signal);
|
|
689
|
+
for (const scenario of scenarioIds) {
|
|
690
|
+
const url = new URL(preview.url);
|
|
691
|
+
url.searchParams.set("scenario", scenario);
|
|
641
692
|
url.searchParams.set("waitFor", "verified");
|
|
642
|
-
scenarios[
|
|
693
|
+
scenarios[scenario] = url.href;
|
|
643
694
|
}
|
|
644
695
|
}
|
|
645
696
|
const requestContext = {
|
|
@@ -648,159 +699,102 @@ export function createVerificationController(root, { reportRoot = root, onProgre
|
|
|
648
699
|
projectRoot: root,
|
|
649
700
|
framework: options.config.framework,
|
|
650
701
|
profile: profileName,
|
|
651
|
-
mode
|
|
702
|
+
mode,
|
|
652
703
|
checks: group.map(({ contract: _contract, ...check }) => check),
|
|
653
|
-
scenarios
|
|
704
|
+
scenarios
|
|
654
705
|
};
|
|
655
706
|
writeFileSync(request, JSON.stringify(requestContext));
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const update = (value) => {
|
|
669
|
-
progress = { ...runProgress(group, value, startedAt, profileName, profile.timeoutMs ?? 60000), startedAt };
|
|
670
|
-
onProgress?.(progress);
|
|
671
|
-
notifyProgress?.(progress);
|
|
707
|
+
const unit = mode === "unit", junit = path.join(directory, "junit.xml"), command = { command: "runtime", timeoutMs, label: `Behavior profile ${profileName}` };
|
|
708
|
+
let emitFault;
|
|
709
|
+
const args = unit ? unitSpecArgs(root, group, junit, timeoutMs) : await browserSpecArgs(root, directory, group, options.config.mcp.capture, timeoutMs, signal);
|
|
710
|
+
if (unit)
|
|
711
|
+
emitFault = await emitForUnitSpecs(root, signal);
|
|
712
|
+
let commandRun, reportValue, fault;
|
|
713
|
+
const startedAt = Date.now(), update = (value) => {
|
|
714
|
+
const next = { ...runProgress(group, value, startedAt, profileName, timeoutMs), startedAt };
|
|
715
|
+
progress = next;
|
|
716
|
+
onProgress?.(next);
|
|
717
|
+
notifyProgress?.(next);
|
|
718
|
+
return next;
|
|
672
719
|
};
|
|
673
|
-
update();
|
|
674
|
-
let lastSnapshot = "",
|
|
675
|
-
lastUpdate = Date.now();
|
|
720
|
+
let latest = update(), lastSnapshot = "", lastUpdate = Date.now();
|
|
676
721
|
const monitor = setInterval(() => {
|
|
677
722
|
let value;
|
|
678
723
|
try {
|
|
679
724
|
value = readReport(report, runId);
|
|
680
|
-
} catch {
|
|
681
|
-
/* An absent/invalid intermediate snapshot cannot provide evidence. */
|
|
682
|
-
}
|
|
725
|
+
} catch {}
|
|
683
726
|
const snapshot = JSON.stringify(value);
|
|
684
727
|
if (snapshot !== lastSnapshot || Date.now() - lastUpdate >= 5000) {
|
|
685
728
|
lastSnapshot = snapshot;
|
|
686
729
|
lastUpdate = Date.now();
|
|
687
|
-
update(value);
|
|
730
|
+
latest = update(value);
|
|
688
731
|
}
|
|
689
732
|
}, 250);
|
|
690
733
|
try {
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
root,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
734
|
+
if (emitFault !== void 0)
|
|
735
|
+
fault = emitFault;
|
|
736
|
+
else {
|
|
737
|
+
commandRun = await executeDevelopmentCommand(command, args, root, { ADS_VERIFY_REQUEST: request, ADS_VERIFY_REPORT: report, ADS_VERIFY_MODE: mode, ...unit ? { ADS_UNIT_PROJECT: root } : {} }, signal);
|
|
738
|
+
if (unit)
|
|
739
|
+
writeUnitReport(junit, report, runId, root);
|
|
740
|
+
}
|
|
698
741
|
} catch (error) {
|
|
699
|
-
|
|
742
|
+
fault = runnerFault(error);
|
|
700
743
|
} finally {
|
|
701
744
|
clearInterval(monitor);
|
|
702
745
|
}
|
|
703
746
|
try {
|
|
704
747
|
reportValue = readReport(report, runId);
|
|
705
748
|
} catch (error) {
|
|
706
|
-
|
|
749
|
+
fault ??= runnerFault(error);
|
|
707
750
|
}
|
|
708
|
-
update(reportValue);
|
|
709
|
-
|
|
710
|
-
|
|
751
|
+
latest = update(reportValue);
|
|
752
|
+
const finalProgress = latest;
|
|
753
|
+
if (fault) {
|
|
754
|
+
const detail = `${finalProgress.completed}/${finalProgress.total} checks completed; ${finalProgress.pending} without a completed/active result. Active: ${finalProgress.active.map((item) => `${item.unit}#${item.check} (${Math.round(item.elapsedMs)} ms)`).join(", ") || "none reported"}.`;
|
|
711
755
|
diagnostics.push({
|
|
712
756
|
rule: "behavior-runner",
|
|
713
|
-
message: `${
|
|
714
|
-
reason:
|
|
715
|
-
elapsedMs:
|
|
716
|
-
progress,
|
|
717
|
-
output:
|
|
718
|
-
profile: profileName
|
|
757
|
+
message: `${fault.message} ${detail}`,
|
|
758
|
+
reason: fault.reason,
|
|
759
|
+
elapsedMs: fault.elapsedMs ?? Date.now() - startedAt,
|
|
760
|
+
progress: finalProgress,
|
|
761
|
+
output: fault.output?.slice(-4000),
|
|
762
|
+
profile: profileName
|
|
719
763
|
});
|
|
720
764
|
}
|
|
721
|
-
const suiteErrors = Array.isArray(reportValue?.errors) ? reportValue.errors.slice(0, 5).map((error) => String(error).slice(0, 1000)) : []
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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;
|
|
740
|
-
if (runnerFailure) {
|
|
741
|
-
const caseFailures =
|
|
742
|
-
reportValue?.cases.filter((item) => item.status === "failed" && failureCategories.has(item.failure?.category)).map((item) => item.failure) ?? [];
|
|
765
|
+
const suiteErrors = Array.isArray(reportValue?.errors) ? reportValue.errors.slice(0, 5).map((error) => String(error).slice(0, 1000)) : [], incompleteReport = reportValue?.complete === !1 || finalProgress.pending > 0 || finalProgress.active.length > 0, failedCases = reportValue?.cases.filter((item) => item.status === "failed") ?? [], caseFailureExit = commandRun?.code === 1 && !fault && !suiteErrors.length && !incompleteReport && failedCases.length > 0, exit = commandRun && (commandRun.code !== 0 || suiteErrors.length || incompleteReport) ? {
|
|
766
|
+
code: commandRun.code,
|
|
767
|
+
message: `Registered runner ${profileName} ${commandRun.code !== 0 ? `exited with code ${commandRun.code ?? "unknown"}` : incompleteReport ? "left an incomplete report" : "reported a suite error"}. ${suiteErrors.join("; ") || failedCases.slice(0, 3).map((item) => `${String(item.id)}: ${String(item.message || "failed without a case diagnostic")}`).join("; ") || "Inspect the runner output and verification report."}`.slice(0, 3000)
|
|
768
|
+
} : void 0;
|
|
769
|
+
if (exit && commandRun) {
|
|
770
|
+
const caseFailures = failedCases.flatMap((item) => isReportedFailure(item.failure) ? [item.failure] : []), [firstCaseFailure] = caseFailures;
|
|
743
771
|
diagnostics.push({
|
|
744
772
|
rule: "behavior-runner",
|
|
745
|
-
message:
|
|
746
|
-
output:
|
|
773
|
+
message: exit.message,
|
|
774
|
+
output: commandRun.output.slice(-4000),
|
|
747
775
|
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" }),
|
|
776
|
+
failure: caseFailureExit && firstCaseFailure ? { ...firstCaseFailure, phase: "case-results", relatedCategories: [...new Set(caseFailures.map((item) => item.category))] } : failure("runner", "profile-execution", "ADS_RUNNER_EXIT", { certainty: caseFailureExit ? "unclassified" : "observed-boundary" })
|
|
752
777
|
});
|
|
753
778
|
}
|
|
754
|
-
const afterRevisions = await analyze(root, "behavior-revisions", [group]);
|
|
779
|
+
const afterRevisions = revisionsView(await analyze(root, "behavior-revisions", [group]));
|
|
755
780
|
for (const [checkIndex, check] of group.entries()) {
|
|
756
|
-
const file = slash(path.relative(root, path.resolve(root, path.dirname(check.contract.file), check.file)))
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
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;
|
|
772
|
-
if (runnerError?.code === "ENOENT") status = "unavailable";
|
|
773
|
-
const current = afterRevisions[checkIndex] === check.inputRevision;
|
|
774
|
-
if (!current) status = "stale";
|
|
775
|
-
if (signal.aborted) status = "cancelled";
|
|
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 = {
|
|
781
|
+
const file = slash(path.relative(root, path.resolve(root, path.dirname(check.contract.file), check.file))), matches = reportValue?.cases.filter((item) => item.id === check.case && item.file === file) ?? [], reportedStatus = foldReportedStatus(matches), current = afterRevisions[checkIndex] === check.inputRevision, outcome = checkOutcome(matches, {
|
|
782
|
+
runnerFault: fault,
|
|
783
|
+
runnerFailed: !!exit,
|
|
784
|
+
caseFailureExit,
|
|
785
|
+
reported: !!reportValue,
|
|
786
|
+
current,
|
|
787
|
+
cancelled: signal.aborted
|
|
788
|
+
}), outcomeFailure = outcome.status === "passed" ? {} : { failure: outcome.failure }, passed = outcome.status === "passed" && current, caseDetail = matches.find((item) => item.status !== "passed") ?? matches.at(-1), caseDiagnostics = matches.flatMap((item) => recordedList(item.diagnostics)), execution = finalProgress.cases.find((item) => item.unit === check.unit && item.check === check.id)?.state, accepted = acceptance("registered-case", passed, passed ? ["registered-case-completed"] : [], ["unasserted-behavior", "visual-parity", "accessibility-audit"]), completedAt = new Date().toISOString(), investigation = {
|
|
795
789
|
unit: check.unit,
|
|
796
790
|
check: check.id,
|
|
797
|
-
status,
|
|
791
|
+
status: outcome.status,
|
|
798
792
|
runId,
|
|
799
793
|
resourceUri: investigationUri({ unit: check.unit, check: check.id }),
|
|
800
794
|
target: root === reportRoot ? "project" : "candidate",
|
|
801
795
|
framework: options.config.framework,
|
|
802
796
|
profile: profileName,
|
|
803
|
-
mode
|
|
797
|
+
mode,
|
|
804
798
|
scenario: check.scenario ?? null,
|
|
805
799
|
inputRevision: check.inputRevision,
|
|
806
800
|
inputsCurrentAtCompletion: current,
|
|
@@ -808,24 +802,13 @@ export function createVerificationController(root, { reportRoot = root, onProgre
|
|
|
808
802
|
failingStep: caseDetail?.failingStep ?? null,
|
|
809
803
|
viewport: caseDetail?.viewport ?? null,
|
|
810
804
|
viewportSource: caseDetail?.viewportSource ?? null,
|
|
811
|
-
observedPreviewRevision:
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
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
|
-
),
|
|
805
|
+
observedPreviewRevision: caseDiagnostics.filter(isRecord).findLast((item) => item.kind === "preview-startup")?.previewRevision ?? null,
|
|
806
|
+
requests: caseDiagnostics.flatMap((item) => recordedList(isRecord(item) ? item.requests : void 0)).slice(0, 8),
|
|
807
|
+
browserErrors: caseDiagnostics.flatMap((item) => recordedList(isRecord(item) ? item.errors : void 0)).slice(0, 3),
|
|
808
|
+
artifacts: investigationArtifacts(reportRoot, report, matches.flatMap((item) => recordedList(item.artifacts))),
|
|
826
809
|
acceptance: accepted,
|
|
827
|
-
...
|
|
828
|
-
completedAt
|
|
810
|
+
...outcomeFailure,
|
|
811
|
+
completedAt
|
|
829
812
|
};
|
|
830
813
|
results.push({
|
|
831
814
|
unit: check.unit,
|
|
@@ -833,79 +816,63 @@ export function createVerificationController(root, { reportRoot = root, onProgre
|
|
|
833
816
|
file: check.file,
|
|
834
817
|
case: check.case,
|
|
835
818
|
profile: profileName,
|
|
836
|
-
status,
|
|
819
|
+
status: outcome.status,
|
|
837
820
|
current,
|
|
838
821
|
revision: check.inputRevision,
|
|
839
822
|
runId,
|
|
840
|
-
completedAt
|
|
841
|
-
...
|
|
823
|
+
completedAt,
|
|
824
|
+
...outcomeFailure,
|
|
842
825
|
acceptance: accepted,
|
|
843
826
|
investigation,
|
|
844
|
-
previewRevision: profile.mode === "browser" ?
|
|
845
|
-
...
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
? { startupDiagnostics: matches.flatMap((item) => (Array.isArray(item.diagnostics) ? item.diagnostics.slice(0, 5) : [])).slice(0, 10) }
|
|
850
|
-
: {}),
|
|
851
|
-
...(runnerFailure ? { runnerExitCode: run.code } : {}),
|
|
852
|
-
execution: progress.cases.find((item) => item.unit === check.unit && item.check === check.id)?.state,
|
|
827
|
+
previewRevision: profile.mode === "browser" ? host?.previewRevision() ?? readPreviewManifest(options)?.revision ?? null : null,
|
|
828
|
+
...matches.length ? { reportedStatus, durationMs: matches.reduce((sum, item) => sum + finiteDuration(item.durationMs), 0) } : {},
|
|
829
|
+
...matches.some((item) => Array.isArray(item.diagnostics) && item.diagnostics.length) ? { startupDiagnostics: matches.flatMap((item) => Array.isArray(item.diagnostics) ? item.diagnostics.slice(0, 5) : []).slice(0, 10) } : {},
|
|
830
|
+
...exit ? { runnerExitCode: exit.code } : {},
|
|
831
|
+
execution,
|
|
853
832
|
message: [
|
|
854
|
-
matches
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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)),
|
|
833
|
+
matches.filter((item) => item.status !== "passed").map((item) => String(item.message || `Case reported ${String(item.status)} without a diagnostic.`).slice(0, 2000)).join(`
|
|
834
|
+
`),
|
|
835
|
+
fault ? `${fault.message} This check ${matches.length ? `reported ${reportedStatus}` : `was ${execution ?? "not reported"}`}; the complete run did not pass.` : !matches.length ? "The selected case did not execute/report. Missing and skipped cases do not pass." : exit ? `This case reported ${reportedStatus}, but the complete run did not pass. ${exit.message}` : ""
|
|
836
|
+
].filter(Boolean).join(`
|
|
837
|
+
`),
|
|
838
|
+
report: slash(path.relative(reportRoot, report))
|
|
869
839
|
});
|
|
870
840
|
}
|
|
871
|
-
if (signal.aborted)
|
|
841
|
+
if (signal.aborted)
|
|
842
|
+
break;
|
|
872
843
|
}
|
|
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
|
-
);
|
|
844
|
+
saveInvestigations(reportRoot, results.map((result) => result.investigation), contracts.flatMap((contract) => Object.keys(contract.checks).map((id) => identity(contract.unit, id))));
|
|
878
845
|
if (persist) {
|
|
879
846
|
const evidence = saved(root);
|
|
880
|
-
for (const result of results)
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
throw new Error("Verification evidence exceeds 2 MiB. Remove obsolete generated evidence and retry.");
|
|
847
|
+
for (const result of results)
|
|
848
|
+
evidence[identity(result.unit, result.check)] = result;
|
|
849
|
+
const file = resultFile(root), temporary = `${file}.${randomUUID()}.tmp`, content = JSON.stringify({ schemaVersion: 1, results: evidence });
|
|
850
|
+
if (Buffer.byteLength(content) > 2097152)
|
|
851
|
+
throw Error("Verification evidence exceeds 2 MiB. Remove obsolete generated evidence and retry.");
|
|
886
852
|
try {
|
|
887
853
|
writeFileSync(temporary, content);
|
|
888
854
|
renameSync(temporary, file);
|
|
889
855
|
} finally {
|
|
890
|
-
rmSync(temporary, { force:
|
|
856
|
+
rmSync(temporary, { force: !0 });
|
|
891
857
|
}
|
|
892
858
|
}
|
|
893
859
|
return verificationResult(diagnostics, results);
|
|
894
860
|
} catch (error) {
|
|
895
|
-
broken =
|
|
896
|
-
return verificationResult([{ rule: "behavior-verification", message: error
|
|
861
|
+
broken = !0;
|
|
862
|
+
return verificationResult([{ rule: "behavior-verification", message: thrownMessage(error) }], results);
|
|
897
863
|
} finally {
|
|
898
864
|
try {
|
|
899
|
-
if (host && host === owned && (broken || signal.aborted))
|
|
865
|
+
if (host && host === owned && (broken || signal.aborted))
|
|
866
|
+
await closeOwned();
|
|
900
867
|
} finally {
|
|
901
868
|
releasePreview?.();
|
|
902
|
-
if (active ===
|
|
903
|
-
active =
|
|
904
|
-
progress =
|
|
869
|
+
if (active === run) {
|
|
870
|
+
active = void 0;
|
|
871
|
+
progress = void 0;
|
|
905
872
|
}
|
|
906
873
|
finish();
|
|
907
874
|
}
|
|
908
875
|
}
|
|
909
|
-
}
|
|
876
|
+
}
|
|
910
877
|
};
|
|
911
878
|
}
|