feat: persist events across commit boundaries

This commit is contained in:
2026-08-31 09:35:20 +00:00
parent 43dcd56313
commit 583b539f86
7 changed files with 722 additions and 14 deletions
+8 -3
View File
@@ -102,8 +102,12 @@ CREATE TABLE command_events (
event_seq INTEGER NOT NULL CHECK(event_seq > 0), observed_at INTEGER NOT NULL, server_receipt_time INTEGER NOT NULL,
event_type INTEGER NOT NULL, compression INTEGER NOT NULL CHECK(compression IN (1,2)),
raw_bytes INTEGER NOT NULL CHECK(raw_bytes >= 0), stored_bytes INTEGER NOT NULL CHECK(stored_bytes >= 0),
payload BLOB NOT NULL, immutable_sha256 BLOB NOT NULL CHECK(length(immutable_sha256) = 32),
PRIMARY KEY(issue_uuid, event_seq)
payload BLOB, segment_ordinal INTEGER, segment_record_offset INTEGER, segment_record_length INTEGER,
immutable_sha256 BLOB NOT NULL CHECK(length(immutable_sha256) = 32),
PRIMARY KEY(issue_uuid, event_seq),
CHECK((payload IS NOT NULL AND segment_ordinal IS NULL AND segment_record_offset IS NULL AND segment_record_length IS NULL) OR
(payload IS NULL AND segment_ordinal >= 0 AND segment_record_offset >= 0 AND segment_record_length > 0)),
FOREIGN KEY(issue_uuid, segment_ordinal) REFERENCES output_segments(issue_uuid, ordinal) ON DELETE CASCADE
) STRICT, WITHOUT ROWID;
CREATE TABLE output_segments (
issue_uuid BLOB NOT NULL REFERENCES commands(issue_uuid) ON DELETE CASCADE,
@@ -111,7 +115,8 @@ CREATE TABLE output_segments (
min_event_seq INTEGER NOT NULL, max_event_seq INTEGER NOT NULL CHECK(max_event_seq >= min_event_seq),
stream_mix INTEGER NOT NULL CHECK(stream_mix >= 0),
compressed_bytes INTEGER NOT NULL CHECK(compressed_bytes >= 0), raw_bytes INTEGER NOT NULL CHECK(raw_bytes >= 0),
checksum BLOB NOT NULL CHECK(length(checksum) = 32), created_at INTEGER NOT NULL,
checksum BLOB CHECK(checksum IS NULL OR length(checksum) = 32), sealed INTEGER NOT NULL DEFAULT 0 CHECK(sealed IN (0,1)),
created_at INTEGER NOT NULL,
PRIMARY KEY(issue_uuid, ordinal), UNIQUE(path)
) STRICT, WITHOUT ROWID;
CREATE TABLE output_truncations (