Skip to content

Repository list: in_use_mode alias + repository_summary denormalization#3

Draft
daimoniac wants to merge 2 commits intomainfrom
cursor/repo-list-summary-a3c0
Draft

Repository list: in_use_mode alias + repository_summary denormalization#3
daimoniac wants to merge 2 commits intomainfrom
cursor/repo-list-summary-a3c0

Conversation

@daimoniac
Copy link
Copy Markdown
Owner

Summary

This PR implements the attached plan in two commits.

Commit 1: API semantics for repository listing

  • Add parseRepositoryListInUseQuery so in_use_mode=in_use_newer (and hyphen variants) maps to the same filter as in-use, while in_use still wins when both query params are present.
  • Document in_use vs in_use_mode on GET /api/v1/repositories in Swagger annotations (regenerate in CI/Docker via make swagger; build/ is gitignored).

Commit 2: repository_summary for fast list + pagination

  • New repository_summary table (FK to repositories ON DELETE CASCADE), indexes, and an AFTER INSERT trigger to seed a summary row for each new repository.
  • ensureRepositorySummaries runs after schema init: seeds missing rows and full backfill when there is drift or updated_at = 0.
  • refreshRepositorySummary recomputes scan aggregates plus runtime_used (via existing repositoryRuntimeUsageByID) and whitelisted.
  • Writers call refresh: RecordScan, RecordClusterInventory + DeleteClusterInventory (full runtime refresh), whitelist add/remove, CleanupArtifactScans, CleanupExcessScans.
  • ListRepositories reads from repository_summary with SQL WHERE, ORDER BY, LIMIT/OFFSET, and a matching COUNT(*).
  • repairRepositorySummariesForList runs at the start of ListRepositories only when uninitialized rows exist (updated_at = 0), so tests that insert repositories directly still get populated summaries without scanning every list in production.

Tests

  • internal/api/repository_list_in_use_query_test.go for query parsing.
  • internal/statestore/sqlite_repository_summary_test.go for RecordScan + summary + list consistency.
  • Extended schema test table list for repository_summary.
Open in Web Open in Cursor 

cursoragent and others added 2 commits April 23, 2026 08:40
Add parseRepositoryListInUseQuery so in_use_mode=in_use_newer maps to the
same filter as in_use. Document in_use vs in_use_mode precedence in Swagger.
Repository list remains boolean InUse-only in the state store; semver rules
apply only to per-repository tag views.

Co-authored-by: Stefan Knott <daimoniac@users.noreply.github.com>
Add repository_summary with indexes and an AFTER INSERT trigger on repositories.
Backfill on store open when counts drift or rows have updated_at=0.
Refresh summary on RecordScan, cluster inventory sync/delete, whitelist changes,
artifact digest cleanup, and excess scan cleanup.

Rewrite ListRepositories to JOIN repository_summary with SQL filters and
LIMIT/OFFSET. Repair uninitialized summary rows lazily on list for test DBs
that insert repositories directly.

Co-authored-by: Stefan Knott <daimoniac@users.noreply.github.com>
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