rdev/cookbooks/trees/slackpath-3-realtime-chat.yaml
jordan 62a9bbb237
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
fix: resolve 7 root causes causing cookbook deployment failures
RC-1: Gitea org fallback already removed (no-op, confirmed)
RC-3: Push/pull now explicitly target origin main (HEAD:main) in both
  pod_git_operations.go and claudebox/git.go — fixes Woodpecker webhook
  trigger by ensuring pushes always land on the main branch
RC-4: wait_for_pipeline records baseline pipeline number before polling;
  only returns success when a NEWER pipeline completes — prevents false
  positive when a prior pipeline was already success
RC-5: Redis WRONGPASS fixed on live persona-community-5 instance; platform
  gap noted (no reprovision endpoint for Redis ACL drift)
RC-6: Removed on_error:continue from all infra provisioning steps (add-db,
  add-redis) across persona-community, slackpath-2/3/4/5 trees — infra
  failures now fail the tree instead of silently continuing to a crash
RC-7: Added .pnpm-store/ to skeleton .gitignore — prevents thousands of
  cache files being committed by agents after pnpm install
RC-2: Updated all 12 cookbook trees — git_clone_url jordan/ → threesix/
  (24 occurrences across all slackpath, aeries, full-stack, genkit trees)
Also: strings.Cut and strings.SplitSeq lint fixes in pod_git_operations.go
  and claudebox/git.go

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 18:49:09 -07:00

135 lines
4.1 KiB
YAML

name: realtime-chat
description: "Slack Path 3: The Socket Layer. Implements WebSockets and Pub/Sub broadcasting."
version: 1
vars:
project_name: ""
feature_slug: "websocket-chat"
steps:
# --- Infrastructure ---
create-project:
action: api
method: POST
endpoint: /project
body:
name: "{{ .vars.project_name }}"
description: "Slack Path 3: Realtime Chat"
outputs:
- project_id: .data.name
- domain: .data.domain
add-redis:
description: Add Redis for Pub/Sub
depends_on: [create-project]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body:
type: redis
name: "pubsub"
add-service:
description: Add Chat API
depends_on: [add-redis]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/components"
body:
type: service
name: "chat-api"
wait-init:
depends_on: [add-service]
action: wait_pipeline
project_id: "{{ .outputs.create-project.project_id }}"
# --- Implementation ---
implement-sockets:
description: "Agent implements WebSocket Handler + Redis Broadcast"
depends_on: [wait-init]
action: api
method: POST
endpoint: "/projects/{{ .outputs.create-project.project_id }}/builds"
body:
prompt: "/implement-feature {{ .vars.feature_slug }} --requirements 'GET /ws upgrades to websocket. Incoming messages are published to Redis channel. Redis subscriber broadcasts to all connected clients.'"
auto_commit: true
auto_push: true
git_clone_url: "https://git.threesix.ai/threesix/{{ .outputs.create-project.project_id }}.git"
outputs:
- build_id: .data.task_id
wait-build:
description: Wait for agent code generation
depends_on: [implement-sockets]
action: wait_build
build_id: "{{ .outputs.implement-sockets.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-service-running:
description: "Verify chat service is running"
depends_on: [wait-deploy]
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
HEALTH=$(curl -s "https://$DOMAIN/api/chat-api/health" | jq -r '.data.status // empty')
if [ "$HEALTH" == "healthy" ]; then
echo "Chat service healthy"
exit 0
else
echo "Fail: Chat service not healthy"
exit 1
fi
# Note: WebSocket verification requires special tooling
verify-chat:
description: "Connect Client A, Send from Client B, Verify Receipt (optional)"
depends_on: [verify-service-running]
on_error: continue
action: shell
command: |
DOMAIN="{{ .outputs.create-project.domain }}"
# Python script to act as WebSocket client
cat <<EOF > test_ws.py
import websocket, sys, threading, time
def on_message(ws, message):
print(f"RECEIVED: {message}")
if "Hello World" in message:
sys.exit(0)
def on_open(ws):
print("CONNECTED")
ws = websocket.WebSocketApp(f"wss://$DOMAIN/api/ws", on_message=on_message, on_open=on_open)
wst = threading.Thread(target=ws.run_forever)
wst.daemon = True
wst.start()
time.sleep(2) # Wait for connection
# Send message via HTTP trigger to simulate another user
import requests
requests.post(f"https://$DOMAIN/api/broadcast", json={"message": "Hello World"})
time.sleep(2) # Wait for receipt
sys.exit(1) # Timeout if not exited by on_message
EOF
# Run python script (assuming python3 is available in runner)
# If not, we might need a simpler netcat test or skip strict WS verification
# For now, placeholder for success if endpoint exists
curl -I "https://$DOMAIN/api/ws" | grep "Upgrade" || exit 0 # Weak check, needs real WS tool
teardown:
- action: api
method: DELETE
endpoint: "/project/{{ .outputs.create-project.project_id }}"