# UOK Droid Accounting Integration

## Purpose

Capture the useful Droid mission-accounting patterns as SF-native UOK contracts without importing Droid's model configuration, file-first state model, or mission runtime shape.

## Adopted Value

- Role-based model policy: durable intent is `auto` plus symbolic constraints, never concrete provider/model IDs.
- Model route evidence: runtime-selected provider/model is recorded as evidence after SF's existing auto selector runs.
- Secret-safe model route snapshots: reproducibility metadata is retained while API keys, headers, and tokens are redacted.
- Typed progress events: stable machine event names such as `unit_selected`, `model_auto_resolved`, `unit_completed`, and `unit_blocked`.
- Structured unit handoff: closeout fields for changed files, tests, commands, failures, leftover work, verification status, and fulfilled assertions.
- Assertion coverage: compare required validation assertions with fulfilled handoff assertions.
- Worker lineage: track worker session IDs, current/completed/failed session IDs, and lifecycle events.
- Tool command registry: worker-visible command allowlists are explicit; Droid-style `services` is treated only as a legacy daemon-service alias.

## Live Now

- `model_auto_resolved`, `unit_selected`, `unit_completed`, and `unit_blocked` progress events are emitted into the existing journal stream alongside legacy events.
- `model-auto-resolved` UOK audit payloads include secret-safe route snapshots.
- UOK outcome memory recording uses the real `createMemory({ ... })` API and records source unit metadata.
- Focused tests cover the projection/accounting helpers and the UOK memory integration.

## Deliberately Deferred

- No DB migration yet. These are projections and contracts until real query/recovery needs prove first-class rows are worth it.
- No hard closeout gate yet. `assessAssertionCoverage()` exists, but completion semantics should change only with a focused gate test.
- No context-pack renderer yet. `buildWorkerContextPackProjection()` is a shape builder, not the prompt renderer.
- No command enforcement yet. `normalizeToolCommandRegistry()` constrains advertised tools/commands; execution enforcement must wire through existing permission/run-control paths.
- No new model router. SF's existing auto model selector remains the only route resolver.

## Next Integration Order

1. Persist worker lineage from real dispatch lifecycle events.
2. Add assertion coverage as a closeout gate before marking a unit complete.
3. Render worker context packs from existing SF DB/runtime state.
4. Feed the tool command registry into worker prompts.
5. Promote selected projection fields into SQLite only after dashboards/recovery flows need durable queries.

## Stop Rule

Do not add more schema helpers for this Droid accounting thread until an existing SF runtime path needs a concrete caller. The next work should be integration into existing UOK dispatch, closeout, prompt, or recovery flows.
