mirror of
https://github.com/block/buzz.git
synced 2026-10-31 22:41:12 +00:00
wip(workflows): preserve durable inbox foundation
Checkpoint the Node B persistence and provenance boundary before producer and API integration. Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: loganj <loganj@squareup.com>
This commit is contained in:
@@ -411,6 +411,36 @@ CREATE TABLE workflow_runs (
|
||||
CREATE INDEX idx_workflow_runs_workflow ON workflow_runs (community_id, workflow_id);
|
||||
CREATE INDEX idx_workflow_runs_status ON workflow_runs (community_id, status);
|
||||
|
||||
-- Durable, target-scoped inbox for workflow messages addressed to managed agents.
|
||||
CREATE TABLE workflow_agent_deliveries (
|
||||
community_id UUID NOT NULL REFERENCES communities(id),
|
||||
id UUID NOT NULL,
|
||||
workflow_id UUID NOT NULL,
|
||||
run_id UUID NOT NULL,
|
||||
step_id VARCHAR(64) NOT NULL,
|
||||
definition_event_id BYTEA NOT NULL CHECK (octet_length(definition_event_id) = 32),
|
||||
message_event_id BYTEA NOT NULL CHECK (octet_length(message_event_id) = 32),
|
||||
message_event_created_at TIMESTAMPTZ NOT NULL,
|
||||
channel_id UUID NOT NULL,
|
||||
target_pubkey BYTEA NOT NULL CHECK (octet_length(target_pubkey) = 32),
|
||||
status workflow_agent_delivery_status NOT NULL DEFAULT 'pending',
|
||||
claim_token UUID,
|
||||
claimed_at TIMESTAMPTZ,
|
||||
execution_trace JSONB NOT NULL,
|
||||
trigger_context JSONB,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
PRIMARY KEY (community_id, id),
|
||||
UNIQUE (community_id, run_id, step_id, target_pubkey),
|
||||
FOREIGN KEY (community_id, workflow_id) REFERENCES workflows (community_id, id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (community_id, run_id) REFERENCES workflow_runs (community_id, id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (community_id, message_event_created_at, message_event_id)
|
||||
REFERENCES events (community_id, created_at, id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE INDEX idx_workflow_agent_deliveries_pending
|
||||
ON workflow_agent_deliveries (community_id, target_pubkey, created_at)
|
||||
WHERE status = 'pending';
|
||||
|
||||
-- ── Workflow approvals ────────────────────────────────────────────────────────
|
||||
-- token-hash lookup scoped: approval token grants cannot act on another
|
||||
-- community's same hash (conformance).
|
||||
@@ -1749,6 +1779,7 @@ SELECT attach_community_write_fence('scheduled_workflow_fires');
|
||||
SELECT attach_community_write_fence('subscriptions');
|
||||
SELECT attach_community_write_fence('thread_metadata');
|
||||
SELECT attach_community_write_fence('users');
|
||||
SELECT attach_community_write_fence('workflow_agent_deliveries');
|
||||
SELECT attach_community_write_fence('workflow_approvals');
|
||||
SELECT attach_community_write_fence('workflow_runs');
|
||||
SELECT attach_community_write_fence('workflows');
|
||||
|
||||
Reference in New Issue
Block a user