Skip to content

test: drop the vacuous USED_PATHS case and pin the gaps index by resolution, not by text - #417

Merged
Vivswan merged 1 commit into
mainfrom
wt/test-hygiene-openapi
Sep 22, 2026
Merged

Vivswan merged 1 commit into
mainfrom
wt/test-hygiene-openapi

Conversation

@Vivswan

@Vivswan Vivswan commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Before / After

Before:

  • test/e2e/openapi/validate.test.ts had a case asserting the validator's path list equals USED_PATHS. trimDescriptor() builds that list by iterating USED_PATHS, so the assertion compared the function's output with its own input.
  • test/scripts/graduate-upstream-gaps.test.ts pinned generateIndex() by its text: the import lines, the GAPS literal, and template equality between an empty and a two-gap render.

After:

  • The USED_PATHS case is gone, with the paths() accessor on OpenApiValidator that existed for it alone. The test.each beside it still pins the missing-path and now-documented arms by message.
  • generateIndex is pinned at the boundary its output crosses: the index generated for the real src/upstream-gaps/ type-checks beside copies of its gap files, loads (so every import resolves), and every UNSHIPPED_GRAPHQL_SDL entry names a gap file that exists. The empty directory runs the same row.

How

  • Each row builds a src/ mirror in a temp dir: every sibling of upstream-gaps/ is symlinked (a gap may import ../types.js), the gap files are copied beside the generated index. withTempDir removes it on every path.
  • The empty row keeps its own reason: the committed index compiles under the project typecheck only while a gap file exists.
  • The GAPS key, not the import, is what names a gap file downstream: unshippedGraphqlSdl() renders it as the file to retire. That is why the row loads the index instead of matching its text.

Proof

Mutants, with the deleted or replaced cases gone:

Mutant Result
trimDescriptor copy loop skips a used path (usedPaths.slice(1)) the $ref sibling fails: it pins the kept slice's keys
a used path missing from the descriptor trimDescriptor throws at load; the test.each pins the message. The deleted case only failed as collateral of that throw
gapEntry emits the camelCase alias as the key for every base compiles; the real-directory row fails on src/upstream-gaps/issueCreationPolicy.ts, a file that does not exist
gapEntry emits a hyphenated key unquoted the real-directory row fails at the tsc assertion (TS1005)

Green after: bun test test/e2e/openapi test/scripts/graduate-upstream-gaps.test.ts, typecheck, knip, lint, build:check.

Line accounting

File + -
test/e2e/openapi/validate.test.ts 1 7
test/e2e/openapi/validate.ts 0 5
test/scripts/graduate-upstream-gaps.test.ts 65 48
total 66 60

Reviewer note

  • The paths() removal is a consequence of the deleted case, not a separate change: its docstring named that case as its consumer, and nothing else called it.
  • The real-directory row repeats what the project typecheck of the committed index proves, inside this test file, so the text pins could go without losing the key-names-the-file contract; the key-to-value wiring is not pinned (both sides come from one camelCaseGapName call).
  • Gates: codex rubber-duck review, 2 rounds, converged with no findings.
  • The SDL-entry check is non-vacuous while issue-creation-policy.ts (graphql-schema) exists; after it graduates the row still pins compile + load.

BEGIN_COMMIT_OVERRIDE
test: drop the vacuous USED_PATHS case and pin the gaps index by resolution, not by text

The "contains exactly the USED_PATHS paths" case compared trimDescriptor output with its own input, and the $ref sibling already pins the kept slice keys, so it goes, with the paths() accessor that existed for it alone.
The generateIndex shape test pinned the emitted import lines and the GAPS literal; instead the index generated for the real gap directory is loaded beside copies of its files and every UNSHIPPED_GRAPHQL_SDL entry must name one of them.
The empty-index tsc case becomes a test.each row beside that real-directory row, so a hyphenated base emitted as an unquoted key fails to compile and a camelCase key names a file that does not exist.
END_COMMIT_OVERRIDE

…lution, not by text

The "contains exactly the USED_PATHS paths" case compared trimDescriptor output with its own input, and the $ref sibling already pins the kept slice keys, so it goes, with the paths() accessor that existed for it alone.
The generateIndex shape test pinned the emitted import lines and the GAPS literal; instead the index generated for the real gap directory is loaded beside copies of its files and every UNSHIPPED_GRAPHQL_SDL entry must name one of them.
The empty-index tsc case becomes a test.each row beside that real-directory row, so a hyphenated base emitted as an unquoted key fails to compile and a camelCase key names a file that does not exist.
@Vivswan Vivswan added the merge-when-green Owner approved: merge once every gate is green label Sep 22, 2026
Copilot AI balanced review requested due to automatic review settings September 22, 2026 10:00
@Vivswan Vivswan added the merge-when-green Owner approved: merge once every gate is green label Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

File size check

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

File Size Tier Cap
.github/scripts/release-pipeline.ts:6 156 chars warn 150
.github/scripts/release-pipeline.ts:453 151 chars warn 150
.github/scripts/release-pipeline.ts:1247 153 chars warn 150
.github/scripts/release-pipeline.ts:1 34 comment lines (header) warn 25
.github/scripts/release-pipeline.ts:449 14 comment lines warn 10
.github/workflows/post-green.yml:29 153 chars warn 150
.github/workflows/update-release-pr.yml:109 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:42 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 2633 lines warn 2560
test/e2e/generators.ts:1703 166 chars warn 150
test/e2e/generators.ts:1857 161 chars warn 150
test/e2e/generators.ts:1666 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:8 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

🟡 Changes recommended

The new semantic assertion can pass when a generated index silently omits a GraphQL gap.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates tests to validate generated gap indexes by behavior rather than emitted text and removes a redundant OpenAPI assertion.

Changes:

  • Removes the self-referential USED_PATHS test and unused accessor.
  • Type-checks and loads generated indexes in temporary source mirrors.
  • Validates generated GraphQL gap file references.
File Description
test/​e2e/​openapi/​validate.test.ts Removes the redundant path-list assertion.
test/​e2e/​openapi/​validate.ts Removes the test-only paths() accessor.
test/​scripts/​graduate-upstream-gaps.test.ts Replaces textual index assertions with compile/load checks.

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

Comment thread test/scripts/graduate-upstream-gaps.test.ts
@Vivswan
Vivswan merged commit eca20fa into main Sep 22, 2026
38 checks passed
@Vivswan
Vivswan deleted the wt/test-hygiene-openapi branch September 22, 2026 10:14
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