Skip to content

fix: include existing PCB records in PcbCircuitElement - #950

Draft
1932819331hy-debug wants to merge 1 commit into
tscircuit:mainfrom
1932819331hy-debug:fix/pcb-union-completeness
Draft

1932819331hy-debug wants to merge 1 commit into
tscircuit:mainfrom
1932819331hy-debug:fix/pcb-union-completeness

Conversation

@1932819331hy-debug

@1932819331hy-debug 1932819331hy-debug commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

 PcbCircuitElement
+ PcbGroup
+ PCBKeepout
+ PcbFabricationNotePath
+ PcbFabricationNoteText
+ PcbCourtyardOverlapError

These existing PCB schemas are already exported and registered in the general circuit-element union, but their parsed records cannot be assigned to PcbCircuitElement. Add the missing type imports/members, following the same kind of correction as #447. No runtime schema changes.

Historical evidence

  • Seven valid records (including all three keepout shapes) produce 14 PCB-union assignment/discriminator diagnostics on the base; those specific diagnostics disappear with this patch.
  • Related native Bun tests: 11 passed, 0 failed, 41 assertions. Runtime checks pass before and after because this is a type-only fix.
  • Independent local review reproduced 14-to-0 target diagnostics, removed each added member to restore the expected errors, checked narrowing/non-any behavior and five negative controls, and confirmed identical transpiled PCB-barrel JavaScript.
  • Historical limitation: after materializing the remaining exact-source barrels, the focused compiler invocation still exits 2 because ts-expect is unavailable locally. No stub or replacement declaration was used. This is NOT a full typecheck pass.
  • Additional type-surface audit checked 166 exported PCB record types and 108 schema outputs: all concrete outputs fit the corrected union; the incomplete abstract base shapes remain excluded. No additional production changes were needed.
  • Local verification used Bun 1.4.4, lock-matching Zod 3.25.76 and format-si-unit 0.0.7, and TypeScript 5.9.3 rather than lock 5.8.3. At that point full locked typecheck, full suite, build, lint and hosted CI were unverified.

Only the PCB type barrel and the regression test are changed; no local config, dependency or evidence artifacts are included.

Locked native follow-up (2026-11-16)

The exact unchanged head was restored in a complete checkout and installed with bun install --frozen-lockfile. The original lockfile remained unchanged; TypeScript 5.8.3 and real ts-expect 1.3.0 now match the locked environment. No stubs, source changes or relaxed compiler settings were used.

  • Full original project tsc --noEmit: exit 0.
  • Default native bun test: 516 pass, 0 fail, 2,827 assertions, 1 snapshot, across 197 files. No timeout override or adapted tests.
  • Exact parent plus the same regression test: precisely 14 target compiler errors; runtime tests also pass 516/516, as expected for a type-only repair.
  • Zod lint, snake-case check and real ESM/DTS build pass. Candidate/parent JavaScript outputs are byte-identical; declarations reflect the union correction.
  • Source formatting still fails in four unchanged, parent-identical files: src/pcb/properties/pcb_pin1_location.ts, tests/pcb_board_flex_material.test.ts, tests/pcb_packing_error.test.ts and tests/pcb_pin1_location.test.ts. No unrelated formatting cleanup.
  • An actual six-file npm tarball imports by normal package name; its declarations compile a downstream consumer and its runtime parses seven records covering the five added members, including three keepout shapes. This uses real shared installed dependencies, not a separate clean consumer installation.

The first nested-script invocation could not find Bun on PATH (exit 127); a command-local PATH prefix fixed that. The initial downstream compiler invocation from the outer evidence directory could not resolve Node types; the unchanged consumer compiled from its own directory. Those failed attempts remain recorded, not silently counted as passes.

An independent follow-up verified the exact source/lock state and installed direct versions, reproduced the candidate full compiler pass and the parent's 14 target diagnostics, lint/build and freshly extracted package type/runtime consumers. The rebuilt outputs matched the tarball byte-for-byte. It audited the recorded complete 516-test logs and independently reran the targeted schema regression, rather than claiming a second complete 516-test execution. The four parent-identical formatting failures were independently reproduced.

These results close the earlier local compiler/dependency and native-build gaps, but do not claim hosted approval, all-format-green or Ready. The original type-design review was not repeated.

Merge Danger

Door: Two-way; no migration.

Blast Radius: Type consumers. The union now accepts these already-existing PCB records; downstream exhaustive switches may need to handle them. Runtime parsing is unchanged.

AI-assisted implementation and independent AI-assisted local review.

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.

1 participant