Handbook
101-03 — Read a contract
Mental model linking human contract.md, machine contract.json, and load_contract_spec in Python.
Updated
What you will build
Mental model linking human contract.md, machine contract.json, and load_contract_spec in Python.
Prerequisites
Files you will touch
Read-only:
src/forge_lcdl/contracts/pw_chunk_classify/v1/contract.mdsrc/forge_lcdl/contracts/pw_chunk_classify/v1/contract.json
Step 1 — Skim Markdown
Open contract.md and note inputs, outputs, examples, failure modes.
Step 2 — Inspect JSON schema keys
Open contract.json and confirm input_schema / output_schema properties align with the Markdown sections.
Step 3 — Load in Python
PYTHONPATH=src python3 - <<'PY'
from forge_lcdl.contracts_api import load_contract_spec
spec = load_contract_spec("pw_chunk_classify", "v1")
print(spec.task_id, spec.version)
print("input keys:", sorted(spec.input_schema.get("properties", {}).keys()))
print("output keys:", sorted(spec.output_schema.get("properties", {}).keys()))
PY
Expected output
Printed pw_chunk_classify / v1 plus non-empty input / output property lists.
Common failures
| Symptom | Fix |
|---|---|
UnknownContractError |
Wrong task_id or missing v1 folder |
| Empty properties | Sidecar incomplete — run audit_contract_docs.py --strict when authoring |
Verify
Cross-check one required field from JSON against the payload you used in 101-02.
What changed
You can navigate ContractSpec before writing application code.