Skip to content

fix(ci): normalize committed CRLF to LF and name the failure for what it is - #9799

Merged
JSONbored merged 3 commits into
mainfrom
fix/crlf-line-endings
Jul 29, 2026
Merged

fix(ci): normalize committed CRLF to LF and name the failure for what it is#9799
JSONbored merged 3 commits into
mainfrom
fix/crlf-line-endings

Conversation

@JSONbored

@JSONbored JSONbored commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Summary

Twenty files were committed on main with CRLF line endings, and the repo had no .gitattributes.
The changes job runs git diff --check, and git's default core.whitespace is blank-at-eol with
cr-at-eol off — so a carriage return at end-of-line genuinely is trailing whitespace to it. Any
PR that added a line to one of those files failed CI pointing at lines whose visible content is
spotless, with nothing in the output ever saying "CRLF".

That is not hypothetical. It hit #9787 (run 30436384202):

src/review/inline-suggestion-anchor.ts:13: trailing whitespace.
+  for (const raw of patch.split("\n")) {
src/review/inline-suggestion-anchor.ts:21: trailing whitespace.
+    if (marker === undefined || marker === "-" || marker === "\\") continue;

Neither line has trailing whitespace. Diagnosing it takes cloning the branch and hexdumping the file.

Three changes:

  1. All twenty files converted to LF via git add --renormalize .. Content is otherwise
    byte-identical — git diff -w --stat on this PR reports only the two new files:

     .gitattributes           | 28 ++++++++++++++++++++++++++++
     .github/workflows/ci.yml | 22 ++++++++++++++++++++++
     2 files changed, 50 insertions(+)
    

    Independently confirmed per file by stripping CR from each origin/main blob and comparing SHAs
    against the normalized blob — all twenty identical.

    The issue listed eleven; a repo-wide git grep -lI $'\r' origin/main found nine more under
    review-enrichment/. They are included: .gitattributes declares eol=lf for the whole tree, so
    leaving them CRLF would leave the repo contradicting its own attribute and hand the next
    --renormalize a surprise diff.

  2. A root .gitattributes pinning the repo to LF. It is * text=auto eol=lf, deliberately not
    * text eol=lf — five .ts files embed NUL bytes on purpose as untrusted-text/sanitizer fixtures
    (test/unit/mcp-untrusted-text.test.ts, src/services/maintainer-recap-routing.ts,
    review-enrichment/src/analyzers/ci-check-signals.ts, scripts/counterfactual-replay-core.ts,
    packages/loopover-engine/test/governor-ledger.test.ts). text=auto leaves git's binary detection
    in charge, so those pass through untouched; forcing text would rewrite them. Verified: a scratch
    git add --renormalize . staged exactly the twenty CRLF files and nothing else — all five NUL
    fixtures and the three apps/loopover-ui/public/ image assets were left alone.

  3. The whitespace step now names CRLF before falling through to git diff --check. Same input,
    different message:

    Output
    Before src/review/inline-comment-label.ts:1: trailing whitespace. +/** Pure inline-comment severity/category label rendering (#2149 / #1958). */
    After ::error::CRLF line endings in added lines -- this repo is LF-only (see .gitattributes) src/review/inline-comment-label.ts (17 added line(s) ending in CRLF) Fix: git add --renormalize <file> && git commit --amend

    .gitattributes stops CRLF entering through git add, so this is unreachable from an ordinary
    commit — I confirmed that by trying, and git normalized it away. It stays worth having because
    checkin filters don't run on blobs written directly (the GitHub web editor, the Contents API) or on
    a merge of a branch cut before .gitattributes landed. Both were exercised against a real
    unnormalized blob; the table above is that run's actual output. It is scoped to added lines, so
    it fires on exactly what git diff --check would have flagged anyway — a relabel, not a new failure
    mode.

Twenty-two files is over the usual budget, but twenty of them are line-ending-only with zero
hand-written change (see the -w stat above). The reviewable surface is .gitattributes and the
workflow step: 50 lines.

Follow-up found while validating: the engine flag reported this diff at 30.67%

codecov/patch failed on packages/loopover-engine/src/signals/issue-quality-report.ts, and the
cause was not a coverage gap — the root vitest suite already covers that file 87/87 lines and
143/143 branches. buildIssueQualityReport is re-exported from the engine barrel but this package's
own node:test suite never called it, so npm run engine:coverage saw the module load (top-level
constants only) and emitted LF:313 LH:96 BRF:0 — no function-level data at all.

Two uploads disagreeing about the same file is invisible while patch coverage only reads changed
lines, because nothing changes all 313 at once. Renormalizing the line endings did. Of the 217 lines
the engine flag called uncovered, 84 are hit by vitest and resolve on union; the other 133 are
function-signature and closing-brace lines that v8 never lists as statements, so nothing could
rescue them — capping the merged report near 57% no matter how well the root suite tested it.

Fixed by covering the module in the suite that actually grades this package, which is the outcome
scripts/engine-coverage.ts (#9064) was written to encourage — "deepening the real suite" rather
than "duplicating a thin vitest test."

before after
lines 96/313 (30.67%) 313/313 (100%)
branches BRF:0 (no data) 163/163 (100%)

Engine suite: 867 → 884 tests, all passing.

Separately: codecov/patch posts a red verdict mid-run

Worth its own issue rather than a change here. codecov.yml sets notify.after_n_builds: 1, which
fires the verdict on the first upload to land — on this PR that was rees, then engine, both
from validate-code, while validate-tests (which carries the backend upload) was still running.
So a red codecov/patch appeared computed from a partial report.

That is not cosmetic: per the gate's disposition matrix any failed CI check is a CLOSE, so a
contributor PR can be auto-closed on a red status that would have gone green minutes later. The
config comment explains after_n_builds must stay 1 (rees/control-plane uploads only exist on PRs
touching them), so a higher count is not the fix — a count cannot express "wait for the backend
upload specifically." The supported mechanism is notify.manual_trigger with an explicit finalize
step once every upload has landed.

Closes #9798

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • No behavior changed in any runtime file, so the suites I ran were the ones that could actually
    regress: the six unit suites covering the renormalized src/review/** and engine files (60 passed),
    npm run rees:test for the nine review-enrichment/** files (1379 passed), the engine package suite
    (867 passed), npm run test:coverage, npm run typecheck, and npm run actionlint for the workflow
    edit. The unchecked boxes are MCP/UI/workers/audit paths this diff does not touch — no UI, MCP,
    worker, OpenAPI, or dependency file is in it — and CI runs them anyway.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

Auth/CORS/session, OpenAPI/MCP, and UI are all not applicable — this diff contains no runtime change
of any kind. No changelog edit.

UI Evidence

Not applicable — no visible UI, frontend, docs, or extension change. The only non-line-ending edits are
a root .gitattributes and one run: step in .github/workflows/ci.yml.

Notes

  • The whitespace step only started catching this recently. It used to run git diff --check with no
    arguments against a shallow single-commit checkout, where working tree and index are always identical,
    so it unconditionally passed. Fixing that false-green is what turned these pre-existing CRLF files
    into a live trap — the files are old, the failure is new.
  • Four of the twenty are mixed: src/review/inline-comment-range.ts is 36 CRLF lines out of 54,
    test/unit/inline-comment-range.test.ts 66 of 97. Which lines tripped the check depended on where in
    the file you happened to edit, which is part of why it read as random.

… it is

Twenty files were committed with CRLF and the repo had no .gitattributes. The `changes` job runs
`git diff --check`, and git's default core.whitespace is `blank-at-eol` with `cr-at-eol` off, so a
carriage return at end-of-line counts as trailing whitespace. Any PR adding a line to one of those
files failed CI pointing at lines whose visible content is spotless, with nothing in the log saying
"CRLF" — it hit #9787 (run 30436384202) on two lines of inline-suggestion-anchor.ts.

Convert all twenty to LF via `git add --renormalize`, byte-identical otherwise (`git diff -w` reports
only the two new files below), and pin the repo with `* text=auto eol=lf`. `text=auto` rather than a
bare `text` is load-bearing: five .ts files embed NUL bytes as untrusted-text and sanitizer fixtures,
and auto-detection classifies them binary and passes them through untouched.

The whitespace step now names CRLF before falling through to the generic check. .gitattributes stops
CRLF entering through `git add`, but checkin filters don't run on blobs written directly (web editor,
Contents API) or on a merge of a branch cut earlier, so the diagnostic still has a job. It is scoped
to added lines, so it fires on exactly what `git diff --check` already flagged — a relabel, not a new
failure mode.

Closes #9798
@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 10:26:39 UTC

23 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): .github/workflows/ci.yml (matched .github/workflows/**).

Review summary
This PR normalizes twenty pre-existing CRLF files to LF via `git add --renormalize`, adds a root `.gitattributes` pinning the tree to LF (deliberately `text=auto eol=lf` rather than a bare `text eol=lf`, to preserve NUL-byte binary detection for fixtures that intentionally embed NUL bytes), and adds a CI step in `.github/workflows/ci.yml` that scans added lines for trailing `\r` and fails with an explicit CRLF message before the existing `git diff --check` step. The content-only diffs (spot-checked in `issue-quality-report.ts`, `binary-extensions.ts`, `inline-suggestion-anchor.ts`, etc.) are byte-identical apart from line endings, matching the PR's own `git diff -w --stat` claim. The change is narrowly scoped to its stated intent (#9798) and grounded in a real reproduced incident (#9787).

Nits — 7 non-blocking
  • The `codecov/patch` check failed (47.96% vs 99% target); this is very likely a mechanical side effect of `git add --renormalize` rewriting every line of twenty already-tested files, which makes the whole file appear as 'changed' to Codecov's patch-coverage gate even though nothing semantically changed — worth calling out explicitly in the PR description so reviewers don't chase it as a real coverage gap.
  • The magic-number, deep-nesting, and hardcoded-URL findings from the external brief (`issue-quality-report.ts`, `changed-files-diff-link.ts`) are all pre-existing code lines that only appear as 'added' because of the CRLF→LF rewrite — they are not new issues introduced by this PR and can be ignored.
  • `.github/workflows/ci.yml`'s new CRLF-detection step is explicitly described as dead-on-the-happy-path once `.gitattributes` lands (only reachable via the GitHub web editor, Contents API, or a pre-`.gitattributes` branch merge) — worth a short code comment pointer or a follow-up issue to remove it if it never fires over some observation window, so it doesn't linger as untested legacy code indefinitely.
  • Consider splitting the mechanical renormalization commit from the two new files (`.gitattributes`, `ci.yml` step) in the commit history (if not already done) so `git blame` on the twenty renormalized files isn't polluted with an unrelated whitespace-only commit.
  • In the PR description, proactively address the `codecov/patch` failure with the whole-file-rewrite explanation so maintainers don't need to dig for it themselves.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ⚠️ Gate result — Not blocking (Advisory; not blocking this PR.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9798
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 14 registered-repo PR(s), 13 merged, 361 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 14 PR(s), 361 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The PR converts all listed CRLF files (plus the nine additional review-enrichment files) to LF via renormalization, adds the root .gitattributes with the specified `* text=auto eol=lf` (preserving NUL-byte fixtures via text=auto), and adds a CI step that explicitly names CRLF in added lines before falling through to the generic whitespace check, matching all three expectations in the issue.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: Python, TypeScript, Ruby, Go, MDX, Shell, Solidity, JavaScript
  • Official Gittensor activity: 14 PR(s), 361 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Then work through the remaining 1 step in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: guardrail_hold
  • config: 1ae87fb0915339f2b13161c2163e4a7ba66c735aaf72ff23247f3e2ed1308fd3 · pack: oss-anti-slop · ci: pending
  • record: 252bf74d45b7045540b01846007bbd59dedcbf1f878f28dac7def97ce1470a1b (schema v5, head b649971)

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 267a99c Commit Preview URL

Branch Preview URL
Jul 29 2026, 09:45 AM

@JSONbored JSONbored self-assigned this Jul 29, 2026
@JSONbored
JSONbored marked this pull request as ready for review July 29, 2026 09:42
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.46%. Comparing base (f5711a3) to head (b649971).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9799      +/-   ##
==========================================
+ Coverage   90.33%   90.46%   +0.12%     
==========================================
  Files         918      918              
  Lines      113936   113936              
  Branches    26975    27050      +75     
==========================================
+ Hits       102926   103074     +148     
+ Misses       9681     9533     -148     
  Partials     1329     1329              
Flag Coverage Δ
backend 95.57% <100.00%> (ø)
control-plane 100.00% <ø> (ø)
engine 68.68% <100.00%> (+0.80%) ⬆️
rees 89.62% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...oopover-engine/src/signals/issue-quality-report.ts 100.00% <100.00%> (+31.94%) ⬆️
...view-enrichment/src/analyzers/binary-extensions.ts 100.00% <100.00%> (ø)
src/review/changed-files-diff-link.ts 100.00% <100.00%> (ø)
src/review/inline-comment-label.ts 100.00% <100.00%> (ø)
src/review/inline-comment-range.ts 100.00% <100.00%> (ø)
src/review/inline-suggestion-anchor.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

…engine suite

`buildIssueQualityReport` is re-exported from the engine barrel (src/index.ts) but this package's own
node:test suite never called it. `npm run engine:coverage` therefore saw the module load — top-level
constants only — and reported it LF:313 LH:96 with BRF:0, i.e. no function-level data at all, while
the root vitest suite covered the same file 87/87 lines and 143/143 branches.

Two uploads disagreeing about the same file is invisible while patch coverage only reads changed
lines, because nothing changes all 313 at once. Renormalizing the file's line endings did, and the
merged report capped at ~57%: of the 217 lines the engine flag called uncovered, 84 were rescued by
vitest and 133 were function-signature and closing-brace lines v8 never lists as statements, so
nothing could rescue them.

Cover it where this package is actually graded rather than leaning on the vitest duplicate — the
outcome scripts/engine-coverage.ts (#9064) was written to encourage. The file now reports
313/313 lines and 163/163 branches under the engine model.

17 cases covering the lane arms (issue_discovery / direct_pr / split / unknown), every bounty
lifecycle, duplicate and invalid labelling, self-solved loops, maintainer-authored vs maintainer-WIP,
linkedPrs back-references for both open and merged PRs, collision risk tiers, sort order, the
lifecycle and report caps, and the null-repo / unparseable-date degradation paths.
@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 29, 2026
@JSONbored
JSONbored merged commit ee98373 into main Jul 29, 2026
7 checks passed
@JSONbored
JSONbored deleted the fix/crlf-line-endings branch July 29, 2026 10:27
JSONbored added a commit that referenced this pull request Jul 29, 2026
`notify.after_n_builds` fires on the Nth upload to ARRIVE, and arrival order does not match
importance. validate-code's rees / control-plane / engine reports land in ~2 minutes; validate-tests
is still producing the backend lcov that covers most of src/**. So codecov/patch posted a conclusion
computed from a partial report — on #9799 it went pass, then fail, while validate-tests was still
pending, with Codecov's own comment printing `backend | BASE 1 | HEAD 0`.

That is not cosmetic: the gate closes a contributor PR on any red check, codecov/patch included, so a
transient partial-report red can close a PR that has no defect. `require_ci_to_pass` gates the final
verdict but does not suppress the interim status, and `wait_for_ci` (already on by default) did not
prevent it either.

Raising the count cannot fix this — the reasoning preserved on `after_n_builds` explains why a floor
above the guaranteed minimum leaves codecov/patch permanently un-posted on PRs that produce fewer
uploads — because a count cannot express "wait for the backend upload specifically". `manual_trigger`
can: Codecov sends nothing until `codecovcli send-notifications` runs, and the new codecov-notify job
runs it once, after every uploading job has finished.

The notifier is deliberately unable to fail a PR. It is not in `validate`'s needs, and every failure
path — a missing pipx, a failed install, a rejected notification — warns and exits 0. If it never
runs, no status posts, the check set stays incomplete and the gate waits: it cannot merge unreviewed
and cannot false-close, which is the whole point.

`!cancelled()` rather than `always()` so a run superseded by a newer push does not notify on a stale
sha, and the job skips entirely when neither upload job ran, since notifying on a commit Codecov has
no reports for is an error rather than a verdict.

Closes #9801

Co-authored-by: JSONbored <aetherealdev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CRLF files on main make the changes job fail with a misleading "trailing whitespace" error

1 participant