Skip to content

Use sqlite-web transaction local DB API#2795

Open
findolor wants to merge 1 commit into
mainfrom
arda/sqlite-web-transaction-localdb
Open

Use sqlite-web transaction local DB API#2795
findolor wants to merge 1 commit into
mainfrom
arda/sqlite-web-transaction-localdb

Conversation

@findolor

@findolor findolor commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • bump @rainlanguage/sqlite-web to 0.0.3
  • replace the old positional local DB callbacks with an options object: { localDb, statusCallback }
  • require localDb.query, localDb.wipeAndRecreate, and localDb.transaction for sync YAMLs
  • send batch writes through one localDb.transaction([...]) call instead of looping queries with manual BEGIN / COMMIT
  • keep schema/reset/view SQL as single .sql scripts and adapt them into sqlite-web-compatible single-statement batches at the Rust boundary
  • update webapp wiring, mocks, README/API docs, and local DB WASM tests

Review

  • Ran a staged local review with two read-only reviewers.
  • Fixed the actionable finding by adding direct WASM constructor coverage for the exported { localDb, statusCallback } options path and missing transaction validation.

Verification

  • cargo check -p raindex_common
  • cargo check -p raindex_common -p raindex_cli
  • cargo test --workspace
  • cargo test -p raindex_common local_db::
  • cargo test -p raindex_cli local_db::pipeline::bootstrap
  • nix develop .#wasm-shell -c bash -c 'CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test --target wasm32-unknown-unknown --lib -p raindex_quote -p raindex_bindings -p raindex_js_api -p raindex_common'
  • nix develop .#wasm-shell -c bash -c 'npm install --no-check && cd packages/raindex && npm run build && npm test'
  • nix develop .#wasm-shell -c bash -c 'npm install --no-check && npm run svelte-lint-format-check -w @rainlanguage/webapp && npm run test -w @rainlanguage/webapp'
  • nix develop .#wasm-shell -c bash -c 'npm install --no-check && npm run build -w @rainlanguage/raindex && npm run build -w @rainlanguage/ui-components && npm run build -w @rainlanguage/webapp && npm run lint-format-check:all && npm run test --workspaces'
  • git diff --check
  • nix develop -c rainix-rs-static
  • In-app browser smoke test against http://127.0.0.1:5173/db-playground
    • initially caught sqlite-web Batch statements must contain a single statement
    • fixed by adapting the existing SQL scripts into single-statement transaction entries before calling sqlite-web
    • rerun showed LOCALDB ACTIVE; schema query returned local DB tables; db_metadata returned { id: 1, db_schema_version: 5 }
    • relevant browser logs showed no sqlite/localDb transaction error; only the expected sqlite-web WASM load warning

Summary by CodeRabbit

  • New Features

    • Local DB setup now uses a single options object, making configuration simpler and more consistent.
    • SQL operations for table creation, cleanup, and related tasks now run as batched statements, improving reliability.
    • Registry and client APIs now support updated local DB and status callback handling.
  • Bug Fixes

    • Improved handling for reset and transaction flows, including clearer error reporting when required local DB functions are missing.
  • Documentation

    • Updated setup and architecture docs to match the new configuration format.

findolor commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

How to use the Graphite Merge Queue

Add the label Raindex-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@findolor, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d2e513a0-1f4b-4fe5-8e7d-5a93b2eb25af

📥 Commits

Reviewing files that changed from the base of the PR and between b080e7d and 1afc572.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (29)
  • crates/cli/src/commands/local_db/pipeline/bootstrap.rs
  • crates/common/src/local_db/executor.rs
  • crates/common/src/local_db/pipeline/adapters/bootstrap.rs
  • crates/common/src/local_db/query/clear_tables/mod.rs
  • crates/common/src/local_db/query/create_tables/mod.rs
  • crates/common/src/local_db/query/create_views/mod.rs
  • crates/common/src/local_db/query/mod.rs
  • crates/common/src/local_db/query/sql_script.rs
  • crates/common/src/local_db/query/sql_statement_batch.rs
  • crates/common/src/raindex_client/local_db/executor.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler/wasm.rs
  • crates/common/src/raindex_client/local_db/query/clear_tables.rs
  • crates/common/src/raindex_client/local_db/query/create_tables.rs
  • crates/common/src/raindex_client/local_db/vaults.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/raindex_yaml.rs
  • crates/common/src/raindex_client/trades/get_by_owner.rs
  • crates/common/src/raindex_client/trades/get_by_tx.rs
  • crates/common/src/raindex_client/trades/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/js_api/src/registry.rs
  • package.json
  • packages/raindex/ARCHITECTURE.md
  • packages/raindex/README.md
  • packages/webapp/ARCHITECTURE.md
  • packages/webapp/src/routes/+layout.ts
📝 Walkthrough

Walkthrough

The PR reworks SQL execution into transaction batches (new SqlScript parser, clear_tables_batch/create_tables_batch/create_views_batch, SqlStatementBatch::inner_statements) used by reset/bootstrap flows, and refactors the JS local-database callback API into a unified local_db/options object consumed by JsCallbackExecutor, LocalDb, RaindexClient::new, and the JS API registry, with matching tests, webapp wiring, and docs updated.

Changes

SQL batch execution refactor

Layer / File(s) Summary
SqlScript parsing and batch helpers
crates/common/src/local_db/query/sql_script.rs, .../query/mod.rs, .../query/sql_statement_batch.rs
Adds SqlScript for splitting SQL text into statements/batches (quote/comment aware) and SqlStatementBatch::inner_statements for transaction-aware slicing.
Clear/create/view table batches
.../query/clear_tables/mod.rs, .../query/create_tables/mod.rs, .../query/create_views/mod.rs
Replaces single-statement builders with clear_tables_batch, vacuum_stmt, create_tables_batch, and drop/create view statement builders derived via SqlScript.
local_db executor test updates
crates/common/src/local_db/executor.rs
Test schema-stamping switches from create_tables_stmt to create_tables_sql/create_tables_batch via execute_batch.
reset_db orchestration
crates/common/src/local_db/pipeline/adapters/bootstrap.rs
reset_db now runs clear batch → vacuum → create batch; tests rewritten with with_batch/reset_prefix_sql ordering assertions.
CLI bootstrap test alignment
crates/cli/src/commands/local_db/pipeline/bootstrap.rs
Test mocks and assertions updated to the batch-based reset sequence and error propagation checks.

Estimated code review effort: 4 (Complex) | ~60 minutes

Local DB options-object API refactor

Layer / File(s) Summary
Executor core refactor
crates/common/src/raindex_client/local_db/executor.rs
JsCallbackExecutor holds a local_db JsValue; execute_batch/invoke_transaction_unlocked issue a single transaction callback from inner_statements; wipe_and_recreate simplified; tests rewritten accordingly.
LocalDb wrapper and scheduler helper
.../local_db/mod.rs, .../pipeline/runner/scheduler/wasm.rs
LocalDb::from_js_local_db(local_db: JsValue) replaces from_js_callback; scheduler test helper builds an object-based mock local_db.
Query wrappers and pipeline bootstrap tests
.../local_db/query/clear_tables.rs, .../query/create_tables.rs, .../pipeline/bootstrap.rs
clear_tables/create_tables execute batches through the new executor; tests assert transaction callback usage and reset-batch calls.
RaindexClient options API
crates/common/src/raindex_client/mod.rs
RaindexClient::new now takes options: Option<JsValue> parsed into LocalDbClientOptions (localDb, statusCallback) via Reflect; wiring and tests updated.
Registry options parameter
crates/js_api/src/registry.rs
getRaindexClient accepts a single options parameter, forwarded to RaindexClient::new.
Downstream test call-sites
.../local_db/orders.rs, .../local_db/vaults.rs, .../trades/*, .../vaults.rs, .../raindex_yaml.rs
Tests migrated to new_test_client_with_local_db/local_db_object_from_query_callback and reduced RaindexClient::new argument lists.
Webapp, docs, dependency
packages/webapp/src/routes/+layout.ts, packages/*/ARCHITECTURE.md, packages/raindex/README.md, package.json
+layout.ts passes { localDb, statusCallback }; docs updated to match; @rainlanguage/sqlite-web bumped to ^0.0.3.

Estimated code review effort: 5 (Critical) | ~110 minutes

Sequence Diagram(s)

sequenceDiagram
  participant JS
  participant RaindexClient
  participant LocalDbClientOptions
  participant LocalDb
  participant JsCallbackExecutor
  participant JsLocalDb

  JS->>RaindexClient: new(settings, subgraphs, options)
  RaindexClient->>LocalDbClientOptions: parse(options)
  LocalDbClientOptions-->>RaindexClient: localDb, statusCallback
  RaindexClient->>LocalDb: from_js_local_db(localDb)
  LocalDb->>JsCallbackExecutor: new(local_db)
  JsCallbackExecutor->>JsLocalDb: query / wipeAndRecreate / transaction (validated)
Loading
sequenceDiagram
  participant BootstrapPipeline
  participant Executor
  participant JsCallbackExecutor
  participant JsLocalDb

  BootstrapPipeline->>Executor: execute_batch(clear_tables_batch())
  BootstrapPipeline->>Executor: query_text(vacuum_stmt())
  BootstrapPipeline->>Executor: execute_batch(create_tables_batch())
  Executor->>JsCallbackExecutor: invoke_transaction_unlocked(batch)
  JsCallbackExecutor->>JsLocalDb: transaction(local_db, statements array)
Loading

Possibly related PRs

  • rainlanguage/raindex#2584: Both PRs change the vault_deltas view drop/recreate path via create_views_batch and related reset SQL expectations.
  • rainlanguage/raindex#2587: Both touch the batch-based clear_tables/create_tables execution path and the schema tables involved.
  • rainlanguage/raindex#2698: Both affect the create_tables_batch/CREATE_TABLES_SQL statements and header-guard PRAGMA stamping consumed by the batch execution flow.

Suggested reviewers: 0xgleb, JuaniRios, hardyjosh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.07% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: switching to the sqlite-web transaction-based local DB API.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch arda/sqlite-web-transaction-localdb

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@findolor findolor self-assigned this Jul 1, 2026
@findolor findolor requested review from 0xgleb and JuaniRios July 1, 2026 09:29
@findolor findolor force-pushed the arda/sqlite-web-transaction-localdb branch 2 times, most recently from 93b918a to 237ca76 Compare July 1, 2026 10:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

♻️ Duplicate comments (6)
crates/common/src/local_db/query/create_tables/statements/063.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/063.sql` around
lines 1 - 2, The CREATE INDEX statement in the derived_trades migration is
missing the same IF NOT EXISTS guard as the related index migration; update the
index definition for idx_derived_trades_tx to use a safe idempotent creation
pattern. Keep the change in the SQL migration that defines derived_trades
indexes so reruns do not fail when the index already exists.
crates/common/src/local_db/query/create_tables/statements/062.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/062.sql` around
lines 1 - 2, Add IF NOT EXISTS to the CREATE INDEX statement in the derived
trades index migration, matching the pattern used in 059.sql. Update the index
definition for idx_derived_trades_order_hash_time so the statement is idempotent
and can be re-run safely without failing if the index already exists.
crates/common/src/local_db/query/create_tables/statements/060.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/060.sql` around
lines 1 - 2, The CREATE INDEX statement for the derived_trades table is missing
the same guard as 059.sql, so update the index definition to use IF NOT EXISTS.
Modify the CREATE INDEX for idx_derived_trades_owner_time in the SQL statement
so repeated schema application won’t fail when the index already exists.
crates/common/src/local_db/query/create_tables/statements/058.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/058.sql` around
lines 1 - 2, The CREATE INDEX statement in the derived trades migration is
missing the same IF NOT EXISTS guard as the related index definition in 059.sql.
Update the statement for idx_derived_trades_input_token_time to include IF NOT
EXISTS so repeated runs of the migration remain idempotent, and keep the change
localized to the CREATE INDEX statement in the 058.sql script.
crates/common/src/local_db/query/create_tables/statements/064.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/064.sql` around
lines 1 - 2, The CREATE INDEX statement for idx_derived_trades_time is missing
the same IF NOT EXISTS guard used elsewhere. Update the index definition in the
064.sql migration to include IF NOT EXISTS so repeated runs do not fail,
matching the pattern already used in the related 059.sql statement.
crates/common/src/local_db/query/create_tables/statements/061.sql (1)

1-2: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Same missing IF NOT EXISTS concern as flagged in 059.sql.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_tables/statements/061.sql` around
lines 1 - 2, Add IF NOT EXISTS to the CREATE INDEX statement in the
derived_trades migration, matching the pattern used in 059.sql. Update the
idx_derived_trades_taker_time statement so repeated runs are idempotent and do
not fail if the index already exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/common/src/local_db/query/create_tables/mod.rs`:
- Around line 1-70: Keep CREATE_TABLES_SQL and CREATE_TABLES_STATEMENTS
synchronized in create_tables/mod.rs by adding a test similar to create_views
that verifies the split statement array matches query.sql and stays aligned. Use
the existing CREATE_TABLES_SQL constant, CREATE_TABLES_STATEMENTS slice, and
SqlStatementBatch/SqlStatement setup to assert the batch content matches the
source SQL so future edits can’t drift silently.

In `@crates/common/src/raindex_client/local_db/executor.rs`:
- Around line 101-108: The manual loops in invoke_transaction_unlocked and the
other affected JS array-building path should be rewritten with iterator adapters
instead of explicit for loops. Keep the fallible transaction_statement
conversion chained with ? inside a try_for_each/for_each or equivalent iterator
pipeline, and preserve the existing behavior of pushing each converted item into
the Array builder. Use the existing symbols invoke_transaction_unlocked and
transaction_statement as the main touchpoints, and apply the same refactor to
the second loop range noted in the review.

In `@crates/common/src/raindex_client/local_db/query/create_tables.rs`:
- Around line 23-62: The test wrapper_uses_transaction_batch is too loose
because it only checks that transaction receives more than one statement. Update
the assertion to verify the exact expected batch size for create_tables, using
the statement list from CREATE_TABLES_STATEMENTS or the create_tables path in
create_tables.rs, so regressions that drop statements are caught. Keep the
existing transaction capture in wrapper_uses_transaction_batch and assert the
received array length matches the full expected count.

---

Duplicate comments:
In `@crates/common/src/local_db/query/create_tables/statements/058.sql`:
- Around line 1-2: The CREATE INDEX statement in the derived trades migration is
missing the same IF NOT EXISTS guard as the related index definition in 059.sql.
Update the statement for idx_derived_trades_input_token_time to include IF NOT
EXISTS so repeated runs of the migration remain idempotent, and keep the change
localized to the CREATE INDEX statement in the 058.sql script.

In `@crates/common/src/local_db/query/create_tables/statements/060.sql`:
- Around line 1-2: The CREATE INDEX statement for the derived_trades table is
missing the same guard as 059.sql, so update the index definition to use IF NOT
EXISTS. Modify the CREATE INDEX for idx_derived_trades_owner_time in the SQL
statement so repeated schema application won’t fail when the index already
exists.

In `@crates/common/src/local_db/query/create_tables/statements/061.sql`:
- Around line 1-2: Add IF NOT EXISTS to the CREATE INDEX statement in the
derived_trades migration, matching the pattern used in 059.sql. Update the
idx_derived_trades_taker_time statement so repeated runs are idempotent and do
not fail if the index already exists.

In `@crates/common/src/local_db/query/create_tables/statements/062.sql`:
- Around line 1-2: Add IF NOT EXISTS to the CREATE INDEX statement in the
derived trades index migration, matching the pattern used in 059.sql. Update the
index definition for idx_derived_trades_order_hash_time so the statement is
idempotent and can be re-run safely without failing if the index already exists.

In `@crates/common/src/local_db/query/create_tables/statements/063.sql`:
- Around line 1-2: The CREATE INDEX statement in the derived_trades migration is
missing the same IF NOT EXISTS guard as the related index migration; update the
index definition for idx_derived_trades_tx to use a safe idempotent creation
pattern. Keep the change in the SQL migration that defines derived_trades
indexes so reruns do not fail when the index already exists.

In `@crates/common/src/local_db/query/create_tables/statements/064.sql`:
- Around line 1-2: The CREATE INDEX statement for idx_derived_trades_time is
missing the same IF NOT EXISTS guard used elsewhere. Update the index definition
in the 064.sql migration to include IF NOT EXISTS so repeated runs do not fail,
matching the pattern already used in the related 059.sql statement.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e2585064-a67e-4c6f-b7ef-de8901c52565

📥 Commits

Reviewing files that changed from the base of the PR and between 237ca76 and 93b918a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (118)
  • crates/cli/src/commands/local_db/pipeline/bootstrap.rs
  • crates/common/src/local_db/executor.rs
  • crates/common/src/local_db/pipeline/adapters/bootstrap.rs
  • crates/common/src/local_db/query/clear_tables/mod.rs
  • crates/common/src/local_db/query/clear_tables/statements/001.sql
  • crates/common/src/local_db/query/clear_tables/statements/002.sql
  • crates/common/src/local_db/query/clear_tables/statements/003.sql
  • crates/common/src/local_db/query/clear_tables/statements/004.sql
  • crates/common/src/local_db/query/clear_tables/statements/005.sql
  • crates/common/src/local_db/query/clear_tables/statements/006.sql
  • crates/common/src/local_db/query/clear_tables/statements/007.sql
  • crates/common/src/local_db/query/clear_tables/statements/008.sql
  • crates/common/src/local_db/query/clear_tables/statements/009.sql
  • crates/common/src/local_db/query/clear_tables/statements/010.sql
  • crates/common/src/local_db/query/clear_tables/statements/011.sql
  • crates/common/src/local_db/query/clear_tables/statements/012.sql
  • crates/common/src/local_db/query/clear_tables/statements/013.sql
  • crates/common/src/local_db/query/clear_tables/statements/014.sql
  • crates/common/src/local_db/query/clear_tables/statements/015.sql
  • crates/common/src/local_db/query/clear_tables/statements/016.sql
  • crates/common/src/local_db/query/clear_tables/statements/017.sql
  • crates/common/src/local_db/query/clear_tables/statements/018.sql
  • crates/common/src/local_db/query/clear_tables/statements/019.sql
  • crates/common/src/local_db/query/clear_tables/statements/020.sql
  • crates/common/src/local_db/query/clear_tables/statements/021.sql
  • crates/common/src/local_db/query/clear_tables/statements/022.sql
  • crates/common/src/local_db/query/clear_tables/statements/023.sql
  • crates/common/src/local_db/query/clear_tables/statements/024.sql
  • crates/common/src/local_db/query/create_tables/mod.rs
  • crates/common/src/local_db/query/create_tables/statements/001.sql
  • crates/common/src/local_db/query/create_tables/statements/002.sql
  • crates/common/src/local_db/query/create_tables/statements/003.sql
  • crates/common/src/local_db/query/create_tables/statements/004.sql
  • crates/common/src/local_db/query/create_tables/statements/005.sql
  • crates/common/src/local_db/query/create_tables/statements/006.sql
  • crates/common/src/local_db/query/create_tables/statements/007.sql
  • crates/common/src/local_db/query/create_tables/statements/008.sql
  • crates/common/src/local_db/query/create_tables/statements/009.sql
  • crates/common/src/local_db/query/create_tables/statements/010.sql
  • crates/common/src/local_db/query/create_tables/statements/011.sql
  • crates/common/src/local_db/query/create_tables/statements/012.sql
  • crates/common/src/local_db/query/create_tables/statements/013.sql
  • crates/common/src/local_db/query/create_tables/statements/014.sql
  • crates/common/src/local_db/query/create_tables/statements/015.sql
  • crates/common/src/local_db/query/create_tables/statements/016.sql
  • crates/common/src/local_db/query/create_tables/statements/017.sql
  • crates/common/src/local_db/query/create_tables/statements/018.sql
  • crates/common/src/local_db/query/create_tables/statements/019.sql
  • crates/common/src/local_db/query/create_tables/statements/020.sql
  • crates/common/src/local_db/query/create_tables/statements/021.sql
  • crates/common/src/local_db/query/create_tables/statements/022.sql
  • crates/common/src/local_db/query/create_tables/statements/023.sql
  • crates/common/src/local_db/query/create_tables/statements/024.sql
  • crates/common/src/local_db/query/create_tables/statements/025.sql
  • crates/common/src/local_db/query/create_tables/statements/026.sql
  • crates/common/src/local_db/query/create_tables/statements/027.sql
  • crates/common/src/local_db/query/create_tables/statements/028.sql
  • crates/common/src/local_db/query/create_tables/statements/029.sql
  • crates/common/src/local_db/query/create_tables/statements/030.sql
  • crates/common/src/local_db/query/create_tables/statements/031.sql
  • crates/common/src/local_db/query/create_tables/statements/032.sql
  • crates/common/src/local_db/query/create_tables/statements/033.sql
  • crates/common/src/local_db/query/create_tables/statements/034.sql
  • crates/common/src/local_db/query/create_tables/statements/035.sql
  • crates/common/src/local_db/query/create_tables/statements/036.sql
  • crates/common/src/local_db/query/create_tables/statements/037.sql
  • crates/common/src/local_db/query/create_tables/statements/038.sql
  • crates/common/src/local_db/query/create_tables/statements/039.sql
  • crates/common/src/local_db/query/create_tables/statements/040.sql
  • crates/common/src/local_db/query/create_tables/statements/041.sql
  • crates/common/src/local_db/query/create_tables/statements/042.sql
  • crates/common/src/local_db/query/create_tables/statements/043.sql
  • crates/common/src/local_db/query/create_tables/statements/044.sql
  • crates/common/src/local_db/query/create_tables/statements/045.sql
  • crates/common/src/local_db/query/create_tables/statements/046.sql
  • crates/common/src/local_db/query/create_tables/statements/047.sql
  • crates/common/src/local_db/query/create_tables/statements/048.sql
  • crates/common/src/local_db/query/create_tables/statements/049.sql
  • crates/common/src/local_db/query/create_tables/statements/050.sql
  • crates/common/src/local_db/query/create_tables/statements/051.sql
  • crates/common/src/local_db/query/create_tables/statements/052.sql
  • crates/common/src/local_db/query/create_tables/statements/053.sql
  • crates/common/src/local_db/query/create_tables/statements/054.sql
  • crates/common/src/local_db/query/create_tables/statements/055.sql
  • crates/common/src/local_db/query/create_tables/statements/056.sql
  • crates/common/src/local_db/query/create_tables/statements/057.sql
  • crates/common/src/local_db/query/create_tables/statements/058.sql
  • crates/common/src/local_db/query/create_tables/statements/059.sql
  • crates/common/src/local_db/query/create_tables/statements/060.sql
  • crates/common/src/local_db/query/create_tables/statements/061.sql
  • crates/common/src/local_db/query/create_tables/statements/062.sql
  • crates/common/src/local_db/query/create_tables/statements/063.sql
  • crates/common/src/local_db/query/create_tables/statements/064.sql
  • crates/common/src/local_db/query/create_tables/statements/065.sql
  • crates/common/src/local_db/query/create_views/mod.rs
  • crates/common/src/local_db/query/create_views/vault_deltas/001.sql
  • crates/common/src/local_db/query/create_views/vault_deltas/002.sql
  • crates/common/src/local_db/query/sql_statement_batch.rs
  • crates/common/src/raindex_client/local_db/executor.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler/wasm.rs
  • crates/common/src/raindex_client/local_db/query/clear_tables.rs
  • crates/common/src/raindex_client/local_db/query/create_tables.rs
  • crates/common/src/raindex_client/local_db/vaults.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/raindex_yaml.rs
  • crates/common/src/raindex_client/trades/get_by_owner.rs
  • crates/common/src/raindex_client/trades/get_by_tx.rs
  • crates/common/src/raindex_client/trades/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/js_api/src/registry.rs
  • package.json
  • packages/raindex/ARCHITECTURE.md
  • packages/raindex/README.md
  • packages/webapp/ARCHITECTURE.md
  • packages/webapp/src/routes/+layout.ts

Comment thread crates/common/src/local_db/query/create_tables/mod.rs Outdated
Comment thread crates/common/src/raindex_client/local_db/executor.rs Outdated
Comment thread crates/common/src/raindex_client/local_db/query/create_tables.rs
@findolor findolor force-pushed the arda/sqlite-web-transaction-localdb branch 5 times, most recently from 3142682 to b080e7d Compare July 1, 2026 11:03
@findolor

findolor commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
crates/common/src/local_db/query/create_views/mod.rs (1)

19-24: 🩺 Stability & Availability | 🔵 Trivial | 🏗️ Heavy lift

Avoid a production panic in view_statement().

If vault_deltas.sql ever stops splitting into exactly two statements, both public helpers panic here. Prefer validating once and propagating a typed error instead of relying on expect() in a runtime path. As per coding guidelines, "reserve unwrap()/expect() for tests and invariants that can be proven infallible".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/common/src/local_db/query/create_views/mod.rs` around lines 19 - 24,
The helper in view_statement() currently uses expect() on
SqlScript::new(VAULT_DELTAS_VIEW_SQL).statements(), which can panic in
production if the SQL no longer splits as assumed. Replace this with a validated
path that checks the statement count once, returns a typed error on mismatch,
and have the public helpers that depend on view_statement() propagate that error
instead of panicking.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/common/src/local_db/query/sql_script.rs`:
- Around line 87-102: The tail handling in split_statements is pushing
comment-only fragments because it only checks trim() emptiness, so inputs like
"SELECT 1; -- note" become a spurious second batch item. Update split_statements
to track whether the current slice contains executable SQL outside comments
before pushing the final statement, and use that same logic for any
batch-finalizing path in this function. Add a regression test covering a
trailing comment-only fragment to ensure it is skipped.

---

Nitpick comments:
In `@crates/common/src/local_db/query/create_views/mod.rs`:
- Around line 19-24: The helper in view_statement() currently uses expect() on
SqlScript::new(VAULT_DELTAS_VIEW_SQL).statements(), which can panic in
production if the SQL no longer splits as assumed. Replace this with a validated
path that checks the statement count once, returns a typed error on mismatch,
and have the public helpers that depend on view_statement() propagate that error
instead of panicking.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ee77a9c4-482c-44e5-9bd9-a337327eb38f

📥 Commits

Reviewing files that changed from the base of the PR and between 93b918a and b080e7d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (29)
  • crates/cli/src/commands/local_db/pipeline/bootstrap.rs
  • crates/common/src/local_db/executor.rs
  • crates/common/src/local_db/pipeline/adapters/bootstrap.rs
  • crates/common/src/local_db/query/clear_tables/mod.rs
  • crates/common/src/local_db/query/create_tables/mod.rs
  • crates/common/src/local_db/query/create_views/mod.rs
  • crates/common/src/local_db/query/mod.rs
  • crates/common/src/local_db/query/sql_script.rs
  • crates/common/src/local_db/query/sql_statement_batch.rs
  • crates/common/src/raindex_client/local_db/executor.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler/wasm.rs
  • crates/common/src/raindex_client/local_db/query/clear_tables.rs
  • crates/common/src/raindex_client/local_db/query/create_tables.rs
  • crates/common/src/raindex_client/local_db/vaults.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/raindex_yaml.rs
  • crates/common/src/raindex_client/trades/get_by_owner.rs
  • crates/common/src/raindex_client/trades/get_by_tx.rs
  • crates/common/src/raindex_client/trades/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/js_api/src/registry.rs
  • package.json
  • packages/raindex/ARCHITECTURE.md
  • packages/raindex/README.md
  • packages/webapp/ARCHITECTURE.md
  • packages/webapp/src/routes/+layout.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/webapp/ARCHITECTURE.md
  • packages/raindex/ARCHITECTURE.md
  • packages/raindex/README.md
🚧 Files skipped from review as they are similar to previous changes (21)
  • crates/common/src/raindex_client/trades/get_by_owner.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler/wasm.rs
  • crates/common/src/raindex_client/raindex_yaml.rs
  • crates/common/src/local_db/query/clear_tables/mod.rs
  • crates/common/src/raindex_client/trades/get_by_tx.rs
  • package.json
  • crates/common/src/raindex_client/local_db/query/clear_tables.rs
  • packages/webapp/src/routes/+layout.ts
  • crates/js_api/src/registry.rs
  • crates/common/src/raindex_client/trades/mod.rs
  • crates/common/src/local_db/executor.rs
  • crates/common/src/raindex_client/local_db/query/create_tables.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/bootstrap.rs
  • crates/cli/src/commands/local_db/pipeline/bootstrap.rs
  • crates/common/src/raindex_client/local_db/vaults.rs
  • crates/common/src/local_db/pipeline/adapters/bootstrap.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/local_db/query/sql_statement_batch.rs

Comment thread crates/common/src/local_db/query/sql_script.rs
@findolor findolor force-pushed the arda/sqlite-web-transaction-localdb branch from b080e7d to 1afc572 Compare July 1, 2026 11:16
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