Skip to content

test: name the schema build step before tsc runs and register a helper's kind argument as data - #456

Merged
Vivswan merged 1 commit into
mainfrom
test/infra-prerequisites
Oct 5, 2026
Merged

Vivswan merged 1 commit into
mainfrom
test/infra-prerequisites

Conversation

@Vivswan

@Vivswan Vivswan commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Before

Clean checkout, bun test test/docs/library-examples.test.ts:

error: expect(received).toEqual(expected)
- []
+ [
+   "docs/reference/library.md:117: TS2307: Cannot find module '.../lib/settings.schema.json' or its corresponding type declarations.",
+ ]
(fail) docs/reference/library.md examples > every ts fence compiles, in page order, against src/index.ts [976.12ms]
 3 pass
 1 fail

Scanner: knobbedList(entry, "knobbed", shape) in a helper reported "knobbed" as an unpinned message.

After

Same checkout, lib/ absent:

error: lib/settings.schema.json is not built; run `bun run build:schema`
(fail) docs/reference/library.md examples > every ts fence compiles, in page order, against src/index.ts [0.87ms]
 4 pass
 1 fail

After bun run build:schema: 5 pass. Scanner: the planted call is silent, the message beside it still reports.

How

  • Fail closed: the generator only writes into the tree, so compileExamples checks the file before tsc, only when a fence imports the schema path.
  • One mint: schemaNotBuilt() in test/settings-schema.ts, which readSettingsSchema() already used.
  • Registry, not a resolver: DATA_ARGUMENTS names the kind parameter of wrappedList and knobbedList, and takes commitMessageFamily's key names and githubName's noun from PIECE_ARGUMENTS.
  • Census: every-literal 261 to 255, six key-name and noun literals pinned by accident. Message positions unchanged at 88.

Proof

  • tsc -p ., biome check, knip: clean.
  • Both test files: 14 pass, two new rows.
  • Clean-checkout control: mv lib lib.bak, run, restore. Output above.
  • Codex rubber-duck on the registry form: converged, no findings.
Technical details

Line accounting (git diff --numstat origin/main...HEAD): +116 / -48

File + - Kind
test/docs/library-examples.test.ts 63 8 schema-path parameter, import detection, fail-closed guard, one test row
test/sections/refusal-messages.test.ts 42 38 four registry entries, docstring and header row, one planted row, shifted expectations
test/settings-schema.ts 11 2 shared schemaNotBuilt() mint

The six dropped literals: commitMessageFamily("squash_merge_commit_title", "squash_merge_commit_message"), commitMessageFamily("merge_commit_title", "merge_commit_message"), githubName("secret"), githubName("variable"). A key or noun that renders inside a message is data: a containment pin on it holds wherever a test spells the key.

The earlier form of this PR carried a typed-parameter resolver (read the callee's parameter type to decide message or vocabulary). The lead gate blocked it on size: 114 lines for the same 255 / 88 census, and a guarantee resting on partial type interpretation. Deleted in favour of the audited registry.

Recorded, not built:

  • importsModule misses an import with an inline comment between from and the path, and accepts an import "..." inside a template literal. The page has neither.
  • Single-quoted import spellings stay unrewritten (pre-existing).

Files: test/settings-schema.ts, test/docs/library-examples.test.ts, test/sections/refusal-messages.test.ts

Copilot AI balanced review requested due to automatic review settings October 5, 2026 04:54
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

File size check

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

File Size Tier Cap
.github/actions/setup/action.yml:7 169 chars warn 150
.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:456 151 chars warn 150
.github/scripts/release-pipeline.ts:1250 153 chars warn 150
.github/scripts/release-pipeline.ts:1 33 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:452 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:75 157 chars warn 150
src/engine/layers.ts:95 167 chars warn 150
src/flows/settings-write.ts:137 159 chars warn 150
src/github/api-error.ts:104 159 chars warn 150
src/github/secret-scan.ts:45 11 comment lines warn 10
src/schema.ts:188 153 chars warn 150
src/schema.ts:199 176 chars warn 150
src/sections/contract/errors.ts:13 14 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/sections/shared/schema-helpers.ts:15 153 chars warn 150
src/types.ts:16 156 chars warn 150
test/docs/guides.test.ts:451 155 chars warn 150
test/docs/nightly-workflows.test.ts:206 160 chars warn 150
test/e2e/constants.ts:9 197 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
test/sections/refusal-messages.test.ts:61 19 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 focused test-infrastructure changes are internally consistent and cover the reported regressions.

Review effort: Balanced
Findings: None

What changed in this PR

Improves test diagnostics for missing generated schemas and prevents vocabulary literals from being mistaken for refusal messages.

Changes:

  • Adds a shared missing-schema error helper.
  • Detects schema imports before compiling documentation examples.
  • Classifies literals using local function parameter types.
File Description
test/​settings-schema.ts Centralizes missing-schema errors.
test/​docs/​library-examples.test.ts Adds schema preflight detection and coverage.
test/​sections/​refusal-messages.test.ts Adds typed-parameter vocabulary classification and controls.

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

…r's kind argument as data

The library-examples test rewrote the page's schema subpath import to lib/settings.schema.json, a built and ignored artifact, so a clean checkout failed with TS2307 against the page line, which reads as a docs defect. The generator only writes into the tree, so the test cannot build the schema elsewhere; compileExamples now checks, before tsc and only when the program imports the schema path, that the file exists, and rejects with the one line readSettingsSchema already uses: lib/settings.schema.json is not built; run bun run build:schema. The line is minted once in test/settings-schema.ts. Every other test reads the schema through readSettingsSchema and already failed closed.

The refusal-messages scanner read a bare string argument of a local helper in a schema slice or shared helper as a message unless the DATA_ARGUMENTS registry named the position, so a kind tag such as "knobbed" passed to the minting helpers needed a line-end pin, and the kinds were carried in a table to avoid it. The registry now names the kind parameter of wrappedList and knobbedList, and takes over commitMessageFamily's two key names and githubName's noun from PIECE_ARGUMENTS, where their containment pins held wherever any test spelled the key or the word. The real census drops those six key-name and noun literals and nothing else. One planted row holds the control: knobbedList(entry, "knobbed", shape) reports "knobbed" on main and is silent here.
@Vivswan
Vivswan force-pushed the test/infra-prerequisites branch from 9314ba1 to d68afbc Compare October 5, 2026 05:15
Copilot AI balanced review requested due to automatic review settings October 5, 2026 05:15
@Vivswan Vivswan changed the title test: name the schema build step before tsc runs and read a helper's typed parameter as vocabulary test: name the schema build step before tsc runs and register a helper's kind argument as data Oct 5, 2026

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 changes are focused, internally consistent, and covered by targeted tests.

Review effort: Balanced
Findings: None

@Vivswan
Vivswan marked this pull request as ready for review October 5, 2026 05:43
@Vivswan Vivswan added the merge-when-green Owner approved: merge once every gate is green label Oct 5, 2026
@Vivswan
Vivswan merged commit 238d812 into main Oct 5, 2026
31 checks passed
@Vivswan
Vivswan deleted the test/infra-prerequisites branch October 5, 2026 05:55
Vivswan added a commit that referenced this pull request Oct 5, 2026
The library-examples test gained, in #456, an existsSync check before tsc ran: when a fence imported the package's settings.schema.json subpath and lib/settings.schema.json was absent, compileExamples rejected with a line naming bun run build:schema, through a textual import scan (importsModule) and a shared mint (schemaNotBuilt) in test/settings-schema.ts.

The owner's rule: do not write a check or guard for something that fails on its own. A missing build output, a missing package, a wrong toolchain surface as failures when they happen and are fixed then; a pre-check that restates a failure the tool already produces is deleted. tsc's own TS2307 against the page line is that failure, so both files return to their content before #456. The refusal-messages registry rows and planted row from #456 stay.

The same rule removes two more pre-checks of the same class: readSettingsSchema's own existsSync check and not-built message (readFileSync's ENOENT names the path) and refusalSources' existsSync check and census message (read() raises the same ENOENT, and the gone-source control asserts it). Every other existsSync under test/ and .github/scripts/ chooses a path, skips an optional input, or is the test's own assertion, and stays.
Vivswan added a commit that referenced this pull request Oct 5, 2026
The library-examples test gained, in #456, an existsSync check before tsc ran: when a fence imported the package's settings.schema.json subpath and lib/settings.schema.json was absent, compileExamples rejected with a line naming bun run build:schema, through a textual import scan (importsModule) and a shared mint (schemaNotBuilt) in test/settings-schema.ts.

The owner's rule: do not write a check or guard for something that fails on its own. A missing build output, a missing package, a wrong toolchain surface as failures when they happen and are fixed then; a pre-check that restates a failure the tool already produces is deleted. tsc's own TS2307 against the page line is that failure, so both files return to their content before #456. The refusal-messages registry rows and planted row from #456 stay.

The same rule removes two more pre-checks of the same class: readSettingsSchema's own existsSync check and not-built message (readFileSync's ENOENT names the path) and refusalSources' existsSync check and census message (read() raises the same ENOENT, and the gone-source control asserts it). Every other existsSync under test/ and .github/scripts/ chooses a path, skips an optional input, or is the test's own assertion, and stays.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-when-green Owner approved: merge once every gate is green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants