Converge note-frontmatter contract to one shared zod schema#344
Open
jmchilton wants to merge 1 commit into
Open
Converge note-frontmatter contract to one shared zod schema#344jmchilton wants to merge 1 commit into
jmchilton wants to merge 1 commit into
Conversation
Two hand-maintained encodings drifted: ajv meta_schema.yml (CLI validator) and a parallel zod in site content.config.ts (Astro). The prompt note type existed only in the ajv copy; the site zod had silently dropped several regexes. - New @galaxy-foundry/note-schema: buildNoteSchema() discriminated union over 9 note types + canonical tags/reference-contract/license-policy loaders (collapses triplicate loader copies across build-cli, site, scripts). - Validator native-zod: validate.ts uses safeParse, maps issues to the old field:message strings. ajv dropped from the frontmatter path (still used by cast-mold for Mold IO schemas). build-cli lib/*.ts are re-export shims. - Site consumes the shared schema; delete meta_schema.yml + duplicate site libs; repoint docs + slash commands. - Restore constraints the site zod had dropped: license_file regex, companions uniqueItems+regex, validator_bin/subcommand regex, prompt note type. - Join site to pnpm workspace (workspace:* deps, drop site/package-lock.json); scope packages-* scripts to packages/*; rewrite deploy.yml withastro->explicit pnpm build so package dist exists before Astro imports it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Drafted by Claude (AI assistant) on jmchilton's behalf.
Why
The note-frontmatter contract was maintained in two hand-written encodings that drifted apart:
meta_schema.yml— ajv / JSON Schema Draft-07, used by the CLI validator.site/src/content.config.ts, used by the Astro site.They had already diverged: the
promptnote type existed only in the ajv copy, and the site zod had silently dropped several regex/uniqueness constraints. This is the same two-encoding drift class that broke a prior deploy.This PR converges them to one zod schema, imported by both the validator and the site.
What changed
@galaxy-foundry/note-schema—buildNoteSchema({tags, contract, licensePolicy})returns a discriminated union over the 9 note types, plus the canonicaltags/reference-contract/license-policyloaders. This collapses what were triplicate loader copies acrossbuild-cli,site, andscripts.validate.tsusesschema.safeParseand maps zod issues to the existingfield: messagestrings. ajv is dropped from the frontmatter path (still used bycast-moldfor Mold IO schemas).build-cli'slib/schema.ts/reference-contract.ts/license-policy.tsare now thin re-export shims.content.config.ts→buildNoteSchema; newsite/src/lib/registries.tsloads the registries; the two duplicate site libs are deleted.meta_schema.ymldeleted. Docs + slash commands repointed.license_fileregex,companionsuniqueItems + item regex,validator_bin/subcommandregex, and thepromptnote type. The union is now tighter than the old flat property bag.siteto the pnpm workspace —workspace:*deps, droppedsite/package-lock.json, regeneratedpnpm-lock.yaml, scopedpackages-*scripts topackages/*.deploy.ymlrewriteThe Pages deploy previously used
withastro/action@v3(which detectedsite/package-lock.json→ npm). After the workspace join, that lockfile is gone and site deps areworkspace:*(npm can't resolve those), so the action would break.deploy.yml's build job is replaced with an explicit pnpm build mirroring the workingpackages.yml:This also fixes a latent fragility: the old path relied on the packages' gitignored
dist/somehow existing; it's now built deterministically before Astro imports it. The Astrobase: '/foundry'is hardcoded inastro.config.mjs, so dropping the action's implicitconfigure-pagesis safe. The one thing not provable in CI-of-this-PR is the actual Pages deploy (deploy.yml only runs on push tomain) — worth watching the first post-merge deploy run.Verification (all green locally)
pnpm install --frozen-lockfilenpm run validatenpm run testnpm run packages-test/-typecheck/-build/-format/-lintnpm run typecheck(tsc + astro check)npm run smoke:packagesnpm run site:build(the deploy command)A subagent review found no constraint-parity gaps (no previously-invalid note would now validate) and no lingering references to the deleted files.
🤖 Generated with Claude Code