Skip to content

fix(workspace): cap instruction discovery during open - #378

Draft
chusia06 wants to merge 1 commit into
Waishnav:mainfrom
chusia06:codex/bound-workspace-instruction-discovery
Draft

chusia06 wants to merge 1 commit into
Waishnav:mainfrom
chusia06:codex/bound-workspace-instruction-discovery

Conversation

@chusia06

Copy link
Copy Markdown

Opening a large multi-project directory can spend minutes discovering nested instruction files before open_workspace returns. In our packaged 1.0.8 deployment, a correlated request spent 230 seconds of its 231-second runtime in discovery. A separate read-only terminal comparison on current main took 10,023 ms without this patch and 44 ms with it; these are single-run observations, not a latency guarantee.

This bounds the existing sequential walk across the whole request to 256 directories, 10,000 entries, and a one-second time budget checked between filesystem operations. Small workspaces retain their nested instruction inventory. If scanning stops early, the response explicitly says the inventory is incomplete and asks the host to check applicable ancestor instructions or open the specific project. The warning is also retained on reused workspace responses. A single stalled filesystem operation is not cancelled by this budget.

This is a smaller alternative alongside #197 and #374, following the bounded-discovery direction discussed on #91. It applies to all directory layouts, keeps current bootstrap/reuse behavior, and introduces no configuration, tool schema, or dependency changes. Related to #90; it does not implement that issue's proposed automatic ancestor-instruction loading.

Typecheck, Vite/TypeScript build, 45 focused tests, and the complete source suite passed locally (152 passed, one platform skip; TMPDIR=/tmp pnpm test avoids macOS Unix-socket path limits). The fresh package-install smoke check remains blocked: the newly resolved Koffi native dependency fails to link on macOS, including with Node 22 and temporary CMake. Package-install success and Windows/Linux execution are unverified, so this PR is a draft. No live MCP host acceptance is claimed for this source patch.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Adds discovery limits and warnings for instruction files.

The inaccessible-directory warning gap is non-blocking; the review does not identify a reason to hold the merge.

Findings

  1. P2 Inaccessible scans appear complete ▶

Summary

The PR limits nested instruction-file discovery and warns when the scan reaches its limit. The warning appears on initial and reused workspace opens, including responses that omit the bootstrap inventory. An inaccessible nested directory is still treated as a completed scan, so its omitted instructions do not trigger the new warning.

Reviews (1) · Last reviewed commit: "fix(workspace): cap instruction discover..."

entries = await opendir(directory);
} catch {
// Preserve discovery's existing handling of inaccessible directories.
return true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Inaccessible scans appear complete

When a nested directory cannot be opened, the walk returns true without checking it for instruction files. The new completeness flag therefore remains false, and open_workspace gives no incomplete-inventory warning. Users may treat the omitted instructions as a complete list. This warning gap does not block merging, but access failures should be reported as incomplete scans rather than as scan-limit stops.

Artifacts

Focused denied-directory service check source

  • The authored check creates a nested instruction file, confirms `opendir` returns `EACCES`, and invokes `WorkspaceRegistry.openWorkspace` against the selected source tree.

Service output before the incomplete-inventory signal

  • Running the check against HEAD^ showed a denied directory, an empty instruction inventory, and no incomplete-inventory signal.

Service output with the incomplete-inventory signal

  • Running the same check against HEAD showed a denied directory and empty inventory, but the new incomplete-inventory signal was false.

View artifacts

T-Rex Ran code and verified through T-Rex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant