Skip to content

fix(core): remove unused CoreResult type alias, standardize on LintResult (#477)#520

Merged
avifenesh merged 6 commits intomainfrom
feature/standardize-result-type-477
Feb 20, 2026
Merged

fix(core): remove unused CoreResult type alias, standardize on LintResult (#477)#520
avifenesh merged 6 commits intomainfrom
feature/standardize-result-type-477

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Remove pub type CoreResult<T> = Result<T, CoreError>; from diagnostics.rs - it was defined and re-exported but never used anywhere in the codebase
  • Remove CoreResult from the pub use diagnostics::{...} re-export block in lib.rs
  • Add lint_result_is_sole_result_alias regression test with exhaustive CoreError variant matching
  • Expand public_types_are_importable to assert CoreError is still exported
  • Upgrade LintError alias comment to rustdoc (///)
  • Expand CHANGELOG migration note to clarify LintError/CoreError relationship
  • Sync CLAUDE.md/AGENTS.md to document LintError and LintResult in the diagnostics.rs module entry

Why CoreResult was dead code

CoreResult<T> was defined alongside LintResult<T> but never adopted. LintResult<T> is the established convention used across 40+ call sites in 9 files. Since LintError = CoreError (a type alias), both result types were identical at the type-system level - CoreResult was a redundant export with zero usages.

Migration

Before:

use agnix_core::CoreResult;  // was available but unused

After:

use agnix_core::LintResult;  // sole public Result alias
// LintResult<T> = Result<T, LintError> = Result<T, CoreError>

CoreError and LintError (its public alias) remain exported and unchanged.

Test Plan

  • cargo test -p agnix-core - all 50 API contract tests pass, including new lint_result_is_sole_result_alias
  • cargo test - full workspace: 3682 tests pass (net +1 vs main)
  • cargo check - clean, no warnings
  • grep -r "CoreResult" crates/ - zero live usages remain

Closes #477

…sult (#477)

CoreResult<T> was defined and re-exported but never used anywhere in the
codebase. LintResult<T> is the established convention used in 40+ locations.
Since LintError is already an alias for CoreError, both aliases resolved to
the same type - CoreResult was pure dead code.

Closes #477
…al assertions

Replace trivially-true type_name checks with concrete Err construction
using CoreError::Validation variants, verifying the LintResult<T> =
Result<T, LintError> = Result<T, CoreError> chain end-to-end.
- Add CoreError to public_types_are_importable contract test
- Replace panic! with unreachable! in test catch-all arm
- Upgrade LintError alias comment to rustdoc (/// style)
- Expand CHANGELOG migration note to clarify LintError/CoreError relationship
…is_sole_result_alias

Replace wildcard arm with explicit File/Validation/Config arms so the match
is truly exhaustive. A new CoreError variant will now cause a compile error
in this test rather than silently passing.
…on (#477)

The diagnostics.rs entry in CLAUDE.md/AGENTS.md omitted LintError and
LintResult, which are the primary public error types from that module.
With CoreResult removed, LintResult is now the sole public Result alias
- making this an appropriate time to document both types explicitly.
Copilot AI review requested due to automatic review settings February 20, 2026 14:51
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @avifenesh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request streamlines the error handling type aliases within the agnix-core crate by removing the unused CoreResult type. The change standardizes on LintResult as the sole public Result alias, enhancing clarity and consistency in the API. It also includes comprehensive testing and documentation updates to reflect this simplification, ensuring that CoreError and its alias LintError remain properly exposed and functional.

Highlights

  • CoreResult Removal: The CoreResult type alias has been removed from diagnostics.rs and its re-export in lib.rs as it was unused and redundant.
  • LintResult Standardization: The codebase now exclusively uses LintResult<T> as the public Result alias, clarifying error handling types.
  • Documentation Updates: CHANGELOG.md, CLAUDE.md, and AGENTS.md have been updated to reflect the change and document LintError and LintResult.
  • Improved Testing: A new regression test, lint_result_is_sole_result_alias, was added to ensure LintResult's correctness and exhaustive CoreError variant matching, alongside an expansion of public_types_are_importable to confirm CoreError export.
  • Comment Enhancement: The LintError alias comment in diagnostics.rs was upgraded to rustdoc for better documentation.
Changelog
  • CHANGELOG.md
    • Added a breaking change entry detailing the removal of CoreResult<T> and advising the use of LintResult<T> instead, while clarifying that LintError (an alias for CoreError) remains exported.
Activity
  • All cargo test -p agnix-core API contract tests passed, including the newly added lint_result_is_sole_result_alias test.
  • The full workspace cargo test command passed with 3682 tests.
  • cargo check completed without warnings.
  • A grep search confirmed no live usages of "CoreResult" remain in the crates/ directory.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request effectively removes the unused CoreResult type alias and standardizes on LintResult, improving code clarity and reducing redundancy. The changes are well-tested with new regression tests and updates to existing API contract tests. Documentation in CHANGELOG.md, CLAUDE.md, and AGENTS.md has been updated to reflect these changes, ensuring consistency across the project. The use of rustdoc for LintError is a good improvement for public API documentation.

- `rules/` - Validators implementing Validator trait (25 validators)
- `config.rs` - LintConfig, LintConfigBuilder, ConfigError, ToolVersions, SpecRevisions
- `diagnostics.rs` - Diagnostic, Fix, DiagnosticLevel, ValidationOutcome
- `diagnostics.rs` - Diagnostic, Fix, DiagnosticLevel, ValidationOutcome, LintError (= CoreError), LintResult
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The documentation for diagnostics.rs in AGENTS.md has been updated to correctly reflect the removal of CoreResult and the standardization on LintResult and LintError. This ensures that the documentation remains accurate and consistent with the code changes.

- **`MAX_REGEX_INPUT_SIZE` precise boundary tests**: 27 tests covering the exact 65536-byte limit for all 12 guarded regex functions across `markdown.rs`, `prompt.rs`, and `cross_platform.rs` - each function gets an at-limit (processed) and one-byte-over (rejected) test; also confirms `extract_imports` and `extract_markdown_links` are unrestricted (byte-scan/pulldown-cmark, not regex) (#457)

### Changed
- **`CoreResult` type alias removed** (breaking): `CoreResult<T>` has been removed from the public API. Use `LintResult<T>` (i.e., `Result<T, LintError>`) instead. `LintError` is a public alias for `CoreError`; both remain exported. (#477)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The CHANGELOG.md entry clearly documents the removal of CoreResult and the recommendation to use LintResult, along with the clarification of LintError as an alias for CoreError. This is a good practice for communicating breaking changes and migration paths to users.

- `rules/` - Validators implementing Validator trait (25 validators)
- `config.rs` - LintConfig, LintConfigBuilder, ConfigError, ToolVersions, SpecRevisions
- `diagnostics.rs` - Diagnostic, Fix, DiagnosticLevel, ValidationOutcome
- `diagnostics.rs` - Diagnostic, Fix, DiagnosticLevel, ValidationOutcome, LintError (= CoreError), LintResult
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The documentation for diagnostics.rs in CLAUDE.md has been updated to correctly reflect the removal of CoreResult and the standardization on LintResult and LintError. This ensures that the documentation remains accurate and consistent with the code changes.

use thiserror::Error;

pub type LintResult<T> = Result<T, LintError>;
pub type CoreResult<T> = Result<T, CoreError>;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The CoreResult type alias has been correctly removed from diagnostics.rs, as it was unused and redundant. This simplifies the public API and reduces potential confusion.

Comment on lines +675 to +679
/// `LintError` is the canonical public name for [`CoreError`].
///
/// Both names are re-exported at the crate root. Internal code constructs
/// variants via `CoreError`; public API surfaces and function signatures
/// use `LintError` and [`LintResult`].
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The comment for LintError has been upgraded to a rustdoc comment (///), which is a good practice for public API documentation. It clearly explains the relationship between LintError and CoreError and their intended usage.


pub use config::{ConfigWarning, FilesConfig, LintConfig, generate_schema};
pub use diagnostics::{
ConfigError, CoreError, CoreResult, Diagnostic, DiagnosticLevel, FileError, Fix,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The CoreResult re-export has been correctly removed from lib.rs, aligning with its removal from diagnostics.rs and standardizing on LintResult as the sole public Result alias.

Comment on lines +31 to 35
// Error types: CoreError is the concrete enum; LintError is its public alias.
// Both are re-exported. CoreResult was removed in #477.
let _ = std::any::type_name::<agnix_core::CoreError>();
// LintResult type alias - the sole public Result alias.
let _ = std::any::type_name::<agnix_core::LintResult<()>>();
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The public_types_are_importable test has been updated to reflect the removal of CoreResult and the explicit re-export of CoreError. This ensures that the API contract tests accurately represent the public API surface.

Comment on lines +1142 to +1181

// ============================================================================
// LintResult is the sole public Result alias (#477)
// ============================================================================

/// Verify that `LintResult<T>` is the sole public Result alias in agnix-core.
///
/// `CoreResult<T>` was removed in #477 because it was dead code - defined and
/// re-exported but never used anywhere in the codebase. `LintResult<T>` is the
/// established convention used across 40+ call sites.
#[test]
fn lint_result_is_sole_result_alias() {
use agnix_core::{CoreError, LintError, LintResult, ValidationError};

// LintResult<T> must accept Ok values.
let ok: LintResult<u32> = Ok(42);
assert_eq!(ok.unwrap(), 42);

// LintResult<T> must accept Err values constructed from a concrete CoreError variant.
// This verifies LintResult<T> = Result<T, LintError> = Result<T, CoreError> end-to-end.
let err: LintResult<u32> = Err(CoreError::Validation(ValidationError::TooManyFiles {
count: 9999,
limit: 1000,
}));
assert!(err.is_err());

// LintError and CoreError are type aliases for the same enum - constructing
// one variant via CoreError and matching through LintError must work.
let lint_err: LintError = CoreError::Validation(ValidationError::TooManyFiles {
count: 1,
limit: 0,
});
// Exhaustively match all three CoreError variants through the LintError alias.
// If a new CoreError variant is added, this match will fail to compile.
match lint_err {
LintError::File(_) => {}
LintError::Validation(_) => {}
LintError::Config(_) => {}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

A new regression test lint_result_is_sole_result_alias has been added to verify that LintResult<T> is indeed the sole public Result alias and that it correctly handles Ok and Err values, including exhaustive matching of CoreError variants. This is a robust test for the intended behavior.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes the unused CoreResult<T> type alias from the public API and standardizes on LintResult<T> as the sole Result type alias for agnix-core. The change addresses issue #477 which identified inconsistent API design where both type aliases were exported but only LintResult was actually used across the codebase (40+ call sites in 9 files).

Changes:

  • Removed the dead CoreResult<T> type alias definition and its re-export
  • Added comprehensive regression test lint_result_is_sole_result_alias with exhaustive variant matching
  • Upgraded LintError documentation to rustdoc with clear guidance on usage conventions
  • Updated all documentation files (CHANGELOG, CLAUDE.md, AGENTS.md) with consistent messaging

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/agnix-core/src/diagnostics.rs Removed unused CoreResult<T> type alias; upgraded LintError comment to rustdoc with usage guidance
crates/agnix-core/src/lib.rs Removed CoreResult from public re-export list
crates/agnix-core/tests/api_contract.rs Added lint_result_is_sole_result_alias regression test; updated public_types_are_importable to assert CoreError export and document the removal
CHANGELOG.md Added breaking change entry with clear migration path from CoreResult to LintResult
CLAUDE.md Updated diagnostics.rs module entry to document LintError and LintResult
AGENTS.md Updated diagnostics.rs module entry to document LintError and LintResult

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Reformat pub use statement in lib.rs and struct initialization in test to comply with cargo fmt standards.
@avifenesh avifenesh merged commit 6f2fb95 into main Feb 20, 2026
23 checks passed
@avifenesh avifenesh deleted the feature/standardize-result-type-477 branch February 20, 2026 15:07
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.

Standardize on one Result type alias for public API

2 participants