From 8e0855994f395a6c30dd5c32a4bdf33b15239e5a Mon Sep 17 00:00:00 2001 From: Logan Johnson Date: Tue, 25 Aug 2026 10:53:33 -0400 Subject: [PATCH] fix(db): integrate delivery inbox into deletion and schema surfaces Migration 0034 introduced workflow_agent_deliveries without wiring the four integration surfaces that pin new tenant tables: - schema.sql desired-state bootstrap lacked the workflow_agent_delivery_status enum the inline table definition uses, so desired-state apply failed with 'type does not exist'. - EXPECTED_SCOPED_TABLES / PURGE_SCOPED_TABLES omitted the table, so the deletion catalog inventory failed closed on 'unknown' drift (by design) across the deletion suite; purge order puts the delivery inbox before its workflow_runs/workflows/events parents. - The embedded-migrator count pin still said 33. - The 0029/schema.sql fence-parity test did not account for 0034 attaching the community write fence to the new table. Also restore the doc comment on KIND_WORKFLOW_DEF: the wake-kind constant was inserted between the comment and its item, leaving KIND_WORKFLOW_DEF undocumented and failing clippy -D missing-docs. Co-authored-by: Wakko <0999168a3b1a4dabdf398cf43ba2893bb29b74dc06d0b31c2d3b51dbebea1612@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson --- crates/buzz-core/src/kind.rs | 2 +- crates/buzz-db/src/deletion.rs | 2 ++ crates/buzz-db/src/migration.rs | 6 +++++- schema/schema.sql | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/buzz-core/src/kind.rs b/crates/buzz-core/src/kind.rs index 06fc320ac0..578ad6ded5 100644 --- a/crates/buzz-core/src/kind.rs +++ b/crates/buzz-core/src/kind.rs @@ -443,10 +443,10 @@ pub const KIND_THREAD_SUMMARY: u32 = 39005; /// clients must not infer `has_more` from row counts. pub const KIND_WINDOW_BOUNDS: u32 = 39006; -/// Workflow definition (parameterized replaceable, d=workflow_uuid). /// Ephemeral, relay-authored hint that a durable workflow delivery is ready. pub const KIND_WORKFLOW_AGENT_WAKE: u32 = 24620; +/// Workflow definition (parameterized replaceable, d=workflow_uuid). pub const KIND_WORKFLOW_DEF: u32 = 30620; /// NIP-DV: per-viewer DM visibility snapshot (relay-signed, parameterized diff --git a/crates/buzz-db/src/deletion.rs b/crates/buzz-db/src/deletion.rs index fbe69f22a6..60f518bffc 100644 --- a/crates/buzz-db/src/deletion.rs +++ b/crates/buzz-db/src/deletion.rs @@ -79,6 +79,7 @@ pub const EXPECTED_SCOPED_TABLES: &[&str] = &[ "subscriptions", "thread_metadata", "users", + "workflow_agent_deliveries", "workflow_approvals", "workflow_runs", "workflows", @@ -86,6 +87,7 @@ pub const EXPECTED_SCOPED_TABLES: &[&str] = &[ /// Foreign-key-safe child-before-parent order for the PostgreSQL purge. pub const PURGE_SCOPED_TABLES: &[&str] = &[ + "workflow_agent_deliveries", "workflow_approvals", "scheduled_workflow_fires", "workflow_runs", diff --git a/crates/buzz-db/src/migration.rs b/crates/buzz-db/src/migration.rs index 80be5328d3..c37006d061 100644 --- a/crates/buzz-db/src/migration.rs +++ b/crates/buzz-db/src/migration.rs @@ -640,7 +640,7 @@ mod tests { let mut migrations: Vec<_> = MIGRATOR.iter().collect(); migrations.sort_by_key(|migration| migration.version); - assert_eq!(migrations.len(), 33); + assert_eq!(migrations.len(), 34); assert_eq!(migrations[0].version, 1); assert_eq!(&*migrations[0].description, "initial schema"); assert!(migrations[0] @@ -1549,6 +1549,10 @@ mod tests { let mut expected_fences = migration.fence_attachments.clone(); expected_fences.remove("product_feedback"); expected_fences.remove("rate_limit_violations"); + // Migration 0034 attaches the fence to the durable managed-agent + // delivery inbox after 0029; the desired-state schema carries it + // inline. + expected_fences.insert("workflow_agent_deliveries".to_owned()); assert_eq!( expected_fences, schema.fence_attachments, "write-fence attachment targets differ after recovery policy" diff --git a/schema/schema.sql b/schema/schema.sql index 2eab7e137a..69d3173af3 100644 --- a/schema/schema.sql +++ b/schema/schema.sql @@ -35,6 +35,7 @@ CREATE TYPE delivery_method AS ENUM ('webhook', 'websocket'); CREATE TYPE subscription_status AS ENUM ('active', 'paused', 'deleted'); CREATE TYPE pause_reason AS ENUM ('user', 'system', 'rate_limit'); CREATE TYPE channel_add_policy AS ENUM ('anyone', 'owner_only', 'nobody'); +CREATE TYPE workflow_agent_delivery_status AS ENUM ('pending', 'claimed'); -- ── Communities ─────────────────────────────────────────────────────────────── -- Conformance: row zero (host binding). The host map. `resolve_host(host)`