# Runtime Architecture

## Services

1. **Registry:** versioned scales, dimensions, profiles, policies, and Sentinel bindings.
2. **Resolver:** deterministic inheritance/precedence with field provenance.
3. **Observer:** authorized feature extraction; emits observations.
4. **State engine:** decay, aggregation, confidence, contradiction, and state snapshots.
5. **Assessment engine:** target distance, band drift, zones, and boundaries.
6. **Policy engine:** deterministic constraints and eligible response intersection.
7. **Sentinel orchestrator:** least-forceful response, execution/proposal/escalation, outcome loop.
8. **Record/Event store:** append-only provenance and privacy-minimized Events.
9. **Calibration worker:** adjudicated outcomes, drift checks, method caps, and suspension.

## LLM hooks

**Before call (synchronous):** resolve effective profile/policy; validate Consent/data; retrieve only relevant Wisdom; assemble Presence; add a bounded Coherence directive and prohibited effects; record config versions in trace.

**After response, before release (synchronous for consequential output):** measure relevant dimensions; check deterministic and probabilistic boundaries; assess drift; either release, revise/modulate, hold for feedback, or escalate. Low-stakes conversational measurement may complete asynchronously and affect a future turn, never retroactively rewrite the released response.

## Actor hooks

**Before Action (always synchronous):** validate typed Action, Authority, Permission, Consent, Connection, data, target, audience, resource effects, delegation, effective Coherence constraints, stop conditions, audit availability, and idempotency. Result is `allow`, `allow-with-modulation`, `deny`, or `escalate`.

**After Action:** record completed/partial/failed effects; emit outcome; update state; evaluate retry/persistence and recovery; calibrate. Irreversible effects are never inferred as successful from model text.

## Sync versus async

- Synchronous: policy/profile resolution, deterministic boundaries, Authority/Permission checks, preflight, consequential output release gate.
- Asynchronous: non-blocking behavioral observations, state recomputation, trend summaries, calibration, retention/decay, aggregate Realm insights.
- Async work cannot widen or retroactively legitimize an Action.

## Context and storage

System/developer context receives only effective target cues, relevant policies, constraints, confidence warnings, and expiry. Tools receive exact typed Action contracts. Events carry IDs/versions and minimized features. Raw private content is ephemeral by default. Structured governance and audit objects never live only in a vector database.

## Failure and idempotency

Consequential preflight fails closed when Authority, boundary policy, profile version, or audit write is unavailable. Observation-only paths degrade visibly to `unknown`. Interventions and Actions use idempotency keys; retries cannot change target, audience, data, or effect under the same key.

