feat(repl): Phase 11.11a REPL .spawn for interactive BEGIN CONCURRENT demos (SQLR-22)#131
Merged
Merged
Conversation
… demos (SQLR-22)
Lifts the REPL from a single Database to Vec<Connection> so users can mint
sibling handles in-session and step through cross-handle MVCC scenarios.
The prompt now shows the active handle ('sqlrite[A]> ' / 'sqlrite[B]> ')
so it's obvious which connection will execute the next line.
New meta-commands:
- .spawn Mint a sibling Connection sharing the same Arc<Mutex<Database>>
via Connection::connect(), then switch to it. Each handle gets
a stable letter name (A, B, ..., Z, then AA, AB).
- .use NAME Switch the active handle (case-insensitive); errors with the
list of valid names on miss.
- .conns List every handle, mark active with *, tag handles holding
an open BEGIN CONCURRENT with (BEGIN CONCURRENT).
Plumbing:
- New ReplState in src/repl/mod.rs owns Vec<Connection>, parallel
Vec<String> of names, and the active index. Exposes lock_active() for
meta-commands that mutate the underlying Database directly, and
active_conn_mut() for SQL dispatch through Connection.
- src/main.rs migrates the REPL loop from &mut Database to
&mut ReplState. SQL dispatch routes through a new
Connection::execute_with_render which returns CommandOutput (status +
optional rendered prettytable) instead of a bare String — so BEGIN
CONCURRENT / COMMIT / ROLLBACK still hit the per-connection MVCC
state, while SELECTs come back with the prettytable for the REPL to
print above the status line.
- Connection::concurrent_tx_is_open() promoted from private to public
so .conns can render per-handle tx state.
- .open collapses every sibling back to a single handle named A —
siblings pointing at the previous Database would otherwise be
stranded with stale MVCC state.
Tests:
- 8 new cases in src/meta_command/mod.rs cover .spawn / .use / .conns
parse + dispatch behaviour, case-insensitive .use, the error message
on unknown names, multi-handle shared-database visibility,
.open-collapse, and the A → Z → AA naming wrap.
Docs:
- roadmap.md: Phase 11.11a promoted to shipped; the heavier
benchmark workload split out as 11.11b.
- usage.md: new "Multi-handle mode" section with a worked
BEGIN-CONCURRENT-vs-BEGIN-CONCURRENT demo.
- smoke-test.md: prompt example refreshed (sqlrite[A]>), command
count bumped from 5 → 9.
- design-decisions.md: new §12h covering the migration rationale
(why Vec<Connection> over HashMap, why .open collapses siblings,
why execute_with_render instead of pre-parsing).
Workspace: 615/615 Rust tests pass (was 607, +8 new). fmt + clippy
+ doc all clean. Smoke-tested the BEGIN CONCURRENT demo end-to-end
across A/B handles — A's commit hits Busy as expected.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DatabasetoVec<Connection>so users can mint sibling handles in-session and step through cross-handle MVCC scenarios..spawn/.use NAME/.connsdrive the multi-handle UX; the prompt always shows the active handle (sqlrite[A]>,sqlrite[B]>).Connection::execute_with_renderlets the REPL keep the prettytable output forSELECTwhile routing every line throughConnectionsoBEGIN CONCURRENT/COMMIT/ROLLBACKhit the per-connection MVCC state.Worked demo
Changes
src/repl/mod.rs: newReplStatestruct holdsVec<Connection>, parallelVec<String>of stable letter names, and the active index. Methods:spawn_sibling,use_handle,handles_summary,lock_active,active_conn_mut,collapse_to_active. Anext_handle_name(usize) -> Stringhelper produces theA, …, Z, AA, ABsequence.src/meta_command/mod.rs: newMetaCommand::Spawn/Use(String)/Connsvariants + parser + handlers..opennow callsstate.collapse_to_active()before swapping the underlying Database so siblings can't be left pointing at the stale one.src/main.rs: REPL loop migrated from&mut Databaseto&mut ReplState. SQL dispatch routes throughConnection::execute_with_render. Prompt shows the active handle name.src/connection.rs: newexecute_with_render,execute_dispatch_with_render,execute_in_concurrent_tx_with_render— render-aware twins of the existing dispatch tree.concurrent_tx_is_open()promoted topubso.connscan render the per-handle tx flag.Why this is split from "Phase 11.11"
The original plan-doc 11.11 bundled the REPL
.spawnwork with a heavier "N concurrent writers" benchmark workload (extends thebenchmarks/harness, links SQLite + DuckDB drivers, criterion-driven). Splitting keeps each PR reviewable. The bench workload becomes Phase 11.11b in the roadmap.Test plan
cargo build --workspace --exclude sqlrite-desktop --exclude sqlrite-python --exclude sqlrite-nodejs --exclude sqlrite-benchmarks --all-targetscargo test --workspace --exclude sqlrite-desktop --exclude sqlrite-python --exclude sqlrite-nodejs --exclude sqlrite-benchmarks— 615/615 (was 607, +8 new inmeta_command::tests)cargo fmt --all -- --checkcargo clippy --workspace --exclude sqlrite-desktop --exclude sqlrite-python --exclude sqlrite-nodejs --exclude sqlrite-benchmarks --all-targetscargo doc --workspace --exclude sqlrite-desktop --exclude sqlrite-python --exclude sqlrite-nodejs --exclude sqlrite-benchmarks --no-depsDocs updated
docs/roadmap.md— Phase 11.11a promoted to shipped, 11.11b carved out for the bench workload.docs/usage.md— new "Multi-handle mode" section with the worked demo above.docs/smoke-test.md— prompt example refreshed (sqlrite[A]>), command count bumped 5 → 9.docs/design-decisions.md— new §12h on the migration rationale (Vec<Connection>overHashMap,.opencollapse semantics,execute_with_renderdesign).🤖 Generated with Claude Code