Repository navigation
🐛 fix(index): leave an index whose content is current untouched - #13
Merged
Merged
Conversation
index build rewrote every index.md on every run, and an index with mixed line endings (an editor or agent wrote LF lines into a CRLF file) came out LF even when nothing changed. On a core.autocrlf=true checkout git then reports the file modified with an empty diff, since its size no longer matches the CRLF size git recorded. Compare the render with the on-disk file the way index check does (line endings are not content) and skip the write when they match. A changed index still keeps CRLF when it was pure CRLF, and falls back to LF otherwise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…racter bumpRootIndexMarker left the scalar style to yaml.v3, which writes a target such as a tab then a newline as a literal block whose tab-led line no parser reads back, so migrate --apply could leave an unparseable bundle-root index.md. FuzzRootIndexMarker caught it in CI on #13. Force double-quoted style when the target holds a control character; every other target is written as before. The input joins the fuzz seeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
okfctl index buildno longer rewrites anindex.mdwhose content is already current. On a Windows checkout (core.autocrlf=true), that rewrite could change only the line endings, and git then reported the file modified with an empty diff.Index build
index checkdoes, ignoring line endings (normalizeEOL). When they match, it skips the write, so the file keeps its bytes and its mtime.index checkreports CRLF index.md as stale;index builddoubles curator shape suffixes on CRLF cwest/okfctl#185. A mixed-ending or LF index is written LF, and a new index is written LF.Migrate (
okf_versionmarker)migrate --applytakes its target version from a user-editable plan. For a target such as a tab then a newline, yaml.v3 wrote a literal block whose tab-led line no parser reads back, leaving an unparseable bundle-rootindex.md. Such a target is now written double-quoted, with every control character escaped. Any other target is written exactly as before.Index rendering (
internal/okf/)reserved_lifecycle.go:WriteIndexWithOptionsreads the existing index once, skips it when its content is current, and otherwise picks the line endings from it as before.index_eol_test.goaddsTestWriteIndex_UnchangedIndexIsNotRewritten. It covers pure-CRLF, mixed and LF indexes whose content is current (same bytes, same mtime after the build), with a changed root index as the control (it is still rewritten).TestWriteIndex_PreservesExistingLineEndingsgives its mixed-ending index a real content change, so it still proves that a changed mixed index is written LF.migrate.go:bumpRootIndexMarkerforces double-quoted style on a target with a control character.writepath_fuzz_test.go:FuzzRootIndexMarkerseeds the failing input ("\t\n0"), which went red (found a tab character where an indentation space is expected) and then green. The existing migrate tests, unchanged, are the control for ordinary targets.Evidence
nextat the parent of this branch): on a CRLF checkout, an index that an editor or agent left with mixed endings (one line rewritten LF) comes back pure LF fromindex buildeven though its content is unchanged. Every build also rewrites every index, so every mtime moves.After: that index keeps its bytes and mtime, and
index checkstays rc 0.TestWriteIndex_UnchangedIndexIsNotRewrittenwent red before the change: all three unchanged indexes had their mtime moved, and the mixed one lost its bytes. It is green after.Real corpus: copies of three production CRLF-checkout bundles, built with the installed
nextbinary (v0.4.0-53-g5d27721) and with this branch.index build(before → after)index checkrcvalidatercThose bundles' indexes are each pure LF or pure CRLF today, so no bytes change in either column; that is the control showing the change hides nothing. The mixed-ending case the change targets is the fixture above.
The index tests, the
-run Conformancesuite and gofmt pass.internal/okfandcmdpass apart from the tests that fail identically onnexton this Windows host (plugin and editor exec,truemissing from PATH, CRLF git clones).-raceruns in CI only (no C compiler on the host).Merge Danger
Door: two-way
Blast Radius: index writes
okfctl index build(and the commands that rebuild indexes, such asnode new,node mvandnode rm) no longer touch an index whose content is current. Its bytes, line endings and mtime stay as they were.Not in this PR: line endings of concept files and
log.md.index buildnever writes those, and a log append always changes content.🤖 Generated with Claude Code