February 2026 edition
OKHAM Implementer Guide
Target Audience: Developers, architects, and teams implementing OKHAM standards in production systems.
Overview
This guide provides implementation-grade guidance for adopting OKHAM standards. It assumes no specific runtime, framework, or language—OKHAM contracts are implementation-agnostic.
Key Principle: OKHAM defines what systems agree on (contracts), not how they implement it (code).
Minimal Compliance Requirements
To claim compliance with an OKHAM contract, you MUST:
- Implement the contract structure as defined in SPECIFICATION.md
- Validate artifacts against the contract's JSON Schema
- Preserve semantic meaning as specified in the contract
- Use correct versioning according to the contract's versioning rules
You do NOT need:
- A specific runtime or framework
- A specific programming language
- A specific transport protocol
- A specific storage backend
Golden Path: Implementation Sequence
This is the recommended order for implementing OKHAM standards. You can adopt incrementally—start with one contract and expand as needed.
Phase 1: Type Interoperability (OTC)
Goal: Establish shared type vocabulary across system boundaries.
Steps:
- Read OTC SPECIFICATION.md
- Identify types that cross system boundaries in your architecture
- Define types using OTC structure:
id: Unique type identifier (e.g.,[email protected])name: Human-readable type nameversion: Semantic versionschema: JSON Schema definitionsemantics: Semantic metadata (purpose, constraints, relationships)
- Validate types against OTC JSON Schema
- Publish types to a shared registry (optional but recommended)
- Implement type resolution in your services
Minimal Viable Implementation:
{
"id": "[email protected]",
"name": "User",
"version": "1.0.0",
"schema": {
"type": "object",
"properties": {
"id": { "type": "string" },
"email": { "type": "string", "format": "email" }
},
"required": ["id", "email"]
},
"semantics": {
"purpose": "Represents a user account in the system"
}
}
Compliance Checklist:
- [ ] Types have unique IDs with semantic versioning
- [ ] Types include JSON Schema definitions
- [ ] Types include semantic metadata
- [ ] Types validate against OTC schema
- [ ] Type references use full IDs (not just names)
Phase 2: Event-Driven Observability (OEC)
Goal: Standardize events as immutable facts with causality chains.
Steps:
- Read OEC SPECIFICATION.md
- Identify events in your system (domain events, integration events, system events)
- Define events using OEC structure:
id: Unique event identifiertype: Event type (semantic classification)timestamp: ISO 8601 timestampsource: Event source (capability, service, component)data: Event payload (typed using OTC)causation: Causality chain (parent event IDs)correlation: Correlation ID for tracing
- Validate events against OEC JSON Schema
- Implement event emission in your services
- Implement event consumption with causality tracking
Minimal Viable Implementation:
{
"id": "evt_123456",
"type": "[email protected]",
"timestamp": "2024-01-16T10:30:00Z",
"source": "user-service",
"data": {
"userId": "user_789",
"email": "[email protected]"
},
"causation": [],
"correlation": "corr_abc123"
}
Compliance Checklist:
- [ ] Events have unique IDs
- [ ] Events have semantic types (not generic "event")
- [ ] Events include ISO 8601 timestamps
- [ ] Events include source identification
- [ ] Events include causation chains
- [ ] Events validate against OEC schema
- [ ] Event data uses OTC-defined types
Phase 3: Declarative Governance (OPC)
Goal: Define engine-independent policies for governance and compliance.
Steps:
- Read OPC SPECIFICATION.md
- Identify governance requirements (access control, validation, rate limiting, compliance)
- Define policies using OPC structure:
id: Unique policy identifiername: Human-readable policy nameversion: Semantic versioneffect: Policy effect (allow, deny, condition)rules: Policy rules (conditions and actions)scope: Policy scope (resources, capabilities, events)
- Validate policies against OPC JSON Schema
- Implement policy evaluation engine (or use existing engine)
- Integrate policy enforcement in your services
Minimal Viable Implementation:
{
"id": "[email protected]",
"name": "Admin Only Policy",
"version": "1.0.0",
"effect": "deny",
"rules": [
{
"condition": "user.role != 'admin'",
"action": "deny",
"message": "Only admins can perform this action"
}
],
"scope": {
"capabilities": ["com.example.DeleteUser"]
}
}
Compliance Checklist:
- [ ] Policies have unique IDs with semantic versioning
- [ ] Policies have clear effects (allow/deny/condition)
- [ ] Policies include explicit rules
- [ ] Policies define scope (what they apply to)
- [ ] Policies validate against OPC schema
- [ ] Policy evaluation is deterministic
Phase 4: UI Component Portability (OUCC)
Goal: Preserve UI component semantics across rendering engines.
Steps:
- Read OUCC SPECIFICATION.md
- Identify UI components that need portability
- Define components using OUCC structure:
id: Unique component identifiername: Human-readable component nameversion: Semantic versionprops: Component properties (typed using OTC)slots: Component slots (children, content)semantics: Semantic metadata (purpose, accessibility)
- Validate components against OUCC JSON Schema
- Implement component rendering in your UI framework
- Implement component composition
Minimal Viable Implementation:
{
"id": "[email protected]",
"name": "Button",
"version": "1.0.0",
"props": {
"label": { "type": "string", "required": true },
"variant": { "type": "string", "enum": ["primary", "secondary"] }
},
"slots": {
"icon": { "optional": true }
},
"semantics": {
"purpose": "Interactive button for user actions",
"accessibility": {
"role": "button",
"keyboard": true
}
}
}
Compliance Checklist:
- [ ] Components have unique IDs with semantic versioning
- [ ] Components define typed props
- [ ] Components define slots (if applicable)
- [ ] Components include semantic metadata
- [ ] Components include accessibility metadata
- [ ] Components validate against OUCC schema
Phase 5: Business Flow Composition (OBC) — Optional
Goal: Define declarative business flows with semantic meaning.
Steps:
- Read OBC SPECIFICATION.md (when available)
- Identify business processes that need orchestration
- Define flows using OBC structure (specification pending)
- Validate flows against OBC JSON Schema
- Implement flow execution engine
- Integrate flow monitoring and observability
Status: OBC is currently PLANNED. Check documentation for updates.
Phase 6: Accessibility Obligations (OAC) — Optional
Goal: Define normative accessibility requirements and evidence.
Steps:
- Read OAC SPECIFICATION.md (when available)
- Identify accessibility requirements for your UI components
- Define obligations using OAC structure (specification pending)
- Validate obligations against OAC JSON Schema
- Implement accessibility testing and evidence collection
- Integrate accessibility compliance reporting
Status: OAC is currently PLANNED. Check documentation for updates.
Reference Resolution Rules
OKHAM contracts use fully qualified identifiers for references. Follow these rules:
ID Format
{namespace}.{name}@{version}
Examples:
[email protected](type)[email protected](event)[email protected](policy)[email protected](component)
Versioning Rules
OKHAM uses semantic versioning (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes (incompatible API changes)
- MINOR: Backward-compatible additions
- PATCH: Backward-compatible bug fixes
Version Resolution:
- Exact match:
[email protected](specific version) - Major version:
com.example.User@1(latest 1.x.x) - Latest:
com.example.User(latest version, not recommended for production)
Cross-Contract References
When one contract references another:
- Use full IDs: Always include namespace, name, and version
- Validate references: Ensure referenced contracts exist and are accessible
- Track dependencies: Maintain dependency graphs for impact analysis
Example: OEC event referencing OTC type
{
"id": "evt_123",
"type": "[email protected]",
"data": {
"$type": "[email protected]",
"id": "user_789",
"email": "[email protected]"
}
}
Compatibility Expectations
Backward Compatibility
Within a MAJOR version, implementations MUST maintain backward compatibility:
- MINOR version changes: Add new optional fields, do not remove or change existing fields
- PATCH version changes: Fix bugs, do not change behavior
Breaking Changes
MAJOR version changes indicate breaking changes:
- Removing fields
- Changing field types
- Changing field semantics
- Changing validation rules
Migration Path: Provide migration guides for MAJOR version changes.
Validation Strategy
Schema Validation
All OKHAM contracts include JSON Schema definitions. Use standard JSON Schema validators:
Languages:
- JavaScript/Node.js:
ajv,jsonschema - Python:
jsonschema,pydantic - Go:
gojsonschema,jsonschema - Java:
everit-org/json-schema,networknt/json-schema-validator - Rust:
jsonschema-rs
Example (JavaScript):
const Ajv = require('ajv');
const ajv = new Ajv();
const otcSchema = require('./otc-schema.json');
const validate = ajv.compile(otcSchema);
const type = {
id: "[email protected]",
name: "User",
version: "1.0.0",
schema: { /* ... */ },
semantics: { /* ... */ }
};
const valid = validate(type);
if (!valid) {
console.error(validate.errors);
}
Semantic Validation
Beyond schema validation, validate semantic correctness:
- Type references: Ensure referenced types exist
- Event causation: Ensure parent events exist
- Policy scope: Ensure scoped resources exist
- Component props: Ensure prop types are valid
Artifact Management
Storage
OKHAM contracts can be stored in:
- File system: JSON/YAML files in version control
- Database: Document store (MongoDB, PostgreSQL JSONB)
- Registry: Dedicated contract registry (OCC-compliant)
- Key-Value Store: Redis, etcd, NATS KV
Recommendation: Use version control (Git) as the source of truth.
Discovery
Implement contract discovery mechanisms:
- Registry API: HTTP API for querying contracts
- File-based discovery: Scan directories for contract files
- Service mesh: Integrate with service mesh metadata
- NATS KV: Use NATS Key-Value store for distributed discovery
Versioning
Store multiple versions of contracts:
contracts/
types/
[email protected]
[email protected]
[email protected]
events/
[email protected]
policies/
[email protected]
Testing Strategy
Unit Tests
Test contract validation:
describe('OTC Type Validation', () => {
it('should validate a valid type', () => {
const type = { /* valid OTC type */ };
expect(validateOTC(type)).toBe(true);
});
it('should reject an invalid type', () => {
const type = { /* invalid OTC type */ };
expect(validateOTC(type)).toBe(false);
});
});
Integration Tests
Test cross-contract references:
describe('OEC Event with OTC Type', () => {
it('should validate event with valid type reference', () => {
const event = {
id: "evt_123",
type: "[email protected]",
data: {
$type: "[email protected]",
id: "user_789"
}
};
expect(validateEvent(event)).toBe(true);
});
});
Compliance Tests
Test OKHAM compliance:
describe('OKHAM Compliance', () => {
it('should have unique IDs', () => {
const types = loadAllTypes();
const ids = types.map(t => t.id);
expect(new Set(ids).size).toBe(ids.length);
});
it('should use semantic versioning', () => {
const types = loadAllTypes();
types.forEach(t => {
expect(t.version).toMatch(/^\d+\.\d+\.\d+$/);
});
});
});
Common Pitfalls
❌ Pitfall 1: Mixing Implementation with Contracts
Wrong:
{
"id": "[email protected]",
"runtime": "nodejs",
"database": "postgresql"
}
Right:
{
"id": "[email protected]",
"name": "User",
"schema": { /* ... */ },
"semantics": { /* ... */ }
}
Reason: OKHAM contracts define meaning, not implementation details.
❌ Pitfall 2: Using Generic Names
Wrong:
{
"id": "[email protected]"
}
Right:
{
"id": "[email protected]"
}
Reason: Use fully qualified namespaces to avoid collisions.
❌ Pitfall 3: Skipping Semantic Metadata
Wrong:
{
"id": "[email protected]",
"schema": { /* ... */ }
}
Right:
{
"id": "[email protected]",
"schema": { /* ... */ },
"semantics": {
"purpose": "Represents a user account",
"constraints": ["email must be unique"]
}
}
Reason: Semantic metadata preserves meaning beyond structure.
❌ Pitfall 4: Breaking Backward Compatibility
Wrong (MINOR version change):
// v1.1.0 - BREAKING CHANGE in MINOR version
{
"id": "[email protected]",
"schema": {
"properties": {
"id": { "type": "number" } // Changed from string to number
}
}
}
Right (MAJOR version change):
// v2.0.0 - Breaking change in MAJOR version
{
"id": "[email protected]",
"schema": {
"properties": {
"id": { "type": "number" }
}
}
}
Reason: Breaking changes require MAJOR version bumps.
Performance Considerations
Caching
Cache validated contracts to avoid repeated validation:
const contractCache = new Map();
function getContract(id) {
if (contractCache.has(id)) {
return contractCache.get(id);
}
const contract = loadContract(id);
validateContract(contract);
contractCache.set(id, contract);
return contract;
}
Lazy Loading
Load contracts on-demand, not at startup:
// Bad: Load all contracts at startup
const allContracts = loadAllContracts(); // Slow startup
// Good: Load contracts on-demand
function getContract(id) {
return loadContract(id); // Fast startup
}
Batch Validation
Validate multiple contracts in parallel:
const contracts = [contract1, contract2, contract3];
const results = await Promise.all(
contracts.map(c => validateContract(c))
);
Monitoring & Observability
Contract Usage Metrics
Track contract usage:
- Type usage: Which types are most referenced
- Event frequency: Which events are most emitted
- Policy evaluations: Which policies are most evaluated
- Component renders: Which components are most rendered
Validation Failures
Monitor validation failures:
- Schema validation errors: Track which contracts fail validation
- Reference errors: Track broken references
- Version conflicts: Track version mismatches
Compliance Reporting
Generate compliance reports:
- Coverage: Which contracts are implemented
- Versioning: Which versions are in use
- Dependencies: Which contracts depend on others
Migration Strategy
Migrating Existing Systems
- Audit existing contracts: Identify types, events, policies, components
- Map to OKHAM contracts: Define OKHAM-compliant versions
- Implement adapters: Create adapters for legacy systems
- Gradual rollout: Migrate one contract at a time
- Deprecate legacy: Mark legacy contracts as deprecated
- Remove legacy: Remove legacy contracts after migration period
Coexistence
OKHAM contracts can coexist with legacy systems:
- Adapters: Convert legacy formats to OKHAM contracts
- Dual-write: Write to both legacy and OKHAM formats
- Gradual migration: Migrate services incrementally
Next Steps
- Choose a contract: Start with OTC (types) or OEC (events)
- Read the specification: Study the normative requirements
- Implement validation: Set up JSON Schema validation
- Define contracts: Create your first OKHAM-compliant contracts
- Test compliance: Validate contracts against schemas
- Integrate: Use contracts in your services
- Monitor: Track usage and compliance
Additional Resources
- LLM-START-HERE.md — LLM guidance and anti-hallucination rules
- CONTRACT-MAP.md — Contract ownership and boundaries
- CONFORMANCE.md — Compliance levels and checklists
- GLOSSARY.md — Authoritative term definitions
- Standards Documentation — All OKHAM standards
Remember: OKHAM is implementation-agnostic. Adopt what you need, when you need it.