mirror of
https://github.com/block/buzz.git
synced 2026-11-28 04:01:45 +00:00
Wake agents from verified workflow mentions
Signed-off-by: Logan Johnson <loganj@squareup.com> Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <loganj@squareup.com>
This commit is contained in:
@@ -7,6 +7,21 @@ use std::future::Future;
|
||||
use std::pin::Pin;
|
||||
|
||||
use buzz_core::tenant::CommunityId;
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Workflow authority carried into a message side effect.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WorkflowMessageContext {
|
||||
/// Server-resolved community that owns the workflow run.
|
||||
pub community_id: CommunityId,
|
||||
/// Exact workflow run driving this side effect.
|
||||
pub run_id: Uuid,
|
||||
/// Exact signed-definition step being executed.
|
||||
pub step_id: String,
|
||||
/// Exact signed definition selected when the run was created, or `None`
|
||||
/// for a legacy run that must not emit an automatic wake.
|
||||
pub definition_event_id: Option<Vec<u8>>,
|
||||
}
|
||||
|
||||
/// Errors from action sink operations.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -48,11 +63,8 @@ impl From<ActionSinkError> for crate::WorkflowError {
|
||||
pub trait ActionSink: Send + Sync {
|
||||
/// Post a message to a channel on behalf of a workflow owner.
|
||||
///
|
||||
/// - `community_id`: the server-resolved community that owns the workflow
|
||||
/// run driving this side effect. The relay-signed message is published
|
||||
/// under *this* community, never the deployment/default tenant — the run
|
||||
/// carries its owning community so a workflow in community B posts into B
|
||||
/// even though the side effect has no inbound connection to bind.
|
||||
/// - `context`: exact workflow authority driving this side effect, including
|
||||
/// the server-resolved community and optional signed-definition revision
|
||||
/// - `channel_id`: UUID string of the target channel
|
||||
/// - `text`: rendered message body (must not be empty/whitespace-only)
|
||||
/// - `authored_text`: the workflow owner's stored, unrendered step template;
|
||||
@@ -67,7 +79,7 @@ pub trait ActionSink: Send + Sync {
|
||||
/// Returns the event ID hex string on success.
|
||||
fn send_message(
|
||||
&self,
|
||||
community_id: CommunityId,
|
||||
context: WorkflowMessageContext,
|
||||
channel_id: &str,
|
||||
text: &str,
|
||||
authored_text: &str,
|
||||
|
||||
@@ -18,6 +18,7 @@ use serde_json::Value as JsonValue;
|
||||
use tracing::{debug, info, warn};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::action_sink::WorkflowMessageContext;
|
||||
use crate::error::WorkflowError;
|
||||
use crate::schema::{ActionDef, Step, WorkflowDef};
|
||||
use crate::WorkflowEngine;
|
||||
@@ -636,7 +637,12 @@ pub async fn dispatch_action(
|
||||
let event_id = engine
|
||||
.action_sink()?
|
||||
.send_message(
|
||||
community_id,
|
||||
WorkflowMessageContext {
|
||||
community_id,
|
||||
run_id,
|
||||
step_id: step_id.to_owned(),
|
||||
definition_event_id: wf_run.definition_event_id.clone(),
|
||||
},
|
||||
&channel_id,
|
||||
text,
|
||||
authored_text,
|
||||
|
||||
Reference in New Issue
Block a user