Skip to content

Contract Schema Reference

The Contract object is an optional extension to a Brainfile task. It defines the formal agreement between a requester (PM) and a worker (Agent).

Source of Truth: contract.json

See also

For a field-by-field walkthrough with examples, see Types → Contract.

Object Structure

FieldTypeDescriptionRequired
statusstringCurrent lifecycle state (see below)Yes
deliverablesArray<Deliverable>List of items to be producedNo
validationValidationHow to verify the workNo
constraintsArray<string>Implementation rules to followNo
outOfScopeArray<string>Explicitly out-of-scope itemsNo
feedbackstringPM feedback after failed validationNo
versionintegerContract version (incremented on amendment)No
metricsMetricsAuto-tracked timing and rework dataNo

Lifecycle Status (status)

Contracts follow a strict state machine to coordinate between different agents.

  • 🔵 ready: Work is defined and available for an agent to pick up.
  • 🟡 in_progress: An agent has claimed the task and is working on it.
  • 🟣 delivered: Work is completed and submitted for validation.
  • 🟢 done: Work has passed validation and is finalized.
  • 🔴 failed: Work failed validation or was abandoned.
  • ⚠️ blocked: Agent is stuck on an external dependency.
readyin_progressdelivereddoneblockedfailedContract created, waiting for agent pickupAgent actively working on deliverablesWork complete, awaiting validationValidated and approvedAgent stuck on external dependencyValidation failed, needs rework

Deliverable Object

Each item in the deliverables array defines a specific output.

FieldTypeDescription
typestringCategory (e.g., file, test, docs, refactor)
pathstringPath to the file or identifier for the deliverable
descriptionstring(Optional) Human-readable explanation

Validation Object

FieldTypeDescription
commandsArray<string>Shell commands to execute for validation

Metrics Object

Auto-tracked by the CLI. Do not manually edit.

FieldTypeDescription
pickedUpAtstringISO 8601 timestamp when agent picked up
deliveredAtstringISO 8601 timestamp when agent delivered
durationnumberSeconds between pickup and delivery
reworkCountnumberTimes contract was re-picked up after failure

Example (YAML)

In a v2 task file (.brainfile/board/task-63.md):

Task metadata

The task's own fields (description, relatedFiles, assignee) provide context. The contract focuses on deliverables and validation.

yaml
---
id: task-63
type: task
title: "Update API documentation"
column: todo
assignee: codex
relatedFiles:
  - src/routes/api.ts
contract:
  status: ready
  version: 1
  deliverables:
    - type: docs
      path: docs/api-v2.md
      description: "Updated REST endpoints"
  validation:
    commands:
      - npm run docs:verify
  constraints:
    - Use Swagger/OpenAPI 3.0 format
    - Document all error codes
  outOfScope:
    - Changing the authentication logic
---

## Description
Preparing for the Q3 mobile app release.

Key fields explained

  • deliverables — Exact file paths the agent must produce. The PM validates these exist.
  • validation.commands — Shell commands run automatically during contract validate.
  • constraints — Implementation rules the agent must follow (not validated automatically).
  • outOfScope — Prevents scope creep by explicitly excluding items.

Full walkthrough

For a step-by-step guide to creating, assigning, and validating contracts, see the Contracts Guide.

v2 changes

In v2, context.background moved to task.description and context.relevantFiles moved to task.relatedFiles. The context object is deprecated.

Released under the MIT License.