agnes-the-ai-analyst/services/verification_detector/schemas.py
PavelDo e1108b6112
feat(memory): corporate memory v1+v1.5 + 0.15.0 (#72)
Adds corporate memory v1 (verification flywheel + contradiction detection + confidence scoring) and v1.5 (audience-based distribution + per-item privacy + admin curation). Server: GET /api/memory/bundle returns mandatory + ranked-approved items within a token budget; POST /api/memory/admin/mandate accepts an audience field gated against user_group_members; /api/memory/stats uses SQL aggregation. CLI: da sync writes received items to .claude/rules/km_*.md. Verification detector extracts knowledge candidates from session JSONL files. Auto-tagging via Haiku when ai: is configured. Adapted from the v9-era branch onto v13/v14 RBAC: _is_privileged_viewer + _effective_groups now query user_group_members JOIN user_groups; require_role(Role.KM_ADMIN) replaced with require_admin (km_admin collapsed into admin). Schema v15: knowledge_items context-engineering columns + knowledge_contradictions + session_extraction_state. Schema v16: verification_evidence. Cuts release v0.15.0 (also bundles #116 /me/debug page).
2026-04-29 07:16:22 +02:00

48 lines
1.7 KiB
Python

"""JSON schema for LLM structured output from the verification detector.
Confidence is intentionally NOT part of this schema. It is derived in code from
(source_type, detection_type) via services.corporate_memory.confidence — the LLM
is not trusted to set its own credibility (see docs/pd-ps-comments.md Q3).
"""
VERIFICATION_SCHEMA: dict = {
"type": "object",
"properties": {
"verifications": {
"type": "array",
"items": {
"type": "object",
"properties": {
"detection_type": {
"type": "string",
"enum": ["correction", "confirmation", "unprompted_definition"],
},
"title": {"type": "string"},
"content": {"type": "string"},
"user_quote": {"type": "string"},
"domain": {
"type": "string",
"enum": [
"finance",
"engineering",
"product",
"data",
"operations",
"infrastructure",
],
},
"entities": {"type": "array", "items": {"type": "string"}},
},
"required": [
"detection_type",
"title",
"content",
"user_quote",
"domain",
"entities",
],
},
}
},
"required": ["verifications"],
}