An open source design system that's fully customizable and agent ready
TypeScript
spec(knowledge): every specification in the repository is a knowledge record (#8113)
Cindy Zhang174568834060
diff --git a/docs/architecture/knowledge-contracts.md b/docs/architecture/knowledge-contracts.mdindex 34b7845628..a2a2d24b32 100644--- a/docs/architecture/knowledge-contracts.md+++ b/docs/architecture/knowledge-contracts.md@@ -9,14 +9,7 @@ superseded_by: nullapproved_by: cixzhangapproved_at: 2026-08-30owners: [cixzhang]-applies_to:- [- AGENTS.md,- .github/PULL_REQUEST_TEMPLATE/,- docs/,- packages/core/src/,- packages/lab/src/,- ]+applies_to: [AGENTS.md, .github/PULL_REQUEST_TEMPLATE/, docs/, packages/]verified_by:[scripts/check-knowledge.test.mjs,@@ -51,8 +44,10 @@ deciding_specs: []"INV25","INV26","DEC-9",+ "INV27","DEC-10",- "DEC-12"+ "DEC-12",+ "DEC-13"]}}@@ -315,6 +310,22 @@ Every record is either:record outrank a narrower owner (INV9), and does not require behavior to livein the named files (INV18). Every pattern matches at least one tracked file.+### Record coverage++- **INV27 — Every specification in the repository is a knowledge record.** A+ specification, a file that states what any part of the system must do as+ opposed to consumer docs, guides, and READMEs that explain how to use it, is+ a record of a kind this record names, in any package that exists today or is+ added later. 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.+ Discovery treats every tracked Markdown file named `*.spec.md`, and every+ tracked Markdown file under a directory named `specs`, as a record candidate,+ and a candidate that is not a valid record fails `pnpm check:knowledge`.+ `README.md` index files, `plan.md` implementation plans, and the paths+ discovery already ignores are not candidates.+## Path applicabilityUse this optional block when a record governs paths that its placement, path@@ -656,9 +667,20 @@ this flow passes the historical review benchmark and is enforced on pull request## Owning code- `AGENTS.md` points reviewers to the narrowest relevant record.-- `docs/templates/knowledge/` contains authoring forms.-- Component records are direct `<PublicName>.spec.md` children of a Core or Lab- component root. The public name normally matches the root; a parent/member+- `docs/templates/knowledge/` contains the only authoring forms; a package keeps+ no template of its own (INV27).+- Component records are direct `<PublicName>.spec.md` children of a component+ root. Component roots are the component directories of Core+ (`packages/core/src/`) and Lab (`packages/lab/src/`), the source roots of the+ flat component packages `scripts/component-packages.cjs` registers (Charts,+ RichText, and Vega keep their records directly in `src/`), and the component+ directories of every platform implementation package, such as+ `packages/native/apple/Sources/Astryx/` for Swift. A platform implementation's record has the id+ `component:<language>/<PublicName>` (for example `component:swift/Button`),+ names its core component in `platform_of` (`component:<PublicName>`), and+ states only what that platform adds or must do differently; the core record+ keeps the shared contract (INV2). Until the core component has its own+ record, its public source and documentation stand in as that contract. The public name normally matches the root; a parent/memberexception requires an exact top-level or full inline consumer-doc entry inthat root. Public semantic module records are nested at least one directorybeneath the same root as `<PublicName>.spec.md`; the parent component's@@ -669,6 +691,13 @@ this flow passes the historical review benchmark and is enforced on pull request- Wiki `component-scores.json` is the current operational audit datastore. Thehistorical `<PublicName>.audit.json` reservation never received a schema or activerecords and is retired by INV12.+- A record governing one package's cross-component rules lives under that+ package's `specs/` directory as `<slug>.spec.md`, with kind `architecture`+ and an id of `architecture:` followed by the package name, each directory+ between `specs/` and the file, and the slug, joined by hyphens. For example,+ `packages/native/specs/swift/accessibility.spec.md` is+ `architecture:native-swift-accessibility`. Repository-wide architecture+ stays in `docs/architecture/`.- `packages/themes/<theme>/<theme>.spec.md` contains that package theme'scanonical record; `docs/themes/README.md` is guidance and an index only.- `docs/schemas/knowledge/` defines required structure.@@ -938,6 +967,23 @@ every active record to declare paths most already reach through placement orinheritance. Rejected: regular expressions, because a reviewer cannot readtheir reach at a glance and they over-match silently.+### DEC-13 — Every spec is a knowledge record, wherever it lives++**Reference:** `architecture:knowledge-contracts/DEC-13`+**Decider:** `cixzhang`, `2026-10-23`++Specification records in any package, including packages added later, use the+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 component, so the core record keeps+the shared contract and the platform record holds only the platform's part.+Until the core component has its own record, its public source and+documentation stand in as that contract.++Rejected: package-local spec formats, because their records skip structure+checks, the owner gate, and path routing.+## Verification| Invariant | Evidence | Failure signal |@@ -960,11 +1006,19 @@ their reach at a glance and they over-match silently.| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || INV22–INV24 | Contributor/reviewer evidence inventory; public-link and byte verification; retained remote refs; unchanged fixture/baseline/media paths | Disposable captures enter the source tree, cleanup loses a referenced image, a temporary branch is called durable, or storage changes overwrite an owner's proof or retention contract || INV25, INV26, DEC-12 | `scripts/specs-for-file.test.mjs`, `scripts/check-knowledge.test.mjs`, and `pnpm check:knowledge` | A current record is reached by no tracked non-record path, a lookup infers a link from a name, a pattern matches nothing or the whole repository, or a pattern match widens a claim or outranks a narrower owner |+| INV27, DEC-13 | `scripts/check-knowledge.test.mjs` and `pnpm check:knowledge` | A `*.spec.md` file or a Markdown file under a `specs` directory without valid record frontmatter, outside its kind's location, or following a package-local template passes |Evidence placement is enforced by contributors and reviewers. The local`docs/pr-assets/` ignore prevents accidental staging; it is not a blocking CIcheck and does not prevent force-added evidence elsewhere.+Current enforcement gap: discovery does not yet read record candidates outside+registered component packages, themes, and `docs/`; component records have no+`platform_of` field until the next schema version; and the component id+pattern does not yet accept a language-qualified id such as+`component:swift/Button`. Until all three land, records under+`packages/native/` are checked only by review.+Current enforcement gap: no checked-in gate yet proves the open-pull-requestsearch. Until one exists, the pull-request summary records the search terms,canonical owner/path, and overlapping open work inspected.diff --git a/docs/contributing/spec-writing.md b/docs/contributing/spec-writing.mdindex 6bdc69d03b..4c037c7ab8 100644--- a/docs/contributing/spec-writing.md+++ b/docs/contributing/spec-writing.md@@ -5,9 +5,14 @@ someone deciding whether an implementation conforms, long after the pullrequests that shaped it are closed. Every sentence in a record has to survivethat reader.-This guide applies to every knowledge record that states what the system does:-`docs/specs/<id>/spec.md`, family, design, theme, and architecture records, and-colocated `<Name>.spec.md` component and module contracts. An implementation+This guide applies to every knowledge record that states what the system does,+wherever it lives in the repository and in any package added later:+`docs/specs/<id>/spec.md`, family, design, theme, and architecture records,+package records under a package's `specs/` directory, and colocated+`<Name>.spec.md` component and module contracts in Core, Lab, the flat+component packages (Charts, RichText, Vega), and platform implementation+packages. Every spec must be a valid knowledge record; one that is not fails+the knowledge check (`architecture:knowledge-contracts` INV27). An implementationplan (`plan.md`) tracks work and is outside it. It projects`architecture:knowledge-contracts` (INV2 and INV10) and the templates under`docs/templates/knowledge/` into a pass an author runs and a reviewer checks. Itdiff --git a/docs/specs/AST-093-native-component-guidelines/spec.md b/docs/specs/AST-093-native-component-guidelines/spec.mdindex 6b42a7efae..0028eaba7a 100644--- a/docs/specs/AST-093-native-component-guidelines/spec.md+++ b/docs/specs/AST-093-native-component-guidelines/spec.md@@ -58,13 +58,17 @@ validating, and reviewing individual native components whilecore does (`packages/core/src/<Name>/<Name>.spec.md`). Each language has oneimplementation package; for Swift that is `packages/native/apple/`, and thespec is `packages/native/apple/Sources/Astryx/<Name>/<Name>.spec.md`, beside- the component's views. `<Name>` is the core component's name. The spec follows- `packages/native/specs/TEMPLATE.md`: summary, contract, native control,- platform guidelines, brand through the theme, states, accessibility, test and- validation, and open questions. One spec covers every implementation of the+ the component's views. `<Name>` is the core component's name. The spec is a+ knowledge record of kind `component` with id `component:<language>/<Name>`+ that names its core component in `platform_of`, built from+ `docs/templates/knowledge/component-spec.md`+ (`architecture:knowledge-contracts` INV27). Until the core component has its+ own record, `platform_of` still names `component:<Name>`, and the core+ component's public source and documentation stand in as its contract. One spec covers every implementation of thecomponent in that language, on every platform the language serves (Swiftserves `ios` and `macos`). Rules that apply across a language's components- live under `packages/native/specs/<language>/`. A merged native component spec+ are architecture records under `packages/native/specs/<language>/`, named+ `<slug>.spec.md`. A merged native component specdescribes that component's implementations in that language. It never changesthe core contract and never contradicts `spec:AST-082` or this record; whereit does, they win.@@ -136,15 +140,18 @@ validating, and reviewing individual native components while## Current-state impact-- `@astryxdesign/native` gains `packages/native/specs/`, holding the template- and one directory per language, starting with `swift/`. The directory is not- published.+- `@astryxdesign/native` gains `packages/native/specs/`, holding one directory+ per language, starting with `swift/`. The directory is not published.+- 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. Until then,+ the package READMEs still name the template, and a new component spec follows+ FR1 instead.- No architecture, family, contributing, or consumer-doc record changes.- No native component spec exists yet.- Component folders live inside a language's implementation package. ForSwift that is `packages/native/apple/`, whose `Astryx` product holds the- SwiftUI views; until they are on `main`, no component folder exists and no- component spec can be added.+ SwiftUI views.- The first Swift views in the `Astryx` product (Banner, Button, Card, Heading, Text,and TextInput) take hand-written parameters, including `action` for thecontract's `onClick`, until they move to the generated contracts. Until then@@ -160,14 +167,14 @@ validating, and reviewing individual native components while## Verification-| Contract | Verification | Representative states | Mutation or failure expectation |-| -------- | --------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| FR1 | Review of the spec's path beside the component and its sections against the template | a spec per language; a spec for a component with no core contract | A component spec outside its component's folder, missing a template section, or renaming a core prop passes review |-| 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 |-| FR4 | Theme test with two themes, plus source review for literals | default theme; a second theme with different color, type, and shape | A brand value stays the same across both themes, or a platform-only visual prop is added |-| FR5 | The package's tests on every supported platform and the captures attached to the change | light; dark; largest text; every state the core contract names | A change merges without tests, without captures, or with a capture-based claim backed only by source |-| FR6 | Changed paths, commit authors, the review app's exact-head review, the spec review's findings, and the approval | all native paths by group members; a spec-defined requirement unmet; behavior no spec defines; a path outside `packages/native/`; a commit from someone else | An approval without an exact-head review-app pass or a spec review, an approval with a spec-defined requirement unmet, an out-of-scope pull request approved without review, or an in-scope one blocked only for behavior no spec defines |+| Contract | Verification | Representative states | Mutation or failure expectation |+| -------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| FR1 | Review of the spec's path beside the component, plus `pnpm check:knowledge` on its record frontmatter, id, and `platform_of` | a spec per language; a spec for a component with no core contract | A component spec outside its component's folder, without valid record frontmatter, under another id, naming no core component, or renaming a core prop passes |+| FR2 | The spec's account of the platform control it builds on, or why none fits, 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 account of the platform guidelines it follows, 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 |+| FR4 | Theme test with two themes, plus source review for literals | default theme; a second theme with different color, type, and shape | A brand value stays the same across both themes, or a platform-only visual prop is added |+| FR5 | The package's tests on every supported platform and the captures attached to the change | light; dark; largest text; every state the core contract names | A change merges without tests, without captures, or with a capture-based claim backed only by source |+| FR6 | Changed paths, commit authors, the review app's exact-head review, the spec review's findings, and the approval | all native paths by group members; a spec-defined requirement unmet; behavior no spec defines; a path outside `packages/native/`; a commit from someone else | An approval without an exact-head review-app pass or a spec review, an approval with a spec-defined requirement unmet, an out-of-scope pull request approved without review, or an in-scope one blocked only for behavior no spec defines |## Decision log