Skip to content

[WIP] Cleanup#2977

Open
joshlf wants to merge 1 commit intoGb4a4c349671f37aad9e084998afdb7c57d92be43from
G0b9216c6738c722e3424be5ee5e085157b5813f9
Open

[WIP] Cleanup#2977
joshlf wants to merge 1 commit intoGb4a4c349671f37aad9e084998afdb7c57d92be43from
G0b9216c6738c722e3424be5ee5e085157b5813f9

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Feb 4, 2026


⬇️ Download this PR

Branch

git fetch origin refs/heads/G0b9216c6738c722e3424be5ee5e085157b5813f9 && git checkout -b pr-G0b9216c6738c722e3424be5ee5e085157b5813f9 FETCH_HEAD

Checkout

git fetch origin refs/heads/G0b9216c6738c722e3424be5ee5e085157b5813f9 && git checkout FETCH_HEAD

Cherry Pick

git fetch origin refs/heads/G0b9216c6738c722e3424be5ee5e085157b5813f9 && git cherry-pick FETCH_HEAD

Pull

git pull origin refs/heads/G0b9216c6738c722e3424be5ee5e085157b5813f9

Stacked PRs enabled by GHerrit.

gherrit-pr-id: G0b9216c6738c722e3424be5ee5e085157b5813f9
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @joshlf, 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 significantly enhances the hermes tool's internal infrastructure by integrating a comprehensive logging framework and modernizing code practices. It centralizes doc comment parsing logic, streamlines interactions with external tools, and refines the shadow crate generation process, all contributing to a more robust and maintainable codebase.

Highlights

  • Logging Integration: The hermes tool now integrates env_logger and log crates for improved logging capabilities. Existing println! and eprintln! calls have been replaced with log::debug! and log::warn! respectively, providing more structured and configurable output.
  • Doc Comment Parsing Refactor: A new docs module has been introduced to centralize the logic for parsing Hermes directives from doc comments. This refactors and consolidates code previously scattered across parser.rs and shadow.rs, improving maintainability and clarity.
  • Rust 2021 Idiom Adoption: Code has been updated to leverage modern Rust 2021 idioms, specifically replacing older line.find(|c| c == '(' || c == '[') with line.find(['(', '[']) and path.extension().map_or(false, |e| e == 'rs') with path.extension().is_some_and(|e| e == 'rs') for cleaner syntax.
  • External Tool Command Enhancements: Commands for charon, aeneas, and lake have been enhanced with additional flags. charon now includes RUSTFLAGS="-Aunused_braces" and --error-on-warnings, aeneas uses --warnings-as-errors and --no-progress-bar, and lake build runs with --quiet for less verbose output.
  • Shadow Crate and Test Improvements: The shadow crate generation now automatically adds #[allow(unused_variables)] to shim functions to prevent warnings. Integration tests have been updated to utilize env_logger for better test logging control, and a new test case verifies the unused_variables attribute.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • tools/Cargo.lock
    • Added env_filter, env_logger, jiff, jiff-static, log, portable-atomic, portable-atomic-util and their transitive dependencies.
  • tools/hermes/Cargo.toml
    • Added cargo_metadata, env_logger, log, quote dependencies.
  • tools/hermes/src/desugar.rs
    • Updated line.find to use array literal for multiple characters.
    • Refactored if let Some(...) && let Some(...) for improved readability.
    • Changed out.push_str(" ") to out.push(' ') for single character push.
  • tools/hermes/src/docs.rs
    • New file added to provide utility functions for parsing Hermes directives from doc comments.
  • tools/hermes/src/include/__hermes_std.rs
    • Added copyright header.
    • Added #![allow(dead_code, unused_imports)] attribute.
  • tools/hermes/src/lib.rs
    • Added pub mod docs; to expose the new doc parsing module.
  • tools/hermes/src/main.rs
    • Initialized env_logger for application-wide logging.
  • tools/hermes/src/orchestration.rs
    • Replaced println! with log::debug! for consistent logging.
    • Added RUSTFLAGS="-Aunused_braces" environment variable to charon command.
    • Added --error-on-warnings flag to charon command.
    • Updated path.extension().map_or(false, |e| e == "rs") to path.extension().is_some_and(|e| e == "rs").
    • Added ALL_AENEAS_BACKENDS constant.
    • Added --warnings-as-errors and --no-progress-bar flags to aeneas command.
    • Added --quiet flag to lake build command.
  • tools/hermes/src/parser.rs
    • Refactored check_attrs_for_misplaced_spec to use crate::docs::iter_hermes_lines.
    • Refactored visit_item_fn to use crate::docs::iter_hermes_lines and crate::docs::parse_hermes_tag.
    • Removed redundant local parse_doc_attr function.
  • tools/hermes/src/pipeline.rs
    • Updated path.extension().map_or(false, |e| e == "rs") to path.extension().is_some_and(|e| e == "rs").
    • Replaced println! with log::info! for pipeline step messages.
    • Replaced eprintln! with log::warn! for error messages.
    • Updated if let Some(...) && let Some(...) for Rust 2021 idioms.
  • tools/hermes/src/shadow.rs
    • Removed unused ensure_single_source function.
    • Updated path.extension().map_or(false, |e| e == "rs") to path.extension().is_some_and(|e| e == "rs").
    • Simplified combined_str format for model requirements.
    • Added #[allow(unused_variables)] attribute to generated shim functions.
    • Refactored parse_model_specs to use crate::docs::iter_hermes_lines and crate::docs::parse_hermes_tag.
    • Removed redundant local parse_doc_attr function.
  • tools/hermes/src/translator.rs
    • Updated if let FnArg::Typed(...) && let Type::Reference(...) && ... for Rust 2021 idioms.
  • tools/hermes/tests/cases/success/read_shim_success.rs
    • Changed unsafe fn to pub unsafe fn.
  • tools/hermes/tests/cases/success/unused_vars_check.rs
    • New test case added to verify #[allow(unused_variables)] functionality.
  • tools/hermes/tests/integration.rs
    • Replaced println! with log::debug! and log::info! for test output.
    • Initialized env_logger with is_test(true) for integration tests.
    • Updated path.extension().map_or(false, |e| e == "rs") to path.extension().is_some_and(|e| e == "rs").
    • Simplified conditional logic for symlink checks.
  • tools/vendor/env_filter/.cargo-checksum.json
    • Added new vendor file.
  • tools/vendor/env_filter/.cargo_vcs_info.json
    • Added new vendor file.
  • tools/vendor/env_filter/Cargo.lock
    • Added new vendor file.
  • tools/vendor/env_filter/Cargo.toml
    • Added new vendor file.
  • tools/vendor/env_filter/Cargo.toml.orig
    • Added new vendor file.
  • tools/vendor/env_filter/LICENSE-APACHE
    • Added new vendor file.
  • tools/vendor/env_filter/LICENSE-MIT
    • Added new vendor file.
  • tools/vendor/env_filter/README.md
    • Added new vendor file.
  • tools/vendor/env_filter/src/directive.rs
    • Added new vendor file.
  • tools/vendor/env_filter/src/filter.rs
    • Added new vendor file.
  • tools/vendor/env_filter/src/filtered_log.rs
    • Added new vendor file.
  • tools/vendor/env_filter/src/lib.rs
    • Added new vendor file.
  • tools/vendor/env_filter/src/op.rs
    • Added new vendor file.
  • tools/vendor/env_filter/src/parser.rs
    • Added new vendor file.
  • tools/vendor/env_logger/.cargo-checksum.json
    • Added new vendor file.
  • tools/vendor/env_logger/.cargo_vcs_info.json
    • Added new vendor file.
  • tools/vendor/env_logger/Cargo.lock
    • Added new vendor file.
  • tools/vendor/env_logger/Cargo.toml
    • Added new vendor file.
  • tools/vendor/env_logger/Cargo.toml.orig
    • Added new vendor file.
  • tools/vendor/env_logger/LICENSE-APACHE
    • Added new vendor file.
  • tools/vendor/env_logger/LICENSE-MIT
    • Added new vendor file.
  • tools/vendor/env_logger/README.md
    • Added new vendor file.
  • tools/vendor/env_logger/examples/custom_default_format.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/custom_format.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/default.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/direct_logger.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/filters_from_code.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/in_tests.rs
    • Added new vendor file.
  • tools/vendor/env_logger/examples/syslog_friendly_format.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/humantime.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/kv.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/mod.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/writer/buffer.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/writer/mod.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/fmt/writer/target.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/lib.rs
    • Added new vendor file.
  • tools/vendor/env_logger/src/logger.rs
    • Added new vendor file.
  • tools/vendor/env_logger/tests/init-twice-retains-filter.rs
    • Added new vendor file.
  • tools/vendor/env_logger/tests/log-in-log.rs
    • Added new vendor file.
  • tools/vendor/env_logger/tests/log_tls_dtors.rs
    • Added new vendor file.
  • tools/vendor/env_logger/tests/regexp_filter.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/.cargo-checksum.json
    • Added new vendor file.
  • tools/vendor/jiff-static/.cargo_vcs_info.json
    • Added new vendor file.
  • tools/vendor/jiff-static/COPYING
    • Added new vendor file.
  • tools/vendor/jiff-static/Cargo.lock
    • Added new vendor file.
  • tools/vendor/jiff-static/Cargo.toml
    • Added new vendor file.
  • tools/vendor/jiff-static/Cargo.toml.orig
    • Added new vendor file.
  • tools/vendor/jiff-static/LICENSE-MIT
    • Added new vendor file.
  • tools/vendor/jiff-static/README.md
    • Added new vendor file.
  • tools/vendor/jiff-static/UNLICENSE
    • Added new vendor file.
  • tools/vendor/jiff-static/src/lib.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/crc32/mod.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/crc32/table.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/error/itime.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/error/mod.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/mod.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/tzif.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/array_str.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/error.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/escape.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/itime.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/mod.rs
    • Added new vendor file.
  • tools/vendor/jiff-static/src/shared/util/utf8.rs
    • Added new vendor file.
  • tools/vendor/jiff/.cargo-checksum.json
    • Added new vendor file.
  • tools/vendor/jiff/.cargo_vcs_info.json
    • Added new vendor file.
  • tools/vendor/jiff/CHANGELOG.md
    • Added new vendor file.
  • tools/vendor/jiff/COMPARE.md
    • Added new vendor file.
  • tools/vendor/jiff/COPYING
    • Added new vendor file.
  • tools/vendor/jiff/Cargo.lock
    • Added new vendor file.
  • tools/vendor/jiff/Cargo.toml
    • Added new vendor file.
  • tools/vendor/jiff/Cargo.toml.orig
    • Added new vendor file.
  • tools/vendor/jiff/DESIGN.md
    • Added new vendor file.
  • tools/vendor/jiff/LICENSE-MIT
    • Added new vendor file.
  • tools/vendor/jiff/PLATFORM.md
    • Added new vendor file.
  • tools/vendor/jiff/README.md
    • Added new vendor file.
  • tools/vendor/jiff/UNLICENSE
    • Added new vendor file.
Activity
  • The pull request is currently marked as "Work In Progress" (WIP), indicating that the author is still actively developing and refining the changes.
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 is a nice cleanup effort. It introduces logging throughout the tool, which will improve debuggability. It also refactors the logic for parsing special documentation comments into a dedicated docs module, making the code cleaner and more modular. Many smaller idiomatic improvements are also included. I've found one critical issue in the changes, but otherwise, this is a great improvement.

} else {
let combined = model_requires.join(") && (");
let combined_str = format!("({})", combined);
let combined_str = format!("{}", combined);
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change appears to introduce a bug when combining multiple preconditions. The original code wrapped the joined string in parentheses, which is necessary for syn::parse_str to correctly parse it as a single expression when there are multiple preconditions joined by &&.

For example, if model_requires is ["a > 0", "b > 0"], the combined string will be "a > 0) && (b > 0". The new code will try to parse this directly, which fails. The original code would have created "(a > 0) && (b > 0)", which is a valid expression.

This will cause the logic to incorrectly fall back to true for the preconditions, effectively ignoring them.

Suggested change
let combined_str = format!("{}", combined);
let combined_str = format!("({})", combined);

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.02%. Comparing base (84d671e) to head (a1c0b5f).

Additional details and impacted files
@@                            Coverage Diff                             @@
##           Gb4a4c349671f37aad9e084998afdb7c57d92be43    #2977   +/-   ##
==========================================================================
  Coverage                                      92.02%   92.02%           
==========================================================================
  Files                                             19       19           
  Lines                                           6029     6029           
==========================================================================
  Hits                                            5548     5548           
  Misses                                           481      481           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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