Skip to content

fix(runtime): prefer host type flags over mode bits in Stats - #1909

Open
wasaybuilds wants to merge 1 commit into
rivet-dev:mainfrom
wasaybuilds:fix/stats-prefer-host-type-flags
Open

fix(runtime): prefer host type flags over mode bits in Stats#1909
wasaybuilds wants to merge 1 commit into
rivet-dev:mainfrom
wasaybuilds:fix/stats-prefer-host-type-flags

Conversation

@wasaybuilds

Copy link
Copy Markdown

Closes #1839.

  • Every host stat payload already carries isDirectory and isSymbolicLink (javascript_sync_rpc_stat_value, javascript_sync_rpc_host_stat_value, HostStat::to_value), but Stats derived all seven type predicates from the mode bits alone. Dirent, right below it, already trusts its explicit boolean.
  • The type is now resolved once in the constructor from the host flags, falling back to the mode bits when a backend omits them. A backend that sends no hints behaves exactly as it does today.
  • Resolving a single format also keeps the predicates mutually exclusive, which mode bits plus a contradicting hint would not.

Behaviour of the real Stats class, before and after:

case                                   BEFORE           AFTER
--------------------------------------------------------------------------
regular file, host agrees              isFile           isFile
STALE CACHE: dir bit on a real file    isDirectory      isFile          <-- changed
real directory                         isDirectory      isDirectory
symlink                                isSymbolicLink   isSymbolicLink
STALE CACHE: file bit on a real dir    isFile           isDirectory     <-- changed
legacy backend, no hints (dir)         isDirectory      isDirectory
legacy backend, no hints (file)        isFile           isFile
fifo, hints both false                 isFIFO           isFIFO

Only the two cases where the mode bits contradict the host change, and both change to the host's answer. Row 2 is the reported failure: the Claude CLI's Edit tool seeing EISDIR on a regular file.

_typeFormat is defined non-enumerable, so mode is untouched and JSON.stringify(stats) / Object.keys(stats) are unchanged.

Same caveat as #1908 — no committed test, because the guest fs suites need a VM I can't build locally. Glad to add one wherever you'd want it.

Host stat payloads always carry isDirectory and isSymbolicLink, which reflect
what the VFS resolved, but Stats derived every type predicate from the mode
bits alone. On a backend whose mode bits can go stale — an NFS/EFS attribute
cache, for example — a regular file reporting the directory bit made
isDirectory() true, and callers that branch on it failed with EISDIR.

The type is now resolved once from the host flags, falling back to the mode
bits when a backend omits them, so a backend that sends no hints behaves
exactly as before. Dirent already used its explicit boolean this way.
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.

bridge fs: Stats.isDirectory() derives from mode bits only, ignoring the explicit is_directory flag from the host

1 participant