Skip to content

refactor(core): centralize install_before resolution#9286

Merged
jdx merged 2 commits intojdx:mainfrom
risu729:codex/refactor-install-before
Apr 22, 2026
Merged

refactor(core): centralize install_before resolution#9286
jdx merged 2 commits intojdx:mainfrom
risu729:codex/refactor-install-before

Conversation

@risu729
Copy link
Copy Markdown
Contributor

@risu729 risu729 commented Apr 21, 2026

Summary

  • centralize install_before timestamp precedence in a small helper
  • compute the effective before_date during ToolVersion resolution and carry it on the resolved ToolVersion
  • reuse the resolved ToolVersion before_date when building install context
  • align backend latest resolution with the existing config-opts fallback pattern and call resolve_before_date once

Validation

  • cargo fmt --check
  • git diff --check
  • cargo test install_before --quiet
  • cargo check --quiet

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 21, 2026

Greptile Summary

This PR centralizes install_before timestamp resolution into a new install_before::resolve_before_date helper, removes the old effective_before_date from tool_request.rs, and carries the computed cutoff on ToolVersion.before_date so every consumer (toolset install, install-into, backends) reads from one source of truth. The refactoring is clean and the test coverage (unit tests in install_before.rs, new test_inline_install_before_wins_over_config_entry in backend/mod.rs) is solid.

Confidence Score: 5/5

Safe to merge — the refactoring is logically equivalent to the previous code for all identified code paths, and prior thread concerns about inline-opts precedence and the None branch in install_into.rs are correctly resolved in this revision.

No new P0/P1 issues found. The effective_latest_before_date now explicitly checks ba().opts() before config.get_tool_opts(), fixing the precedence concern from earlier thread iterations. All remaining findings are P2 or already noted in previous comments. The new unit tests give good confidence the logic is correct.

No files require special attention.

Important Files Changed

Filename Overview
src/install_before.rs New module centralizing install_before resolution with correct precedence (override → per-tool → global) and thorough unit tests.
src/toolset/tool_version.rs Adds before_date field to ToolVersion and resolves it early in resolve() via the new helper; uses with_before_date builder pattern to propagate it on all return paths.
src/backend/mod.rs Refactors effective_latest_before_date to check inline ba().opts() first, then config opts, correctly preserving inline-option precedence; adds a test verifying inline wins over a config entry.
src/toolset/toolset_install.rs Removes the pre-resolve effective_before_date call; reads before_date from the already-resolved tv.before_date instead.
src/cli/install_into.rs Drops the pre-build effective_before_date call and the custom ResolveOptions; reads before_date from the resolved tv.before_date after toolset build.
src/toolset/tool_request.rs Removes effective_before_date and its tests (moved to install_before.rs); resolve now delegates directly to ToolVersion::resolve.
src/main.rs Registers the new install_before module.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ToolRequest::resolve] --> B[ToolVersion::resolve]
    B --> C[resolve_before_date]
    C --> D{opts.before_date set?}
    D -- Yes --> E[Use CLI override]
    D -- No --> F{per-tool install_before set?}
    F -- Yes --> G[Parse per-tool option]
    F -- No --> H{Settings::install_before set?}
    H -- Yes --> I[Parse global setting]
    H -- No --> J[None]
    E & G & I & J --> K[tv.before_date on ToolVersion]
    K --> L[InstallContext.before_date]
    K --> M[backend latest_version]
    M --> N[effective_latest_before_date]
    N --> O{before_date already set?}
    O -- Yes --> P[Use it]
    O -- No --> Q{ba opts install_before?}
    Q -- Yes --> R[Inline opts highest precedence]
    Q -- No --> S{config tool opts install_before?}
    S -- Yes --> T[Config file opts]
    S -- No --> U[resolve_before_date global fallback]
Loading

Reviews (9): Last reviewed commit: "fix(backend): preserve inline install_be..." | Re-trigger Greptile

Comment thread src/toolset/toolset_install.rs Outdated
Comment thread src/install_before.rs Outdated
Copy link
Copy Markdown
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 centralizes the logic for resolving the install_before cutoff into a new install_before module. It introduces a structured way to handle precedence between CLI overrides, tool-specific options, and global settings, ensuring consistent timestamp resolution across the application. The changes include refactoring Backend, ToolRequest, and various CLI commands to use this new centralized logic. Feedback was provided regarding a potential type mismatch in resolve_before_date_for_backend and a suggestion to refactor the logic to be more concise while correctly checking all configuration sources.

Comment thread src/install_before.rs Outdated
@risu729 risu729 force-pushed the codex/refactor-install-before branch 2 times, most recently from 5bdd365 to 2ab3802 Compare April 22, 2026 04:24
Comment thread src/cli/install_into.rs Outdated
@risu729 risu729 force-pushed the codex/refactor-install-before branch 4 times, most recently from 8ea3dcb to 8eed126 Compare April 22, 2026 05:27
@risu729 risu729 marked this pull request as ready for review April 22, 2026 05:35
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@risu729 risu729 force-pushed the codex/refactor-install-before branch from 8eed126 to 8c040ea Compare April 22, 2026 05:52
Comment thread src/backend/mod.rs Outdated
@risu729 risu729 marked this pull request as draft April 22, 2026 06:07
@risu729 risu729 marked this pull request as ready for review April 22, 2026 17:35
@risu729 risu729 force-pushed the codex/refactor-install-before branch from 9d151d3 to 56956d3 Compare April 22, 2026 18:35
@jdx jdx merged commit 4f940b2 into jdx:main Apr 22, 2026
34 checks passed
@risu729 risu729 deleted the codex/refactor-install-before branch April 22, 2026 22:22
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