fix(agent-core-v2): tolerate stray files in the sessions directory during index scans - #3501
Open
zhi1ong wants to merge 1 commit into
Open
fix(agent-core-v2): tolerate stray files in the sessions directory during index scans#3501zhi1ong wants to merge 1 commit into
zhi1ong wants to merge 1 commit into
Conversation
…ring index scans The session index mtime probes stat <entry>/state.json for every entry of every workspace bucket directory. A stray regular file inside a bucket (e.g. a Finder .DS_Store) makes that stat fail with ENOTDIR, which the node-fs storage translated to StorageError(io_failed), rejecting the whole scan: freshness checks, (re)projection, reconciliation, and the authoritative read path all fail, so the resume picker and kimi session list show no sessions. Treat ENOTDIR like ENOENT in the node-fs storage probes: a regular file in place of a scope directory means the key cannot exist, so read, readStream, list, delete, size, and mtime now report it as missing instead of failing. This matches the in-memory backend, where probing a path below a value already resolves to missing.
🦋 Changeset detectedLatest commit: 7c25b1b 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
Resolve #3500
(Filed with this PR; awaiting a maintainer's
/approve.)Problem
On 0.40.x the resume picker (
kimi -r,/sessions) andkimi session listlist no sessions at all when any workspace bucket directory under~/.kimi-code/sessions/contains a stray regular file — macOS Finder's.DS_Storeis the common trigger. The scan added in #3422 stats<entry>/state.jsonfor every entry of every bucket directory; for a regular-file entry that fails withENOTDIR, which the node-fs storage translated toStorageError(io_failed)("storage stat failed: unrecognized I/O error"), rejecting the whole scan. Projection, startup freshness checks, periodic reconciliation, and the authoritative fallback read all fail, so fresh processes cannot list any session. Long-running servers degrade into a per-entry-tolerant branch and keep working, which makes the failure look like frontends see different session sets.What changed
isEnoentis nowisMissingEntryand also matchesENOTDIR. A regular file in place of a scope directory means the probed key cannot exist, soread,readStream,list,delete,size, andmtimereport it as missing instead of throwing. This fits the existing storage contract ("undefined = missing"), heals every session-index scan path through one seam, and matches the in-memory backend, where probing a path below a value already resolves to missing.ENOENTsemantics already live.@moonshot-ai/kimi-code.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.