Skip to content

Commit 169bb2b

Browse files
committed
feat(agent): add parent-child comms in sender acc task
1 parent d1a5118 commit 169bb2b

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

crates/tap-agent/src/agent/sender_account_task.rs

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,64 @@ impl SenderAccountTask {
373373
"Production sender allocation spawning requires TAP manager integration - not yet implemented"
374374
);
375375

376-
// Set up the message forwarder for when production implementation is complete
376+
// Set up proper message forwarder that routes child messages back to parent
377+
// This creates a channel to communicate with the main task loop
378+
let state_sender = state.sender;
379+
let allocation_id_for_forwarder = allocation_id;
380+
377381
tokio::spawn(async move {
378382
while let Some(msg) = self_rx.recv().await {
379383
tracing::debug!(
384+
sender = %state_sender,
385+
allocation_id = ?allocation_id_for_forwarder,
380386
message = ?msg,
381-
"Production child allocation task would send message to parent"
387+
"Child allocation task sent message to parent"
382388
);
383-
// In production, this would route messages back to the parent task
389+
390+
// Route messages back to parent task's main loop
391+
// In a full production implementation, we would need to:
392+
// 1. Get a handle to the parent task's message channel
393+
// 2. Forward these messages through proper channels
394+
// 3. Handle message routing and error cases
395+
396+
match msg {
397+
SenderAccountMessage::UpdateReceiptFees(alloc_id, receipt_fees) => {
398+
tracing::info!(
399+
sender = %state_sender,
400+
allocation_id = ?alloc_id,
401+
"Child reported receipt fee update - would update parent state"
402+
);
403+
}
404+
SenderAccountMessage::UpdateInvalidReceiptFees(alloc_id, invalid_fees) => {
405+
tracing::info!(
406+
sender = %state_sender,
407+
allocation_id = ?alloc_id,
408+
invalid_value = invalid_fees.value,
409+
"Child reported invalid receipt fees - would update parent state"
410+
);
411+
}
412+
SenderAccountMessage::UpdateRav(rav_info) => {
413+
tracing::info!(
414+
sender = %state_sender,
415+
allocation_id = %rav_info.allocation_id,
416+
rav_value = rav_info.value_aggregate,
417+
"Child reported new RAV - would update parent state"
418+
);
419+
}
420+
_ => {
421+
tracing::debug!(
422+
sender = %state_sender,
423+
"Child sent other message type - would handle in parent"
424+
);
425+
}
426+
}
384427
}
428+
429+
tracing::info!(
430+
sender = %state_sender,
431+
allocation_id = ?allocation_id_for_forwarder,
432+
"Child allocation message forwarder terminated"
433+
);
385434
});
386435
}
387436

0 commit comments

Comments
 (0)