Sync Contract
:::info Source
Sourced from services/ai-gateway-service/SYNC_CONTRACT.md in the documentation repo.
:::
1. Applicability
Limited offline-relevance. Prompts + local AI models can be shipped in PlayPackage bundles for offline AI tutor.
2. Registration
{ service: 'ai_gateway', entityType: 'Prompt', conflictPolicy: 'server_authoritative', deltaProjector: 'prompts_by_tenant', pushHandler: 'none', versionField: 'publishedAt', schemaRef: 'schemas://ai/prompt/v1' }
{ service: 'ai_gateway', entityType: 'LocalAIConfig', conflictPolicy: 'server_authoritative', deltaProjector: 'local_ai_by_device', pushHandler: 'none', versionField: 'updatedAt', schemaRef: 'schemas://ai/local_config/v1' }
3. Offline Behavior
- AI tutor uses local model (Llama-family) cached in PlayPackage bundle.
- Prompts for offline tutor shipped with bundle (specific offline-flagged prompts).
- Completions queued locally (AIcompletion outbox) and synced on reconnect for analytics + cost accounting.
- Budget approximated offline; strict enforcement online only.
4. Local AI Config
- Per-bundle tuple: (model version, quantization, prompt version, safety config).
- Device storage quota enforced.
- Model updates via bundle re-download.
5. LocalStore
ai_cache: (promptHash, modelId PK, output (blob), expiresAt, provenance)
assistant_turns: (id PK, sessionId, payload, aiProvenance, createdAt, pushedAt?)
6. Cursor
Scope: ai:tenant:{tid} for prompts.
7. Security
- Local AI model encrypted within bundle.
- Prompts for offline are a subset (vetted for offline safety).
- PII redaction still applied on-device before sending to local model.