feat: enforce client spool quota tiers
This commit is contained in:
@@ -60,6 +60,9 @@ CREATE TABLE commands (
|
||||
command_revision INTEGER NOT NULL CHECK(command_revision > 0),
|
||||
phase INTEGER NOT NULL CHECK(phase BETWEEN 1 AND 11),
|
||||
terminal INTEGER NOT NULL DEFAULT 0 CHECK(terminal IN (0, 1)),
|
||||
output_charged_bytes INTEGER NOT NULL DEFAULT 0 CHECK(output_charged_bytes >= 0),
|
||||
total_charged_bytes INTEGER NOT NULL CHECK(total_charged_bytes >= 0),
|
||||
closeout_remaining_bytes INTEGER NOT NULL CHECK(closeout_remaining_bytes >= 0),
|
||||
next_local_ordinal INTEGER NOT NULL DEFAULT 1 CHECK(next_local_ordinal > 0),
|
||||
next_event_seq INTEGER NOT NULL DEFAULT 1 CHECK(next_event_seq > 0),
|
||||
last_server_ack INTEGER NOT NULL DEFAULT 0 CHECK(last_server_ack >= 0),
|
||||
@@ -72,6 +75,8 @@ CREATE TABLE events (
|
||||
event_kind INTEGER NOT NULL CHECK(event_kind > 0),
|
||||
compression INTEGER NOT NULL CHECK(compression IN (1, 2)),
|
||||
raw_bytes INTEGER NOT NULL CHECK(raw_bytes >= 0),
|
||||
charged_bytes INTEGER NOT NULL CHECK(charged_bytes > 0),
|
||||
output INTEGER NOT NULL CHECK(output IN (0, 1)),
|
||||
payload BLOB NOT NULL,
|
||||
payload_sha256 BLOB NOT NULL CHECK(length(payload_sha256) = 32),
|
||||
created_at INTEGER NOT NULL,
|
||||
@@ -79,6 +84,12 @@ CREATE TABLE events (
|
||||
UNIQUE(issue_uuid, event_seq)
|
||||
) STRICT, WITHOUT ROWID;
|
||||
CREATE INDEX events_send_window ON events(issue_uuid, event_seq, local_ordinal);
|
||||
CREATE TABLE spool_counters (
|
||||
singleton INTEGER PRIMARY KEY CHECK(singleton = 1),
|
||||
client_total_charged_bytes INTEGER NOT NULL CHECK(client_total_charged_bytes >= 0),
|
||||
charge_version INTEGER NOT NULL CHECK(charge_version = 1)
|
||||
) STRICT;
|
||||
INSERT INTO spool_counters(singleton, client_total_charged_bytes, charge_version) VALUES (1, 0, 1);
|
||||
CREATE TABLE command_tombstones (
|
||||
issue_uuid BLOB PRIMARY KEY CHECK(length(issue_uuid) = 16),
|
||||
immutable_sha256 BLOB NOT NULL CHECK(length(immutable_sha256) = 32),
|
||||
|
||||
Reference in New Issue
Block a user