Skip to content

feat: decompose V1 CRUD routes into pipeline primitives (#86)#123

Merged
intel352 merged 2 commits intomainfrom
feat/issue-86-admin-decomp-b
Feb 23, 2026
Merged

feat: decompose V1 CRUD routes into pipeline primitives (#86)#123
intel352 merged 2 commits intomainfrom
feat/issue-86-admin-decomp-b

Conversation

@intel352
Copy link
Contributor

Summary

Replace the last 2 V1 admin CRUD routes (deploy and stop) that still delegated to admin-v1-mgmt (V1APIHandler) with declarative pipeline definitions using admin-db.

Routes Decomposed

All 6 routes from Phase B now use pipeline primitives:

Route Status
POST /api/v1/admin/organizations/{id}/projects ✅ Already decomposed
POST /api/v1/admin/projects/{id}/workflows ✅ Already decomposed
POST /api/v1/admin/workflows ✅ Already decomposed
PUT /api/v1/admin/workflows/{id} ✅ Already decomposed
POST /api/v1/admin/workflows/{id}/deploy 🆕 Decomposed in this PR
POST /api/v1/admin/workflows/{id}/stop 🆕 Decomposed in this PR

Pipeline Pattern (deploy/stop)

request_parse → set(now) → db_exec(UPDATE status) → db_query(get workflow) → json_response(200)

Each route now uses pipeline steps (request_parse, set, db_exec, db_query, json_response) instead of Go delegates, consistent with the other decomposed routes.

Verification

  • go build
  • go test ./...
  • go vet ./...
  • golangci-lint run

Closes #86

Replace 6 V1 admin CRUD routes that delegated to V1APIHandler with
declarative pipeline definitions using admin-db:

- POST /api/v1/admin/organizations/{id}/projects (create project)
- POST /api/v1/admin/projects/{id}/workflows (create workflow in project)
- POST /api/v1/admin/workflows (create workflow)
- PUT /api/v1/admin/workflows/{id} (update workflow + version)
- POST /api/v1/admin/workflows/{id}/deploy (deploy workflow)
- POST /api/v1/admin/workflows/{id}/stop (stop workflow)

Each route now uses pipeline steps (request_parse, validate, set,
db_exec, db_query, conditional, json_response) instead of Go delegates.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 23, 2026 10:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes Phase B of the admin config decomposition by replacing the remaining V1 admin workflow deploy and stop CRUD routes that previously delegated to admin-v1-mgmt with fully declarative pipeline definitions backed by admin-db.

Changes:

  • Replaced /api/v1/admin/workflows/{id}/deploy delegate step with a pipeline that updates status to active and returns the workflow record.
  • Replaced /api/v1/admin/workflows/{id}/stop delegate step with a pipeline that updates status to stopped and returns the workflow record.

Comment on lines +1096 to +1100
- name: respond
type: step.json_response
config:
status: 200
body_from: "steps.get-workflow.row"
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stop pipeline responds 200 with steps.get-workflow.row even when the workflow isn't found. Because step.db_query (mode: single) returns found: false + empty row, this endpoint will return {} with 200 rather than a 404.

Add a conditional step on steps.get-workflow.found (or check affected_rows from the UPDATE) and return a 404 json_response when the workflow does not exist.

Suggested change
- name: respond
type: step.json_response
config:
status: 200
body_from: "steps.get-workflow.row"
- name: respond-if-found
type: step.condition
config:
condition: "{{index .steps \"get-workflow\" \"found\"}}"
true_steps:
- name: respond
type: step.json_response
config:
status: 200
body_from: "steps.get-workflow.row"
false_steps:
- name: respond-not-found
type: step.json_response
config:
status: 404
body:
error: "workflow not found"

Copilot uses AI. Check for mistakes.
Comment on lines +1059 to +1061
mode: single
- name: respond
type: step.json_response
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deploy pipeline always responds 200 with steps.get-workflow.row even when the workflow ID doesn't exist. step.db_query in mode: single returns found: false and an empty row, so this endpoint will return {} with 200 instead of a 404 (unlike the GET/PUT/DELETE workflow routes above).

Add a conditional step on steps.get-workflow.found and a not-found json_response (404) route, or otherwise fail the pipeline when no row is found.

Suggested change
mode: single
- name: respond
type: step.json_response
mode: single
- name: not-found
type: step.json_response
condition: "{{ not .steps.get-workflow.found }}"
config:
status: 404
body:
error: "workflow not found"
- name: respond
type: step.json_response
condition: "{{ .steps.get-workflow.found }}"

Copilot uses AI. Check for mistakes.
@intel352
Copy link
Contributor Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copy link
Contributor

Copilot AI commented Feb 23, 2026

@intel352 I've opened a new pull request, #137, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* fix: add 404 handling to deploy and stop workflow pipelines

Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
@intel352 intel352 merged commit 4ecf982 into main Feb 23, 2026
14 checks passed
@intel352 intel352 deleted the feat/issue-86-admin-decomp-b branch February 23, 2026 16:16
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.

Admin Decomposition: Decompose V1 CRUD routes into pipeline primitives (Phase B)

3 participants