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,427 @@
|
|
|
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 { execFileSync, spawnSync } from "node:child_process";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
import {
|
|
9
|
+
endToEndCaseNames,
|
|
10
|
+
runEndToEndCase,
|
|
11
|
+
} from "../consumer-reference/fixtures/consumer-conformance/e2e-fixture.mjs";
|
|
12
|
+
import { MIGRATION_DIMENSIONS, validateConsumerConformanceSemantics } from "./consumer-conformance-contract.mjs";
|
|
13
|
+
import { canonicalSourceManifest } from "./page-evidence-contract.mjs";
|
|
14
|
+
import { parseStrictJson } from "./strict-json.mjs";
|
|
15
|
+
|
|
16
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
17
|
+
const fixtureRoot = path.join(repositoryRoot, "consumer-reference", "fixtures", "consumer-conformance");
|
|
18
|
+
const validator = path.join(repositoryRoot, "scripts", "validate-consumer-conformance.mjs");
|
|
19
|
+
const contractCases = Object.freeze([
|
|
20
|
+
["omitted-dimension", "migration_dimension_required"],
|
|
21
|
+
["applicable-without-scenario", "migration_dimension_scenario_required"],
|
|
22
|
+
["source-regex-runtime-proof", "runtime_evidence_method_invalid"],
|
|
23
|
+
["orphan-adoption-scenario", "adoption_scenario_unknown"],
|
|
24
|
+
["malformed-local-target", "adoption_consumer_target_invalid"],
|
|
25
|
+
["unpinned-stylegallery-revision", "adoption_stylegallery_revision_unpinned"],
|
|
26
|
+
["unknown-stylegallery-revision", "adoption_stylegallery_revision_unknown"],
|
|
27
|
+
["missing-stylegallery-path", "adoption_stylegallery_path_missing"],
|
|
28
|
+
["missing-stylegallery-anchor", "adoption_stylegallery_anchor_missing"],
|
|
29
|
+
["debt-without-lifecycle", "adoption_debt_incomplete"],
|
|
30
|
+
]);
|
|
31
|
+
const runtimeCases = Object.freeze([
|
|
32
|
+
["missing-source", "consumer_source_missing"],
|
|
33
|
+
["symlink-source", "consumer_source_symlink"],
|
|
34
|
+
["checkout-symlink", "runtime_command_checkout_symlink"],
|
|
35
|
+
["missing-result-artifact", "runtime_result_artifact_missing"],
|
|
36
|
+
["symlink-result-artifact", "runtime_result_artifact_symlink"],
|
|
37
|
+
["invalid-result-artifact-json", "runtime_result_artifact_json_invalid"],
|
|
38
|
+
["fabricated-result-artifact", "runtime_result_artifact_mismatch"],
|
|
39
|
+
["fabricated-repository", "consumer_repository_mismatch"],
|
|
40
|
+
["fabricated-revision", "consumer_revision_unknown"],
|
|
41
|
+
["fabricated-source-digest", "runtime_source_digest_mismatch"],
|
|
42
|
+
["nonzero-command", "runtime_command_failed"],
|
|
43
|
+
["forged-noop-result", "runtime_command_result_missing"],
|
|
44
|
+
["github-repository-spoof", "consumer_repository_mismatch", { GITHUB_REPOSITORY: "example/spoof" }],
|
|
45
|
+
]);
|
|
46
|
+
const documentedLifecycleCase = "documented-page-evidence-lifecycle";
|
|
47
|
+
|
|
48
|
+
function parseArguments(argv) {
|
|
49
|
+
const options = { caseName: undefined, json: false };
|
|
50
|
+
for (let index = 2; index < argv.length; index += 1) {
|
|
51
|
+
const argument = argv[index];
|
|
52
|
+
if (argument === "--json") options.json = true;
|
|
53
|
+
else if (argument === "--case") {
|
|
54
|
+
const value = argv[index + 1];
|
|
55
|
+
if (!value || value.startsWith("--")) throw new Error("--case requires a case name");
|
|
56
|
+
options.caseName = value;
|
|
57
|
+
index += 1;
|
|
58
|
+
} else throw new Error(`unsupported argument ${argument}`);
|
|
59
|
+
}
|
|
60
|
+
return options;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function sameSet(actual, expected) {
|
|
64
|
+
return actual.length === expected.length && new Set(actual).size === expected.length && expected.every((entry) => actual.includes(entry));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function readJson(file) {
|
|
68
|
+
return parseStrictJson(fs.readFileSync(file, "utf8"));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function validateInventory(manifest) {
|
|
72
|
+
const expectedKeys = ["id", "invalid_cases", "schema_record", "schema_version", "valid_records"];
|
|
73
|
+
const encodedCases = Array.isArray(manifest.invalid_cases)
|
|
74
|
+
? manifest.invalid_cases.map((entry) => Object.keys(entry).length === 2 ? `${entry.name}:${entry.expected_code}` : "")
|
|
75
|
+
: [];
|
|
76
|
+
const expectedEncoded = [...contractCases, ...runtimeCases].map(([name, code]) => `${name}:${code}`);
|
|
77
|
+
const entries = fs.readdirSync(fixtureRoot, { withFileTypes: true });
|
|
78
|
+
const closedFiles = entries.every((entry) => entry.isFile())
|
|
79
|
+
&& sameSet(entries.map((entry) => entry.name), ["e2e-fixture.mjs", "manifest.json", "runtime-proof.mjs", "valid-migration-result.json", "valid-migration.json"]);
|
|
80
|
+
return Object.keys(manifest).length === expectedKeys.length
|
|
81
|
+
&& sameSet(Object.keys(manifest), expectedKeys)
|
|
82
|
+
&& manifest.id === "consumer-conformance-fixture-inventory"
|
|
83
|
+
&& manifest.schema_version === "1.0"
|
|
84
|
+
&& manifest.schema_record === "consumer-reference/schema/consumer-conformance-record.schema.json"
|
|
85
|
+
&& Array.isArray(manifest.valid_records)
|
|
86
|
+
&& sameSet(manifest.valid_records, ["valid-migration.json"])
|
|
87
|
+
&& sameSet(encodedCases, expectedEncoded)
|
|
88
|
+
&& closedFiles;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function git(root, ...args) {
|
|
92
|
+
return execFileSync("git", ["-c", `safe.directory=${root}`, ...args], { cwd: root, encoding: "utf8" }).trim();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function writeFile(root, reference, content) {
|
|
96
|
+
const file = path.join(root, reference);
|
|
97
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
98
|
+
fs.writeFileSync(file, content);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function runtimeResult(value, overrides = {}) {
|
|
102
|
+
const scenario = value.scenarios[0];
|
|
103
|
+
return {
|
|
104
|
+
argv: scenario.argv,
|
|
105
|
+
evidence_method: scenario.evidence_method,
|
|
106
|
+
exit_code: scenario.exit_code,
|
|
107
|
+
record_kind: "consumer_migration_scenario_result",
|
|
108
|
+
recorded_at: "2026-07-21T00:00:00Z",
|
|
109
|
+
repository: value.consumer.repository,
|
|
110
|
+
revision: value.consumer.revision,
|
|
111
|
+
run_id: scenario.run_id,
|
|
112
|
+
scenario_id: scenario.id,
|
|
113
|
+
schema_version: "1.0",
|
|
114
|
+
session_id: scenario.session_id,
|
|
115
|
+
source_digest: scenario.source_digest,
|
|
116
|
+
status: "passed",
|
|
117
|
+
...overrides,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function initializeRuntimeFixture(source) {
|
|
122
|
+
const root = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-consumer-runtime-")));
|
|
123
|
+
execFileSync("git", ["init", "-b", "main"], { cwd: root, stdio: "ignore" });
|
|
124
|
+
git(root, "config", "user.email", "fixture@example.com");
|
|
125
|
+
git(root, "config", "user.name", "StyleGallery fixture");
|
|
126
|
+
git(root, "remote", "add", "origin", "https://github.com/example/consumer-web.git");
|
|
127
|
+
writeFile(root, "src/app.js", "export const app = true;\n");
|
|
128
|
+
writeFile(root, "src/styles.css", ".app { display: block; }\n");
|
|
129
|
+
writeFile(root, "tests/migration.mjs", `import fs from "node:fs";\nimport path from "node:path";\nimport { spawnSync } from "node:child_process";\nif (process.argv.includes("--lock-worktree")) { const locked = spawnSync("git", ["worktree", "lock", "."]); if (locked.status !== 0) process.exit(18); }\nconst reference = process.env.STYLEGALLERY_RESULT_ARTIFACT;\nconst context = JSON.parse(process.env.STYLEGALLERY_RUNTIME_CONTEXT);\nconst file = path.resolve(process.cwd(), reference);\nfs.mkdirSync(path.dirname(file), { recursive: true });\nif (process.argv.includes("--oversized-result")) { const descriptor = fs.openSync(file, "wx"); fs.ftruncateSync(descriptor, 67108865); fs.closeSync(descriptor); process.exit(0); }\nfs.writeFileSync(file, JSON.stringify({ ...context, record_kind: "consumer_migration_scenario_result", recorded_at: "2026-07-21T00:00:00Z", schema_version: "1.0", status: "passed" }, null, 2) + "\\n", { flag: "wx" });\n`);
|
|
130
|
+
writeFile(root, "tests/failing.mjs", "process.exit(17);\n");
|
|
131
|
+
writeFile(root, "tests/hanging.mjs", "setInterval(() => {}, 1000);\n");
|
|
132
|
+
writeFile(root, "tests/noop.mjs", "// Intentionally produces no result artifact.\n");
|
|
133
|
+
git(root, "add", "src/app.js", "src/styles.css", "tests/migration.mjs", "tests/failing.mjs", "tests/hanging.mjs", "tests/noop.mjs");
|
|
134
|
+
git(root, "commit", "-m", "fixture sources");
|
|
135
|
+
const cleanRevision = git(root, "rev-parse", "HEAD");
|
|
136
|
+
fs.symlinkSync("app.js", path.join(root, "src/linked.js"));
|
|
137
|
+
git(root, "add", "src/linked.js");
|
|
138
|
+
git(root, "commit", "-m", "fixture symlink source");
|
|
139
|
+
const symlinkRevision = git(root, "rev-parse", "HEAD");
|
|
140
|
+
git(root, "reset", "--hard", cleanRevision);
|
|
141
|
+
|
|
142
|
+
const value = structuredClone(source);
|
|
143
|
+
value.consumer = {
|
|
144
|
+
relevant_sources: ["src/app.js", "src/styles.css", "tests/migration.mjs"],
|
|
145
|
+
repository: "example/consumer-web",
|
|
146
|
+
revision: git(root, "rev-parse", "HEAD"),
|
|
147
|
+
};
|
|
148
|
+
const styleGalleryRevision = git(repositoryRoot, "rev-parse", "HEAD");
|
|
149
|
+
for (const mapping of value.adoption_mappings) mapping.stylegallery.revision = styleGalleryRevision;
|
|
150
|
+
const sourceFailures = [];
|
|
151
|
+
const manifest = canonicalSourceManifest(root, value.consumer.relevant_sources, sourceFailures);
|
|
152
|
+
if (!manifest || sourceFailures.length > 0) throw new Error(`runtime fixture source manifest failed: ${JSON.stringify(sourceFailures)}`);
|
|
153
|
+
value.scenarios[0] = {
|
|
154
|
+
...value.scenarios[0],
|
|
155
|
+
argv: ["node", "tests/migration.mjs"],
|
|
156
|
+
evidence_method: "integration",
|
|
157
|
+
result_artifact: "evidence/results/migration-round-trip.json",
|
|
158
|
+
source_digest: manifest.sha256,
|
|
159
|
+
};
|
|
160
|
+
writeFile(root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
161
|
+
writeFile(root, "evidence/results/fabricated.json", `${JSON.stringify(runtimeResult(value, { scenario_id: "fabricated-scenario" }), null, 2)}\n`);
|
|
162
|
+
const failing = structuredClone(value);
|
|
163
|
+
failing.scenarios[0].argv = ["node", "tests/failing.mjs"];
|
|
164
|
+
failing.scenarios[0].result_artifact = "evidence/results/nonzero-command.json";
|
|
165
|
+
writeFile(root, failing.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(failing), null, 2)}\n`);
|
|
166
|
+
const noop = structuredClone(value);
|
|
167
|
+
noop.scenarios[0].argv = ["node", "tests/noop.mjs"];
|
|
168
|
+
noop.scenarios[0].result_artifact = "evidence/results/forged-noop-result.json";
|
|
169
|
+
writeFile(root, noop.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(noop), null, 2)}\n`);
|
|
170
|
+
writeFile(root, "evidence/results/invalid.json", "{not json}\n");
|
|
171
|
+
fs.symlinkSync("migration-round-trip.json", path.join(root, "evidence/results/redirect.json"));
|
|
172
|
+
return { root, symlinkRevision, value };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function mutatedRuntimeRecord(name, source, fixture) {
|
|
176
|
+
const value = structuredClone(source);
|
|
177
|
+
if (name === "missing-source") value.consumer.relevant_sources[0] = "src/missing.js";
|
|
178
|
+
else if (name === "symlink-source") {
|
|
179
|
+
value.consumer.relevant_sources[0] = "src/linked.js";
|
|
180
|
+
value.consumer.revision = fixture.symlinkRevision;
|
|
181
|
+
}
|
|
182
|
+
else if (name === "checkout-symlink") value.consumer.revision = fixture.symlinkRevision;
|
|
183
|
+
else if (name === "missing-result-artifact") value.scenarios[0].result_artifact = "evidence/results/missing.json";
|
|
184
|
+
else if (name === "symlink-result-artifact") value.scenarios[0].result_artifact = "evidence/results/redirect.json";
|
|
185
|
+
else if (name === "invalid-result-artifact-json") value.scenarios[0].result_artifact = "evidence/results/invalid.json";
|
|
186
|
+
else if (name === "fabricated-result-artifact") value.scenarios[0].result_artifact = "evidence/results/fabricated.json";
|
|
187
|
+
else if (name === "fabricated-repository") value.consumer.repository = "fabricated/consumer";
|
|
188
|
+
else if (name === "fabricated-revision") value.consumer.revision = "0".repeat(40);
|
|
189
|
+
else if (name === "fabricated-source-digest") value.scenarios[0].source_digest = "0".repeat(64);
|
|
190
|
+
else if (name === "nonzero-command") {
|
|
191
|
+
value.scenarios[0].argv = ["node", "tests/failing.mjs"];
|
|
192
|
+
value.scenarios[0].result_artifact = "evidence/results/nonzero-command.json";
|
|
193
|
+
}
|
|
194
|
+
else if (name === "forged-noop-result") {
|
|
195
|
+
value.scenarios[0].argv = ["node", "tests/noop.mjs"];
|
|
196
|
+
value.scenarios[0].result_artifact = "evidence/results/forged-noop-result.json";
|
|
197
|
+
}
|
|
198
|
+
else if (name === "github-repository-spoof") value.consumer.repository = "example/spoof";
|
|
199
|
+
else throw new Error(`unknown runtime fixture case ${name}`);
|
|
200
|
+
return value;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function documentedLifecycleIsExecutable() {
|
|
204
|
+
const document = fs.readFileSync(path.join(repositoryRoot, "design-engineering", "consumer-migration-readiness.md"), "utf8");
|
|
205
|
+
const start = document.indexOf("## Verification Contract");
|
|
206
|
+
const end = document.indexOf("## Source, License, And Attribution");
|
|
207
|
+
const verification = document.slice(start, end);
|
|
208
|
+
return [
|
|
209
|
+
"create-page-evidence-session.mjs",
|
|
210
|
+
"finalize-page-evidence.mjs",
|
|
211
|
+
"validate-consumer-conformance.mjs",
|
|
212
|
+
"--root <consumer-root>",
|
|
213
|
+
"--record <record.json>",
|
|
214
|
+
"--artifact-root <artifact-root>",
|
|
215
|
+
"--runner-result <runner-result.json>",
|
|
216
|
+
"--review-by <RFC3339-date-time>",
|
|
217
|
+
].every((fragment) => verification.includes(fragment));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function mutatedRecord(name, source) {
|
|
221
|
+
const value = structuredClone(source);
|
|
222
|
+
if (name === "omitted-dimension") delete value.migration_dimensions.exact_time_boundary;
|
|
223
|
+
else if (name === "applicable-without-scenario") value.migration_dimensions.route_parity = { scenario_ids: [], status: "applicable" };
|
|
224
|
+
else if (name === "source-regex-runtime-proof") value.scenarios[0].evidence_method = "source_regex";
|
|
225
|
+
else if (name === "orphan-adoption-scenario") value.adoption_mappings[0].scenario_ids = ["missing-scenario"];
|
|
226
|
+
else if (name === "malformed-local-target") value.adoption_mappings[0].consumer_target = { identity: "app shell", kind: "selector" };
|
|
227
|
+
else if (name === "unpinned-stylegallery-revision") value.adoption_mappings[0].stylegallery.revision = "abc123";
|
|
228
|
+
else if (name === "unknown-stylegallery-revision") value.adoption_mappings[0].stylegallery.revision = "0".repeat(40);
|
|
229
|
+
else if (name === "missing-stylegallery-path") value.adoption_mappings[0].stylegallery.path = "recipes/missing.md";
|
|
230
|
+
else if (name === "missing-stylegallery-anchor") value.adoption_mappings[0].stylegallery.anchor = "#missing-anchor";
|
|
231
|
+
else if (name === "debt-without-lifecycle") value.adoption_mappings[0].debt = [{ summary: "Replace the temporary spacing bridge." }];
|
|
232
|
+
else throw new Error(`unknown fixture case ${name}`);
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function runValidator(root, record, env = {}) {
|
|
237
|
+
const child = spawnSync(process.execPath, [validator, "--root", root, "--record", record, "--json"], {
|
|
238
|
+
cwd: repositoryRoot,
|
|
239
|
+
encoding: "utf8",
|
|
240
|
+
env: { ...process.env, ...env },
|
|
241
|
+
});
|
|
242
|
+
let output;
|
|
243
|
+
try {
|
|
244
|
+
output = JSON.parse(child.stdout);
|
|
245
|
+
} catch {
|
|
246
|
+
output = { failures: [], parse_error: child.stderr || child.stdout };
|
|
247
|
+
}
|
|
248
|
+
return { output, status: child.status };
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const options = parseArguments(process.argv);
|
|
252
|
+
const tempRoot = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-consumer-conformance-")));
|
|
253
|
+
const results = [];
|
|
254
|
+
let runtimeFixture;
|
|
255
|
+
try {
|
|
256
|
+
const manifest = readJson(path.join(fixtureRoot, "manifest.json"));
|
|
257
|
+
const inventoryOk = validateInventory(manifest) && fs.existsSync(path.join(repositoryRoot, manifest.schema_record));
|
|
258
|
+
results.push({ actual: inventoryOk, expected: true, name: "closed-fixture-inventory", ok: inventoryOk });
|
|
259
|
+
const valid = readJson(path.join(fixtureRoot, "valid-migration.json"));
|
|
260
|
+
const selected = options.caseName ?? "all";
|
|
261
|
+
for (const name of endToEndCaseNames) {
|
|
262
|
+
if (selected === "all" || selected === name) results.push(runEndToEndCase(name, valid));
|
|
263
|
+
}
|
|
264
|
+
if (selected === "all" || selected === "valid-migration") {
|
|
265
|
+
const codes = validateConsumerConformanceSemantics(valid, "valid-migration.json").map((entry) => entry.code);
|
|
266
|
+
const checkedDimensions = Object.keys(valid.migration_dimensions ?? {}).length;
|
|
267
|
+
const checkedMappings = valid.adoption_mappings?.length ?? 0;
|
|
268
|
+
const ok = codes.length === 0 && checkedDimensions === MIGRATION_DIMENSIONS.length && checkedMappings === 1;
|
|
269
|
+
results.push({ actual: { checkedDimensions, checkedMappings, codes }, expected: "valid static template, 13 dimensions, one mapping", name: "valid-migration", ok });
|
|
270
|
+
}
|
|
271
|
+
if (selected === "all" || selected === "stale-template-rebound") {
|
|
272
|
+
const stale = structuredClone(valid);
|
|
273
|
+
stale.adoption_mappings[0].stylegallery.revision = "0".repeat(40);
|
|
274
|
+
const result = runEndToEndCase("end-to-end-consumer", stale);
|
|
275
|
+
results.push({ ...result, expected: "dynamic record rebound to the current StyleGallery checkout", name: "stale-template-rebound" });
|
|
276
|
+
}
|
|
277
|
+
const contractTemplate = structuredClone(valid);
|
|
278
|
+
const styleGalleryRevision = git(repositoryRoot, "rev-parse", "HEAD");
|
|
279
|
+
for (const mapping of contractTemplate.adoption_mappings) mapping.stylegallery.revision = styleGalleryRevision;
|
|
280
|
+
for (const [name, expectedCode] of contractCases) {
|
|
281
|
+
if (selected !== "all" && selected !== name) continue;
|
|
282
|
+
const record = path.join(tempRoot, `${name}.json`);
|
|
283
|
+
fs.writeFileSync(record, `${JSON.stringify(mutatedRecord(name, contractTemplate), null, 2)}\n`);
|
|
284
|
+
const child = runValidator(tempRoot, path.basename(record));
|
|
285
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
286
|
+
const ok = child.status !== 0 && codes.includes(expectedCode);
|
|
287
|
+
results.push({ actual: { codes, status: child.status }, expected: expectedCode, name, ok });
|
|
288
|
+
}
|
|
289
|
+
const runtimeTemplate = structuredClone(valid);
|
|
290
|
+
runtimeTemplate.adoption_mappings[0].stylegallery.revision = "0".repeat(40);
|
|
291
|
+
runtimeFixture = initializeRuntimeFixture(runtimeTemplate);
|
|
292
|
+
if (selected === "all" || selected === "valid-runtime-proof") {
|
|
293
|
+
const record = "records/valid-runtime-proof.json";
|
|
294
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(runtimeFixture.value, null, 2)}\n`);
|
|
295
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
296
|
+
const ok = child.status === 0 && child.output.ok === true && child.output.checkedScenarios === 1;
|
|
297
|
+
results.push({ actual: { codes: child.output.failures?.map((entry) => entry.code) ?? [], status: child.status }, expected: "runtime-bound record and exit:0", name: "valid-runtime-proof", ok });
|
|
298
|
+
}
|
|
299
|
+
for (const [name, expectedCode, env] of runtimeCases) {
|
|
300
|
+
if (selected !== "all" && selected !== name) continue;
|
|
301
|
+
const record = `records/${name}.json`;
|
|
302
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(mutatedRuntimeRecord(name, runtimeFixture.value, runtimeFixture), null, 2)}\n`);
|
|
303
|
+
const child = runValidator(runtimeFixture.root, record, env);
|
|
304
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
305
|
+
const ok = child.status !== 0 && codes.includes(expectedCode);
|
|
306
|
+
results.push({ actual: { codes, status: child.status }, expected: expectedCode, name, ok });
|
|
307
|
+
}
|
|
308
|
+
if (selected === "all" || selected === "child-process-denied-cleanup") {
|
|
309
|
+
const value = structuredClone(runtimeFixture.value);
|
|
310
|
+
value.scenarios[0].argv = ["node", "tests/migration.mjs", "--lock-worktree"];
|
|
311
|
+
value.scenarios[0].result_artifact = "evidence/results/locked-worktree-cleanup.json";
|
|
312
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
313
|
+
const record = "records/locked-worktree-cleanup.json";
|
|
314
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
315
|
+
const before = git(runtimeFixture.root, "worktree", "list", "--porcelain");
|
|
316
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
317
|
+
const after = git(runtimeFixture.root, "worktree", "list", "--porcelain");
|
|
318
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
319
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_failed") && before === after;
|
|
320
|
+
results.push({ actual: { codes, registeredWorktreesUnchanged: before === after, status: child.status }, expected: "child process denied and no registered temporary worktree", name: "child-process-denied-cleanup", ok });
|
|
321
|
+
}
|
|
322
|
+
if (selected === "all" || selected === "timed-out-command-cleanup") {
|
|
323
|
+
const value = structuredClone(runtimeFixture.value);
|
|
324
|
+
value.scenarios[0].argv = ["node", "tests/hanging.mjs"];
|
|
325
|
+
value.scenarios[0].result_artifact = "evidence/results/timed-out-command.json";
|
|
326
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
327
|
+
const record = "records/timed-out-command.json";
|
|
328
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
329
|
+
const before = git(runtimeFixture.root, "worktree", "list", "--porcelain");
|
|
330
|
+
const child = runValidator(runtimeFixture.root, record, { STYLEGALLERY_RUNTIME_TIMEOUT_MS: "100" });
|
|
331
|
+
const after = git(runtimeFixture.root, "worktree", "list", "--porcelain");
|
|
332
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
333
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_failed") && before === after;
|
|
334
|
+
results.push({ actual: { codes, registeredWorktreesUnchanged: before === after, status: child.status }, expected: "timeout and no registered temporary worktree", name: "timed-out-command-cleanup", ok });
|
|
335
|
+
}
|
|
336
|
+
if (selected === "all" || selected === "permission-override-denied") {
|
|
337
|
+
const value = structuredClone(runtimeFixture.value);
|
|
338
|
+
value.scenarios[0].argv = ["node", "--allow-child-process", "tests/migration.mjs"];
|
|
339
|
+
value.scenarios[0].result_artifact = "evidence/results/permission-override.json";
|
|
340
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
341
|
+
const record = "records/permission-override.json";
|
|
342
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
343
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
344
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
345
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_argv_unsafe") && child.output.checkedRuntimeCommands === 0;
|
|
346
|
+
results.push({ actual: { checkedRuntimeCommands: child.output.checkedRuntimeCommands, codes, status: child.status }, expected: "permission override rejected before execution", name: "permission-override-denied", ok });
|
|
347
|
+
}
|
|
348
|
+
if (selected === "all" || selected === "permission-disable-denied") {
|
|
349
|
+
const value = structuredClone(runtimeFixture.value);
|
|
350
|
+
value.scenarios[0].argv = ["node", "--no-permission=false", "tests/migration.mjs"];
|
|
351
|
+
value.scenarios[0].result_artifact = "evidence/results/permission-disable.json";
|
|
352
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
353
|
+
const record = "records/permission-disable.json";
|
|
354
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
355
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
356
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
357
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_argv_unsafe") && child.output.checkedRuntimeCommands === 0;
|
|
358
|
+
results.push({ actual: { checkedRuntimeCommands: child.output.checkedRuntimeCommands, codes, status: child.status }, expected: "permission disable rejected before execution", name: "permission-disable-denied", ok });
|
|
359
|
+
}
|
|
360
|
+
if (selected === "all" || selected === "permission-underscore-denied") {
|
|
361
|
+
const value = structuredClone(runtimeFixture.value);
|
|
362
|
+
value.scenarios[0].argv = ["node", "--allow_child_process", "tests/migration.mjs"];
|
|
363
|
+
value.scenarios[0].result_artifact = "evidence/results/permission-underscore.json";
|
|
364
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
365
|
+
const record = "records/permission-underscore.json";
|
|
366
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
367
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
368
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
369
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_argv_unsafe") && child.output.checkedRuntimeCommands === 0;
|
|
370
|
+
results.push({ actual: { checkedRuntimeCommands: child.output.checkedRuntimeCommands, codes, status: child.status }, expected: "underscore permission override rejected before execution", name: "permission-underscore-denied", ok });
|
|
371
|
+
}
|
|
372
|
+
if (selected === "all" || selected === "permission-path-shaped-denied") {
|
|
373
|
+
const value = structuredClone(runtimeFixture.value);
|
|
374
|
+
value.scenarios[0].argv = ["node", "--allow-fs-read=/tmp/outside.mjs", "tests/migration.mjs"];
|
|
375
|
+
value.scenarios[0].result_artifact = "evidence/results/permission-path-shaped.json";
|
|
376
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
377
|
+
const record = "records/permission-path-shaped.json";
|
|
378
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
379
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
380
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
381
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_argv_unsafe") && child.output.checkedRuntimeCommands === 0;
|
|
382
|
+
results.push({ actual: { checkedRuntimeCommands: child.output.checkedRuntimeCommands, codes, status: child.status }, expected: "path-shaped permission option rejected before execution", name: "permission-path-shaped-denied", ok });
|
|
383
|
+
}
|
|
384
|
+
if (selected === "all" || selected === "oversized-command-result") {
|
|
385
|
+
const value = structuredClone(runtimeFixture.value);
|
|
386
|
+
value.scenarios[0].argv = ["node", "tests/migration.mjs", "--oversized-result"];
|
|
387
|
+
value.scenarios[0].result_artifact = "evidence/results/oversized-command-result.json";
|
|
388
|
+
writeFile(runtimeFixture.root, value.scenarios[0].result_artifact, `${JSON.stringify(runtimeResult(value), null, 2)}\n`);
|
|
389
|
+
const record = "records/oversized-command-result.json";
|
|
390
|
+
writeFile(runtimeFixture.root, record, `${JSON.stringify(value, null, 2)}\n`);
|
|
391
|
+
const child = runValidator(runtimeFixture.root, record);
|
|
392
|
+
const codes = child.output.failures?.map((entry) => entry.code) ?? [];
|
|
393
|
+
const ok = child.status !== 0 && codes.includes("runtime_command_result_missing") && child.output.checkedRuntimeCommands === 0;
|
|
394
|
+
results.push({ actual: { checkedRuntimeCommands: child.output.checkedRuntimeCommands, codes, status: child.status }, expected: "oversized command result rejected before read", name: "oversized-command-result", ok });
|
|
395
|
+
}
|
|
396
|
+
if (selected === "all" || selected === documentedLifecycleCase) {
|
|
397
|
+
const actual = documentedLifecycleIsExecutable();
|
|
398
|
+
results.push({ actual, expected: true, name: documentedLifecycleCase, ok: actual });
|
|
399
|
+
}
|
|
400
|
+
const knownCase = selected === "all"
|
|
401
|
+
|| selected === "valid-migration"
|
|
402
|
+
|| selected === "valid-runtime-proof"
|
|
403
|
+
|| selected === "stale-template-rebound"
|
|
404
|
+
|| selected === documentedLifecycleCase
|
|
405
|
+
|| selected === "child-process-denied-cleanup"
|
|
406
|
+
|| selected === "timed-out-command-cleanup"
|
|
407
|
+
|| selected === "permission-override-denied"
|
|
408
|
+
|| selected === "permission-disable-denied"
|
|
409
|
+
|| selected === "permission-underscore-denied"
|
|
410
|
+
|| selected === "permission-path-shaped-denied"
|
|
411
|
+
|| selected === "oversized-command-result"
|
|
412
|
+
|| endToEndCaseNames.includes(selected)
|
|
413
|
+
|| contractCases.some(([name]) => name === selected)
|
|
414
|
+
|| runtimeCases.some(([name]) => name === selected);
|
|
415
|
+
if (!knownCase) {
|
|
416
|
+
results.push({ actual: selected, expected: "known case", name: "case-selection", ok: false });
|
|
417
|
+
}
|
|
418
|
+
} finally {
|
|
419
|
+
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
420
|
+
if (runtimeFixture) fs.rmSync(runtimeFixture.root, { force: true, recursive: true });
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const result = { ok: results.every((entry) => entry.ok), results };
|
|
424
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
425
|
+
else if (result.ok) console.log(`ok: ${results.length} consumer conformance fixture cases`);
|
|
426
|
+
else console.error(results.filter((entry) => !entry.ok).map((entry) => `${entry.name}: expected ${entry.expected}`).join("\n"));
|
|
427
|
+
process.exitCode = result.ok ? 0 : 1;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
7
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
const validator = path.join(repositoryRoot, "scripts", "validate-consumer-reference.mjs");
|
|
9
|
+
const validItem = "consumer-reference/fixtures/valid-experimental.json";
|
|
10
|
+
const errorCases = [
|
|
11
|
+
{ args: ["--item", "--json"], codes: ["argument_value_required"], name: "item_missing_value_before_json" },
|
|
12
|
+
{ args: ["--item", "--unknown", "--json"], codes: ["argument_value_required", "argument_unknown"], name: "item_missing_value_before_unknown" },
|
|
13
|
+
{ args: ["--profile", "--json"], codes: ["argument_value_required"], name: "profile_missing_value_before_json" },
|
|
14
|
+
{ args: ["--profile", "--unknown", "--json"], codes: ["argument_value_required", "argument_unknown"], name: "profile_missing_value_before_unknown" },
|
|
15
|
+
{ args: ["--json", "--item"], codes: ["argument_value_required"], name: "json_before_item_missing_value" },
|
|
16
|
+
{ args: ["--json", "--profile"], codes: ["argument_value_required"], name: "json_before_profile_missing_value" },
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function run(args) {
|
|
20
|
+
return spawnSync(process.execPath, [validator, ...args], {
|
|
21
|
+
cwd: repositoryRoot,
|
|
22
|
+
encoding: "utf8",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function runErrorCase(testCase) {
|
|
27
|
+
const child = run(testCase.args);
|
|
28
|
+
let report;
|
|
29
|
+
try {
|
|
30
|
+
report = JSON.parse(child.stdout);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
return {
|
|
33
|
+
actual: { stderr: child.stderr.trim(), status: child.status, stdout: child.stdout },
|
|
34
|
+
expected: `${testCase.codes.join(",")} in parseable JSON with nonzero exit`,
|
|
35
|
+
name: testCase.name,
|
|
36
|
+
ok: false,
|
|
37
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const codes = Array.isArray(report.failures) ? report.failures.map((failure) => failure.code) : [];
|
|
41
|
+
return {
|
|
42
|
+
actual: { codes, ok: report.ok, status: child.status, stderr: child.stderr.trim() },
|
|
43
|
+
expected: `${testCase.codes.join(",")} in parseable JSON with nonzero exit`,
|
|
44
|
+
name: testCase.name,
|
|
45
|
+
ok: child.status !== 0
|
|
46
|
+
&& child.stderr.length === 0
|
|
47
|
+
&& report.ok === false
|
|
48
|
+
&& codes.length === testCase.codes.length
|
|
49
|
+
&& testCase.codes.every((code) => codes.includes(code)),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const results = errorCases.map(runErrorCase);
|
|
54
|
+
const jsonLast = run(["--item", validItem, "--json"]);
|
|
55
|
+
const jsonFirst = run(["--json", "--item", validItem]);
|
|
56
|
+
results.push({
|
|
57
|
+
actual: { firstStatus: jsonFirst.status, lastStatus: jsonLast.status, stderr: `${jsonFirst.stderr}${jsonLast.stderr}` },
|
|
58
|
+
expected: "valid arguments produce byte-identical JSON regardless of --json position",
|
|
59
|
+
name: "valid_json_option_order",
|
|
60
|
+
ok: jsonFirst.status === 0
|
|
61
|
+
&& jsonLast.status === 0
|
|
62
|
+
&& jsonFirst.stderr.length === 0
|
|
63
|
+
&& jsonLast.stderr.length === 0
|
|
64
|
+
&& jsonFirst.stdout === jsonLast.stdout,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const report = { ok: results.every((result) => result.ok), results };
|
|
68
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
69
|
+
process.exitCode = report.ok ? 0 : 1;
|