From c74e31798b96577933718676adb17c7ada7d52ef Mon Sep 17 00:00:00 2001 From: Trezy Date: Thu, 07 May 2026 16:48:54 +0000 Subject: [PATCH] fix: add success and dead-letter logging to label scripts Signed-off-by: Trezy --- src/lua/scripts.rs | 38 +++++++++++++++++++++++++++++++++++++- 1 file(s) changed, 37 insertion(s)(+), 1 deletion(s)(-) diff --git a/src/lua/scripts.rs b/src/lua/scripts.rs --- a/src/lua/scripts.rs +++ b/src/lua/scripts.rs @@ -540,7 +540,26 @@ let delay = std::time::Duration::from_secs(1 << (attempt - 1)); tokio::time::sleep(delay).await; } match run_label_lua_once(state, &resolved, &event).await { - Ok(outcome) => return outcome, + Ok(outcome) => { + log_event( + &state.db, + EventLog { + event_type: "script.executed".to_string(), + severity: Severity::Info, + actor_did: None, + subject: Some(event.uri.clone()), + detail: serde_json::json!({ + "host_kind": "label", + "host_id": host_id, + "trigger": resolved.id, + "attempts": attempt + 1, + }), + }, + state.db_backend, + ) + .await; + return outcome; + } Err(e) => { last_error = e; tracing::warn!( @@ -568,6 +587,23 @@ error: &last_error, attempts: MAX_ATTEMPTS, collection, }, + ) + .await; + log_event( + &state.db, + EventLog { + event_type: "script.dead_lettered".to_string(), + severity: Severity::Error, + actor_did: None, + subject: Some(event.uri.clone()), + detail: serde_json::json!({ + "host_kind": "label", + "host_id": host_id, + "trigger": resolved.id, + "error": last_error, + }), + }, + state.db_backend, ) .await; LabelHookOutcome::Continue(original) -- tangled.sh