unconscious/subconscious: use Option<AutoAgent> instead of placeholder

Previously, spawning an agent used std::mem::replace with an empty-name
AutoAgent as placeholder. This caused ghost stats entries under "" when
those placeholders accidentally got their stats logged.

Now uses Option<AutoAgent> with .take() - the type honestly represents
that the agent is unavailable while running. Panic recovery in
subconscious now properly recreates the agent from its definition.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-04-12 20:11:40 -04:00
parent 33156d9ab3
commit b94e056372
3 changed files with 37 additions and 23 deletions

3
Cargo.lock generated
View file

@ -612,6 +612,7 @@ dependencies = [
"dirs",
"env_logger",
"futures",
"json5",
"log",
"serde",
"serde_json",
@ -632,8 +633,8 @@ dependencies = [
"json5",
"libc",
"log",
"scopeguard",
"serde",
"serde_json",
"tokio",
"tokio-util",
]