Skip to content

feat: add repository lifecycle API and local capacity guard - #3

Open
harshitethic wants to merge 5 commits into
mainfrom
feat/repository-lifecycle-api
Open

harshitethic wants to merge 5 commits into
mainfrom
feat/repository-lifecycle-api

Conversation

@harshitethic

Copy link
Copy Markdown
Owner

Problem

Every GitHub clone or ZIP analysis is persisted under backend/repos/, but RepoPilot previously had no inventory, deletion, retention, or capacity policy. A long-running local server could therefore accumulate repositories until disk space became the effective limit.

Solution

Add explicit repository lifecycle management:

  • inventory valid repository IDs and report file count, total bytes, and UTC update time;
  • GET /api/repositories to expose local inventory;
  • DELETE /api/repositories/{repo_id} to remove a selected repository;
  • POST /api/repositories/cleanup to remove repositories older than a bounded age;
  • REPOPILOT_MAX_REPOSITORIES capacity guard (default 100);
  • enforce the same capacity guard for both Git clones and ZIP extraction.

When capacity is reached, RepoPilot refuses new analysis with an actionable error instead of silently consuming more disk.

Safety

All lifecycle operations reuse the existing 12-hex repository ID validation and contained safe_repo_path() resolution. Cleanup enumerates only valid managed repository IDs.

Tests / CI

Adds backend tests for:

  • file/byte inventory;
  • capacity exhaustion;
  • stale-vs-fresh cleanup;
  • targeted deletion and invalid ID rejection.

The backend CI job now runs unittest in addition to bytecode compilation.

README documentation covers the new endpoints, cleanup request, and capacity environment variable.

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