{"record":{"id":"9a5a8132edc36259","repo":"Hmbown/CodeWhale","slug":"for","errorCode":null,"errorMessage":"{} for {}: {}","messagePattern":"\\{\\} for \\{\\}: \\{\\}","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"crates/tui/src/snapshot/repo.rs","lineNumber":324,"sourceCode":"    }\n\n    /// Variant of [`Self::open_or_init`] that accepts an explicit\n    /// workspace-size cap. `cap_bytes = 0` disables the cap entirely\n    /// (always snapshot, regardless of size).\n    ///\n    /// When the workspace exceeds the cap and the side repo hasn't\n    /// been initialized yet, returns `Err(InvalidInput)` with a\n    /// \"workspace too large\" reason. Subsequent calls (after the user\n    /// shrinks the workspace or raises the cap via config) succeed.\n    pub fn open_or_init_with_cap(workspace: &Path, cap_bytes: u64) -> io::Result<Self> {\n        let work_tree = workspace\n            .canonicalize()\n            .unwrap_or_else(|_| workspace.to_path_buf());\n        if let Some(reason) = unsafe_workspace_snapshot_reason(\n            &work_tree,\n            crate::config::effective_home_dir().as_deref(),\n        ) {\n            return Err(io::Error::new(\n                io::ErrorKind::InvalidInput,\n                format!(\n                    \"{GATE_UNSAFE_LOCATION_MARKER} for {reason}: {}\",\n                    display_workspace_for_gate(workspace)\n                ),\n            ));\n        }\n\n        let _ = ensure_snapshot_dir(&work_tree)?;\n        let git_dir = snapshot_git_dir(&work_tree);\n\n        let needs_init = !git_dir.exists();\n        if needs_init {\n            // First-init size guard. Skipping this on subsequent opens\n            // is intentional: paying a workspace walk on every snapshot\n            // would defeat the purpose of the cap, and a workspace\n            // that fit on first init is allowed to grow within the\n            // existing repo's `MAX_SNAPSHOT_SIZE_MB` budget. Users on","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/snapshot/repo.rs#L306-L342","documentation":"SnapshotRepo::open_or_init_with_cap (crates/tui/src/snapshot/repo.rs:324) refuses to enable snapshots for workspaces in unsafe locations, checked by `unsafe_workspace_snapshot_reason`. The message starts with the GATE_UNSAFE_LOCATION_MARKER (\"workspace snapshots are disabled\"), then names the reason and displays the workspace path. The turn loop matches on this marker to show the matching recovery notice.","triggerScenarios":"Opening/initing a snapshot repo whose canonicalized work tree is an unsafe location per unsafe_workspace_snapshot_reason — e.g. the workspace is (under) the user's home directory itself, the effective home dir, or another protected system location.","commonSituations":"Launching codewhale with the working directory set to $HOME or a parent-of-home path; running inside /tmp root or a system dir that the safety gate protects; a mis-set CODEWHALE/effective home making the workspace compare equal to home.","solutions":["Run codewhale from a real project directory, not $HOME or one of its protected ancestors.","Read the `reason` in the message to see exactly which location rule fired and move the workspace accordingly.","If home detection is wrong (e.g. odd HOME env), fix the environment so effective_home_dir resolves to the real home."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let ws = std::fs::canonicalize(cwd)?;\nlet home = dirs::home_dir().unwrap();\nlet safe = ws != home && !ws.starts_with(&home) && ws != Path::new(\"/\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always launch codewhale from a project subdirectory, never $HOME.","Check the `reason` field in the message to learn which location rule fired.","Fix a wrong HOME/env if home detection makes a valid workspace look unsafe."],"tags":["safety-gate","workspace-location","snapshots"],"backgroundTag":"unsupported-operation","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"}