Skip to content

fix(store): write notes with LF on every platform - #214

Merged
CryptoJones merged 1 commit into
mainfrom
fix/atomic-write-deterministic-newlines
Aug 2, 2026
Merged

fix(store): write notes with LF on every platform#214
CryptoJones merged 1 commit into
mainfrom
fix/atomic-write-deterministic-newlines

Conversation

@CryptoJones

Copy link
Copy Markdown
Owner

1 of 6 in the follow-up batch. Ships in v8.1.0.

The root cause behind four bugs

store._atomic_write and paths.atomic_write_text open in text mode with newline=None, whose documented behaviour is to translate every \n to os.linesep on write. So the same note was written LF on POSIX and CRLF on Windows — and nothing in the code could see it, because text-mode reads translate back.

Every Windows-only failure in this repo's recent history traces here, and each one passed a fully green Linux run first:

bug symptom
#202 compliance-log rotation never fired on Windows
#194 (pre-merge) transaction identity hashes never matched what had just been written → recovery rolled back nothing
#194 (pre-merge) pre-image restore translated twice → every rollback grew a blank line in the note it was restoring

Three of those were silent: no crash, no error, just a subsystem quietly not working on one platform.

Fix

newline="\n" on both writers. Bytes are now identical on every OS, which additionally makes note digests, mesh merges, and git diffs platform-stable — note_version currently hashes different bytes for the same logical note depending on where it was written.

It matters most in paths.atomic_write_text: that one writes omi-guard.sh, and a shell script whose shebang line ends \r\n is not a shell script.

Compatibility

Existing CRLF files keep their bytes until something rewrites them — this changes what we write, not a migration. Obsidian, git, and every parser in this repo read LF fine on Windows.

Test

test_notes_are_written_with_lf_on_every_platform asserts no \r\n in a written note. It only fails on Windows, which is exactly where the class of bug lives — the Windows legs are the point.

Gates

ruff check . · mypy src (strict) · pytest (885 passed) · pip-audit — green locally.

🤖 Generated with Claude Code

`_atomic_write` and `paths.atomic_write_text` opened in text mode with the
default newline translation, so every `\n` became `os.linesep` on write: the
same note was LF on POSIX and CRLF on Windows. Nothing in the code could see
it, because text-mode reads translate back.

Four bugs came out of that single property, each passing a green Linux run and
failing only on the Windows legs:

* compliance-log rotation that never fired (#202),
* transaction identity hashes that never matched what had just been written, so
  recovery classified every file as a foreign edit and rolled back nothing,
* pre-image restores that translated a second time, growing a blank line in the
  note each rollback was supposed to restore.

An explicit newline="\n" makes the bytes identical everywhere, which also makes
note digests, mesh merges, and git diffs platform-stable. It matters most in
paths.atomic_write_text, which writes omi-guard.sh: a shell script whose
shebang line ends \r\n is not a shell script.

Existing CRLF files keep their bytes until something rewrites them; Obsidian,
git, and every parser here read LF fine on Windows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@CryptoJones, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f1d45eba-88f9-4fe2-909c-b8ef77042050

📥 Commits

Reviewing files that changed from the base of the PR and between 6aafd6b and f5a404b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • CHANGELOG.md
  • pyproject.toml
  • src/omind/__init__.py
  • src/omind/paths.py
  • src/omind/store.py
  • tests/test_store.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CryptoJones
CryptoJones merged commit 7338130 into main Aug 2, 2026
16 checks passed
@CryptoJones
CryptoJones deleted the fix/atomic-write-deterministic-newlines branch August 2, 2026 20:30
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