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,177 @@
|
|
|
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 { cleanupFixture, completeSession, initializeConsumer } from "./page-evidence-fixture.mjs";
|
|
9
|
+
|
|
10
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
11
|
+
const auditor = path.join(repositoryRoot, "scripts", "audit-evidence-freshness.mjs");
|
|
12
|
+
const calibration = path.join(repositoryRoot, "consumer-reference", "baselines", "calibration.json");
|
|
13
|
+
const selectedCase = process.argv.find((argument) => argument === "--case") ? process.argv[process.argv.indexOf("--case") + 1] : null;
|
|
14
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-freshness-"));
|
|
15
|
+
|
|
16
|
+
function writeJson(file, value) {
|
|
17
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
18
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function run(args) {
|
|
22
|
+
const child = spawnSync(process.execPath, [auditor, ...args, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
23
|
+
let report;
|
|
24
|
+
try {
|
|
25
|
+
report = JSON.parse(child.stdout);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
report = null;
|
|
28
|
+
}
|
|
29
|
+
return { child, report };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function result(name, expected, actual, ok) {
|
|
33
|
+
return { actual, expected, name, ok };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function pageSchema() {
|
|
37
|
+
return {
|
|
38
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
39
|
+
$id: "https://stylegallery.test/page-evidence-manifest.schema.json",
|
|
40
|
+
additionalProperties: false,
|
|
41
|
+
properties: {
|
|
42
|
+
record_kind: { const: "page_evidence_manifest" },
|
|
43
|
+
review_by: { format: "date-time", type: "string" },
|
|
44
|
+
schema_version: { const: "1.0" },
|
|
45
|
+
},
|
|
46
|
+
required: ["record_kind", "review_by", "schema_version"],
|
|
47
|
+
type: "object",
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function pageFixture(file, reviewBy) {
|
|
52
|
+
writeJson(file, { record_kind: "page_evidence_manifest", review_by: reviewBy, schema_version: "1.0" });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function selected(cases) {
|
|
56
|
+
if (!selectedCase) return cases;
|
|
57
|
+
const match = cases.filter((testCase) => testCase.name === selectedCase);
|
|
58
|
+
if (match.length === 0) {
|
|
59
|
+
return [result(selectedCase, "known --case", { cases: cases.map((testCase) => testCase.name) }, false)];
|
|
60
|
+
}
|
|
61
|
+
return match;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const pageSchemaPath = path.join(tempRoot, "page-evidence-manifest.schema.json");
|
|
65
|
+
writeJson(pageSchemaPath, pageSchema());
|
|
66
|
+
const pagePreDeadline = path.join(tempRoot, "review-window.json");
|
|
67
|
+
pageFixture(pagePreDeadline, "2026-07-27T00:00:00Z");
|
|
68
|
+
const pagePastDeadline = path.join(tempRoot, "review-past-deadline.json");
|
|
69
|
+
pageFixture(pagePastDeadline, "2026-07-20T00:00:00Z");
|
|
70
|
+
const pageAtDeadline = path.join(tempRoot, "review-at-deadline.json");
|
|
71
|
+
pageFixture(pageAtDeadline, "2026-07-21T00:00:00Z");
|
|
72
|
+
const pageFresh = path.join(tempRoot, "review-fresh.json");
|
|
73
|
+
pageFixture(pageFresh, "2026-08-20T00:00:00Z");
|
|
74
|
+
const malformed = path.join(tempRoot, "malformed.json");
|
|
75
|
+
fs.writeFileSync(malformed, '{"record_kind":"page_evidence_manifest","review_by":"not-a-date","schema_version":"1.0"}\n');
|
|
76
|
+
const unknown = path.join(tempRoot, "unknown.json");
|
|
77
|
+
writeJson(unknown, { record_kind: "unsupported_evidence_manifest", schema_version: "1.0" });
|
|
78
|
+
const missing = path.join(tempRoot, "missing.json");
|
|
79
|
+
const missingPageSchema = path.join(tempRoot, "missing-page-evidence-manifest.schema.json");
|
|
80
|
+
const completedPageFixture = initializeConsumer();
|
|
81
|
+
const completedPage = completeSession(completedPageFixture);
|
|
82
|
+
if (completedPage.validate?.status !== 0) throw new Error(`full page fixture failed: ${JSON.stringify(completedPage.validate?.report ?? completedPage.finalize?.report)}`);
|
|
83
|
+
const completeManifest = JSON.parse(fs.readFileSync(path.join(completedPage.session.artifactRoot, "page-evidence-manifest.json"), "utf8"));
|
|
84
|
+
const impossibleDateRecords = [
|
|
85
|
+
["impossible-session-started-at", (value) => { value.session.started_at = "2023-02-30T12:00:00Z"; }],
|
|
86
|
+
["impossible-session-completed-at", (value) => { value.session.completed_at = "2023-02-30T12:00:00Z"; }],
|
|
87
|
+
["impossible-manifest-completed-at", (value) => { value.completed_at = "2023-02-30T12:00:00Z"; }],
|
|
88
|
+
["impossible-scenario-recorded-at", (value) => { value.scenarios[0].recorded_at = "2023-02-30T12:00:00Z"; }],
|
|
89
|
+
].map(([name, mutate]) => {
|
|
90
|
+
const value = structuredClone(completeManifest);
|
|
91
|
+
mutate(value);
|
|
92
|
+
const file = path.join(tempRoot, `${name}.json`);
|
|
93
|
+
writeJson(file, value);
|
|
94
|
+
return { file, name };
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const cases = [
|
|
98
|
+
(() => {
|
|
99
|
+
const actual = run(["--record", pageFresh, "--page-schema", pageSchemaPath, "--as-of", "2023-02-30T12:00:00Z", "--mode", "advisory"]);
|
|
100
|
+
return result("impossible-as-of", "exit nonzero with as_of_invalid", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures?.some((item) => item.code === "as_of_invalid"));
|
|
101
|
+
})(),
|
|
102
|
+
...impossibleDateRecords.map(({ file, name }) => (() => {
|
|
103
|
+
const actual = run(["--record", file, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
104
|
+
return result(name, "exit nonzero with freshness_record_invalid", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures?.some((item) => item.code === "freshness_record_invalid"));
|
|
105
|
+
})()),
|
|
106
|
+
(() => {
|
|
107
|
+
const actual = run(["--record", calibration, "--as-of", "2026-07-01T00:00:00Z", "--mode", "advisory"]);
|
|
108
|
+
return result("fresh-calibration", "exit 0 with status fresh and no warnings", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "fresh" && actual.report.warnings.length === 0);
|
|
109
|
+
})(),
|
|
110
|
+
(() => {
|
|
111
|
+
const actual = run(["--record", calibration, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
112
|
+
return result("expiring-calibration-advisory", "exit 0 with expiring status and evidence_expiring warning", { codes: actual.report?.warnings?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "expiring" && actual.report.warnings.some((item) => item.code === "evidence_expiring"));
|
|
113
|
+
})(),
|
|
114
|
+
(() => {
|
|
115
|
+
const actual = run(["--record", calibration, "--as-of", "2026-07-28T00:00:00Z", "--mode", "advisory"]);
|
|
116
|
+
return result("expired-calibration-advisory", "exit 0 with expired status and warning", { codes: actual.report?.warnings?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "expired" && actual.report.warnings.some((item) => item.code === "evidence_expired"));
|
|
117
|
+
})(),
|
|
118
|
+
(() => {
|
|
119
|
+
const actual = run(["--record", pagePreDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
120
|
+
return result("pre-deadline-page-advisory", "exit 0 with expiring status and evidence_expiring warning", { codes: actual.report?.warnings?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "expiring" && actual.report.warnings.some((item) => item.code === "evidence_expiring"));
|
|
121
|
+
})(),
|
|
122
|
+
(() => {
|
|
123
|
+
const actual = run(["--record", pagePreDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "blocking"]);
|
|
124
|
+
return result("pre-deadline-review-window-blocking", "exit 0 with expiring status, advisory evidence_expiring warning, and no blocking failure", { failureCodes: actual.report?.failures?.map((item) => item.code), warningCodes: actual.report?.warnings?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "expiring" && actual.report.warnings.some((item) => item.code === "evidence_expiring") && actual.report.failures.length === 0);
|
|
125
|
+
})(),
|
|
126
|
+
(() => {
|
|
127
|
+
const actual = run(["--record", pagePastDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
128
|
+
return result("review-due-page-advisory", "exit 0 with review_due status and evidence_review_due warning", { codes: actual.report?.warnings?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.ok === true && actual.report.records[0]?.status === "review_due" && actual.report.warnings.some((item) => item.code === "evidence_review_due"));
|
|
129
|
+
})(),
|
|
130
|
+
(() => {
|
|
131
|
+
const before = fs.readFileSync(calibration);
|
|
132
|
+
const actual = run(["--record", calibration, "--record", pagePreDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
133
|
+
const after = fs.readFileSync(calibration);
|
|
134
|
+
return result("repeated-record-and-source-immutability", "two records are audited and calibration bytes remain unchanged", { bytesUnchanged: before.equals(after), count: actual.report?.records?.length, status: actual.child.status }, actual.child.status === 0 && actual.report?.records?.length === 2 && before.equals(after));
|
|
135
|
+
})(),
|
|
136
|
+
(() => {
|
|
137
|
+
const actual = run(["--record", pageFresh, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
138
|
+
return result("fresh-page-review", "exit 0 with fresh page evidence", { status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status === 0 && actual.report?.records[0]?.status === "fresh");
|
|
139
|
+
})(),
|
|
140
|
+
(() => {
|
|
141
|
+
const actual = run(["--record", malformed, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
142
|
+
return result("malformed-advisory", "exit nonzero with freshness_record_invalid", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.ok === false && actual.report.failures.some((item) => item.code === "freshness_record_invalid"));
|
|
143
|
+
})(),
|
|
144
|
+
(() => {
|
|
145
|
+
const actual = run(["--record", unknown, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
146
|
+
return result("unknown-record-kind", "exit nonzero with freshness_record_invalid", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures.some((item) => item.code === "freshness_record_invalid"));
|
|
147
|
+
})(),
|
|
148
|
+
(() => {
|
|
149
|
+
const actual = run(["--record", missing, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
150
|
+
return result("unreadable-record", "exit nonzero with freshness_record_unreadable", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures.some((item) => item.code === "freshness_record_unreadable"));
|
|
151
|
+
})(),
|
|
152
|
+
(() => {
|
|
153
|
+
const actual = run(["--record", pagePreDeadline, "--page-schema", missingPageSchema, "--as-of", "2026-07-21T00:00:00Z", "--mode", "advisory"]);
|
|
154
|
+
return result("missing-page-schema", "exit nonzero with freshness_schema_missing", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures.some((item) => item.code === "freshness_schema_missing"));
|
|
155
|
+
})(),
|
|
156
|
+
(() => {
|
|
157
|
+
const actual = run(["--record", calibration, "--as-of", "2026-07-28T00:00:00Z", "--mode", "blocking"]);
|
|
158
|
+
return result("expired-calibration-blocking", "exit nonzero with evidence_expired", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status }, actual.child.status !== 0 && actual.report?.failures.some((item) => item.code === "evidence_expired"));
|
|
159
|
+
})(),
|
|
160
|
+
(() => {
|
|
161
|
+
const actual = run(["--record", pagePastDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "blocking"]);
|
|
162
|
+
return result("review-due-blocking", "exit nonzero with evidence_review_due", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status !== 0 && actual.report?.ok === false && actual.report.records[0]?.status === "review_due" && actual.report.failures.some((item) => item.code === "evidence_review_due"));
|
|
163
|
+
})(),
|
|
164
|
+
(() => {
|
|
165
|
+
const actual = run(["--record", pageAtDeadline, "--page-schema", pageSchemaPath, "--as-of", "2026-07-21T00:00:00Z", "--mode", "blocking"]);
|
|
166
|
+
return result("page-at-review-deadline-blocking", "exit nonzero with review_due/evidence_review_due at the deadline", { codes: actual.report?.failures?.map((item) => item.code), status: actual.child.status, statuses: actual.report?.records?.map((item) => item.status) }, actual.child.status !== 0 && actual.report?.ok === false && actual.report.records[0]?.status === "review_due" && actual.report.failures.some((item) => item.code === "evidence_review_due"));
|
|
167
|
+
})(),
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
const report = { ok: selected(cases).every((testCase) => testCase.ok), results: selected(cases) };
|
|
172
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
173
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
174
|
+
} finally {
|
|
175
|
+
cleanupFixture(completedPageFixture);
|
|
176
|
+
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
177
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const cases = [
|
|
9
|
+
["key_runtime_mismatch", "runtime-key-mismatch", "state_activation_key_parity", "action-focused"],
|
|
10
|
+
["pressed_false", "runtime-pressed-false", "pressed_surface_mismatch", "toggle-focused-pressed"],
|
|
11
|
+
["visual_ready", "runtime-visual-ready", "visual_surface_parity", "toggle-focused-pressed"],
|
|
12
|
+
["unknown_scenario", "runtime-unknown-scenario", "state_runtime_unknown_scenario", "action-focused"],
|
|
13
|
+
["expanded_ax_mismatch", "runtime-expanded-ax-mismatch", "expanded_surface_mismatch", "disclosure-expanded-loading"],
|
|
14
|
+
["disabled_activation", "runtime-disabled-activation", "state_activation_key_parity", "action-disabled-busy"],
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const results = cases.map(([name, mutation, expected, scenario]) => {
|
|
18
|
+
const child = spawnSync(
|
|
19
|
+
path.join(repositoryRoot, "node_modules", ".bin", "playwright"),
|
|
20
|
+
["test", "tests/component-state-evidence.spec.mjs", "--project=chromium", "--reporter=line", "--grep", scenario],
|
|
21
|
+
{ cwd: repositoryRoot, encoding: "utf8", env: { ...process.env, STATE_MUTATION: mutation } },
|
|
22
|
+
);
|
|
23
|
+
const output = `${child.stdout}\n${child.stderr}`;
|
|
24
|
+
return {
|
|
25
|
+
actual: { named: output.includes(expected), status: child.status },
|
|
26
|
+
expected,
|
|
27
|
+
name,
|
|
28
|
+
ok: child.status !== 0 && output.includes(expected),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const failures = results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`);
|
|
33
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
34
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
35
|
+
if (!report.ok) process.exitCode = 1;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { execFileSync } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import {
|
|
10
|
+
canonicalSourceManifest,
|
|
11
|
+
repositoryGitArgs,
|
|
12
|
+
sourceManifestMatches,
|
|
13
|
+
} from "./capture-session-contract.mjs";
|
|
14
|
+
import { compileSchemas } from "./component-state-contract.mjs";
|
|
15
|
+
|
|
16
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
17
|
+
const profileRoot = path.join(repositoryRoot, "design-engineering/reference-profiles/governed-local");
|
|
18
|
+
const schemaRoot = path.join(repositoryRoot, "consumer-reference/schema");
|
|
19
|
+
const first = canonicalSourceManifest(repositoryRoot, profileRoot);
|
|
20
|
+
const second = canonicalSourceManifest(repositoryRoot, profileRoot);
|
|
21
|
+
|
|
22
|
+
assert.equal(first.sha256, second.sha256, "source manifest digest must be deterministic");
|
|
23
|
+
assert.deepEqual(first.files, second.files, "source manifest files must be stable");
|
|
24
|
+
assert(first.files.some((entry) => entry.path === "tests/component-state-evidence.spec.mjs"), "capture browser code must be bound");
|
|
25
|
+
assert(first.files.some((entry) => entry.path === "playwright.config.mjs"), "Playwright capture configuration must be bound");
|
|
26
|
+
assert(first.files.some((entry) => entry.path === "package.json"), "capture dependency declarations must be bound");
|
|
27
|
+
assert(first.files.some((entry) => entry.path === "package-lock.json"), "exact capture dependencies must be bound");
|
|
28
|
+
assert(first.files.some((entry) => entry.path === "scripts/artifact-metadata.mjs"), "capture artifact metadata code must be bound");
|
|
29
|
+
assert(first.files.some((entry) => entry.path === "scripts/visual-expectation-contract.mjs"), "visual expectation selection must be bound");
|
|
30
|
+
assert(!first.files.some((entry) => entry.path === "scripts/finalize-component-state-evidence.mjs"), "post-capture finalization must not invalidate captured source identity");
|
|
31
|
+
assert(!first.files.some((entry) => entry.path === "scripts/validate-component-state.mjs"), "post-capture enforcement must not invalidate captured source identity");
|
|
32
|
+
assert(first.files.some((entry) => entry.path.endsWith("/profile.json")), "profile declarations must be bound");
|
|
33
|
+
assert(first.files.some((entry) => entry.path.endsWith("/tokens.dtcg.json")), "profile token inputs must be bound");
|
|
34
|
+
assert.equal(sourceManifestMatches(first, repositoryRoot, profileRoot), true, "canonical source manifest must match itself");
|
|
35
|
+
const revisionArgs = repositoryGitArgs(repositoryRoot, "rev-parse", "HEAD");
|
|
36
|
+
assert.deepEqual(revisionArgs, ["-c", `safe.directory=${repositoryRoot}`, "rev-parse", "HEAD"], "repository Git trust must be scoped to the exact checkout");
|
|
37
|
+
assert.equal(
|
|
38
|
+
execFileSync("git", revisionArgs, {
|
|
39
|
+
cwd: repositoryRoot,
|
|
40
|
+
encoding: "utf8",
|
|
41
|
+
env: { ...process.env, GIT_TEST_ASSUME_DIFFERENT_OWNER: "1" },
|
|
42
|
+
}).trim(),
|
|
43
|
+
execFileSync("git", revisionArgs, { cwd: repositoryRoot, encoding: "utf8" }).trim(),
|
|
44
|
+
"repository Git reads must trust only the exact checkout when container ownership differs",
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-source-contract-"));
|
|
48
|
+
try {
|
|
49
|
+
const copiedProfiles = path.join(tempRoot, "profiles");
|
|
50
|
+
const copiedRepository = path.join(tempRoot, "repository");
|
|
51
|
+
fs.cpSync(profileRoot, copiedProfiles, { recursive: true });
|
|
52
|
+
for (const entry of first.files.filter((candidate) => !candidate.path.startsWith("profiles/"))) {
|
|
53
|
+
const source = path.join(repositoryRoot, entry.path);
|
|
54
|
+
const target = path.join(copiedRepository, entry.path);
|
|
55
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
56
|
+
fs.copyFileSync(source, target);
|
|
57
|
+
}
|
|
58
|
+
const copied = canonicalSourceManifest(copiedRepository, copiedProfiles);
|
|
59
|
+
assert.equal(copied.sha256, first.sha256, "profile-root location must not change the source digest");
|
|
60
|
+
const tokenFile = path.join(copiedProfiles, "editorial/tokens.dtcg.json");
|
|
61
|
+
fs.appendFileSync(tokenFile, "\n");
|
|
62
|
+
assert.equal(sourceManifestMatches(copied, copiedRepository, copiedProfiles), false, "profile source drift must invalidate the manifest");
|
|
63
|
+
fs.copyFileSync(path.join(profileRoot, "editorial/tokens.dtcg.json"), tokenFile);
|
|
64
|
+
const configFile = path.join(copiedRepository, "playwright.config.mjs");
|
|
65
|
+
const config = fs.readFileSync(configFile, "utf8").replace("viewport: { height: 768, width: 1024 },", "deviceScaleFactor: 2,\n viewport: { height: 768, width: 1024 },");
|
|
66
|
+
fs.writeFileSync(configFile, config);
|
|
67
|
+
assert.equal(sourceManifestMatches(copied, copiedRepository, copiedProfiles), false, "deviceScaleFactor drift must invalidate the source manifest before it can double screenshot pixels");
|
|
68
|
+
|
|
69
|
+
const copiedSchemas = path.join(tempRoot, "schemas");
|
|
70
|
+
fs.cpSync(schemaRoot, copiedSchemas, { recursive: true });
|
|
71
|
+
const captureSchema = path.join(copiedSchemas, "capture-session.schema.json");
|
|
72
|
+
const schemaSource = fs.readFileSync(captureSchema, "utf8");
|
|
73
|
+
fs.writeFileSync(captureSchema, schemaSource.replace('"title":', '"title": "shadowed title",\n "title":'));
|
|
74
|
+
assert.throws(
|
|
75
|
+
() => compileSchemas(copiedSchemas),
|
|
76
|
+
(error) => error?.code === "component_schema_json_invalid" && error?.path === captureSchema,
|
|
77
|
+
"duplicate component schema properties must fail strict compilation with a named error",
|
|
78
|
+
);
|
|
79
|
+
} finally {
|
|
80
|
+
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
process.stdout.write(`${JSON.stringify({ files: first.files.length, ok: true, sha256: first.sha256 }, null, 2)}\n`);
|
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
|
|
9
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
|
+
const availableCases = new Map([
|
|
11
|
+
["overflow", { expected: "document_no_horizontal_overflow", grep: "@sentinel-overflow", mutation: "overflow" }],
|
|
12
|
+
["clipped-focus", { expected: "focus_geometry_visible", grep: "@sentinel-clipped-focus", mutation: "clipped-focus" }],
|
|
13
|
+
["low-contrast", { expected: "color-contrast", grep: "@sentinel-low-contrast", mutation: "low-contrast" }],
|
|
14
|
+
["dialog-focus-leak", { expected: "dialog_focus_trap", grep: "@sentinel-dialog-focus-leak", mutation: "dialog-focus-leak" }],
|
|
15
|
+
["console-error", { expected: "console_error_free", grep: "@sentinel-console-error", mutation: "console-error" }],
|
|
16
|
+
["page-evidence-symlink", { expected: "page_evidence_output_symlink", pageEvidence: "symlink" }],
|
|
17
|
+
["page-evidence-existing-output", { expected: "page_evidence_output_exists", pageEvidence: "existing-output" }],
|
|
18
|
+
["ci-cleanup-symlink", { ciCleanup: true, expected: ".tmp must be a real directory" }],
|
|
19
|
+
]);
|
|
20
|
+
const selected = [];
|
|
21
|
+
let json = false;
|
|
22
|
+
const argumentFailures = [];
|
|
23
|
+
|
|
24
|
+
for (let index = 2; index < process.argv.length; index += 1) {
|
|
25
|
+
const argument = process.argv[index];
|
|
26
|
+
if (argument === "--json") json = true;
|
|
27
|
+
else if (argument === "--case") {
|
|
28
|
+
const name = process.argv[index + 1];
|
|
29
|
+
if (!name || name.startsWith("--")) argumentFailures.push("--case requires a value");
|
|
30
|
+
else {
|
|
31
|
+
selected.push(name);
|
|
32
|
+
index += 1;
|
|
33
|
+
}
|
|
34
|
+
} else argumentFailures.push(`unsupported argument ${argument}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const names = selected.length > 0 ? [...new Set(selected)] : [...availableCases.keys()];
|
|
38
|
+
for (const name of names) if (!availableCases.has(name)) argumentFailures.push(`unknown case ${name}`);
|
|
39
|
+
|
|
40
|
+
function runPlaywright(grep, environment) {
|
|
41
|
+
return spawnSync(
|
|
42
|
+
path.join(repositoryRoot, "node_modules", ".bin", "playwright"),
|
|
43
|
+
["test", "tests/consumer-conformance.spec.mjs", "--project=chromium", "--reporter=line", "--grep", grep],
|
|
44
|
+
{
|
|
45
|
+
cwd: repositoryRoot,
|
|
46
|
+
encoding: "utf8",
|
|
47
|
+
env: { ...process.env, ...environment },
|
|
48
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function runMutationControl(name, control) {
|
|
54
|
+
const child = runPlaywright(control.grep, { CONSUMER_CONFORMANCE_MUTATION: control.mutation });
|
|
55
|
+
const output = `${child.stdout}\n${child.stderr}`;
|
|
56
|
+
return {
|
|
57
|
+
actual: { named: output.includes(control.expected), status: child.status },
|
|
58
|
+
expected: control.expected,
|
|
59
|
+
name,
|
|
60
|
+
ok: child.status !== 0 && output.includes(control.expected),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function writeReceipt(root) {
|
|
65
|
+
const receipt = {
|
|
66
|
+
attempt: 1,
|
|
67
|
+
intended_scenario_ids: ["responsive-layout"],
|
|
68
|
+
nonce: "a".repeat(64),
|
|
69
|
+
repository: "changeroa/StyleGallery",
|
|
70
|
+
revision: "b".repeat(40),
|
|
71
|
+
run_id: "consumer-conformance-sentinel-run",
|
|
72
|
+
session_id: "consumer-conformance-sentinel-session",
|
|
73
|
+
source: { sha256: "c".repeat(64) },
|
|
74
|
+
};
|
|
75
|
+
fs.writeFileSync(path.join(root, "page-evidence-session.json"), `${JSON.stringify(receipt)}\n`, { flag: "wx" });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function runPageEvidenceControl(name, control) {
|
|
79
|
+
const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-page-evidence-sentinel-"));
|
|
80
|
+
const observations = [];
|
|
81
|
+
try {
|
|
82
|
+
for (const outputKind of ["captures", "runner"]) {
|
|
83
|
+
const caseRoot = path.join(temporaryRoot, outputKind);
|
|
84
|
+
const artifactRoot = path.join(caseRoot, "artifacts");
|
|
85
|
+
const outside = path.join(caseRoot, "outside");
|
|
86
|
+
fs.mkdirSync(artifactRoot, { recursive: true });
|
|
87
|
+
fs.mkdirSync(outside, { recursive: true });
|
|
88
|
+
writeReceipt(artifactRoot);
|
|
89
|
+
|
|
90
|
+
const filename = outputKind === "captures"
|
|
91
|
+
? "responsive-layout-state-w1024-focus.png"
|
|
92
|
+
: "responsive-layout.json";
|
|
93
|
+
const outputPath = path.join(artifactRoot, outputKind, filename);
|
|
94
|
+
const outsidePath = path.join(outside, filename);
|
|
95
|
+
const marker = "do-not-overwrite";
|
|
96
|
+
if (control.pageEvidence === "symlink") fs.symlinkSync(outside, path.join(artifactRoot, outputKind), "dir");
|
|
97
|
+
else {
|
|
98
|
+
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
|
|
99
|
+
fs.writeFileSync(outputPath, marker, { flag: "wx" });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const child = runPlaywright("state-w1024-focus", {
|
|
103
|
+
CONSUMER_CONFORMANCE_CAPTURE_DIR: "",
|
|
104
|
+
CONSUMER_CONFORMANCE_MUTATION: "none",
|
|
105
|
+
PAGE_EVIDENCE_ARTIFACT_ROOT: artifactRoot,
|
|
106
|
+
PAGE_EVIDENCE_CASE_ID: "state-w1024-focus",
|
|
107
|
+
PAGE_EVIDENCE_SCENARIO_ID: "responsive-layout",
|
|
108
|
+
});
|
|
109
|
+
const output = `${child.stdout}\n${child.stderr}`;
|
|
110
|
+
observations.push({
|
|
111
|
+
named: output.includes(control.expected),
|
|
112
|
+
output_kind: outputKind,
|
|
113
|
+
outside_write: fs.existsSync(outsidePath),
|
|
114
|
+
preserved: control.pageEvidence === "existing-output" ? fs.readFileSync(outputPath, "utf8") === marker : true,
|
|
115
|
+
status: child.status,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
} finally {
|
|
119
|
+
fs.rmSync(temporaryRoot, { force: true, recursive: true });
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
actual: { observations },
|
|
124
|
+
expected: control.expected,
|
|
125
|
+
name,
|
|
126
|
+
ok: observations.every((observation) => observation.status !== 0 && observation.named && !observation.outside_write && observation.preserved),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function runCiCleanupControl(name, control) {
|
|
131
|
+
const workspace = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-ci-cleanup-sentinel-"));
|
|
132
|
+
const outside = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-ci-cleanup-outside-"));
|
|
133
|
+
const marker = path.join(outside, "consumer", "preserve.txt");
|
|
134
|
+
try {
|
|
135
|
+
fs.mkdirSync(path.dirname(marker), { recursive: true });
|
|
136
|
+
fs.writeFileSync(marker, "preserve\n", { flag: "wx" });
|
|
137
|
+
fs.symlinkSync(outside, path.join(workspace, ".tmp"), "dir");
|
|
138
|
+
const child = spawnSync(process.execPath, [path.join(repositoryRoot, "scripts", "run-consumer-page-evidence-ci.mjs"), "cleanup", "--consumer-root", ".tmp/consumer"], { cwd: workspace, encoding: "utf8" });
|
|
139
|
+
const output = `${child.stdout}\n${child.stderr}`;
|
|
140
|
+
return {
|
|
141
|
+
actual: { markerPreserved: fs.readFileSync(marker, "utf8") === "preserve\n", named: output.includes(control.expected), status: child.status },
|
|
142
|
+
expected: control.expected,
|
|
143
|
+
name,
|
|
144
|
+
ok: child.status !== 0 && output.includes(control.expected) && fs.readFileSync(marker, "utf8") === "preserve\n",
|
|
145
|
+
};
|
|
146
|
+
} finally {
|
|
147
|
+
fs.rmSync(workspace, { force: true, recursive: true });
|
|
148
|
+
fs.rmSync(outside, { force: true, recursive: true });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const results = argumentFailures.length === 0 ? names.map((name) => {
|
|
153
|
+
const control = availableCases.get(name);
|
|
154
|
+
return control.pageEvidence ? runPageEvidenceControl(name, control) : control.ciCleanup ? runCiCleanupControl(name, control) : runMutationControl(name, control);
|
|
155
|
+
}) : [];
|
|
156
|
+
|
|
157
|
+
const failures = [
|
|
158
|
+
...argumentFailures.map((message) => `argument_invalid:${message}`),
|
|
159
|
+
...results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`),
|
|
160
|
+
];
|
|
161
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
162
|
+
if (json) process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
163
|
+
else if (report.ok) process.stdout.write(`consumer conformance sentinel passed ${results.length} mutation controls\n`);
|
|
164
|
+
else process.stderr.write(`${failures.join("\n")}\n`);
|
|
165
|
+
if (!report.ok) process.exitCode = 1;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const cases = [
|
|
9
|
+
["hidden_layout", "hidden-layout", "computed_layout_visible"],
|
|
10
|
+
["long_content_reflow", "long-content-reflow", "computed_long_content_reflow"],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
const results = cases.map(([name, mutation, expected]) => {
|
|
14
|
+
const child = spawnSync(
|
|
15
|
+
path.join(repositoryRoot, "node_modules", ".bin", "playwright"),
|
|
16
|
+
["test", "tests/consumer-reference-sentinels.spec.mjs", "--project=chromium", "--reporter=line"],
|
|
17
|
+
{ cwd: repositoryRoot, encoding: "utf8", env: { ...process.env, SENTINEL_MUTATION: mutation } },
|
|
18
|
+
);
|
|
19
|
+
const output = `${child.stdout}\n${child.stderr}`;
|
|
20
|
+
return {
|
|
21
|
+
actual: { named: output.includes(expected), status: child.status },
|
|
22
|
+
expected,
|
|
23
|
+
name,
|
|
24
|
+
ok: child.status !== 0 && output.includes(expected),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const failures = results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`);
|
|
29
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
30
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
31
|
+
if (!report.ok) process.exitCode = 1;
|
|
@@ -0,0 +1,124 @@
|
|
|
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 generator = path.join(repositoryRoot, "scripts/generate-consumer-reference-evidence.mjs");
|
|
13
|
+
|
|
14
|
+
function run(root, check = false, environment = {}) {
|
|
15
|
+
const args = [generator, "--root", root, "--json"];
|
|
16
|
+
if (check) args.push("--check");
|
|
17
|
+
const child = spawnSync(process.execPath, args, { cwd: repositoryRoot, encoding: "utf8", env: { ...process.env, ...environment } });
|
|
18
|
+
let report = { failures: [], ok: false, parse_error: true };
|
|
19
|
+
try { report = JSON.parse(child.stdout); } catch { report = { failures: [], ok: false, parse_error: true }; }
|
|
20
|
+
return { report, status: child.status };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function editJson(file, mutate) {
|
|
24
|
+
const value = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
25
|
+
mutate(value);
|
|
26
|
+
fs.writeFileSync(file, `${JSON.stringify(value, null, 2)}\n`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-pr5-generator-"));
|
|
30
|
+
const results = [];
|
|
31
|
+
|
|
32
|
+
function freshRoot(name) {
|
|
33
|
+
const root = path.join(tempRoot, name);
|
|
34
|
+
fs.cpSync(sourceRoot, root, { recursive: true });
|
|
35
|
+
return root;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function expectFailure(name, expected, root) {
|
|
39
|
+
const child = run(root, true);
|
|
40
|
+
results.push({ expected, name, ok: child.status > 0 && child.report.failures.some((failure) => failure.code === expected) });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function mutateGenerated(name, expected, mutate) {
|
|
44
|
+
const root = freshRoot(name);
|
|
45
|
+
run(root);
|
|
46
|
+
const file = path.join(root, "editorial/generated/state-matrix.md");
|
|
47
|
+
const lines = fs.readFileSync(file, "utf8").split("\n");
|
|
48
|
+
mutate(lines);
|
|
49
|
+
fs.writeFileSync(file, lines.join("\n"));
|
|
50
|
+
expectFailure(name, expected, root);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const canonicalRoot = freshRoot("canonical");
|
|
55
|
+
const generated = run(canonicalRoot);
|
|
56
|
+
results.push({ expected: "canonical_generation", name: "canonical", ok: generated.status === 0 && generated.report.ok && generated.report.scaffold !== true });
|
|
57
|
+
const checked = run(canonicalRoot, true);
|
|
58
|
+
results.push({ expected: "deterministic_zero_drift", name: "check", ok: checked.status === 0 && checked.report.ok && checked.report.scaffold !== true });
|
|
59
|
+
|
|
60
|
+
mutateGenerated("stale", "generated_stale", (lines) => { lines.push("stale"); });
|
|
61
|
+
mutateGenerated("generated_unsorted", "generated_unsorted", (lines) => {
|
|
62
|
+
const first = lines.findIndex((line) => line.startsWith("| <code>"));
|
|
63
|
+
[lines[first], lines[first + 1]] = [lines[first + 1], lines[first]];
|
|
64
|
+
});
|
|
65
|
+
mutateGenerated("generated_duplicate", "generated_duplicate_row", (lines) => {
|
|
66
|
+
const first = lines.findIndex((line) => line.startsWith("| <code>"));
|
|
67
|
+
lines.splice(first + 1, 0, lines[first]);
|
|
68
|
+
});
|
|
69
|
+
mutateGenerated("generated_missing", "generated_missing_row", (lines) => {
|
|
70
|
+
const first = lines.findIndex((line) => line.startsWith("| <code>"));
|
|
71
|
+
lines.splice(first, 1);
|
|
72
|
+
});
|
|
73
|
+
mutateGenerated("source_count", "generated_source_count_mismatch", (lines) => {
|
|
74
|
+
const first = lines.findIndex((line) => line.startsWith("| <code>"));
|
|
75
|
+
lines.splice(first, 1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const unsortedRoot = freshRoot("source_unsorted");
|
|
79
|
+
editJson(path.join(unsortedRoot, "editorial/states/button.states.json"), (value) => { value.scenarios.reverse(); });
|
|
80
|
+
expectFailure("source_unsorted", "source_unsorted", unsortedRoot);
|
|
81
|
+
|
|
82
|
+
const duplicateRoot = freshRoot("scenario_duplicate");
|
|
83
|
+
editJson(path.join(duplicateRoot, "editorial/states/button.states.json"), (value) => { value.scenarios.push({ ...value.scenarios[0] }); });
|
|
84
|
+
expectFailure("scenario_duplicate", "scenario_duplicate", duplicateRoot);
|
|
85
|
+
|
|
86
|
+
const missingRoot = freshRoot("fixture_scenario_missing");
|
|
87
|
+
editJson(path.join(missingRoot, "editorial/states/button.states.json"), (value) => { value.scenarios = value.scenarios.filter((scenario) => scenario.id !== "action-focused"); });
|
|
88
|
+
expectFailure("fixture_scenario_missing", "fixture_scenario_missing", missingRoot);
|
|
89
|
+
|
|
90
|
+
const injectionRoot = freshRoot("markdown_injection");
|
|
91
|
+
editJson(path.join(injectionRoot, "editorial/components/button.component.json"), (value) => { value.semantic_modes[0].element = "<script>alert(1)</script>|`\nnext"; });
|
|
92
|
+
const injection = run(injectionRoot);
|
|
93
|
+
const injectionOutput = fs.readFileSync(path.join(injectionRoot, "editorial/generated/keyboard-matrix.md"), "utf8");
|
|
94
|
+
results.push({
|
|
95
|
+
expected: "escaped_markdown_injection",
|
|
96
|
+
name: "markdown_injection",
|
|
97
|
+
ok: injection.status === 0
|
|
98
|
+
&& injectionOutput.includes("<script>alert(1)</script>|`<br>next")
|
|
99
|
+
&& !injectionOutput.includes("<script>alert(1)</script>"),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const referenceRoot = freshRoot("canonical_reference_discovery");
|
|
103
|
+
fs.copyFileSync(path.join(referenceRoot, "editorial/components/button.component.json"), path.join(referenceRoot, "editorial/components/alternate.component.json"));
|
|
104
|
+
editJson(path.join(referenceRoot, "editorial/components/alternate.component.json"), (value) => { value.semantic_modes[0].element = "canonical alternate element"; });
|
|
105
|
+
editJson(path.join(referenceRoot, "editorial/profile.json"), (value) => { value.component_records = ["components/alternate.component.json"]; });
|
|
106
|
+
editJson(path.join(referenceRoot, "editorial/fixtures/button.fixture.json"), (value) => { value.component_record = "../components/alternate.component.json"; });
|
|
107
|
+
const reference = run(referenceRoot);
|
|
108
|
+
const referenceOutput = fs.readFileSync(path.join(referenceRoot, "editorial/generated/keyboard-matrix.md"), "utf8");
|
|
109
|
+
results.push({ expected: "canonical_profile_reference", name: "canonical_reference_discovery", ok: reference.status === 0 && referenceOutput.includes("canonical alternate element") });
|
|
110
|
+
|
|
111
|
+
const localeRoot = freshRoot("locale_determinism");
|
|
112
|
+
const firstLocale = run(localeRoot, false, { LANG: "C", LC_ALL: "C" });
|
|
113
|
+
const firstBytes = fs.readFileSync(path.join(localeRoot, "editorial/generated/state-matrix.md"));
|
|
114
|
+
const secondLocale = run(localeRoot, false, { LANG: "tr_TR.UTF-8", LC_ALL: "tr_TR.UTF-8" });
|
|
115
|
+
const secondBytes = fs.readFileSync(path.join(localeRoot, "editorial/generated/state-matrix.md"));
|
|
116
|
+
results.push({ expected: "locale_independent_bytes", name: "locale_determinism", ok: firstLocale.status === 0 && secondLocale.status === 0 && firstBytes.equals(secondBytes) });
|
|
117
|
+
} finally {
|
|
118
|
+
fs.rmSync(tempRoot, { recursive: true, force: true });
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const failures = results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`);
|
|
122
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
123
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
124
|
+
assert.equal(report.ok, true);
|