fix(cases): keep deleted workspaces deleted, cap pastCap, scope stalls to network mounts

- applyWorkspaceHooks: an "unknown" probe that is not near a stalled path
  (refused by the stall cap, or an unexpected stat error) no longer reads as
  "go ahead". It checks existence with pathExistsForWrite first, so a deleted
  workspace is not recreated by the mkdir -p in ensureCodemanHooks.
- pastCap gets a hard ceiling, PATH_PROBE_STALL_CEILING = UV_THREADPOOL_SIZE
  (default 4) minus one, so explicit requests against several dead paths can
  never take the last libuv worker. The bulk cap now defaults to one below the
  ceiling (2 with the default pool), leaving a slot for an explicit request.
- A stall widens to its mount only for network and FUSE filesystem types read
  from /proc/self/mounts; on a local mount (a path typed under a local /home
  that reaches a NAS through a symlink) it narrows to the stalled path.
- GET /api/cases/:name probes CLAUDE.md with pastCap, like the folder probe.
- Comment in config/path-probe.ts describes the mount-scoped stall.
This commit is contained in:
Aamer Akhter
2026-10-05 09:51:27 -04:00
parent d1bfbb4fcf
commit 9fa44109b8
7 changed files with 171 additions and 38 deletions
+13 -6
View File
@@ -852,13 +852,20 @@ export async function refreshStaleCodemanHooks(casePath: string): Promise<void>
*/
export async function applyWorkspaceHooks(workspace: string, install?: boolean): Promise<void> {
try {
const skip = await absentOrUnreachable(workspace);
if (skip === 'unreachable') {
console.warn(
`[hooks] ${workspace} is not responding (unreachable mount?); Codeman hooks not checked or installed`
);
const state = await probePath(workspace);
if (state === 'absent') return;
if (state === 'unknown') {
if (isNearStalledPath(workspace)) {
console.warn(
`[hooks] ${workspace} is not responding (unreachable mount?); Codeman hooks not checked or installed`
);
return;
}
// Any other "unknown" (the stall cap refused the probe, or the stat failed
// with something other than ENOENT) proves nothing about existence, and the
// install below would mkdir -p a deleted repo back into being: ask directly.
if (!(await pathExistsForWrite(workspace))) return;
}
if (skip) return;
const shouldInstall = install ?? (await readWorkspaceHooksEnabled());
await (shouldInstall ? ensureCodemanHooks(workspace) : refreshStaleCodemanHooks(workspace));
} catch {