Skip to content

spec(knowledge-contracts): every spec in the repository is a knowledge record - #8113

Merged
cixzhang merged 1 commit into
mainfrom
spec/knowledge-records-everywhere
Oct 24, 2026
Merged

cixzhang merged 1 commit into
mainfrom
spec/knowledge-records-everywhere

Conversation

@cixzhang

@cixzhang cixzhang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

Whether every spec in the repository, in any package including ones added later, must be a standard knowledge record.

Existing authority searched

  • architecture:knowledge-contracts defines record kinds, frontmatter, templates and placement, but only places component records under Core and Lab, themes under packages/themes/, and everything else under docs/.
  • docs/contributing/spec-writing.md applies to knowledge records, but doesn't say a spec outside those places must be one.
  • packages/native/specs/ currently holds Markdown specs with no frontmatter and a package-local template, which pnpm check:knowledge and pnpm specs:for don't see.

Decision

  • INV27 (new): a spec in any package is a record of a named kind, with that kind's frontmatter, its template from docs/templates/knowledge/, and its canonical location. No package defines its own format, template or location. Discovery treats every *.spec.md file and every Markdown file under a specs directory as a record candidate, and fails one that isn't a valid record (README.md, plan.md and already-ignored paths excepted).
  • Placement: component roots include platform implementation packages. A platform record has the id component:<language>/<PublicName> (e.g. component:swift/Button), names its core record in platform_of, and holds only the platform's part. A package's cross-component rules live in packages/<package>/specs/ as <slug>.spec.md architecture records (architecture:<package>-<slug>).
  • DEC-13 records this, rejecting package-local formats in one line.
  • Spec-writing guide: its scope now names every record wherever it lives, including package records and platform component records.
  • The enforcement gap (discovery outside Core, Lab, themes and docs/, plus the platform_of schema field) is stated until the implementing change lands.

Rejected alternatives

  • Package-local spec formats: their records skip structure checks, the owner gate and path routing (DEC-13).

Claim scope and non-goals

Record kinds, frontmatter fields for existing kinds, and current records outside packages/native/ are unchanged.

Evidence and implementation relationship

Record only. A follow-up updates check:knowledge discovery, adds platform_of in the next schema version, and converts the native specs (and amends AST-093 FR1 to cite this placement).

Writing rubric results

  • R1 narration: none.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: one, DEC-13, one line.
  • R5 pull request or issue references remaining: none in the record.
  • R6 ruled open questions still listing options: none.

Scope

  • One durable decision: one architecture invariant and its decision, plus the guide's scope line.
  • It records observable rules and preserves equivalent internal implementations.
  • Verification states the evidence and failure signal without prescribing CI topology.
  • Canonical owner (architecture:knowledge-contracts), affected claims, and overlapping open work (native spec PRs) are named.
  • Public text contains no internal context.

Validation

Prettier-formatted with the repository config; check:knowledge runs in CI.

Overlapping open work searched

Landing order

After #8033, so FR1 is amended against its merged text.

@vercel

vercel Bot commented Oct 24, 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 Oct 24, 2026 5:31pm UTC

Request Review

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 0ad2d14

@astracat-bot

astracat-bot Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 24, 2026, 5:51 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

@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 owner-approved INV27 direction is clear, but this head leaves two current records disagreeing about native specs. spec:AST-093 FR1 still says a native component spec is packages/native/specs/<language>/<Name>.md built from packages/native/specs/TEMPLATE.md, which INV27 now rules out, so please amend FR1 with its verification row and Current-state impact in this pull request, or hold the native placement until that amendment lands.

  • The new enforcement-gap paragraph says discovery reads only Core, Lab, themes and docs/, but scripts/check-knowledge.mjs already validates the registered flat component packages, including six draft records in packages/charts/src/ that the new component-root list leaves out.
  • The gap should also name the component idPattern change, since ^component:[A-Z][A-Za-z0-9]*$ rejects component:swift/Button.
  • The package-record example packages/native/specs/swift/accessibility.spec.md does not follow the specs/<slug>.spec.md rule it illustrates.
  • Please list the open pull requests you searched in the description, including #8033, which keeps the package template.

[Automated review]

today or is added later, is a record of a kind this record names. It carries
that kind's frontmatter, follows that kind's template in
`docs/templates/knowledge/`, and sits at that kind's canonical location
(Owning code). No package defines its own spec format, template, or location.

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 conflicts with current spec:AST-093 FR1, which still says a native component spec is packages/native/specs/<language>/<Name>.md and follows packages/native/specs/TEMPLATE.md; its FR1 verification row counts a spec outside that folder passing review as a failure. With both current, native authors can't satisfy both. Please amend AST-093 FR1, its verification row and its Current-state impact in this PR, including which swift-ios-<n> package holds a language's record, or hold the native placement until that amendment lands.

Comment on lines +670 to +673
- Component records are direct `<PublicName>.spec.md` children of a component
root. Component roots are the component directories of Core
(`packages/core/src/`), Lab (`packages/lab/src/`), and every platform
implementation package, such as `packages/native/swift-ios-<n>/core/` for

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.

Discovery already treats charts, richtext and vega as component packages (scripts/component-packages.cjs, flat layout with records directly under src/) and reads six draft records in packages/charts/src/ today. This list leaves them out, so under INV27 they would sit outside their kind's location. Consider listing the registered flat component packages here.

Comment on lines +1007 to +1010
Current enforcement gap: discovery does not yet read record candidates outside
Core, Lab, themes, and `docs/`, and component records have no `platform_of`
field until the next schema version. Until both land, records under
`packages/native/` are checked only by review.

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.

scripts/check-knowledge.mjs already reads component records outside Core, Lab, themes and docs/ (the flat packages above), so this sentence understates what discovery does. The schema work is also more than platform_of: the v3 component idPattern (^component:[A-Z][A-Za-z0-9]*$) rejects component:swift/Button.

Comment on lines +691 to +693
and id `architecture:<package>-<slug>`. For example, the Swift accessibility
rules are `architecture:native-swift-accessibility` at
`packages/native/specs/swift/accessibility.spec.md`. Repository-wide

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.

The rule puts <slug>.spec.md directly in the package's specs/ directory with id architecture:<package>-<slug>, but the example nests it as specs/swift/accessibility.spec.md. By the rule this is packages/native/specs/swift-accessibility.spec.md; either change the example or let the rule allow subdirectories and define the slug.

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Oct 24, 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 waits on an engineering owner's decision: INV27, DEC-13 and the new package and platform placement rules are new requirements, and the earlier /approve-spec named the previous commit, so this head has no spec-owner approval. Current spec:AST-093 FR1 still places native component specs at packages/native/specs/<language>/<Name>.md from packages/native/specs/TEMPLATE.md, so approval also needs an engineering owner to update FR1, its verification row and its Current-state impact in this pull request (or to hold out the native placement sentences); an engineering owner then records the decision by commenting /approve-spec with the full SHA of the head being approved (for this head, /approve-spec 57e419b5b02cf18ca4585d813411c207915e2a67), and the author may do so as an engineering owner. Three wording fixes are needed as well:

  • Platform ids are per language while every versioned platform package is a component root, so two swift-ios-<n> packages would both hold component:swift/Button; say which package holds a language's record.
  • Charts, RichText and Vega are flat packages whose component records sit directly in src/, not in component directories, and the spec-writing guide's list leaves them out.
  • INV27's first sentence ("a file that states what any part of the system does") also covers consumer docs and READMEs; scope it to specifications.

[Automated review]

Comment on lines +674 to +677
`scripts/component-packages.cjs`) and of every platform implementation
package, such as `packages/native/swift-ios-<n>/core/` for Swift. A platform implementation's record has the id
`component:<language>/<PublicName>` (for example `component:swift/Button`),
names its core record in `platform_of`, and states only what that platform

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.

Every platform implementation package is a component root, but the record's id is per language. With versioned packages (swift-ios-1, swift-ios-2, …), a Button in two packages gives two records the same id component:swift/Button, which check-knowledge rejects as a duplicate. Please say which package holds a language's record, or put the package in the id.

Comment on lines +671 to +673
root. Component roots are the component directories of every registered
component package's source root (Core `packages/core/src/`, Lab
`packages/lab/src/`, Charts `packages/charts/src/`, and the others in

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.

Charts, RichText and Vega are flat packages: their component records are direct children of src/ (for example packages/charts/src/Chart.spec.md), and a .spec.md inside a component directory of a flat package is classified as a module. Please say that a flat package's component records sit directly in its src/.

Comment on lines +668 to +669
- `docs/templates/knowledge/` contains the only authoring forms; a package keeps
no template of its own (INV27).

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.

Current spec:AST-093 FR1 still says a native component spec follows packages/native/specs/TEMPLATE.md at packages/native/specs/<language>/<Name>.md. Both records are current, so FR1, its verification row and its Current-state impact need amending in this pull request (or the native placement held out) before reviewers can rely on this rule.

Comment on lines +315 to +317
- **INV27 — Every specification in the repository is a knowledge record.** A
file that states what any part of the system does, in any package that exists
today or is added later, is a record of a kind this record names. It carries

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.

"A file that states what any part of the system does" also describes consumer docs, package READMEs and CLI guide pages, which this record keeps outside the record kinds, while the discovery sentence below excludes README.md. Please scope this sentence to specifications, for example files that state requirements an implementation must meet.

Comment thread docs/contributing/spec-writing.md Outdated
Comment on lines +12 to +13
`<Name>.spec.md` component and module contracts in Core, Lab, and platform
implementation packages. A spec that is not a valid knowledge record is not

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 list leaves out the registered flat component packages (Charts, RichText, Vega), whose colocated records the guide also covers.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 27f07cc

@cixzhang
cixzhang force-pushed the spec/knowledge-records-everywhere branch from 57e419b to 27f07cc Compare October 24, 2026 09:08
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 24, 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.

The exact-head spec approval settles the direction, and amending AST-093 in this pull request resolves the earlier conflict between the two records; four wording fixes remain before it can land.

  • platform_of: knowledge-contracts says a platform record names its core record, AST-093 says its core component, and Button, Card, Heading and TextInput have no core record yet, so please make both records say the same thing and cover that case.
  • Charts, RichText and Vega keep their component records directly in src/, but the Owning code text describes component directories, a layout pnpm check:knowledge rejects, and the spec-writing guide leaves those packages out.
  • AST-093's FR2 and FR3 verification rows still point at the package template's native-control and guideline sections, which the shared component template does not have.
  • INV27's first sentence ("a file that states what any part of the system does") also covers consumer docs and READMEs, so please scope it to specifications.

The next commit resets the spec approval, so an engineering owner will need to approve the final head again.

[Automated review]

`scripts/component-packages.cjs`) and of every platform implementation
package, such as `packages/native/swift-ios-<n>/core/` for Swift. A platform implementation's record has the id
`component:<language>/<PublicName>` (for example `component:swift/Button`),
names its core record in `platform_of`, and states only what that platform

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 says a platform record names its core record in platform_of, while AST-093 FR1 (docs/specs/AST-093-native-component-guidelines/spec.md:62) says its core component. Button, Card, Heading and TextInput, four of the six first Swift views AST-093 lists, have no core record today (their core contract is packages/native/src/components/<Name>.ts), so their Swift records can follow AST-093 but not this line or DEC-13. Please make both records say the same thing: what platform_of holds, and what a platform record covers when its core component has no record (or require a core record first).

Comment on lines +163 to +164
| FR2 | The spec's native-control section and the state captures | a component built on a platform control; a component with no platform control | A component draws its own control where a platform control fits, with no reason in its spec |
| FR3 | The spec's guideline section and the captures | hit target size; largest Dynamic Type; Reduce Motion; VoiceOver focus | A capture shows a hit target below the platform minimum or text that does not scale |

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.

FR1 now builds the spec from docs/templates/knowledge/component-spec.md and retires packages/native/specs/TEMPLATE.md, but these rows still verify "the spec's native-control section" and "the spec's guideline section", which only the package template has. Consider verifying what the spec states (the platform control it looked for and why it does not fit; the guideline pages it follows), or naming the component-template section that holds each.

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 9c7398a

@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 exact-head spec approval settles the direction and the earlier wording fixes are in, but the native package's own instructions still point at the template this head retires, and two sentences restate the rule inaccurately.

  • packages/native/specs/README.md (Adding a spec) and the two Swift READMEs still say to copy TEMPLATE.md for a new component spec, which amended AST-093 FR1 and INV27 rule out; please point them at the record form, or say in AST-093's Current-state impact that new component specs follow FR1 until the conversion.
  • docs/contributing/spec-writing.md says a spec that is not a valid record “is not a spec”, while INV27 says it fails the knowledge check; please state it as the requirement.
  • DEC-13 still says a platform record names its core record, while the Owning code rule and AST-093 FR1 cover core components with no record yet (Button, Card, Heading, TextInput); please align it.

The next commit resets the spec approval, so an engineering owner will need to record /approve-spec on the final head.

[Automated review]

Comment thread docs/contributing/spec-writing.md Outdated
Comment on lines +14 to +15
packages. A spec that is not a valid knowledge record is not
a spec (`architecture:knowledge-contracts` INV27). An implementation

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.

INV27 says a spec-shaped file that is not a valid record fails pnpm check:knowledge; this sentence instead says it “is not a spec”, which reads as putting such files outside INV27 and outside this guide's rubric. Consider: “Every spec is a valid knowledge record (architecture:knowledge-contracts INV27); one that is not fails the knowledge check.”

record kinds, frontmatter, templates, and placement this record defines, and
discovery fails a spec-shaped file that is not a valid record. A platform
implementation's component record is a `component` record with a
language-qualified id that names its core record, so the core record keeps the

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.

The Owning code rule and AST-093 FR1 now have a platform record name its core component and let that component's public source and documentation stand in until it has a record, but DEC-13 still says it names its core record and that the core record keeps the shared contract. Button, Card, Heading and TextInput have no core record yet; consider “names its core component” here, or citing the Owning code rule.

Comment on lines +143 to +145
- The Swift specs under `packages/native/specs/swift/` and the package template
`packages/native/specs/TEMPLATE.md` predate FR1's record form. They convert
to knowledge records in one change, which removes the template.

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.

packages/native/specs/README.md (Adding a spec, step 1) and the two Swift READMEs still tell authors to copy TEMPLATE.md for a new component spec, which FR1 now rules out. Please update those instructions in this pull request, or say here that new component specs follow FR1 rather than the package READMEs until the conversion.

… record

INV27 makes every specification, in any package, a knowledge record; DEC-13
records the owner decision. Platform packages place component records as
component:<language>/<Name> naming the core component in platform_of, with the
core component's public source standing in until its core record exists.
spec-writing covers every record anywhere. AST-093 FR1 builds native component
specs from the standard component template.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 8b8d6b3

@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.

Recommend approval: the exact-head spec approval covers INV27, DEC-13 and the amended AST-093 FR1, and the three fixes requested on the previous revision are in. pnpm check:knowledge passes on this revision, and the enforcement-gap paragraph covers the only specs discovery does not read yet, the eight files under packages/native/specs/. Optionally, the package specs/ placement bullet could say whether Core's own cross-component architecture counts as repository-wide, since four Core-only architecture records stay in docs/architecture/. Any new commit resets the spec approval, so an engineering owner would record /approve-spec again on the final head.

[Automated review]

@cixzhang
cixzhang merged commit 1745688 into main Oct 24, 2026
69 checks passed
@github-actions
github-actions Bot deleted the spec/knowledge-records-everywhere branch October 25, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — 8b8d6b3a Deployed Oct 24, 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