Repository navigation
Description
Problem
On native Windows, packages/codev/src/__tests__/bugfix-1982-update-root-docs.test.ts fails 5 of its tests on main. Run on main @ 118ad8897: https://github.com/cluesmith/codev/actions/runs/45703930614 (Targeted tests job). The same 5 fail on any branch cut from there (seen on the branch for PR #1988, run 45702187250, where the other 456 test files pass).
The file was added by PR #1984 (the fix for issue #1982, codev update reporting false conflicts on CLAUDE.md / AGENTS.md). That PR was merged without a Windows run; the on-demand Windows workflow should have been asked for, because the change is about line endings and file comparison.
What fails
| Test | Failure |
|---|---|
| an edit outside the managed block is one conflict, and the edit is kept | byte comparison: the managed block in the file has CR LF line endings where the expected text has LF |
| known limit: an unedited doc from an older template that changed outside the block is still a conflict | the same byte comparison |
| a CRLF checkout of an unedited doc is up to date | reports CLAUDE.md as a conflict; expected none |
| a doc whose managed block is missing altogether is not a conflict; the block is put back | reports AGENTS.md as a conflict; expected none |
| --dry-run reports exactly what the real run then does | the two outputs differ by one line |
What is not known
Whether this is only the tests (on a Windows checkout with core.autocrlf, the templates in the repository are CR LF, which is not what the published package contains), or the product (an adopter on Windows whose CLAUDE.md is checked out with CR LF gets a false conflict or a file with mixed line endings from codev update). The third and fourth rows read like product behaviour. Find out which before fixing: build the package as it is published and run codev update on a Windows runner against a project whose root docs are CR LF and against one whose docs are LF.
Fix
- If the product is wrong:
codev updatemust treat a root doc that differs from the template only in line endings as unedited, must not report it as a conflict, and must write the managed block with the line endings the document already uses, so a file never ends up mixed. - If only the tests are wrong: make them independent of the checkout's line endings.
- Either way the file passes on Windows, and the same holds for the tests PR [Air #1985] feat: codev update replaces an unedited CLAUDE.md / AGENTS.md from an older release #1987 adds beside it (
air-1985-update-older-root-docs.test.ts), which change the same code.
Testing
- The on-demand Windows workflow on the branch, with both test files, linked from the PR.
- The check above with the built package on a Windows runner, CR LF and LF projects, result stated in the PR.
Activity
waleedkadous commentedon Nov 25, 2026
More evidence, from the Windows run on the branch of PR #1987 (run 45704914599, head
2bee21c25), which rewrites the same code:AGENTS.mdis missing, the real run creates the doc and then refreshes its block, while the dry run skipped a doc that did not exist yet. PR [Air #1985] feat: codev update replaces an unedited CLAUDE.md / AGENTS.md from an older release #1987 gives the dry run that content. So once PR [Air #1985] feat: codev update replaces an unedited CLAUDE.md / AGENTS.md from an older release #1987 merges, four tests fail onmain, not five..codev-newbyte comparisons.init's block refresh writes the managed block with LF, so the resulting doc has mixed line endings, while.codev-newis the template as checked out (all CR LF). Whether a real adopter can get a mixed-ending root doc (the published package's templates are LF; an adopter's own doc may be CR LF throughcore.autocrlf) is the product question this issue has to answer.waleedkadous commentedon Nov 25, 2026
On it! Working on a fix now.
[Bugfix #1990] Fix: write the managed block in the root doc's own lin…
[Bugfix #1990] Test: CR LF root docs keep their line endings through …
[Bugfix #1990] PROBE (never merged): after the fix, on the branch head
waleedkadous commentedon Nov 25, 2026
Findings: the product is wrong, but not as guessed. CR LF docs get mixed line endings, not conflicts
Measured on a Windows runner, not reasoned: run 45709493779, from a probe branch that will not be merged. The probe packs the branch's packages and installs them globally into a temp prefix, as an adopter would. It then replaces the installed skeleton with the files exactly as git stores them, which is what the published package carries: the installed
CLAUDE.mdtemplate measured 0 CR LF / 168 LF. Finally it runs the installedcodev initandcodev update --agenttwice on each project. The code ismain's, at9fc63f2cc.update(CR LF / LF)core.autocrlf=true)The second
updaterun changed nothing in any project.So an adopter on Windows whose docs are CR LF gets no false conflict.
matchesTemplatealready normalises CR LF before comparing, so the conflict decision is right. What they do get is a doc with mixed line endings. The cause is inmanaged-block.ts:renderHotContextBlockjoins the block with\n, andupsertHotContextBlocksplices it into the doc unchanged. That happens to an unedited doc, to a doc missing its block, and to a doc the adopter edited, which is supposed to be kept as it is.The bugfix-1982 failures on Windows (same run, at
main's code)Four failures in
bugfix-1982-update-root-docs.test.ts;air-1985-update-older-root-docs.test.tsis green. The fifth, the dry-run test, was fixed by PR #1987, which corrected--dry-runfor a root doc that does not exist yet..codev-newbyte comparisons are this bug. On a Windows checkout the templates are CR LF, andinititself writes the block in LF, so the docinitwrites is mixed while.codev-newis the pure CR LF template.replace(/\n/g, '\r\n'), which turns a CR LF doc into\r\r\n.end + 2, which assumes LF.Fix (PR to follow)
upsertHotContextBlockwrites the block, and any line breaks an insertion adds, in the line ending the doc uses outside the managed block:A doc this bug has already left mixed (CR LF body, LF block) is healed by the next update.
initfrom a CR LF skeleton writes CR LF throughout. The two LF-assuming tests no longer depend on the checkout's line endings.[Bugfix #1990] Builder thread: investigation, Windows probe, fix
[Bugfix #1990] Fix: count the line break on each side of the markers …
[Bugfix #1990] Test: a CR LF doc a pre-fix update inserted the block …
[Bugfix #1990] Builder thread: CMAP rounds, final Windows runs
[Bugfix #1990] Fix: write .codev-new in its root doc's line ending
[Bugfix #1990] Test: .codev-new takes its doc's line ending and is st…
[Bugfix #1990] Builder thread: .codev-new ruling, before/after probes…
waleedkadous commentedon Nov 25, 2026
Confirmed after the merge of PR #1991: the Windows workflow on
main@b6ef50e0fis green (unit tests, CLI tests, install verification, both probes): https://github.com/cluesmith/codev/actions/runs/45724239805.mainhad been red on native Windows since PR #1984.