Skip to content

feat(database): read bounded conversation patch replay - #322

Draft
sandersonstabo wants to merge 4 commits into
agent/backend-startup-reconciliation-sweep-port-1a5eff2from
agent/database-conversation-patch-replay-port-86287f9
Draft

feat(database): read bounded conversation patch replay#322
sandersonstabo wants to merge 4 commits into
agent/backend-startup-reconciliation-sweep-port-1a5eff2from
agent/database-conversation-patch-replay-port-86287f9

Conversation

@sandersonstabo

@sandersonstabo sandersonstabo commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Depends on #321.

Scope

  • add a one-transaction, per-thread durable conversation patch replay reader
  • return typed Current, bounded contiguous Batch (max 64), or ResnapshotRequired outcomes
  • reconstruct all five domain patch variants with the accepted E2/E5 timestamp and revision mapping
  • reject gaps, malformed durable payloads, and content-leaking corruption paths
  • add 12 focused database tests for bounds, cursors, all variants, isolation, gaps, and corruption defense

Verification

  • focused Bazel database/test build with jobs=1
  • //tests/database:conversation_patch_replay_test (all 12 cases)
  • fresh production and integration-test Clippy markers
  • //:format_test
  • cargo metadata --locked --offline --no-deps
  • exact eight-path hash/status/diff guards and Bazel shutdown 0

Exclusions / remaining work

  • no backend RequestHandler subscribe/unsubscribe wiring
  • no SessionDelivery publication loop or notifier
  • no transport/client/frontend changes
  • no startup/custody/provider policy

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Adds a bounded, transactionally consistent conversation patch replay reader to the database module. The reader returns typed Current, contiguous Batch (max 64), or ResnapshotRequired outcomes, reconstructs all five patch variants, and rejects gaps and malformed payloads.

  • Corruption errors use fixed strings instead of interpolated persisted values so they cannot leak patch content.
  • Adds 12 database tests covering bounds, cursors, variants, isolation, gaps, corruption, and error-content leakage.
  • Registers the reader and its test target in Bazel and Cargo.
  • Not yet wired to the backend request handler, session delivery, transport, or frontend.

Written for commit f945d8e. Summary will update on new commits.

Review in cubic

Add Repository::read_conversation_patch_replay with transactional
Current/Batch/ResnapshotRequired semantics, capped at 64 patches,
contiguity and corruption checks, five-variant reconstruction with
E2/E5 stamp mapping. Add focused in-memory tests covering
ThreadNotFound/Current/Resnapshot, capping, round-trip of all five
variants, mid-tail isolation, gaps, and malformed payload defense.
…onstraint fixtures (E5a-c1)

Replace interpolated patch/item/lifecycle/phase/thread identifiers in
CorruptData reasons with fixed strings; counters/timestamps remain.
Use scoped PRAGMA ignore_check_constraints=ON for negative revision/
zero sequence/negative tail and oversized body fixtures, restoring OFF
after each, keeping foreign_keys toggle only for FK violations. Add
sentinel leak assertions for unknown kinds/phases/lifecycle/thread
mismatch. Remove uncompiled-test commentary and prove execution via
temporary registration: 12/12 conversation_patch_replay tests pass,
clippy pedantic clean for lib and owned test.

Co-authored-by: Muse Spark
…5a-c2)

Remove crate-wide #![allow(clippy::pedantic)] and dead START_KEY_BYTES
const, replace entities::{self} import shape, fix uninlined_format_args,
cast_possible_truncation, wildcard and manual_let_else diagnostics with
ordinary code. Add narrow function-scoped allows only for intrinsically
large fixtures (all_five_variants_round_trip, sentinel_enum) with
concrete reasons. Preserve 12 passing behaviors and sentinel hygiene.
@sandersonstabo
sandersonstabo force-pushed the agent/database-conversation-patch-replay-port-86287f9 branch from 53c9c76 to f945d8e Compare August 29, 2026 10:10
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