Skip to content

Fail closed when a discovered route module cannot be read - #791

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
cursor/fail-closed-route-source-reads-a02c
Sep 12, 2026
Merged

ScriptedAlchemy merged 3 commits into
mainfrom
cursor/fail-closed-route-source-reads-a02c

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

compileRouteGraph treated every readFile failure as a racing deletion. That made EACCES / EIO / EMFILE look like a vanished module: extract and validate skipped, and inspect / validate reported no error.

Change

readRouteModuleText now uses the existing isErrno helper — the same disappearance check as discoverState and readProjectIgnoreRules.

Error Behavior
ENOENT Silent skip (undefined text). Extract/validate stay off, same as a later snapshot that no longer lists the file.
Everything else (EACCES, EIO, EMFILE, EISDIR, ENOTDIR, EPERM, uncoded errors, …) Rethrow. Not a new ABxxxx — route graph has no unreadable-source diagnostic, and this PR does not invent one.

Tests

  • ENOENT after glob still compiles the discovered route with empty config and no diagnostics.
  • After discovery, replacing the route file with a directory (EISDIR) rejects compileRouteGraph instead of omitting the module. This is deterministic across platforms; it does not depend on chmod 000.

Local proof (after pnpm build):

pnpm exec rstest --config rstest.unit.config.ts packages/agent-bundle/tests/route-graph.test.ts \
  -t 'skips extract and validate when a discovered route module disappears before read|fails closed when a discovered route module cannot be read'
# 2 passed (ENOENT race + EISDIR fail-closed)

pnpm exec rstest --config rstest.unit.config.ts packages/agent-bundle/tests/route-graph.test.ts
# 66 passed

pnpm exec rslint packages/agent-bundle/src/routes/graph.ts packages/agent-bundle/tests/route-graph.test.ts
# passed

Draft only; do not merge.

Open in Web Open in Cursor 

compileRouteGraph treated every readFile failure as a racing deletion.
Keep ENOENT as a silent skip so extract/validate match a later snapshot,
and propagate other I/O errors through the existing isErrno helper.

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3881ffc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agent-bundle Patch
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@791
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@791
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@791
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@791

commit: 3881ffc

Replace the chmod/EACCES case, which is skipped under root and
unreliable on Windows, with a deterministic unlink-then-directory
race via mutateDiscoveredSource.

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review September 12, 2026 15:18
@ScriptedAlchemy
ScriptedAlchemy merged commit d7dec2c into main Sep 12, 2026
19 checks passed
@ScriptedAlchemy
ScriptedAlchemy deleted the cursor/fail-closed-route-source-reads-a02c branch September 12, 2026 15:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3881ffc785

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return undefined;
} catch (error) {
if (isErrno(error, 'ENOENT')) return undefined;
throw error;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Document unreadable route failures in both locales

When a discovered route module produces EACCES, EIO, or another non-ENOENT read error, this new throw changes the observable behavior of the public compileRouteGraph API and the build, inspect, and validate flows, but the commit does not update a matching page under either website/docs/en/** or website/docs/zh/**. Document the new fail-closed behavior in both locales so users know these commands no longer treat unreadable route modules as absent.

AGENTS.md reference: AGENTS.md:L89-L95

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-12T15:21:55.183444Z 3881ffc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants