Skip to content

codev update root-doc tests fail on native Windows (5 tests on main since PR #1984) #1990

Done

Description

@waleedkadous

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 update must 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

  1. added
    area/scaffold
    on Nov 25, 2026
  2. waleedkadous commented on Nov 25, 2026

    @waleedkadous
    ContributorAuthor

    More evidence, from the Windows run on the branch of PR #1987 (run 45704914599, head 2bee21c25), which rewrites the same code:

  3. waleedkadous commented on Nov 25, 2026

    @waleedkadous
    ContributorAuthor

    On it! Working on a fix now.

  4. added 3 commits that reference this issue on Nov 25, 2026
  5. waleedkadous commented on Nov 25, 2026

    @waleedkadous
    ContributorAuthor

    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.md template measured 0 CR LF / 168 LF. Finally it runs the installed codev init and codev update --agent twice on each project. The code is main's, at 9fc63f2cc.

    Project Root-doc conflicts CLAUDE.md before → after update (CR LF / LF) AGENTS.md before → after
    LF, unedited none 0 / 168 → 0 / 168 (untouched) 0 / 170 → 0 / 170
    CR LF, unedited (committed and checked out again with core.autocrlf=true) none 168 / 0 → 154 / 14 (mixed) 170 / 0 → 156 / 14 (mixed)
    CR LF, managed block missing (doc from before Spec 987) none 152 / 0 → 152 / 16 (mixed) 154 / 0 → 154 / 16 (mixed)
    CR LF, CLAUDE.md edited outside the block CLAUDE.md (correct) 172 / 0 → 158 / 14: the adopter's own doc is modified 170 / 0 → 156 / 14

    The second update run changed nothing in any project.

    So an adopter on Windows whose docs are CR LF gets no false conflict. matchesTemplate already 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 in managed-block.ts: renderHotContextBlock joins the block with \n, and upsertHotContextBlock splices 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.ts is green. The fifth, the dry-run test, was fixed by PR #1987, which corrected --dry-run for a root doc that does not exist yet.

    • The two .codev-new byte comparisons are this bug. On a Windows checkout the templates are CR LF, and init itself writes the block in LF, so the doc init writes is mixed while .codev-new is the pure CR LF template.
    • "a CRLF checkout of an unedited doc is up to date" is a test problem. It used replace(/\n/g, '\r\n'), which turns a CR LF doc into \r\r\n.
    • "a doc whose managed block is missing altogether" is a test problem. It sliced end + 2, which assumes LF.

    Fix (PR to follow)

    upsertHotContextBlock writes the block, and any line breaks an insertion adds, in the line ending the doc uses outside the managed block:

    • If every line break outside the block is CR LF, the doc is CR LF.
    • Anything else takes LF, the ending of the published templates: all LF, both kinds, or no line break at all.

    A doc this bug has already left mixed (CR LF body, LF block) is healed by the next update. init from a CR LF skeleton writes CR LF throughout. The two LF-assuming tests no longer depend on the checkout's line endings.

  6. added 7 commits that reference this issue on Nov 25, 2026
  7. waleedkadous commented on Nov 25, 2026

    @waleedkadous
    ContributorAuthor

    Confirmed after the merge of PR #1991: the Windows workflow on main @ b6ef50e0f is green (unit tests, CLI tests, install verification, both probes): https://github.com/cluesmith/codev/actions/runs/45724239805. main had been red on native Windows since PR #1984.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/scaffold

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions