Files
IdeaSDK/crates/infrastructure/src/background_task/mod.rs
Blomios eb9cc16181 feat(background): livraison auto au propriétaire + projection des tâches de fond dans le work-state (T1+T3)
T1 — Wake automatique du propriétaire à la complétion.
La complétion d'une tâche de fond est désormais livrée à l'agent
propriétaire dès que la session accepte l'envoi (wake.rs :
mark_completion_delivered au send accepté), via un drain de flux dédié
(structured.rs : drain_reply_stream_with_readiness). L'inbox médiée
enfile l'item sans démarrer de tour ni marquer l'agent busy
(input/mod.rs : enqueue FIFO silencieux). Régression couverte
(tests/agent_wake.rs, tests input/mod.rs).

T3 — Tâches de fond projetées dans le read-model du panneau Work.
AgentWorkState porte désormais background_tasks
(VO AgentBackgroundTaskState), alimenté par un builder best-effort
with_background_tasks(store) : union list_open_for_agent + dispatch des
completions non livrées par owner_agent_id, erreur store => Vec vide
(aucune régression live/busy/tickets). DTO Tauri backgroundTasks et
wiring du BackgroundTaskStore côté state.rs. Le frontend, déjà câblé,
affiche Cancel/Retry (mapping queued/waiting -> pending, tri sur
updatedAtMs). Borne V1 : une tâche terminale déjà livrée n'est plus
énumérable (Retry limité à la fenêtre non livrée).

Tests : cargo build --workspace OK ; cargo test -p application /
-p app-tauri / -p infrastructure verts ; frontend build + vitest verts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-04 00:21:33 +02:00

24 lines
977 B
Rust

//! First-class background task infrastructure.
//!
//! Three cohesive pieces close the B2→B8 loop:
//!
//! - [`sink`] — the durable [`BackgroundCompletionSink`], single writer between a
//! runner completion and the ready-to-deliver signal (persist-before-signal).
//! - [`tail`] — a UTF-8-safe bounded ring buffer for stdout/stderr tails.
//! - [`runner`] — [`CommandBackgroundRunner`], the concrete
//! [`BackgroundTaskRunner`](domain::ports::BackgroundTaskRunner) that spawns a
//! command-backed task over a composed [`PtyPort`](domain::ports::PtyPort) and
//! emits exactly one completion per task.
mod runner;
mod sink;
mod tail;
pub use runner::CommandBackgroundRunner;
pub use sink::{
start_background_ready_inbox_bridge, BackgroundCompletionSink, BackgroundCompletionSinkError,
BackgroundCompletionSinkOutcome, BackgroundReadyInboxBridgeHandle,
BackgroundTaskReadyToDeliver,
};
pub use tail::{bounded_tail, tail_cap_bytes, BoundedTail};