Repository navigation
feat: cache registry integrity lookups - #274
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds caching of registry-provided integrity hashes (used by git pkgs integrity --registry) into the existing versions cache so repeated runs avoid redundant registry/enrichment requests while still honoring the standard 24-hour enrichment TTL.
Changes:
- Extend the
CachedVersionmodel and DB queries to read/write the existingversions.integritycolumn. - Update
integrity --registryto reuse cached integrity where fresh, fetch only missing/stale versions, and batch-save successful lookups. - Add regression tests and document the registry integrity caching behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents --registry usage and the 24-hour cache behavior. |
| internal/database/queries.go | Adds integrity to CachedVersion, includes it in cached reads, and persists it via SaveVersions. |
| docs/internals.md | Notes that integrity --registry uses the version cache and fetches only missing/stale versions. |
| cmd/integrity.go | Implements cached registry integrity lookups, avoids creating the enrichment client when unnecessary, and batch-saves cache updates. |
| cmd/analysis_test.go | Adds regression coverage for cache hits/misses and preserving cached integrity across non-integrity version updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
andrew
left a comment
There was a problem hiding this comment.
Requesting changes for two cache-correctness regressions:
-
[P1] internal/database/queries.go:2355-2363 — SaveVersions preserves an existing integrity value when an update omits integrity, but it unconditionally refreshes the shared enriched_at timestamp. A later freshness, license, or deprecation update can therefore make an integrity hash older than 24 hours appear fresh indefinitely. If the registry hash changed, integrity --registry may reuse the old hash and incorrectly report no mismatch. I reproduced this by aging an integrity row by 48 hours, applying a license-only SaveVersions update, and observing GetCachedVersions return the stale integrity within a 24-hour TTL. Integrity needs its own freshness marker, or equivalent field-specific cache semantics.
-
[P2] cmd/integrity.go:307-313 — The registry check saves only each installed exact version into versions, while freshness treats any non-empty GetCachedVersions result as a complete package-version history. After integrity --registry caches the installed version, freshness can skip GetVersions, see only that version, and report it as latest even when newer releases exist. The cache needs to distinguish exact-version metadata from a complete version-list fetch, or consumers must verify completeness before reusing it.
The existing CI is green but does not cover either cross-command interaction.
|
Fixed both cache-contract regressions. Exact integrity lookups now use a dedicated I also added a This bumps the database schema to v14. Added regressions for an aged integrity entry followed by a generic metadata update and for |
andrew
left a comment
There was a problem hiding this comment.
Please rebase this branch onto current main and resolve the content conflicts introduced by #273.
In internal/database/queries.go, preserve the GetCachedVersionsIncludingStale and shared getCachedVersions path from main, which licenses --offline uses, while adding this PR's integrity and integrity_checked_at columns to the shared SELECT and Scan. In docs/internals.md, preserve the documentation for both offline licenses and integrity/version-list caching.
The two earlier cache-correctness requests look resolved at 9da2596. Once the branch is rebased and CI is green, I will re-review the combined result.
# Conflicts: # docs/internals.md # internal/database/queries.go
# Conflicts: # docs/internals.md # internal/database/queries.go
9da2596 to
6340835
Compare
|
Rebased onto current
|
andrew
left a comment
There was a problem hiding this comment.
Both cache-correctness regressions are resolved: integrity now has its own integrity_checked_at freshness marker independent of enriched_at, and version_lists distinguishes complete history fetches from exact-version writes so freshness/dated outdated no longer mistake an integrity-only row for a full release list. Rebase onto #273 preserves the shared getCachedVersions reader and GetCachedVersionsIncludingStale for licenses --offline. Regression tests cover both cross-command interactions.
Closes #260
Summary
Cache version integrity metadata used by
git pkgs integrity --registryso repeated checks do not make unnecessary registry requests.CachedVersionmodelversions.integritycolumnThe
integritycolumn already exists in theversionstable, so this change does not require a schema migration or schema-version bump.Testing
Added regression coverage confirming that:
Validation performed:
go test ./...go tool golangci-lint run ./...git diff --check