Skip to content

fix(core): exclude Emacs autosaves from local indexing - #1547

Merged
phernandez merged 1 commit into
mainfrom
codex/fix-1537-autosave
Sep 14, 2026
Merged

phernandez merged 1 commit into
mainfrom
codex/fix-1537-autosave

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

Emacs writes #note.md# autosaves beside the real note. Local indexing currently admits these scratch copies as resources. Closes #1537.

What Changed

Exclude Emacs #…# basenames in the existing local scratch-file filter shared by watcher event normalization and full-project scans. This applies with existing/custom .bmignore files and leaves other resource suffixes and legitimate hash-containing note names alone.

Implementation Details

The baseline regression reproduced resource ingestion with both identical note bytes and different draft bytes: the watcher created a second entity at notes/#note.md#. It did not reproduce the reported takeover of notes/note.md on current main. The actual watcher path is event normalization → regular-file indexing → BatchIndexer._upsert_regular_file; its initial lookup and uniqueness-conflict recovery both resolve the exact project-relative file path. Markdown accepted-content reconciliation belongs to the separate note path. No evidence justified changing that persistence protocol or adding locks.

Filtering before watcher move detection and project-scan change planning prevents autosaves from entering either resource persistence or checksum move reconciliation. The regression exercises autosave create/modify/delete and a forced full scan, checking real-note identity, permalink, observations/relations, accepted Markdown/version, and disk bytes. No ignore parser changes or historical corruption repair are included.

Testing

  • Before fix: regression failed on autosave admission (5 failed, 4 passed); logs showed Indexed regular file: notes/#note.md# and two entities.
  • uv run pytest tests/index/test_emacs_autosave.py tests/index/test_filesystem_events.py tests/index/test_local_watch_ignore_parity.py tests/index/test_local_project_scan_parity.py tests/index/test_local_watch_regular_file_parity.py -q --no-cov — 28 passed.
  • just fast-check — passed (ruff check/format and full ty typecheck).
  • just doctor — passed the isolated API/file/index/search/status loop.

Risks / Follow-ups

Files whose basenames are wrapped in # are treated as local editor scratch, consistently with the existing built-in temporary-file exclusions. This prevents future autosave ingestion; it does not claim to diagnose or repair the historical row takeover reported in #1537. Related reconciliation/ignore-parser work remains separate.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-14T04:39:24.937460Z 5bbc8b6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@phernandez
phernandez merged commit 85821da into main Sep 14, 2026
34 checks passed
@phernandez
phernandez deleted the codex/fix-1537-autosave branch September 14, 2026 05:18
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.

[BUG] Emacs autosave #note.md# is indexed as a non-markdown resource and can destroy the real note's entity row

1 participant