pre_vfs runs before each VFS call and post_vfs after it, whoever makes
the call: a command, a runtime’s file API, a file tool, session.vfs, FUSE,
FSKit or SFTP. TypeScript spells each method and field in camelCase (preVfs, ctx.path).
A command or a file CLI that reads through
ctx.vfs meets both. An account
CLI, such as gh or slack, calls its service directly and makes no VFS
call: pre_command judges it and
pre_network its connections.
Context
Every call a VFS marks reaches both methods,
read_tree, search and copy
too. Every ctx also carries the session fields.
pre_vfs
session.vfs.write("/reports/q3.md", ...) raises EACCES. The same
policy refuses a command redirect (echo x > /reports/q3.md) and writes
through runtime file APIs, FUSE, FSKit and SFTP.
post_vfs
session.vfs.read raises
EACCES; commands and runtime file reads meet the same check. Cached
reads and retained handles are checked against current policy before
returning their bytes or metadata. These checks do not fetch the retained
value again. Bytes already delivered to a program remain in its memory.
post_vfs can refuse a read but not shorten it: the file comes
back whole or not at all. To cap how much a command prints, use
post_execute.