Conversation
…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.
Summary of ChangesHello @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 Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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 |
| - **`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) |
There was a problem hiding this comment.
| - `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 |
| use thiserror::Error; | ||
|
|
||
| pub type LintResult<T> = Result<T, LintError>; | ||
| pub type CoreResult<T> = Result<T, CoreError>; |
| /// `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`]. |
|
|
||
| pub use config::{ConfigWarning, FilesConfig, LintConfig, generate_schema}; | ||
| pub use diagnostics::{ | ||
| ConfigError, CoreError, CoreResult, Diagnostic, DiagnosticLevel, FileError, Fix, |
| // 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<()>>(); |
|
|
||
| // ============================================================================ | ||
| // 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(_) => {} | ||
| } | ||
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
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_aliaswith exhaustive variant matching - Upgraded
LintErrordocumentation 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.
Summary
pub type CoreResult<T> = Result<T, CoreError>;fromdiagnostics.rs- it was defined and re-exported but never used anywhere in the codebaseCoreResultfrom thepub use diagnostics::{...}re-export block inlib.rslint_result_is_sole_result_aliasregression test with exhaustiveCoreErrorvariant matchingpublic_types_are_importableto assertCoreErroris still exportedLintErroralias comment to rustdoc (///)LintError/CoreErrorrelationshipCLAUDE.md/AGENTS.mdto documentLintErrorandLintResultin thediagnostics.rsmodule entryWhy CoreResult was dead code
CoreResult<T>was defined alongsideLintResult<T>but never adopted.LintResult<T>is the established convention used across 40+ call sites in 9 files. SinceLintError = CoreError(a type alias), both result types were identical at the type-system level -CoreResultwas a redundant export with zero usages.Migration
Before:
After:
CoreErrorandLintError(its public alias) remain exported and unchanged.Test Plan
cargo test -p agnix-core- all 50 API contract tests pass, including newlint_result_is_sole_result_aliascargo test- full workspace: 3682 tests pass (net +1 vs main)cargo check- clean, no warningsgrep -r "CoreResult" crates/- zero live usages remainCloses #477