fix(TASK-036): reuse hooks::base_envs_parts in job terminal hook firing

This commit is contained in:
Dark-Alex-17 committed 2026-09-16 13:44:35 -06:00
1 parent 8f775dc2d9
commit 363104fe77
2 files changed
+9 -22

No files matched your search

+8 -21
View File
@@ -22,7 +22,6 @@ use crate::utils::{
}; };
use anyhow::{Context, Result, anyhow, bail}; use anyhow::{Context, Result, anyhow, bail};
use chrono::{SecondsFormat, Utc};
use indexmap::IndexMap; use indexmap::IndexMap;
use parking_lot::{Mutex, RwLock}; use parking_lot::{Mutex, RwLock};
use serde_json::{Value, json}; use serde_json::{Value, json};
@@ -84,9 +83,9 @@ impl JobHookSnapshot {
} }
/// Fires `job.completed` or `job.failed`. `fire_resolved` callers supply /// Fires `job.completed` or `job.failed`. `fire_resolved` callers supply
/// their own base envs, so this mirrors the engine's assembly; the event /// their own base envs; the event name and timestamp are computed here so
/// name and timestamp are computed here so they reflect the actual /// they reflect the actual outcome rather than the moment the snapshot
/// outcome rather than the moment the snapshot was taken. /// was taken.
fn fire_terminal(self, success: bool, error: Option<String>) { fn fire_terminal(self, success: bool, error: Option<String>) {
let (event, resolved) = if success { let (event, resolved) = if success {
(HookEvent::JobCompleted, self.completed) (HookEvent::JobCompleted, self.completed)
@@ -96,23 +95,11 @@ impl JobHookSnapshot {
if resolved.is_empty() { if resolved.is_empty() {
return; return;
} }
let mut base_envs = vec![ let base_envs = hooks::base_envs_parts(
("COYOTE_EVENT".to_string(), event.as_str().to_string()), event,
( self.session_name.as_deref(),
"COYOTE_CONFIG_DIR".to_string(), self.agent_name.as_deref(),
paths::config_dir().display().to_string(), );
),
(
"COYOTE_EVENT_TIMESTAMP".to_string(),
Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true),
),
];
if let Some(name) = self.session_name {
base_envs.push(("COYOTE_SESSION_ID".to_string(), name));
}
if let Some(name) = self.agent_name {
base_envs.push(("COYOTE_AGENT_NAME".to_string(), name));
}
let mut extras = vec![ let mut extras = vec![
("COYOTE_JOB_ID", self.job_id), ("COYOTE_JOB_ID", self.job_id),
("COYOTE_TOOL_NAME", self.tool), ("COYOTE_TOOL_NAME", self.tool),
+1 -1
View File
@@ -325,7 +325,7 @@ fn base_envs(event: HookEvent, ctx: &RequestContext) -> Vec<(String, String)> {
) )
} }
fn base_envs_parts( pub(crate) fn base_envs_parts(
event: HookEvent, event: HookEvent,
session_name: Option<&str>, session_name: Option<&str>,
agent_name: Option<&str>, agent_name: Option<&str>,