Skip to content

fix: --check false positive after disk round-trip#59

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
barnabasJ:fix/idempotent-check-after-disk-roundtrip
Mar 9, 2026
Merged

fix: --check false positive after disk round-trip#59
zachdaniel merged 1 commit intoash-project:mainfrom
barnabasJ:fix/idempotent-check-after-disk-roundtrip

Conversation

@barnabasJ
Copy link
Contributor

Summary

  • mix usage_rules.sync --check reports false positives on a second run after a clean sync
  • Root cause: Rewrite.Source.write/2 applies eof_newline/1 (String.trim_trailing/1 + "\n") before File.write/2, but generated content may not end with "\n". The 1-byte trailing newline diff causes --check to detect changes when nothing actually changed.
  • Fix: compare managed sections (trimmed) for SKILL.md files, and trimmed content for reference files, so trailing whitespace from the disk round-trip is ignored

Test plan

  • Added 5 idempotency regression tests covering skills.build, skills.deps, AGENTS.md, sub-rules, and custom content in SKILL.md
  • Tests use a simulate_disk_roundtrip helper that applies the same eof_newline transform Rewrite uses on disk writes
  • All 86 tests pass

…mismatch

Rewrite.Source.write/2 applies eof_newline/1 (String.trim_trailing + "\n")
before File.write/2, but the generated content may not end with "\n". On
subsequent syncs, the 1-byte trailing newline difference causes --check to
report changes when nothing actually changed.

Fix by comparing managed sections (trimmed) for SKILL.md files and trimmed
content for reference files, so trailing whitespace differences from the
disk round-trip are ignored.
@zachdaniel zachdaniel merged commit 9fd6ed1 into ash-project:main Mar 9, 2026
23 checks passed
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.

2 participants