Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

ci: name every public API row in a pull request's scope (tag-along check) (#10792)

Cindy Zhang914c833e5aeb
diff --git a/.github/PULL_REQUEST_TEMPLATE/bug-fix.md b/.github/PULL_REQUEST_TEMPLATE/bug-fix.md
index 39cd41ed81..835041189a 100644
--- a/.github/PULL_REQUEST_TEMPLATE/bug-fix.md
+++ b/.github/PULL_REQUEST_TEMPLATE/bug-fix.md
@@ -25,6 +25,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] One defect is restored.
- [ ] Separable contradictory or unsettled tagalongs were removed or split.
- [ ] No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
diff --git a/.github/PULL_REQUEST_TEMPLATE/documentation.md b/.github/PULL_REQUEST_TEMPLATE/documentation.md
index a9d48f326a..4c35761982 100644
--- a/.github/PULL_REQUEST_TEMPLATE/documentation.md
+++ b/.github/PULL_REQUEST_TEMPLATE/documentation.md
@@ -18,6 +18,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] This PR changes documentation only, or names every necessary generated artifact.
- [ ] Runtime, API, visual, and policy changes were removed or split.
- [ ] Public text and artifacts contain no internal Meta context.
diff --git a/.github/PULL_REQUEST_TEMPLATE/maintenance.md b/.github/PULL_REQUEST_TEMPLATE/maintenance.md
index 661f6132f9..5c25900665 100644
--- a/.github/PULL_REQUEST_TEMPLATE/maintenance.md
+++ b/.github/PULL_REQUEST_TEMPLATE/maintenance.md
@@ -21,6 +21,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] 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.
diff --git a/.github/PULL_REQUEST_TEMPLATE/new-feature.md b/.github/PULL_REQUEST_TEMPLATE/new-feature.md
index cfe90d6f23..e1fa430c2e 100644
--- a/.github/PULL_REQUEST_TEMPLATE/new-feature.md
+++ b/.github/PULL_REQUEST_TEMPLATE/new-feature.md
@@ -26,6 +26,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] One capability is added.
- [ ] Unrelated fixes, cleanup, and policy changes were removed or split.
- [ ] Consumer docs, focused tests, and migration evidence ship with the feature.
diff --git a/.github/PULL_REQUEST_TEMPLATE/other.md b/.github/PULL_REQUEST_TEMPLATE/other.md
index 5979e3e2f9..57c6b691f9 100644
--- a/.github/PULL_REQUEST_TEMPLATE/other.md
+++ b/.github/PULL_REQUEST_TEMPLATE/other.md
@@ -22,6 +22,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] This PR has one primary intent.
- [ ] Independently removable deltas were removed or split.
- [ ] Public text and artifacts contain no internal Meta context.
diff --git a/.github/PULL_REQUEST_TEMPLATE/specification.md b/.github/PULL_REQUEST_TEMPLATE/specification.md
index ff573598cf..e124591422 100644
--- a/.github/PULL_REQUEST_TEMPLATE/specification.md
+++ b/.github/PULL_REQUEST_TEMPLATE/specification.md
@@ -37,6 +37,8 @@
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] This PR contains specification records only.
- [ ] It records observable behavior and preserves equivalent internal implementations.
- [ ] Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract.
diff --git a/.github/PULL_REQUEST_TEMPLATE/visual-update.md b/.github/PULL_REQUEST_TEMPLATE/visual-update.md
index 8a619c9b38..3a2546b45f 100644
--- a/.github/PULL_REQUEST_TEMPLATE/visual-update.md
+++ b/.github/PULL_REQUEST_TEMPLATE/visual-update.md
@@ -25,6 +25,8 @@ Choose one and link it:
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] Appearance is the primary intent.
- [ ] Behavior, API, interaction model, and unrelated layout changes were removed or split.
- [ ] The evidence shows the changed pixels actively running, not only source or computed styles.
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 511d251368..7dcf130af8 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -26,6 +26,8 @@ Keep one primary intent; remove or split independently reviewable tagalongs.
## Scope
+Components: <!-- the components and modules this PR changes, comma-separated -->
+
- [ ] This PR has one primary intent.
- [ ] Independently removable API, visual, layout, behavior, cleanup, and policy changes were removed or split.
- [ ] Public text and artifacts contain no internal Meta context.
diff --git a/.github/scripts/api-tagalong.mjs b/.github/scripts/api-tagalong.mjs
new file mode 100644
index 0000000000..0593add448
--- /dev/null
+++ b/.github/scripts/api-tagalong.mjs
@@ -0,0 +1,312 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Find public API rows that ride along outside a pull request's scope.
+ * @input `--changes` api-changes.json, `--title`, `--body-file`, `--root`
+ * (component-packages.cjs names each package's components), `--files`,
+ * `--decided` (JSON list of `Name` or `Name.member` a current record
+ * decides), `--summary`
+ * @output JSON: scope, rows by component, tag-along rows, decided rows, `big`;
+ * a Markdown table with `--summary`. Exit 0, or 2 for an unread input
+ * @position CI evidence for architecture:knowledge-contracts INV33. A behavior
+ * handler is an event callback such as `onClick`; a handler change
+ * with no API row is not visible here, and review finds it
+ */
+
+import fs from 'node:fs';
+import {createRequire} from 'node:module';
+import path from 'node:path';
+import {fileURLToPath} from 'node:url';
+
+const require = createRequire(import.meta.url);
+const {
+ COMPONENT_PACKAGES,
+ documentedComponentsOutsideComponentDirectories,
+ flatPackageComponentNames,
+ nestedPackageComponentNames,
+} = require('../../scripts/component-packages.cjs');
+
+const MAX_COMPONENTS = 3;
+const MAX_ROWS = 10;
+const MAX_FILES = 100;
+const PACKAGE_SCOPE = '@astryxdesign/';
+/** A factory or hook prefix that a component's own export adds to its name. */
+const OWN_EXPORT_PREFIX = /^(?:use|Use|create|with|is)(?=[A-Z])/;
+
+const stripComments = text =>
+ String(text ?? '').replace(/<!--[\s\S]*?-->/g, '');
+
+/** The text under the body's `## Scope` heading, up to the next heading. */
+function scopeSection(body) {
+ const lines = stripComments(body).split(/\r?\n/);
+ const start = lines.findIndex(l => /^##\s+Scope\s*$/.test(l));
+ if (start < 0) return '';
+ const rest = lines.slice(start + 1);
+ const end = rest.findIndex(l => /^#{1,2}\s/.test(l));
+ return (end < 0 ? rest : rest.slice(0, end)).join('\n');
+}
+
+/**
+ * The pull request's named scope: the entries of the title's
+ * conventional-commit scope, then the `Components:` line under `## Scope`.
+ * `text` is the code spans under `## Scope`: only those name a row, so the
+ * template's checklist prose never does.
+ * @param {{title: string, body: string}} input
+ */
+export function parseScope({title, body}) {
+ const titleScope = String(title ?? '').match(/^\w+\(([^)]*)\)!?:/);
+ const fromTitle = (titleScope ? titleScope[1].split(',') : [])
+ .map(s => s.trim())
+ .filter(Boolean);
+ const section = scopeSection(body);
+ const line = section.match(/^\s*(?:[-*]\s+)?Components:(.*)$/m);
+ const text = (section.match(/`[^`\n]+`/g) ?? []).join('\n');
+ const fromBody = (line ? line[1].split(',') : [])
+ .map(s => s.replace(/`/g, '').trim())
+ .filter(Boolean);
+ return {scope: [...new Set([...fromTitle, ...fromBody])], text};
+}
+
+/** Capitalized folder names under one source root, sorted. */
+function componentFolders(src) {
+ if (!fs.existsSync(src)) return [];
+ return fs
+ .readdirSync(src, {withFileTypes: true})
+ .filter(entry => entry.isDirectory() && /^[A-Z]/.test(entry.name))
+ .map(entry => entry.name)
+ .sort();
+}
+
+/**
+ * Each registered package's component names, by package name: every public
+ * component the registry names (a component in another component's folder,
+ * such as TableRow in Table, included), plus each capitalized folder.
+ * @returns {Record<string, string[]>}
+ */
+export function componentsByPackage(root, packages = COMPONENT_PACKAGES) {
+ const out = {};
+ for (const pkg of packages) {
+ if (!fs.existsSync(path.join(root, pkg.src))) continue;
+ const names =
+ pkg.layout === 'flat'
+ ? flatPackageComponentNames(root, pkg)
+ : [
+ ...nestedPackageComponentNames(root, pkg),
+ ...documentedComponentsOutsideComponentDirectories(root, pkg),
+ ...componentFolders(path.join(root, pkg.src)),
+ ];
+ out[`${PACKAGE_SCOPE}${pkg.name}`] = [...new Set(names)].sort();
+ }
+ return out;
+}
+
+/** The row's top-level name: `interface ItemProps` gives `ItemProps`. */
+function topName(item) {
+ const words = String(item ?? '')
+ .replace(/`/g, '')
+ .split(' ');
+ return words.length > 1 ? words[1] : words[0];
+}
+
+/** The component a theme-target row names: `target alert-dialog (AlertDialog)`. */
+function targetOwner(item) {
+ const match = String(item ?? '').match(/^target \S+ \(([^)]+)\)$/);
+ return match ? match[1] : null;
+}
+
+/** Whether `name` starts with the word `prefix` (`Tab` starts `TabList`, not `Tabular`). */
+const startsWithWord = (name, prefix, ignoreCase = false) =>
+ (ignoreCase
+ ? name.toLowerCase().startsWith(prefix.toLowerCase())
+ : name.startsWith(prefix)) && !/^[a-z]/.test(name.slice(prefix.length));
+
+/**
+ * The component with the longest name that starts the row's name, or null.
+ * `useCollapsible` belongs to Collapsible.
+ */
+function componentOf(name, components) {
+ const candidates = [name, name.replace(OWN_EXPORT_PREFIX, '')];
+ let best = null;
+ for (const candidate of candidates)
+ for (const c of components)
+ if (startsWithWord(candidate, c) && (!best || c.length > best.length))
+ best = c;
+ return best;
+}
+
+const escapeRegExp = s => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
+const mentions = (text, word) =>
+ !!word &&
+ new RegExp(`(?<![\\w$@/-])${escapeRegExp(word)}(?![\\w$.-])`).test(text);
+
+const shortName = pkg => pkg.replace(/^@[^/]+\//, '');
+
+/**
+ * @param {{changes: unknown, title: string, body: string,
+ * components: Record<string, string[]>, files?: number,
+ * decided?: string[]}} input
+ */
+export function analyze({
+ changes,
+ title,
+ body,
+ components,
+ files = 0,
+ decided = [],
+}) {
+ const decidedRows = new Set(decided);
+ const {scope, text} = parseScope({title, body});
+ const inScopeSet = new Set(scope.map(s => s.toLowerCase()));
+ const isInScope = name => inScopeSet.has(String(name).toLowerCase());
+ const packages = Array.isArray(changes) ? changes : (changes?.packages ?? []);
+ const rowsByComponent = {};
+ const tagalongs = {};
+ const decidedOutside = {};
+ let rowCount = 0;
+ for (const p of packages) {
+ const pkg = String(p?.pkg ?? '');
+ const own = components[pkg] ?? [];
+ for (const r of Array.isArray(p?.rows) ? p.rows : []) {
+ const name = topName(r.item);
+ const owner = targetOwner(r.item);
+ // A theme target belongs to the exact component it names, never a prefix.
+ const component = owner
+ ? own.includes(owner)
+ ? owner
+ : null
+ : componentOf(name, own);
+ const group = component ?? pkg;
+ const out = {
+ package: pkg,
+ change: r.change,
+ name,
+ member: r.member ?? null,
+ entry: r.entry,
+ section: r.section,
+ item: r.item,
+ line: r.line,
+ ...(r.before != null ? {before: r.before} : {}),
+ };
+ (rowsByComponent[group] ??= []).push(out);
+ rowCount++;
+ // A removed row takes API away; it never rides along.
+ if (r.change === 'removed') continue;
+ const inScope = component
+ ? isInScope(component)
+ : isInScope(pkg) || isInScope(shortName(pkg));
+ const named =
+ mentions(text, group) ||
+ (!component && mentions(text, shortName(pkg))) ||
+ mentions(text, name) ||
+ (out.member != null && mentions(text, `${name}.${out.member}`)) ||
+ // A row no component owns is named by a scope entry that starts it.
+ (!component &&
+ !owner &&
+ scope.some(s => startsWithWord(name, s, true)));
+ if (inScope || named) continue;
+ // A row a current record decides stays visible but needs no owner.
+ const isDecided =
+ decidedRows.has(name) ||
+ (out.member != null && decidedRows.has(`${name}.${out.member}`));
+ ((isDecided ? decidedOutside : tagalongs)[group] ??= []).push(out);
+ }
+ }
+ const big =
+ Object.keys(rowsByComponent).length > MAX_COMPONENTS ||
+ rowCount > MAX_ROWS ||
+ Number(files) > MAX_FILES;
+ return {
+ version: 1,
+ scope,
+ rows_by_component: rowsByComponent,
+ tagalongs,
+ decided: decidedOutside,
+ big,
+ };
+}
+
+const cell = s => String(s).replace(/\|/g, '\\|');
+
+/** The Markdown table: one line per component with rows. */
+export function renderSummary(result) {
+ const inScope = new Set(result.scope.map(s => s.toLowerCase()));
+ const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
+ const lines = ['| Component | Rows | In scope |', '| --- | --- | --- |'];
+ for (const [group, rows] of Object.entries(result.rows_by_component)) {
+ const extra = result.tagalongs[group]?.length ?? 0;
+ const decided = result.decided?.[group]?.length ?? 0;
+ const outside = [
+ extra && `${plural(extra, 'tag-along row')}`,
+ decided && `${plural(decided, 'row')} a current record decides`,
+ ].filter(Boolean);
+ const state =
+ inScope.has(group.toLowerCase()) ||
+ inScope.has(shortName(group).toLowerCase())
+ ? 'yes'
+ : outside.length
+ ? `${extra ? 'no' : 'outside the scope'}: ${outside.join('; ')}`
+ : rows.every(r => r.change === 'removed')
+ ? 'removed only'
+ : 'named under Scope';
+ lines.push(`| ${cell(group)} | ${rows.length} | ${state} |`);
+ }
+ return lines.join('\n') + '\n';
+}
+
+function parseArgs(argv) {
+ const args = {files: 0, title: '', root: process.cwd()};
+ const keys = {
+ '--changes': 'changes',
+ '--title': 'title',
+ '--body-file': 'bodyFile',
+ '--root': 'root',
+ '--files': 'files',
+ '--summary': 'summary',
+ '--decided': 'decided',
+ };
+ for (let i = 0; i < argv.length; i++) {
+ const key = keys[argv[i]];
+ if (!key || i + 1 >= argv.length)
+ throw new Error(`Unknown or incomplete option: ${argv[i]}`);
+ args[key] = argv[++i];
+ }
+ if (!args.changes)
+ throw new Error('--changes <api-changes.json> is required');
+ return args;
+}
+
+function main() {
+ let input;
+ try {
+ const args = parseArgs(process.argv.slice(2));
+ input = {
+ changes: JSON.parse(fs.readFileSync(args.changes, 'utf8')),
+ title: args.title,
+ body: args.bodyFile ? fs.readFileSync(args.bodyFile, 'utf8') : '',
+ components: componentsByPackage(args.root),
+ files: Number(args.files) || 0,
+ summary: args.summary,
+ decided: args.decided
+ ? JSON.parse(fs.readFileSync(args.decided, 'utf8'))
+ : [],
+ };
+ const {changes} = input;
+ if (!Array.isArray(changes) && !Array.isArray(changes?.packages))
+ throw new Error('the changes file has no packages list');
+ if (!Array.isArray(input.decided))
+ throw new Error('the decided file is not a list');
+ } catch (err) {
+ // Callers fail closed on exit 2: an unread input is never a pass.
+ console.error(`api-tagalong: ${err.message}`);
+ process.exit(2);
+ }
+ const result = analyze(input);
+ if (input.summary) fs.writeFileSync(input.summary, renderSummary(result));
+ process.stdout.write(JSON.stringify(result, null, 2) + '\n');
+}
+
+if (
+ process.argv[1] &&
+ path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)
+)
+ main();
diff --git a/.github/scripts/api-tagalong.test.mjs b/.github/scripts/api-tagalong.test.mjs
new file mode 100644
index 0000000000..6294979dd2
--- /dev/null
+++ b/.github/scripts/api-tagalong.test.mjs
@@ -0,0 +1,687 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file Contracts for the public API tag-along check.
+ * @input Fixture API changes, pull request titles and bodies, component folders
+ * @output Scope parsing, per-component grouping, tag-along rows, size, exit codes
+ * @position Regression tests for `.github/scripts/api-tagalong.mjs`
+ */
+
+import {execFileSync, spawnSync} from 'node:child_process';
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import {fileURLToPath} from 'node:url';
+import {afterAll, beforeAll, describe, expect, it} from 'vitest';
+import {
+ analyze,
+ componentsByPackage,
+ parseScope,
+ renderSummary,
+} from './api-tagalong.mjs';
+
+const SCRIPT = path.join(
+ path.dirname(fileURLToPath(import.meta.url)),
+ 'api-tagalong.mjs',
+);
+
+const REPO = path.resolve(
+ path.dirname(fileURLToPath(import.meta.url)),
+ '../..',
+);
+
+let tmp;
+let root;
+
+beforeAll(() => {
+ tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'api-tagalong-'));
+ root = tmp;
+ for (const dir of [
+ 'packages/core/src/Item',
+ 'packages/core/src/ItemGroup',
+ 'packages/core/src/List',
+ 'packages/core/src/Table',
+ 'packages/core/src/Tab',
+ 'packages/core/src/Button',
+ 'packages/core/src/Icon',
+ 'packages/core/src/Collapsible',
+ 'packages/core/src/hooks',
+ 'packages/lab/src/Integration',
+ 'packages/lab/src/__tests__',
+ 'packages/cli/src/IconSet',
+ ])
+ fs.mkdirSync(path.join(root, dir), {recursive: true});
+ fs.writeFileSync(path.join(root, 'packages/core/src/index.ts'), '');
+});
+
+afterAll(() => fs.rmSync(tmp, {recursive: true, force: true}));
+
+const row = (item, member = null, change = 'added') => ({
+ change,
+ entry: '.',
+ section: 'Types',
+ item,
+ member,
+ line: member ? `prop ${member}?: unknown` : item,
+ usage: '',
+});
+
+const changesFile = packages => ({version: 2, baseRecord: 'main', packages});
+const pkg = (name, rows) => ({pkg: name, rows});
+
+/** The changes of an integration import that also adds Item's onClick. */
+const integrationImport = changesFile([
+ pkg('@astryxdesign/core', [
+ row('component Item', 'onClick'),
+ row('interface ItemProps', 'onClick'),
+ ]),
+ pkg('@astryxdesign/lab', [
+ row('component Integration'),
+ row('interface IntegrationProps'),
+ row('type IntegrationConfig'),
+ row('function IntegrationManifest'),
+ ]),
+]);
+const integrationTitle =
+ 'feat(integrations): import the config and integration API';
+
+const body = scopeLines =>
+ [
+ '## Summary',
+ '',
+ 'Text.',
+ '',
+ '## Scope',
+ '',
+ ...scopeLines,
+ '',
+ '## Testing',
+ '',
+ 'Ran it.',
+ ].join('\n');
+
+const run = input =>
+ analyze({components: componentsByPackage(root), files: 0, ...input});
+
+describe('scope', () => {
+ it('reads component scopes from the conventional-commit title', () => {
+ expect(
+ parseScope({title: 'feat(Table): sort rows', body: ''}).scope,
+ ).toEqual(['Table']);
+ expect(
+ parseScope({title: 'fix(Item, List): keep focus', body: ''}).scope,
+ ).toEqual(['Item', 'List']);
+ });
+
+ it('keeps every title scope entry, and a plain type has none', () => {
+ expect(parseScope({title: 'fix(core): x', body: ''}).scope).toEqual([
+ 'core',
+ ]);
+ expect(parseScope({title: integrationTitle, body: ''}).scope).toEqual([
+ 'integrations',
+ ]);
+ expect(parseScope({title: 'ci: x', body: ''}).scope).toEqual([]);
+ });
+
+ it('adds the Components line under the Scope heading and ignores template comments', () => {
+ const {scope} = parseScope({
+ title: 'feat(Table): x',
+ body: body([
+ 'Components: Integration, `Item` <!-- note -->',
+ '- [ ] No intended public API change.',
+ ]),
+ });
+ expect(scope).toEqual(['Table', 'Integration', 'Item']);
+ expect(
+ parseScope({
+ title: 'ci: x',
+ body: body([
+ 'Components: <!-- the components and modules this PR changes, comma-separated -->',
+ ]),
+ }).scope,
+ ).toEqual([]);
+ });
+
+ it('reads a Components line only under the Scope heading', () => {
+ expect(
+ parseScope({title: 'ci: x', body: 'Components: Item\n\n## Scope\n\nnone'})
+ .scope,
+ ).toEqual([]);
+ });
+});
+
+describe('grouping', () => {
+ it("finds each registered package's own component folders", () => {
+ expect(componentsByPackage(root)).toEqual({
+ '@astryxdesign/core': [
+ 'Button',
+ 'Collapsible',
+ 'Icon',
+ 'Item',
+ 'ItemGroup',
+ 'List',
+ 'Tab',
+ 'Table',
+ ],
+ '@astryxdesign/lab': ['Integration'],
+ });
+ });
+
+ it("names the components the registry finds inside other components' folders", () => {
+ const core = componentsByPackage(REPO)['@astryxdesign/core'];
+ for (const name of ['Table', 'TableRow', 'List', 'ListItem', 'Theme'])
+ expect(core).toContain(name);
+ });
+
+ it('files a nested component under its own name, not its folder', () => {
+ const components = {
+ '@astryxdesign/core': ['List', 'ListItem', 'Table', 'TableRow'],
+ };
+ const tableRow = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('component TableRow', 'status'),
+ row('type TableRowStatus'),
+ ]),
+ ]),
+ title: 'fix(TableRow): add a status prop',
+ body: '',
+ });
+ expect(Object.keys(tableRow.rows_by_component)).toEqual(['TableRow']);
+ expect(tableRow.tagalongs).toEqual({});
+ const listItem = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [row('interface ListItemProps', 'tone')]),
+ ]),
+ title: 'fix(ListItem): x',
+ body: '',
+ });
+ expect(listItem.tagalongs).toEqual({});
+ const list = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [row('interface ListItemProps', 'tone')]),
+ ]),
+ title: 'fix(List): x',
+ body: '',
+ });
+ expect(Object.keys(list.tagalongs)).toEqual(['ListItem']);
+ });
+
+ it("matches a row only against its own package's components", () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/cli', [
+ row('interface IconSetAdapter'),
+ row('interface IconSetAdapter', 'resolve'),
+ ]),
+ ]),
+ title: 'feat(cli): add icon set adapters',
+ body: body(['Components: cli']),
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual([
+ '@astryxdesign/cli',
+ ]);
+ expect(result.tagalongs).toEqual({});
+ });
+
+ it("groups a component's own hooks and factories under it", () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('hook useItemState'),
+ row('function createTableModel'),
+ row('function isListItem'),
+ ]),
+ ]),
+ title: 'feat(core): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component).sort()).toEqual([
+ 'Item',
+ 'List',
+ 'Table',
+ ]);
+ });
+
+ it('groups a row under the component with the longest matching name', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ItemProps', 'onClick'),
+ row('interface ItemGroupProps', 'gap'),
+ row('component ItemGroup'),
+ row('interface TableProps', 'dense'),
+ row('type TabOrientation'),
+ ]),
+ ]),
+ title: 'feat(Item): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component).sort()).toEqual([
+ 'Item',
+ 'ItemGroup',
+ 'Tab',
+ 'Table',
+ ]);
+ expect(result.rows_by_component.Item.map(r => r.name)).toEqual([
+ 'ItemProps',
+ ]);
+ expect(result.rows_by_component.ItemGroup).toHaveLength(2);
+ });
+
+ it('groups a row with no component under its package', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('hook useThemeMode'),
+ row('var --color-accent (core.css)'),
+ ]),
+ ]),
+ title: 'feat(core): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual([
+ '@astryxdesign/core',
+ ]);
+ });
+
+ it('does not match a component name followed by a lowercase letter', () => {
+ const result = run({
+ changes: changesFile([pkg('@astryxdesign/core', [row('type Tabular')])]),
+ title: 'feat(Tab): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual([
+ '@astryxdesign/core',
+ ]);
+ });
+});
+
+describe('tag-alongs', () => {
+ it('flags Item when an integration import with no component scope adds its onClick', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: '',
+ });
+ expect(result.scope).toEqual(['integrations']);
+ expect(result.tagalongs.Item.map(r => `${r.name}.${r.member}`)).toEqual([
+ 'Item.onClick',
+ 'ItemProps.onClick',
+ ]);
+ expect(result.tagalongs.Integration).toHaveLength(4);
+ });
+
+ it('has no tag-alongs when the Scope section names Integration and Item', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: body(['Components: Integration, Item']),
+ });
+ expect(result.scope).toEqual(['integrations', 'Integration', 'Item']);
+ expect(result.tagalongs).toEqual({});
+ expect(result.rows_by_component.Item).toHaveLength(2);
+ });
+
+ it('accepts a row named anywhere under the Scope heading', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: body([
+ 'Components: Integration',
+ '',
+ 'Also adds `ItemProps.onClick` and `Item` onClick (owner approved).',
+ ]),
+ });
+ expect(result.tagalongs).toEqual({});
+ });
+
+ it('does not accept a row named only outside the Scope heading', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: `Adds Item onClick.\n\n${body(['Components: Integration'])}`,
+ });
+ expect(Object.keys(result.tagalongs)).toEqual(['Item']);
+ });
+
+ it('keeps every component of a multi-component title in scope', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ItemProps', 'size', 'changed'),
+ row('interface ListProps', 'gap', 'removed'),
+ row('interface ButtonProps', 'tone'),
+ ]),
+ ]),
+ title: 'fix(Item, List): align rows',
+ body: '',
+ });
+ expect(result.scope).toEqual(['Item', 'List']);
+ expect(Object.keys(result.tagalongs)).toEqual(['Button']);
+ });
+
+ it('accepts a package-level row whose name starts with a named scope entry', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/lab', [
+ row('type ConnectorRegistry'),
+ row('type Connectors'),
+ ]),
+ ]),
+ title: 'chore: x',
+ body: body(['Components: Connector']),
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual([
+ '@astryxdesign/lab',
+ ]);
+ expect(result.tagalongs['@astryxdesign/lab'].map(r => r.name)).toEqual([
+ 'Connectors',
+ ]);
+ });
+});
+
+describe('change kinds and case', () => {
+ it('never lists a removed row as a tag-along', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ButtonProps', 'tone', 'removed'),
+ row('interface ButtonProps', 'size', 'changed'),
+ ]),
+ ]),
+ title: 'fix(List): x',
+ body: '',
+ });
+ expect(result.rows_by_component.Button).toHaveLength(2);
+ expect(result.tagalongs.Button.map(r => r.member)).toEqual(['size']);
+ });
+
+ it('matches scope names in any case', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ItemProps', 'size'),
+ row('interface ButtonProps', 'tone'),
+ row('var --color-accent (core.css)'),
+ ]),
+ ]),
+ title: 'fix(item): x',
+ body: body(['Components: button, CORE']),
+ });
+ expect(result.tagalongs).toEqual({});
+ });
+});
+
+describe('own types, removed-only, and decided rows', () => {
+ it("groups a component's Use-prefixed types under it", () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface UseCollapsibleOptions', 'defaultOpen'),
+ row('type UseCollapsibleReturn'),
+ row('hook useCollapsible'),
+ ]),
+ ]),
+ title: 'fix(Collapsible): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual(['Collapsible']);
+ expect(result.tagalongs).toEqual({});
+ });
+
+ it('labels a component whose only rows are removed', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ButtonProps', 'tone', 'removed'),
+ row('interface ListProps', 'gap'),
+ ]),
+ ]),
+ title: 'fix(List): x',
+ body: '',
+ });
+ const table = renderSummary(result);
+ expect(table).toMatch(/\| Button \| 1 \| removed only \|/);
+ expect(table).toMatch(/\| List \| 1 \| yes \|/);
+ });
+
+ it('lists a row a current record decides as outside the scope, not as a tag-along', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: body(['Components: Integration']),
+ decided: ['ItemProps.onClick', 'Item'],
+ });
+ expect(result.tagalongs).toEqual({});
+ expect(result.decided.Item.map(r => `${r.name}.${r.member}`)).toEqual([
+ 'Item.onClick',
+ 'ItemProps.onClick',
+ ]);
+ expect(renderSummary(result)).toMatch(
+ /\| Item \| 2 \| outside the scope: 2 rows a current record decides \|/,
+ );
+ });
+
+ it('counts an undecided row as a tag-along beside a decided one', () => {
+ const result = run({
+ changes: integrationImport,
+ title: integrationTitle,
+ body: body(['Components: Integration']),
+ decided: ['ItemProps.onClick'],
+ });
+ expect(result.tagalongs.Item.map(r => r.name)).toEqual(['Item']);
+ expect(result.decided.Item.map(r => r.name)).toEqual(['ItemProps']);
+ expect(renderSummary(result)).toMatch(
+ /\| Item \| 2 \| no: 1 tag-along row; 1 row a current record decides \|/,
+ );
+ });
+});
+
+describe('theme targets and template prose', () => {
+ const components = {
+ '@astryxdesign/core': [
+ 'AlertDialog',
+ 'Button',
+ 'Layout',
+ 'Text',
+ 'TextArea',
+ ],
+ };
+ const target = (name, owner) => ({
+ ...row(`target ${name} (${owner})`),
+ entry: 'Theme targets',
+ section: '',
+ });
+
+ it('files a theme target under the exact component it names', () => {
+ const result = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [target('alert-dialog', 'AlertDialog')]),
+ ]),
+ title: 'fix(AlertDialog): x',
+ body: '',
+ });
+ expect(Object.keys(result.rows_by_component)).toEqual(['AlertDialog']);
+ expect(result.tagalongs).toEqual({});
+ });
+
+ it("never lets a component cover another component's target by prefix", () => {
+ const result = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [target('text-area', 'TextArea')]),
+ ]),
+ title: 'fix(Text): x',
+ body: '',
+ });
+ expect(Object.keys(result.tagalongs)).toEqual(['TextArea']);
+ });
+
+ it('does not read the template checklist as naming rows', () => {
+ const template = fs.readFileSync(
+ path.join(REPO, '.github/pull_request_template.md'),
+ 'utf8',
+ );
+ const filled = template.replace(/^Components:.*$/m, 'Components: Button');
+ expect(filled).toMatch(/text and artifacts/);
+ expect(filled).toMatch(/layout/);
+ const result = analyze({
+ components,
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ target('text', 'Text'),
+ target('layout', 'Layout'),
+ row('interface ButtonProps', 'tone'),
+ ]),
+ ]),
+ title: 'fix(Button): x',
+ body: filled,
+ });
+ expect(Object.keys(result.tagalongs).sort()).toEqual(['Layout', 'Text']);
+ });
+});
+
+describe('member names in code spans', () => {
+ it('names only that member when a code span names Name.member', () => {
+ const result = run({
+ changes: changesFile([
+ pkg('@astryxdesign/core', [
+ row('interface ItemProps', 'onClick'),
+ row('interface ItemProps', 'size', 'changed'),
+ row('hook useItemState'),
+ ]),
+ ]),
+ title: 'fix(List): x',
+ body: body(['Components: List', '', 'Also adds `ItemProps.onClick`.']),
+ });
+ expect(result.tagalongs.Item.map(r => `${r.name}.${r.member}`)).toEqual([
+ 'ItemProps.size',
+ 'useItemState.null',
+ ]);
+ });
+});
+
+describe('size', () => {
+ const many = (n, name = 'Item') =>
+ Array.from({length: n}, (_, i) => row(`interface ${name}Props`, `p${i}`));
+
+ it('is big with more than 3 components', () => {
+ const rows = [
+ row('type ItemA'),
+ row('type ListA'),
+ row('type TableA'),
+ row('type ButtonA'),
+ ];
+ expect(
+ run({
+ changes: changesFile([pkg('@astryxdesign/core', rows.slice(0, 3))]),
+ title: 'x: y',
+ body: '',
+ }).big,
+ ).toBe(false);
+ expect(
+ run({
+ changes: changesFile([pkg('@astryxdesign/core', rows)]),
+ title: 'x: y',
+ body: '',
+ }).big,
+ ).toBe(true);
+ });
+
+ it('is big with more than 10 rows', () => {
+ expect(
+ run({
+ changes: changesFile([pkg('@astryxdesign/core', many(10))]),
+ title: 'x: y',
+ body: '',
+ }).big,
+ ).toBe(false);
+ expect(
+ run({
+ changes: changesFile([pkg('@astryxdesign/core', many(11))]),
+ title: 'x: y',
+ body: '',
+ }).big,
+ ).toBe(true);
+ });
+
+ it('is big with more than 100 changed files', () => {
+ const changes = changesFile([pkg('@astryxdesign/core', many(1))]);
+ expect(run({changes, title: 'x: y', body: '', files: 100}).big).toBe(false);
+ expect(run({changes, title: 'x: y', body: '', files: 101}).big).toBe(true);
+ });
+});
+
+describe('command line', () => {
+ const write = (name, text) => {
+ const file = path.join(tmp, name);
+ fs.writeFileSync(file, text);
+ return file;
+ };
+
+ it('prints the result, writes the summary table, and exits 0', () => {
+ const changes = write('changes.json', JSON.stringify(integrationImport));
+ const bodyFile = write('body.md', body(['Components: Integration']));
+ const summary = path.join(tmp, 'summary.md');
+ const out = execFileSync(
+ process.execPath,
+ [
+ SCRIPT,
+ '--changes',
+ changes,
+ '--title',
+ integrationTitle,
+ '--body-file',
+ bodyFile,
+ '--root',
+ root,
+ '--files',
+ '3330',
+ '--summary',
+ summary,
+ ],
+ {encoding: 'utf8'},
+ );
+ const result = JSON.parse(out);
+ expect(result.version).toBe(1);
+ expect(result.big).toBe(true);
+ expect(Object.keys(result.tagalongs)).toEqual(['Item']);
+ const table = fs.readFileSync(summary, 'utf8');
+ expect(table).toContain('| Component | Rows | In scope |');
+ expect(table).toMatch(/\| Integration \| 4 \| yes \|/);
+ expect(table).toMatch(/\| Item \| 2 \| no: 2 tag-along rows \|/);
+ });
+
+ it('exits 2 when the changes file is missing or unreadable', () => {
+ const missing = spawnSync(
+ process.execPath,
+ [
+ SCRIPT,
+ '--changes',
+ path.join(tmp, 'nope.json'),
+ '--title',
+ 'ci: x',
+ '--root',
+ root,
+ ],
+ {encoding: 'utf8'},
+ );
+ expect(missing.status).toBe(2);
+ const broken = write('broken.json', '{not json');
+ const unreadable = spawnSync(
+ process.execPath,
+ [SCRIPT, '--changes', broken, '--title', 'ci: x', '--root', root],
+ {encoding: 'utf8'},
+ );
+ expect(unreadable.status).toBe(2);
+ const noFlag = spawnSync(process.execPath, [SCRIPT, '--title', 'ci: x'], {
+ encoding: 'utf8',
+ });
+ expect(noFlag.status).toBe(2);
+ });
+});
diff --git a/docs/architecture/knowledge-contracts.md b/docs/architecture/knowledge-contracts.md
index 5d048a4815..8e4d02e042 100644
--- a/docs/architecture/knowledge-contracts.md
+++ b/docs/architecture/knowledge-contracts.md
@@ -9,7 +9,15 @@ superseded_by: null
approved_by: cixzhang
approved_at: 2026-08-30
owners: [cixzhang]
-applies_to: [AGENTS.md, .github/PULL_REQUEST_TEMPLATE/, docs/, packages/]
+applies_to:
+ [
+ AGENTS.md,
+ .github/PULL_REQUEST_TEMPLATE/,
+ .github/pull_request_template.md,
+ .github/scripts/api-tagalong.mjs,
+ docs/,
+ packages/,
+ ]
verified_by:
[
scripts/check-knowledge.test.mjs,
@@ -22,6 +30,7 @@ verified_by:
.github/scripts/review-signal-decision.test.mjs,
.github/scripts/review-signal-workflow.test.mjs,
.github/scripts/spec-owner-decision.test.mjs,
+ .github/scripts/api-tagalong.test.mjs,
apps/docsite/src/__tests__/example-coverage.test.ts,
]
deciding_specs: []
@@ -482,6 +491,10 @@ the rest:
line, and a placeholder decider that a real decider replaces are not
changes.
+### Public API scope
+
+- **INV33 — Every public API row a pull request adds or changes is named in its scope.** A pull request names the components and modules it changes, and lists its public API rows by component. A row outside that named scope that no current owner-approved record decides is sent to an owner with the row listed, and the pull request doesn't merge until the row is named and owner-approved, or split into its own pull request. A row outside the scope that a current record decides needs no further step (INV25), but the status still lists it as outside the scope, so a reviewer sees it. A behavior handler (a public event or callback prop, such as `onClick`, that makes a component act on input) added outside the scope warns.
+
## Path applicability
Use this optional block when a record governs paths that its placement, path
@@ -1356,6 +1369,13 @@ The owner said: "Anything lab only gets an ok". A Lab-only pull request, as `spe
Rejected: treating a pull request that also changes Core or another package as Lab-only.
+### DEC-21 — A public API row outside a pull request's scope needs a decision
+
+**Reference:** `architecture:knowledge-contracts/DEC-21`
+**Decider:** `cixzhang`, `2026-11-09`
+
+The owner said: "I think for big prs like 3280 we need better guard rails around preventing tagalongs". A single large import once carried Item's row `onClick` and container click with no decision recorded. The rule above makes such a tag-along visible before merge. Rejected: relying on review to catch tag-alongs in large pull requests.
+
## Verification
| Invariant | Evidence | Failure signal |
@@ -1376,16 +1396,17 @@ Rejected: treating a pull request that also changes Core or another package as L
| DEC-14 (design owner's own PR) | `.github/scripts/spec-owner-reconcile.test.mjs` "accepts a DESIGNOWNER author's own /approve-spec on a design record"; the accessibility-requirement and deprecation limit has no gate check (the Current gap in DEC-14) | A DESIGNOWNER author's own `/approve-spec` does not approve a current design record on their own pull request; the accessibility-requirement and deprecation limit has no failure signal because the gate does not check it (Current gap) |
| DEC-11 | `.github/scripts/review-signal-decision.test.mjs`, `.github/scripts/review-clear-workflow.test.mjs`, and `.github/scripts/review-signal-workflow.test.mjs` | An app approval clears a read-only or fork author or an earlier head; a later app request for changes or dismissal leaves the gate clear; an app approval overrides an ENGOWNER request for changes; or an unset app or unreadable permission clears the gate |
-| Invariant | Evidence | Failure signal |
-| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| 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`, `.github/scripts/change-scope.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 |
-| INV28, DEC-16 | `apps/docsite/src/lib/exampleCoverage.mjs` and `apps/docsite/src/__tests__/example-coverage.test.ts` (advisory: the report prints and never gates), plus review of each hook example against INV28's criteria | The report omits a public hook that has no hook doc or no conforming example block, or a missing or non-conforming hook example fails a merge or release |
-| INV29 | Baselined lint over comments in package source (not built): record ids, pull request and issue numbers, date stamps, and long quote blocks fail in new comments, and existing sites are baselined. Review reports narration and file headers past about 12 lines as non-blocking findings. Cleanup lands in per-area pull requests with no behavior change, each with a `pnpm specs:for` comparison of every touched file before and after | A new comment cites a record, pull request, issue, or date, quotes a record, or narrates the code; a header grows past about 12 lines, with no lint failure or review finding; removing a comment drops a record or cited claim from a file's `pnpm specs:for` result because that comment was the file's only link to it; or cleanup removes or rewrites a directive a tool reads, such as a `@pr-a11y` line |
-| INV30, DEC-17 | Human-owner review of each new external URL in a pull request from an author outside the team, enforced by review and merge tooling outside the repository; no repository CI check (the INV30 enforcement gap below) | An outside pull request that adds an external URL under package docs or the docsite is approved or merged without a human owner's exact-head approval, or a team pull request that adds one is held for a human owner |
-| INV31, DEC-18 | `scripts/check-knowledge.test.mjs` "approval line history"; `pnpm check:knowledge --base <base>` lists each changed approval line with its original decider; review and merge tooling outside the repository require that decider's exact-head approval (the INV31 enforcement gap below) | A pull request that changes or removes an existing Decider or `approved_by` line is approved or merged without the original decider's exact-head approval, or a pull request that only adds a decision or an approver is held |
-| DEC-15 | `.github/scripts/knowledge-paths.test.mjs`, `.github/scripts/change-scope.test.mjs`, `scripts/check-knowledge.test.mjs`, `scripts/specs-for-file.test.mjs`, and `pnpm check:knowledge` | A component or module record outside `docs/specs/components/<ComponentRoot>/`, a `*.spec.md` left in a component package's source tree or beside a Swift view, a record matched to the wrong package when two share a root, a record whose component root no registered package's source tree has, a platform record whose id or `platform_of` does not match its path, or a platform record change that skips the spec-owner gate |
+| Invariant | Evidence | Failure signal |
+| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| 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`, `.github/scripts/change-scope.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 |
+| INV28, DEC-16 | `apps/docsite/src/lib/exampleCoverage.mjs` and `apps/docsite/src/__tests__/example-coverage.test.ts` (advisory: the report prints and never gates), plus review of each hook example against INV28's criteria | The report omits a public hook that has no hook doc or no conforming example block, or a missing or non-conforming hook example fails a merge or release |
+| INV29 | Baselined lint over comments in package source (not built): record ids, pull request and issue numbers, date stamps, and long quote blocks fail in new comments, and existing sites are baselined. Review reports narration and file headers past about 12 lines as non-blocking findings. Cleanup lands in per-area pull requests with no behavior change, each with a `pnpm specs:for` comparison of every touched file before and after | A new comment cites a record, pull request, issue, or date, quotes a record, or narrates the code; a header grows past about 12 lines, with no lint failure or review finding; removing a comment drops a record or cited claim from a file's `pnpm specs:for` result because that comment was the file's only link to it; or cleanup removes or rewrites a directive a tool reads, such as a `@pr-a11y` line |
+| INV30, DEC-17 | Human-owner review of each new external URL in a pull request from an author outside the team, enforced by review and merge tooling outside the repository; no repository CI check (the INV30 enforcement gap below) | An outside pull request that adds an external URL under package docs or the docsite is approved or merged without a human owner's exact-head approval, or a team pull request that adds one is held for a human owner |
+| INV31, DEC-18 | `scripts/check-knowledge.test.mjs` "approval line history"; `pnpm check:knowledge --base <base>` lists each changed approval line with its original decider; review and merge tooling outside the repository require that decider's exact-head approval (the INV31 enforcement gap below) | A pull request that changes or removes an existing Decider or `approved_by` line is approved or merged without the original decider's exact-head approval, or a pull request that only adds a decision or an approver is held |
+| INV33, DEC-21 | `.github/scripts/api-tagalong.test.mjs` | An added or changed row whose component is outside the title scope and the `Components:` line, not named in a code span or the `Components:` line under `## Scope`, and not decided by a current record, is not listed as a tag-along; an in-scope, named, removed, or decided row is listed as a tag-along; a decided row outside the scope is missing from the summary; a row matches another package's components; or an unreadable API changes file exits 0 |
+| DEC-15 | `.github/scripts/knowledge-paths.test.mjs`, `.github/scripts/change-scope.test.mjs`, `scripts/check-knowledge.test.mjs`, `scripts/specs-for-file.test.mjs`, and `pnpm check:knowledge` | A component or module record outside `docs/specs/components/<ComponentRoot>/`, a `*.spec.md` left in a component package's source tree or beside a Swift view, a record matched to the wrong package when two share a root, a record whose component root no registered package's source tree has, a platform record whose id or `platform_of` does not match its path, or a platform record change that skips the spec-owner gate |
Evidence placement is enforced by contributors and reviewers. The local
`docs/pr-assets/` ignore prevents accidental staging; it is not a blocking CI
@@ -1429,3 +1450,11 @@ Current enforcement gap: no repository check reads approvals (INV31).
`pnpm check:knowledge --base <base>` reports each changed approval line as a
warning and does not fail. Review and merge tooling outside the repository
requires the original decider's approval.
+
+Current enforcement gap: `.github/scripts/api-tagalong.mjs` lists each added or
+changed public API row outside a pull request's named scope (INV33), and lists
+a row a current record decides as outside the scope without counting it as a
+tag-along when its caller supplies those rows. No CI job runs the script yet,
+so review sends an undecided row to an owner. The script reads API rows only:
+review checks owner approval of a named row and a behavior handler change
+outside the scope that adds no API row.