From a7eea1855e3786126058bb915e4ab02723d8d9eb Mon Sep 17 00:00:00 2001 From: Aditya Vikram Singh <247195684+avs-io@users.noreply.github.com> Date: Mon, 7 Sep 2026 14:33:48 +0530 Subject: [PATCH] fix(doctor): add probeRoots for seven filesystem-silent providers (#899) Close forge/mux/open-design/openclaw/zcode/zed/zerostack filesystem gaps. Vercel remains the network-only exception. OpenClaw SQLite/JSONL accounting stays in the following #1259 commit; this commit only adds OpenClaw probeRoots so empty-root diagnostics can see an agents path. Source-DIFF: 00ebf26c (1259-899-sqlite-discovery) / carried in d91b6a71 Lane: local core-wave 2026-09-07 --- src/providers/forge.ts | 6 ++- src/providers/mux.ts | 6 ++- src/providers/open-design.ts | 6 ++- src/providers/openclaw.ts | 8 +++- src/providers/zcode.ts | 6 ++- src/providers/zed.ts | 6 ++- src/providers/zerostack.ts | 6 ++- .../providers/probe-roots-899-census.test.ts | 41 +++++++++++++++++++ 8 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 tests/providers/probe-roots-899-census.test.ts diff --git a/src/providers/forge.ts b/src/providers/forge.ts index 27931e98..47dd6dbb 100644 --- a/src/providers/forge.ts +++ b/src/providers/forge.ts @@ -5,7 +5,7 @@ import { join } from 'path' import { extractBashCommands } from '../bash-utils.js' import { calculateCost } from '../models.js' import { getSqliteLoadError, isSqliteAvailable, openDatabase, type SqliteDatabase } from '../sqlite.js' -import type { ParsedProviderCall, Provider, SessionParser, SessionSource } from './types.js' +import type { ParsedProviderCall, ProbeRoot, Provider, SessionParser, SessionSource } from './types.js' type ConversationRow = { conversation_id: string @@ -270,6 +270,10 @@ export function createForgeProvider(dbPath = DEFAULT_DB_PATH): Provider { return rawTool }, + async probeRoots(): Promise { + return [{ path: dbPath, label: 'db' }] + }, + async discoverSessions(): Promise { if (!isSqliteAvailable()) return [] return discoverFromDb(dbPath) diff --git a/src/providers/mux.ts b/src/providers/mux.ts index 4ebd9195..2356e137 100644 --- a/src/providers/mux.ts +++ b/src/providers/mux.ts @@ -5,7 +5,7 @@ import { homedir } from 'os' import { readSessionLines } from '../fs-utils.js' import { calculateCost, getShortModelName } from '../models.js' import { extractBashCommands } from '../bash-utils.js' -import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' +import type { Provider, SessionSource, SessionParser, ParsedProviderCall, ProbeRoot } from './types.js' import { safeNumber } from '../parser.js' const toolNameMap: Record = { @@ -269,6 +269,10 @@ export function createMuxProvider(muxRoot?: string): Provider { return toolNameMap[rawTool] ?? rawTool }, + async probeRoots(): Promise { + return [{ path: root, label: 'root' }] + }, + async discoverSessions(): Promise { return discoverSessions(root) }, diff --git a/src/providers/open-design.ts b/src/providers/open-design.ts index 5a2a0790..85e7b013 100644 --- a/src/providers/open-design.ts +++ b/src/providers/open-design.ts @@ -4,7 +4,7 @@ import { homedir, platform } from 'os' import { readSessionLines } from '../fs-utils.js' import { calculateCost } from '../models.js' -import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' +import type { Provider, SessionSource, SessionParser, ParsedProviderCall, ProbeRoot } from './types.js' const PROVIDER_NAME = 'open-design' const ENV_DIR = 'CODEBURN_OPEN_DESIGN_DIR' @@ -246,6 +246,10 @@ export function createOpenDesignProvider(overrideDir?: string): Provider { return rawTool }, + async probeRoots(): Promise { + return [{ path: overrideDir ?? getOpenDesignDir(), label: 'sessions' }] + }, + async discoverSessions(): Promise { return discoverOpenDesignSessions(overrideDir ?? getOpenDesignDir()) }, diff --git a/src/providers/openclaw.ts b/src/providers/openclaw.ts index bc6da536..140567f1 100644 --- a/src/providers/openclaw.ts +++ b/src/providers/openclaw.ts @@ -5,7 +5,7 @@ import { homedir } from 'os' import { readSessionFile } from '../fs-utils.js' import { calculateCost } from '../models.js' import { extractBashCommands } from '../bash-utils.js' -import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' +import type { Provider, SessionSource, SessionParser, ParsedProviderCall, ProbeRoot } from './types.js' const toolNameMap: Record = { bash: 'Bash', @@ -263,6 +263,12 @@ export function createOpenClawProvider(overrideDir?: string): Provider { return toolNameMap[rawTool] ?? rawTool }, + async probeRoots(): Promise { + // #899: empty agents root that exists must be distinguishable from missing install. + const roots = overrideDir ? [overrideDir] : getOpenClawDirs() + return roots.map(path => ({ path, label: 'agents' })) + }, + async discoverSessions(): Promise { if (overrideDir) return discoverInDir(overrideDir) const all: SessionSource[] = [] diff --git a/src/providers/zcode.ts b/src/providers/zcode.ts index d9eaf47f..a273178d 100644 --- a/src/providers/zcode.ts +++ b/src/providers/zcode.ts @@ -3,7 +3,7 @@ import { homedir } from 'os' import { calculateCost } from '../models.js' import { isSqliteAvailable, getSqliteLoadError, openDatabase, type SqliteDatabase } from '../sqlite.js' -import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' +import type { Provider, SessionSource, SessionParser, ParsedProviderCall, ProbeRoot } from './types.js' /// ZCode (CLI v0.14.x) records usage in a single SQLite database at /// ~/.zcode/cli/db/db.sqlite. We read it because the other on-disk sources are @@ -213,6 +213,10 @@ export function createZcodeProvider(dbPathOverride?: string): Provider { return rawTool }, + async probeRoots(): Promise { + return [{ path: dbPath, label: 'db' }] + }, + async discoverSessions(): Promise { if (!isSqliteAvailable()) return [] return discover(dbPath) diff --git a/src/providers/zed.ts b/src/providers/zed.ts index 7164149e..75391275 100644 --- a/src/providers/zed.ts +++ b/src/providers/zed.ts @@ -5,7 +5,7 @@ import zlib from 'zlib' import { calculateCost } from '../models.js' import { getSqliteLoadError, isSqliteAvailable, openDatabase, type SqliteDatabase } from '../sqlite.js' -import type { ParsedProviderCall, Provider, SessionParser, SessionSource } from './types.js' +import type { ParsedProviderCall, ProbeRoot, Provider, SessionParser, SessionSource } from './types.js' // Zed's built-in agent stores one row per thread in a single SQLite database; // the `data` blob is zstd-compressed JSON carrying `request_token_usage` @@ -213,6 +213,10 @@ export function createZedProvider(dbPathOverride?: string): Provider { return rawTool }, + async probeRoots(): Promise { + return [{ path: dbPathOverride ?? getZedThreadsDbPath(), label: 'threads.db' }] + }, + async discoverSessions(): Promise { if (!isSqliteAvailable()) return [] const dbPath = dbPathOverride ?? getZedThreadsDbPath() diff --git a/src/providers/zerostack.ts b/src/providers/zerostack.ts index 959e1b1e..6c0aa994 100644 --- a/src/providers/zerostack.ts +++ b/src/providers/zerostack.ts @@ -4,7 +4,7 @@ import { homedir, platform } from 'os' import { readSessionFile } from '../fs-utils.js' import { calculateCost, getShortModelName } from '../models.js' -import type { Provider, SessionSource, SessionParser, ParsedProviderCall } from './types.js' +import type { Provider, SessionSource, SessionParser, ParsedProviderCall, ProbeRoot } from './types.js' // zerostack (https://github.com/gi-dellav/zerostack) is a minimal Rust coding // agent. Each session is a single JSON file under /zerostack/sessions/. @@ -133,6 +133,10 @@ export function createZerostackProvider(sessionsDir?: string): Provider { return toolNameMap[rawTool] ?? rawTool }, + async probeRoots(): Promise { + return [{ path: dir, label: 'sessions' }] + }, + async discoverSessions(): Promise { let files: string[] try { diff --git a/tests/providers/probe-roots-899-census.test.ts b/tests/providers/probe-roots-899-census.test.ts new file mode 100644 index 00000000..e10b91ec --- /dev/null +++ b/tests/providers/probe-roots-899-census.test.ts @@ -0,0 +1,41 @@ +import { describe, it, expect } from 'vitest' +import { getAllProviders } from '../../src/providers/index.js' + +/** + * #899 exact-main residual census (Codex REVIEW-2026-09-06-2306): + * seven filesystem gaps + one intentional Vercel network exception. + * Method presence is necessary but not sufficient for OpenClaw empty-root + * semantics — see openclaw.test.ts doctor fixture. + */ +const FILESYSTEM_GAP_NAMES = [ + 'forge', + 'mux', + 'open-design', + 'openclaw', + 'zcode', + 'zed', + 'zerostack', +] as const + +describe('#899 probeRoots census', () => { + it('closes the seven filesystem gaps; Vercel remains network exception', async () => { + const providers = await getAllProviders() + const byName = new Map(providers.map(p => [p.name, p])) + + for (const name of FILESYSTEM_GAP_NAMES) { + const p = byName.get(name) + expect(p, `provider ${name} should be loaded`).toBeTruthy() + expect(p!.probeRoots, `${name} must implement probeRoots`).toBeTypeOf('function') + const roots = await p!.probeRoots!() + expect(roots.length, `${name} probeRoots must return ≥1 root`).toBeGreaterThanOrEqual(1) + } + + const vercel = byName.get('vercel-gateway') + expect(vercel).toBeTruthy() + expect(vercel!.network).toBe(true) + expect(vercel!.probeRoots, 'Vercel is intentional network exception — no probeRoots').toBeUndefined() + + const missingFilesystem = providers.filter(p => !p.network && !p.probeRoots).map(p => p.name) + expect(missingFilesystem).toEqual([]) + }) +})