Skip to content

fix(native): restore cargo test --lib green#978

Open
carlos-alm wants to merge 1 commit intomainfrom
fix/cargo-test-failures
Open

fix(native): restore cargo test --lib green#978
carlos-alm wants to merge 1 commit intomainfrom
fix/cargo-test-failures

Conversation

@carlos-alm
Copy link
Copy Markdown
Contributor

Summary

Fix 11 pre-existing cargo test --lib failures in crates/codegraph-core. CI only runs cargo check --workspace, so these rotted silently.

  • Scala/Swift grammar ABI mismatch (10 tests). tree-sitter-scala 0.25 and tree-sitter-swift 0.7 emit ABI-15 grammars, but the workspace pins tree-sitter = "0.24" (supports up to ABI-14). Loading either grammar raised LanguageError { version: 15 }. Downgrade to the last 0.24-compatible releases: tree-sitter-scala 0.24.1, tree-sitter-swift 0.6.0.
  • config::tests::deserialize_empty_config (1 test). BuildSettings derived Default, which gave incremental: false via bool::default(). BuildConfig::build is #[serde(default)], so deserializing {} fell through to BuildSettings::default() and disagreed with the field-level #[serde(default = "default_true")]. Replace the derive with a manual Default impl that matches the serde defaults.

Result: 165 passed / 11 failed → 176 passed / 0 failed.

Test plan

  • cargo test --lib -p codegraph-core — 176 passed, 0 failed
  • cargo check --workspace — clean (5 pre-existing warnings, unchanged)
  • Consider a follow-up to add cargo test --lib to .github/workflows/ci.yml so these do not rot again

Three pre-existing failures surfaced by `cargo test --lib`, none of
which CI catches (CI only runs `cargo check --workspace`):

- `tree-sitter-scala 0.25` and `tree-sitter-swift 0.7` emit ABI-15
  grammars, but the workspace pins `tree-sitter = "0.24"` (supports up
  to ABI-14). Loading either grammar raised `LanguageError { version:
  15 }`, breaking all 10 Scala/Swift extractor tests. Downgrade to the
  last 0.24-compatible releases (0.24.1 / 0.6.0).

- `BuildSettings` derived `Default`, which gave `incremental: false`
  via `bool::default()`. `BuildConfig::build` is `#[serde(default)]`,
  so deserializing `{}` fell through to `BuildSettings::default()` and
  disagreed with the `#[serde(default = "default_true")]` field
  attribute. Implement `Default` manually so both paths agree.

Full suite now: 176 passed, 0 failed (was 165 passed, 11 failed).

docs check acknowledged — change is an internal grammar-crate
downgrade and a Default-impl bug fix; no user-facing API, language
support, or architecture change.
@claude
Copy link
Copy Markdown

claude bot commented Apr 20, 2026

Claude finished @carlos-alm's task —— View job


PR Review Analysis

Conducting comprehensive review of cargo test fixes...

Todo List:

  • Read and analyze changed files
  • Phase 1: Root cause analysis
  • Phase 2: Configuration change detection
  • Phase 3: Test integrity verification
  • Phase 4: Code quality assessment
  • Phase 5: Backlog compliance rating
  • Final recommendation and rating

Root Cause Analysis

Problem Being Solved: 11 pre-existing cargo test --lib failures in the native Rust codebase that rotted silently because CI only runs cargo check --workspace. The failures are legitimate technical issues, not hidden symptoms.

Why This Approach:

  1. Grammar ABI mismatch (10 tests): tree-sitter-scala 0.25 and tree-sitter-swift 0.7 emit ABI-15 grammars, but the workspace uses tree-sitter = "0.24" (max ABI-14). This causes LanguageError { version: 15 } when loading grammars. Correct fix: Downgrade to last compatible versions (tree-sitter-scala 0.24.1, tree-sitter-swift 0.6.0) rather than upgrading the entire tree-sitter ecosystem.

  2. Serde config mismatch (1 test): BuildSettings derived Default gave incremental: false via bool::default(), but the field has #[serde(default = "default_true")]. When deserializing {}, serde fell through to BuildSettings::default() which disagreed with field-level defaults. Correct fix: Replace derive with manual Default impl that matches serde expectations.

Risk Assessment: ✅ Low risk - Both fixes address root technical incompatibilities, not symptoms. The grammar downgrades are conservative (using last known-compatible versions) and the serde fix ensures consistency between Default and deserialization behavior.

Backlog Compliance

  • Zero-dep: ✅ No new dependencies added - Only version downgrades of existing tree-sitter grammar dependencies
  • Foundation-aligned: ✅ Fully compliant - No violations of core principles, maintains offline-first architecture
  • Problem-fit: 3/5 - Fixes testing infrastructure but doesn't directly address "AI agents waste tokens re-orienting in codebases." However, maintaining test suite health is essential foundation work.
  • Breaking: No - Internal dependency version changes with no API surface impact
  • Tier: 1 (zero-dep ✓ + foundation-aligned ✓)

Critical Concerns

None - This is a clean technical fix addressing legitimate compatibility issues.

Code Quality Observations:

  1. config.rs:38-48: Manual Default impl is well-documented and correctly matches serde field defaults
  2. Cargo.toml:28-29: Grammar downgrades are conservative, staying within 0.24-compatible ecosystem
  3. Test coverage: The fix includes a test case (deserialize_empty_config) that validates the serde behavior

Minor Suggestion: Consider the author's suggestion to add cargo test --lib to CI to prevent future rot.

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: Clean technical fix addressing real compatibility issues. Well-documented approach, conservative dependency management, and proper test coverage. The downgrades are the correct approach rather than forcing a tree-sitter major version bump across the entire ecosystem. Only minor deduction for being foundational rather than user-facing improvement.

Suggested Follow-up: Add cargo test --lib -p codegraph-core to CI workflow to prevent similar silent failures.


@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 20, 2026

Greptile Summary

This PR fixes 11 silently-rotted cargo test --lib failures in crates/codegraph-core by downgrading tree-sitter-scala (0.25→0.24) and tree-sitter-swift (0.7→0.6) to stay within the ABI-14 boundary of the workspace-pinned tree-sitter = "0.24", and by replacing #[derive(Default)] on BuildSettings with a manual Default impl that aligns incremental: true and drift_threshold: 0.1 with the serde field-level defaults. The root cause of each failure is well-explained and the fixes are minimal and targeted.

Confidence Score: 5/5

Safe to merge — all three changes are correct, targeted fixes with passing test verification.

All findings are P2 or below: the grammar downgrade is the correct ABI-compatible fix, the manual Default impl correctly aligns serde and Rust defaults, and the lockfile is consistent. No logic bugs, no security concerns, no regressions.

No files require special attention.

Important Files Changed

Filename Overview
crates/codegraph-core/src/config.rs Replaces #[derive(Default)] on BuildSettings with a manual Default impl that returns incremental: true and drift_threshold: 0.1, matching the serde field-level defaults and fixing the deserialize_empty_config test.
crates/codegraph-core/Cargo.toml Downgrades tree-sitter-swift from 0.7 to 0.6 and tree-sitter-scala from 0.25 to 0.24 to stay within ABI-14 supported by the workspace-pinned tree-sitter = "0.24"; also bumps package version to 3.9.4.
Cargo.lock Lock file updated to reflect downgraded tree-sitter-scala 0.24.1 and tree-sitter-swift 0.6.0 with correct checksums; straightforward lockfile regeneration.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["BuildConfig deserialized from '{}'"] --> B{build key present?}
    B -- "No (absent)" --> C["#serde(default) triggers\nBuildSettings::default()"]
    B -- "Yes" --> D["Deserialize BuildSettings fields"]
    C --> E["BEFORE: derive(Default)\nincremental = false ❌\ndrift_threshold = 0.0 ❌"]
    C --> F["AFTER: manual Default impl\nincremental = default_true() = true ✅\ndrift_threshold = default_drift_threshold() = 0.1 ✅"]
    D --> G["#serde(default = 'default_true')\nincremental = true ✅"]
    D --> H["#serde(default = 'default_drift_threshold')\ndrift_threshold = 0.1 ✅"]
Loading

Reviews (1): Last reviewed commit: "fix(native): restore cargo test --lib gr..." | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed0 callers affected across 0 files

  • BuildSettings.default in crates/codegraph-core/src/config.rs:42 (0 transitive callers)

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.

1 participant