An open source design system that's fully customizable and agent ready
TypeScript
fix(specs): use current repository approver membership (#7538)
nynexman4464c529db22253b
diff --git a/scripts/check-knowledge.mjs b/scripts/check-knowledge.mjsindex a02a344b0e..0a270bcb7f 100644--- a/scripts/check-knowledge.mjs+++ b/scripts/check-knowledge.mjs@@ -1,5 +1,12 @@// Copyright (c) Meta Platforms, Inc. and affiliates.+/**+ * @file Knowledge-record validation.+ * @input Versioned schemas, records, and current ENGOWNERS/DESIGNOWNERS.+ * @output Structural, relationship, and approval-eligibility problems.+ * @position Repository knowledge guardrail; schemas do not grant approval rights.+ */+/* global console, process */import fs from 'node:fs';import path from 'node:path';@@ -1296,7 +1303,7 @@ function validateAgainstSchema(isTemplate,currentTemplateVersion,designApprovalOwners = [],- themeApprovalOwners = [],+ engineeringApprovalOwners = [],) {const problems = [...document.problems];const {frontmatter, sections} = document;@@ -1409,11 +1416,9 @@ function validateAgainstSchema(const approvedBy = frontmatter.get('approved_by');const approvedAt = frontmatter.get('approved_at');const authorizedOwners =- kind === 'design'- ? [...new Set([...schema.approvalOwners, ...designApprovalOwners])]- : kind === 'theme'- ? themeApprovalOwners- : schema.approvalOwners;+ kind === 'design' || kind === 'theme'+ ? [...new Set([...engineeringApprovalOwners, ...designApprovalOwners])]+ : engineeringApprovalOwners;if (!authorizedOwners.includes(approvedBy)) {problems.push(`${filePath}: current records require approved_by to name an authorized owner.`,@@ -1593,9 +1598,6 @@ export async function validateKnowledgeRoot(root = DEFAULT_ROOT) {const engineeringApprovalOwners = fs.existsSync(engineeringOwnersPath)? parseOwnerFile(fs.readFileSync(engineeringOwnersPath, 'utf8')): [];- const themeApprovalOwners = [- ...new Set([...engineeringApprovalOwners, ...designApprovalOwners]),- ];const problems = [...discoverThemeRecordCandidates(root).problems];const ids = new Map();const records = [];@@ -1634,7 +1636,7 @@ export async function validateKnowledgeRoot(root = DEFAULT_ROOT) {true,templateVersions[kind],designApprovalOwners,- themeApprovalOwners,+ engineeringApprovalOwners,),);if (template.frontmatter.get('kind') !== kind) {@@ -1687,7 +1689,7 @@ export async function validateKnowledgeRoot(root = DEFAULT_ROOT) {false,templateVersions[document.frontmatter.get('kind')],designApprovalOwners,- themeApprovalOwners,+ engineeringApprovalOwners,),);const authority = document.frontmatter.get('authority');diff --git a/scripts/check-knowledge.test.mjs b/scripts/check-knowledge.test.mjsindex da0ad4455d..e235c7a8de 100644--- a/scripts/check-knowledge.test.mjs+++ b/scripts/check-knowledge.test.mjs@@ -1991,6 +1991,85 @@ describe('knowledge validation', () => {);});+ describe('repository owner eligibility', () => {+ const records = [+ ['architecture', 'architecture.md', 'docs/architecture/approval.md'],+ [+ 'component',+ 'component-spec.md',+ 'packages/core/src/Button/Button.spec.md',+ ],+ [+ 'module',+ 'module-spec.md',+ 'packages/core/src/Button/hooks/useButtonThing.spec.md',+ ],+ ['family', 'family-contract.md', 'docs/families/approval.md'],+ ['system-spec', 'system-spec.md', 'docs/specs/AST-900/spec.md'],+ ['design', 'design-spec.md', 'docs/design/approval.md'],+ ['theme', 'theme-spec.md', 'packages/themes/neutral/neutral.spec.md'],+ ];++ function writeApprovalRecord(root, templateName, filePath, approvedBy) {+ const template = fs.readFileSync(+ path.join(root, 'docs/templates/knowledge', templateName),+ 'utf8',+ );+ const content = template+ .replace('authority: draft', 'authority: current')+ .replace('approved_by: null', `approved_by: ${approvedBy}`)+ .replace('approved_at: null', 'approved_at: 2026-10-13');+ fs.mkdirSync(path.dirname(path.join(root, filePath)), {recursive: true});+ fs.writeFileSync(path.join(root, filePath), content);+ }++ function approvalProblems(problems, filePath) {+ return problems.filter(problem =>+ problem.startsWith(`${filePath}: current records require approved_by`),+ );+ }++ it.each(records)(+ 'accepts an ENGOWNER for %s records',+ async (_kind, templateName, filePath) => {+ const root = fixtureRoot();+ writeApprovalRecord(root, templateName, filePath, 'nynexman4464');+ expect(+ approvalProblems(await validateKnowledgeRoot(root), filePath),+ ).toEqual([]);+ },+ );++ it.each(records)(+ 'does not inherit the legacy schema approver list for %s',+ async (_kind, templateName, filePath) => {+ const root = fixtureRoot();+ for (const ownerFile of ['ENGOWNERS', 'DESIGNOWNERS']) {+ const ownerPath = path.join(root, '.github', ownerFile);+ fs.writeFileSync(+ ownerPath,+ fs.readFileSync(ownerPath, 'utf8').replace(/@cixzhang\b/g, ''),+ );+ }+ writeApprovalRecord(root, templateName, filePath, 'cixzhang');+ expect(+ approvalProblems(await validateKnowledgeRoot(root), filePath),+ ).toHaveLength(1);+ },+ );++ it.each(records)(+ 'limits DESIGNOWNER eligibility to design/theme for %s',+ async (kind, templateName, filePath) => {+ const root = fixtureRoot();+ writeApprovalRecord(root, templateName, filePath, 'rubyycheung');+ expect(+ approvalProblems(await validateKnowledgeRoot(root), filePath),+ ).toHaveLength(kind === 'design' || kind === 'theme' ? 0 : 1);+ },+ );+ });+it('requires explicit approval for a current record', async () => {const root = fixtureRoot();const directory = path.join(root, 'packages/core/src/Button');