{"record":{"id":"bf9a04673654edd2","repo":"Hmbown/CodeWhale","slug":"failed-to-record-sub-agent-verification-approval","errorCode":null,"errorMessage":"failed to record sub-agent verification approval: {err}","messagePattern":"failed to record sub-agent verification approval: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/subagent/mod.rs","lineNumber":3178,"sourceCode":"                error = %err,\n                \"sub-agent work-graph registration skipped; spawning unbound\"\n            );\n            return Ok(None);\n        }\n\n        // A root Operate verification lease is provenance, not delegated\n        // authority. Nested workers cannot inherit this bit.\n        if runtime.accept_verification && runtime.spawn_depth == 1 {\n            let reference = format!(\"operate-verification:{agent_id}\");\n            if let Err(err) = lifecycle.work.record_operation_approval(\n                &lifecycle.session_id,\n                &lifecycle.external,\n                &reference,\n                \"agent\",\n                &format!(\"agent:{agent_id}:approval\"),\n            ) {\n                let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);\n                return Err(anyhow!(\n                    \"failed to record sub-agent verification approval: {err}\"\n                ));\n            }\n        }\n        Ok(Some(lifecycle))\n    }\n\n    fn reconcile_record(&self, record: &AgentWorkerRecord) -> Result<bool, String> {\n        let Some(snapshot) = agent_worker_owner_snapshot(record) else {\n            return Ok(false);\n        };\n        self.work.reconcile_operation(&self.session_id, snapshot)\n    }\n\n    fn reconcile_state(\n        &self,\n        state: OwnerState,\n        seq: u64,","sourceCodeStart":3160,"sourceCodeEnd":3196,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/subagent/mod.rs#L3160-L3196","documentation":"After a sub-agent run completes, its verification approval must be recorded under the reference `agent:{agent_id}:approval` in the lifecycle journal; failure triggers reconciliation to OwnerState::Failed and this error wrapping the underlying cause. The message deliberately embeds the inner error ({err}) because an unrecorded approval means the sub-agent's success cannot be trusted downstream.","triggerScenarios":"Calling the sub-agent completion path when the approval-record function errors — e.g. the lifecycle journal/state store is unavailable, the reference is rejected, or the underlying record API returns an error while lifecycle.external/reference are being persisted.","commonSituations":"Disk-full or permission problems writing lifecycle state; a corrupted or locked session journal; schema changes to the approval record format after an upgrade; concurrent settlement closing the record mid-write.","solutions":["Inspect the wrapped {err} in the message — it names the real underlying failure (IO, storage, format)","Retry the sub-agent run after fixing the state store (disk space, permissions, file lock)","Verify the session journal/state files are not corrupted or from an incompatible version","Ensure the approval record API is called before the parent turn finishes settling, and handle its Result explicitly"],"exampleFix":"// before: ignore record failure, agent looks approved\nlet _ = record_approval(&lifecycle.external, &reference, \"agent\", &key);\n// after: fail loudly and reconcile (as the tool does)\nif let Err(err) = record_approval(&lifecycle.external, &reference, \"agent\", &key) {\n    let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);\n    return Err(anyhow!(\"failed to record sub-agent verification approval: {err}\"));\n}","handlingStrategy":"try-catch","validationCode":"// preflight the state store before recording\nif !lifecycle.store_writable() {\n    return Err(anyhow!(\"lifecycle store not writable; approval cannot be recorded\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(err) = record_approval(&lifecycle.external, &reference, \"agent\", &key) {\n    let _ = lifecycle.reconcile_state(OwnerState::Failed, 1, None);\n    return Err(anyhow!(\"failed to record sub-agent verification approval: {err}\"));\n}\n// caller: inspect inner err for IO/permission/corruption fixes","preventionTips":["Monitor disk space and permissions on the session state directory","Keep approval record format backward-compatible across upgrades","Reconcile to OwnerState::Failed whenever recording fails (as implemented)","Write approval records before the parent turn settles"],"tags":["subagent","persistence","approval"],"backgroundTag":"database-write-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}