Skip to content

Add exclude_newer_timestamp to Database::Settings#4228

Open
jezdez wants to merge 4 commits intomamba-org:mainfrom
jezdez:feature/exclude-newer
Open

Add exclude_newer_timestamp to Database::Settings#4228
jezdez wants to merge 4 commits intomamba-org:mainfrom
jezdez:feature/exclude-newer

Conversation

@jezdez
Copy link
Copy Markdown
Contributor

@jezdez jezdez commented Apr 10, 2026

Description

Adds an optional exclude_newer_timestamp field to Database::Settings, allowing callers to exclude packages with a timestamp newer than the given Unix epoch cutoff during repodata loading.

This enables conda's --exclude-newer feature to work with the libmamba solver backend, matching what rattler already supports natively. See conda/conda#15759 for the full tracking and conda/ceps#154 for the CEP proposing indexed_timestamp in repodata.

How it works

The cutoff is applied at load time in both ingestion paths:

  • JSON path (mamba_read_json -> set_repo_solvables_impl): after a solvable is parsed and its timestamp set, the timestamp is compared to the cutoff. If newer, the solvable is removed via repo.remove_solvable(id, true) -- the same pattern used for parse failures.
  • PackageInfo path (add_repo_from_packages_impl_loop): the package timestamp (normalized from ms to seconds) is checked before adding a solvable. If newer, the package is skipped entirely.

The .solv cache path is not filtered. Callers (e.g. conda-libmamba-solver) are expected to invalidate the cache when exclude_newer_timestamp changes, the same way they handle repodata_filters.

Other changes

  • Moved MAX_CONDA_TIMESTAMP from the anonymous namespace in helpers.cpp to helpers.hpp so database.cpp can also use it.
  • Python bindings: Database.__init__() accepts an optional exclude_newer_timestamp keyword argument.

Context

When set, packages with a timestamp newer than the cutoff are excluded
during repodata loading. This covers both ingestion paths:

- JSON (mamba_read_json -> set_repo_solvables_impl): after parsing a
  solvable, check its timestamp and remove it if newer than the cutoff
- PackageInfo (add_repo_from_packages_impl_loop): skip the package
  before adding a solvable

The .solv cache path is not filtered; callers (e.g. conda-libmamba-solver)
are expected to invalidate the cache when exclude_newer changes.

Also moves MAX_CONDA_TIMESTAMP to helpers.hpp so both helpers.cpp and
database.cpp can use it without duplication.

Python bindings expose the new parameter as an optional
exclude_newer_timestamp keyword argument on Database.__init__().

This enables conda's --exclude-newer feature to work with the libmamba
solver backend. See conda/conda#15759 for full tracking.
jezdez added 3 commits April 10, 2026 14:35
- C++ tests (test_database.cpp): verify add_repo_from_packages filters
  packages by timestamp, normalizes millisecond timestamps, and filters
  packages loaded from repodata JSON
- Python tests (test_solver_libsolv.py): verify the libmambapy binding
  accepts exclude_newer_timestamp, filters packages from both the
  packages API and repodata JSON, and that None keeps all packages
The repodata JSON filter was reading solv.timestamp() to check
against the cutoff, but libsolv attributes require internalize()
before they can be read back. Since internalize() runs after all
packages are loaded, the timestamp was always 0 at filter time.

Fix by passing the parsed timestamp out of set_solvable via an
out parameter and using that directly in the filter comparison.

Also fix the millisecond normalization test to use a timestamp
that actually triggers the normalization path (> MAX_CONDA_TIMESTAMP),
and add subdir/depends fields to the Python repodata test fixture
to match real repodata structure.
Apply clang-format to ternary expression in database.cpp and
a pre-existing line-break issue in helpers.cpp.
jezdez added a commit to jezdez/conda-libmamba-solver that referenced this pull request Apr 10, 2026
Convert the exclude_newer duration/timestamp from conda's config
into a Unix timestamp cutoff and pass it to libmambapy's Database
constructor as exclude_newer_timestamp. This enables native
--exclude-newer filtering in the libmamba solver backend.

Depends on:
- conda/conda#15761 (exclude_newer config + parse_duration_to_seconds)
- mamba-org/mamba#4228 (exclude_newer_timestamp in Database::Settings)
jezdez added a commit to jezdez/conda-libmamba-solver that referenced this pull request Apr 10, 2026
Convert the exclude_newer duration/timestamp from conda's config
into a Unix timestamp cutoff and pass it to libmambapy's Database
constructor as exclude_newer_timestamp. This enables native
--exclude-newer filtering in the libmamba solver backend.

Depends on:
- conda/conda#15761 (exclude_newer config + parse_duration_to_seconds)
- mamba-org/mamba#4228 (exclude_newer_timestamp in Database::Settings)
jezdez added a commit to jezdez/conda-libmamba-solver that referenced this pull request Apr 10, 2026
Convert the exclude_newer duration/timestamp from conda's config
into a Unix timestamp cutoff and pass it to libmambapy's Database
constructor as exclude_newer_timestamp. This enables native
--exclude-newer filtering in the libmamba solver backend.

Depends on:
- conda/conda#15761 (exclude_newer config + parse_duration_to_seconds)
- mamba-org/mamba#4228 (exclude_newer_timestamp in Database::Settings)
jezdez added a commit to jezdez/conda-libmamba-solver that referenced this pull request Apr 10, 2026
Convert the exclude_newer duration/timestamp from conda's config
into a Unix timestamp cutoff and pass it to libmambapy's Database
constructor as exclude_newer_timestamp. This enables native
--exclude-newer filtering in the libmamba solver backend.

Depends on:
- conda/conda#15761 (exclude_newer config + parse_duration_to_seconds)
- mamba-org/mamba#4228 (exclude_newer_timestamp in Database::Settings)
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 10, 2026

Codecov Report

❌ Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.52%. Comparing base (f7d6d8e) to head (d11028e).

Files with missing lines Patch % Lines
libmambapy/bindings/solver_libsolv.cpp 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4228      +/-   ##
==========================================
+ Coverage   52.73%   53.52%   +0.79%     
==========================================
  Files         240      240              
  Lines       29526    29538      +12     
  Branches     3154     3157       +3     
==========================================
+ Hits        15570    15811     +241     
+ Misses      13953    13724     -229     
  Partials        3        3              

☔ 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.

@jezdez jezdez changed the title Add exclude_newer_timestamp to Database::Settings Add exclude_newer_timestamp to Database::Settings Apr 10, 2026
jezdez added a commit to jezdez/conda-libmamba-solver that referenced this pull request Apr 10, 2026
The kwarg doesn't exist in released libmambapy yet (pending
mamba-org/mamba#4228), so passing None causes a TypeError.
Only include the kwarg when there's an actual timestamp value.
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.

1 participant