## Phase 4: Contracts & Schema Layer

### 4.1 @oshun/contracts-common (Shared Schemas) ✅

- [x] **4.1.1** Create libs/contracts/ project
- [x] **4.1.2** Add project.json with scope:shared, layer:contracts tags
- [x] **4.1.3** Define Asset schema with provenance and licensing fields
- [x] **4.1.4** Define User schema (shared across domains)
- [x] **4.1.5** Define Project schema
- [x] **4.1.6** Define Timestamps and audit trail schemas
- [x] **4.1.7** Export as Zod schemas (Proto integration deferred to 4.3)
- [x] **4.1.8** TypeScript types inferred from Zod schemas

### 4.2 @oshun/contracts-events (Event Contracts) ✅

- [x] **4.2.1** Create libs/contracts/src/events/ module
- [x] **4.2.2** Included in @oshun/contracts package
- [x] **4.2.3** Define event envelope schema (id, type, timestamp, payload,
      metadata)
- [x] **4.2.4** Define isis.asset.generated event
- [x] **4.2.5** Define isis.job.failed event
- [x] **4.2.6** Define isis.workflow.registered event
- [x] **4.2.7** Define sophia.document.ingested event
- [x] **4.2.8** Define sophia.index.updated event
- [x] **4.2.9** Define hathor.world.published event
- [x] **4.2.10** Define hathor.simulation.completed event
- [x] **4.2.11** Define bellona.build.completed event
- [x] **4.2.12** Define bellona.export.ready event
- [x] **4.2.13** Define yemaya.project.created event
- [x] **4.2.14** Define yemaya.asset.approved event
- [x] **4.2.15** Event publisher interface in envelope.ts
- [x] **4.2.16** Event consumer interface in envelope.ts

### 4.3 @oshun/proto (Protocol Buffer Definitions) ✅

- [x] **4.3.1** Create libs/proto/ project (separate library)
- [x] **4.3.2** Add project.json with scope:shared, layer:contracts tags
- [x] **4.3.3** Migrate yemaya/packages/proto (19 .proto files):
  - [x] common/types.proto (shared types, UUID, pagination)
  - [x] ai/ai.proto (AI service definitions)
  - [x] agent/agent.proto (agent orchestration)
  - [x] asset/asset.proto (asset management)
  - [x] auth/auth.proto (authentication)
  - [x] bridge/blender.proto (Blender bridge)
  - [x] bridge/godot.proto (Godot bridge)
  - [x] bridge/unreal.proto (Unreal bridge)
  - [x] collaboration/collaboration.proto
  - [x] generation3d/generation3d.proto
  - [x] health/health.proto
  - [x] loadbalancing/loadbalancing.proto
  - [x] pipeline/autonomous_pipeline.proto
  - [x] procedural/procedural.proto
  - [x] project/project.proto
  - [x] reflection/reflection.proto
  - [x] rendering/rendering.proto
  - [x] splatting/gaussian_splatting.proto
  - [x] user/user.proto
- [x] **4.3.4** Create TypeScript proto loader utilities
- [x] **4.3.5** Create service definitions with metadata
- [x] **4.3.6** Create proto generation script (scripts/generate.ts)
- [x] **4.3.7** Add proto files for isis services
- [x] **4.3.8** Add proto files for sophia services
- [x] **4.3.9** Add proto files for hathor services
- [x] **4.3.10** Set up buf.yaml for linting

### 4.4 @oshun/openapi (OpenAPI Specifications) ✅

- [x] **4.4.1** Create libs/openapi/ project (standalone library)
- [x] **4.4.2** Add project.json with scope:shared, layer:contracts tags
- [x] **4.4.3** Migrate lilith/openapi/openapi.yaml as main spec (37k+ lines)
- [x] **4.4.4** Create spec loader utilities for reading YAML specs
- [x] **4.4.5** Create spec registry with domain metadata
- [x] **4.4.6** Create spec merging utility for combining modular specs
- [x] **4.4.7** Create endpoint and schema extraction utilities
- [x] **4.4.8** Create TypeScript generation script skeleton
- [x] **4.4.9** Create modular OpenAPI specs per domain:
  - [x] isis-api.yaml, sophia-api.yaml, hathor-api.yaml
  - [x] bellona-api.yaml, yemaya-api.yaml, lilith-api.yaml
- [x] **4.4.10** Set up OpenAPI validation in CI

---

