Skip to content

Add SP Pool replication policy mechanism#651

Open
anjor wants to merge 10 commits intomainfrom
feat/sp-pool
Open

Add SP Pool replication policy mechanism#651
anjor wants to merge 10 commits intomainfrom
feat/sp-pool

Conversation

@anjor
Copy link
Collaborator

@anjor anjor commented Mar 25, 2026

Summary

  • Adds an SP Pool feature for Milestone 2: users assign preparations + storage providers with a per-provider replication policy (e.g. {"market": 1, "pdp": 1}), and the system auto-generates/manages Schedules to match the desired state
  • New models: SPPool, SPPoolProvider, SPPoolPreparation with ReplicationPolicy custom JSON type (stored as map[DealType]int)
  • Inline reconciliation engine computes the cross-product of providers × preparations × policy deal types, creates missing schedules, and pauses/unlinks stale ones
  • 11 REST API endpoints under /api/sp-pool with full CRUD, pause/resume, and provider/preparation management
  • 11 CLI commands under singularity deal sp-pool
  • SPPoolProviderID FK added to Schedule (SET NULL on delete) to track which schedules are pool-managed

Test plan

  • go build ./... — compiles clean
  • go vet ./... — no issues
  • go test ./model/... ./handler/... ./api/... — all pass
  • Reconciliation tests: cross-product (2 providers × 2 preps × mixed policy → 6 schedules), idempotency, paused pool creates paused schedules, policy change unlinks removed deal types, empty pool is no-op
  • Handler tests: create validation (name required, duplicate rejected, cron rules), add-preparation validation (wallet required, duplicate rejected, not-found pool)
  • Manual end-to-end: create pool → add provider with policy → add preparation → verify schedule auto-created → pause/resume → remove provider → verify schedule unlinked
  • Swagger regeneration (go generate ./...) after merge

anjor added 3 commits March 20, 2026 12:13
Introduce a declarative SP Pool feature that lets users assign a set of
preparations and storage providers with a per-provider replication policy
(e.g. {"market": 1, "pdp": 1}), and automatically generates and manages
Schedules to match the desired state.

- New models: SPPool, SPPoolProvider, SPPoolPreparation with
  ReplicationPolicy custom JSON type
- Add SPPoolProviderID FK to Schedule for tracking generated schedules
- Full CRUD + mutation handlers with inline reconciliation engine
- REST API: 11 endpoints under /api/sp-pool
- CLI: singularity deal sp-pool {create,list,get,update,remove,pause,
  resume,add-provider,remove-provider,add-preparation,remove-preparation}
- Tests for reconciliation (cross-product, idempotency, policy change,
  pause/resume) and handler validation
@anjor anjor requested a review from parkan March 25, 2026 11:43
@parkan parkan force-pushed the main branch 2 times, most recently from 35b56b1 to 3c132b0 Compare March 26, 2026 15:10
@anjor
Copy link
Collaborator Author

anjor commented Mar 26, 2026

Re-scoped this PR per review feedback. The SP Pool machinery is gone; the branch now just adds a string group label on schedules, --group on schedule create/update, and a deal schedule create-batch command for the cross-product and replication expansion logic. Full repo test pass is green after codegen (go test ./...).

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