Repository navigation
Store manifest-declared license history - #325
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds commit-scoped persistence and historical querying for licenses declared directly in project manifests, enabling point-in-time license lookups per manifest path without re-parsing past commits.
Changes:
- Introduces a new
manifest_licensestable and bumps the DB schema version to store manifest-declared licenses/license-file paths as commit-scoped events (including removals). - Extends the analyzer and indexer pipeline to emit and persist manifest license events independently of dependency changes.
- Adds
GetManifestLicensesAtRefplus regression tests and documentation updates for the new storage/query behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/indexer/indexer.go | Persists manifest-license events per analyzed commit via the batch writer. |
| internal/indexer/indexer_test.go | Adds integration test ensuring license-only commits are indexed without dependency-change flags and are queryable by commit. |
| internal/database/schema.go | Adds the manifest_licenses table and supporting indexes. |
| internal/database/queries.go | Adds ManifestLicense model + GetManifestLicensesAtRef query and includes the new table in database info output. |
| internal/database/database.go | Bumps schema version to v16. |
| internal/database/database_test.go | Updates schema creation test to include manifest_licenses. |
| internal/database/batch_writer.go | Adds batch writer support for buffering and inserting manifest-license events transactionally. |
| internal/database/batch_writer_test.go | Adds regression test for manifest license state retrieval across commits (including removal). |
| internal/analyzer/analyzer.go | Emits manifest license events for add/modify/delete operations on manifests. |
| internal/analyzer/analyzer_test.go | Adds analyzer-level tests for multi-license manifests, license-file, modifications, and deletions. |
| docs/schema.md | Documents the new manifest_licenses table and indexes. |
| docs/internals.md | Updates internals documentation to describe manifest-license event tracking and selection logic. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
This PR bumps the schema from v15 to v16 and adds writes to manifest_licenses, but an existing v15 database is still opened without a version check. When reindex reaches a manifest change, insertManifestLicenses writes to a table that does not exist and the reindex fails.
Please detect the existing v15 schema before entering this PR’s new write path, return a clear error instructing the user to run git pkgs upgrade, and add a regression test covering reindex with a v15 database.
|
Thanks, Fixed. I also added a regression test that creates a realistic v15 database by removing the v16-only |
andrew
left a comment
There was a problem hiding this comment.
Please address both schema compatibility paths:
-
Move the schema guard into the shared indexing path. branch add and bisect invoke the indexer directly and bypass the check in cmd/reindex.go. Against schema v15, git pkgs branch add feature reaches insertManifestLicenses and fails with no such table: manifest_licenses. Add command-level coverage for these entrypoints.
-
Handle newer schemas separately. A v16 binary labels schema v17 as outdated and advises git pkgs upgrade, whose current path rebuilds the database at v16. During rollback, report that the binary is older than the database and require a compatible binary.
8dd3376 to
94d6336
Compare
|
Addressed both compatibility paths. Schema validation now runs in the shared indexer, covering reindex, branch add and bisect before any writes. Newer schemas now require a compatible binary and upgrade refuses to rebuild or downgrade them. Added command-level regressions and rebased onto current main. |
Closes #305
Summary
ParseResult.LicensesandParseResult.LicenseFileGetManifestLicensesAtReffor retrieving manifest license state at a specific commitImplementation
The new
manifest_licensestable stores license state against a commit and manifest. This preserves historical license information while supporting manifests that declare multiple licenses.The analyzer emits manifest-license events for additions, modifications, and removals. The batch writer persists these events independently of dependency changes, allowing a commit that only changes a project's declared license to be indexed correctly.
Testing
Added regression coverage for:
license-filedeclarationsVerification
go build ./...go mod tidy -diffgo test ./... -count=1go test -race ./... -count=1go tool golangci-lint run ./...git diff --check