Skip to content

fix(agent-core-v2): skip stray non-directory entries during session index scans - #3618

Merged
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:bug-158-09-07-session-index-stray-files
Sep 7, 2026
Merged

fix(agent-core-v2): skip stray non-directory entries during session index scans#3618
sailist merged 1 commit into
MoonshotAI:mainfrom
sailist:bug-158-09-07-session-index-stray-files

Conversation

@sailist

@sailist sailist commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

No linked issue — the bug was reported directly from a Canary build.

Problem

Recent sessions disappeared from the session list when the sessions directory contained any stray non-directory entry (e.g. a .DS_Store file or a legacy workspace.json file left by an old version). The session index scan stats <entry>/state.json for every entry under a workspace's sessions directory; for a plain file that stat fails with ENOTDIR, which surfaced as a generic storage.io_failed ("unrecognized I/O error") and aborted the whole index re-projection. The index then stayed on its previous generation, so all recent sessions vanished from the list, and the error message gave no hint about the real cause.

What changed

  • The per-entry mtime stat in the session index source now treats an ENOTDIR failure the same as ENOENT: the entry is not a session directory, so it is skipped instead of failing the entire scan. Genuine I/O errors (EIO, EMFILE, ...) still propagate.
  • Skipped entries are logged with a warn message that includes the offending path, so future failures point at the concrete bad entry.
  • The logger is threaded from the session index service and projector into the scan; the shared storage contract is unchanged (ENOTDIR semantics for other consumers are untouched).
  • Added a regression test that places stray files and a state-less directory in the sessions tree and proves the projection still publishes a new generation with the bad entries skipped (it fails before the fix); removed one duplicate legacy-path test case to keep the test count net-neutral.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 11ecb54

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Sep 7, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@11ecb54
npx https://pkg.pr.new/@moonshot-ai/kimi-code@11ecb54

commit: 11ecb54

@sailist
sailist merged commit 75682b0 into MoonshotAI:main Sep 7, 2026
16 checks passed
@github-actions github-actions Bot mentioned this pull request Sep 7, 2026
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