Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/contract-baseline.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Every contract must include:
- `sections` (array, at least one item): section catalog.
- `constraints` (object): currently requires `motion` with `allowedDurationsMs` and `allowedTimingFunctions`.
- `color` (object): required unified color policy with `policy` and `allowedValues`.
- `tokens` (object, optional): allowlisted UI token categories for typography, layout, and motion.

## Per-surface required fields

Expand Down Expand Up @@ -47,6 +48,14 @@ Optional per-surface icon policy (web surfaces):
- `icons.policy`: one of `"off"`, `"warn"`, `"strict"`.
- `icons.allowedSources`: array of allowed icon source libraries (for example `lucide-react`, `@heroicons/react/24/outline`).

Optional top-level UI token policies:

- `tokens.typography`: allowlisted font and type-scale tokens used in font-family, font-size, line-height, and letter-spacing declarations.
- `tokens.layout`: allowlisted spacing, width, sizing, and radius tokens used in layout declarations.
- `tokens.motion`: allowlisted duration and easing tokens used in transition and animation declarations.
- `tokens.<category>.allowedTokens`: canonical token refs used for enforcement.
- `tokens.<category>.tokenMetadata` (optional): generated metadata for canonical tokens, including normalized values, observed attributes, and collapsed aliases.

## Section required fields

Each item in `sections` must include:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions packages/interfacectl-cli/dist/commands/generate-contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getBundledContractSchema, validateContractStructure, } from "@surfaces/
import { seedColorPolicyFromObservedDescriptors } from "../utils/color-policy-seeding.js";
import { seedChromePolicyFromObservedDescriptors } from "../utils/chrome-policy-seeding.js";
import { seedIconPolicyFromObservedDescriptors } from "../utils/icon-policy-seeding.js";
import { seedObservedUiContract } from "../utils/observed-ui-seeding.js";
const DEFAULT_OUT_DIR = "contracts/generated";
export async function runGenerateContractCommand(options) {
const cwd = process.cwd();
Expand All @@ -23,12 +24,18 @@ export async function runGenerateContractCommand(options) {
appRoot,
surfaceId,
});
const seeded = await seedColorPolicyFromObservedDescriptors({
const uiSeeded = await seedObservedUiContract({
workspaceRoot: cwd,
appRoot,
surfaceId,
contract: extractedContract,
});
const seeded = await seedColorPolicyFromObservedDescriptors({
workspaceRoot: cwd,
appRoot,
surfaceId,
contract: uiSeeded.contract,
});
const iconSeeded = await seedIconPolicyFromObservedDescriptors({
workspaceRoot: cwd,
appRoot,
Expand All @@ -42,10 +49,12 @@ export async function runGenerateContractCommand(options) {
contract: iconSeeded.contract,
});
const contract = chromeSeeded.contract;
const filteredReportWarnings = report.warnings.filter((warning) => !uiSeeded.resolvedPlaceholderWarnings.includes(warning.code));
const reportWithSeedWarnings = {
...report,
warnings: [
...report.warnings,
...filteredReportWarnings,
...uiSeeded.warnings,
...seeded.warnings,
...iconSeeded.warnings,
...chromeSeeded.warnings,
Expand Down
52 changes: 52 additions & 0 deletions packages/interfacectl-cli/dist/commands/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ function mapViolationsToFindings(summary) {
"font-not-allowed": "font.disallowed",
"color-not-allowed": "color.disallowed",
"icon-source-not-allowed": "icon.source-disallowed",
"token-not-allowed": "token.disallowed",
"layout-width-exceeded": "layout.width-exceeded",
"layout-width-undetermined": "layout.width-undetermined",
"layout-container-missing": "layout.container-missing",
Expand All @@ -329,6 +330,14 @@ function mapViolationsToFindings(summary) {
"landing-pattern-section-order": "landing.pattern.section-order",
"landing-pattern-section-nested": "landing.pattern.section-nested",
"landing-pattern-background-mode": "landing.pattern.background-mode",
"landing-pattern-marketing-layout-missing": "landing.pattern.marketing-layout-missing",
"landing-pattern-hero-container-mode": "landing.pattern.hero-container-mode",
"landing-pattern-hero-visual-placement": "landing.pattern.hero-visual-placement",
"landing-pattern-section-divider-mode": "landing.pattern.section-divider-mode",
"landing-pattern-section-spacing-profile": "landing.pattern.section-spacing-profile",
"marketing-typography-profile-missing": "marketing.typography.profile-missing",
"marketing-typography-role-missing": "marketing.typography.role-missing",
"marketing-typography-role-token": "marketing.typography.role-token",
"motion-duration-not-allowed": "motion.duration",
"motion-timing-not-allowed": "motion.timing",
"descriptor-flows-missing": "descriptor.flows.missing",
Expand Down Expand Up @@ -391,6 +400,49 @@ function mapViolationsToFindings(summary) {
}
break;
}
case "token-not-allowed": {
finding.expected = Array.isArray(details.allowedTokens)
? details.allowedTokens
: undefined;
finding.found = {
category: details.tokenCategory,
token: details.token,
canonicalToken: details.canonicalToken,
normalizedValue: details.normalizedValue,
};
if (details.policy === "warn") {
finding.severity = "warning";
}
break;
}
case "landing-pattern-marketing-layout-missing":
case "landing-pattern-hero-container-mode":
case "landing-pattern-hero-visual-placement":
case "landing-pattern-section-divider-mode":
case "landing-pattern-section-spacing-profile":
case "marketing-typography-profile-missing":
case "marketing-typography-role-missing":
case "marketing-typography-role-token": {
finding.expected =
details.expectedProfileId ??
details.expectedHeroContainerMode ??
details.expectedHeroVisualPlacement ??
details.expectedSectionDividerMode ??
details.expectedSectionSpacingProfile ??
details.allowedTokens;
finding.found =
details.actualProfileId ??
details.actualHeroContainerMode ??
details.actualHeroVisualPlacement ??
details.actualSectionDividerMode ??
details.actualSectionSpacingProfile ??
details.token ??
details.role;
if (details.policy === "warn") {
finding.severity = "warning";
}
break;
}
case "descriptor-flows-missing": {
finding.expected = details.requiredFlowIds;
finding.found = null;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading