Skip to content

feat(core): feature-gate __internal module and promote normalize_line_endings to stable API#519

Merged
avifenesh merged 10 commits intomainfrom
fix/remove-internal-module-472
Feb 20, 2026
Merged

feat(core): feature-gate __internal module and promote normalize_line_endings to stable API#519
avifenesh merged 10 commits intomainfrom
fix/remove-internal-module-472

Conversation

@avifenesh
Copy link
Collaborator

Summary

Resolves #472.

  • Add __internal Cargo feature flag to agnix-core to gate the __internal module, removing the implicit semver obligations created by its previously unconditional public visibility
  • Promote normalize_line_endings to a stable public API at the crate root (agnix_core::normalize_line_endings), since agnix-lsp uses it in production code and it is a genuine utility with no internal type dependencies
  • Update all consumers: agnix-lsp import path, fuzz crate dependency, integration test dev-dependency, workspace root dev-dependencies, and benchmark required-features

Changes

crates/agnix-core/src/lib.rs

  • Add pub use parsers::frontmatter::normalize_line_endings as stable public re-export
  • Gate __internal module behind #[doc(hidden)] #[cfg(any(test, feature = "__internal"))]

crates/agnix-core/Cargo.toml

  • Add __internal = [] feature
  • Add required-features = ["__internal"] to the validation benchmark target
  • Add self-referential dev-dependency to enable __internal for integration tests (standard Cargo pattern; cfg(test) does not apply to integration test compilations)

crates/agnix-lsp/src/backend/events.rs

  • Update import from agnix_core::__internal::normalize_line_endings to agnix_core::normalize_line_endings

crates/agnix-core/fuzz/Cargo.toml

  • Add features = ["__internal"] to the agnix-core dependency

Cargo.toml (workspace root)

  • Add "__internal" to workspace dev-dependency features alongside "__internal_unchecked"

crates/agnix-core/tests/api_contract.rs

  • Add normalize_line_endings_is_public_api test covering all Cow contract cases: Cow::Owned for CRLF, lone CR, and mixed; Cow::Borrowed for LF-only and empty; pointer identity for zero-copy guarantee

CHANGELOG.md, CLAUDE.md, AGENTS.md

  • Document the feature gate and stable API promotion

Test Plan

  • cargo test --workspace - 3680+ tests, 0 failures
  • cargo build --package agnix-lsp - compiles without __internal feature
  • cargo check --package agnix-core (default, no --internal) - __internal module absent
  • cargo check --package agnix-core --all-features - __internal module present
  • cargo bench --bench validation --package agnix-core --features __internal -- --test - benchmark compiles
  • diff CLAUDE.md AGENTS.md - files are byte-for-byte identical

…nternal

- Re-export `normalize_line_endings` at crate root as stable public API
- Remove `normalize_line_endings` from `__internal` module re-exports
- Gate `__internal` module behind `#[cfg(any(test, feature = "__internal"))]`
- Add `__internal` Cargo feature for fuzz/bench/integration test use
- Add `required-features = ["__internal"]` to validation bench target
- Update agnix-lsp to import from `agnix_core::normalize_line_endings`
…n tests

- Add `features = ["__internal"]` to fuzz crate dependency on agnix-core
- Add self-referential dev-dependency in agnix-core to enable __internal
  for integration tests (cfg(test) does not apply to the library when
  compiling integration tests)
- Add "__internal" to workspace root dev-dependency feature list
…CHANGELOG

- Add integration test verifying normalize_line_endings is accessible via
  the public API (agnix_core::normalize_line_endings)
- Document __internal feature gate and normalize_line_endings promotion
  in CHANGELOG.md under [Unreleased]
Add Cow::Borrowed contract assertion for LF-only input and lone CR
normalization case, completing full coverage of the public API contract.
- Swap #[doc(hidden)] / #[cfg(...)] attribute order to match Rust convention
- Add Stability: stable annotation to normalize_line_endings public API
- Use ## prefix for __internal feature comment to match __internal_unchecked
- Strengthen api_contract test: add Cow::Owned assertions for CRLF/CR cases,
  empty string, mixed line endings, and pointer identity for Cow::Borrowed
Copilot AI review requested due to automatic review settings February 20, 2026 13:44
@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 refines the API surface of the agnix-core crate by explicitly managing the visibility of internal components and promoting a commonly used utility function. The changes enhance API stability by preventing unintended external dependencies on internal implementation details, while making a genuinely useful function more accessible. This ensures a clearer separation between stable public interfaces and internal mechanisms, improving maintainability and future compatibility.

Highlights

  • Feature-gated __internal module: The __internal module in agnix-core is now protected by a Cargo feature flag, removing implicit semver obligations for internal components that were previously publicly visible.
  • Promoted normalize_line_endings to stable API: The normalize_line_endings function has been moved to a stable public API at the crate root (agnix_core::normalize_line_endings), acknowledging its utility and use in production code within agnix-lsp.
  • Updated consumer dependencies and configurations: All relevant consumers, including agnix-lsp, fuzz targets, integration tests, and benchmarks, have been updated to reflect the API changes and utilize the new __internal feature flag where appropriate.
Changelog
  • AGENTS.md
    • Documented the feature-gating of the __internal module and the promotion of normalize_line_endings to a stable public API.
  • CHANGELOG.md
    • Added an entry for the __internal module being feature-gated.
    • Added an entry for normalize_line_endings being promoted to a stable public API.
  • CLAUDE.md
    • Documented the feature-gating of the __internal module and the promotion of normalize_line_endings to a stable public API.
  • Cargo.lock
    • Updated dependencies to include a self-reference for agnix-core with the __internal feature enabled.
  • Cargo.toml
    • Added the __internal feature to the agnix-core dev-dependency in the workspace root.
  • crates/agnix-core/Cargo.toml
    • Added a new __internal Cargo feature.
    • Configured agnix-core as a self-referencing dev-dependency with the __internal feature for integration tests.
    • Added required-features = ["__internal"] to the validation benchmark target.
  • crates/agnix-core/fuzz/Cargo.toml
    • Added the __internal feature to the agnix-core dependency for fuzzing.
  • crates/agnix-core/src/lib.rs
    • Promoted normalize_line_endings to a stable public re-export at the crate root.
    • Feature-gated the __internal module using #[cfg(any(test, feature = "__internal"))].
  • crates/agnix-core/tests/api_contract.rs
    • Added a new test suite for normalize_line_endings covering various Cow contract cases, including Cow::Owned for CRLF, lone CR, and mixed endings, and Cow::Borrowed for LF-only and empty strings with pointer identity verification.
  • crates/agnix-lsp/src/backend/events.rs
    • Updated the import path for normalize_line_endings to its new stable location at the crate root.
Activity
  • All workspace tests (cargo test --workspace) passed with over 3680 tests and 0 failures.
  • The agnix-lsp package successfully compiled (cargo build --package agnix-lsp) without the __internal feature.
  • A default cargo check --package agnix-core confirmed the __internal module was absent.
  • A cargo check --package agnix-core --all-features confirmed the __internal module was present.
  • The validation benchmark for agnix-core compiled successfully with the __internal feature enabled (cargo bench --bench validation --package agnix-core --features __internal -- --test).
  • A byte-for-byte comparison (diff CLAUDE.md AGENTS.md) confirmed these documentation files are identical.
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

This pull request effectively gates the __internal module behind a feature flag and promotes normalize_line_endings to a stable public API. The changes are well-implemented across the workspace, including updates to Cargo.toml files, consumers of the function, and documentation. The new integration test for normalize_line_endings is comprehensive. I have one suggestion to improve the test structure for better maintainability.

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 resolves #472 by reducing unintended semver surface area in agnix-core while keeping a production-used utility function available as a stable API.

Changes:

  • Feature-gates agnix_core::__internal behind the new __internal Cargo feature (or cfg(test)), preventing unconditional public exposure.
  • Promotes normalize_line_endings to a stable crate-root API (agnix_core::normalize_line_endings) and updates consumers accordingly.
  • Updates fuzz/bench/test configuration (features + required-features) and adds an integration test to lock in the Cow/zero-copy contract.

Reviewed changes

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

Show a summary per file
File Description
crates/agnix-lsp/src/backend/events.rs Switches to the new stable agnix_core::normalize_line_endings import.
crates/agnix-core/tests/api_contract.rs Adds an API contract test ensuring stable behavior and Cow guarantees for normalize_line_endings.
crates/agnix-core/src/lib.rs Re-exports normalize_line_endings at crate root; gates __internal behind __internal feature / cfg(test).
crates/agnix-core/fuzz/Cargo.toml Enables __internal feature for fuzz targets that rely on hidden re-exports.
crates/agnix-core/Cargo.toml Introduces __internal feature; adds bench required-features; adds self dev-dep to enable __internal for integration tests.
Cargo.toml Enables __internal in workspace root dev-dependency features.
Cargo.lock Lockfile update reflecting the self dev-dependency entry.
CLAUDE.md Documents the new __internal gating and crate-root stable API for normalize_line_endings.
CHANGELOG.md Notes the __internal feature gate and stable API promotion.
AGENTS.md Mirrors the documentation updates for agent guidance.

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

@avifenesh
Copy link
Collaborator Author

Addressed gemini-code-assist's suggestion: split the single normalize_line_endings_is_public_api test into 5 focused per-case tests (97603aa) for clearer failure signals on regression.

@avifenesh avifenesh merged commit a93b724 into main Feb 20, 2026
25 checks passed
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.

Architecture: remove or feature-gate __internal module

2 participants