|
| 1 | +# Persona Decision Surface (Inventory) |
| 2 | + |
| 3 | +This document enumerates, facts-only, the observable persona decision points, veto paths, and annotation APIs in the codebase. It is an inventory for Phase 6 work and contains no proposals. |
| 4 | + |
| 5 | +## Key APIs |
| 6 | + |
| 7 | +- `shieldcraft.persona.emit_veto(engine, persona_ctx, phase, code, explanation, severity)` |
| 8 | + - Capability: **veto** (records a veto in engine state, emits persona events/annotations) |
| 9 | + - Audit: writes to `engine._persona_vetoes` and emits PersonaEvent/PersonaAnnotation via observability |
| 10 | + - Usage: called by persona evaluation code and tests |
| 11 | + |
| 12 | +- `shieldcraft.persona.emit_annotation(engine, persona_ctx, phase, message, severity)` |
| 13 | + - Capability: **annotate** (non-authoritative; emits annotations and PersonaEvent) |
| 14 | + - Audit: appends to engine `_persona_annotations` and emits PersonaEvent |
| 15 | + |
| 16 | +- `shieldcraft.persona.decision_record.record_decision(engine, persona_id, phase, decision)` |
| 17 | + - Capability: **decision** (records non-blocking persona decisions as PersonaEvents) |
| 18 | + - Audit: appends to engine `_persona_decisions` and emits PersonaEvent |
| 19 | + |
| 20 | +## Evaluation & Enforcement Points |
| 21 | + |
| 22 | +- `shieldcraft.persona.persona_evaluator.evaluate_personas(engine, personas, items, phase="checklist")` |
| 23 | + - Scope: **Generator** (ChecklistGenerator.build calls this before persona-influenced checks) |
| 24 | + - Decision types: **veto** (emit_veto), **constraint** (non-mutating instruction recorded via `record_decision`) |
| 25 | + - Determinism: iterates personas deterministically by `persona.name` |
| 26 | + |
| 27 | +- `shieldcraft.services.validator.persona_gate.enforce_persona_veto(engine)` |
| 28 | + - Scope: **Validator / Generator / Readiness evaluator** (called from ChecklistGenerator and readiness evaluator) |
| 29 | + - Decision type: **veto enforcement** (raises `RuntimeError("persona_veto:...")` when vetoes present) |
| 30 | + - Determinism: selects single veto deterministically (sort by severity then persona_id) |
| 31 | + |
| 32 | +- `Engine.preflight` persona veto check |
| 33 | + - Scope: **Engine preflight** (top-level preflight gate checks `engine._persona_vetoes`) |
| 34 | + - Decision type: **REFUSAL** (records `G7_PERSONA_VETO` event and raises `RuntimeError("persona_veto:...")`) |
| 35 | + |
| 36 | +## Persona Loading & Discovery |
| 37 | + |
| 38 | +- `shieldcraft.persona.load_persona(path)` |
| 39 | + - Scope: **persona discovery / engine self-host** (persona files loaded when persona feature enabled) |
| 40 | + - Decision types: **load-time errors** (raises `PersonaError` on invalid persona files, `SyncError` on repo sync failures) |
| 41 | + |
| 42 | +- `shieldcraft.persona.persona_registry` (register/list/find_personas_for_phase) |
| 43 | + - Scope: **in-memory registry for deterministic test/runtime persona evaluation** |
| 44 | + - Behavior: `find_personas_for_phase(phase)` filters by persona `scope` (phase or `all`) |
| 45 | + |
| 46 | +## Observability / Audit |
| 47 | + |
| 48 | +- `shieldcraft.observability.emit_persona_event(engine, persona_id, capability, phase, payload_ref, severity)` |
| 49 | + - Records PersonaEvent payloads (`persona_events_v1.json`) deterministically and emits a companion hash |
| 50 | + |
| 51 | +- `shieldcraft.observability.emit_persona_annotation(engine, persona_id, phase, message, severity)` |
| 52 | + - Records persona annotations (`persona_annotations_v1.json`) deterministically |
| 53 | + |
| 54 | +## Tests and Instrumentation (examples) |
| 55 | + |
| 56 | +- Tests call `emit_veto` and `emit_annotation` directly to simulate persona-driven vetoes and annotations |
| 57 | +- `persona_evaluator.evaluate_personas` is exercised in generator tests (ensures constraints are recorded and applied) |
| 58 | + |
| 59 | +## Observations (facts-only) |
| 60 | + |
| 61 | +- Persona APIs are intentionally conservative and deterministic (sorted iteration, deterministic discovery rules). |
| 62 | +- Persona decisions are recorded via PersonaEvent/Annotation and stored on the `engine` object for deterministic inspection. |
| 63 | +- Veto enforcement is a deterministic, centralized check (`enforce_persona_veto`) used in multiple phases. |
| 64 | + |
| 65 | +This completes the factual inventory of persona decision points in the current codebase. |
0 commit comments