{"record":{"id":"9fefd6cdffc949a4","repo":"Hmbown/CodeWhale","slug":"first-coordination-interrupt","errorCode":null,"errorMessage":"first coordination interrupt","messagePattern":"first coordination interrupt","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/tools/subagent/tests.rs","lineNumber":6705,"sourceCode":"    for caller in [\"agent_missing\", \"agent_unrelated\", agent_id.as_str()] {\n        assert!(\n            manager\n                .interrupt_child(&agent_id, Some(caller), \"forbidden\".into())\n                .is_err()\n        );\n    }\n    manager.record_worker_event(\n        &agent_id,\n        AgentWorkerStatus::RunningTool,\n        Some(\"step 2/8: running tool 'read_file'\".to_string()),\n        Some(2),\n        Some(\"read_file\".to_string()),\n    );\n\n    let reason = \"parent rerouted this lane\".to_string();\n    let (prior, first) = manager\n        .interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone())\n        .expect(\"first coordination interrupt\");\n    let (_, second) = manager\n        .interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone())\n        .expect(\"repeated coordination interrupt\");\n    assert_eq!(prior.status, SubAgentStatus::Running);\n    assert!(matches!(\n        first.status,\n        SubAgentStatus::Interrupted(ref actual) if actual == &reason\n    ));\n    assert_eq!(second.status, first.status);\n    assert_eq!(\n        first\n            .checkpoint\n            .as_ref()\n            .map(|checkpoint| (checkpoint.reason.as_str(), checkpoint.steps_taken)),\n        Some((\"test_checkpoint\", 2))\n    );\n\n    let completion = completion_rx","sourceCodeStart":6687,"sourceCodeEnd":6723,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/tests.rs#L6687-L6723","documentation":"Test assertion `...interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone()).expect(\"first coordination interrupt\")` at `crates/tui/src/tools/subagent/tests.rs:6705`. The test interrupts a Running child agent from its parent and expects the call to succeed, returning the prior state (Running) and the interrupt record. A panic means interrupt_child returned Err for the first, legitimate interrupt.","triggerScenarios":"interrupt_child errors because the agent is not registered with this manager, the agent id mismatches, the parent id 'agent_parent' is rejected by a new parentage check, or a state-machine change makes Running non-interruptible or requires a different role.","commonSituations":"Refactors adding parentage/permission validation to interrupt_child that break the test's synthetic parent id; state machine changes that remove or rename the Running->interrupted transition; test setup reordered so the agent is not yet Running when interrupted.","solutions":["Surface the actual Err (unwrap_or_else including it in the panic) to see why the interrupt was refused.","Verify the agent is registered and in Running state on the same manager before interrupt_child is called.","Check any parent-id validation in interrupt_child: the test's 'agent_parent' must be accepted for a Worker-role child in tests.","Confirm the prior.status assertion expectation (Running) still matches the state machine; update the test if the transition contract legitimately changed."],"exampleFix":"// before\nlet (prior, first) = manager\n    .interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone())\n    .expect(\"first coordination interrupt\");\n// after\nlet (prior, first) = manager\n    .interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone())\n    .unwrap_or_else(|e| panic!(\"first coordination interrupt of {agent_id} failed: {e:?}\"));","handlingStrategy":"type-guard","validationCode":"// Ensure the child is Running and registered before interrupting:\nlet rec = manager.get_worker_record(&agent_id).expect(\"child registered\");\nassert_eq!(rec.status, AgentWorkerStatus::Running, \"child must be Running before interrupt\");","typeGuard":null,"tryCatchPattern":"let (prior, first) = manager.interrupt_child(&agent_id, Some(\"agent_parent\"), reason.clone())\n    .unwrap_or_else(|e| panic!(\"first coordination interrupt failed: {e:?}\"));","preventionTips":["Keep parentage validation in interrupt_child permissive for test harnesses or provide a test seam.","Assert the child's state before interrupting in tests.","Include interrupt_child's error variant in assertion messages for fast diagnosis."],"tags":["rust","test","panic","interruption","subagent","state-machine"],"backgroundTag":"invalid-state-transition","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"}