lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

commit 40877808b5fa742612ace7658611cff6dd7807ee
parent a0b0c1ae5ddc5ea36885339878f4e562a6c87e93
Author: triesap <tyson@radroots.org>
Date:   Tue, 26 May 2026 09:11:48 +0000

local-events: add network source runtime

Diffstat:
Mcrates/local_events/migrations/0000_local_events.up.sql | 2+-
Mcrates/local_events/migrations/0001_change_tracking.down.sql | 2+-
Mcrates/local_events/migrations/0001_change_tracking.up.sql | 2+-
Mcrates/local_events/src/models.rs | 3+++
Mcrates/local_events/tests/store.rs | 21+++++++++++++++++++++
5 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/crates/local_events/migrations/0000_local_events.up.sql b/crates/local_events/migrations/0000_local_events.up.sql @@ -3,7 +3,7 @@ create table if not exists local_event_record ( record_id text not null unique, family text not null check (family in ('local_work', 'signed_event')), status text not null check (status in ('local_draft', 'local_saved', 'pending_publish', 'published', 'failed', 'conflict')), - source_runtime text not null check (source_runtime in ('cli', 'app', 'service', 'worker', 'test')), + source_runtime text not null check (source_runtime in ('cli', 'app', 'network', 'service', 'worker', 'test')), created_at_ms integer not null, inserted_at_ms integer not null, updated_at_ms integer not null, diff --git a/crates/local_events/migrations/0001_change_tracking.down.sql b/crates/local_events/migrations/0001_change_tracking.down.sql @@ -25,7 +25,7 @@ create table local_event_record_previous ( record_id text not null unique, family text not null check (family in ('local_work', 'signed_event')), status text not null check (status in ('local_draft', 'local_saved', 'pending_publish', 'published', 'failed', 'conflict')), - source_runtime text not null check (source_runtime in ('cli', 'app', 'service', 'worker', 'test')), + source_runtime text not null check (source_runtime in ('cli', 'app', 'network', 'service', 'worker', 'test')), created_at_ms integer not null, inserted_at_ms integer not null, updated_at_ms integer not null, diff --git a/crates/local_events/migrations/0001_change_tracking.up.sql b/crates/local_events/migrations/0001_change_tracking.up.sql @@ -4,7 +4,7 @@ create table local_event_record_next ( record_id text not null unique, family text not null check (family in ('local_work', 'signed_event')), status text not null check (status in ('local_draft', 'local_saved', 'pending_publish', 'published', 'failed', 'conflict')), - source_runtime text not null check (source_runtime in ('cli', 'app', 'service', 'worker', 'test')), + source_runtime text not null check (source_runtime in ('cli', 'app', 'network', 'service', 'worker', 'test')), created_at_ms integer not null, inserted_at_ms integer not null, updated_at_ms integer not null, diff --git a/crates/local_events/src/models.rs b/crates/local_events/src/models.rs @@ -106,6 +106,7 @@ impl PublishOutboxStatus { pub enum SourceRuntime { Cli, App, + Network, Service, Worker, Test, @@ -116,6 +117,7 @@ impl SourceRuntime { match self { Self::Cli => "cli", Self::App => "app", + Self::Network => "network", Self::Service => "service", Self::Worker => "worker", Self::Test => "test", @@ -126,6 +128,7 @@ impl SourceRuntime { match value { "cli" => Ok(Self::Cli), "app" => Ok(Self::App), + "network" => Ok(Self::Network), "service" => Ok(Self::Service), "worker" => Ok(Self::Worker), "test" => Ok(Self::Test), diff --git a/crates/local_events/tests/store.rs b/crates/local_events/tests/store.rs @@ -103,6 +103,27 @@ fn append_is_idempotent_by_record_id() { } #[test] +fn source_runtime_network_round_trips() { + let store = store(); + let mut input = signed_event("event-network-a"); + input.source_runtime = SourceRuntime::Network; + + let inserted = store.append_record(&input).expect("append network event"); + let rows = store + .list_records_after_seq(0, 10) + .expect("list network event"); + + assert_eq!(SourceRuntime::Network.as_str(), "network"); + assert_eq!( + SourceRuntime::parse("network").expect("parse network runtime"), + SourceRuntime::Network + ); + assert_eq!(inserted.source_runtime, SourceRuntime::Network); + assert_eq!(rows.len(), 1); + assert_eq!(rows[0].source_runtime, SourceRuntime::Network); +} + +#[test] fn projection_cursor_advances_without_rewinding() { let store = store();