Skip to content

test(packages): enforce strict TSRX source consumers - #733

Merged
trueadm merged 10 commits into
octanejs:mainfrom
jonkwheeler:jon/strict-tsrx-consumer-validation
Aug 12, 2026
Merged

trueadm merged 10 commits into
octanejs:mainfrom
jonkwheeler:jon/strict-tsrx-consumer-validation

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • discover every published framework binding that ships authored .tsrx instead of maintaining a package allowlist
  • install the complete packed workspace dependency closure and required external peers
  • compile installed .tsrx implementation files with strict tsrx-tsc under Node and browser/no-Node configurations
  • fix strict source typing in Jotai, Redux, Redux Toolkit, and Lucide
  • include the Recharts declaration corrections from fix(recharts): expose strict consumer types #730
  • fail closed when an enrolled binding has no importable public entry

This is the external packed-consumer guardrail portion of #721. Repository-side source typechecking remains in #732, and browser-safe process.env.NODE_ENV references remain in #734. Includes and supersedes #730.

Known residuals

  • @octanejs/visx is explicitly deferred while its React SVG/event prop types are migrated to Octane-native types.
  • @octanejs/livestore is explicitly deferred because LiveStore 0.4 declarations require the exact Effect peer graph captured by the workspace lockfile.
  • @octanejs/recharts source compilation is explicitly deferred until tsrx-tsc resolves extensionless imports to sibling .tsrx modules. Its declaration surface remains covered here.

All exceptions are named and logged; every other current and future published TSRX binding enrolls automatically.

Testing

  • node --test scripts/package-pack-canaries.test.mjs (20 tests passed)
  • tsrx-tsc --noEmit -p packages/jotai/tsconfig.json
  • tsrx-tsc --noEmit -p packages/redux/tsconfig.json
  • tsrx-tsc --noEmit -p packages/redux-toolkit/tsconfig.json
  • tsrx-tsc --noEmit -p packages/shadcn/tsconfig.json
  • Prettier check and git diff --check passed
  • Full package packing completed locally; the isolated dependency install did not finish in the restricted local environment, so CI remains the authoritative end-to-end packed-consumer run

Review

Compound Engineering review completed. All actionable findings were applied.

Post-Deploy Monitoring & Validation

No additional runtime monitoring is required because this changes compile-time package validation only. Watch the package-pack CI job and first main build after merge. Both strict compiler lanes passing is healthy; an enrolled-package diagnostic or missing-entry error is a mitigation trigger.


Note

Medium Risk
Touches published package.json export/types for Recharts and broad CI pack validation; impact is compile-time and packaging contracts rather than runtime behavior, but failures block releases until exceptions are resolved.

Overview
Adds automatic strict packed-consumer validation for every published framework binding that ships .tsrx, replacing a fixed package list with discovery from tarballs and export maps. The external consumer now installs the full packed workspace closure plus promoted external peers, typechecks installed implementation .tsrx under strict tsrx-tsc in Node and browser (no @types/node) projects, and fails when a enrolled binding has no importable public entry. Known gaps stay on an explicit exception map with logged warnings (including deferred Recharts source compilation).

Binding and typing fixes so more packages pass or expose a stable public surface: explicit props/types on Jotai Provider, Redux Provider, and RTK Query ApiProvider; Lucide root /// <reference for icon ambient types; Recharts routes types/exports.types to index.d.ts (runtime still src/index.ts) and expands that declaration file (components, hooks, TooltipFormatter, unsupported exports probed via @ts-expect-error). Canary probes and unit tests cover discovery, closure resolution, dual tsconfigs, and Recharts type assertions.

Reviewed by Cursor Bugbot for commit 7332c91. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added the test PR: tests only label Aug 12, 2026
Comment thread scripts/check-package-packs.mjs Resolved
dudusotero added a commit to dudusotero/octane that referenced this pull request Aug 12, 2026
octanejs#733 rebuilds the packed TSRX consumer canary around automatic discovery
of every binding that ships .tsrx, which is a better answer than the
package list this branch was extending. Drop the overlapping edits to
package-pack-canaries.mjs, check-package-packs.mjs and their test so the
two branches stop touching the same files.

What remains here is the part octanejs#733 does not cover: the root typecheck
chain still runs tsgo over packages that ship .tsrx, so those files are
absent from the program CI actually runs.
@dudusotero

Copy link
Copy Markdown
Contributor

I had two PRs in flight on the same problem and have rescoped both so neither touches a file this one does: #732 (repository-side typecheck) and #734 (remix-router plus process references). The auto-discovery here is a better answer than the package list #732 was extending, so I reverted that part.

Two gaps I ran into while measuring the same surface, both possibly relevant to "Closes #721".

The repository's own typecheck chain still runs tsgo. This PR does not modify package.json, so after it merges pnpm typecheck still runs tsgo --noEmit -p packages/{jotai,redux,visx,recharts}/tsconfig.json. tsgo has no tsrx plugin, so those .tsrx files are not in the program at all:

pnpm exec tsgo     --noEmit -p packages/jotai/tsconfig.json   # exit 0
pnpm exec tsrx-tsc --noEmit -p packages/jotai/tsconfig.json   # 2 errors, same tsconfig

The packed canary catches this from outside once a package is enrolled, but a contributor editing a binding in-repo still gets a green local typecheck over source that was never parsed. That is what #732 covers, and it is why I do not think the two overlap.

The process.env.NODE_ENV references are in .ts modules, not .tsrx. The browser lane's include is ['src/**/*.ts', 'src/**/*.tsrx', 'node_modules/@octanejs/**/*.tsrx'], so under node_modules only .tsrx is compiled directly. The bare process references live in:

packages/jotai/src/react/useAtomValue.ts:156
packages/jotai/src/react/useSetAtom.ts:31
packages/jotai/src/react/utils.ts:63
packages/redux/src/hooks.ts (3 sites)
packages/remix-router/src/lib/router/utils.ts:14

None of those files is modified here, and they still reference the bare global on main. Either the browser lane does not reach them, in which case gap C survives for enrolled packages, or it does reach them through the import graph and the lane should currently be red. Worth confirming which, since it decides whether jotai and redux are actually clean under the no-@types/node config.

#734 fixes those five with a module-local declare const process rather than a globalThis read, because define substitution matches the literal process.env.NODE_ENV text and the dead-code elimination that follows depends on it.

One note on the recharts work absorbed from #730, since you are now carrying it: 177 extensionless relative imports in packages/recharts/src resolve only to a sibling .tsrx, and tsrx-tsc does not resolve those (147 TS2307, of which 133 are this). recharts is the only package in the repo that does it, every other binding writes the extension. Routing types at index.d.ts hides it from consumers, but packages/octane/src/compiler/vite.js deliberately supports extensionless .tsrx at bundle time, so the type layer and the bundler still disagree.

- install the complete packed workspace dependency closure
- allow pnpm to install required external peers
- defer Recharts source compilation until tsrx-tsc resolves extensionless TSRX imports
@jonkwheeler

Copy link
Copy Markdown
Contributor Author

Two gaps I ran into while measuring the same surface, both possibly relevant to "Closes #721".

Thanks — agreed on the scope split. I removed the closing claim and now describe #733 as the external packed-consumer portion of #721, with #732 owning repository-side tsrx-tsc coverage and #734 owning the browser-safe process.env.NODE_ENV references.

The no-Node lane reaches imported .ts modules through the public entry graph, but the direct node_modules include only guarantees authored .tsrx coverage; #734 is therefore still required for those five bare-global sites.

I also confirmed the Recharts extensionless imports make direct source compilation fail independently of its declaration surface. Commit 1a11753 adds an explicit Recharts debt exception with that exact reason, so this PR no longer implies the source graph passes. The declaration consumer probe remains active.

@cursor cursor Bot 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 1a11753. Configure here.

Comment thread scripts/check-package-packs.mjs Resolved
@trueadm
trueadm merged commit 0b7460e into octanejs:main Aug 12, 2026
3 of 21 checks passed
@jonkwheeler
jonkwheeler deleted the jon/strict-tsrx-consumer-validation branch August 12, 2026 19:41
trueadm pushed a commit that referenced this pull request Aug 12, 2026
…734)

* fix: validate published TSRX source with a consumer-shaped typecheck

Packages that ship .tsrx were typechecked by tsgo, which drops those
files from the program entirely. Their published source was therefore
never checked at all. Bindings publish raw source and point exports at
it, so every one of those errors is visible to a consumer.

- Generate canonical consumer projects from the same tsconfig the CLI
  scaffolds, with a drift check, so what is validated cannot diverge
  from what users actually compile against.
- Move the .tsrx-publishing projects that already pass onto tsrx-tsc.
- Add a no-@types/node lane to the packed-tarball canary. The existing
  lane sets types: ["node"], so it cannot see `process` references in
  published source, which a browser app does not resolve.
- Add a guardrail over source-published packages with an enumerated
  allowlist of the remaining violations. A stale entry fails the check,
  so the list can only shrink.

* refactor: cede packed-canary changes to #733

#733 rebuilds the packed TSRX consumer canary around automatic discovery
of every binding that ships .tsrx, which is a better answer than the
package list this branch was extending. Drop the overlapping edits to
package-pack-canaries.mjs, check-package-packs.mjs and their test so the
two branches stop touching the same files.

What remains here is the part #733 does not cover: the root typecheck
chain still runs tsgo over packages that ship .tsrx, so those files are
absent from the program CI actually runs.

* fix(bindings): fix published source a browser app cannot type-check

These packages ship raw source and point exports at it, so a consumer's
program compiles every reachable module. The repo checked them with tsgo,
which drops .tsrx from the program, so none of this was visible in CI
while all of it was visible to consumers.

- Declare `process` module-locally at every published
  `process.env.NODE_ENV` reference. A browser app has no @types/node. The
  expression stays written out literally so bundler define substitution
  and the dead-code elimination after it are unaffected, and nothing
  ambient ships in the tarball.
- Let Form and Link accept a null forwarded ref: the compiler composes it
  as ref={[ref, spread.ref]}, and Ref<T> array members cannot be undefined.
- Carry the same process deviation into the remix-router vendoring script,
  so a re-vendor does not reintroduce the error.

The Provider prop typings for jotai and redux are left to #733, which
edits the same two files.

* fix: widen the source-publication gate past the typecheck chain

Two defects Cursor Bugbot found on this PR, both confirmed.

The nodeTypes and excluded rules only saw projects discovered by parsing
inline compiler invocations out of the root typecheck chain. A package
validated through a package script, a node wrapper, or absent from the
chain never entered the loop, so the gate stayed green while missing the
defect it claims to block. They now walk each source-published package's
own tsconfigs; the tsgo rule still follows the chain, since that rule
genuinely is a claim about what the chain runs.

The excluded rule matched an exclude entry only when it named a shipped
file exactly, so `src`, `src/**` or `src/**/*.tsrx` could drop packed
source without tripping it. Exclude entries are now translated into path
predicates following tsc's own wildcard shape.

The allowlist grows from 100 to 112. All twelve additions are
node-types-in-validation-tsconfig entries that chain-only discovery could
not see, including the four Bugbot named. The previous number was not the
real debt, only the part the gate could reach.

* fix: stop the spec matcher spanning directories on a wildcard segment

Third Bugbot finding, confirmed. The trailing `($|/)` was appended to every
pattern, so a wildcard final segment behaved like a directory prefix:
`src/*` matched `src/a/b/deep.ts` and `*` matched `src/a/b.ts`, where tsc's
`*` and `?` do not cross `/`.

Only a literal final segment, or `**` whose `.*` already spans, keeps the
directory suffix now. Totals are unchanged at 112; no current entry depended
on the over-match.
trueadm pushed a commit that referenced this pull request Aug 13, 2026
…732)

* fix: validate published TSRX source with a consumer-shaped typecheck

Packages that ship .tsrx were typechecked by tsgo, which drops those
files from the program entirely. Their published source was therefore
never checked at all. Bindings publish raw source and point exports at
it, so every one of those errors is visible to a consumer.

- Generate canonical consumer projects from the same tsconfig the CLI
  scaffolds, with a drift check, so what is validated cannot diverge
  from what users actually compile against.
- Move the .tsrx-publishing projects that already pass onto tsrx-tsc.
- Add a no-@types/node lane to the packed-tarball canary. The existing
  lane sets types: ["node"], so it cannot see `process` references in
  published source, which a browser app does not resolve.
- Add a guardrail over source-published packages with an enumerated
  allowlist of the remaining violations. A stale entry fails the check,
  so the list can only shrink.

* refactor: cede packed-canary changes to #733

#733 rebuilds the packed TSRX consumer canary around automatic discovery
of every binding that ships .tsrx, which is a better answer than the
package list this branch was extending. Drop the overlapping edits to
package-pack-canaries.mjs, check-package-packs.mjs and their test so the
two branches stop touching the same files.

What remains here is the part #733 does not cover: the root typecheck
chain still runs tsgo over packages that ship .tsrx, so those files are
absent from the program CI actually runs.

* fix: widen the source-publication gate past the typecheck chain

Two defects Cursor Bugbot found on this PR, both confirmed.

The nodeTypes and excluded rules only saw projects discovered by parsing
inline compiler invocations out of the root typecheck chain. A package
validated through a package script, a node wrapper, or absent from the
chain never entered the loop, so the gate stayed green while missing the
defect it claims to block. They now walk each source-published package's
own tsconfigs; the tsgo rule still follows the chain, since that rule
genuinely is a claim about what the chain runs.

The excluded rule matched an exclude entry only when it named a shipped
file exactly, so `src`, `src/**` or `src/**/*.tsrx` could drop packed
source without tripping it. Exclude entries are now translated into path
predicates following tsc's own wildcard shape.

The allowlist grows from 100 to 112. All twelve additions are
node-types-in-validation-tsconfig entries that chain-only discovery could
not see, including the four Bugbot named. The previous number was not the
real debt, only the part the gate could reach.

* fix: stop the spec matcher spanning directories on a wildcard segment

Third Bugbot finding, confirmed. The trailing `($|/)` was appended to every
pattern, so a wildcard final segment behaved like a directory prefix:
`src/*` matched `src/a/b/deep.ts` and `*` matched `src/a/b.ts`, where tsc's
`*` and `?` do not cross `/`.

Only a literal final segment, or `**` whose `.*` already spans, keeps the
directory suffix now. Totals are unchanged at 112; no current entry depended
on the over-match.

* fix: deny the consumer projects the Node globals a browser app lacks

Fourth Bugbot finding, confirmed. The generated projects omitted `types` to
mirror `octane init`, but the two omissions mean opposite things. A freshly
scaffolded app has no `@types/*` installed at all; these projects run inside
the monorepo, where an omitted `types` makes TypeScript auto-include every
installed one. Published source was being handed the Node globals it must
not see, which is the exact gap these projects exist to catch.

Proved before and after with a probe compiled under the base config inside
the repo: `process.env.NODE_ENV` resolved cleanly, and now reports TS2591.

The packed-tarball consumer already pins `types` empty for the same reason,
so this makes the in-repo projects agree with it.
@leonidaz leonidaz mentioned this pull request Aug 13, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test PR: tests only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants