Skip to content

fix(codemod): preserve retained React registry factories - #3052

Merged
domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/codemod-retained-registry-types
Nov 18, 2026
Merged

domgan-oai merged 5 commits into
octanejs:mainfrom
openai-oss-forks:fix/codemod-retained-registry-types

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A selected registration module could rewrite React's createElement to Octane even though an unchanged React registry later renders its callback result. Preserve the original named factory for a proven retained React registry, including mixed modules that also compile a native component. Refuse writes when the source-backed boundary is unresolved, the factory has other uses, or registrations are ambiguous.

Fixes #2776.

Validation

  • perf-review: not applicable (codemod-only diff).
  • concise-code: src +104 −16 (runtime +0 −0); new files and exports: patch changeset and RETAINED_REGISTRY_BOUNDARY, consumed by the write guard; alternatives: blanket React factory preservation (~5 lines) rejected because it changes unrelated native migrations and hides ambiguous ownership; bytes: not applicable.
  • pnpm format:check
  • pnpm typecheck
  • pnpm test
  • targeted tests: 13 retained-registry controls passed, including exact/mixed modules, missing React declarations, ambiguous registrations, and unchanged files on blocked writes.
  • Codemod TypeScript build and changed-file Prettier check passed. After integrating the live base, eight focused registry and retained-workspace-hook write controls passed with both blockers retained.
  • pnpm sync completed with no tracked changes.

Risk / follow-ups

The proof intentionally supports a bounded named-factory registration shape. Unproved or ambiguous ownership remains an explicit migration boundary.

Provenance

  • An agent produced this diff (agent-authored)

Originating task: Codex task, host com-79386.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Codemod-only change, but it alters which files rewrite vs stay unchanged and introduces a new write-blocking error path that may surprise existing migration runs.

Overview
The codemod now keeps React createElement in registration modules only when it can prove the import is used solely inside a typed callback handed to a relative React registry, including mixed files that also export a native component or harmless primitive exports.

When that boundary cannot be proved—missing or weak ReactNode typing, extra registrations or unrelated code, more than one use of the factory, or ambiguous modules—it reports a new retained-registry-boundary error and refuses to write, leaving the source unchanged. Cases that previously still rewrote createElement to Octane (for example a second factory or a mixed React/Octane module) now surface that error instead.

project.ts treats this rule like other hard migration blockers, and tests cover the allow vs block matrix (mixed modules, ES2022, missing React types, duplicate registrations).

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

@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Nov 18, 2026
@trueadm
trueadm marked this pull request as ready for review November 18, 2026 20:53
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark report

🟢 No byte growth, no added work, and no timing changes beyond ±3%.

Compares 22d39dbf0, the merge commit's first parent with eaf55200e on the same runner. Any increase in a js-framework work counter fails this check; byte changes are a report. Wall time is a report: base and head samples alternate in one browser, and an operation is called slower or faster only when the 95% confidence interval of its ratio excludes ±3%. Workflow run

js-framework: 1k/10k row operations

target operation base ms head ms head/base 95% CI
octane-tsrx select_lots 0.009 0.009 −7.0% −15.9% … −3.1% 🟢 faster
All 20 timed operations (19 without a verdict)
target operation base ms head ms head/base 95% CI
octane-tsrx run 3.325 3.750 +1.6% −4.2% … +5.3% ⚪ within noise
octane-tsrx replace 10.258 9.650 +2.2% −8.6% … +6.7% ⚪ within noise
octane-tsrx add 3.733 3.508 −4.4% −7.2% … −0.0% ⚪ within noise
octane-tsrx update 0.104 0.099 −0.8% −8.3% … +2.3% ⚪ within noise
octane-tsrx select 0.007 0.007 −3.9% −7.0% … +0.8% ⚪ within noise
octane-tsrx swap 0.022 0.022 −0.0% −9.1% … +3.1% ⚪ within noise
octane-tsrx remove 0.019 0.020 +2.3% −2.7% … +6.8% ⚪ within noise
octane-tsrx runlots 26.667 27.708 −5.1% −9.8% … +7.0% ⚪ within noise
octane-tsrx select_lots 0.009 0.009 −7.0% −15.9% … −3.1% 🟢 faster
octane-tsrx clear 49.858 49.692 −0.1% −6.4% … +3.2% ⚪ within noise
octane-jsx run 3.858 3.758 −0.0% −4.1% … +1.3% ⚪ within noise
octane-jsx replace 8.192 7.617 −2.2% −6.6% … +4.9% ⚪ within noise
octane-jsx add 3.117 3.242 ±0.0% −3.1% … +3.4% ⚪ within noise
octane-jsx update 0.157 0.157 +1.0% −0.0% … +2.0% ⚪ within noise
octane-jsx select 0.080 0.084 −0.2% −1.0% … +2.0% ⚪ within noise
octane-jsx swap 0.130 0.131 +0.7% −1.4% … +2.1% ⚪ within noise
octane-jsx remove 0.116 0.115 −1.1% −2.2% … +0.8% ⚪ within noise
octane-jsx runlots 27.717 28.150 +0.2% −4.7% … +5.8% ⚪ within noise
octane-jsx select_lots 0.952 0.964 −0.0% −3.7% … +5.4% ⚪ within noise
octane-jsx clear 56.567 54.892 −1.4% −7.0% … +8.8% ⚪ within noise

All 64 work counters are unchanged.

Application bundle size (bytes)

No changes across 111 measured values.

Public-import reachability bundles (bytes)

No changes across 141 measured values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codemod replaces React.createElement inside callbacks rendered by a retained React registry

1 participant