Repository navigation
feat(commands): carry payloads, state, results, and effects as Bytes blobs - #508
Merged
Merged
Conversation
…blobs handle now takes Bytes.Bytes for the payload, state, result, and effect, and stores them as SQLite BLOBs, so a webhook body with a NUL byte round-trips and deduplicates. step is generic over affine types: it takes dup_p and dup_r to copy the payload and result of a new command, and a refusal answers Note (record only) instead of rewriting the old state. Closes #504
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.
Summary
commandsnow carries payloads, state, results, and effects asBytes.Bytes, stored as SQLite BLOBs. A webhook body goes in as it arrives, with no conversion to a byteString, and a payload with a NUL byte now round-trips and deduplicates. SQLite's text binding rejected NUL before.This is a breaking change:
commandsgoes to 0.2.0.0. A 0.1 database stores TEXT where 0.2 reads BLOBs, so 0.2 needs a new file. The README says so.Design decision: affine
step, not a Data stand-inBytesis affine (Type), so it cannot sit in the oldDatarecords. The issue offered two choices. I took a third:stepand its types are now generic overType. The laws keep their full strength over the real payload. A digest key would have proven facts about the digest only.An affine
stepcannot use a value twice, so two things changed:steptakes~dup_pand~dup_r. A new command's payload goes todecideand to the record. Its result goes to the record and to the reply.handlepassesdup(Array.clone). Copies happen only for new commands, not duplicates.Note{record, reply}and writes no state row. Before, it answeredWritewith the old state.decideconsumes the state, and rewriting an unchanged row did nothing anyway.Law changes (
LAWS.bend)Typeand take~dup_pand~dup_r.accept_recorded,refuse_keeps_state, andretry_replaysassumecopy_pandcopy_r:dup(x) == (x, x).refuse_keeps_statenow expectsNote{Record{p, Refused{r}, at}, Fresh{Refused{r}}}.retriedtakes the kept state for theNotecase.PROOF.bendproves all five.Bytes.eqreflexivity and theArray.clonecopy fact are trust assumptions, listed in the README trust boundary.eqwas already one before this change.Verification
scripts/check.sh commands: the laws hold, andcheck.bendpasses. It has a new case: an event with a NUL byte is recorded, its retry replays, and a payload that differs only after the NUL byte is a conflict.scripts/publish.sh --check:[email protected] will publish.scripts/pins.shpasses.Closes #504