Skip to content

fix(knowledge): gate, check, and route platform records under docs/specs/components - #9279

Merged
cixzhang merged 5 commits into
mainfrom
fix/platform-record-gate
Nov 1, 2026
Merged

cixzhang merged 5 commits into
mainfrom
fix/platform-record-gate

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Maintainer impact

A platform record such as docs/specs/components/TextInput/TextInput.swift.spec.md is invisible to the spec tooling. A pull request that edits one, or makes one current, gets a green spec-owner gate ("No knowledge records changed.") with no owner approval; pnpm check:knowledge never reads it; and pnpm specs:for on a Swift view returns no component record. Owners reviewing a Swift spec change get no gate, and an agent looking up a Swift view gets no contract.

Intended invariant

architecture:knowledge-contracts (Owning code, DEC-15) places a platform record beside the core record as <PublicName>.<language>.spec.md with the id component:<language>/<PublicName> and platform_of: component:<PublicName>. A record change is owner-gated, and lookup is path-first. Nothing here changes product code or what a record says.

Change

  • Owner gate (.github/scripts/change-scope.cjs): a platform record is a spec record, so it goes through the spec-owner gate like the core record beside it. A current one needs an engineering owner's approval; a draft one does not.
  • check:knowledge: platform records go through the same record loop as every other record (schema rules, applicability blocks, duplicate ids, latest schema version), accepting the language-qualified id (component:<language>/<PublicName>). It is placed like the core record it implements, whether or not that record exists: its folder must be a component root a registered package owns, and its public name must be that root or a public component of it. Then it checks what only a platform record has: platform_of names the core component, the core record beside it declares that id, and its verified_by paths exist. A platform record's theme-target block is parsed but not checked against a core theming contract.
  • specs:for: a platform record governs its language's code for the same component root (the whole root when it is named after the root, otherwise its same-stem files). Through platform_of it brings in the core record. Every Swift record is draft today, so the default lookup is unchanged. With --include-draft, packages/native/apple/Sources/Astryx/TextInput/TextInput.swift lists component:swift/TextInput and component:TextInput; a current Swift record will show by default.
  • CI path: a change that touches only platform records now takes the spec-only CI path, like one that touches only core records.
  • Record: the architecture:knowledge-contracts enforcement-gap paragraph and DEC-15 verification row now say what is checked.

Evidence

  • Failure before the change: on main, classifyChanges([{filename: 'docs/specs/components/TextInput/TextInput.swift.spec.md'}]) returns touchesKnowledgeRecords: false. specs:for on TextInput.swift lists no component record.
  • Success after the change: a Swift record made current leaves the gate pending ("spec waiting (eng)"). A Swift view change that leaves its record alone still reads "No knowledge records changed.", and an edit to a draft Swift record needs no approval. Tests: spec-owner-reconcile.test.mjs. check:knowledge reports a misplaced record (an unknown root, or a name that is not a public component of its root), a wrong or duplicate id, a wrong platform_of, empty owners, a missing verified_by path, an invalid path- or review-applicability block, and a current record without approval or with an empty verified_by.
  • Product/runtime behavior verified unchanged: no package source changes. pnpm check:knowledge passes; specs:for --unreached returns 0; specs:for --unrouted output is unchanged.
  • CI impact: no workflow, action, or job changes. Runner class, job-minutes per update, runner-pool usage, and time to green are unchanged; the added tests run in the existing node test job (a few seconds).

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest --project node on knowledge-paths, change-scope, spec-owner-decision, spec-owner-reconcile, spec-owner-workflow, check-knowledge, and specs-for-file: 395 tests pass.
  • pnpm check:knowledge, specs:for --unreached, and --unrouted (unchanged).

Writing rubric results

  • R1 narration: none. The amended paragraph states what is checked, in the present tense.
  • R2 research: none.
  • R3 evidence names a change: the DEC-15 row names the tests that catch a wrong platform record and a skipped gate.
  • R4 rejected alternatives: none added.
  • R5 PR/issue refs: none.
  • R6 ruled open questions: none open.

Posted by Cindy's agent on her behalf.

…ecs/components

A platform record such as docs/specs/components/TextInput/TextInput.swift.spec.md
was not a knowledge record to change-scope, check:knowledge, or specs:for, so a
pull request that made one current passed the spec-owner gate with no approval.

- change-scope: a platform record is a spec record, gated like the core record
  beside it.
- check:knowledge: checks a platform record's kind, id, platform_of, owners,
  authority and approval fields, and verified_by paths.
- specs:for: a platform record governs its language's code for the same
  component root and brings in the core record it names in platform_of.
- knowledge-contracts: the enforcement-gap paragraph and the DEC-15
  verification row say what is now checked.
@vercel

vercel Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 1, 2026 9:30am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 1, 2026
@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec a04614d

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 1, 2026 07:45
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9b6d550

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

API changes: core +8 · ~20 · −0 (report stale: run pnpm api:report); richtext +0 · ~1 · −0 (report stale: run pnpm api:report)

29 API changes (advisory)
Package Where Signature Usage
+ core . · Types · interface FieldStatusProps message: string import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {message: …}
+ core . · Types · interface FieldStatusProps ref?: React.Ref<HTMLDivElement> import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {ref: …}
+ core . · Types · interface FieldStatusProps type: InputStatusType import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {type: …}
+ core . · Types · interface FieldStatusProps variant?: FieldStatusVariant = 'attached' import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {variant: …}
+ core . · Types · interface FieldStatusProps xstyle?: StyleXStyles import type {FieldStatusProps} from '@astryxdesign/core'; const x: FieldStatusProps = {xstyle: …}
+ core . · Types · interface FieldStatusProps inherits AriaAttributes, DOMAttributes, HTMLAttributes import type {FieldStatusProps} from '@astryxdesign/core'
+ core . · Types · interface SearchContext interface SearchContext<T extends SearchableItem = SearchableItem> import type {SearchContext} from '@astryxdesign/core'
+ core ./Typeahead · Also exported from an earlier entry point · SearchContext SearchContext (.) import {SearchContext} from '@astryxdesign/core/Typeahead'
~ core . · Components · component ComplexSelector prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors <ComplexSelector statusVariant="attached" />
~ core . · Components · component DateInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <DateInput statusVariant="attached" />
~ core . · Components · component DateRangeInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <DateRangeInput statusVariant="attached" />
~ core . · Components · component Field prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <Field statusVariant="attached" />
~ core . · Components · component FieldStatus component FieldStatus(props: FieldStatusProps) → component FieldStatus @deprecated <FieldStatus />
~ core . · Components · component FieldStatus prop variant?: FieldStatusVariant = 'attached' → prop variant: FieldStatusVariant = 'attached' <FieldStatus variant="attached" />
~ core . · Components · component FileInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <FileInput statusVariant="attached" />
~ core . · Components · component MultiSelector prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary and ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary and ghost selectors <MultiSelector statusVariant="attached" />
~ core . · Components · component NumberInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <NumberInput statusVariant="attached" />
~ core . · Components · component PowerSearch prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <PowerSearch statusVariant="attached" />
~ core . · Components · component Selector prop statusVariant?: FieldStatusVariant = 'attached' for input selectors; 'detached' for secondary/ghost selectors → prop statusVariant?: FieldStatusPlacement = 'attached' for input selectors; 'detached' for secondary/ghost selectors <Selector statusVariant="attached" />
~ core . · Components · component TextArea prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <TextArea statusVariant="attached" />
~ core . · Components · component TextInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <TextInput statusVariant="attached" />
~ core . · Components · component TimeInput prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <TimeInput statusVariant="attached" />
~ core . · Components · component Tokenizer prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <Tokenizer statusVariant="attached" />
~ core . · Components · component Typeahead prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusPlacement = 'attached' <Typeahead statusVariant="attached" />
~ core . · Types · interface FieldStatusProps interface FieldStatusProps extends BaseProps<HTMLDivElement> (props of FieldStatus) → interface FieldStatusProps extends BaseProps<HTMLDivElement> import type {FieldStatusProps} from '@astryxdesign/core'
~ core . · Types · interface FieldStatusVariantMap tooltip: true → tooltip: true @deprecated import type {FieldStatusVariantMap} from '@astryxdesign/core'; const x: FieldStatusVariantMap = {tooltip: …}
~ core . · Types · interface SearchSource search: (query: string) => Promise<T[]> | T[] → search: (query: string, context?: SearchContext<T>) => Promise<T[]> | T[] import type {SearchSource} from '@astryxdesign/core'; const x: SearchSource = {search: …}
~ core . · Types · interface UseInputStatusIconOptions statusVariant?: FieldStatusVariant → statusVariant?: FieldStatusPlacement import type {UseInputStatusIconOptions} from '@astryxdesign/core'; const x: UseInputStatusIconOptions = {statusVariant: …}
~ richtext . · Components · component RichTextEditor prop statusVariant?: FieldStatusVariant = 'attached' → prop statusVariant?: FieldStatusVariant | 'tooltip' = 'attached' <RichTextEditor statusVariant="tooltip" />

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.

CI impact: 0 job-min per update · pool 0% · time to green −1.2 min · standard runners · 6 CI action or script files changed (not measured)
Before After Change
Job-minutes per PR update 78.7 78.7 0
Runner pool, runner-minutes a day 36,690 36,690 0 (0%)
Average concurrent jobs 25.5 25.5 0
Time to green (median → this run) 14.6 min 13.4 min −1.2 min
Runs a day 466 466 0

Not measured (the jobs that use these keep their recent minutes above): .github/scripts/change-scope.cjs, .github/scripts/change-scope.test.mjs, .github/scripts/knowledge-paths.cjs, .github/scripts/knowledge-paths.test.mjs, .github/scripts/spec-owner-decision.test.mjs, .github/scripts/spec-owner-reconcile.test.mjs.

Assumptions: before is each job's average over the last 20 pull-request runs; after keeps that for unchanged jobs and uses this run's minutes for added or changed ones, weighted by how often each changed job ran in those runs; runs a day averages the seven whole days before today; time to green compares this run with the median of those runs that ran the same jobs.


Generated by PR Enrichment workflow | View full report

@astracat-bot

astracat-bot Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 1, 2026, 9:40 AM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the gate, check and lookup changes match the knowledge-contracts record, and the new tests fail on main and pass here, but two things need fixing first.

  • validatePlatformComponentRecords copies the owners, authority and approval checks from validateAgainstSchema and has already drifted: a current Swift record with verified_by: [] passes (the new check-knowledge test asserts it), so please run platform records through the shared validator with a language-qualified id allowance and delete the copy.
  • The description says specs:for on TextInput.swift now lists component:swift/TextInput and component:TextInput, but every Swift record is draft, so the default lookup is unchanged and that holds only with --include-draft; please reword it, and mention that a change touching only Swift records now takes the spec-only CI path.

[Automated review]

Comment thread scripts/check-knowledge.mjs Outdated
Comment on lines +1054 to +1088
const owners = frontmatter.get('owners');
if (!Array.isArray(owners) || owners.length === 0) {
problems.push(`${filePath}: owners must be a non-empty inline list.`);
}

const authority = frontmatter.get('authority');
if (!schema.authorities.includes(authority)) {
problems.push(
`${filePath}: authority must be ${schema.authorities.join(', ')}.`,
);
}
if (authority === 'current') {
if (!engineeringApprovalOwners.includes(frontmatter.get('approved_by'))) {
problems.push(
`${filePath}: current records require approved_by to name an authorized owner.`,
);
}
const approvedAt = frontmatter.get('approved_at');
if (
typeof approvedAt !== 'string' ||
!/^\d{4}-\d{2}-\d{2}$/.test(approvedAt)
) {
problems.push(
`${filePath}: current records require approved_at as YYYY-MM-DD.`,
);
}
}
if (authority === 'archived') {
const reason = frontmatter.get('archive_reason');
if (!schema.archiveReasons.includes(reason)) {
problems.push(
`${filePath}: archived records require archive_reason (${schema.archiveReasons.join(', ')}).`,
);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These owners, authority, approved_by/approved_at and archive_reason checks copy validateAgainstSchema (lines 1977-2029) and leave out its currentNonEmptyFields and superseded_by rules, so a current Swift record with verified_by: [] passes here; the shared validator reports current records require non-empty verified_by for the same record. Run with the component schema, validateAgainstSchema rejects the six Swift records only on the id pattern, so it can take a language-qualified id (component:<language>/<PublicName>), keeping just the platform-specific checks here.

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 87ab1b1

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the gate, check and lookup changes match the knowledge-contracts record, and the misplaced-record cases from the last round (Buton/, Wire/, Banana) now fail pnpm check:knowledge. One gap remains: validatePlatformComponentRecords rebuilds the core placement rule as a single ternary and, for a flat package, skips the root check, so docs/specs/components/RichTextEditor/RichTextView.swift.spec.md passes while the same core record fails, although the amended record says platform records are checked as core records are. Please move the placement checks into one helper that both validateComponentModuleRelationships and validatePlatformComponentRecords call, and add a flat-package case to the platform test.

[Automated review]

Comment thread scripts/check-knowledge.mjs Outdated
Comment on lines +1041 to +1053
} else if (
location.layout === 'flat'
? !packageHasPublicComponent(root, location.packageName, publicName)
: publicName !== componentRoot &&
!componentRootDefinesPublicComponent(
location.componentSourcePath,
publicName,
)
) {
problems.push(
`${filePath}: platform record for ${publicName} must match component root ${JSON.stringify(componentRoot)} or an exact public component entry in that root's consumer docs.`,
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This folds the core rule's two independent checks (lines 1273-1291) into one ternary, so for a flat package only the export is checked and never that the name is the folder's root or a public component of it. At this head docs/specs/components/RichTextEditor/RichTextView.swift.spec.md passes pnpm check:knowledge, while the same core record fails with "flat component record component:RichTextView must match component root "RichTextEditor"". A shared placement helper called from both functions, plus a flat-package case in the platform test, would close it.

@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 9b6d550

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: both earlier points are fixed (the platform validator now uses validateAgainstSchema, and the description scopes the specs:for claim to --include-draft), and the new tests fail on main and pass here, but one gap remains. validatePlatformComponentRecords still runs its own record loop, so a platform record's path-applicability:v1 or review-applicability:v1 block is never validated even though specs:for now reads it: a ** pattern in TextInput.swift.spec.md passes check:knowledge and routes unrelated files to the Swift record, and an unsupported trigger passes but makes every pnpm specs:for run exit 1. Please run platform records through the main record loop in validateKnowledgeRoot (passing the language-qualified idPattern), keep only the platform_of, core-id and verified_by checks separate, and add a test with an invalid block.

[Automated review]

) {
const problems = [];
const tracked = repositoryFiles ? new Set(repositoryFiles) : null;
for (const absolutePath of discoverPlatformComponentRecords(root)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop runs beside validateKnowledgeRoot's record loop and leaves out its path-applicability, review-applicability and duplicate-id checks. loadKnowledgeIndex now feeds platform records to specs:for, so those blocks take effect without validation. A ** pattern here passes check:knowledge and routes packages/cli/package.json to component:swift/TextInput. An unsupported review trigger passes too, and then every pnpm specs:for run exits 1. Iterating discoverPlatformComponentRecords in the main loop with the idPattern override, and keeping only the platform_of, core-id and verified_by checks here, closes all three.

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026
@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 2e20944

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 1, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval recommended: Swift platform records now go through the spec-owner gate, pnpm check:knowledge and pnpm specs:for the way architecture:knowledge-contracts and spec:AST-093 describe, and the flat-package placement gap from the last round is closed by the shared componentNamePlacement helper with its own test. Nothing further is needed from the author for this review.

[Automated review]

@cixzhang
cixzhang merged commit f2e9b92 into main Nov 1, 2026
52 checks passed

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: the gate, check and lookup changes match the knowledge-contracts record, and the earlier applicability-block and duplicate-id gaps are fixed. One gap remains: a platform record filed in the wrong folder, or for a root no registered package has (for example docs/specs/components/Buton/Button.swift.spec.md), still passes pnpm check:knowledge and drops out of specs:for for its Swift view, while the amended record says platform records are checked like every other record. Please check a platform record's folder and public name the way core component records are checked (validateComponentModuleRelationships), even when no core record exists, and add a test for it, or narrow that sentence to the checks that run.

[Automated review]

);
}
const corePath = `${COMPONENT_SPEC_ROOT}/${componentRoot}/${publicName}.spec.md`;
if (fs.existsSync(path.join(root, corePath))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This compares against the core component only when a core record file exists, and platform records never reach validateComponentModuleRelationships (they are kept out of records at line 2316). So docs/specs/components/Buton/Button.swift.spec.md, Wire/Wire.swift.spec.md (no registered package has a Wire root) or Button/Banana.swift.spec.md all pass check:knowledge, while the same mistake in a core record fails, and the misplaced record drops out of specs:for for its Swift view. Resolving the core path with componentRecordLocation even when no core record exists, and requiring the public name to be the root or a public component of it (as lines 1232-1270 do for core records), would close it; a test with a misplaced platform record would pin it.

Comment on lines +1165 to +1168
`pnpm check:knowledge` checks a platform record
(`docs/specs/components/<ComponentRoot>/<PublicName>.<language>.spec.md`) like
every other record, accepting its language-qualified id, and also checks that
`platform_of` names its core component and that its `verified_by` paths exist.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"like every other record" reads as including the folder and component-root checks (the DEC-15 row counts "a record whose component root no registered package's source tree has" as a failure), which platform records do not get yet, and it leaves out that a platform record's theme-target block is not checked. Either add the placement check in validatePlatformComponentRecords or name the checks that run.

@cixzhang

cixzhang commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec e7e0a39

This branch was successfully deployed

1 active deployment
Preview — 9b6d5501 Deployed Nov 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant