Skip to content

build(schema): build lib/settings.schema.json instead of committing it - #415

Merged
Vivswan merged 1 commit into
mainfrom
wt/schema-off-main
Sep 23, 2026
Merged

Vivswan merged 1 commit into
mainfrom
wt/schema-off-main

Conversation

@Vivswan

@Vivswan Vivswan commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Before After
lib/settings.schema.json on main committed; regenerated by build:check, auto-fix, and the schema-check job untracked and gitignored, like lib/index.js and lib/pkg/
Packaged commits (build tags, vX.Y.Z, v2, latest) carried the committed file carry it as a required built file (release-pipeline.ts)
Who builds it nobody on a PR; the release hook byte-checked the committed copy bun run test, bun run fuzz, the e2e-smoke and nightly fuzz jobs, the package smoke, and the packaging and publish jobs run build:schema first
How tests read it JSON imports, which tsc resolves at typecheck readSettingsSchema() at run time (test/settings-schema.ts), so a checkout that has not built it still typechecks; a missing file fails naming the fix (bun run build:schema)

Depends on

How

  • Off main: .gitignore gains lib/settings.schema.json beside lib/index.js; the generator creates lib/ on a fresh checkout.
  • Built where it is read: the test and fuzz scripts run build:schema first; e2e-smoke, nightly-fuzz, and the package smoke build it before the fuzzer or build:lib. test:e2e is unchanged: test/e2e/run.ts never loads the schema.
  • Packaged, not byte-checked: PACKAGED_PATHS and REQUIRED_BUILT_FILES include the schema; post-green.yml and both npm publishers run build:schema; update-release.yml drops the git diff --exit-code byte check, which an untracked file never trips.
  • Drift machinery goes: the schema row leaves generated.ts and auto-fix.yml; the schema-check job is deleted.
  • Docs follow: the blob/main schema link in examples.md would 404 and now names the v2 tag with an x-release-please-major marker; release-please-config.json lists the page. The other pages say "built" where they said "committed".
  • What a contributor runs: bun run test builds the schema first; bun run build:schema alone or bun run build also writes it. A bare bun test on a fresh checkout does not.

Proof

Local, targeted:

Check Result
bun run typecheck with lib/ deleted entirely pass (no JSON import of the built file remains)
bun run build:schema into a missing lib/ writes the file (92 definitions)
bun run knip, bun run lint, bun run lint:yaml, bun run build:check pass; build:check reports 11 generated files
bun run test <readers, test/docs, generated, auto-fix-allowlist, release-pipeline x2, generators.test> with the schema deleted first all pass
bun run test:e2e --sections labels 62/62
bun .github/scripts/package-smoke.ts with the schema deleted first builds the schema, packs, installs, imports the schema subpath, typechecks: ok
bun run fuzz --iterations 1 --seed 2 with the schema deleted first builds the schema; 1/1 iterations ok

Red proof: with the file deleted and bun run build:schema removed from the test script, bun run test test/published-schema.test.ts fails with ENOENT on lib/settings.schema.json; restored, it passes.

Technical details
  • Reviewer note ($schema hints): README, getting-started, snapshot, and src/flows/snapshot.ts are unchanged: they name the raw URL at the moving major tag, which points at packaged commits, and those carry lib/.
  • Accepted deviation ($id): the $id stays the HEAD raw URL by owner decision. HEAD is main, so after this PR that URL stops serving the file, as the catalog's old main URL does; consumers fetch through the hints (and, once Point github-settings-as-code at its latest release asset SchemaStore/schemastore#6396 lands, the release asset), not the $id.
  • Reviewer note (test/docs/guides.test.ts): carries ../../lib/settings.schema.json only inside a synthetic fixture page for the links-leaving-docs guard, not a real doc link; left as is.
  • Files:
    • .gitignore; .github/scripts/gen-settings-schema.ts (mkdirSync for lib/); lib/settings.schema.json removed from the index.
    • package.json (test, fuzz); test/e2e/fuzz.ts (the printed replay commands go through bun run fuzz); CONTRIBUTING.md (the replay recipe).
    • checks.yml: the check job builds it through bun run test, so a failing generator fails the Test step; schema-check deleted; e2e-smoke builds it before the fuzzer. nightly-fuzz.yml gets the same step.
    • .github/scripts/package-smoke.ts builds it before build:lib: the tarball's files list and the ./settings.schema.json export need it.
    • .github/scripts/release-pipeline.ts (PACKAGED_PATHS, REQUIRED_BUILT_FILES, the refusal text); post-green.yml's build step; update-release-pr.yml and update-release.yml (build:schema && build:lib; the byte check dropped).
    • Drift machinery: generated.ts, test/scripts/generated.test.ts, and every list in auto-fix.yml (header, trigger paths, git add, case arm, error message, commit subjects); the lefthook.yml comment.
    • Tests: test/settings-schema.ts (the new reader); published-schema, schema-corpus, package-json, docs/readme, docs/library-examples, and e2e/generators read through it; the release-pipeline tests and fixture carry the schema in the packaged tree.
    • Docs: the AGENTS.md hard rule, CONTRIBUTING.md, SECURITY.md, troubleshooting.md (the fork-branch recipe no longer asks for a schema commit), library.md ("committed" to "built"; the checkout recipe and the packaged-commit description name the schema), and examples.md.
  • Line accounting: git diff origin/main...HEAD -M --numstat: 33 files, +131 / -4227. Of the deletions, 4128 are lib/settings.schema.json itself; the code and prose delta is +131 / -99.

BEGIN_COMMIT_OVERRIDE
build(schema): build lib/settings.schema.json instead of committing it

lib/settings.schema.json is untracked and gitignored beside lib/index.js and lib/pkg/, and every packaged commit off main now carries it as a required built file.
The test and fuzz scripts, the e2e-smoke job, the package smoke, and the packaging and publish jobs run build:schema before anything loads or packs the schema.
The drift machinery (the generated-output table row, the auto-fix schema branch, the schema-check job, the release hook's byte check) goes with the committed file.
The $schema hints and the $id are unchanged; the examples page links the schema at the moving major tag, which release-please now rewrites.
END_COMMIT_OVERRIDE

Copilot AI balanced review requested due to automatic review settings September 22, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema build is consistently integrated across testing, packaging, publishing, validation, and documentation paths.

Review effort: Balanced
Findings: None

What changed in this PR

Moves the published settings schema from tracked generated output to a build artifact while preserving it in packaged releases.

Changes:

  • Builds the schema before tests, fuzzing, packaging, and publishing.
  • Reads the schema at runtime in tests to keep fresh checkouts typecheckable.
  • Updates release validation, CI, documentation, and generated-file machinery.
File Description
.gitignore Ignores the built schema.
.github/​SECURITY.md Documents schema packaging guarantees.
.github/​scripts/​changed-sections.ts Updates the untracked lib/ rationale.
.github/​scripts/​gen-settings-schema.ts Creates lib/ before schema generation.
.github/​scripts/​generated.ts Removes the schema from committed outputs.
.github/​scripts/​package-smoke.ts Builds the schema before packing.
.github/​scripts/​release-pipeline.ts Requires schema in packaged commits.
.github/​workflows/​auto-fix.yml Removes schema drift auto-fixing.
.github/​workflows/​checks.yml Builds schema in relevant test jobs.
.github/​workflows/​nightly-fuzz.yml Builds schema before fuzzing.
.github/​workflows/​post-green.yml Includes schema in packaged builds.
.github/​workflows/​update-release-pr.yml Builds schema before prerelease publishing.
.github/​workflows/​update-release.yml Builds and publishes the schema artifact.
AGENTS.md Records the new build-artifact rule.
CONTRIBUTING.md Updates contributor commands and release details.
docs/​reference/​library.md Documents built schema distribution.
docs/​start/​examples.md Links to the packaged major-tag schema.
lefthook.yml Removes obsolete schema-freshness wording.
lib/​settings.schema.json Removes the generated schema from source control.
package.json Builds schema before tests and fuzzing.
release-please-config.json Enables major-tag updates in examples.
test/​docs/​library-examples.test.ts Reuses the shared schema path.
test/​docs/​readme.test.ts Reads the built schema at runtime.
test/​e2e/​fuzz.ts Routes replay commands through the build script.
test/​e2e/​generators.ts Loads the built schema lazily.
test/​package-json.test.ts Uses the runtime schema reader.
test/​published-schema.test.ts Uses the shared schema reader.
test/​schema-corpus.test.ts Compiles the runtime-loaded schema.
test/​scripts/​generated.test.ts Removes schema from tracked generated files.
test/​scripts/​release-pipeline-build.test.ts Updates packaged-tree assertions.
test/​scripts/​release-pipeline-fixture.ts Adds schema to package fixtures.
test/​scripts/​release-pipeline.test.ts Tests required packaged schema files.
test/​settings-schema.ts Adds the shared runtime schema reader.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 22, 2026 09:47
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

File size check

0 over a hard cap (fails), 32 warning(s).

File Size Tier Cap
.github/scripts/gen-inputs-table.ts:54 11 comment lines warn 10
.github/scripts/generated.ts:28 191 chars warn 150
.github/scripts/release-pipeline.ts:7 156 chars warn 150
.github/scripts/release-pipeline.ts:458 151 chars warn 150
.github/scripts/release-pipeline.ts:1252 153 chars warn 150
.github/scripts/release-pipeline.ts:1 35 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:454 14 comment lines warn 10
.github/workflows/post-green.yml:29 153 chars warn 150
.github/workflows/update-release-pr.yml:110 14 comment lines warn 10
docs/upgrading/v2-to-v3.md 1276 lines warn 1040
src/engine/layers.ts:217 157 chars warn 150
src/flows/settings-write.ts:142 159 chars warn 150
src/flows/settings-write.ts:30 11 comment lines warn 10
src/flows/snapshot.ts:189 13 comment lines warn 10
src/github/secret-scan.ts:43 11 comment lines warn 10
src/schema.ts:186 153 chars warn 150
src/schema.ts:197 176 chars warn 150
src/sections/contract/errors.ts:14 14 comment lines warn 10
src/sections/contract/module.ts:963 185 chars warn 150
src/sections/contract/module.ts:627 12 comment lines warn 10
src/sections/contract/module.ts:897 12 comment lines warn 10
src/sections/secret_scanning_custom_patterns/compilable-form.ts:382 161 chars warn 150
src/sections/shared/roles.ts:43 13 comment lines warn 10
src/types.ts:16 156 chars warn 150
test/docs/guides.test.ts:451 155 chars warn 150
test/e2e/generators.ts 2634 lines warn 2560
test/e2e/generators.ts:1704 166 chars warn 150
test/e2e/generators.ts:1858 161 chars warn 150
test/e2e/generators.ts:1667 12 comment lines warn 10
test/engine/execute.test.ts:617 152 chars warn 150
test/flows/merge-parity.test.ts:63 164 chars warn 150
test/scripts/auto-fix-allowlist.test.ts:12 12 comment lines warn 10

Split the file, wrap the line, shorten or exempt the comment, or list the path in .file-size-allow.local with a # reason.

5 managed file(s) skipped; repo-platform owns them.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The build, test, packaging, publishing, and documentation paths consistently implement the new generated-schema lifecycle.

Review effort: Balanced
Findings: None

Copilot AI review requested due to automatic review settings September 22, 2026 10:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The coordinated changes affect release topology, package publication, and multiple CI paths, warranting final human validation despite no concrete defect found.

Review effort: Balanced
Findings: None

Copilot AI review requested due to automatic review settings September 22, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema is consistently built and validated across testing, packaging, publishing, and release paths.

Review effort: Balanced
Findings: None

Copilot AI review requested due to automatic review settings September 22, 2026 10:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Schema generation and packaging paths are consistently updated and covered by focused tests.

Review effort: Balanced
Findings: None

Copilot AI review requested due to automatic review settings September 22, 2026 10:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The schema build lifecycle is consistently covered across testing, packaging, publishing, release validation, and documentation.

Review effort: Balanced
Findings: None

lib/settings.schema.json is untracked and gitignored beside lib/index.js and lib/pkg/, and every packaged commit off main now carries it as a required built file.
The test and fuzz scripts, the e2e-smoke job, the package smoke, and the packaging and publish jobs run build:schema before anything loads or packs the schema.
The drift machinery (the generated-output table row, the auto-fix schema branch, the schema-check job, the release hook's byte check) goes with the committed file.
The $schema hints and the $id are unchanged; the examples page links the schema at the moving major tag, which release-please now rewrites.
Copilot AI review requested due to automatic review settings September 23, 2026 01:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Repository instructions still recommend a fresh-checkout test command that now fails before generating the schema.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Low severity

Open (1)

Comment thread AGENTS.md
@Vivswan
Vivswan merged commit d413db5 into main Sep 23, 2026
30 checks passed
@Vivswan
Vivswan deleted the wt/schema-off-main branch September 23, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants