stylegallery 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +156 -0
- package/CATALOG.md +69 -0
- package/DOMAINS.md +65 -0
- package/GOVERNANCE.md +222 -0
- package/GUIDE.md +59 -0
- package/README.md +313 -0
- package/consumer-reference/adapters/style-dictionary.config.mjs +36 -0
- package/consumer-reference/agent-native/README.md +157 -0
- package/consumer-reference/agent-native/registry.json +640 -0
- package/consumer-reference/agent-native/schema/agent-native.schema.json +848 -0
- package/consumer-reference/agent-native/schema/epistemic.schema.json +14 -0
- package/consumer-reference/agent-native/schema/execution.schema.json +12 -0
- package/consumer-reference/agent-native/schema/identity.schema.json +10 -0
- package/consumer-reference/agent-native/schema/learning.schema.json +12 -0
- package/consumer-reference/agent-native/schema/manifest.schema.json +6 -0
- package/consumer-reference/agent-native/schema/operation.schema.json +12 -0
- package/consumer-reference/agent-native/schema/protocol-binding.schema.json +9 -0
- package/consumer-reference/agent-native/schema/retrieval.schema.json +10 -0
- package/consumer-reference/baselines/calibration.json +260 -0
- package/consumer-reference/baselines/manifest.json +21 -0
- package/consumer-reference/contract.md +83 -0
- package/consumer-reference/fixtures/consumer-conformance/e2e-fixture.mjs +282 -0
- package/consumer-reference/fixtures/consumer-conformance/manifest.json +102 -0
- package/consumer-reference/fixtures/consumer-conformance/runtime-proof.mjs +32 -0
- package/consumer-reference/fixtures/consumer-conformance/valid-migration-result.json +18 -0
- package/consumer-reference/fixtures/consumer-conformance/valid-migration.json +142 -0
- package/consumer-reference/fixtures/invalid-stable-ended-support.json +19 -0
- package/consumer-reference/fixtures/promotion/invalid-blocking-evidence.json +26 -0
- package/consumer-reference/fixtures/promotion/invalid-count-only.json +29 -0
- package/consumer-reference/fixtures/promotion/invalid-missing-owner-migration.json +25 -0
- package/consumer-reference/fixtures/promotion/invalid-normative-bypass-no-regression.json +25 -0
- package/consumer-reference/fixtures/promotion/invalid-related-counted-independent.json +45 -0
- package/consumer-reference/fixtures/promotion/invalid-stable-ended-support.json +26 -0
- package/consumer-reference/fixtures/promotion/manifest.json +15 -0
- package/consumer-reference/fixtures/promotion/valid-deferred-example.json +67 -0
- package/consumer-reference/fixtures/promotion/valid-normative-bypass.json +67 -0
- package/consumer-reference/fixtures/token-portability/invalid-cycle.json +7 -0
- package/consumer-reference/fixtures/token-portability/invalid-dangling-alias.json +6 -0
- package/consumer-reference/fixtures/token-portability/invalid-extends.json +4 -0
- package/consumer-reference/fixtures/token-portability/invalid-json-pointer.json +7 -0
- package/consumer-reference/fixtures/token-portability/invalid-resolver.json +9 -0
- package/consumer-reference/fixtures/token-portability/invalid-type-mismatch.json +10 -0
- package/consumer-reference/fixtures/token-portability/invalid-unknown-reserved.json +6 -0
- package/consumer-reference/fixtures/token-portability/invalid-untested-type.json +6 -0
- package/consumer-reference/fixtures/token-portability/valid-border.json +14 -0
- package/consumer-reference/fixtures/token-portability/valid-reference.json +32 -0
- package/consumer-reference/fixtures/token-portability/valid-whole-alias.json +7 -0
- package/consumer-reference/fixtures/valid-deprecated.json +21 -0
- package/consumer-reference/fixtures/valid-experimental.json +19 -0
- package/consumer-reference/generated/manifest.json +40 -0
- package/consumer-reference/generated/tokens.css +12 -0
- package/consumer-reference/index.md +32 -0
- package/consumer-reference/policies/shared-experimental.json +37 -0
- package/consumer-reference/schema/ax-evidence.schema.json +30 -0
- package/consumer-reference/schema/baseline-manifest.schema.json +55 -0
- package/consumer-reference/schema/calibration-record.schema.json +190 -0
- package/consumer-reference/schema/capture-session.schema.json +161 -0
- package/consumer-reference/schema/component-state.schema.json +150 -0
- package/consumer-reference/schema/consumer-conformance-record.schema.json +365 -0
- package/consumer-reference/schema/dom-evidence.schema.json +38 -0
- package/consumer-reference/schema/evidence-record.schema.json +81 -0
- package/consumer-reference/schema/fixture-manifest.schema.json +32 -0
- package/consumer-reference/schema/item.schema.json +188 -0
- package/consumer-reference/schema/page-evidence-manifest.schema.json +216 -0
- package/consumer-reference/schema/page-evidence-session.schema.json +119 -0
- package/consumer-reference/schema/portable-tokens.schema.json +104 -0
- package/consumer-reference/schema/promotion-rfc.schema.json +219 -0
- package/consumer-reference/schema/runtime-evidence-manifest.schema.json +33 -0
- package/consumer-reference/schema/visual-evidence.schema.json +31 -0
- package/design-engineering/consumer-migration-readiness.md +124 -0
- package/design-engineering/index.md +28 -0
- package/design-engineering/interface-craft.md +107 -0
- package/design-engineering/reference-profiles/external-adaptation/index.md +12 -0
- package/design-engineering/reference-profiles/governed-local/editorial/components/button.component.json +125 -0
- package/design-engineering/reference-profiles/governed-local/editorial/evidence/button.evidence.json +3504 -0
- package/design-engineering/reference-profiles/governed-local/editorial/fixtures/button.fixture.json +65 -0
- package/design-engineering/reference-profiles/governed-local/editorial/generated/evidence-coverage.md +23 -0
- package/design-engineering/reference-profiles/governed-local/editorial/generated/keyboard-matrix.md +19 -0
- package/design-engineering/reference-profiles/governed-local/editorial/generated/state-matrix.md +21 -0
- package/design-engineering/reference-profiles/governed-local/editorial/local-foundations.json +12 -0
- package/design-engineering/reference-profiles/governed-local/editorial/profile.json +43 -0
- package/design-engineering/reference-profiles/governed-local/editorial/states/button.states.json +195 -0
- package/design-engineering/reference-profiles/governed-local/editorial/tokens.dtcg.json +17 -0
- package/design-engineering/reference-profiles/governed-local/index.md +26 -0
- package/design-engineering/reference-profiles/governed-local/terminal/components/button.component.json +125 -0
- package/design-engineering/reference-profiles/governed-local/terminal/evidence/button.evidence.json +3504 -0
- package/design-engineering/reference-profiles/governed-local/terminal/fixtures/button.fixture.json +65 -0
- package/design-engineering/reference-profiles/governed-local/terminal/generated/evidence-coverage.md +23 -0
- package/design-engineering/reference-profiles/governed-local/terminal/generated/keyboard-matrix.md +19 -0
- package/design-engineering/reference-profiles/governed-local/terminal/generated/state-matrix.md +21 -0
- package/design-engineering/reference-profiles/governed-local/terminal/local-foundations.json +12 -0
- package/design-engineering/reference-profiles/governed-local/terminal/profile.json +43 -0
- package/design-engineering/reference-profiles/governed-local/terminal/states/button.states.json +195 -0
- package/design-engineering/reference-profiles/governed-local/terminal/tokens.dtcg.json +17 -0
- package/design-engineering/reference-profiles/index.md +19 -0
- package/game-ui/classification.md +82 -0
- package/game-ui/index.md +35 -0
- package/game-ui/reference-record.md +62 -0
- package/game-ui/screen-hierarchy.md +107 -0
- package/game-ui/unity/architecture.md +166 -0
- package/game-ui/unity/cli-loop.md +84 -0
- package/game-ui/unity/data/unity-technologies-public-repositories.json +26654 -0
- package/game-ui/unity/org-wiki.md +146 -0
- package/game-ui/unity/repository-map.md +102 -0
- package/game-ui/unity/ui-systems.md +85 -0
- package/guides/decision-tree.md +149 -0
- package/guides/documentation-mode-taxonomy.md +157 -0
- package/guides/layout-brief.md +220 -0
- package/guides/vocabulary.md +148 -0
- package/guides/webpage-generation-workflow.md +185 -0
- package/index.md +36 -0
- package/layout/index.md +26 -0
- package/motion/index.md +24 -0
- package/motion/practice-reference.md +145 -0
- package/motion/review-workflow.md +86 -0
- package/motion/vocabulary.md +82 -0
- package/package.json +78 -0
- package/patterns/centering/center.md +87 -0
- package/patterns/centering/index.md +6 -0
- package/patterns/centering/super-center.md +89 -0
- package/patterns/containment/box.md +87 -0
- package/patterns/containment/clamped-card.md +86 -0
- package/patterns/containment/content-limiter.md +87 -0
- package/patterns/containment/fluid-styles.md +86 -0
- package/patterns/containment/index.md +8 -0
- package/patterns/grid-repetition/card-grid.md +88 -0
- package/patterns/grid-repetition/columns.md +87 -0
- package/patterns/grid-repetition/dense-grid.md +88 -0
- package/patterns/grid-repetition/grid-wrapper.md +89 -0
- package/patterns/grid-repetition/index.md +12 -0
- package/patterns/grid-repetition/masonry-approx.md +87 -0
- package/patterns/grid-repetition/page-grid.md +90 -0
- package/patterns/grid-repetition/ram-grid.md +88 -0
- package/patterns/grid-repetition/twelve-span-grid.md +92 -0
- package/patterns/in-line-grouping/badge-list.md +94 -0
- package/patterns/in-line-grouping/breadcrumb.md +89 -0
- package/patterns/in-line-grouping/cluster.md +89 -0
- package/patterns/in-line-grouping/deconstructed-pancake.md +92 -0
- package/patterns/in-line-grouping/index.md +13 -0
- package/patterns/in-line-grouping/pagination.md +89 -0
- package/patterns/in-line-grouping/reel.md +90 -0
- package/patterns/in-line-grouping/split-nav.md +97 -0
- package/patterns/in-line-grouping/tab-strip.md +88 -0
- package/patterns/in-line-grouping/wrap-row.md +89 -0
- package/patterns/index.md +13 -0
- package/patterns/media-fit/frame.md +95 -0
- package/patterns/media-fit/icon-frame.md +87 -0
- package/patterns/media-fit/index.md +6 -0
- package/patterns/overlay-exception/imposter.md +95 -0
- package/patterns/overlay-exception/index.md +6 -0
- package/patterns/overlay-exception/overlay-stack.md +89 -0
- package/patterns/split-sidebar/index.md +12 -0
- package/patterns/split-sidebar/list-detail.md +95 -0
- package/patterns/split-sidebar/main-with-rail.md +95 -0
- package/patterns/split-sidebar/media-object.md +102 -0
- package/patterns/split-sidebar/sidebar.md +101 -0
- package/patterns/split-sidebar/split-screen.md +92 -0
- package/patterns/split-sidebar/sticky-aside.md +97 -0
- package/patterns/split-sidebar/supporting-pane.md +95 -0
- package/patterns/split-sidebar/switcher.md +93 -0
- package/patterns/stacking/feed.md +88 -0
- package/patterns/stacking/index.md +8 -0
- package/patterns/stacking/line-up.md +95 -0
- package/patterns/stacking/stack.md +87 -0
- package/patterns/stacking/step-nav.md +88 -0
- package/patterns/viewport-shell/cover.md +90 -0
- package/patterns/viewport-shell/fixed-sidenav-shell.md +97 -0
- package/patterns/viewport-shell/holy-grail.md +112 -0
- package/patterns/viewport-shell/index.md +11 -0
- package/patterns/viewport-shell/panel-layout.md +95 -0
- package/patterns/viewport-shell/scroll-body-shell.md +93 -0
- package/patterns/viewport-shell/sticky-footer.md +92 -0
- package/patterns/viewport-shell/sticky-header.md +86 -0
- package/platform-guides/apple-interaction.md +89 -0
- package/platform-guides/index.md +26 -0
- package/quality/claim-records/index.md +3 -0
- package/quality/claim-records/samples.md +92 -0
- package/quality/claim-records/stylegallery-multidomain-scope.md +42 -0
- package/quality/claims.md +77 -0
- package/quality/evidence/accessibility.md +58 -0
- package/quality/evidence/consumer-migration.md +42 -0
- package/quality/evidence/design-rationale.md +34 -0
- package/quality/evidence/executable-evidence.md +79 -0
- package/quality/evidence/families.md +56 -0
- package/quality/evidence/hci-evaluation.md +36 -0
- package/quality/evidence/index.md +16 -0
- package/quality/evidence/pattern-contract-audit.md +96 -0
- package/quality/evidence/search-metadata-polyhierarchy.md +86 -0
- package/quality/evidence/sources.md +43 -0
- package/quality/evidence/tokens.md +33 -0
- package/quality/evidence/visual-qa.md +41 -0
- package/quality/gates/accessibility-evidence.md +60 -0
- package/quality/gates/consumer-migration-evidence.md +53 -0
- package/quality/gates/design-claim.md +56 -0
- package/quality/gates/harmony-evaluation.md +78 -0
- package/quality/gates/index.md +13 -0
- package/quality/gates/layout.md +52 -0
- package/quality/gates/rationale.md +53 -0
- package/quality/gates/visual-evidence.md +47 -0
- package/quality/index.md +55 -0
- package/quality/principles.md +58 -0
- package/recipes/article-page.md +52 -0
- package/recipes/command-surface.md +55 -0
- package/recipes/dashboard.md +56 -0
- package/recipes/form-flow.md +55 -0
- package/recipes/homepage.md +89 -0
- package/recipes/index.md +13 -0
- package/recipes/list-detail.md +55 -0
- package/recipes/primitive-to-recipe-matrix.md +83 -0
- package/recipes/saas-settings.md +52 -0
- package/scripts/agent-native/a2a-projection.mjs +248 -0
- package/scripts/agent-native/agui-projection.mjs +178 -0
- package/scripts/agent-native/canonical-json.mjs +109 -0
- package/scripts/agent-native/cli-adapter.mjs +68 -0
- package/scripts/agent-native/events.mjs +113 -0
- package/scripts/agent-native/execution.mjs +227 -0
- package/scripts/agent-native/fixture.mjs +159 -0
- package/scripts/agent-native/identity.mjs +184 -0
- package/scripts/agent-native/immutable-store.mjs +102 -0
- package/scripts/agent-native/knowledge.mjs +168 -0
- package/scripts/agent-native/learning-records.mjs +244 -0
- package/scripts/agent-native/learning.mjs +247 -0
- package/scripts/agent-native/mcp-adapter.mjs +173 -0
- package/scripts/agent-native/queries.mjs +173 -0
- package/scripts/agent-native/registry.mjs +154 -0
- package/scripts/agent-native/retrieval.mjs +171 -0
- package/scripts/agent-native/self-description.mjs +160 -0
- package/scripts/artifact-metadata.mjs +20 -0
- package/scripts/audit-evidence-freshness.mjs +308 -0
- package/scripts/baseline-contract.mjs +189 -0
- package/scripts/baseline-schema-parity.mjs +40 -0
- package/scripts/build-reference-artifacts.mjs +127 -0
- package/scripts/calibration-raw-contract.mjs +172 -0
- package/scripts/capture-session-contract.mjs +187 -0
- package/scripts/component-state-artifact-fixture.mjs +44 -0
- package/scripts/component-state-contract.mjs +99 -0
- package/scripts/component-state-semantics.mjs +128 -0
- package/scripts/component-state-workflow-contract.mjs +67 -0
- package/scripts/component-state-workflow-negative-cases.mjs +64 -0
- package/scripts/consumer-conformance-contract.mjs +198 -0
- package/scripts/consumer-evidence-governance-contract.mjs +210 -0
- package/scripts/consumer-reference-case-runner.mjs +93 -0
- package/scripts/consumer-reference-schema.mjs +155 -0
- package/scripts/create-component-state-session.mjs +100 -0
- package/scripts/create-page-evidence-session.mjs +139 -0
- package/scripts/domain-document-boundaries.mjs +40 -0
- package/scripts/domain-validation-checks.mjs +141 -0
- package/scripts/evidence-artifact-contract.mjs +191 -0
- package/scripts/finalize-component-state-evidence.mjs +165 -0
- package/scripts/finalize-page-evidence.mjs +197 -0
- package/scripts/generate-consumer-reference-evidence.mjs +154 -0
- package/scripts/generate-patterns.mjs +218 -0
- package/scripts/governance-matrix-contract.mjs +73 -0
- package/scripts/governance-matrix-negative-cases.mjs +114 -0
- package/scripts/governance-policy-contract.mjs +49 -0
- package/scripts/governance-test-fixture.mjs +321 -0
- package/scripts/governance-workflow-negative-cases.mjs +241 -0
- package/scripts/governed-profile-registry.mjs +125 -0
- package/scripts/json-schema-formats.mjs +31 -0
- package/scripts/markdown-structure.mjs +45 -0
- package/scripts/page-artifact-metadata.mjs +124 -0
- package/scripts/page-evidence-contract.mjs +297 -0
- package/scripts/page-evidence-fixture.mjs +271 -0
- package/scripts/pattern-data.mjs +325 -0
- package/scripts/profile-record-contract.mjs +140 -0
- package/scripts/promotion-attestation-contract.mjs +91 -0
- package/scripts/promotion-boundary-test-contract.mjs +92 -0
- package/scripts/promotion-fixture-inventory.mjs +109 -0
- package/scripts/promotion-governance-contract.mjs +28 -0
- package/scripts/reference-artifact-path-contract.mjs +28 -0
- package/scripts/reference-profile-contract.mjs +114 -0
- package/scripts/reference-token-contract.mjs +156 -0
- package/scripts/run-consumer-page-evidence-ci.mjs +170 -0
- package/scripts/sg-mcp.mjs +16 -0
- package/scripts/sg.mjs +27 -0
- package/scripts/strict-json.mjs +72 -0
- package/scripts/summarize-sentinel-calibration.mjs +98 -0
- package/scripts/test-agent-adapter-conformance.mjs +250 -0
- package/scripts/test-agent-conformance-receipt.mjs +106 -0
- package/scripts/test-agent-events.mjs +81 -0
- package/scripts/test-agent-execution-effects.mjs +114 -0
- package/scripts/test-agent-execution-fixtures.mjs +140 -0
- package/scripts/test-agent-execution-kernel.mjs +39 -0
- package/scripts/test-agent-execution-learning.mjs +130 -0
- package/scripts/test-agent-execution-lifecycle.mjs +143 -0
- package/scripts/test-agent-execution-safety.mjs +158 -0
- package/scripts/test-agent-execution-views.mjs +117 -0
- package/scripts/test-agent-identity-integrity-cases.mjs +160 -0
- package/scripts/test-agent-knowledge-kernel.mjs +183 -0
- package/scripts/test-agent-learning.mjs +246 -0
- package/scripts/test-agent-mcp.mjs +246 -0
- package/scripts/test-agent-native-schemas.mjs +215 -0
- package/scripts/test-agent-projections.mjs +249 -0
- package/scripts/test-agent-registry-mcp-integrity.mjs +215 -0
- package/scripts/test-agent-registry-mutations.mjs +110 -0
- package/scripts/test-audit-evidence-freshness.mjs +177 -0
- package/scripts/test-component-state-sentinel.mjs +35 -0
- package/scripts/test-component-state-source-contract.mjs +83 -0
- package/scripts/test-consumer-conformance-sentinel.mjs +165 -0
- package/scripts/test-consumer-reference-sentinel.mjs +31 -0
- package/scripts/test-generate-consumer-reference-evidence.mjs +124 -0
- package/scripts/test-json-cli-output.mjs +151 -0
- package/scripts/test-json-schema-formats.mjs +40 -0
- package/scripts/test-reference-adapters.mjs +199 -0
- package/scripts/test-renderer-purity.mjs +34 -0
- package/scripts/test-sg-cli.mjs +129 -0
- package/scripts/test-summarize-sentinel-calibration.mjs +226 -0
- package/scripts/test-validate-baseline-manifest.mjs +234 -0
- package/scripts/test-validate-component-state-artifacts.mjs +243 -0
- package/scripts/test-validate-component-state.mjs +106 -0
- package/scripts/test-validate-consumer-conformance.mjs +427 -0
- package/scripts/test-validate-consumer-reference-cli.mjs +69 -0
- package/scripts/test-validate-consumer-reference.mjs +263 -0
- package/scripts/test-validate-domains.mjs +357 -0
- package/scripts/test-validate-governance.mjs +292 -0
- package/scripts/test-validate-ia.mjs +262 -0
- package/scripts/test-validate-okf.mjs +73 -0
- package/scripts/test-validate-page-evidence.mjs +302 -0
- package/scripts/test-validate-patterns.mjs +157 -0
- package/scripts/test-validate-promotion-rfc.mjs +250 -0
- package/scripts/test-validate-reference-profiles.mjs +170 -0
- package/scripts/test-validate-unity-org-wiki.mjs +57 -0
- package/scripts/test-validate-unity-source-contracts.mjs +67 -0
- package/scripts/test-validate-vocabulary.mjs +174 -0
- package/scripts/test-validate-webpage-workflow.mjs +293 -0
- package/scripts/validate-baseline-manifest.mjs +44 -0
- package/scripts/validate-catalog.mjs +65 -0
- package/scripts/validate-component-state.mjs +141 -0
- package/scripts/validate-consumer-conformance.mjs +477 -0
- package/scripts/validate-consumer-reference.mjs +288 -0
- package/scripts/validate-domains.mjs +237 -0
- package/scripts/validate-governance.mjs +248 -0
- package/scripts/validate-ia.mjs +136 -0
- package/scripts/validate-links.mjs +66 -0
- package/scripts/validate-okf.mjs +104 -0
- package/scripts/validate-page-evidence.mjs +191 -0
- package/scripts/validate-patterns.mjs +246 -0
- package/scripts/validate-promotion-rfc.mjs +224 -0
- package/scripts/validate-reference-artifacts.mjs +125 -0
- package/scripts/validate-renderer-purity.mjs +56 -0
- package/scripts/validate-unity-org-wiki.mjs +146 -0
- package/scripts/validate-unity-source-contracts.mjs +107 -0
- package/scripts/validate-vocabulary.mjs +115 -0
- package/scripts/validate-webpage-workflow.mjs +254 -0
- package/scripts/visual-expectation-contract.mjs +20 -0
- package/scripts/workflow-action-contract.mjs +163 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import { artifactMetadata } from "./artifact-metadata.mjs";
|
|
9
|
+
import { sessionLink, sha256 } from "./capture-session-contract.mjs";
|
|
10
|
+
import { makePng, syntheticImage } from "./component-state-artifact-fixture.mjs";
|
|
11
|
+
import { resolveProfileRecords } from "./profile-record-contract.mjs";
|
|
12
|
+
|
|
13
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
14
|
+
const sourceProfiles = path.join(repositoryRoot, "design-engineering/reference-profiles/governed-local");
|
|
15
|
+
const validator = path.join(repositoryRoot, "scripts/validate-component-state.mjs");
|
|
16
|
+
const finalizer = path.join(repositoryRoot, "scripts/finalize-component-state-evidence.mjs");
|
|
17
|
+
const creator = path.join(repositoryRoot, "scripts/create-component-state-session.mjs");
|
|
18
|
+
|
|
19
|
+
const png = makePng(32);
|
|
20
|
+
|
|
21
|
+
function writeJson(file, value) {
|
|
22
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
23
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function prepareCanonical() {
|
|
27
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-state-artifacts-base-"));
|
|
28
|
+
const profileRoot = path.join(root, "profiles");
|
|
29
|
+
const artifactRoot = path.join(root, "artifacts");
|
|
30
|
+
fs.cpSync(sourceProfiles, profileRoot, { recursive: true });
|
|
31
|
+
for (const entry of fs.readdirSync(profileRoot, { withFileTypes: true }).filter((item) => item.isDirectory())) {
|
|
32
|
+
const resolved = resolveProfileRecords(path.join(profileRoot, entry.name), []);
|
|
33
|
+
const statesRecord = resolved.records.states[0];
|
|
34
|
+
for (const scenario of statesRecord.value.scenarios) {
|
|
35
|
+
const metadata = artifactMetadata(syntheticImage(entry.name, scenario.id), "image/png");
|
|
36
|
+
scenario.expected.visual_image = scenario.expected.visual_image.map((expectation) => ({ environment_id: expectation.environment_id, height: metadata.height, sha256: metadata.sha256, width: metadata.width }));
|
|
37
|
+
}
|
|
38
|
+
writeJson(statesRecord.path, statesRecord.value);
|
|
39
|
+
}
|
|
40
|
+
const receiptFile = path.join(artifactRoot, "capture-session.json");
|
|
41
|
+
const created = spawnSync(process.execPath, [creator, "--root", profileRoot, "--output", receiptFile, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
42
|
+
if (created.status !== 0) throw new Error(`canonical session creation failed: ${created.stdout}${created.stderr}`);
|
|
43
|
+
const receiptBytes = fs.readFileSync(receiptFile);
|
|
44
|
+
const receipt = JSON.parse(receiptBytes);
|
|
45
|
+
const captureLink = sessionLink(receipt, sha256(receiptBytes));
|
|
46
|
+
const capturedAt = new Date().toISOString();
|
|
47
|
+
for (const entry of fs.readdirSync(profileRoot, { withFileTypes: true }).filter((item) => item.isDirectory())) {
|
|
48
|
+
const resolved = resolveProfileRecords(path.join(profileRoot, entry.name), []);
|
|
49
|
+
const fixtures = resolved.records.fixture[0].value;
|
|
50
|
+
const states = new Map(resolved.records.states[0].value.scenarios.map((scenario) => [scenario.id, scenario]));
|
|
51
|
+
for (const fixture of fixtures.scenarios) {
|
|
52
|
+
const scenario = states.get(fixture.id);
|
|
53
|
+
const prefix = path.join(artifactRoot, "runtime", `${entry.name}-${fixture.id}`);
|
|
54
|
+
const attributes = Object.fromEntries(Object.entries(scenario.expected.dom).filter(([key]) => !["active", "role"].includes(key)));
|
|
55
|
+
writeJson(`${prefix}.dom.json`, {
|
|
56
|
+
activation_count: scenario.expected.activation === "allowed" ? 1 : 0,
|
|
57
|
+
activation_key: fixture.activation_key,
|
|
58
|
+
active: scenario.expected.dom.active === "true",
|
|
59
|
+
attributes,
|
|
60
|
+
capture_session: captureLink,
|
|
61
|
+
captured_at: capturedAt,
|
|
62
|
+
channel: "dom",
|
|
63
|
+
profile_id: resolved.profile.id,
|
|
64
|
+
role: scenario.expected.dom.role,
|
|
65
|
+
scenario_id: fixture.id,
|
|
66
|
+
schema_version: "1.0",
|
|
67
|
+
semantic_mode: scenario.semantic_mode,
|
|
68
|
+
visual_states: scenario.expected.visual,
|
|
69
|
+
});
|
|
70
|
+
writeJson(`${prefix}.ax.json`, {
|
|
71
|
+
capture_session: captureLink,
|
|
72
|
+
captured_at: capturedAt,
|
|
73
|
+
channel: "ax",
|
|
74
|
+
name: fixture.label,
|
|
75
|
+
profile_id: resolved.profile.id,
|
|
76
|
+
properties: Object.fromEntries(Object.entries(scenario.expected.ax).filter(([key]) => key !== "role")),
|
|
77
|
+
role: scenario.expected.ax.role,
|
|
78
|
+
scenario_id: fixture.id,
|
|
79
|
+
schema_version: "1.0",
|
|
80
|
+
semantic_mode: scenario.semantic_mode,
|
|
81
|
+
});
|
|
82
|
+
fs.mkdirSync(path.dirname(`${prefix}.png`), { recursive: true });
|
|
83
|
+
const image = syntheticImage(entry.name, fixture.id);
|
|
84
|
+
fs.writeFileSync(`${prefix}.png`, image);
|
|
85
|
+
writeJson(`${prefix}.visual.json`, {
|
|
86
|
+
capture_session: captureLink,
|
|
87
|
+
captured_at: capturedAt,
|
|
88
|
+
channel: "visual",
|
|
89
|
+
image: { path: `${entry.name}-${fixture.id}.png`, ...artifactMetadata(image, "image/png") },
|
|
90
|
+
profile_id: resolved.profile.id,
|
|
91
|
+
scenario_id: fixture.id,
|
|
92
|
+
schema_version: "1.0",
|
|
93
|
+
semantic_mode: scenario.semantic_mode,
|
|
94
|
+
source_sha256: receipt.source.sha256,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const manifest = path.join(artifactRoot, "runtime-manifest.json");
|
|
99
|
+
const child = spawnSync(process.execPath, [finalizer, "--root", profileRoot, "--artifact-root", artifactRoot, "--output", manifest, "--write-canonical", "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
100
|
+
if (child.status !== 0) throw new Error(`canonical artifact finalization failed: ${child.stdout}${child.stderr}`);
|
|
101
|
+
const finalization = JSON.parse(child.stdout);
|
|
102
|
+
if (finalization.artifactCount !== 40) throw new Error(`canonical finalization must close 40 runtime files, found ${finalization.artifactCount}`);
|
|
103
|
+
const passCount = JSON.parse(fs.readFileSync(manifest, "utf8")).records.flatMap((record) => record.passes).length;
|
|
104
|
+
if (passCount !== 30) throw new Error(`canonical finalization must retain 30 channel passes, found ${passCount}`);
|
|
105
|
+
return { artifactRoot, manifest, profileRoot, root };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function codes(output) {
|
|
109
|
+
return (output.failures ?? []).map((failure) => failure.code);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function findPass(manifest, scenario, channel, record = 0) {
|
|
113
|
+
return manifest.records[record].passes.find((pass) => pass.scenario_id === scenario && pass.channel === channel);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function refresh(pass, artifactRoot, preserveDimensions = false) {
|
|
117
|
+
const file = path.join(artifactRoot, pass.artifact.path);
|
|
118
|
+
const dimensions = { height: pass.artifact.height, width: pass.artifact.width };
|
|
119
|
+
pass.artifact = { path: pass.artifact.path, ...artifactMetadata(fs.readFileSync(file), pass.artifact.media_type) };
|
|
120
|
+
if (preserveDimensions) Object.assign(pass.artifact, dimensions);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function mutateJsonArtifact(manifest, artifactRoot, scenario, channel, mutate) {
|
|
124
|
+
const pass = findPass(manifest, scenario, channel);
|
|
125
|
+
const file = path.join(artifactRoot, pass.artifact.path);
|
|
126
|
+
const document = JSON.parse(fs.readFileSync(file));
|
|
127
|
+
mutate(document);
|
|
128
|
+
writeJson(file, document);
|
|
129
|
+
refresh(pass, artifactRoot);
|
|
130
|
+
return pass;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const cases = [
|
|
134
|
+
{ name: "canonical", valid: true },
|
|
135
|
+
{ expect: "evidence_channel_duplicate", name: "channel_substitution", mutate: (m) => { findPass(m, "action-focused", "ax").channel = "dom"; } },
|
|
136
|
+
{ expect: "evidence_png_invalid", name: "dummy_visual_bytes", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); fs.writeFileSync(path.join(a, p.artifact.path), "not a png"); refresh(p, a, true); } },
|
|
137
|
+
{ expect: "evidence_visual_image_mismatch", name: "wrong_valid_png", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); fs.writeFileSync(path.join(a, p.artifact.path), makePng(224)); refresh(p, a); } },
|
|
138
|
+
{ expect: "evidence_visual_expectation_mismatch", name: "coordinated_visual_substitution", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); const file = path.join(a, p.artifact.path); const image = makePng(224); fs.writeFileSync(file, image); refresh(p, a); const sidecar = path.join(a, p.artifact.path.replace(/\.png$/, ".visual.json")); const document = JSON.parse(fs.readFileSync(sidecar)); document.image = { path: path.basename(file), ...artifactMetadata(image, "image/png") }; writeJson(sidecar, document); } },
|
|
139
|
+
{ expect: "evidence_json_invalid", name: "png_as_dom", mutate: (m, a) => { const p = findPass(m, "action-focused", "dom"); fs.writeFileSync(path.join(a, p.artifact.path), png); refresh(p, a); } },
|
|
140
|
+
{ expect: "evidence_artifact_symlink", name: "artifact_symlink", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); const f = path.join(a, p.artifact.path); fs.rmSync(f); fs.symlinkSync("/etc/hosts", f); } },
|
|
141
|
+
{ expect: "evidence_artifact_reused", name: "artifact_path_reuse", mutate: (m) => { const p = findPass(m, "action-loading-busy", "visual"); p.artifact = structuredClone(findPass(m, "action-focused", "visual").artifact); } },
|
|
142
|
+
{ expect: "evidence_artifact_content_reused", name: "artifact_content_reuse", mutate: (m, a) => { const source = findPass(m, "action-focused", "visual"); const target = findPass(m, "action-loading-busy", "visual"); fs.copyFileSync(path.join(a, source.artifact.path), path.join(a, target.artifact.path)); refresh(target, a); } },
|
|
143
|
+
{ expect: "evidence_scenario_unknown", name: "unknown_scenario", mutate: (m) => { findPass(m, "action-focused", "dom").scenario_id = "unknown-scenario"; } },
|
|
144
|
+
{ expect: "runtime_manifest_profile_unknown", name: "unknown_profile", mutate: (m) => { m.records[0].profile_id = "unknown-profile"; } },
|
|
145
|
+
{ expect: "evidence_artifact_integrity", name: "forged_hash", mutate: (m) => { findPass(m, "action-focused", "visual").artifact.sha256 = `sha256:${"0".repeat(64)}`; } },
|
|
146
|
+
{ expect: "evidence_artifact_missing", name: "missing_artifact", mutate: (m) => { findPass(m, "action-focused", "visual").artifact.path = "runtime/missing.png"; } },
|
|
147
|
+
{ expect: "evidence_artifact_type_invalid", name: "directory_artifact", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); p.artifact.path = "runtime/directory.png"; fs.mkdirSync(path.join(a, p.artifact.path)); } },
|
|
148
|
+
{ expect: "evidence_artifact_escape", name: "outside_artifact", mutate: (m) => { findPass(m, "action-focused", "visual").artifact.path = "../outside.png"; } },
|
|
149
|
+
{ expect: "evidence_dom_content_mismatch", name: "pressed_dom_false", mutate: (m, a) => { const p = findPass(m, "toggle-focused-pressed", "dom"); const f = path.join(a, p.artifact.path); const d = JSON.parse(fs.readFileSync(f)); d.attributes["aria-pressed"] = "false"; writeJson(f, d); refresh(p, a); } },
|
|
150
|
+
{ expect: "evidence_dom_content_mismatch", name: "disabled_dom_false", mutate: (m, a) => { const p = findPass(m, "action-disabled-busy", "dom"); const f = path.join(a, p.artifact.path); const d = JSON.parse(fs.readFileSync(f)); d.attributes.disabled = "false"; writeJson(f, d); refresh(p, a); } },
|
|
151
|
+
{ expect: "evidence_runtime_identity_mismatch", name: "activation_key_mismatch", mutate: (m, a) => { const p = findPass(m, "action-focused", "dom"); const f = path.join(a, p.artifact.path); const d = JSON.parse(fs.readFileSync(f)); d.activation_key = "Space"; writeJson(f, d); refresh(p, a); } },
|
|
152
|
+
{ expect: "evidence_recorded_at_mismatch", name: "stale_runtime", mutate: (m) => { m.recorded_at = "2000-01-01T00:00:00.000Z"; for (const record of m.records) for (const pass of record.passes) pass.recorded_at = m.recorded_at; } },
|
|
153
|
+
{ expect: "evidence_dom_schema_invalid", name: "unexpected_certification", mutate: (m, a) => { const p = findPass(m, "action-focused", "dom"); const f = path.join(a, p.artifact.path); const d = JSON.parse(fs.readFileSync(f)); d.certification = true; writeJson(f, d); refresh(p, a); } },
|
|
154
|
+
{ expect: "evidence_dom_schema_invalid", name: "dom_extra_nested_field", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { d.attributes.certification = "true"; }); } },
|
|
155
|
+
{ expect: "evidence_dom_schema_invalid", name: "dom_null_type", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { d.active = null; }); } },
|
|
156
|
+
{ expect: "evidence_dom_schema_invalid", name: "dom_missing_key", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { delete d.activation_count; }); } },
|
|
157
|
+
{ expect: "evidence_ax_schema_invalid", name: "ax_extra_nested_field", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "ax", (d) => { d.properties.certification = true; }); } },
|
|
158
|
+
{ expect: "evidence_ax_schema_invalid", name: "ax_null_type", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "ax", (d) => { d.properties.focused = null; }); } },
|
|
159
|
+
{ expect: "evidence_ax_schema_invalid", name: "ax_missing_key", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "ax", (d) => { delete d.role; }); } },
|
|
160
|
+
{ expect: "capture_session_receipt_mismatch", name: "receipt_tamper", mutate: (m, a) => { const f = path.join(a, "capture-session.json"); const r = JSON.parse(fs.readFileSync(f)); r.nonce = "0".repeat(64); writeJson(f, r); } },
|
|
161
|
+
{ expect: "capture_session_schema_invalid", name: "receipt_source_missing", mutate: (_m, a) => { const f = path.join(a, "capture-session.json"); const r = JSON.parse(fs.readFileSync(f)); delete r.source; writeJson(f, r); } },
|
|
162
|
+
{ expect: "runtime_manifest_schema_invalid", name: "completed_session_source_missing", mutate: (m) => { delete m.session.source; } },
|
|
163
|
+
{ expect: "evidence_visual_schema_invalid", name: "visual_session_source_missing", mutate: (m, a) => { const p = findPass(m, "action-focused", "visual"); const f = path.join(a, p.artifact.path.replace(/\.png$/, ".visual.json")); const d = JSON.parse(fs.readFileSync(f)); delete d.capture_session.source; writeJson(f, d); } },
|
|
164
|
+
{ expect: "evidence_dom_schema_invalid", name: "dom_session_source_missing", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { delete d.capture_session.source; }); } },
|
|
165
|
+
{ expect: "evidence_ax_schema_invalid", name: "ax_session_source_missing", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "ax", (d) => { delete d.capture_session.source; }); } },
|
|
166
|
+
{ expect: "capture_session_receipt_mismatch", name: "isolated_session_replay", mutate: (_m, a) => { fs.copyFileSync(path.join(alternate.artifactRoot, "capture-session.json"), path.join(a, "capture-session.json")); } },
|
|
167
|
+
{ expect: "capture_session_missing", name: "receipt_missing", mutate: (m, a) => { fs.rmSync(path.join(a, "capture-session.json")); } },
|
|
168
|
+
{ expect: "capture_session_mismatch", name: "cross_session_artifact_mix", mutate: (m, a) => { const target = findPass(m, "action-focused", "dom"); const sourceManifest = JSON.parse(fs.readFileSync(alternate.manifest)); const source = findPass(sourceManifest, "action-focused", "dom"); fs.copyFileSync(path.join(alternate.artifactRoot, source.artifact.path), path.join(a, target.artifact.path)); refresh(target, a); } },
|
|
169
|
+
{ expect: "capture_session_mismatch", name: "visual_cross_session_replay", mutate: (m, a) => { const target = findPass(m, "action-focused", "visual"); const sourceManifest = JSON.parse(fs.readFileSync(alternate.manifest)); const source = findPass(sourceManifest, "action-focused", "visual"); fs.copyFileSync(path.join(alternate.artifactRoot, source.artifact.path), path.join(a, target.artifact.path)); fs.copyFileSync(path.join(alternate.artifactRoot, source.artifact.path.replace(/\.png$/, ".visual.json")), path.join(a, target.artifact.path.replace(/\.png$/, ".visual.json"))); refresh(target, a); } },
|
|
170
|
+
{ expect: "capture_session_mismatch", name: "artifact_revision_drift", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { d.capture_session.revision = "0".repeat(40); }); } },
|
|
171
|
+
{ expect: "capture_session_mismatch", name: "artifact_environment_drift", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { d.capture_session.environment.browser = "Different browser"; }); } },
|
|
172
|
+
{ expect: "capture_session_mismatch", name: "artifact_attempt_drift", mutate: (m, a) => { mutateJsonArtifact(m, a, "action-focused", "dom", (d) => { d.capture_session.attempt += 1; }); } },
|
|
173
|
+
{ expect: "capture_session_time_outside", name: "artifact_time_outside_session", mutate: (m, a) => { for (const channel of ["dom", "ax"]) { const p = mutateJsonArtifact(m, a, "action-focused", channel, (d) => { d.captured_at = "2000-01-01T00:00:00.000Z"; }); p.recorded_at = "2000-01-01T00:00:00.000Z"; } findPass(m, "action-focused", "visual").recorded_at = "2000-01-01T00:00:00.000Z"; } },
|
|
174
|
+
{ expect: "capture_session_time_outside", name: "completed_before_started", mutate: (m) => { m.session.completed_at = "2000-01-01T00:00:00.000Z"; m.recorded_at = m.session.completed_at; } },
|
|
175
|
+
{ expect: "at_evidence_unverified", name: "fake_at", mutate: (m) => { findPass(m, "action-focused", "ax").channel = "at"; } },
|
|
176
|
+
{ expect: "runtime_manifest_identity_mismatch", name: "run_identity_mismatch", mutate: (m) => { findPass(m, "action-focused", "dom").run.id = "different-run"; } },
|
|
177
|
+
{ expect: "capture_source_drift", name: "source_drift", mutate: (_m, _a, root) => { fs.appendFileSync(path.join(root, "profiles/editorial/tokens.dtcg.json"), "\n"); } },
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
const base = prepareCanonical();
|
|
181
|
+
const alternate = prepareCanonical();
|
|
182
|
+
const results = cases.map((testCase) => {
|
|
183
|
+
const root = fs.mkdtempSync(path.join(os.tmpdir(), `stylegallery-state-artifacts-${testCase.name}-`));
|
|
184
|
+
try {
|
|
185
|
+
fs.cpSync(base.root, root, { recursive: true });
|
|
186
|
+
const artifactRoot = path.join(root, "artifacts");
|
|
187
|
+
const manifestFile = path.join(artifactRoot, "runtime-manifest.json");
|
|
188
|
+
const manifest = JSON.parse(fs.readFileSync(manifestFile));
|
|
189
|
+
testCase.mutate?.(manifest, artifactRoot, root);
|
|
190
|
+
writeJson(manifestFile, manifest);
|
|
191
|
+
const child = spawnSync(process.execPath, [validator, "--root", path.join(root, "profiles"), "--artifact-root", artifactRoot, "--runtime-manifest", manifestFile, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
192
|
+
const output = JSON.parse(child.stdout);
|
|
193
|
+
const actual = codes(output);
|
|
194
|
+
const ok = testCase.valid ? child.status === 0 && output.ok === true : child.status !== 0 && output.ok === false && actual.includes(testCase.expect);
|
|
195
|
+
return {
|
|
196
|
+
actual: {
|
|
197
|
+
codes: actual,
|
|
198
|
+
...(testCase.valid && !ok ? { findings: output.failures.slice(0, 10) } : {}),
|
|
199
|
+
status: child.status,
|
|
200
|
+
},
|
|
201
|
+
expected: testCase.expect ?? "valid",
|
|
202
|
+
name: testCase.name,
|
|
203
|
+
ok,
|
|
204
|
+
};
|
|
205
|
+
} finally {
|
|
206
|
+
fs.rmSync(root, { force: true, recursive: true });
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
const closedRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-state-artifacts-closed-"));
|
|
211
|
+
fs.cpSync(base.root, closedRoot, { recursive: true });
|
|
212
|
+
fs.writeFileSync(path.join(closedRoot, "artifacts/runtime/unmanifested.txt"), "rogue");
|
|
213
|
+
const closed = spawnSync(process.execPath, [finalizer, "--root", path.join(closedRoot, "profiles"), "--artifact-root", path.join(closedRoot, "artifacts"), "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
214
|
+
const closedOutput = JSON.parse(closed.stdout);
|
|
215
|
+
results.push({ actual: { codes: codes(closedOutput), status: closed.status }, expected: "runtime_artifact_unmanifested", name: "unmanifested_closed_set", ok: closed.status !== 0 && codes(closedOutput).includes("runtime_artifact_unmanifested") });
|
|
216
|
+
results.push({ actual: { codes: codes(closedOutput), status: closed.status }, expected: "capture_session_replay", name: "session_replay", ok: closed.status !== 0 && codes(closedOutput).includes("capture_session_replay") });
|
|
217
|
+
fs.rmSync(closedRoot, { force: true, recursive: true });
|
|
218
|
+
|
|
219
|
+
const revisionRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-state-revision-"));
|
|
220
|
+
try {
|
|
221
|
+
const receiptFile = path.join(revisionRoot, "capture-session.json");
|
|
222
|
+
const child = spawnSync(process.execPath, [creator, "--root", sourceProfiles, "--output", receiptFile, "--json"], {
|
|
223
|
+
cwd: repositoryRoot,
|
|
224
|
+
encoding: "utf8",
|
|
225
|
+
env: { ...process.env, GITHUB_SHA: "0".repeat(40) },
|
|
226
|
+
});
|
|
227
|
+
const output = JSON.parse(child.stdout);
|
|
228
|
+
results.push({
|
|
229
|
+
actual: { codes: codes(output), receiptWritten: fs.existsSync(receiptFile), status: child.status },
|
|
230
|
+
expected: "capture_revision_mismatch",
|
|
231
|
+
name: "github_sha_mismatch",
|
|
232
|
+
ok: child.status !== 0 && codes(output).includes("capture_revision_mismatch") && !fs.existsSync(receiptFile),
|
|
233
|
+
});
|
|
234
|
+
} finally {
|
|
235
|
+
fs.rmSync(revisionRoot, { force: true, recursive: true });
|
|
236
|
+
}
|
|
237
|
+
fs.rmSync(base.root, { force: true, recursive: true });
|
|
238
|
+
fs.rmSync(alternate.root, { force: true, recursive: true });
|
|
239
|
+
|
|
240
|
+
const failures = results.filter((result) => !result.ok).map((result) => `${result.name}:${result.expected}`);
|
|
241
|
+
const report = { adversarial: results.length - 1, failures, ok: failures.length === 0, results };
|
|
242
|
+
console.log(JSON.stringify(report, null, 2));
|
|
243
|
+
if (!report.ok) process.exitCode = 1;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const sourceRoot = path.join(repositoryRoot, "design-engineering/reference-profiles/governed-local");
|
|
12
|
+
const validator = path.join(repositoryRoot, "scripts/validate-component-state.mjs");
|
|
13
|
+
|
|
14
|
+
function readJson(file) {
|
|
15
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function writeJson(file, value) {
|
|
19
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function edit(root, profile, relative, mutate) {
|
|
23
|
+
const file = path.join(root, profile, relative);
|
|
24
|
+
const value = readJson(file);
|
|
25
|
+
mutate(value);
|
|
26
|
+
writeJson(file, value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function scenario(value, id) {
|
|
30
|
+
return value.scenarios.find((candidate) => candidate.id === id);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function pass(value, scenarioId, channel) {
|
|
34
|
+
return value.passes.find((candidate) => candidate.scenario_id === scenarioId && candidate.channel === channel);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function run(root) {
|
|
38
|
+
const child = spawnSync(process.execPath, [validator, "--root", root, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
39
|
+
let report = { failures: [], ok: false, parse_error: true };
|
|
40
|
+
try { report = JSON.parse(child.stdout); } catch { report = { failures: [], ok: false, parse_error: true }; }
|
|
41
|
+
return { report, status: child.status };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const cases = [
|
|
45
|
+
["unresolved_conditional", "conditional_unresolved", (root) => edit(root, "editorial", "components/button.component.json", (value) => { delete value.semantic_modes[0].aria_states[2].resolution; })],
|
|
46
|
+
["missing_applicability_reason", "applicability_reason_required", (root) => edit(root, "editorial", "components/button.component.json", (value) => { delete value.semantic_modes[0].aria_states[0].reason; })],
|
|
47
|
+
["missing_role_required_state", "role_required_aria_state", (root) => edit(root, "editorial", "components/button.component.json", (value) => { value.semantic_modes[1].aria_states = value.semantic_modes[1].aria_states.filter((state) => state.name !== "pressed"); })],
|
|
48
|
+
["switch_mixed", "switch_mixed_prohibited", (root) => edit(root, "editorial", "components/button.component.json", (value) => { value.semantic_modes[1] = { ...value.semantic_modes[1], aria_states: [{ name: "checked", status: "required", values: ["false", "mixed"] }], id: "switch", role: "switch" }; })],
|
|
49
|
+
["missing_environment", "evidence_schema_invalid", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { delete value.passes[0].environment; })],
|
|
50
|
+
["committed_visual_expectation_mismatch", "evidence_visual_expectation_mismatch", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { pass(value, "action-disabled-busy", "visual").artifact.sha256 = `sha256:${"0".repeat(64)}`; })],
|
|
51
|
+
["missing_committed_source", "capture_source_missing", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { delete value.passes[0].session.source; })],
|
|
52
|
+
["committed_source_drift", "capture_source_drift", (root) => fs.appendFileSync(path.join(root, "editorial/tokens.dtcg.json"), "\n")],
|
|
53
|
+
["false_aggregate_pass", "aggregate_pass_forbidden", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { value.aggregate_pass = true; })],
|
|
54
|
+
["normative_conflict", "normative_activation_conflict", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-focused").expected.activation = "suppressed"; })],
|
|
55
|
+
["preview_rolled_stable", "preview_rolled_stable", (root) => edit(root, "editorial", "components/button.component.json", (value) => { value.versions.delivery_channel = "stable"; })],
|
|
56
|
+
["expanded_surface", "expanded_surface_mismatch", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "disclosure-expanded-loading").expected.ax.expanded = false; })],
|
|
57
|
+
["disabled_activation", "disabled_activation", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-disabled-busy").expected.activation = "allowed"; })],
|
|
58
|
+
["loading_without_busy", "loading_busy_state_required", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-loading-busy").states = ["focus", "loading"]; })],
|
|
59
|
+
["loading_as_disabled", "loading_disabled_conflated", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-loading-busy").expected.visual.push("disabled"); })],
|
|
60
|
+
["required_channel", "required_channel_missing", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { value.passes = value.passes.filter((candidate) => !(candidate.scenario_id === "action-focused" && candidate.channel === "ax")); })],
|
|
61
|
+
["self_asserted_at", "at_evidence_unverified", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { value.passes[0].channel = "at"; value.passes[0].environment.kind = "assistive_technology"; })],
|
|
62
|
+
["duplicate_mode", "semantic_mode_duplicate", (root) => edit(root, "editorial", "components/button.component.json", (value) => { value.semantic_modes.push(structuredClone(value.semantic_modes[0])); })],
|
|
63
|
+
["duplicate_pass", "evidence_pass_duplicate", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { value.passes.push(structuredClone(value.passes[0])); })],
|
|
64
|
+
["duplicate_state_set", "state_set_duplicate", (root) => edit(root, "editorial", "states/button.states.json", (value) => { const copy = structuredClone(value.scenarios[0]); copy.id = "duplicate-disabled-busy"; copy.states.reverse(); value.scenarios.push(copy); })],
|
|
65
|
+
["duplicate_visual_environment", "visual_environment_duplicate", (root) => edit(root, "editorial", "states/button.states.json", (value) => { value.visual_environments.push(structuredClone(value.visual_environments[0])); })],
|
|
66
|
+
["missing_visual_expectation", "visual_expectation_missing", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-focused").expected.visual_image.pop(); })],
|
|
67
|
+
["unknown_visual_environment", "visual_environment_unknown", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-focused").expected.visual_image[0].environment_id = "unknown-environment"; })],
|
|
68
|
+
["pressed_surface", "pressed_surface_mismatch", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "toggle-focused-pressed").expected.dom["aria-pressed"] = "false"; })],
|
|
69
|
+
["busy_surface", "busy_surface_mismatch", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-loading-busy").expected.ax.busy = false; })],
|
|
70
|
+
["disabled_surface", "disabled_surface_mismatch", (root) => edit(root, "editorial", "states/button.states.json", (value) => { scenario(value, "action-disabled-busy").expected.dom.disabled = "false"; })],
|
|
71
|
+
["unknown_evidence_scenario", "evidence_scenario_unknown", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { value.passes[0].scenario_id = "unknown-scenario"; })],
|
|
72
|
+
["duplicate_channel", "evidence_channel_duplicate", (root) => edit(root, "editorial", "evidence/button.evidence.json", (value) => { const copy = structuredClone(value.passes[0]); copy.id = "unique-pass-id"; copy.artifact.path = "runtime/unique.png"; copy.artifact.sha256 = `sha256:${"1".repeat(64)}`; value.passes.push(copy); })],
|
|
73
|
+
["activation_key", "fixture_activation_key_invalid", (root) => edit(root, "editorial", "fixtures/button.fixture.json", (value) => { value.scenarios[1].activation_key = "Escape"; })],
|
|
74
|
+
["unexercised_scenario", "fixture_scenario_unexercised", (root) => edit(root, "editorial", "fixtures/button.fixture.json", (value) => { value.scenarios = value.scenarios.filter((candidate) => candidate.id !== "action-loading-busy"); })],
|
|
75
|
+
["profile_field_missing", "profile_reference_required", (root) => edit(root, "editorial", "profile.json", (value) => { delete value.component_records; })],
|
|
76
|
+
["profile_reference_duplicate", "profile_reference_duplicate", (root) => edit(root, "editorial", "profile.json", (value) => { value.component_records.push(value.component_records[0]); })],
|
|
77
|
+
["profile_reference_unknown", "profile_reference_unknown", (root) => edit(root, "editorial", "profile.json", (value) => { value.component_records[0] = "mystery/button.json"; })],
|
|
78
|
+
["profile_reference_outside", "profile_reference_outside", (root) => edit(root, "editorial", "profile.json", (value) => { value.component_records[0] = "../terminal/components/button.component.json"; })],
|
|
79
|
+
["profile_reference_missing", "profile_reference_missing", (root) => fs.rmSync(path.join(root, "editorial/components/button.component.json"))],
|
|
80
|
+
["profile_reference_symlink", "profile_reference_symlink", (root) => { const file = path.join(root, "editorial/components/button.component.json"); fs.rmSync(file); fs.symlinkSync(path.join(root, "terminal/components/button.component.json"), file); }],
|
|
81
|
+
["profile_reference_redirect", "profile_reference_redirect", (root) => { const directory = path.join(root, "editorial/components"); const actual = path.join(root, "editorial/components-real"); fs.renameSync(directory, actual); fs.symlinkSync(actual, directory); }],
|
|
82
|
+
["cross_profile_swap", "profile_identity_mismatch", (root) => fs.copyFileSync(path.join(root, "terminal/components/button.component.json"), path.join(root, "editorial/components/button.component.json"))],
|
|
83
|
+
["generated_reference_missing", "profile_reference_missing", (root) => fs.rmSync(path.join(root, "editorial/generated/state-matrix.md"))],
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-pr5-state-"));
|
|
87
|
+
const results = [];
|
|
88
|
+
try {
|
|
89
|
+
for (const [name, expected, mutate] of cases) {
|
|
90
|
+
const root = path.join(tempRoot, name);
|
|
91
|
+
fs.cpSync(sourceRoot, root, { recursive: true });
|
|
92
|
+
mutate(root);
|
|
93
|
+
const child = run(root);
|
|
94
|
+
const codes = child.report.failures.map((failure) => failure.code);
|
|
95
|
+
results.push({ actual: { codes, scaffold: child.report.scaffold === true, status: child.status }, expected, name, ok: child.status > 0 && codes.includes(expected) && child.report.scaffold !== true });
|
|
96
|
+
}
|
|
97
|
+
const canonical = run(sourceRoot);
|
|
98
|
+
results.push({ actual: { status: canonical.status }, expected: "canonical_valid", name: "canonical", ok: canonical.status === 0 && canonical.report.ok === true && canonical.report.scaffold !== true });
|
|
99
|
+
} finally {
|
|
100
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const failures = results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`);
|
|
104
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
105
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
106
|
+
assert.equal(report.ok, true);
|