Fulfill Contract
fulfill_contractSubmit execution or review deliverables for a claimed contract, enforcing TOCTOU workspace integrity, JSON schema validation, and SHA-256 auditing before completion.
Instructions
Submit execution or review deliverables for a CLAIMED contract under Dual-Track TOCTOU verification (ADR-0004 / ADR-0006 / ADR-0007) and Ajv JSON Schema validation.
Purpose
Delivers task outputs, enforces track-specific workspace integrity and cryptographic SHA-256 auditing, validates structured payloads, and transitions the contract to terminal COMPLETED.
Track-Specific Fulfillment Rules
Track A — Read-Only Audit (code_review | architecture_audit, ADR-0004):
Pointer files on disk MUST remain 100% unchanged (verifyAllPointers). Pass suggested code fixes in structured_output.fixes.
Accidental disk edits trigger a 1-strike recoverable RETRY_NEEDED buffer (restore via git checkout/stash, call verify_contract, then retry); a 2nd dirty attempt transitions to terminal POINTER_STALE while salvaging your output.
Track B1 — Direct Mutation (implementation | test_generation with write_mode="direct", default, ADR-0006):
Editing pointer files on disk and creating declared artifacts_pointers files is expected and permitted (SECURITY_REJECTED and FILE_MISSING remain hard blockers).
Post-mutation full-file SHA-256 hashes are committed into verified_sha256 while pointers preserves the pre-mutation baseline.
Track B2 — Zero-Write Proposal Mode (implementation | test_generation with write_mode="proposal", ADR-0007):
Pointer files on disk MUST remain 100% unchanged (enforced by the same 1-strike TOCTOU guard as Track A).
You MUST provide a valid non-empty unified git diff (<= 512KB) in proposed_patch touching only safe workspace paths and declared existing pointer files (or new files from /dev/null). Missing or invalid patches return recoverable RETRY_NEEDED (remediation.action="FIX_PATCH_AND_RESUBMIT").
Return Value
Returns { ok, contract_id, status: 'COMPLETED' | 'RETRY_NEEDED' | 'POINTER_STALE' | 'VALIDATION_FAILED' | 'TIMED_OUT', retry_count, max_retries, toctou_strike?, max_toctou_strikes?, dirty_files?, validation_errors?, no_op?, proposed_patch_sha256?, proposed_patch_bytes?, remediation?, message }.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"contract_id": "<contract_id>",
"result_summary": "<result_summary>"
},
"name": "fulfill_contract"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agent_id | No | Worker agent identifier. Must match the contract target_agent (defaults to AGENT_NAME env var). | |
| claim_token | No | Exclusive lease token returned in contract.claim_token by poll_next_task (FC-301). Mutating operations must provide matching claim_token to prevent cross-worker interference. | |
| contract_id | Yes | The contract ID returned by poll_next_task that is currently in CLAIMED status. | |
| proposed_patch | No | Unified git diff patch payload (max 524288 bytes / 512KB, ADR-0007) required when fulfilling a contract dispatched with write_mode="proposal". Do NOT modify pointer files on disk in proposal mode; submit all file edits and new files in this unified diff. | |
| result_summary | Yes | Detailed markdown or plain text summary of review findings, implementation details, or test execution outcomes (1-20000 chars). | |
| structured_output | No | Structured JSON payload matching contract_schema. Bounded to 1MB and max 32 depth (FC-302). For code reviews, pass proposed patches in fixes: [{ path, patch, description }] rather than editing pointer files directly (ADR-0004). | |
| artifacts_pointers | No | Optional pointers to new or modified artifact files created during task execution (max 50 files). |