{
  "schema_version": "0.1",
  "artifact_type": "prd",
  "canonical": true,
  "artifact_id": "PRD-011",
  "agent_summary": {
    "title": "Structured Reasoning Diagnostic kernel",
    "status": "approved",
    "summary": "Evolve the existing local Reason Guard into a structured deterministic diagnostic kernel with explicit evidence obligations, coalesced findings, and coverage-qualified completion clearance, without creating an RSP or standalone server.",
    "last_reviewed_at": "2026-07-24",
    "load_notes": "Canonical requirements grounded by the hash-bound planning.requirements workflow WFR-408 and explicitly approved by the user on 2026-07-24."
  },
  "goals": [
    "Turn explicit promised evidence checks into bounded structured obligations that state what evidence is required and how it will be accepted.",
    "Clear obligations deterministically from bound host tool results without model or network calls on the hook path.",
    "Coalesce repeated obligation findings into one actionable diagnostic with bounded occurrence history.",
    "Produce an honest completion-clearance receipt that reports mode, coverage, limitations, deferred work, and remaining blockers.",
    "Preserve report as the default mode, privacy boundaries, low-latency local execution, and Claude, Codex, and OpenCode parity."
  ],
  "non_goals": [
    "Build an RSP, Reasoning Diagnostic Server, standalone process, network protocol, or remote event-ingestion service.",
    "Add changed-symbol impact analysis, repository dependency diagnostics, context brokerage, or generic diagnostic code actions.",
    "Call a model or an external service from the Reason Guard hook path.",
    "Persist raw or private reasoning, prompts, transcripts, secrets, credentials, or raw tool output.",
    "Treat inferred natural-language intent as sufficient authority to hard-block completion."
  ],
  "requirements": [
    {
      "id": "PRD-REQ-085",
      "priority": "must",
      "summary": "Accept a versioned host-neutral evidence-check directive with bounded fields for obligation kind, claim, required evidence, acceptance predicates, expected result, blocking policy, and source confidence.",
      "source_ids": ["REQ-173", "REQ-171", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-098"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-086",
      "priority": "must",
      "summary": "Retain conservative prose inference only as labelled lower-confidence fallback; inferred obligations default to report-only and cannot independently hard-block completion.",
      "source_ids": ["REQ-173", "WFR-408", ".prd_plugin/hooks/prd_reason_guard.py"],
      "acceptance_ids": ["PRD-ACC-099"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-087",
      "priority": "must",
      "summary": "Bind observed evidence to host tool identity and outcome, then evaluate only a fixed allowlist of bounded deterministic acceptance predicates.",
      "source_ids": ["REQ-173", "REQ-171", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-100"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-088",
      "priority": "must",
      "summary": "Represent repeated findings as one active diagnostic per diagnostic code and obligation, with bounded occurrence count and first-seen, last-seen, active, and resolved metadata.",
      "source_ids": ["REQ-173", "WFR-408", "tests/test_reason_guard.py"],
      "acceptance_ids": ["PRD-ACC-101"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-089",
      "priority": "must",
      "summary": "Migrate existing local Reason Guard state atomically, preserve supported obligation and evidence history, reject malformed or future schemas safely, and retain replay and concurrency guarantees.",
      "source_ids": ["REQ-173", "REQ-171", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-102"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-090",
      "priority": "must",
      "summary": "Emit a completion-clearance receipt whose status is clear, conditional, or blocked and which always reports mode, coverage, limitations, open blocking obligations, deferred count, and a report digest.",
      "source_ids": ["REQ-173", "REQ-172", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-103"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-091",
      "priority": "must",
      "summary": "Persist only bounded summaries, identifiers, digests, predicate outcomes, and sanitized metadata; exclude raw or private reasoning, prompts, transcripts, secrets, credentials, and raw tool output.",
      "source_ids": ["REQ-173", "REQ-171", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-104"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-092",
      "priority": "must",
      "summary": "Preserve Claude, Codex, and OpenCode behavior plus downstream template and installer parity, and present human-readable diagnostic, status, configuration, and UI text with internal IDs secondary when needed.",
      "source_ids": ["REQ-173", "REQ-172", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-105"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-093",
      "priority": "must",
      "summary": "Keep processing local, deterministic, model-free, network-free, and bounded; retain latency reporting and prove no material regression against the checked-in benchmark method before release.",
      "source_ids": ["REQ-173", "REQ-171", "WFR-408"],
      "acceptance_ids": ["PRD-ACC-106"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-094",
      "priority": "must",
      "summary": "Persist separate Claude, Codex, and OpenCode Reason Guard ledgers whose bounded session records survive host and session changes without overwriting prior audit state.",
      "source_ids": ["REQ-176", "DBR-002", "WFR-445"],
      "acceptance_ids": ["PRD-ACC-107"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-095",
      "priority": "must",
      "summary": "Backfill trusted Claude history from visible assistant text records only, using the same live, recent-X, full, cursor, replay, source-integrity, and coverage semantics as supported Codex history.",
      "source_ids": ["REQ-176", "DBR-002", "WFR-445"],
      "acceptance_ids": ["PRD-ACC-108"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-096",
      "priority": "must",
      "summary": "Migrate supported single-report state safely and expose human-readable host and session history through status and UI while keeping session identifiers secondary.",
      "source_ids": ["REQ-176", "DBR-002", "WFR-445"],
      "acceptance_ids": ["PRD-ACC-109"],
      "status": "approved"
    },
    {
      "id": "PRD-REQ-097",
      "priority": "must",
      "summary": "Distinguish provider, surface, current model, effort level, and session so Codex Desktop, Codex CLI, Claude Desktop, Claude CLI, and OpenCode are reported separately from internal session identity; unsupported markers must remain explicitly unknown.",
      "source_ids": ["REQ-176", "DBR-002"],
      "acceptance_ids": ["PRD-ACC-110"],
      "status": "approved"
    }
  ],
  "non_functional_requirements": [
    {
      "id": "PRD-NFR-043",
      "summary": "Security and privacy: acceptance is data, never executable code, and durable state contains no private reasoning, prompt, transcript, secret, credential, or raw tool-output material.",
      "source_ids": ["PRD-REQ-087", "PRD-REQ-091"]
    },
    {
      "id": "PRD-NFR-044",
      "summary": "Performance: hook work is bounded by configured collection and field limits, performs no model or network calls, and keeps measured latency visible.",
      "source_ids": ["PRD-REQ-085", "PRD-REQ-088", "PRD-REQ-093"]
    },
    {
      "id": "PRD-NFR-045",
      "summary": "Reliability: migration, replay, duplicate delivery, interruption, malformed input, and concurrent host events fail safely without corrupting the local ledger.",
      "source_ids": ["PRD-REQ-087", "PRD-REQ-088", "PRD-REQ-089"]
    },
    {
      "id": "PRD-NFR-046",
      "summary": "Portability and parity: one host-neutral contract drives equivalent Claude, Codex, and OpenCode semantics and every shipped downstream copy.",
      "source_ids": ["PRD-REQ-085", "PRD-REQ-092"]
    },
    {
      "id": "PRD-NFR-047",
      "summary": "Honesty and boundedness: reduced or missing coverage is visible, can only yield conditional or blocked clearance, and no server or adjacent diagnostic platform enters this slice.",
      "source_ids": ["PRD-REQ-086", "PRD-REQ-090", "PRD-REQ-093"]
    },
    {
      "id": "PRD-NFR-048",
      "summary": "Longitudinal privacy and reliability: host ledgers retain bounded session metadata and sanitized diagnostic state while excluding raw transcripts, prompts, thinking blocks, signatures, credentials, and tool payloads.",
      "source_ids": ["PRD-REQ-094", "PRD-REQ-095", "PRD-REQ-096"]
    }
  ],
  "acceptance_criteria": [
    {
      "id": "PRD-ACC-098",
      "summary": "Contract tests accept valid versioned evidence-check directives and reject unknown versions, oversized fields, unknown keys, invalid blocking values, and unsupported predicate shapes without creating a blocking obligation.",
      "requirement_ids": ["PRD-REQ-085", "PRD-NFR-045"]
    },
    {
      "id": "PRD-ACC-099",
      "summary": "A prose promise can create a labelled heuristic report-only observation, but only a valid explicit directive can create a blocking obligation.",
      "requirement_ids": ["PRD-REQ-086", "PRD-NFR-047"]
    },
    {
      "id": "PRD-ACC-100",
      "summary": "Bound tool results clear obligations only when tool identity, outcome, and every allowlisted acceptance predicate match; unrelated, failed, malformed, replayed, or mismatched evidence leaves the obligation open without evaluating arbitrary code.",
      "requirement_ids": ["PRD-REQ-087", "PRD-NFR-043", "PRD-NFR-045"]
    },
    {
      "id": "PRD-ACC-101",
      "summary": "Repeated completion-boundary events for the same code and obligation produce one diagnostic whose bounded occurrence metadata updates deterministically; resolution closes that diagnostic without losing its audit summary.",
      "requirement_ids": ["PRD-REQ-088", "PRD-NFR-044", "PRD-NFR-045"]
    },
    {
      "id": "PRD-ACC-102",
      "summary": "Migration fixtures upgrade supported legacy state atomically and preserve relevant history; malformed or future state is quarantined or reported safely, and concurrent/replayed events remain idempotent.",
      "requirement_ids": ["PRD-REQ-089", "PRD-NFR-045"]
    },
    {
      "id": "PRD-ACC-103",
      "summary": "Clearance is clear only with full coverage and no open blocking obligations or active blocking diagnostics; reduced coverage is conditional at best, and unresolved or deferred blockers are named in human-readable form.",
      "requirement_ids": ["PRD-REQ-090", "PRD-NFR-047"]
    },
    {
      "id": "PRD-ACC-104",
      "summary": "Privacy sentinel tests prove local state, reports, diagnostics, receipts, logs, and snapshots contain only bounded sanitized metadata and digests, never prohibited raw content.",
      "requirement_ids": ["PRD-REQ-091", "PRD-NFR-043"]
    },
    {
      "id": "PRD-ACC-105",
      "summary": "Equivalent fixtures pass through Claude, Codex, and OpenCode dispatch paths; hub and skeleton copies match; configuration, status, and UI surfaces use readable names and explanations with IDs secondary only where needed.",
      "requirement_ids": ["PRD-REQ-092", "PRD-NFR-046"]
    },
    {
      "id": "PRD-ACC-106",
      "summary": "The focused benchmark and full release gates show bounded collection sizes, no hook-path model or network dependency, retained latency reporting, no material benchmark regression, and CHML zero after the final audit-fix-reaudit cycle.",
      "requirement_ids": ["PRD-REQ-093", "PRD-NFR-044", "PRD-NFR-047"]
    },
    {
      "id": "PRD-ACC-107",
      "summary": "Equivalent Claude, Codex, and OpenCode events update only their own host ledger and session record; concurrent and replayed events remain atomic and idempotent; bounded retention preserves recent sessions and never lets a new session overwrite another.",
      "requirement_ids": ["PRD-REQ-094", "PRD-NFR-045", "PRD-NFR-048"]
    },
    {
      "id": "PRD-ACC-108",
      "summary": "Claude fixtures and one existing offline transcript prove visible assistant text is ingested oldest-to-newest in live, recent-X, and full modes while thinking, signatures, user content, attachments, and tool payloads never enter state or telemetry.",
      "requirement_ids": ["PRD-REQ-095", "PRD-NFR-043", "PRD-NFR-044", "PRD-NFR-048"]
    },
    {
      "id": "PRD-ACC-109",
      "summary": "A supported legacy single report migrates exactly once into its matching host and session; status and UI expose readable host/session history with identifiers secondary; hub, skeleton, and installer surfaces remain in parity.",
      "requirement_ids": ["PRD-REQ-096", "PRD-NFR-045", "PRD-NFR-046", "PRD-NFR-048"]
    },
    {
      "id": "PRD-ACC-110",
      "summary": "Trusted Codex originator/turn-context and Claude entrypoint/assistant metadata fixtures distinguish Desktop from CLI and retain the latest model and effort; OpenCode forwards bounded assistant model/effort-like variant metadata; explicit overrides work; unknown or cross-provider markers are not guessed; status and UI lead with readable surface, model, and effort while keeping the session ID secondary.",
      "requirement_ids": ["PRD-REQ-097", "PRD-NFR-045", "PRD-NFR-046", "PRD-NFR-048"]
    }
  ],
  "dependencies": [
    "The shipped Reason Guard hook, state lock, dispatcher adapters, mode configuration, and report/status projection remain the implementation base.",
    "The repaired Codex reasoning-summary routing from REQ-172 remains covered by parity tests.",
    "Existing installer, skeleton parity, feature-coverage, local workflow, and release gates remain authoritative."
  ],
  "open_questions": [],
  "approval_gate": {
    "status": "approved",
    "scope": "PRD-011, ARCH-011, and IMP-013 were explicitly approved by the user.",
    "implementation_authorized": true,
    "approved_at": "2026-07-24",
    "approved_by": "user"
  },
  "traceability": {
    "source_ids": ["REQ-173", "REQ-171", "REQ-172", "REQ-176", "DBR-002", "WFR-408", "WFR-445"],
    "request_ids": ["REQ-173"],
    "architecture_ids": ["ARCH-COMP-065", "ARCH-COMP-066", "ARCH-COMP-067", "ARCH-COMP-068", "ARCH-COMP-069"],
    "implementation_task_ids": ["IMP-TASK-104", "IMP-TASK-105", "IMP-TASK-106", "IMP-TASK-107", "IMP-TASK-108", "IMP-TASK-109", "IMP-TASK-110", "IMP-TASK-111", "IMP-TASK-112", "IMP-TASK-117", "IMP-TASK-118", "IMP-TASK-119"],
    "tracking_ids": ["TRK-163"],
    "health_ids": []
  }
}
