chore: drop sqlx-crud; use mostro_core::db::Crud#789
Conversation
Replace the unmaintained sqlx-crud dependency with the in-tree Crud trait from mostro-core 0.13.2. Add hand-written Bond persistence in bond/crud.rs and switch all Order, Dispute, and Bond call sites to mostro_core::db::Crud. Co-authored-by: Cursor <cursoragent@cursor.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (24)
WalkthroughThis PR removes ChangesMostro CRUD migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review Summary
Verdict: Approve
The sqlx-crud removal and the new mostro_core::db::Crud wiring look correct. I did not find any blocking correctness issues on the current head.
Notes
- Bond CRUD column order matches the migration schema.
- No remaining
sqlx_crudreferences in the repo.
|
I did a strict pass on this PR and I do not currently see a correctness blocker. What I specifically checked:
My read is that this follow-up is in a good state. The important part is that I also ran the bond-focused test slices locally against this branch:
So from my side, this looks like a solid daemon-side completion of the |
grunch
left a comment
There was a problem hiding this comment.
Strict review — drop sqlx-crud, route persistence through mostro_core::db::Crud
Verdict: APPROVE-WITH-NITS. No CRITICAL/HIGH issues. The risk is concentrated in the hand-written impl Crud for Bond and call-site parity; both check out. CI green is the merge gate (the branch can't be compiled locally because mostro-core 0.13.2 isn't in the registry cache), but the db::Crud contract the branch assumes was verified against the real mostro-core source.
Verified correct
impl Crud for BondSQL is correct. INSERT column list vspush_bindorder: no off-by-one, no missing column (31 insert binds + 30 update-SET + 1 WHERE = 62).FromRowdecodes by column name, not ordinal, soRETURNING *and thepayout_payment_hashcolumn (added viaALTER TABLE, physically last) are safe.- No SQL injection. Every value goes through
push_bind/push_bind_unseparated; the only formatted string interpolates?placeholders, not values. - UPDATE parity.
push_bond_update_setcovers all 30 non-PK fields (incl.created_at) = the same full-row UPDATEsqlx-crud's derive produced. ConfirmedOrder::update/Dispute::updatefollow the identicalQueryBuilder + push_*_update_set + RETURNING *full-row pattern in mostro-core, so no Order/Dispute update-semantics regression. - CAS transitions are NOT routed through
Crud::update(). The critical state-machine writes (bond slashLocked->PendingPayout, payout hash-persist, range-close) remain rawUPDATE ... WHERE id=? AND state=?. No new TOCTOU window —Crud::update()is used only for auxiliary full-row updates where idempotency (not atomicity) is the needed property. - Clean dependency drop (
sqlx-crudand itsInflectortransitive dep both gone). Executor narrowing (E: Executor->&Pool<Sqlite>) is lossless — no call site passed a&mut Transactionto the old Crud. update()is exercised by thebond/dbtests (create + update paths).
Nits worth fixing before merge (non-blocking)
- [MED] Misleading comment in
src/app/bond/crud.rs. "Drift is caught by bond integration tests" overstates it — the tests verify value round-trip, not thatpush_bind[N]lines up withBOND_INSERT_COLUMNS[N]. A future field added with a misaligned bind would write to the wrong column and the tests would still pass (SQLite's loose typing hides it). Either add an assertion that bind count == column count, or drop the claim. - [MED] Live duplicate in
src/app/bond/db.rs:74-84.find_bond_by_idreimplementsBond::by_idbyte-for-byte, so the trait'sby_idis never used in production -> future divergence point. Delegatefind_bond_by_idtoBond::by_id. - [LOW]
update()rewritescreated_atevery time (same as before). Consider omitting it from the SET with a comment, so an accidentally-mutatedcreated_atcan't corrupt the row.
Merge gate
CI must be green — it's the only thing this review can't substitute for. With CI green, this is mergeable.
grunch
left a comment
There was a problem hiding this comment.
Approving. No CRITICAL/HIGH issues — the impl Crud for Bond SQL is correct (bind/column order, decode-by-name RETURNING *, full-row UPDATE parity with the old sqlx-crud derive), critical CAS transitions stay as raw atomic UPDATE … WHERE state=? (no new TOCTOU), and the sqlx-crud drop is clean. The three nits in my detailed review (misleading "drift caught by tests" comment, find_bond_by_id duplicating Bond::by_id, created_at rewritten on update) are non-blocking and can be addressed in a follow-up. Merge once CI is green.
Keep sqlx 0.9 / mostro-core 0.14 changes on top of merged #789. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
sqlx-cruddependency from mostrod.mostro-coreto 0.13.2 and route all persistence throughmostro_core::db::CrudforOrder,Dispute, andBond.impl Crud for Bondinsrc/app/bond/crud.rs(directpush_bindchains,QueryBuilder+RETURNING *).Follow-up to mostro-core #154 / #155 (released as 0.13.2).
Test plan
cargo fmt --allcargo clippy --all-targets --all-features -- -D warningscargo test— 496 tests passedcargo buildBond regression coverage:
bond/db,bond/flow, andbond/slashintegration tests exercise create/update paths.Reviewer notes
BondCRUD follows the same style asmostro-coredb/dispute.rs(compile-safe explicit binds, no string-dispatchmatch).sqlx-data.jsonunchanged — no raw SQL query strings were modified.db::Crud).Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores