fix(agent-core-v2): tolerate stray files in the sessions directory during index scans - #3501
fix(agent-core-v2): tolerate stray files in the sessions directory during index scans#3501zhi1ong 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. |
|
#3618 is a better fix: it handles this at the session index layer, where the knowledge that stray entries are expected belongs, and it logs the offending path. Generalizing ENOTDIR to ENOENT across the whole storage contract would mask path-construction bugs elsewhere. Closing in favor of it. |
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.