name: 07-build description: > Executes the implementation plan task-by-task following TDD ordering, spec-adherence rules, and atomic commit conventions. Orchestrates parallel agents for independent tasks, manages branches and PRs, invokes 08-verify-build at milestone boundaries, and keeps the execution plan in sync with progress. Supports delta mode for feature addition via evolve cycles. Use when implementing tasks or adding features to an existing app (with active evolve cycle).
07 — Technical Execution (Build)
Execute the execution plan: implement tasks in TDD order, commit atomically, create PRs at milestone and phase boundaries, and orchestrate parallel agents for independent work.
Preamble: pipeline-preamble.md — shared conventions for stages 00–17.
Sessions: sessions-reference.md — requires active_session unless waived; reports under docs/sessions/{id}/reports/.
Cross-cutting: considerations.md, connectivity-gates.md.
State agent: workflow-state-manager — mandatory read/update.
Connectivity (stage 07)
Implement and test all three layers from connectivity-gates: H0i (integration), H0c (CORS), and live scripts (for 13). See §Stage 07 in connectivity-gates for task completion criteria.
Throughput
Treat one agent session as batch-oriented: advance the Task Loop as far as dependencies, data management, branches, and checks allow — across multiple milestones.
- PRs are not session boundaries. After 08-verify-build passes at a milestone, create the minor PR, record it, then continue with the next milestone.
- Same for phase boundaries: Run the gate check, create the major PR, then proceed.
- Do not end the turn after opening a PR unless the user asked for that cadence or there is no unblocked next task.
- AskQuestion is for ambiguity,
blockedtasks, or user steering — not a pause before every task or milestone.
Prerequisites
- Phase B gate must pass:
- 04-tech-plan
completed— execution plan exists - 05-verify-tech
completed— tech plan audited - 06-tech-tooling
completed— dev tooling installed
- 04-tech-plan
- Required:
docs/execution-plan.mdwith at least one approved phase.cursor/rules/— spec-adherence, tdd, atomic-commits, build-execution rules.cursor/hooks.json— hooks installed
- Data management (if applicable): Check
docs/data-management-plan.md. Tasks with data dependencies are blocked until data is staged. Offer to run data-staging if needed.
Session management
Per sessions-reference.md §10 and workflow-state-agent-protocol.md.
- Agent
read_contextmust returnactive_session(or blocking deviation). - Current stage must appear in
active_session.routing_planunless user amends plan. - Write stage reports to
active_session.artifacts_dir/reports/when this stage produces a report. - On completion: update routing-plan entry status; mirror
project.stages.{key}via agentupdate. - 00-context exempt from active_session requirement (session opener).
State management
Agent protocol: workflow-state-agent-protocol.md.
Stage key: stages.07-build.
Invoke workflow-state-manager read_context before any other action; update after each
substep. Do not edit workflow-state.yaml directly.
Detail: docs/execution-plan.md §Current State — update both on every task/milestone change.
On invocation
- Read
docs/execution-plan.md§Current State - Determine active phase, milestone, task
- Report current position:
Execution State:
Phase: [N] — [Phase Name]
Milestone: M[N] — [Milestone Name]
Task: T[N.N] — [Task description]
Progress: [N] / [N] tasks ([%])
Ready to work on: T[N.N] — [description]
- Start the Task Loop without AskQuestion unless tasks are
blockedor the user narrowed scope.
Delta / feature-addition mode
- Implement only pending tasks tagged with
evolve_cycle_idor listed in cycle scope. - Support multiple Fn in one branch (
evolve/{cycle-id}-{slug}). - PR title/body references evolve cycle and feature IDs.
Workflow
Phase 1 Scaffold (Template Projects)
If workflow-state.yaml §template.id is utility or job, the first milestone's
first task is the template scaffold. Execute it before entering the normal Task Loop:
- Read template registry: Load template-registry.md §Template Structure Reference for the selected template type
- Clone template: Clone the template repo from
https://github.com/Cognitive-Chemistry-Labs/template-modal-{id}.gitinto a temporary location - Copy structure: Copy the template's
src/,.github/,.gitignore, andREADME.mdinto the project repo (do not overwrite existing files that have already been modified by prior pipeline stages) - Replace placeholders: Replace all
{{SERVICE_NAME}}occurrences with the value fromworkflow-state.yaml§template.service_name - Prune GPU classes (job template only): Remove GPU class variants not in
workflow-state.yaml§template.gpu_tiers fromsrc/app.py - Commit:
[T1.1] config: scaffold from template-modal-{id}
After the scaffold commit, continue with remaining Phase 1 tasks (dependency setup, initial test, CI/CD config) and then enter the normal Task Loop for subsequent phases.
Task Loop
For each task in order (respecting dependencies):
Step 1 — Pre-flight
- Read spec source cited in the task's Spec Source column
- Check dependencies: All tasks in Depends On must be
completed - Check data deps: If Data Deps is non-empty, verify assets are staged
- Check branch: Correct milestone branch exists and is checked out
- Update state: Set task to
in_progressin Task Tracking table
Step 2 — Execute
Test tasks:
- Read test plan / acceptance criteria
- Write test following TDD conventions
- Run test — should fail (red phase)
- If test passes without implementation, surface as
[Uncertainty]
Code tasks:
- Read spec source for component details
- Implement to make preceding tests pass
- Run tests — should now pass (green phase)
- Refactor if needed, keeping tests green
Browser-facing FastAPI (ChatRAG, internal write, Modal data-mgmt ASGI):
- Call
vecinita_shared_schemas.cors.configure_corsincreate_app - Extend
tests/unit/test_cors_policy.pyfor new routes if needed - Add/update
tests/integrationwhen wiring crosses apps (H0i) - Task is not complete until H0c + H0i pass (see connectivity-gates.md §Stage 07)
For all tasks:
- Follow tech stack from execution plan
- Raise anything unclear via AskQuestion
- If a new dependency is needed, raise as
[Decision], back-add to specs - When any
[Decision],[Ambiguity], or[Contradiction]is resolved during implementation, create an ADR indocs/adr/per considerations.md §ADR logging. Set the Stage field to07-build. Reference the task ID (e.g., T1.3) in the ADR's Context section.
Step 3 — Post-task checks
- Run linter and
ruff formatin write mode on changed files (not just--check— CI runsruff format --checkand will fail on unformatted commits) - Run typechecker
- Run full test suite (not just new tests)
- If frontend or unit-tested code changed, run the CI coverage gate locally:
make test-unit-coverage(or, for a frontend-only change,cd apps/<app> && npm run test:coverage— no DB needed). This enforces the 95% frontend branch gate that plainvitest runskips. New React polling/list components routinely miss branches on the poll interval, refresh handler, unmount guards, and error/??fallbacks — cover these before commit. - Fix any failures before proceeding
Step 4 — Commit & record
- Verify correct branch is checked out (create
feat/M{N}-{slug}if needed) - Stage all task-related files
- Commit:
[T{id}] {type}: {description} - Verify clean state (
git status) - Append to
workflow-state.yaml§git_history.commits:- sha: <short-sha> branch: feat/M{N}-{slug} message: "[T{id}] {type}: {description}" stage: "07-build" files_changed: <count> timestamp: "<ISO-8601>" - Commit the workflow-state update (same or next commit)
Never leave uncommitted work. If an AskQuestion, gate check, or session end is imminent, commit first. Progress lost to uncommitted work is unrecoverable.
Step 5 — Update state
- Set task to
completedin Task Tracking, record date - Advance Current State to next pending task
- Report:
Completed T{id}: {description}. Next: T{next_id}
Milestone Boundary
When all tasks in a milestone are completed:
- Invoke 08-verify-build: Run all checks via parallel agents. 08-verify-build auto-corrects where possible and only blocks on non-trivial issues.
- Create minor PR from milestone branch to phase branch:
- Title:
[M{N}] {Milestone Name} - Body: task list, spec references, check results
- Title:
- Present to user (PR URL). Do NOT stop the session.
- Update PR Plan table. Continue Task Loop for next milestone.
Phase Boundary
When all milestones in a phase are completed:
- Invoke 08-verify-build at phase scope
- Run phase gate check: Verify every criterion in Phase Gate Check section
- Record in Phase Gate Log: Date, result, notes
- If any gate criterion is unmet, surface as
[Decision] - Create major PR from phase branch to main
- Present to user. Continue executing while unblocked.
Agent Orchestration
Parallel task execution
Within a milestone, identify tasks with no unmet dependencies:
- Build dependency graph from Task Tracking table
- Identify parallel batch: tasks with all dependencies
completed - Launch Task subagents (
subagent_type: "generalPurpose") for each - Each agent receives: task definition, spec excerpts, tech stack, branch name
- Parent agent waits, reviews for consistency, commits each task separately
Sequential fallback
Chain dependencies (T1.1 → T1.2 → T1.3) execute sequentially in the parent agent.
User interaction stays in parent
All AskQuestion calls, PR presentations, and gate checks happen in the parent agent.
Error Handling
Task failure
- Set task to
blockedwith blocker description - Surface via AskQuestion: fix now / skip / defer
- If skipping, check and report downstream cascade
Spec gap
- Raise as
[Ambiguity]with what's missing - On resolution, back-add to spec
- Continue with resolved detail
Idempotency
- Completed tasks are never re-executed
- In-progress tasks resume from current state
- Blocked tasks are re-evaluated (blocker may be resolved)
- Existing branches and PRs are reused
Validation tasks (required per entry point)
For every Modal run() entry point task, include a paired validation task before
marking the implementation task complete:
| Check | Spec source |
|---|---|
Invalid payload → error or partial_failure ZIP |
config-spec §Validation Rules |
Upstream minima (e.g. chunk_size ≥ 15) |
config-spec, upstream CLI |
| Required fields for stage | api-contract, spec.md |
Reference hotfix incidents in docs/hotfix-log.md when adding validation — do not
repeat post-deploy surprises (RET-001).
Output Rules
- One task at a time: Complete, commit, update state before starting next
- Tests before code: Every code task preceded by its test passing red phase
- Never skip checks: Lint, typecheck, tests after every task
- Atomic commits: One commit per task, never bundle
- PRs require approval to merge: Never auto-merge
- State always current: Execution plan reflects true progress at all times
- Verify before PR: Always invoke 08-verify-build at boundaries
- Maximize per pass: Complete many tasks and milestones per invocation