feat(agent): add environment agent support, remove direct SP management - #51
Conversation
Introduce agent-based resource provisioning via NATS and remove all direct Service Provider (SP) management, completing the transition to an agent-only architecture. Each resource in a run is now routed to an agent (policy.SelectedAgent) rather than a provider, with per-resource SPRM provisioning using AgentName. - Agent domain (internal/agent/): store, service, HTTP handler (split into handler/convert/errors, matching the SP pattern), health monitor, OpenAPI spec and generated server/client/types - NATS integration (internal/sp/messaging/, internal/sp/consumer/, internal/sp/pending/): CloudEvents publish/consume and sweep-driven pending/queued retries and self-heal, including a CAS fix for a race that let two concurrent healers reassign the same instance to different agents, and proactive reassignment of run-siblings stuck on an excluded agent - Policy: ServiceTypes and Cost threaded into agent evaluation so Rego can see agent capability, with a hard capability pre-filter and explicit rejection when no capable or all-excluded agents remain (previously silent/fail-open) - Placement: agent-aware routing in CreateRun/RehydrateResource/ ReEvaluateWithExclude; ProviderName replaced by AgentName across the store model, DTO, and ListRun filter; fail closed instead of open when listing ready agents errors - SP resource manager: CreateInstance publishes to NATS instead of calling provider HTTP, with AgentName on ServiceTypeInstance and a matching agent_name filter on ListInstances - Removed all provider-specific code (internal/sp/*/provider, api/sp/*/provider, pkg/sp/client/provider) - Subsystem coverage for NATS response events, self-heal sweep re-routing, and sibling reassignment during self-heal (PR dcm-project#37 review thread r3761347505) Assisted by: Cursor - Sonnet 5 Co-authored-by: Cursor <cursoragent@cursor.com> Signed-off-by: gabriel-farache <gfarache@redhat.com>
Resource lifecycle events (create/queue/cancel/delete) had audit gaps: Publisher never logged publish outcomes, and several response-consumer and sweep transitions were silent on success, so a resource's history couldn't be reconstructed from logs alone. Add centralized publish logging in Publisher.publish, success-path transition logs across response_consumer.go and sweep.go, and unify resource_id/ce_type log keys to instance_id/event_type for consistent querying. Validated with two rounds of independent multi-model review (Opus, Grok, Gemini, Codex) across audit-completeness and code-quality/ operational-safety angles. Round findings closed: missing fields on failure/stale paths, a data race in the test log-capture harness (confirmed via -race), and incomplete test assertions. Assisted by: Cursor - Sonnet 4.5 Signed-off-by: gabriel-farache <gfarache@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
MarkDeletionFailed now skips rows already DELETED so a late cleanup timeout cannot overwrite a completed agent ack. Assisted-By: Claude (Anthropic) Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
Unique-constraint hits on Create are no longer retried and surface as 409 instead of a generic 500 after backoff. Assisted-By: Claude (Anthropic) Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
Put back entry/list Debug and resolve-ID Warn/Error logs dropped in the agent rewrite. Assisted-By: Claude (Anthropic) Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
PR Summary by QodoAdd environment agent API + NATS provisioning; remove direct SP management
AI Description
Diagram
High-Level Assessment
Files changed (108)
|
Code Review by Qodo
1.
|
|
Let's try to reopen #37 |
|
Can't reopen #37 |
Align OpenAPI with MarkDeletionComplete and cover show_deleted list/get for DELETED and FAILED. Assisted-By: Claude (Anthropic) Signed-off-by: Gloria Ciavarrini <gciavarrini@redhat.com>
9ae5a1e to
155a2f1
Compare
## Summary - PR #51 removed the `/providers` API (replaced by agent management). TC-30 (`auth_disabled_test.go`) used `/providers` as a target endpoint — now uses `/service-types` which is still available in the catalog API. Fixes the `catalog-subsystem` CI failure blocking all open PRs on `main`. ## Test plan - `make catalog-subsystem-test` — 41/41 specs passed locally Made with [Cursor](https://cursor.com) Signed-off-by: Vladislav Kolodny <vkolodny@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
…talog-items (#38) ## Summary [control-plane#51](dcm-project/control-plane#51) removed the `/providers` endpoint entirely (replaced by agent-based architecture over NATS). - **TC-08**: rewrite from "Provider CRUD" to "Agent CRUD" (`POST/GET /agents`) - **TC-02, TC-34**: replace provider create/delete with agent registration - **All other TCs**: `/providers` → `/catalog-items` as generic protected endpoint - **TC-37/38**: clarify step titles for SP-as-agent context - Add migration note documenting the API change No functional test coverage lost — agent DELETE doesn't exist by design (FK constraints preserve resource→agent history). ## Test plan - N/A (documentation only) - Verified `/catalog-items` and `/agents` return 200 on live stack --------- Signed-off-by: Vladislav Kolodny <vkolodny@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
PR #37 was closed by mistake and cannot be reopened after a force-push/recreate on the fork branch.