Implementation:A5c ai Babysitter tdd quality convergence process
| Knowledge Sources | |
|---|---|
| Domains | TDD, Quality_Convergence, Agent_Orchestration |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Reference process implementation demonstrating test-driven development with iterative quality convergence using the Babysitter SDK.
Description
The tdd-quality-convergence.js file is the flagship process in the Babysitter library. It defines a complete TDD workflow with agent-based planning, a convergence loop that iterates until quality targets are met, parallel quality checks, and enforced human approval breakpoints at three critical stages.
The process defines 11 tasks: agentPlanningTask, writeTestsTask, runTestsTask, implementCodeTask, coverageCheckTask, lintCheckTask, typeCheckTask, securityCheckTask, agentQualityScoringTask, integrationTestTask, and agentFinalReviewTask. Each uses defineTask with the kind: 'agent' pattern.
Usage
- TDD process execution: Run this process to implement a feature with iterative quality convergence.
- Reference pattern: Study this file to learn how to compose defineTask, ctx.task, ctx.breakpoint, and ctx.parallel.all into a complete workflow.
- Quality scoring: The agentQualityScoringTask pattern shows how to score and iterate on implementation quality.
Code Reference
Source Location
- Repository: Babysitter
- File: library/tdd-quality-convergence.js:L1-596
Signature
// Process entry point
const process = defineTask("tdd-quality-convergence", (args, ctx) => {
// args: { feature: string, targetQuality: number, maxIterations: number }
// Returns orchestration graph using ctx.task, ctx.breakpoint, ctx.parallel.all
});
// Key task definitions (all follow this pattern):
const agentPlanningTask = defineTask("agent-planner", (args, ctx) => ({
kind: "agent",
title: "Plan feature implementation",
agent: {
name: "planner",
adapter: "claude-code",
prompt: { role: "user", task: args.feature, context: args.requirements },
outputSchema: { /* planning result schema */ },
},
io: { inputs: args, outputs: "planningResult" },
labels: ["planning"],
}));
// agentQualityScoringTask: { kind: "agent", ... } → qualityScore
// agentFinalReviewTask: { kind: "agent", ... } → finalReview
Import
// The process file is loaded directly by the Babysitter runtime
// Individual tasks use:
import { defineTask } from "@a5c-ai/babysitter-sdk";
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| feature | string | Yes | Feature to implement |
| targetQuality | number | Yes | Quality threshold (0-100) |
| maxIterations | number | Yes | Maximum convergence iterations |
Outputs
| Name | Type | Description |
|---|---|---|
| qualityScore | { overallScore, scores, summary, recommendations, criticalIssues, progress } | Final quality assessment |
| finalReview | { verdict, approved, confidence, strengths, concerns, blockingIssues, followUpTasks } | Final agent review |
Usage Examples
Running the TDD Process
# Via Babysitter CLI
babysitter run:create --process tdd-quality-convergence \
--input '{"feature":"Add user authentication","targetQuality":85,"maxIterations":5}'
Convergence Loop Pattern
// The core convergence loop (simplified from the actual file):
for (let iteration = 1; iteration <= maxIterations; iteration++) {
const tests = await ctx.task(writeTestsTask, { feature, plan, iteration, previousFeedback });
const testResults = await ctx.task(runTestsTask, { testFiles: tests.testFiles, expectFailures: iteration === 1 });
const impl = await ctx.task(implementCodeTask, { feature, plan, tests, testResults, iteration, previousFeedback });
const qualityChecks = await ctx.parallel.all([
() => ctx.task(coverageCheckTask, { testFiles: tests.testFiles }),
() => ctx.task(lintCheckTask, { files: impl.filesCreated }),
() => ctx.task(typeCheckTask, { files: impl.filesCreated }),
() => ctx.task(securityCheckTask, { files: impl.filesCreated }),
]);
const score = await ctx.task(agentQualityScoringTask, {
feature, plan, tests, testResults, implementation: impl,
qualityChecks, iteration, targetQuality,
});
if (score.overallScore >= targetQuality) break;
await ctx.breakpoint({
question: `Iteration ${iteration} score: ${score.overallScore}. Continue?`,
title: `Iteration ${iteration} Review`,
context: { runId, files: [{ path: `artifacts/iteration-${iteration}-report.md`, format: "markdown" }] },
});
}