{"record":{"id":"aeded1c1142c997c","repo":"xai-org/grok-build","slug":"snapshot-subagent-worktree-task-failed-e","errorCode":null,"errorMessage":"snapshot_subagent_worktree task failed: {e}","messagePattern":"snapshot_subagent_worktree task failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-workspace/src/worktree/mod.rs","lineNumber":1517,"sourceCode":"/// thread.\npub async fn snapshot_subagent_worktree(\n    worktree_path: &Path,\n    source_repo: &Path,\n    ref_name: &str,\n) -> Result<String> {\n    let worktree_path = worktree_path.to_path_buf();\n    let source_repo = source_repo.to_path_buf();\n    let ref_name = ref_name.to_string();\n    tokio::task::spawn_blocking(move || -> Result<String> {\n        let message = format!(\"subagent worktree snapshot {ref_name}\");\n        // Capture into the worktree's git, then make it durable in the source\n        // repo (and verify) so it survives the worktree's deletion.\n        xai_fast_worktree::snapshot_worktree_to_ref(&worktree_path, &ref_name, &message)?;\n        xai_fast_worktree::transfer_snapshot_to_repo(&worktree_path, &source_repo, &ref_name)?;\n        Ok(ref_name)\n    })\n    .await\n    .map_err(|e| anyhow::anyhow!(\"snapshot_subagent_worktree task failed: {e}\"))?\n}\n\n/// Remove a subagent worktree directory. Call only AFTER\n/// [`snapshot_subagent_worktree`] succeeded and its ref was persisted, so a\n/// removal failure is safe to treat as best-effort (the durable ref already\n/// backs resume). The blocking fast-worktree work runs on a blocking thread.\npub async fn remove_subagent_worktree(worktree_path: &Path) -> Result<()> {\n    let worktree_path = worktree_path.to_path_buf();\n    // On rootless hosts the snapshot delete needs the privileged helper; without\n    // the delegate the btrfs delete hits EPERM and the snapshot leaks.\n    let delegate = btrfs_delegate_from_env();\n    tokio::task::spawn_blocking(move || {\n        xai_fast_worktree::remove_worktree_with_delegate(&worktree_path, delegate)\n    })\n    .await\n    .map_err(|e| anyhow::anyhow!(\"remove_subagent_worktree task failed: {e}\"))??;\n    Ok(())\n}","sourceCodeStart":1499,"sourceCodeEnd":1535,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-workspace/src/worktree/mod.rs#L1499-L1535","documentation":"Error \"snapshot_subagent_worktree task failed: {e}\" thrown in xai-org/grok-build.","triggerScenarios":"Thrown at crates/codegen/xai-grok-workspace/src/worktree/mod.rs:1517 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}