Repository navigation
ci: make the Astryx surface inventory a regenerate-and-diff gate #3078
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Astro-Han
merged 2 commits into
apache:main
from
1625567290:fix/astryx-surface-inventory-ci
Aug 16, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,109 +1,79 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Coverage gate: every product surface file on disk appears in | ||
| * docs/astryx-surface-file-inventory.paths (and vice versa). | ||
| * Uses the same enumeration as generate-astryx-surface-inventory.mjs. | ||
| * Coverage gate: committed inventory artifacts match a fresh generator run. | ||
| * | ||
| * These files are generated. Hand-editing one half (or leaving a deleted | ||
| * path in the Markdown table) is the failure mode. Regenerating and | ||
| * comparing bytes is the invariant — not a second, hand-written file list. | ||
| * | ||
| * Run: npm run astryx:surface-inventory | ||
| * Fix: npm run astryx:surface-inventory:write | ||
| */ | ||
| import { readFileSync, existsSync } from 'node:fs'; | ||
| import { join } from 'node:path'; | ||
| import { fileURLToPath, pathToFileURL } from 'node:url'; | ||
| import { spawnSync } from 'node:child_process'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { renderAstryxSurfaceInventory } from './generate-astryx-surface-inventory.mjs'; | ||
|
|
||
| const root = join(fileURLToPath(new URL('..', import.meta.url))); | ||
| const pathsFile = join(root, 'docs/astryx-surface-file-inventory.paths'); | ||
| const mdFile = join(root, 'docs/astryx-surface-file-inventory.md'); | ||
|
|
||
| // Import shared enumerator by running generate's export via dynamic import | ||
| const genUrl = pathToFileURL(join(root, 'scripts/generate-astryx-surface-inventory.mjs')).href; | ||
|
|
||
| async function main() { | ||
| function main() { | ||
| if (!existsSync(pathsFile) || !existsSync(mdFile)) { | ||
| console.error( | ||
| 'missing inventory artifacts — run: node scripts/generate-astryx-surface-inventory.mjs', | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // Re-run generator's list logic without rewriting: dynamic import of module | ||
| // that calls main() on load — so import the file by reading list from a | ||
| // subprocess that only prints paths, OR re-implement via spawning generate | ||
| // and comparing. Safest: import after making generate not auto-main. | ||
| const { listProductSurfaceFiles } = await import(genUrl); | ||
| if (typeof listProductSurfaceFiles !== 'function') { | ||
| console.error('generate-astryx-surface-inventory.mjs must export listProductSurfaceFiles'); | ||
| console.error('missing inventory artifacts — run: npm run astryx:surface-inventory:write'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const { files: diskFiles, excluded } = listProductSurfaceFiles(root); | ||
| const listed = readFileSync(pathsFile, 'utf8') | ||
| .split('\n') | ||
| .map((l) => l.trim()) | ||
| .filter(Boolean); | ||
|
|
||
| const diskSet = new Set(diskFiles); | ||
| const listSet = new Set(listed); | ||
| const rendered = renderAstryxSurfaceInventory(root); | ||
| const committedMd = readFileSync(mdFile, 'utf8'); | ||
| const committedPaths = readFileSync(pathsFile, 'utf8'); | ||
| const mdDrift = committedMd !== rendered.markdown; | ||
| const pathsDrift = committedPaths !== rendered.paths; | ||
|
|
||
| const missing = diskFiles.filter((f) => !listSet.has(f)); | ||
| const extra = listed.filter((f) => !diskSet.has(f)); | ||
|
|
||
| const md = readFileSync(mdFile, 'utf8'); | ||
| const mdMissing = []; | ||
| for (const f of diskFiles) { | ||
| if (!md.includes(`\`${f}\``)) mdMissing.push(f); | ||
| if (!mdDrift && !pathsDrift) { | ||
| console.log( | ||
| `astryx surface inventory coverage: ok (${rendered.files.length} files, ${rendered.excluded.length} exclusions)`, | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| // Required dedicated entries (acceptance) | ||
| const required = [ | ||
| 'apps/desktop/src/renderer/settings/general-settings-page.tsx', | ||
| 'apps/desktop/src/renderer/settings/settings-modal.tsx', | ||
| 'packages/ui/src/skills-panel.tsx', | ||
| 'apps/desktop/src/renderer/mcp-page.tsx', | ||
| 'packages/ui/src/scheduled-task-panel.tsx', | ||
| 'packages/ui/src/daily-review-panel.tsx', | ||
| 'packages/ui/src/primitives/module-page.tsx', | ||
| ]; | ||
| const requiredMissing = required.filter((f) => !listSet.has(f) || !md.includes(`\`${f}\``)); | ||
|
|
||
| // No family-batch claim without per-file rows: inventory must not use old batch prose | ||
| if ( | ||
| /General, Appearance, Data, Providers/.test(md) && | ||
| !md.includes('general-settings-page.tsx') | ||
| ) { | ||
| console.error('inventory still uses family-batch claims without per-file rows'); | ||
| process.exit(1); | ||
| } | ||
| const committedPathSet = new Set( | ||
| committedPaths | ||
| .split('\n') | ||
| .map((line) => line.trim()) | ||
| .filter(Boolean), | ||
| ); | ||
| const generatedPathSet = new Set(rendered.files); | ||
| const missing = rendered.files.filter((file) => !committedPathSet.has(file)); | ||
| const extra = [...committedPathSet].filter((file) => !generatedPathSet.has(file)); | ||
|
|
||
| const failures = []; | ||
| if (missing.length) | ||
| failures.push( | ||
| `on disk but not in .paths (${missing.length}):\n ${missing.slice(0, 20).join('\n ')}`, | ||
| ); | ||
| if (extra.length) | ||
| failures.push( | ||
| `in .paths but not on disk (${extra.length}):\n ${extra.slice(0, 20).join('\n ')}`, | ||
| ); | ||
| if (mdMissing.length) { | ||
| failures.push( | ||
| `on disk but not a markdown row (${mdMissing.length}):\n ${mdMissing.slice(0, 20).join('\n ')}`, | ||
| ); | ||
| } | ||
| if (requiredMissing.length) { | ||
| failures.push(`required surfaces missing:\n ${requiredMissing.join('\n ')}`); | ||
| const details = []; | ||
| if (pathsDrift) { | ||
| details.push('.paths does not match generator output'); | ||
| if (missing.length) { | ||
| details.push( | ||
| `on disk but not in .paths (${missing.length}):\n ${missing.slice(0, 20).join('\n ')}`, | ||
| ); | ||
| } | ||
| if (extra.length) { | ||
| details.push( | ||
| `in .paths but not on disk (${extra.length}):\n ${extra.slice(0, 20).join('\n ')}`, | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| if (failures.length) { | ||
| console.error( | ||
| `astryx surface inventory coverage failed:\n${failures.map((f) => `- ${f}`).join('\n')}`, | ||
| ); | ||
| process.exit(1); | ||
| if (mdDrift) { | ||
| details.push('docs/astryx-surface-file-inventory.md does not match generator output'); | ||
| } | ||
|
|
||
| console.log( | ||
| `astryx surface inventory coverage: ok (${listed.length} files, ${excluded.length} exclusions)`, | ||
| console.error( | ||
| `astryx surface inventory is stale; run: npm run astryx:surface-inventory:write\n${details.map((line) => `- ${line}`).join('\n')}`, | ||
| ); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| main().catch((err) => { | ||
| console.error(err); | ||
| try { | ||
| main(); | ||
| } catch (error) { | ||
| console.error(error); | ||
| process.exit(1); | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.