Repository navigation
feat(parser): read transact and retract one fact at a time; cow_update (#550 PR 1) - #684
Merged
Merged
Conversation
#550) PR 1 of #550 (streaming transactions), no change in behaviour. The parser reads tokens on demand from a Lexer instead of a whole-input Vec<Token>. transact and retract go to a statement reader that holds one fact at a time and keeps today's error order: errors are found in phases (tokens, EDN structure, the command, each fact, materialisation, valid windows), and the reader reports the first error of the earliest phase, with the command phase in today's check order. Pass 1 keeps at most TX_CHUNK_FACTS materialised facts; a larger statement is read again (pass 2) from the offset after the last kept fact. Every statement still takes the small path: Statement::facts appends pass 2's chunks. Materialisation and window errors come with the facts, so a read-only database still reports API-014 before them. btree::cow_update applies sorted deletes and inserts copy-on-write in one descent: a leaf or internal node left empty leaves its parent, a tree left empty is root 0, and a delete of a missing key is INT-049. cow_insert is cow_update with no deletes. Differential tests run the old whole-input parser (kept under cfg(test)) against the reader at chunk sizes 1-3; property tests check cow_update against a BTreeSet model. Plan: docs/superpowers/plans/2026-10-21-550-streaming-transactions.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…wasm32 (#550) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT
10 tasks
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.
PR 1 of 3 for #550 (streaming transactions, part of #473). Spec:
docs/superpowers/specs/2026-10-21-streaming-transactions-design.md(#683). Plan:docs/superpowers/plans/2026-10-21-550-streaming-transactions.md(added here).No change in behaviour: every statement still takes the small path.
Parser (spec §3)
Parserreads tokens on demand from aLexer(byte offsets, keeps its first error);parse_ednfinishes lexing before reporting, so a lexer error still beats a structure error. Akeepflag checks structure without holding values.transact/retractgo toparser/statement.rs, which holds one fact at a time and reports today's error: the first error of the earliest phase (tokens, structure, command, fact, materialisation, valid windows). Phase 3 runs in today's check order, which is not text order (PRS-075beforePRS-042).read_statement(pass 1) keeps at mostTX_CHUNK_FACTS(16,384 until PR 3's measurement) materialised facts. A larger statement is read again (pass 2) from the offset after the last kept fact;Statement::factsappends the chunks for now.Minigraf::executestill givesAPI-014on a read-only database before them.B+tree (spec §6)
btree::cow_update(root, inserts, deletes, …): deletes then inserts in one copy-on-write descent. An emptied leaf or internal node leaves its parent, an emptied tree is root 0, a missing/unsorted/repeated delete isINT-049.cow_insertiscow_updatewith no deletes.Deviations from the spec (plan decisions 6, 7, 11)
TX_CHUNK_FACTSfacts, not+ 1, and marks the statement large when one more follows; the acceptance bound then holds exactly.Statement::factsto keep the read-only order.PageAllocator::releasemoves to PR 2, its first caller.Tests
cfg(test)) against the reader over every 0–3 token sequence of 34 statement tokens in 10 templates plus a multi-error corpus, same command or error, and the same facts or error through the write path at chunk sizes 1, 2, 3 and default; asserts 24 codes are reached and pass 2 runs.cow_updateproperty tests against aBTreeSetmodel (0–60K keys, random and contiguous deletes), verify-style walk each step, old pages unchanged,freedexact; delete-all → root 0.🤖 Generated with Claude Code
https://claude.ai/code/session_019kY61Y11gcRD91Y6b7jbGT