fix(agent-core-v2): make host fs stat follow symlinks and add explicit lstat#1843
Open
7Sageer wants to merge 3 commits into
Open
fix(agent-core-v2): make host fs stat follow symlinks and add explicit lstat#18437Sageer wants to merge 3 commits into
7Sageer wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 33a4128 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
5 tasks
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
None — follow-up to #1840, supersedes #1842.
Problem
The v2 engine's
IHostFileSystem.statwas named like Node'sstatbut implementedlstatsemantics — the opposite of Node, and the opposite of the v1 engine'skaos.stat(which follows symlinks by default). Everystat.isFile/stat.isDirectorycall site written with the usual intuition silently mishandled symlinks, and the failure mode was always an invisible skip with no log or warning. This single design flaw has already produced three user-visible bugs in the web backend (a common dotfiles setup installs config/instruction files as symlinks):Readtool rejected symlinked files with"<path>" is not a file.;ReadMediaFilesize checks measured the symlink itself instead of its target.Fixing call sites one by one (#1840, #1842) does not stop new ones from re-introducing the bug, so this PR fixes the semantics at the source.
What changed
IHostFileSystem.statnow follows symlinks (Nodestat/ v1kaossemantics), and a new explicitlstatserves consumers that genuinely need link-level information. The transitionalfollowSymlinksoption added in fix(agent-core-v2): follow symlinks when loading AGENTS.md and reading files #1840 is removed again..gitdiscovery uselstat(symlink-aware behavior preserved); everything else — AGENTS.md loading,Read,ReadMediaFile, glob roots, write-parent checks, workspace validation — now follows links, matching the CLI's v1 engine. This also makes the per-call-site fixes from fix(agent-core-v2): follow symlinks in read and media tools #1842 unnecessary (closing it).Skill discovery and MCP config loading were audited and are not affected: they use
node:fsdirectly, which already follows symlinks.Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.