fix(#1953): route approval helper-events to the submitter, not the root agent

This commit is contained in:
damocles 2026-06-23 20:09:40 +02:00 committed by mara
commit 3618399d94
7 changed files with 187 additions and 73 deletions

View file

@ -989,7 +989,7 @@ async fn handle_request_apply_commit(
return err;
}
tracing::info!(%agent, %target_agent, %commit_ref, "request_apply_commit");
match submit_apply_commit(coord, target_agent, commit_ref, description).await {
match submit_apply_commit(coord, target_agent, commit_ref, description, agent).await {
Ok((id, sha)) => {
tracing::info!(%id, %target_agent, %sha, "apply_commit approval queued");
AgentResponse::Ok
@ -1427,6 +1427,7 @@ fn handle_request_update_meta_inputs(
hive_sh4re::ApprovalKind::UpdateMetaInputs,
&commit_ref,
description,
requester,
)
.map_err(|e| anyhow::anyhow!("{e:#}"))
{
@ -1527,6 +1528,7 @@ fn handle_request_schedule_prompt(
hive_sh4re::ApprovalKind::SchedulePrompt,
&commit_ref,
payload.description.as_deref(),
requester,
) {
Ok(id) => id,
Err(e) => {
@ -1801,6 +1803,10 @@ pub(crate) fn submit_init_config(
hive_sh4re::ApprovalKind::InitConfig,
parent.unwrap_or(""),
description.as_deref(),
// `parent` is the requesting agent (becomes the new child's
// parent); it's also the submitter the approval events route
// back to. No declared parent = operator/root path.
parent.unwrap_or(hive_sh4re::MANAGER_AGENT),
)
.map_err(|e| anyhow::anyhow!("queue approval row: {e:#}"))?;
tracing::info!(%id, %name, "init_config approval queued");
@ -1832,6 +1838,7 @@ pub(crate) async fn submit_apply_commit(
agent: &str,
commit_ref: &str,
description: Option<&str>,
submitter: &str,
) -> anyhow::Result<(i64, String)> {
validate_commit_ref(commit_ref)?;
let proposed_dir = crate::coordinator::Coordinator::agent_proposed_dir(agent);
@ -1859,6 +1866,7 @@ pub(crate) async fn submit_apply_commit(
hive_sh4re::ApprovalKind::ApplyCommit,
commit_ref,
description,
submitter,
)
.map_err(|e| anyhow::anyhow!("queue approval row: {e:#}"))?;
let tag = format!("proposal/{id}");