Files
Heretek-OpenCode Coordinator 51feda30bf feat(gateway): hardened opencode-gateway contract v1 (closes #18/#19, ready for #20 v1.0.0)
- contract/v1/fixtures: 10 golden JSON-RPC 2.0 pairs for search/fetch/
  extract_structured/research_report (+initialize, tools-list wire compat),
  X-Swarm-Contract:1 headers, real sha256 contentHash digests
- packages/contract-client (@heretek-ai/gateway-contract 1.0.0): Zod schemas
  for all tools, provenance envelope {provenance,trust:untrusted,content},
  typed MCP client (initialize negotiation, Retry-After retry, sha256
  verification, contract header assertion), fixture loader + hash check,
  pure SSRF/sanitize/circuit/cache modules
- packages/opencode-guard (@heretek-ai/gateway-guard): OpenCode v2 plugin on
  @opencode/plugin 2.0.26 exact (define + tool.hook + mcp.transform),
  gateway-only allowlist, lane-egress fallback documented
- apps/gateway (Bun/TS): SSRF fail-closed (literal blocklist + DNS pin +
  no-redirect-to-private), per-(host,engine) circuit breakers with half-open,
  injection sanitize envelope, sha256 cache keys + TTLs, caps as error codes
- catalog (4 engines), deploy (smokescreen + caddy snippets)
- QA: bun test 44/44, tsc clean, oxlint clean
2026-10-12 13:10:42 -04:00
..

Contract versions

The gateway's /mcp contract is versioned independently of package versions. Every /mcp response carries X-Swarm-Contract: N and initialize reports serverInfo.contractVersion: N.

Rules

  • Additive (new optional fields, new tools, new error codes, new fixtures): same version. Consumers keep working; fixtures grow.
  • Breaking (remove/rename a field, change semantics, new required params): new version (X-Swarm-Contract: N+1, new contract/vN/ directory), announced in advance. The old version stays served until consumers migrate (decided at bump time).
  • Every behaviour change ships regenerated fixtures in the same change (the fixture conformance test enforces this).
  • Legacy field mapping (scraper-swarm v1 → this contract): fetched_at → fetchedAt, content_sha256 (bare hex) → provenance.contentHash (sha256:-prefixed), web_search/fetch_page/deep_research → search/fetch/research_report (+ new extract_structured).

Layout

contract/vN/fixtures/<area>/<case>.json — golden {contract_version, request, response_status, response_headers, response_body} pairs. Current: v1/.