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

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
contextContextAdditional background informationNo

Lifecycle Status (status)

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

  • draft: Contract is being defined.
  • 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.

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

Context Object

Used to provide deeper understanding to the worker agent.

FieldTypeDescription
backgroundstringHigh-level "why" and architectural context
relevantFilesArray<string>Paths to existing code for reference
outOfScopeArray<string>Explicitly forbidden changes

Example (YAML)

When stored in brainfile.md, a contract looks like this:

yaml
id: task-63
title: "Update API documentation"
contract:
  status: ready
  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
  context:
    background: "Preparing for the Q3 mobile app release"
    relevantFiles:
      - src/routes/api.ts
    outOfScope:
      - Changing the authentication logic

Released under the MIT License.