ticket117: synchronie métier idea_ask_agent + corrélation task ↔ rendezvous

This commit is contained in:
2026-07-31 15:04:54 +02:00
parent 045e0984cc
commit 10c0bef5e5
10 changed files with 435 additions and 40 deletions

View File

@ -20,8 +20,8 @@ use domain::ports::{
IdGenerator, SpawnSpec,
};
use domain::{
AgentId, BackgroundTask, BackgroundTaskKind, BackgroundTaskResult, BackgroundTaskState,
BackgroundTaskWakePolicy, ProjectId, TaskId,
AgentId, BackgroundTask, BackgroundTaskKind, BackgroundTaskRendezvousLink,
BackgroundTaskResult, BackgroundTaskState, BackgroundTaskWakePolicy, ProjectId, TaskId,
};
use crate::error::AppError;
@ -52,6 +52,8 @@ pub struct SpawnBackgroundCommandInput {
pub command: SpawnSpec,
/// Completion wake policy.
pub wake_policy: BackgroundTaskWakePolicy,
/// Optional composite rendezvous this task participates in.
pub rendezvous: Option<BackgroundTaskRendezvousLink>,
/// Optional absolute deadline, epoch milliseconds.
pub deadline_ms: Option<u64>,
}
@ -103,6 +105,7 @@ impl SpawnBackgroundCommand {
input.label,
input.command,
input.wake_policy,
input.rendezvous,
input.deadline_ms,
)
.await?;
@ -117,12 +120,13 @@ impl SpawnBackgroundCommand {
label: String,
command: SpawnSpec,
wake_policy: BackgroundTaskWakePolicy,
rendezvous: Option<BackgroundTaskRendezvousLink>,
deadline_ms: Option<u64>,
) -> Result<BackgroundTask, AppError> {
let task_id = TaskId::from_uuid(self.ids.new_uuid());
let now = u64::try_from(self.clock.now_millis().max(0)).unwrap_or(0);
let task = BackgroundTask::new(
let mut task = BackgroundTask::new(
task_id,
project_id,
owner_agent_id,
@ -132,6 +136,9 @@ impl SpawnBackgroundCommand {
deadline_ms,
)
.map_err(|e| AppError::Invalid(e.to_string()))?;
if let Some(link) = rendezvous {
task = task.with_rendezvous(link);
}
self.store.create(&task).await.map_err(map_port_err)?;
let running = task
@ -287,6 +294,7 @@ impl RetryBackgroundTask {
command,
old.wake_policy,
None,
None,
)
.await?;
Ok(SpawnBackgroundCommandOutput { task })