{"record":{"id":"5837abe02cc434f3","repo":"Hmbown/CodeWhale","slug":"workspace-size-gate-message","errorCode":null,"errorMessage":"<workspace size gate message>","messagePattern":"<workspace size gate message>","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"warning","filePath":"crates/tui/src/snapshot/repo.rs","lineNumber":348,"sourceCode":"            ));\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\n            // workspaces that grew past the cap mid-session get the\n            // existing aggressive-pruning path in `snapshot()`.\n            if let Err(gate) =\n                estimate_workspace_size_bounded(&work_tree, cap_bytes, SIZE_WALK_MAX_ENTRIES)\n            {\n                return Err(io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    gate.describe(cap_bytes, workspace),\n                ));\n            }\n            let parent = git_dir.parent().ok_or_else(|| {\n                io::Error::new(io::ErrorKind::InvalidInput, \"snapshot dir has no parent\")\n            })?;\n            std::fs::create_dir_all(parent)?;\n            // `git init` here uses the parent directory as the work tree\n            // and stores metadata in `.git`. We then continue to use\n            // explicit `--git-dir` / `--work-tree` flags for every other\n            // command so behaviour is invariant of cwd.\n            let init = crate::dependencies::Git::command()\n                .ok_or_else(|| io_other(\"git not found on PATH\"))?\n                .arg(\"init\")\n                .arg(\"--quiet\")\n                .arg(parent)\n                .output()","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/snapshot/repo.rs#L330-L366","documentation":"open_or_init_with_cap runs `estimate_workspace_size_bounded` before initializing a snapshot repo. If the estimate fails the size gate, the WorkspaceGate::describe message is returned as an InvalidInput io::Error: either \"workspace too large for snapshots: over N bytes ...\" (TooLarge, liftable via the max_workspace_gb config) or \"workspace has too many files for snapshots: over 200000 entries\" (TooManyEntries, independent of the byte cap).","triggerScenarios":"Opening a snapshot repo on a workspace whose snapshot-eligible content exceeds cap_bytes (from MAX_SNAPSHOT_SIZE_MB / max_workspace_gb), or whose entry count exceeds SIZE_WALK_MAX_ENTRIES (200,000).","commonSituations":"Pointing codewhale at a monorepo, a directory full of datasets/media, or a tree with hundreds of thousands of small files; an exclude list (.gitignore) that does not cover large build/data dirs.","solutions":["For the TooLarge gate, raise `[snapshots] max_workspace_gb` (or MAX_SNAPSHOT_SIZE_MB) in config.","Add the heavy directories (datasets, artifacts) to .gitignore / snapshot excludes — the estimator skips gitignored content.","For TooManyEntries, reduce the number of files in the workspace; raising the byte cap does NOT lift the 200k-entry bound.","Move large data out of the workspace into a sibling directory."],"exampleFix":"// config.toml\n// before\n[snapshots]\nmax_workspace_gb = 2\n// after\n[snapshots]\nmax_workspace_gb = 20","handlingStrategy":"validation","validationCode":"fn quick_size_ok(ws: &Path, cap_gb: u64) -> std::io::Result<bool> {\n    let out = std::process::Command::new(\"du\")\n        .args([\"-sb\", \"--exclude=node_modules\", \"--exclude=target\"])\n        .arg(ws).output()?;\n    let bytes: u64 = String::from_utf8_lossy(&out.stdout)\n        .split('\\t').next().unwrap_or(\"0\").parse().unwrap_or(0);\n    Ok(bytes <= cap_gb * 1024 * 1024 * 1024)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep large datasets and build artifacts out of the workspace or gitignore them.","Match [snapshots] max_workspace_gb to your workspace size before opening.","Remember TooManyEntries (200k files) is not lifted by raising the byte cap.","Watch for the distinct GATE_TOO_LARGE vs GATE_TOO_MANY_ENTRIES markers in the message."],"tags":["snapshots","size-limit","workspace"],"backgroundTag":"file-size-limit-exceeded","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"}