Skip to content

feat(octane): infer primitive DOM text children - #1003

Merged
domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/feat-dom-text-inference
Sep 8, 2026
Merged

domgan-oai merged 4 commits into
octanejs:mainfrom
openai-oss-forks:codex/feat-dom-text-inference

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Infer primitive DOM text children from safe local syntax, including Number(), BigInt(), Date(), numeric operators, and typeof.
  • Add optional TypeScript project proofs for primitive string, number, bigint, and their unions during one-shot production builds with Vite, Rspack, and Rsbuild.
  • Preserve explicit as string text behavior and client/server hydration layout; keep watch/HMR syntax-only.

Why

Direct primitive DOM children can use Octane's text binding without requiring casts or String() calls. The optional checker can prove typed member reads and imported aliases that syntax alone cannot resolve. Numeric proofs stay distinct from string proofs so they do not change concatenation inference.

Changes

  • Source-bound, serializable primitive text ranges in the TypeScript adapter, plus a project root for renderer rule identities.
  • Vite and Rspack/Rsbuild opt-in wiring with project lifetime and cache guards; Rspack skips persistent module caching for eligible typed modules.
  • Client, server, hydration, option, imported-type invalidation, and watch fallback coverage; compiler guidance and patch changesets.

Validation

  • pnpm install --frozen-lockfile --registry=https://registry.npmjs.org/ (explicitly authorized), pnpm sync, and scoped pnpm format:files:check.
  • Owning package typechecks and scoped pnpm typecheck:files for changed compiler, Vite, Rspack, and Rsbuild files.
  • Focused Vitest: 117 core text cases, 77 nearby hydration/compiler cases, 73 Vite cases (four Chromium cases rerun with local browser permission), 86 Rspack cases, and 16 Rsbuild cases.
  • node benchmarks/bench.mjs --quick --ratios text-type-roots: warm snapshot ratio guard passed; 34-root 0.0016 ms, 20,002-root 0.0018 ms.
  • node --check on changed JavaScript and git diff --check.
  • Full repository pnpm format:check, pnpm typecheck, and pnpm test were not run locally; targeted package gates above cover the changed paths.
  • Current-head CI run 34278249317 passed on 91bc9a49dfe8bff2b42021185f27445b9e3b7e81 after rerunning a transient Chromium-backed parity worker failure on the same head.

Risk / follow-ups

  • The existing as string classification already works on the base; the new test preserves that behavior. Numeric literal static baking is excluded because root static text already has a separate client/server inconsistency.
  • Independently configured Rspack browser/server compilers do not have a shared atomic filesystem snapshot if imported types change while both builds run. Use the same tsconfig and stable source tree for both builds.
  • The TypeScript warm-snapshot ratio guard passes. No controlled before/after DOM timing was collected, so this PR does not claim a measured speedup.

Provenance

  • An agent produced this diff (agent-authored)

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Medium Risk
Changes how DOM children are classified for SSR and hydration; mismatched client/server facts or stale Rspack cache would cause subtle layout bugs, though the PR adds guards and invalidation for the new production path.

Overview
Extends DOM child text binding beyond strings to locally provable numbers and bigints (literals, numeric operators, Number/BigInt/Date()/typeof, and related syntax), while keeping explicit as string behavior and separate string vs primitive TypeScript proofs so numeric evidence does not affect string concatenation inference.

The compiler threads optional textTypeFacts (now including primitiveTextChildRanges) through client/server emission and hydration adjacency so both sides agree on text holes vs renderable children.

Vite, Rspack, and Rsbuild gain an opt-in textTypes: { tsconfig } for one-shot production builds: a shared TypeScript project supplies facts to the compiler; dev/HMR/watch stay syntax-only. Vite fails closed if proofs drift between client and server in the same build. Rspack disables parallel compilation and persistent module caching for typed Octane modules so imported type changes cannot reuse stale output.

Docs and types describe the broader primitive domains, safety boundaries (booleans/objects stay renderable), and optional root on the TS project adapter for renderer rule alignment.

Reviewed by Cursor Bugbot for commit 91bc9a4. 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 feat PR: new feature or capability labels Sep 8, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review September 8, 2026 20:59
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 feat PR: new feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant