Cross-Repository API Contract
1. The Triad of Truth (Contract Coordination)
Cross-repo contract changes are high-risk and require strict coordination across the Triad:
- •Source Code (
api-contract/or.contracts/): The actual TypeScript definitions and endpoint documentation. - •Obsidian Graph (
workflows/):WF-nodes MUST explicitly mention contract changes in their 3-bullet summary to warn downstream agents (e.g.,* Breaking API change proposed in types.ts). - •Planka Board: Contract changes must be tracked as specific Tasks via Native MCP, and cross-repo dependencies must be flagged in the Epic card's comments.
2. Contract Discovery & Tooling
Before implementing any API endpoint or client, check for contract definitions in these locations using the Native filesystem MCP tool (list_directory / read_multiple_files):
- •
api-contract/— This repo is the source of truth for the contract. - •
.contracts/— Synced copy from an external source repo (typically via CI).
If neither exists and you are implementing API endpoints, propose creating an api-contract/ directory following the standard structure:
text
api-contract/ (or .contracts/) ├── README.md # Purpose, sync instructions, change process ├── version.ts # Contract version and changelog ├── types.ts # TypeScript interfaces for all request/response/error shapes └── endpoints.md # Human-readable endpoint documentation
3. Implementation Guidelines
When Implementing API Endpoints (Backend)
- •Read
.contracts/types.ts(orapi-contract/types.ts) viaread_text_filebefore writing handler code. - •Import or reference the types directly — do not redefine them.
- •Validate that request and response shapes match the contract exactly.
- •If the contract is missing fields, document as an
OPEN QUESTIONin the plan and create a Task in Planka. Do not add fields unilaterally.
When Implementing API Clients (Extension/Frontend)
- •Read
api-contract/types.tsbefore writing client code. - •Import types directly from the contract location.
- •Handle all error codes defined in the contract.
- •If the API behaves differently than the contract specifies, flag this as a bug in your analysis/review.
4. Proposing Contract Changes & The Handoff
When a Planner or Architect proposes a contract change, they MUST perform the following Triad alignment:
- •Additive changes (new optional fields, new endpoints): Safe to propose inline.
- •Breaking changes (removing fields, changing types):
- •Document as an
OPEN QUESTIONwith migration notes. - •Use Planka's
create_taskto explicitly add a task like: "Coordinate breaking contract change across repos". - •Use Planka's
add_commentto flag the breaking change for the human user.
- •Document as an
- •Always bump the version in
version.tswhen modifyingtypes.ts. - •Update Obsidian: Use
obsidian/patch_noteto ensure the activeWF-<concrete-id>node mentions the contract change in its## Summary.
5. Contract Sync & Type Validation
For Consumer Repos:
- •If this repo consumes an external contract (indicated by
.contracts/), the contract is synced automatically via GitHub Actions. - •Do not edit files in
.contracts/directly — they will be overwritten. - •Do not attempt to run sync scripts via terminal. Rely on the CI workflow.
Type Validation:
- •When a repo has
.contracts/synced from an external source, you MUST include a test that imports.contracts/types.tsand validates handler I/O shapes. - •This catches contract drift before it causes runtime errors.