3.2 KiB
3.2 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-persistence-contracts | Repository set persistence contracts | done | 1 | plan.md | ../../specs/workspaces/requirements/repository-sets.md |
Task 01: Repository Set Persistence Contracts
Acceptance
repository_setsandrepository_set_itemsexist in both the base schema and the replayable migrations, with workspace and set cascade deletion,UNIQUE(workspace_id, name),UNIQUE(repository_set_id, repository_id), and workspace/set lookup indexes. Initializing the schema twice is a no-op.- Store methods create, read, list, update, and delete sets, and
ReplaceRepositorySetItemsrewrites a whole membership list transactionally with contiguous zero-based positions in the requested order. Reads exclude members whose repository is soft-deleted or belongs to another workspace, and list resolves items for all returned sets without a per-set query. - Soft-deleting a repository removes its
repository_set_itemsrows inside the same transaction that already removesrepository_secret_bindings, for both delete paths.
Verification
cd apps/backend
go test ./internal/task/repository/... ./internal/task/dto/...
Files likely touched
apps/backend/internal/task/repository/sqlite/base_schema.go(newinitRepositorySetsSchemastep appended to thestepsslice at:16-48)apps/backend/internal/task/repository/sqlite/base_migrations.go(runMigrationsat:124)apps/backend/internal/task/repository/sqlite/repository_set.go(new)apps/backend/internal/task/repository/sqlite/repository_entity.go(DeleteRepository:143,DeleteRepositoryIfNoActiveTaskSessions:199)apps/backend/internal/task/repository/sqlite/repository_set_test.go(new)apps/backend/internal/task/repository/sqlite/schema_replay_test.go,postgres_schema_test.goapps/backend/internal/task/repository/interface.go(besideRepositoryEntityRepository:370)apps/backend/internal/task/models/models.go(besideRepository:1426)apps/backend/internal/task/dto/dto.go(besideRepositoryDTO:48,FromRepository:605)
Dependencies
None.
Inputs
- Spec: Data model, Persistence guarantees.
- Patterns:
sqlite/task_repository.gofor the membership table shape,office/repository/sqlite/projects_test.go:16-70for the full-column fixture and assertion style,db/migratelog.go:33for idempotent migration naming ("repository_sets.table"). - Constraint: repositories are soft-deleted (
repositories.deleted_at), so the foreign-key cascade does not clean memberships. Both the delete-path cleanup and the read filter are required. - Portability: use
r.db.Rebind(...), keep the SQL Postgres-safe, and add the tables to the Postgres schema test.
Risks
- A table-rebuild migration added later would drop these tables' columns if it precedes them; keep
the new
Applycalls after the existing rebuild migrations inrunMigrations(). - Positions must stay contiguous after a replace, or the picker's apply order silently changes.
Output contract
Summary, files changed, tests run with results, blockers, risks, divergence from the plan, and task/plan status updates.