Skip to content

feat(vfs): in-memory virtual filesystem + state integration#371

Open
davydog187 wants to merge 1 commit into
mainfrom
feat/virtual-vfs
Open

feat(vfs): in-memory virtual filesystem + state integration#371
davydog187 wants to merge 1 commit into
mainfrom
feat/virtual-vfs

Conversation

@davydog187

Copy link
Copy Markdown
Contributor

Virtual-by-default, PR 1/4 — foundation

First slice of the 1.0.0 virtual-by-default work (tracking: #297; supersedes the draft #302). No behavior change — this only adds the storage layer the later PRs route through.

What

  • Lua.VFS — a vendored, in-memory virtual filesystem: a flat map keyed by normalized absolute path, directories implicit, with tagged-tuple errors (:enoent/:eisdir/:einval) that map onto Lua's nil, message, errno io/os contract. No external dependency (keeps the Elixir floor at ~> 1.16 and mix hex.publish clean — unlike feat(stdlib): route os/require file IO through a virtual filesystem #302's ivarvong/vfs git dep).
  • Lua.VM.Statevfs field seeded in new/0; threaded helpers vfs_read/2, vfs_write/3, vfs_rm/2, vfs_exists?/2; plus update_userdata/3 for the mutable file-handle cursors coming in the io PR.

Why this shape

A git dependency blocks mix hex.publish and bumps the Elixir floor; the surface actually needed is tiny (read/write/rm/exists over one in-memory tree), so it's vendored in-tree where the security boundary belongs.

Next in the stack

  1. sandbox:/env: API + Os.Common/Virtual/Host split + virtual/host loaders (removes the per-path deny-list)
  2. io.* virtualization over the VFS
  3. Docs / ROADMAP / CHANGELOG

Verification

  • mix test: 2588 passed (+24 new), 0 failures
  • mix format + mix compile --warnings-as-errors: clean

Add Lua.VFS, a flat-map in-memory filesystem keyed by normalized absolute
path, with tagged-tuple errors (:enoent/:eisdir/:einval) that map onto Lua's
nil/message/errno io/os contract. Seed it on Lua.VM.State (new/0) and thread it
through vfs_read/2, vfs_write/3, vfs_rm/2, vfs_exists?/2. Add update_userdata/3
for mutable userdata (forthcoming io file-handle cursors).

Foundation for virtual-by-default execution; no behavior change yet.
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