rdev/cookbooks/trees/slackpath-4-microservice-constellation.yaml
jordan 853ec4cf81 fix: go.work race condition with batch components and idempotent provisioning
Three coordinated fixes for CI pipeline race conditions:

1. Woodpecker step dependencies: Added depends_on: [deps] to all 6 component
   templates (service, worker, cli, app-astro, app-react, app-nextjs) so build
   steps wait for go work sync to complete.

2. Idempotent resource provisioning: Modified provisionResources() to check
   for existing database/cache before creating, preventing "already exists"
   errors on component re-adds.

3. Batch component endpoint: POST /projects/{id}/components/batch enables
   atomic multi-component additions in a single git commit. Validates all
   components upfront, provisions infra sequentially, commits code components
   atomically.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 12:31:40 -07:00

133 lines
4.1 KiB
YAML

name: microservice-constellation
description: "Slack Path 4: Distributed System. Orchestrates communication between Auth, Chat, and Worker services."
version: 1
vars:
project_name: ""
feature_slug: "mesh-interop"
steps:
# --- Infrastructure ---
create-project:
action: api
method: POST
endpoint: /project
body:
name: "{{ .vars.project_name }}"
description: "Slack Path 4: Microservices"
outputs:
- project_id: .data.name
- domain: .data.domain
add-db:
description: Add CockroachDB for user/auth storage
depends_on: [create-project]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body:
type: postgres
name: "main-db"
add-redis:
description: Add Redis for job queue and pub/sub
depends_on: [create-project]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body:
type: redis
name: "job-queue"
add-auth:
depends_on: [add-db]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body: { type: service, name: "auth-svc" }
add-chat:
depends_on: [add-redis]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body: { type: service, name: "chat-svc" }
add-worker:
depends_on: [add-redis]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body: { type: worker, name: "worker-svc" }
wait-infra:
depends_on: [add-auth, add-chat, add-worker]
action: wait_pipeline
project_id: "{{ .outputs.create-project.project_id }}"
# --- Implementation ---
implement-mesh:
description: "Agent implements Service-to-Service calls (Chat calls Auth, Chat queues to Worker)"
depends_on: [wait-infra]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/builds"
body:
prompt: "/implement-feature {{ .vars.feature_slug }} --requirements 'Chat Service must call http://auth-svc/validate to check tokens. Chat Service must push to Redis queue for Worker. Worker must process tasks.'"
auto_commit: true
auto_push: true
git_clone_url: "https://git.threesix.ai/jordan/{{ .outputs.create-project.project_id }}.git"
outputs:
- build_id: .data.task_id
wait-build:
description: Wait for agent code generation
depends_on: [implement-mesh]
action: wait_build
build_id: "{{ .outputs.implement-mesh.build_id }}"
max_attempts: 120
poll_interval: 5
wait-deploy:
depends_on: [wait-build]
action: wait_pipeline
project_id: "{{ .outputs.create-project.project_id }}"
# --- Verification ---
verify-services-running:
description: "Verify auth and chat services are healthy"
depends_on: [wait-deploy]
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
AUTH_HEALTH=$(curl -s "https://$DOMAIN/api/auth-svc/health" | jq -r '.data.status // empty')
CHAT_HEALTH=$(curl -s "https://$DOMAIN/api/chat-svc/health" | jq -r '.data.status // empty')
if [ "$AUTH_HEALTH" == "healthy" ] && [ "$CHAT_HEALTH" == "healthy" ]; then
echo "Both services healthy"
exit 0
else
echo "Auth: $AUTH_HEALTH, Chat: $CHAT_HEALTH"
exit 1
fi
verify-e2e:
description: "Call Chat Service (which calls Auth internally) - optional"
depends_on: [verify-services-running]
on_error: continue
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
# We mock a token (assuming auth service has a backdoor or we register first)
# This test verifies that the Chat service didn't crash trying to reach Auth
# and that it successfully handed off work.
RESP=$(curl -s "https://$DOMAIN/api/chat/status")
if echo "$RESP" | grep "Services Connected"; then exit 0; else exit 1; fi
teardown:
- action: api
method: DELETE
endpoint: "/project/{{ .outputs.create-project.project_id }}"