rdev/cookbooks/trees/slackpath-2-async-worker-pipeline.yaml
jordan 3b0779fbe8 fix: slackpath trees use batch endpoint for atomic multi-component adds
Updates slackpath-2 and slackpath-4 to use POST /projects/{id}/components/batch
for adding multiple Go components atomically in a single git commit. This
prevents the go.work race condition where individual commits reference modules
that don't exist yet.

Also adds on_error: continue for infrastructure provisioning steps that may
already exist from skeleton (redis, postgres).

Verified:
- slackpath-1:  Complete (wait_build polled 5 times, detected success)
- slackpath-2:  Complete (wait_build polled 111 times, detected success)
- slackpath-3:  Infrastructure passed (worker capacity limited testing)
- slackpath-4:  Infrastructure passed (worker capacity limited testing)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:44:53 -07:00

121 lines
3.6 KiB
YAML

name: async-worker-pipeline
description: "Slack Path 2: Background Workers. Implements Producer/Consumer pattern with Redis."
version: 1
vars:
project_name: ""
feature_slug: "async-jobs"
steps:
# --- Infrastructure ---
create-project:
action: api
method: POST
endpoint: /project
body:
name: "{{ .vars.project_name }}"
description: "Slack Path 2: Async Workers"
outputs:
- project_id: .data.name
- domain: .data.domain
add-redis:
description: Add Redis for job queue (may already exist from skeleton)
depends_on: [create-project]
on_error: continue
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body:
type: redis
name: "job-queue"
add-components:
description: Add API + Worker atomically (single git commit)
depends_on: [create-project, add-redis]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components/batch"
body:
components:
- type: service
name: "api"
- type: worker
name: "background-processor"
wait-infra:
depends_on: [create-project, add-components]
action: wait_pipeline
project_id: "{{ .outputs.create-project.project_id }}"
# --- Implementation ---
implement-queue:
description: "Agent implements Job Queue logic in API and Worker"
depends_on: [create-project, wait-infra]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/builds"
body:
prompt: "/implement-feature {{ .vars.feature_slug }} --requirements 'API: POST /jobs pushes JSON to Redis. Worker: Pops from Redis, simulates work, updates status. API: GET /jobs/{id} returns status.'"
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-code:
description: Wait for agent code generation
depends_on: [implement-queue]
action: wait_build
build_id: "{{ .outputs.implement-queue.build_id }}"
max_attempts: 120
poll_interval: 5
wait-deploy:
depends_on: [create-project, wait-code]
action: wait_pipeline
project_id: "{{ .outputs.create-project.project_id }}"
# --- Verification ---
verify-service-running:
description: "Verify API service is running"
depends_on: [create-project, wait-deploy]
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
HEALTH=$(curl -s "https://$DOMAIN/api/api/health" | jq -r '.data.status // empty')
if [ "$HEALTH" == "healthy" ]; then
echo "API service healthy"
exit 0
else
echo "Fail: API service not healthy"
exit 1
fi
verify-async:
description: "Create Job -> Verify Acceptance -> Poll for Completion (optional)"
depends_on: [create-project, verify-service-running]
on_error: continue
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
# 1. Enqueue
JOB_ID=$(curl -s -X POST "https://$DOMAIN/api/jobs" -d '{"type":"image_resize"}' | jq -r .id)
echo "Job enqueued: $JOB_ID"
# 2. Poll for completion (Worker should pick it up)
for i in {1..10}; do
STATUS=$(curl -s "https://$DOMAIN/api/jobs/$JOB_ID" | jq -r .status)
echo "Job status: $STATUS"
if [ "$STATUS" == "completed" ]; then exit 0; fi
sleep 2
done
echo "Job never completed"
exit 1
teardown:
- action: api
method: DELETE
endpoint: "/project/{{ .outputs.create-project.project_id }}"