Deliver a contract-first, multi-adapter architecture that makes this codebase the canonical unified tool backend for LLM runtimes while preserving production stability.
- 0 known metadata/schema drift defects in consolidated tools
- 100 percent of consolidated tools use explicit context injection
- 100 percent of consolidated handlers depend on domain facades, not direct DB access
- Legacy tool surface traffic below 5 percent before removal
- p95 tool latency does not regress by more than 10 percent during migration
- Decision closure
- Finalize ADR-004 as compatibility mode with a clear deprecation trigger.
- Keep ADR-005 as the ownership architecture baseline.
- Contract model and generators (thin slice)
- Define
ToolContracttype and generator interfaces. - Migrate a representative thin slice (one combat, one world, one utility tool).
- Generate registry metadata and meta-tool outputs for migrated tools.
- Safety rails
- Add parity tests ensuring generated metadata/actions/schemas match runtime behavior.
- Add CI gate that fails on contract drift for migrated tools.
- Contract generation is running in CI for thin-slice tools.
- No behavioral regressions in migrated tools.
- ADR-004 decision is documented and discoverable.
- Contract migration
- Migrate consolidated tools to
ToolContractobjects. - Remove manual metadata maps in
consolidated-registryafter parity passes.
- Context hardening
- Remove module-level mutable context usage.
- Thread
SessionContextvia router and service signatures. - Add parallel multi-session tests for combat/world/spatial scenarios.
- Service facade rollout
- Introduce facades for combat, world, inventory, party, and session domains.
- Route consolidated handlers through facades first.
- Majority of consolidated tool calls run through contract-generated registry.
- No module-level mutable context remains in migrated modules.
- Domain facade coverage includes critical gameplay paths.
- Adapter completion
- MCP adapter fully generated from contracts.
- Add at least one non-MCP adapter spec target generated from the same contracts.
- Legacy compatibility mode
- Implement forwarding from legacy surface to consolidated contracts.
- Add parity matrix tests for top workflows.
- Add runtime telemetry to measure legacy endpoint usage.
- Planner metadata and workflows
- Publish prerequisites, next actions, and canonical workflows in contracts.
- Extend meta-tools to expose planner metadata for orchestration clients.
- Removal readiness package
- Release notes, migration guide, and deprecation checklist.
- 100 percent consolidated tools are contract-backed.
- Compatibility matrix is green for critical workflows.
- Legacy usage is below threshold and removal is announced.
- Platform contracts
- Scope:
ToolContractmodel, registry/spec/doc generators, parity tests.
- Runtime correctness
- Scope: context threading, race/leak testing, session isolation.
- Domain services
- Scope: facade interfaces, handler rewiring, repository boundary cleanup.
- Compatibility and migration
- Scope: legacy forwarding, telemetry, release communication.
- Migration churn across many files
- Mitigation: domain-by-domain rollout with parity tests per domain.
- Behavior regressions during handler rewiring
- Mitigation: freeze action semantics; enforce snapshot and contract parity tests.
- Performance overhead from extra abstraction
- Mitigation: benchmark before/after each domain migration; tune hot paths in services.
- Consumer breakage from legacy removal
- Mitigation: compatibility mode, telemetry-based threshold, staged deprecation notices.