Skip to content

feat: experiment with scoped async signals and native reads - #877

Merged
trueadm merged 9 commits into
octanejs:mainfrom
openai-oss-forks:codex/experimental-scoped-async-signals
Aug 28, 2026
Merged

trueadm merged 9 commits into
octanejs:mainfrom
openai-oss-forks:codex/experimental-scoped-async-signals

Conversation

@domgan-oai

@domgan-oai domgan-oai commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This is the requested experimental implementation of RFC 2. The author has marked it ready so CI can run; there is no package release or merge recommendation. The primary integration path is compiled @{} TSRX components.

The new octane/signals engine uses the public Alien Signals 3.2.0 system API. Explicit scopes own writable and derived state, revocable async requests, streams, retained results, serialization, and historical adoption. Query arguments are copied and canonicalized; request sharing ends when the last selector leaves. The existing Alien Signals binding remains on its separate 1.0.4 contract.

This consolidation fixes missed reads in parameter defaults and indirect returns by collecting around actual runtime component invocation. Opted-in inferred useMemo callbacks validate and replay native read evidence while retaining lexical dependency inference. Explicit arrays and null keep their contracts. latest preserves a whole result, including its identity and commands, and retirement of a contributing live owner revokes it even after dependency replacement. isPending measures expression availability; snapshots describe background activity. Serialized seeds are copied data owned by the adopter and its frame leases.

The changes reuse Octane cleanup scopes, scheduling, acceptance, Suspense, and hydration. Held output now keeps its DOM, refs, effects, and native read subscriptions together until replacement work is accepted. Compiler activation is separate from collection so unused native adapter implementations stay out of ordinary bundles. Ordinary return-element syntax inside .tsrx has secondary compatibility coverage; it does not replace the compiled TSRX template path.

The performance follow-up avoids duplicate native collection setup when invocation collection already supplies the owner, observer, and write guard. Child scopes still retire their own obsolete reads, and stored-value witnesses use rendering context rather than a cleanup token to decide whether to collect. No graph cache, candidate pool, or additional retained state is introduced.

The API guide, accepted plan, evidence report, and TSRX performance report separate implemented behavior, measured costs, and open gates. The performance follow-up starts from consolidated draft 422c2c937784af835c64d6fae5a39162143c7a44 and also compares with its predecessor cd9ed33754bfc3eeb144ba256dc9b437614e3e92. The branch also incorporates upstream f036bad8d1e0e095694b8bbc71e95d13e01a7330; that website-only update does not change measured inputs.

The CI follow-up in 530ee9a0abe35c5bc1ea0a1da0e44482306a6e42 fixes nested Suspense ref cleanup, caught deletion cleanup that connected an abandoned replacement, and urgent state that superseded every held transition update. It adds public regressions while retaining the original TanStack Query and boundary assertions. Native compiler-version and server-hook errors now use the production catalog and generated CLI explanations. The remaining changes repair benchmark discovery, the CommonJS export contract, a forbidden Formisch config fingerprint, generated eval digests, and formatting.

The final CI follow-up in 4bc7058bea6093e9e33df6d4e8d3714821700ca2 corrects test execution only. The native type-classifier suite now declares its Node environment; all 14 existing cases and assertions are retained. Browser discovery checks actual files against project include/exclude globs, rather than counting shared directory prefixes. An explicit browser glob also prevents the native browser suite from leaking into ordinary shards: Vitest does not expand a bare directory exclusion. Runtime code, compiler options, and benchmark behavior are unchanged.

The CI repair report and final evidence manifest record the repaired source, measurements, commands, and limitations. Earlier reports remain historical rather than being retagged as current checks.

Validation

  • Final supplemental source verification: 1,352 non-browser assertions plus four Chromium assertions in an approved browser-only rerun, covering 82 file executions. Among the 1,144 captured inputs, the only later changes are the compiler test environment header and browser routing metadata. All production and benchmark inputs remain unchanged. Browser setup failures and exact skipped/rerun identities remain recorded; this was not one successful canonical workspace command.
  • Before-fix failures for the new runtime and diagnostic regressions, followed by 76 combined development/production runtime checks and 16 bundled diagnostic checks. The broader total already includes these contracts; these counts are not additive.
  • The compiler type suite reproduced the CI module-loading failure locally before the environment fix, then passed all 28 development/production checks. Browser ownership checks use Vitest’s actual glob semantics, with duplicate and missing-owner controls; the full workflow suite is covered by the CI status below.
  • Canonical generator scripts run against identical staged inputs: CLI data, scaffold manifests, consumer configurations, RuleSync, context budget, and the error catalog with its four unit tests. The eval corpus was regenerated through its canonical authority; only lockfile and grader digests changed in all 19 task records. All eight remaining generator commands passed again with no generated changes and 1,686 unchanged input hashes. The staged generator runs do not establish a completed locked local sync.
  • Two final-source paired TSRX prop-update runs, the full mount/update/SSR/collector harness, and two public-entry bundle runs. Semantic controls pass; every timing sample, unfavorable result, source/dependency hash, and uncertainty interval is retained.
  • Supplemental per-file formatting checks with repository settings, including the final four-file test/configuration follow-up; git diff --check. Earlier formatting provenance proves captured JSON values and measured source hashes were preserved.
  • Required and relevant current-head CI is terminal and successful.
  • Complete local locked pnpm sync, pnpm format:check, pnpm typecheck, and pnpm test.

CI run 33157294097 passed every required and relevant job on 4bc7058bea6093e9e33df6d4e8d3714821700ca2, including formatting/workflow checks, all four main test shards, all four React parity shards, typechecks, Chromium, package validation/builds, eval corpus, runtime loaders, Astro, website, examples, Lynx, Three, and CI provenance. Cursor Bugbot also completed on this head without findings. The PR remains ready and awaits maintainer approval; it has not been merged.

Recorded local locked-install attempts received HTTP 403 for TSRX npm payloads, including approved retries. The supplemental compiler uses verified public tag @tsrx/[email protected] at commit 7cb01278dff7aebfd25cbf5abcd2d47c6da7d81a plus the existing repository patch; it is not an npm SRI match or a complete locked workspace. No locked versions or registry policy were changed. The final pre-push sync ran through package inventory and stopped at the missing @tsrx/prettier-plugin; the remaining canonical generators passed separately on identical source and their generated changes are committed. Local source/toolchain limits remain distinct from the new CI run.

The previously disclosed nested-portal ref failure is now fixed, with inner-first, outer-first, simultaneous, and reentrant teardown controls. Its earlier reproduction on another experimental draft did not establish upstream-main behavior. Earlier type, publication, retention, model, and supplemental resolver reports retain their original scope and hashes; they are not silently counted as fresh verification of the repaired source.

Risk / follow-ups

For compiled @{} TSRX one-signal prop updates, the two paired wall ratios against cd9ed337 are 1.026 (95% interval 0.988–1.065) and 0.997 (0.985–1.009). All five focused cases include parity in both repeats. The earlier +28.6% slowdown was not reliably reproduced, so these near-parity point estimates establish neither a speedup nor exact zero overhead. The separate full mixed runner returns an unfavorable 1.085 ratio for that case: 1.707 to 1.852 microseconds with 17.9%/34.5% relative margins of error. It remains in the report alongside every other unfavorable row.

The near-parity statement does not cover ordinary return-JSX compatibility. In the full runner its one-signal prop update, signal update, and SSR ratios remain 1.980, 2.543, and 1.918; the enabled unread return case is 2.157 for prop updates and 3.840 for SSR. These costs remain explicit secondary compatibility limits.

Both new public-entry builds reproduce their output hashes. The ordinary client and server export bundles are byte-identical to f16c0bc7, at 44,134 and 12,340 gzip bytes. The earlier growth of 130 client / 94 SSR gzip bytes versus cd9ed337 remains disclosed. The boundary guard still excludes the scoped engine and emitted native adapter/collector implementations from ordinary exports. Complete compiled-fixture sizes are recorded separately; no unchanged-application-bundle claim is made.

The unchanged scoped engine retains the earlier consolidation performance limits versus raw Alien Signals: at workload scale 10,000 its broad batch scores are about 2.3–4.0× raw, construction 7.8–16.7×, and disposal 4.8–6.8×. Its chain batch score also rises about 19% versus the previous draft. Both matched graph runs use an explicit 8 MiB Node stack after the raw comparator hit the default stack limit during deep-chain teardown; the failed run is preserved. These are workload results, not universal safe scales or a UI speed claim. Secondary ordinary-return compatibility costs remain disclosed separately.

The earlier foreign-retention workload leaves zero retired consumers after 1,000 lifetimes, using the exact earlier engine bundle. Its earlier deliberate backlink fault detects the expected retained owners. That does not establish async, historical-frame, native DOM, or DevTools retention. Larger TSRX application/lifecycle benchmarks remain open; passing CI does not establish those performance or retention bounds.

Local useDerived$ and async hooks remain deferred because speculative closures cannot safely update transitive committed caches. Mutation journals, remote-write reconciliation, deep stores, pending server-producer transport, non-DOM hosts, and atomic cross-root reveal remain outside scope. Arbitrary local aliases of native hook imports and canonical native-option forwarding in tsrx-tsc remain limitations. The PR stays ready after current-head CI and Bugbot passed; maintainer approval is still required. No merge or package release is part of this work.

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
Benchmark and documentation additions are low risk; the paired changesets describe experimental runtime/compiler signal behavior whose acceptance depends on separate core code not shown in this diff chunk.

Overview
Adds release changesets and a large Node-only benchmark package (benchmarks/scoped-signals) to measure and gate the experimental scoped signal engine and compiler native read path described in the changeset text (opt-in Alien Signals 3.2.0, owned async resources, nativeReads, DevTools metadata).

The unified runner gains scoped-signals (renderer-free graph timing vs raw Alien 3.2.0, continuous partial disposal, optional heap diagnostics) and scoped-native-reads (production-compiled .tsrx mount/update/SSR/collector costs plus deterministic use() five-dependency hit/miss guards in ratios.json). Supporting runners cover bundle boundaries (ordinary entries must not retain the engine or native adapters), async/foreign retention workers with offline heap scanners, native collector protocol controls, DOM/SSR ABI smoke, and published ESM/CJS entry probes, with 2026-08-27 results documented in-repo.

A separate changeset patches @octanejs/mcp-server to expose these suites through the benchmark tool schema.

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

…scoped-async-signals

# Conflicts:
#	docs/packages.md
…scoped-async-signals

# Conflicts:
#	packages/alien-signals/audit/react-parity.json
#	packages/apollo-client/audit/react-parity.json
#	packages/aria/audit/react-parity.json
#	packages/base-ui/audit/react-parity.json
#	packages/cmdk/audit/react-parity.json
#	packages/colorful/audit/react-parity.json
#	packages/day-picker/audit/react-parity.json
#	packages/dexie/audit/react-parity.json
#	packages/dnd-kit/audit/react-parity.json
#	packages/draggable/audit/react-parity.json
#	packages/drei/audit/react-parity.json
#	packages/dropzone/audit/react-parity.json
#	packages/embla-carousel/audit/react-parity.json
#	packages/floating-ui/audit/react-parity.json
#	packages/formisch/audit/react-parity.json
#	packages/gsap/audit/react-parity.json
#	packages/hook-form/audit/react-parity.json
#	packages/i18next/audit/react-parity.json
#	packages/inertia/audit/react-parity.json
#	packages/ink/audit/react-parity.json
#	packages/input-otp/audit/react-parity.json
#	packages/intersection-observer/audit/react-parity.json
#	packages/jotai/audit/react-parity.json
#	packages/lexical/audit/react-parity.json
#	packages/livestore/audit/react-parity.json
#	packages/lucide/audit/react-parity.json
#	packages/mantine-hooks/audit/react-parity.json
#	packages/markdown/audit/react-parity.json
#	packages/mobx/audit/react-parity.json
#	packages/monaco-editor/audit/react-parity.json
#	packages/motion/audit/react-parity.json
#	packages/nuqs/audit/react-parity.json
#	packages/opentui/audit/react-parity.json
#	packages/pdf/audit/react-parity.json
#	packages/phosphor-icons/audit/react-parity.json
#	packages/popper/audit/react-parity.json
#	packages/radix/audit/react-parity.json
#	packages/rainbowkit/audit/react-parity.json
#	packages/react-error-boundary/audit/react-parity.json
#	packages/react-map-gl/audit/react-parity.json
#	packages/recharts/audit/react-parity.json
#	packages/redux-toolkit/audit/react-parity.json
#	packages/redux/audit/react-parity.json
#	packages/remix-router/audit/react-parity.json
#	packages/resizable-panels/audit/react-parity.json
#	packages/rxjs/audit/react-parity.json
#	packages/shadcn/audit/react-parity.json
#	packages/solana-kit/audit/react-parity.json
#	packages/sonner/audit/react-parity.json
#	packages/spring/audit/react-parity.json
#	packages/streamdown/audit/react-parity.json
#	packages/styled-components/audit/react-parity.json
#	packages/swr/audit/react-parity.json
#	packages/syntax-highlighter/audit/react-parity.json
#	packages/tanstack-ai/audit/react-parity.json
#	packages/tanstack-devtools/audit/react-parity.json
#	packages/tanstack-form/audit/react-parity.json
#	packages/tanstack-hotkeys/audit/react-parity.json
#	packages/tanstack-pacer/audit/react-parity.json
#	packages/tanstack-query/audit/react-parity.json
#	packages/tanstack-router-ssr-query/audit/react-parity.json
#	packages/tanstack-router/audit/react-parity.json
#	packages/tanstack-store/audit/react-parity.json
#	packages/tanstack-table/audit/react-parity.json
#	packages/tanstack-virtual/audit/react-parity.json
#	packages/testing-library/audit/react-parity.json
#	packages/textarea-autosize/audit/react-parity.json
#	packages/three/audit/react-parity.json
#	packages/tiptap/audit/react-parity.json
#	packages/transition-group/audit/react-parity.json
#	packages/usehooks-ts/audit/react-parity.json
#	packages/valtio/audit/react-parity.json
#	packages/vaul/audit/react-parity.json
#	packages/visx/audit/react-parity.json
#	packages/wagmi/audit/react-parity.json
#	packages/waypoint/audit/react-parity.json
#	packages/window/audit/react-parity.json
#	packages/xstate-store/audit/react-parity.json
#	packages/xstate/audit/react-parity.json
#	packages/zag/audit/react-parity.json
#	packages/zustand/audit/react-parity.json
@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 Aug 27, 2026
@domgan-oai
domgan-oai marked this pull request as ready for review August 27, 2026 23:04
@trueadm
trueadm merged commit 8adc693 into octanejs:main Aug 28, 2026
31 checks passed
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.

2 participants