Commit 873c926
authored
feat(vnext): add bounded browser parser executor (#181)
## Summary
Adds the private main-realm executor for the isolated parser worker
selected in
ADR 0004.
- Lazily creates at most one authoritative worker generation.
- Serializes requests through a bounded FIFO queue with independent
request-count
and retained UTF-16 text limits.
- Enforces startup, queue-wait, and posted-execution safety deadlines.
- Settles caller cancellation promptly while draining already-posted
work.
- Retires crashed, timed-out, malformed, or poisoned generations without
replaying posted work.
- Preserves never-posted queued work across eligible generation
replacement.
- Rejects reused worker identities and serializes retirement across
hostile
cleanup/settlement reentrancy.
- Keeps the worker factory, executor, protocol, and implementation types
private;
there is no root or `/vnext` public API change.
## Risk classification
Medium: concurrency, cancellation, worker lifecycle, resource
accounting, and
packaging boundaries.
The principal risks are double settlement, stale-generation authority,
physical
worker overlap, posted-work replay, unbounded retention, and browser
bundler
regressions. The implementation mutates ownership before every external
cleanup
or settlement boundary, uses an iterative pump trampoline, and tests
hostile
synchronous callbacks at each boundary.
## Evidence
- Full Node suite: 1,246 passed, 1 expected failure.
- Focused deterministic executor suite: 84 passed.
- Chromium: 4 files / 7 tests, including real worker, crash,
silent-worker
deadline, recovery, and default static Worker URL behavior.
- Changed executor coverage:
- Statements: 95.51%
- Branches: 95.37%
- Functions: 100%
- Lines: 95.49%
- All TypeScript project checks, oxlint, test-integrity, and diff checks
pass.
- Packed-package smoke test passes and asserts the executor artifact.
- The post-rebase executor patch ID exactly matches the twice-reviewed
pre-rebase
patch.
## Adversarial review ledger
The review loop found and fixed:
- cancellation and FIFO reentrancy during promotion;
- `preventDefault` running before generation retirement;
- listener installation continuing after synchronous retirement;
- recursive synchronous worker responses overflowing the stack;
- startup-failure queue transfer and ready-failure ownership errors;
- postMessage accessor disposal/forged-response races;
- a P1 physical-worker overlap during cleanup-triggered nested
submission; and
- same-worker identity reuse after termination.
Two independent reviewers approved the corrected pre-rebase patch. Two
fresh
independent audits also approved the exact rebased head after rerunning
Node,
Chromium, package, coverage, type, lint, integrity, placement, and demo
gates.
## API and rollout
This is implementation infrastructure only. It is not wired to sessions,
completion, diagnostics, or other public features. No compatibility or
migration
work is required in this slice. The next consuming coordinator must
preserve the
same bounded ownership and no-replay rules.
<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds a private, single-lane browser executor for the isolated SQL parser
worker with bounded queueing, strict deadlines, and safe lifecycle
handling. Internal only; no public or `/vnext` API changes. Hardened to
fail closed on retirement errors with explicit terminal states.
- **New Features**
- Lazily creates at most one worker generation; posts one request at a
time.
- Bounded FIFO queue with request-count and UTF‑16 text limits;
startup/queue/execution deadlines and prompt caller cancellation.
- Retires crashed/timed-out/poisoned generations without replay;
preserves never-posted queued work across replacement.
- Rejects reused worker identities; retirement is serialized and atomic
to avoid reentrancy races.
- Executor, worker factory, protocol, and types remain private; docs
updated and `scripts/package-smoke.mjs` asserts executor artifacts.
- **Bug Fixes**
- Fails closed if worker retirement throws to prevent accepting new work
in an unsafe state.
- Makes terminal states explicit to avoid resurrection and double
settlement.
<sup>Written for commit 1cb7105.
Summary will update on new commits.</sup>
<a
href="https://cubic.dev/pr/marimo-team/codemirror-sql/pull/181?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->1 parent a5c4e86 commit 873c926
8 files changed
Lines changed: 4043 additions & 23 deletions
File tree
- docs
- adr
- vnext
- scripts
- src/vnext
- __tests__
- browser_tests
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
| 64 | + | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
71 | | - | |
72 | | - | |
| 76 | + | |
| 77 | + | |
73 | 78 | | |
74 | 79 | | |
75 | 80 | | |
| |||
154 | 159 | | |
155 | 160 | | |
156 | 161 | | |
157 | | - | |
158 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
159 | 168 | | |
160 | 169 | | |
161 | 170 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
167 | 176 | | |
168 | 177 | | |
169 | 178 | | |
| |||
211 | 220 | | |
212 | 221 | | |
213 | 222 | | |
214 | | - | |
| 223 | + | |
215 | 224 | | |
216 | 225 | | |
217 | 226 | | |
| |||
280 | 289 | | |
281 | 290 | | |
282 | 291 | | |
283 | | - | |
| 292 | + | |
284 | 293 | | |
285 | 294 | | |
286 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
94 | 105 | | |
95 | 106 | | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
101 | 112 | | |
102 | 113 | | |
103 | 114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
173 | 175 | | |
174 | 176 | | |
175 | 177 | | |
| |||
0 commit comments