Repository navigation
Rebuild bus projections from one joined cursor with carried claim holders - #2666
Merged
2 commits merged intoOct 23, 2026
Merged
2 commits merged into
2 commits merged into
Conversation
trissim
marked this pull request as ready for review
October 23, 2026 07:59
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
debt-src at 5d5290c, every finding: |
trissim
force-pushed
the
fix/projection-stream
branch
from
October 23, 2026 08:01
3aef4be to
0dcf1f3
Compare
BusProjectionTables.create_schema replayed history with one header stream plus one point SELECT per capability table per record (read_from), each through the strict decode boundary. On a copy of the live bus (19,448 records) that replay took 46.5 s; the joined cursor takes 37.7 s with identical projection rows. Writes are not the remaining cost: a profile puts all projection inserts at about 6 s. The rest is decoding records and replaying claim transitions. BusCapability.history reads every record in sequence order from one cursor: the history header LEFT JOINed to each capability table (members derived from TypedTable.members_with(CapabilityRow)), each stored row decoded once at its column offset. read_from and history share one assembly step (BusCapability.assembled). The per-row replay loop in create_schema is deleted; the projection stamp is unchanged. TypedTable gains qualified() and decode_at() so a select joining tables that share column names decodes each table's slice by declaration order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every replayed claim called HeldResources.claims_for, which reselected and fully decoded the current holders' Claimed rows that the same in-order pass had already decoded. HeldResources.project and apply now take a ClaimHolders member: StoredHolders reads the holders of one live append from their table (the read a separate append transaction needs); ReplayedHolders, owned by create_schema's pass, carries the owners it already projected and never rereads them. apply stays the one owner of which resources leave and hands that set to the holders. The Claimed.replay_claim split is folded into project_into. On a copy of the live bus (19,457 records), the same joined-cursor pass with stored holders took 41.5 s and with carried holders 34.5 s; every projection table's contents are identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
trissim
force-pushed
the
fix/projection-stream
branch
from
October 23, 2026 08:13
0dcf1f3 to
ddda841
Compare
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.
Defect
BusProjectionTables.create_schemarebuilds every bus projection whenever the Core commit changes. Two parts of that replay did needless work:kind.read_from(db, seq)issued one point SELECT per capability table for every record, each through the strict decode boundary.HeldResources.claims_for. That reselected and fully decoded the current holders'Claimedrows, which the same in-order pass had already decoded.Fix
Commit 1: one joined cursor.
BusCapability.history(db)reads every record in sequence order from one cursor: the history header LEFT JOINed to each capability table onseq. The table set is derived fromTypedTable.members_with(CapabilityRow). Each stored row is decoded once, at its column offset.read_fromandhistoryshare one assembly step,BusCapability.assembled.TypedTable.qualified()anddecode_at()let one select join tables that share column names and decode each table's slice.Commit 2: carried claim holders.
HeldResources.projectandapplytake aClaimHoldersmember.StoredHoldersreads the holders of one live append from their table. That read is required: each append is its own transaction.ReplayedHolders, owned by thecreate_schemapass, carries the owners it already projected and never rereads them.applystays the one owner of which resources leave, and hands that set to the holders.Deleted
BusRow.stream+header.kind.read_from(db, header.seq)replay increate_schema.read_from.claims_forreread during the rebuild.Claimed.replay_claim, folded intoproject_into.Not changed
ProjectionProducer.records_for: the commit stamp is kept. Stamp derived projections and index answer eligibility at append #2636 replaced per-class producer identities with it so that derived rows can't survive a change to the code that produces them while the SQL stays equal. Those producers are selected at runtime by role, type and reply scope (messages.py:413-414,bus_publication.py:57,read_basis.py:866), so a per-declaration stamp would need a hand-written producer list.Measurements
All runs were niced, on backup-API copies of the live
bus.sqlite3. Each deleted every projection table, replayed all records and rolled back.read_from(main)received_source, at 96,786 rows, is 2.7 s of that.FieldCodec) and replaying claim transitions.No pytest was run here; the integrator tests this once on
integration.tests/test_bus_resource_claims.py:188now replays throughReplayedHoldersand compares against the live projection.🤖 Generated with Claude Code