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,151 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from "node:child_process";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
|
|
8
|
+
const scriptPath = fileURLToPath(import.meta.url);
|
|
9
|
+
const root = path.resolve(path.dirname(scriptPath), "..");
|
|
10
|
+
const cases = [
|
|
11
|
+
{ kind: "validator", script: "validate-consumer-reference.mjs" },
|
|
12
|
+
{ kind: "harness", script: "test-validate-consumer-reference.mjs" },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
function reportIsComplete(kind, report) {
|
|
16
|
+
if (!report || typeof report !== "object" || report.ok !== true) return false;
|
|
17
|
+
if (kind === "validator") {
|
|
18
|
+
return Number.isInteger(report.checkedItems)
|
|
19
|
+
&& report.checkedItems > 0
|
|
20
|
+
&& Array.isArray(report.profiles);
|
|
21
|
+
}
|
|
22
|
+
return kind === "harness" && Array.isArray(report.results) && report.results.length > 30;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function readStream(stream) {
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
stream.setEncoding("utf8");
|
|
28
|
+
let output = "";
|
|
29
|
+
stream.on("data", (chunk) => { output += chunk; });
|
|
30
|
+
stream.once("end", () => resolve(output));
|
|
31
|
+
stream.once("error", reject);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function waitForClose(child, label) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
child.once("error", (error) => reject(new Error(`${label} failed to start: ${error.message}`, { cause: error })));
|
|
38
|
+
child.once("close", (status, signal) => resolve({ signal, status }));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function parsePipe(kind) {
|
|
43
|
+
try {
|
|
44
|
+
const output = await readStream(process.stdin);
|
|
45
|
+
const report = JSON.parse(output);
|
|
46
|
+
const complete = reportIsComplete(kind, report);
|
|
47
|
+
const summary = {
|
|
48
|
+
bytes: Buffer.byteLength(output),
|
|
49
|
+
complete,
|
|
50
|
+
digest: createHash("sha256").update(output).digest("hex"),
|
|
51
|
+
};
|
|
52
|
+
process.stdout.write(`${JSON.stringify(summary)}\n`);
|
|
53
|
+
process.exitCode = complete ? 0 : 1;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function runPipeCase(testCase, run) {
|
|
61
|
+
const producer = spawn(process.execPath, [path.join(root, "scripts", testCase.script), "--json"], {
|
|
62
|
+
cwd: root,
|
|
63
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
64
|
+
});
|
|
65
|
+
const parser = spawn(process.execPath, [scriptPath, "--pipe-parser", testCase.kind], {
|
|
66
|
+
cwd: root,
|
|
67
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
68
|
+
});
|
|
69
|
+
const directOutputPromise = readStream(producer.stdout);
|
|
70
|
+
const producerStderrPromise = readStream(producer.stderr);
|
|
71
|
+
const parserOutputPromise = readStream(parser.stdout);
|
|
72
|
+
const parserStderrPromise = readStream(parser.stderr);
|
|
73
|
+
let pipeError = null;
|
|
74
|
+
parser.stdin.once("error", (error) => { pipeError = error; });
|
|
75
|
+
producer.stdout.pipe(parser.stdin);
|
|
76
|
+
|
|
77
|
+
const [producerClose, parserClose, directOutput, producerStderr, parserOutput, parserStderr] = await Promise.all([
|
|
78
|
+
waitForClose(producer, `${testCase.kind} producer`),
|
|
79
|
+
waitForClose(parser, `${testCase.kind} parser`),
|
|
80
|
+
directOutputPromise,
|
|
81
|
+
producerStderrPromise,
|
|
82
|
+
parserOutputPromise,
|
|
83
|
+
parserStderrPromise,
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
let directReport;
|
|
87
|
+
let pipeReport;
|
|
88
|
+
try {
|
|
89
|
+
directReport = JSON.parse(directOutput);
|
|
90
|
+
pipeReport = JSON.parse(parserOutput);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return {
|
|
93
|
+
actual: {
|
|
94
|
+
parserStatus: parserClose.status,
|
|
95
|
+
parserStderr: parserStderr.trim(),
|
|
96
|
+
pipeError: pipeError?.message ?? "",
|
|
97
|
+
producerStatus: producerClose.status,
|
|
98
|
+
producerStderr: producerStderr.trim(),
|
|
99
|
+
},
|
|
100
|
+
expected: "complete parseable JSON through a real Node stream pipe",
|
|
101
|
+
name: `${testCase.kind}_pipe_run_${run}`,
|
|
102
|
+
ok: false,
|
|
103
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const directBytes = Buffer.byteLength(directOutput);
|
|
108
|
+
const directDigest = createHash("sha256").update(directOutput).digest("hex");
|
|
109
|
+
const equivalent = pipeReport.bytes === directBytes && pipeReport.digest === directDigest;
|
|
110
|
+
const complete = reportIsComplete(testCase.kind, directReport) && pipeReport.complete === true;
|
|
111
|
+
return {
|
|
112
|
+
actual: {
|
|
113
|
+
complete,
|
|
114
|
+
directBytes,
|
|
115
|
+
equivalent,
|
|
116
|
+
parserSignal: parserClose.signal,
|
|
117
|
+
parserStatus: parserClose.status,
|
|
118
|
+
parserStderr: parserStderr.trim(),
|
|
119
|
+
pipeBytes: pipeReport.bytes,
|
|
120
|
+
pipeError: pipeError?.message ?? "",
|
|
121
|
+
producerSignal: producerClose.signal,
|
|
122
|
+
producerStatus: producerClose.status,
|
|
123
|
+
producerStderr: producerStderr.trim(),
|
|
124
|
+
},
|
|
125
|
+
expected: "complete parseable JSON through a real Node stream pipe",
|
|
126
|
+
name: `${testCase.kind}_pipe_run_${run}`,
|
|
127
|
+
ok: producerClose.status === 0
|
|
128
|
+
&& producerClose.signal === null
|
|
129
|
+
&& parserClose.status === 0
|
|
130
|
+
&& parserClose.signal === null
|
|
131
|
+
&& producerStderr.length === 0
|
|
132
|
+
&& parserStderr.length === 0
|
|
133
|
+
&& pipeError === null
|
|
134
|
+
&& directBytes > 512
|
|
135
|
+
&& complete
|
|
136
|
+
&& equivalent,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function main() {
|
|
141
|
+
const results = [];
|
|
142
|
+
for (const testCase of cases) {
|
|
143
|
+
for (const run of [1, 2]) results.push(await runPipeCase(testCase, run));
|
|
144
|
+
}
|
|
145
|
+
const report = { ok: results.every((result) => result.ok), results };
|
|
146
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
147
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (process.argv[2] === "--pipe-parser") await parsePipe(process.argv[3]);
|
|
151
|
+
else await main();
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import test from "node:test";
|
|
5
|
+
import Ajv2020 from "ajv/dist/2020.js";
|
|
6
|
+
import { addDateTimeFormat, isRfc3339DateTime } from "./json-schema-formats.mjs";
|
|
7
|
+
|
|
8
|
+
test("rejects RFC3339 values whose calendar date would normalize", () => {
|
|
9
|
+
for (const value of [
|
|
10
|
+
"2023-02-29T12:00:00Z",
|
|
11
|
+
"2023-02-30T12:00:00Z",
|
|
12
|
+
"2024-04-31T12:00:00+05:30",
|
|
13
|
+
]) {
|
|
14
|
+
assert.equal(isRfc3339DateTime(value), false, value);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("preserves valid RFC3339 offsets and fractional seconds", () => {
|
|
19
|
+
for (const value of [
|
|
20
|
+
"2024-02-29T23:59:59Z",
|
|
21
|
+
"2024-02-29T23:59:59.123456789+05:30",
|
|
22
|
+
"2024-02-29T00:00:00-04:00",
|
|
23
|
+
]) {
|
|
24
|
+
assert.equal(isRfc3339DateTime(value), true, value);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("uses the strict validator for the AJV date-time format", () => {
|
|
29
|
+
const ajv = new Ajv2020({ allErrors: true, strict: true });
|
|
30
|
+
addDateTimeFormat(ajv);
|
|
31
|
+
const validate = ajv.compile({
|
|
32
|
+
additionalProperties: false,
|
|
33
|
+
properties: { at: { format: "date-time", type: "string" } },
|
|
34
|
+
required: ["at"],
|
|
35
|
+
type: "object",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
assert.equal(validate({ at: "2024-02-29T23:59:59.123Z" }), true);
|
|
39
|
+
assert.equal(validate({ at: "2023-02-29T23:59:59.123Z" }), false);
|
|
40
|
+
});
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import crypto from "node:crypto";
|
|
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 builder = path.join(repositoryRoot, "scripts", "build-reference-artifacts.mjs");
|
|
12
|
+
const validator = path.join(repositoryRoot, "scripts", "validate-reference-artifacts.mjs");
|
|
13
|
+
const schema = JSON.parse(fs.readFileSync(path.join(repositoryRoot, "consumer-reference/schema/portable-tokens.schema.json"), "utf8"));
|
|
14
|
+
|
|
15
|
+
function parseJson(child) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(child.stdout);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return { failures: [{ code: "invalid_json_output", message: error instanceof Error ? error.message : String(error) }], ok: false };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function codes(output) {
|
|
24
|
+
return Array.isArray(output.failures)
|
|
25
|
+
? output.failures.flatMap((failure) => typeof failure?.code === "string" ? [failure.code] : [])
|
|
26
|
+
: [];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const tempRoot = fs.mkdtempSync(path.join(repositoryRoot, ".tmp-stylegallery-reference-adapter-"));
|
|
30
|
+
const results = [];
|
|
31
|
+
|
|
32
|
+
function run(command, args) {
|
|
33
|
+
const child = spawnSync(process.execPath, [command, ...args, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
34
|
+
return { child, output: parseJson(child) };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function recordAccepted(name, execution, predicate = () => true) {
|
|
38
|
+
const actualCodes = codes(execution.output);
|
|
39
|
+
const accepted = execution.child.status === 0 && execution.output.ok === true && execution.output.scaffold !== true;
|
|
40
|
+
results.push({
|
|
41
|
+
actual: { codes: actualCodes, ok: execution.output.ok, scaffold: execution.output.scaffold === true, status: execution.child.status },
|
|
42
|
+
expected: "ok:true and exit:0",
|
|
43
|
+
name,
|
|
44
|
+
ok: accepted && predicate(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function recordRejected(name, execution, expectedCode) {
|
|
49
|
+
const actualCodes = codes(execution.output);
|
|
50
|
+
results.push({
|
|
51
|
+
actual: { codes: actualCodes, ok: execution.output.ok, scaffold: execution.output.scaffold === true, status: execution.child.status },
|
|
52
|
+
expected: expectedCode,
|
|
53
|
+
name,
|
|
54
|
+
ok: execution.child.status !== 0 && execution.output.ok === false && actualCodes.includes(expectedCode),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const groupPattern = new RegExp(Object.keys(schema.$defs.group.patternProperties)[0]);
|
|
60
|
+
const rootPattern = new RegExp(Object.keys(schema.patternProperties)[0]);
|
|
61
|
+
const unsafeSegments = ["__proto__", "prototype", "constructor"];
|
|
62
|
+
results.push({
|
|
63
|
+
actual: {
|
|
64
|
+
groupDescription: schema.$defs.group.properties.$description.type,
|
|
65
|
+
tokenDescription: schema.$defs.token.properties.$description.type,
|
|
66
|
+
unsafeGroupMatches: unsafeSegments.filter((segment) => groupPattern.test(segment)),
|
|
67
|
+
unsafeRootMatches: unsafeSegments.filter((segment) => rootPattern.test(segment)),
|
|
68
|
+
},
|
|
69
|
+
expected: "string descriptions and no unsafe path segments",
|
|
70
|
+
name: "schema_runtime_boundary_parity",
|
|
71
|
+
ok: schema.$defs.group.properties.$description.type === "string"
|
|
72
|
+
&& schema.$defs.token.properties.$description.type === "string"
|
|
73
|
+
&& unsafeSegments.every((segment) => !groupPattern.test(segment) && !rootPattern.test(segment)),
|
|
74
|
+
});
|
|
75
|
+
const output = path.join(tempRoot, "tokens.css");
|
|
76
|
+
const manifest = path.join(tempRoot, "manifest.json");
|
|
77
|
+
const validBuild = run(builder, ["--source", "consumer-reference/fixtures/token-portability/valid-reference.json", "--output", output, "--manifest", manifest, "--adapter", "style-dictionary", "--fail-on-warning"]);
|
|
78
|
+
recordAccepted("valid_reference_build", validBuild, () => {
|
|
79
|
+
const css = fs.readFileSync(output, "utf8");
|
|
80
|
+
return css.includes("var(--color-accent)") && css.includes("var(--space-small)") && !css.includes("[object Object]");
|
|
81
|
+
});
|
|
82
|
+
recordAccepted("valid_reference_manifest", run(validator, ["--manifest", manifest]));
|
|
83
|
+
|
|
84
|
+
for (const fixture of ["valid-whole-alias.json", "valid-border.json"]) {
|
|
85
|
+
recordAccepted(fixture.replace(".json", ""), run(builder, ["--source", `consumer-reference/fixtures/token-portability/${fixture}`, "--output", output, "--manifest", manifest, "--fail-on-warning"]));
|
|
86
|
+
}
|
|
87
|
+
const invalidFixtures = [
|
|
88
|
+
["invalid-extends.json", "token_extends_forbidden"],
|
|
89
|
+
["invalid-json-pointer.json", "token_json_pointer_forbidden"],
|
|
90
|
+
["invalid-resolver.json", "token_resolver_forbidden"],
|
|
91
|
+
["invalid-unknown-reserved.json", "token_unknown_reserved"],
|
|
92
|
+
["invalid-untested-type.json", "token_type_unsupported"],
|
|
93
|
+
["invalid-dangling-alias.json", "alias_dangling"],
|
|
94
|
+
["invalid-cycle.json", "alias_cycle"],
|
|
95
|
+
["invalid-type-mismatch.json", "alias_type_mismatch"],
|
|
96
|
+
];
|
|
97
|
+
for (const [fixture, expected] of invalidFixtures) {
|
|
98
|
+
recordRejected(fixture.replace(".json", ""), run(builder, ["--source", `consumer-reference/fixtures/token-portability/${fixture}`, "--output", output, "--manifest", manifest, "--fail-on-warning"]), expected);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const invalidUnit = path.join(tempRoot, "invalid-unit.json");
|
|
102
|
+
fs.writeFileSync(invalidUnit, '{"space":{"$type":"dimension","bad":{"$value":{"value":1,"unit":"vh"}}}}\n');
|
|
103
|
+
recordRejected("invalid_untested_unit", run(builder, ["--source", invalidUnit, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_unit_unsupported");
|
|
104
|
+
const partialAlias = path.join(tempRoot, "invalid-partial-alias.json");
|
|
105
|
+
fs.writeFileSync(partialAlias, '{"space":{"$type":"dimension","bad":{"$value":"calc({space.base} * 2)"}}}\n');
|
|
106
|
+
recordRejected("invalid_partial_alias", run(builder, ["--source", partialAlias, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "alias_whole_required");
|
|
107
|
+
const invalidGroupDescription = path.join(tempRoot, "invalid-group-description.json");
|
|
108
|
+
fs.writeFileSync(invalidGroupDescription, '{"space":{"$description":{"unsafe":true},"$type":"dimension","small":{"$value":{"value":1,"unit":"px"}}}}\n');
|
|
109
|
+
recordRejected("invalid_group_description", run(builder, ["--source", invalidGroupDescription, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_description_invalid");
|
|
110
|
+
const invalidTokenDescription = path.join(tempRoot, "invalid-token-description.json");
|
|
111
|
+
fs.writeFileSync(invalidTokenDescription, '{"space":{"$type":"dimension","small":{"$description":42,"$value":{"value":1,"unit":"px"}}}}\n');
|
|
112
|
+
recordRejected("invalid_token_description", run(builder, ["--source", invalidTokenDescription, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_description_invalid");
|
|
113
|
+
const duplicateSourceProperty = path.join(tempRoot, "invalid-duplicate-source-property.json");
|
|
114
|
+
fs.writeFileSync(duplicateSourceProperty, '{"space":{"$type":"dimension","$type":"dimension","small":{"$value":{"value":1,"unit":"px"}}}}\n');
|
|
115
|
+
recordRejected("duplicate_source_property", run(builder, ["--source", duplicateSourceProperty, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_json_invalid");
|
|
116
|
+
for (const [name, sourceText] of [
|
|
117
|
+
["constructor", '{"constructor":{"$type":"dimension","small":{"$value":{"value":1,"unit":"px"}}}}\n'],
|
|
118
|
+
["prototype", '{"prototype":{"$type":"dimension","small":{"$value":{"value":1,"unit":"px"}}}}\n'],
|
|
119
|
+
["__proto__", '{"__proto__":{"$type":"dimension","small":{"$value":{"value":1,"unit":"px"}}}}\n'],
|
|
120
|
+
]) {
|
|
121
|
+
const unsafePath = path.join(tempRoot, `invalid-path-${name}.json`);
|
|
122
|
+
fs.writeFileSync(unsafePath, sourceText);
|
|
123
|
+
recordRejected(`invalid_path_${name}`, run(builder, ["--source", unsafePath, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_path_segment_unsafe");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const baselineSource = fs.readFileSync(path.join(repositoryRoot, "consumer-reference/fixtures/token-portability/valid-reference.json"), "utf8");
|
|
127
|
+
fs.writeFileSync(path.join(tempRoot, "source.json"), baselineSource);
|
|
128
|
+
const baselineBuild = run(builder, ["--source", path.join(tempRoot, "source.json"), "--output", output, "--manifest", manifest, "--fail-on-warning"]);
|
|
129
|
+
recordAccepted("artifact_baseline", baselineBuild);
|
|
130
|
+
const baselineCss = fs.readFileSync(output, "utf8");
|
|
131
|
+
const baselineManifest = fs.readFileSync(manifest, "utf8");
|
|
132
|
+
fs.writeFileSync(manifest, baselineManifest.replace('"schemaVersion": "1.0",', '"schemaVersion": "1.0",\n "schemaVersion": "1.0",'));
|
|
133
|
+
recordRejected("duplicate_manifest_property", run(validator, ["--manifest", manifest]), "artifact_manifest_invalid");
|
|
134
|
+
const duplicateValidatorSource = baselineSource.replace('"$type": "color",', '"$type": "color",\n "$type": "color",');
|
|
135
|
+
fs.writeFileSync(path.join(tempRoot, "source.json"), duplicateValidatorSource);
|
|
136
|
+
const duplicateSourceManifest = JSON.parse(baselineManifest);
|
|
137
|
+
duplicateSourceManifest.inputHash = `sha256:${crypto.createHash("sha256").update(duplicateValidatorSource).digest("hex")}`;
|
|
138
|
+
fs.writeFileSync(manifest, `${JSON.stringify(duplicateSourceManifest, null, 2)}\n`);
|
|
139
|
+
recordRejected("duplicate_validator_source_property", run(validator, ["--manifest", manifest]), "artifact_source_invalid");
|
|
140
|
+
fs.writeFileSync(path.join(tempRoot, "source.json"), baselineSource);
|
|
141
|
+
fs.writeFileSync(manifest, baselineManifest);
|
|
142
|
+
const symlinkSource = path.join(tempRoot, "symlink-source.json");
|
|
143
|
+
fs.symlinkSync(path.join(tempRoot, "source.json"), symlinkSource);
|
|
144
|
+
recordRejected("symlink_source", run(builder, ["--source", symlinkSource, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_source_untrusted");
|
|
145
|
+
const realOutput = path.join(tempRoot, "real-tokens.css");
|
|
146
|
+
fs.renameSync(output, realOutput);
|
|
147
|
+
fs.symlinkSync(realOutput, output);
|
|
148
|
+
recordRejected("symlink_validator_output", run(validator, ["--manifest", manifest]), "artifact_output_untrusted");
|
|
149
|
+
recordRejected("symlink_builder_output", run(builder, ["--source", path.join(tempRoot, "source.json"), "--output", output, "--manifest", manifest, "--fail-on-warning"]), "artifact_output_untrusted");
|
|
150
|
+
fs.rmSync(output);
|
|
151
|
+
fs.renameSync(realOutput, output);
|
|
152
|
+
const realManifest = path.join(tempRoot, "real-manifest.json");
|
|
153
|
+
fs.renameSync(manifest, realManifest);
|
|
154
|
+
fs.symlinkSync(realManifest, manifest);
|
|
155
|
+
recordRejected("symlink_validator_manifest", run(validator, ["--manifest", manifest]), "artifact_manifest_untrusted");
|
|
156
|
+
recordRejected("symlink_builder_manifest", run(builder, ["--source", path.join(tempRoot, "source.json"), "--output", output, "--manifest", manifest, "--fail-on-warning"]), "artifact_manifest_untrusted");
|
|
157
|
+
fs.rmSync(manifest);
|
|
158
|
+
fs.renameSync(realManifest, manifest);
|
|
159
|
+
const outsideRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-reference-escape-"));
|
|
160
|
+
const escapedSource = path.join(outsideRoot, "source.json");
|
|
161
|
+
fs.writeFileSync(escapedSource, baselineSource);
|
|
162
|
+
recordRejected("escaped_source", run(builder, ["--source", escapedSource, "--output", output, "--manifest", manifest, "--fail-on-warning"]), "token_source_untrusted");
|
|
163
|
+
const escapedOutput = path.join(outsideRoot, "tokens.css");
|
|
164
|
+
recordRejected("escaped_output", run(builder, ["--source", path.join(tempRoot, "source.json"), "--output", escapedOutput, "--manifest", manifest, "--fail-on-warning"]), "artifact_output_untrusted");
|
|
165
|
+
const escapedManifest = path.join(outsideRoot, "manifest.json");
|
|
166
|
+
recordRejected("escaped_manifest", run(builder, ["--source", path.join(tempRoot, "source.json"), "--output", output, "--manifest", escapedManifest, "--fail-on-warning"]), "artifact_manifest_untrusted");
|
|
167
|
+
fs.rmSync(outsideRoot, { force: true, recursive: true });
|
|
168
|
+
const artifactCases = [
|
|
169
|
+
["no_output", "artifact_output_missing", () => fs.rmSync(output)],
|
|
170
|
+
["zero_count", "artifact_zero_count", (item) => { item.sourceCount = 0; item.outputCount = 0; item.declarations = []; }],
|
|
171
|
+
["warning", "artifact_warning", (item) => { item.warnings = ["synthetic warning"]; }],
|
|
172
|
+
["missing_declaration", "artifact_declaration_missing", (item) => { item.declarations = item.declarations.slice(1); }],
|
|
173
|
+
["duplicate_declaration", "artifact_declaration_duplicate", (item) => { item.declarations.push(item.declarations[0]); }],
|
|
174
|
+
["object_sentinel", "artifact_object_sentinel", () => fs.writeFileSync(output, baselineCss.replace("120ms", "[object Object]"))],
|
|
175
|
+
["unresolved_alias", "artifact_unresolved_value", () => fs.writeFileSync(output, baselineCss.replace("120ms", "{duration.quick}"))],
|
|
176
|
+
["count_mismatch", "artifact_count_mismatch", (item) => { item.outputCount += 1; }],
|
|
177
|
+
["scaffold_manifest", "artifact_scaffold_forbidden", (item) => { item.scaffold = true; }],
|
|
178
|
+
["forged_value", "artifact_source_output_mismatch", (item) => {
|
|
179
|
+
const changed = baselineCss.replace("120ms", "999999s !important");
|
|
180
|
+
fs.writeFileSync(output, changed);
|
|
181
|
+
item.outputHash = `sha256:${crypto.createHash("sha256").update(changed).digest("hex")}`;
|
|
182
|
+
item.declarations.find((declaration) => declaration.name === "--duration-quick").value = "999999s !important";
|
|
183
|
+
}],
|
|
184
|
+
];
|
|
185
|
+
for (const [name, expected, mutate] of artifactCases) {
|
|
186
|
+
fs.writeFileSync(output, baselineCss);
|
|
187
|
+
const item = JSON.parse(baselineManifest);
|
|
188
|
+
mutate(item);
|
|
189
|
+
fs.writeFileSync(manifest, `${JSON.stringify(item, null, 2)}\n`);
|
|
190
|
+
recordRejected(name, run(validator, ["--manifest", manifest]), expected);
|
|
191
|
+
}
|
|
192
|
+
} finally {
|
|
193
|
+
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const failures = results.filter((result) => !result.ok).map((result) => `missing_semantic:${result.name}:${result.expected}`);
|
|
197
|
+
const report = { failures, ok: failures.length === 0, results };
|
|
198
|
+
console.log(JSON.stringify(report, null, 2));
|
|
199
|
+
process.exitCode = report.ok ? 0 : 1;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 validator = path.join(repositoryRoot, "scripts", "validate-renderer-purity.mjs");
|
|
11
|
+
const tempRoot = fs.mkdtempSync(path.join(os.tmpdir(), "stylegallery-pr4-renderer-"));
|
|
12
|
+
const cases = [];
|
|
13
|
+
|
|
14
|
+
function run(renderer) {
|
|
15
|
+
const child = spawnSync(process.execPath, [validator, "--renderer", renderer, "--json"], { cwd: repositoryRoot, encoding: "utf8" });
|
|
16
|
+
return { child, output: JSON.parse(child.stdout) };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const valid = run("tests/helpers/render-consumer-reference.mjs");
|
|
21
|
+
cases.push({ actual: { codes: valid.output.failures.map((failure) => failure.code), status: valid.child.status }, expected: "pure import and exit:0", name: "canonical_renderer_import", ok: valid.child.status === 0 && valid.output.ok === true });
|
|
22
|
+
const mutation = path.join(tempRoot, "render-consumer-reference.mjs");
|
|
23
|
+
fs.writeFileSync(mutation, 'import fs from "node:fs";\nimport { patterns } from "../../scripts/pattern-data.mjs";\nfs.appendFileSync("CATALOG.md", "mutation");\nexport { patterns };\n');
|
|
24
|
+
const invalid = run(mutation);
|
|
25
|
+
const codes = invalid.output.failures.map((failure) => failure.code);
|
|
26
|
+
cases.push({ actual: { codes, status: invalid.child.status }, expected: "renderer_side_effect_capability", name: "renderer_side_effect", ok: invalid.child.status !== 0 && codes.includes("renderer_side_effect_capability") });
|
|
27
|
+
} finally {
|
|
28
|
+
fs.rmSync(tempRoot, { force: true, recursive: true });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const failures = cases.filter((testCase) => !testCase.ok).map((testCase) => `missing_semantic:${testCase.name}:${testCase.expected}`);
|
|
32
|
+
const result = { failures, ok: failures.length === 0, results: cases };
|
|
33
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
34
|
+
if (!result.ok) process.exitCode = 1;
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
import { agentNativeFixture } from "./agent-native/fixture.mjs";
|
|
7
|
+
|
|
8
|
+
const repositoryRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
const cli = path.join(repositoryRoot, "scripts", "sg.mjs");
|
|
10
|
+
const profileRef = "sg:profile/editorial-reference-profile";
|
|
11
|
+
const versionRef = agentNativeFixture.records.find(({ stable_ref }) => stable_ref === profileRef)?.version_id;
|
|
12
|
+
|
|
13
|
+
const successCases = [
|
|
14
|
+
{ command: "discover", baseArgs: ["discover"] },
|
|
15
|
+
{ command: "resolve", baseArgs: ["resolve", profileRef] },
|
|
16
|
+
{ command: "resolve", baseArgs: ["resolve", versionRef], name: "resolve_version_id" },
|
|
17
|
+
{ command: "claims", baseArgs: ["claims", profileRef] },
|
|
18
|
+
{ command: "context", baseArgs: ["context", profileRef] },
|
|
19
|
+
{ command: "ops", baseArgs: ["ops"] },
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const failureCases = [
|
|
23
|
+
{ args: ["--format", "json"], code: "argument_value_required", name: "missing_command" },
|
|
24
|
+
{ args: ["resolve", "--format", "json"], code: "argument_value_required", name: "resolve_missing_stable_ref" },
|
|
25
|
+
{ args: ["claims", "--format", "json"], code: "argument_value_required", name: "claims_missing_stable_ref" },
|
|
26
|
+
{ args: ["resolve", "not-a-stable-ref", "--format", "json"], code: "stable_ref_malformed", name: "malformed_stable_ref" },
|
|
27
|
+
{ args: ["resolve", "sg:profile/unknown-profile", "--format", "json"], code: "stable_ref_unknown", name: "unknown_stable_ref" },
|
|
28
|
+
{ args: ["unknown-command", "--format", "json"], code: "command_unknown", name: "unknown_command" },
|
|
29
|
+
{ args: ["discover", "--unknown", "--format", "json"], code: "argument_unknown", name: "unknown_option" },
|
|
30
|
+
{ args: ["--format", "json", "discover", "--format"], code: "argument_value_required", name: "format_missing_value" },
|
|
31
|
+
{ args: ["--format", "json", "discover", "--format", "yaml"], code: "format_unsupported", name: "unsupported_format" },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
function run(args) {
|
|
35
|
+
return spawnSync(process.execPath, [cli, ...args], {
|
|
36
|
+
cwd: repositoryRoot,
|
|
37
|
+
encoding: "utf8",
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parseJson(child) {
|
|
42
|
+
if (typeof child.stdout !== "string" || child.stdout.length === 0) return null;
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(child.stdout);
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function summarize(child, report) {
|
|
51
|
+
return {
|
|
52
|
+
report,
|
|
53
|
+
signal: child.signal,
|
|
54
|
+
status: child.status,
|
|
55
|
+
stderr: child.stderr,
|
|
56
|
+
stdout: child.stdout,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function hasSuccessContract(child, report, command) {
|
|
61
|
+
return child.status === 0
|
|
62
|
+
&& child.signal === null
|
|
63
|
+
&& child.stderr.length === 0
|
|
64
|
+
&& report !== null
|
|
65
|
+
&& report.ok === true
|
|
66
|
+
&& report.operation === command
|
|
67
|
+
&& report.result !== null
|
|
68
|
+
&& typeof report.result === "object";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function formatVariants(baseArgs) {
|
|
72
|
+
const command = baseArgs[0];
|
|
73
|
+
const operands = baseArgs.slice(1);
|
|
74
|
+
return [
|
|
75
|
+
[...baseArgs, "--format", "json"],
|
|
76
|
+
["--format", "json", ...baseArgs],
|
|
77
|
+
[command, "--format", "json", ...operands],
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function runSuccessCase(testCase) {
|
|
82
|
+
const variants = formatVariants(testCase.baseArgs);
|
|
83
|
+
const runs = variants.map((args) => {
|
|
84
|
+
const child = run(args);
|
|
85
|
+
return { args, child, report: parseJson(child) };
|
|
86
|
+
});
|
|
87
|
+
const reference = runs[0];
|
|
88
|
+
const equivalent = runs.every(({ child, report }) => (
|
|
89
|
+
hasSuccessContract(child, report, testCase.command)
|
|
90
|
+
&& child.stdout === reference.child.stdout
|
|
91
|
+
));
|
|
92
|
+
const repeated = run(testCase.baseArgs.concat(["--format", "json"]));
|
|
93
|
+
const repeatedReport = parseJson(repeated);
|
|
94
|
+
const deterministic = hasSuccessContract(repeated, repeatedReport, testCase.command)
|
|
95
|
+
&& repeated.stdout === reference.child.stdout;
|
|
96
|
+
return {
|
|
97
|
+
actual: runs.map(({ args, child, report }) => ({ args, ...summarize(child, report) })),
|
|
98
|
+
expected: "all --format json positions produce one stdout-only success JSON document with identical bytes",
|
|
99
|
+
name: `${testCase.name ?? testCase.command}_format_order_and_stdout_contract`,
|
|
100
|
+
ok: equivalent && deterministic,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function runFailureCase(testCase) {
|
|
105
|
+
const child = run(testCase.args);
|
|
106
|
+
const report = parseJson(child);
|
|
107
|
+
const codes = Array.isArray(report?.failures)
|
|
108
|
+
? report.failures.map((failure) => failure?.code)
|
|
109
|
+
: [];
|
|
110
|
+
return {
|
|
111
|
+
actual: { codes, ...summarize(child, report) },
|
|
112
|
+
expected: `nonzero stdout-only JSON failure containing stable code ${testCase.code}`,
|
|
113
|
+
name: testCase.name,
|
|
114
|
+
ok: child.status !== 0
|
|
115
|
+
&& child.signal === null
|
|
116
|
+
&& child.stderr.length === 0
|
|
117
|
+
&& report?.ok === false
|
|
118
|
+
&& codes.length > 0
|
|
119
|
+
&& codes.includes(testCase.code),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const results = [
|
|
124
|
+
...successCases.map(runSuccessCase),
|
|
125
|
+
...failureCases.map(runFailureCase),
|
|
126
|
+
];
|
|
127
|
+
const report = { ok: results.every((result) => result.ok), results };
|
|
128
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
129
|
+
process.exitCode = report.ok ? 0 : 1;
|