Skip to content

fix: cargo check for non-Git-LFS checkout(fail-check scanner contract)#8

Open
kernelstub wants to merge 2 commits into
santhsecurity:mainfrom
kernelstub:main
Open

fix: cargo check for non-Git-LFS checkout(fail-check scanner contract)#8
kernelstub wants to merge 2 commits into
santhsecurity:mainfrom
kernelstub:main

Conversation

@kernelstub

@kernelstub kernelstub commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Restored workspace cargo check --all-targets in non-Git-LFS checkouts by replacing three historical scanner diagnostic test targets that had been committed as raw Git LFS pointers with compiling ignored placeholders. Added a scanner contract that fails with a clear message if a top-level Rust test target is ever checked in as an LFS pointer again.

Why

Detector / scanner changes

  • Detector ID:
  • Sample input (redacted if real):
  • Adversarial twin shipped: yes / no — if no, why?
  • Recall delta (corpus run): +N / -N
  • Precision delta (corpus run): +N / -N

Test plan

  • [ x] cargo test --workspace
  • [ x] cargo clippy --workspace --all-targets -- -D warnings
  • [ x] Scan a known-leaky fixture and confirm exit code 1 + a finding for the
    claimed rule on the claimed line
  • [ x] Scan a known-clean fixture and confirm exit code 0

Risk

Backwards compatibility

Screenshots / output snippets

Summary by CodeRabbit

  • Bug Fixes

    • Restored cargo check/test behavior in non-Git-LFS checkouts so toolchain commands run without Git LFS assets.
  • Tests

    • Added a contract test to detect any Rust test sources committed as Git LFS pointers.
    • Replaced missing LFS-backed tests with in-repo placeholder tests (ignored) to avoid parsing failures.
  • Documentation

    • Updated changelog with details and a clearer scanner failure message if an LFS pointer test is found.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 82c80857-143b-48b8-8d99-1b0403a3cf3c

📥 Commits

Reviewing files that changed from the base of the PR and between 5fa7a8d and 54deebf.

📒 Files selected for processing (1)
  • crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs

📝 Walkthrough

Walkthrough

Replaces three Rust test files that were raw Git LFS pointers with compilable placeholder tests, adds a contract test that fails if a top-level Rust test file is an LFS pointer, updates CHANGELOG.md, and applies a minor EOF/whitespace adjustment.

Changes

LFS Pointer Cleanup and Guard Contract

Layer / File(s) Summary
Guard contract for LFS pointers
crates/scanner/tests/contract/mod.rs, crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs
New contract test enumerates .rs files under the scanner test directory, reads each file, detects Git LFS pointer headers by prefix match (version https://git-lfs.github.com/spec/v1), and asserts none are present, failing with offending paths.
Test file placeholder replacements
crates/scanner/tests/diagnose_84_divergence.rs, crates/scanner/tests/diagnose_sb_divergence.rs, crates/scanner/tests/readme_claims.rs
Three files replaced from raw Git LFS pointer contents to compilable Rust test modules; each now contains an ignored #[test] that documents the missing historical diagnostic payload while preserving the test target name.
Documentation and formatting
CHANGELOG.md, crates/sources/src/git/diff.rs
CHANGELOG entry documents the fix and new guard contract; diff.rs EOF/whitespace region adjusted with no behavioral change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 I hopped through tests and fixed the plight,
Replaced lost payloads with placeholders bright.
A contract now watches each .rs sight,
So builds stay green both day and night.
🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing cargo check for non-Git-LFS checkouts by implementing a fail-check scanner contract.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs`:
- Around line 23-25: The test currently silently skips unreadable files by using
`let Ok(source) = std::fs::read_to_string(&path) else { continue; }`; change
this to fail the test on read errors and include the file path in the
message—e.g., replace the `let Ok(...) else continue` with a direct match or
`expect` that panics with a descriptive message containing `path` (or call
`unwrap_or_else(|e| panic!(...))`) so unreadable `.rs` files cause the test to
fail with the path and error context instead of being skipped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b739fd01-557c-432a-8e28-920a82b8c4bc

📥 Commits

Reviewing files that changed from the base of the PR and between 188278b and 5fa7a8d.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • crates/scanner/tests/contract/mod.rs
  • crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs
  • crates/scanner/tests/diagnose_84_divergence.rs
  • crates/scanner/tests/diagnose_sb_divergence.rs
  • crates/scanner/tests/readme_claims.rs
  • crates/sources/src/git/diff.rs
💤 Files with no reviewable changes (1)
  • crates/sources/src/git/diff.rs

Comment thread crates/scanner/tests/contract/rust_test_sources_are_not_lfs_pointers.rs Outdated
…ointers.rs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@kernelstub

Copy link
Copy Markdown
Author

Any checks on this @santhsecurity ?

@santhsecurity santhsecurity left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: Codex auto left a slop comment without asking me while adding some tests.

I can't merge this pr onto main. The decision is correct for your checkout. But your checkout didn't include the git LFS-tracked files, so stubbing them out would remove the real test files. I hope you understand. Sorry about that.

Thank You

santhsecurity pushed a commit that referenced this pull request Jun 11, 2026
readme_claims.rs and diagnose_*.rs were LFS-tracked via .gitattributes, so a
non-LFS checkout materialized them as pointer files that Cargo tried to parse
as Rust — `cargo check --all-targets` failed before any test ran. Rust source
must never be LFS-tracked.

Removed the `*.rs filter=lfs` rules and re-added the three files as normal
text, preserving their real content: readme_claims.rs is the active
README-claims regression suite; diagnose_*.rs are the SIMD/GPU divergence
diagnostics. (readme_claims.rs also carries this session's count-derive
improvement to that suite.)

Adds a contract guard (rust_test_sources_are_not_lfs_pointers) that fails if any
tests/**/*.rs is an LFS pointer OR if .gitattributes LFS-tracks a .rs path —
so the misconfiguration is caught in both LFS and non-LFS checkouts.

Supersedes the destructive approach in PR #8, which stubbed the three real test
files out with empty #[ignore] placeholders (~540 lines of lost coverage) and
left the .gitattributes root cause in place. Keeps PR #8's guard-test idea.

Follow-up (not fixed here): the contract *.toml fixtures and proptest-regressions
are still LFS-tracked, so a non-LFS checkout breaks contracts_runner too.
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