Skip to content

feat(lexer): prototype versioned detection baselines - #129

Draft
BridgeAR wants to merge 5 commits into
mainfrom
BridgeAR/2026-10-05-export-baseline-poc
Draft

BridgeAR wants to merge 5 commits into
mainfrom
BridgeAR/2026-10-05-export-baseline-poc

Conversation

@BridgeAR

@BridgeAR BridgeAR commented Oct 5, 2026

Copy link
Copy Markdown
Member

Conditional export detection keeps the last matching assignment, even when its branch cannot run. This PoC makes final export outcomes conditional on control flow through an opt-in detection baseline.

The third parse argument selects a versioned baseline that can combine detection rules. The default call retains its current behavior and result. This is a bounded syntax experiment. Unsupported syntax, opaque effects, and analysis limits produce unknown outcomes instead of speculative export lists.

Synchronous ESM parsing includes the analyzer in the bundle, which adds about 18 KB.

Refs: #99

Conditional export detection keeps the last matching assignment, even when
its branch cannot run. This PoC makes final export outcomes conditional on
control flow through an opt-in detection baseline.

The third parse argument selects a versioned baseline that can combine
detection rules. The default call retains its current behavior and result.
This is a bounded syntax experiment. Unsupported syntax, opaque effects,
and analysis limits produce unknown outcomes instead of speculative export
lists.

Synchronous ESM parsing includes the analyzer in the bundle, which adds
about 18 KB.

Refs: #99
Flow reports distinguish sequential replacements from conditional alternatives.
Default calls defer the report until its first read so legacy consumers avoid
control-flow parsing. Unsupported effects remain unknown.

Reusing scalar lexer stacks reduces empty JavaScript parses from 4.05 us to
177 ns and from 4.32 us to 187 ns. Two fresh Node 22.23.3 processes use
V8 12.4.254.21-node.57, 50k warmup iterations, and seven alternating 30k-iteration
trials. Each result excludes the fastest and slowest trials.
The Wasm counter adds a small cost without an additional host/guest call.
Conditional reports can be slower because the lexer must establish the trigger
first.

Refs: #99
Conditional replacements lose live dependencies when only the last syntactic
assignment is reported. Reexport groups separate alternative final values and
combine dependencies spread into one value. The third argument retains an
explicit legacy baseline.

Flow analysis starts after two detected replacements and has one C owner for
both parser entries. Unsupported effects produce incomplete results rather
than guessed exports. Zero or one replacement retains the existing fast path.

Against f580443, conditional analysis falls from 4.57 to 2.86 us in CommonJS
and 4.23 to 1.90 us in Wasm. Straight replacements add about 0.90 us in CommonJS
and 0.44 us in Wasm. The shared C owner keeps this bounded cost on the active
path. Measurements use Node 22.23.3, V8 12.4.254.21-node.57, 50,000 warmups,
20,000 iterations per trial, seven alternating trials, and two fresh processes.
Each run removes the best and worst trials.

Refs: #99
Wrapping a single outcome changes the dependency shape for deterministic
modules. Preserve their flat lists and nest only distinct conditional lists.

The overloads reject undefined options although the runtime accepts them,
which prevents callers from forwarding an optional third argument.

Refs: #99
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