Skip to content

Record parser-reported manifest kind in on-demand snapshots - #318

Merged
andrew merged 1 commit into
mainfrom
fix-snapshot-manifest-kind
Aug 10, 2026
Merged

andrew merged 1 commit into
mainfrom
fix-snapshot-manifest-kind

Conversation

@andrew

@andrew andrew commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

list --commit on a commit with no stored snapshot calls IndexCommitSnapshot, which converts each analyzer.Change to a database.SnapshotInfo and hands the batch to StoreSnapshot. SnapshotInfo had no Kind field, so the analyzer's kind was dropped, and StoreSnapshot guessed at manifests.kind:

kind := "manifest"
if s.Integrity != "" {
    kind = "lockfile"
}

That is wrong for any lockfile format without per-entry hashes (Gemfile.lock without CHECKSUMS, Cargo.lock v1/v2, mix.lock, older yarn.lock) and wrong the other way for a manifest that carries an integrity value. The full-index path via BatchWriter.ensureManifests already writes the parser's kind, so the two paths disagreed and whichever inserted the manifests row first won. diff --kind lockfile (#301) and the vuln query both filter on this column.

Add Kind to SnapshotInfo, populate it in IndexCommitSnapshot, and write it directly in StoreSnapshot. TestGetVulnsAtCommitAppliesEcosystemConfig now sets Kind explicitly since it was relying on the removed heuristic.

Existing databases where list --commit created a manifests row before init will keep the wrong kind until reindexed; both write paths skip when the row already exists.

`list --commit` on a commit with no stored snapshot calls
IndexCommitSnapshot, which converts each analyzer.Change to a
database.SnapshotInfo and hands the batch to StoreSnapshot. SnapshotInfo
had no Kind field, so the analyzer's Kind was dropped, and
StoreSnapshot guessed at manifests.kind:

    kind := "manifest"
    if s.Integrity != "" {
        kind = "lockfile"
    }

That is wrong for any lockfile format without per-entry hashes
(Gemfile.lock without CHECKSUMS, Cargo.lock v1/v2, mix.lock, older
yarn.lock) and wrong the other way for a manifest that carries an
integrity value. The full-index path via BatchWriter.ensureManifests
already writes the parser's kind, so the two paths disagreed and
whichever inserted the manifests row first won.

Add Kind to SnapshotInfo, populate it in IndexCommitSnapshot, and write
it directly in StoreSnapshot. The vulns test that seeded snapshots via
StoreSnapshot now sets Kind explicitly since the vuln query filters on
m.kind = 'lockfile'.

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes a mismatch between the full-index path and the on-demand list --commit indexing path by ensuring the parser-reported manifest kind (manifest vs lockfile) is persisted into manifests.kind instead of being inferred from snapshot integrity data.

Changes:

  • Add Kind to database.SnapshotInfo and populate it in Repository.IndexCommitSnapshot.
  • Update DB.StoreSnapshot to write manifests.kind from SnapshotInfo.Kind (removing the integrity-based heuristic).
  • Add a regression test covering a lockfile format without per-entry hashes (Gemfile.lock without CHECKSUMS) and update an existing vuln test to set Kind explicitly.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/git/query.go Threads analyzer Change.Kind into SnapshotInfo for on-demand snapshot indexing.
internal/git/query_test.go New regression test asserting on-demand indexing records correct manifests.kind for Gemfile vs Gemfile.lock.
internal/database/queries.go Removes integrity-based kind guessing; inserts manifest rows using SnapshotInfo.Kind.
internal/database/batch_writer.go Extends SnapshotInfo with a Kind field to support the on-demand snapshot path.
cmd/vulns_test.go Updates test snapshots to set Kind explicitly after heuristic removal.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/database/queries.go Resolved
@andrew
andrew merged commit dfed9ef into main Aug 10, 2026
8 checks passed
@andrew
andrew deleted the fix-snapshot-manifest-kind branch August 10, 2026 08:30
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