Files
TORCH/docs/v2/schemas/task-contract-v1.schema.json
T
thePR0M3TH3ANandClaude Fable 5 70c7819a00 feat(v2): add contract schemas, fixtures, and CI validation (T0.2)
Six JSON Schema 2020-12 contracts under docs/v2/schemas — campaign,
milestone, task-contract, pledge, evidence-bundle, and the public
stewardship-manifest — with valid/invalid fixtures and a dependency-
free subset validator (scripts/validate-v2-contracts.mjs) wired into
npm test as validate:v2. Unsupported schema keywords fail loudly so
the interpreter and the schema files cannot drift apart.

test_integrity_note:
  change_type: [new_tests]
  scenarios:
    - id: SCN-v2-fixture-expectations
      given: committed schemas plus valid/ and invalid/ fixtures
      when: the full validation run executes
      then: valid fixtures pass, invalid fixtures fail, >=12 checked
    - id: SCN-v2-no-ceiling-omission
      given: a well-formed task contract
      when: spendingCeiling is removed
      then: validation reports the missing property
    - id: SCN-v2-pledge-not-money
      given: a well-formed pledge
      when: a balance-shaped extra field is added
      then: validation rejects the unexpected property
    - id: SCN-v2-evidence-completeness
      given: a well-formed evidence bundle
      when: an artifact family or digest is removed/truncated
      then: validation fails the required/pattern check
  observable_outcomes:
    - validator error lists at the runValidation()/validateAgainstSchema() boundary
  determinism_controls:
    - hermetic filesystem fixtures; no network, clock, or randomness
  anti_cheat_rationale:
    prevents:
      - schema files diverging from what the validator enforces
      - budget/provenance fields being omitted to skip enforcement
  relaxation:
    did_relax_any_assertion: false
    if_true_explain_spec_basis: ""

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-08-03 20:54:23 -04:00

143 lines
3.5 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://torch.local/schemas/v2/task-contract-v1.schema.json",
"title": "TORCH Task Contract",
"description": "The bounded unit a worker executes. Spec: DEVELOPMENT_NETWORK_SPEC.md §8. The sha256 of the canonical serialized contract is carried in lock events as taskContractHash; every evidence bundle records it as part of promptBundleDigest provenance.",
"type": "object",
"additionalProperties": false,
"required": [
"schemaVersion",
"id",
"campaignId",
"milestoneId",
"repoUrl",
"gitCommit",
"role",
"rolePromptHash",
"scope",
"toolPermissions",
"validationCommands",
"spendingCeiling",
"publicationPolicy",
"expiresAt"
],
"properties": {
"schemaVersion": {
"const": "torch.task-contract.v1"
},
"id": {
"type": "string",
"pattern": "^tc_[a-z0-9-]{6,64}$"
},
"campaignId": {
"type": "string",
"pattern": "^camp_[a-z0-9-]{6,64}$"
},
"milestoneId": {
"type": "string",
"pattern": "^ms_[a-z0-9-]{6,64}$"
},
"repoUrl": {
"type": "string",
"pattern": "^https://",
"maxLength": 512
},
"gitCommit": {
"type": "string",
"pattern": "^[0-9a-f]{40}$"
},
"role": {
"type": "string",
"description": "Agent role name from the role library (spec §7), e.g. implementation, integration, independent-verifier",
"minLength": 1,
"maxLength": 64,
"pattern": "^[a-z0-9-]+$"
},
"rolePromptHash": {
"type": "string",
"description": "sha256 of the role prompt file, matching the promptHash provenance already carried by 1.x lock events",
"pattern": "^[0-9a-f]{64}$"
},
"featureContractVersion": {
"type": "string",
"maxLength": 64
},
"charterVersion": {
"type": "string",
"maxLength": 64
},
"scope": {
"type": "object",
"additionalProperties": false,
"required": ["allowedPaths"],
"properties": {
"allowedPaths": {
"type": "array",
"minItems": 1,
"maxItems": 100,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 512
}
},
"forbiddenPaths": {
"type": "array",
"maxItems": 100,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 512
}
}
}
},
"toolPermissions": {
"type": "array",
"maxItems": 50,
"uniqueItems": true,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
},
"validationCommands": {
"type": "array",
"minItems": 1,
"maxItems": 20,
"items": {
"type": "string",
"minLength": 1,
"maxLength": 500
}
},
"spendingCeiling": {
"type": "object",
"additionalProperties": false,
"required": ["unit", "amount"],
"properties": {
"unit": {
"enum": ["sats", "usd-cents", "tokens"]
},
"amount": {
"type": "integer",
"minimum": 0
}
}
},
"outputSchemaRef": {
"type": "string",
"maxLength": 256
},
"publicationPolicy": {
"enum": ["private-report", "draft-pr", "public-pr-after-approval"]
},
"expiresAt": {
"type": "integer",
"description": "Unix seconds",
"minimum": 0
}
}
}