{"record":{"id":"8e7022bbf516e374","repo":"Hmbown/CodeWhale","slug":"worker-record","errorCode":null,"errorMessage":"worker record","messagePattern":"worker record","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":6628,"sourceCode":"                envelope.message,\n                MailboxMessage::Completed { .. }\n                    | MailboxMessage::Failed { .. }\n                    | MailboxMessage::Interrupted { .. }\n                    | MailboxMessage::Cancelled { .. }\n            )\n        })\n        .collect::<Vec<_>>();\n    assert_eq!(terminal_mail.len(), 1);\n    assert!(matches!(\n        terminal_mail[0].message,\n        MailboxMessage::Cancelled { ref agent_id } if agent_id == \"agent_model_wait_cancel\"\n    ));\n\n    let complete_events = std::iter::from_fn(|| event_rx.try_recv().ok())\n        .filter(|event| matches!(event, Event::AgentComplete { .. }))\n        .count();\n    assert_eq!(complete_events, 1);\n    let worker = manager.get_worker_record(&agent_id).expect(\"worker record\");\n    assert_eq!(worker.status, AgentWorkerStatus::Cancelled);\n    assert_eq!(\n        worker\n            .events\n            .iter()\n            .filter(|event| event.status.is_terminal())\n            .count(),\n        1\n    );\n}\n\n#[tokio::test]\nasync fn coordination_interrupt_fans_in_once_and_preserves_checkpoint() {\n    use tokio_util::sync::CancellationToken;\n\n    let tmp = tempdir().expect(\"tempdir\");\n    let mut manager = SubAgentManager::new(tmp.path().to_path_buf(), 2);\n    let agent_id = \"agent_coordination_interrupt\".to_string();","sourceCodeStart":6610,"sourceCodeEnd":6646,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L6610-L6646","documentation":"Test assertion `manager.get_worker_record(&agent_id).expect(\"worker record\")` at `crates/tui/src/tools/subagent/tests.rs:6628` in the coordination-interrupt test. After draining completion events, the test expects the cancelled worker's record to still be stored so it can verify terminal event counts. A panic means the record is absent from the manager's store.","triggerScenarios":"get_worker_record returns None because the record was removed on termination, the manager instance is not the one that owned the agent, or the agent id used for lookup differs from the one registered.","commonSituations":"Lifecycle refactors that prune terminal workers from the record map; switching the manager's backing store or path so the lookup hits a different instance; copy-paste of agent ids between tests.","solutions":["Verify the same manager and identical agent_id are used for registration, interrupt, and lookup.","Check that get_worker_record / the cancel-interrupt path retains records for terminal (Cancelled) workers.","If terminal pruning is now intended, rewrite the assertion to capture the record before termination instead.","Log available worker ids on failure to spot id mismatches quickly."],"exampleFix":"// before\nlet worker = manager.get_worker_record(&agent_id).expect(\"worker record\");\n// after\nlet worker = manager.get_worker_record(&agent_id)\n    .unwrap_or_else(|| panic!(\"worker record for {agent_id} missing; known ids: {:?}\", manager.worker_ids()));","handlingStrategy":"type-guard","validationCode":"if manager.get_worker_record(&agent_id).is_none() {\n    panic!(\"worker record for {agent_id} absent before terminal assertions\");\n}","typeGuard":"fn worker_status(m: &SubAgentManager, id: &str) -> Option<AgentWorkerStatus> { m.get_worker_record(id).map(|r| r.status) }","tryCatchPattern":null,"preventionTips":["Use the same manager instance and id constant across setup, interrupt, and lookup.","Retain terminal worker records; if pruning is added, update inspecting tests in the same commit.","Include known worker ids in the failure message."],"tags":["rust","test","panic","state-management","subagent"],"backgroundTag":"record-not-found","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T10:30:35.592Z"}