Skip to content

fix(editor): expose filesystem info for checkpoints - #47

Open
dsent wants to merge 1 commit into
aldum:devfrom
dsent:agent/checkpoint-fs-getinfo
Open

fix(editor): expose filesystem info for checkpoints#47
dsent wants to merge 1 commit into
aldum:devfrom
dsent:agent/checkpoint-fs-getinfo

Conversation

@dsent

@dsent dsent commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

  • expose FS.getInfo(path, filtertype, vfs) through the runtime filesystem adapter
  • define the returned FileInfo shape for LuaCATS-aware editor tooling
  • mirror the same metadata API in the test backend using lfs.attributes
  • route FS.exists through FS.getInfo
  • cover metadata shape and type filtering in the filesystem specs

Why

The checkpoint timestamp lookup calls FS.getInfo, but the adapter only exposed FS.exists. The missing method crashes the first checkpoint attempt. This isolates the adapter fix as one commit on top of aldum/dev.

API compatibility

The production FS.exists signature was already (path, filtertype, vfs). This change adds the optional filtertype argument only to the test backend, bringing it in line with production. Omitting the argument still passes nil and checks for any filesystem entry, so existing one-argument calls keep the same behavior. Existing production callers use the filter to distinguish files from directories.

FileInfo.type is a love.FileType; size and modtime are optional because LÖVE may be unable to determine them. The test backend uses lfs.attributes, which follows symbolic links, so it maps only LuaFileSystem's file and directory modes directly and reports other modes as LÖVE's other. It does not claim symlink semantics.

Validation

  • tests/util/fs_spec.lua: 9 successes, 0 failures, 0 errors
  • full Lua 5.1 suite: 687 successes, 0 failures, 0 errors
  • luac5.1 -p src/util/filesystem.lua tests/util/fs_spec.lua
  • git diff --check origin/dev...HEAD

@dsent
dsent marked this pull request as ready for review July 22, 2026 02:28
@dsent
dsent requested a review from aldum July 22, 2026 19:41
Comment thread src/util/filesystem.lua
local attrs = lfs.attributes(path)
if not attrs then return end

local types = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please represent the file types in the (pseudo-)type system so at least it's linter-validated by the editor tooling, and introduce an alias for {type: love.FileType, size: number, modtime: number}, e.g.

--- @class FileInfo
--- @field type love.FileType
--- @field size number
--- @field modtime number

Assuming this link/symlink renaming is necessary, I'm not sure I understand the point of it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

LuaFileSystem calls a symbolic link "link", while LÖVE’s FileType calls it "symlink". The mapping was intended to make the test implementation return the same vocabulary as production.

However, the current code calls lfs.attributes, which seems to follow symbolic links and report the target as "file" or "directory". So this is essentially dead code. I'll remove it.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

That makes sense. Still, let's add an enum for it

Checkpoint timestamp lookup called FS.getInfo, but the adapter exposed only FS.exists, crashing the first checkpoint. Mirror getInfo across runtime and test backends, and route exists through it so metadata semantics stay centralized.

Add a filesystem regression spec that verifies the metadata shape and type-filter behavior on the target branch.

Refs: compy-editor-checkpoint-fs-getinfo-crash
@dsent
dsent force-pushed the agent/checkpoint-fs-getinfo branch from 2c125e1 to 38d7c75 Compare July 23, 2026 22:52
@dsent

dsent commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator Author

@aldum I must clarify that I encountered this bug using the branch with a heavily updated editor that we now use for lessons. Didn't realize this at the moment. Thus, the bug was caused by the code that we've just wrote and that is not yet merged.

However, I explored the options and came to a conclusion that this is, in fact, not a bad solution. We save checkpoints and need to check the last modification time. The only way to do that without adding any new API seemed to read the current project object and iterate over all files until a matching one is found. This is quite ugly imo (and I'm not sure it gets regenerated often).

link/symlink rename is removed as it defends against a situation that should not happen. Type annotations added.

@dsent
dsent requested a review from aldum July 24, 2026 00:16
dsent added a commit to dsent/compy-ide that referenced this pull request Jul 27, 2026
Comment thread src/util/filesystem.lua
local attrs = lfs.attributes(path)
if not attrs then return end

local types = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

That makes sense. Still, let's add an enum for it

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