This commit captures the current state before implementing the composable monorepo template system. Key changes included: Infrastructure: - Add CockroachDB provisioner adapter for database provisioning - Add Redis provisioner adapter for cache provisioning - Add build events system with PostgreSQL storage - Add WebSocket endpoint for real-time build progress Code agent improvements: - Fix Claude Code adapter to use default allowed tools instead of dangerously-skip-permissions - Add context-aware stream closing for cancellation support - Improve parser tests for edge cases Build system: - Add build event constants and metrics - Remove deprecated git_operations.go (replaced by pod_git_operations.go) - Add rollback logic for multi-step provisioning operations Documentation: - Add composable-monorepo feature documentation - Add DNS/Cloudflare service documentation - Update deployment and troubleshooting guides Cookbooks: - Add fullstack-app cookbook - Refactor landing-test with shared library Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.9 KiB
2.9 KiB
Build Orchestration
Last Updated: 2026-01-27 Confidence: High
Summary
Build orchestration enables structured build specs for bot-driven development. Bots submit build requests with prompts and templates via POST /project/{name}/build, workers execute Claude Code, and callbacks notify completion. All builds are recorded in the build_audit table for observability.
Key Facts:
- BuildSpec: prompt (required), template, variables, auto_commit, auto_push, callback_url
- BuildResult: success, output, error, commit_sha, files_changed, duration_ms, artifacts
- Builds enqueued as work tasks for the worker pool
- Auto-commit/push triggers Woodpecker CI pipeline
- Callback URL receives completion notification with full BuildResult
- Complete audit trail in
build_auditPostgreSQL table
File Pointers:
- Domain:
internal/domain/build.go(BuildSpec, BuildResult, BuildAuditEntry) - Port:
internal/port/build_audit.go(BuildAudit interface) - Adapter:
internal/adapter/postgres/build_audit.go - Service:
internal/service/build_service.go - Handler:
internal/handlers/builds.go(StartBuild, ListBuilds, GetBuild) - Handler:
internal/handlers/create_and_build.go(CreateAndBuild) - Executor:
internal/worker/build_executor.go(BuildSpec→AgentRequest translation) - Git:
internal/worker/pod_git_operations.go(post-build commit/push via kubectl exec) - Migration:
internal/db/migrations/012_worker_registry.sql(build_audit table)
API Endpoints
| Method | Path | Description |
|---|---|---|
| POST | /projects/{id}/builds |
Start a build, returns task_id |
| GET | /projects/{id}/builds |
List builds for project |
| GET | /builds/{taskId} |
Get build status and result |
| POST | /project/create-and-build |
Create project + start build in one call |
Orchestration Flow
- Bot calls
POST /projects/{id}/buildswith BuildSpec (prompt, template, auto_commit, auto_push) - BuildService validates spec (prompt required), creates WorkTask with build spec, enqueues
- Creates BuildAuditEntry with status "pending"
- Returns task ID immediately
- WorkExecutor poll loop claims task from queue
- BuildExecutor builds AgentRequest, calls CodeAgent.Execute() in pod via kubectl exec
- Post-build phase: If auto_commit, PodGitOperations runs
git add/commit/pushin pod- Git operations are programmatic, not LLM-driven (deterministic)
- WorkExecutor reports completion with BuildResult (includes commit_sha, files_changed)
- Audit entry updated, callback URL notified
Build Audit Statuses
pending- enqueued, waiting for workerrunning- worker executingcompleted- finished successfullyfailed- execution failedcancelled- cancelled before completion