Symptôme: stopper un agent (ex Main sur UnityPlugin) laissait des travaux poursuivre, la cascade n'atteignait pas les agents lancés et la pastille restait orange pendant que l'agent continuait à en appeler d'autres. - barrière d'admission par génération d'exécution (ExecutionControl): un stop ferme l'admission de tout le sous-arbre propriété/attente AVANT toute annulation asynchrone — plus aucune nouvelle action inter-agents après stop - arbre de propriété durable en-process (launched_by) + dépendances d'attente actives: la cascade couvre transitivement agents et travaux lancés - commandes d'un agent arrêté rejetées (AppError::AgentStopped); stop lui-même admis pour rester idempotent; réactivation sur relance humaine (génération +1) et enregistrement du propriétaire au spawn - admission exposée aux adaptateurs hors commandes cœur (tickets, templates, plugins) via ensure_agent_execution_active; MCP server/tools, web-server et commandes Tauri alignés - cohérence live-state: statut Idle avec intent « Arrêté » ou « Arrêt incomplet — Certains travaux sont encore actifs » selon l'issue de la cascade; workstate et surfaces UI (AgentsPanel, LayoutGrid, ProjectWorkStatePanel) reflètent l'état réel, plus de pastille orange fantôme - tests: orchestrator_service (cascade/générations/idempotence), workstate_actions, background_task_cancel, error_codes, agents, layout, workstate QA verte sur fix/320-agent-stop-cascade. Aucun push.
139 lines
4.5 KiB
Rust
139 lines
4.5 KiB
Rust
//! L1 tests pinning the stable [`AppError::code`] strings the IPC `ErrorDto`
|
|
//! relies on, and the per-port `From` mappings.
|
|
|
|
use application::AppError;
|
|
use domain::ports::{
|
|
AgentSessionError, EmbedderError, FsError, GitError, MemoryError, ProcessError, PtyError,
|
|
RemoteError, StoreError,
|
|
};
|
|
|
|
#[test]
|
|
fn codes_are_stable() {
|
|
assert_eq!(AppError::NotFound("x".into()).code(), "NOT_FOUND");
|
|
assert_eq!(AppError::Invalid("x".into()).code(), "INVALID");
|
|
assert_eq!(AppError::FileSystem("x".into()).code(), "FILESYSTEM");
|
|
assert_eq!(AppError::Store("x".into()).code(), "STORE");
|
|
assert_eq!(AppError::Process("x".into()).code(), "PROCESS");
|
|
assert_eq!(AppError::Git("x".into()).code(), "GIT");
|
|
assert_eq!(AppError::Remote("x".into()).code(), "REMOTE");
|
|
assert_eq!(
|
|
AppError::AgentStopped {
|
|
agent_id: domain::AgentId::from_uuid(uuid::Uuid::nil()),
|
|
}
|
|
.code(),
|
|
"AGENT_STOPPED"
|
|
);
|
|
assert_eq!(AppError::Internal("x".into()).code(), "INTERNAL");
|
|
}
|
|
|
|
#[test]
|
|
fn fs_not_found_maps_to_not_found_other_to_filesystem() {
|
|
assert_eq!(
|
|
AppError::from(FsError::NotFound("/tmp/x".into())).code(),
|
|
"NOT_FOUND"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(FsError::PermissionDenied("/tmp/x".into())).code(),
|
|
"FILESYSTEM"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(FsError::Io("boom".into())).code(),
|
|
"FILESYSTEM"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn store_not_found_maps_to_not_found_other_to_store() {
|
|
assert_eq!(AppError::from(StoreError::NotFound).code(), "NOT_FOUND");
|
|
assert_eq!(
|
|
AppError::from(StoreError::Serialization("bad".into())).code(),
|
|
"STORE"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn process_pty_runtime_map_to_process() {
|
|
assert_eq!(AppError::from(PtyError::NotFound).code(), "PROCESS");
|
|
assert_eq!(
|
|
AppError::from(ProcessError::Spawn("x".into())).code(),
|
|
"PROCESS"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn agent_session_errors_all_map_to_process() {
|
|
// §17.1 / D4: a structured AgentSession is a live process/SDK conversation, so
|
|
// every failure variant folds into PROCESS (the byte-stream twin). Used by the
|
|
// agent_send / close_agent_session command error arms.
|
|
assert_eq!(
|
|
AppError::from(AgentSessionError::Start("no cli".into())).code(),
|
|
"PROCESS"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(AgentSessionError::Io("broken pipe".into())).code(),
|
|
"PROCESS"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(AgentSessionError::Decode("bad schema".into())).code(),
|
|
"PROCESS"
|
|
);
|
|
assert_eq!(AppError::from(AgentSessionError::Timeout).code(), "PROCESS");
|
|
// The message is carried through onto the single Process shape.
|
|
assert_eq!(
|
|
AppError::from(AgentSessionError::Io("broken pipe".into())),
|
|
AppError::Process(AgentSessionError::Io("broken pipe".into()).to_string())
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn git_and_remote_map_through() {
|
|
assert_eq!(AppError::from(GitError::NotFound).code(), "GIT");
|
|
assert_eq!(
|
|
AppError::from(RemoteError::Auth("nope".into())).code(),
|
|
"REMOTE"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn memory_errors_map_per_variant() {
|
|
// NotFound → NotFound.
|
|
assert_eq!(AppError::from(MemoryError::NotFound).code(), "NOT_FOUND");
|
|
// Frontmatter → Invalid (a malformed note is an invariant violation, not I/O).
|
|
let invalid = AppError::from(MemoryError::Frontmatter("bad yaml".into()));
|
|
assert_eq!(invalid.code(), "INVALID");
|
|
assert_eq!(invalid, AppError::Invalid("bad yaml".to_owned()));
|
|
// Io → Store.
|
|
assert_eq!(
|
|
AppError::from(MemoryError::Io("disk full".into())).code(),
|
|
"STORE"
|
|
);
|
|
// Serialization → Store (the catch-all arm).
|
|
assert_eq!(
|
|
AppError::from(MemoryError::Serialization("bad index".into())).code(),
|
|
"STORE"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn embedder_errors_all_map_to_store() {
|
|
// An embedder is a *derived* recall detail: every variant maps to STORE (its
|
|
// failure must degrade the recall, never fail hard — see the From impl doc).
|
|
assert_eq!(
|
|
AppError::from(EmbedderError::Unavailable("no model".into())).code(),
|
|
"STORE"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(EmbedderError::Unsupported("localOnnx".into())).code(),
|
|
"STORE"
|
|
);
|
|
assert_eq!(
|
|
AppError::from(EmbedderError::Io("read failed".into())).code(),
|
|
"STORE"
|
|
);
|
|
// The message is carried through.
|
|
assert_eq!(
|
|
AppError::from(EmbedderError::Unsupported("api".into())),
|
|
AppError::Store("embedder strategy unsupported: api".to_owned())
|
|
);
|
|
}
|