Architecture & API6 min read

Constrained Blackboard Harness & PostgreSQL Schema

Engineering deep-dive into the 5-stage Constrained Blackboard loop, Zero-LLM Hard Gate, and PostgreSQL 17 tables.

5-Stage Constrained Blackboard Execution Loop

Core Engine
  • Step 0 (Pre-Loop): Resolve LLM profile, merge .md skill bundle SHA-256, check exact-hash cache, optionally scrub 18 Safe-Harbor PHI classes, and fetch tenant-isolated episodic memory.
  • Stage 1 (Problem Extraction): High-recall capture of active diagnoses, chronic conditions, symptoms, meds, history, plus confirmed | ruled_out | suspected | historical tags.
  • Stage 2 (Attribute Enrichment): Binds laterality, acuity, stage, episode_of_care (A/D/S), open_closed, cross-section header lookup, and exact [start_char, end_char] spans.
  • Stage 3 (Hybrid Retrieval + KG): BM25 + L2-normalized dense vectors + RRF (top-10) followed by 1-hop ICD Knowledge Graph expansion toward billable leaves & combo targets.
  • Stage 4 (Bounded Tool Selection): Max 4 inner function-calling turns using built-in + MCP tools, followed by autonomous get_child_codes drilldown on any non-billable header.
  • Stage 5 (Reconciliation & Zero-LLM Hard Gate): Merges combination codes (I13.0, E11.22, J44.0), drops subsumed symptoms, runs Zero-LLM CMS/MCE edits, and loops remediation up to max_iters.
Visual Pipeline · Constrained Blackboard Execution Loop
NODE 01
Step 0: Skills+Cache
NODE 02
Stage 1: Problems
NODE 03
Stage 2: Attributes
NODE 04
Stage 3: Vector+KG
NODE 05
Stage 4: Tools+Drilldown
NODE 06
Stage 5: Hard Gate

PostgreSQL 17 Core Data Plane

  • Single source of truth — zero third-party telemetry databases required.
  • Advisory lock pg_advisory_xact_lock(84729103) guarantees multi-replica migration safety.
TablePurpose & Key Invariants
users2-role RBAC (admin | readonly), scrypt hashes, single unique static sk_amd_ key.
batch_jobs & chart_checkpointsDurable per-row checkpointing, retry-failed resume, dataset & chart F1 metrics.
icd_catalog & knowledge_entries~98k FY2027 pre-embedded float32 codes + pgvector HNSW index + admin CRUD overlays.
skill_versionsImmutable SHA-256 history of every .md edit supporting diff & 1-click rollback.
episodic_memoryStrictly tenant-isolated (client_id, insurer_id) historical coder overrides.
chart_hash_cacheExact SHA-256 cache over chart + scope + skill bundle + model for zero duplicate spend.
trace_recordsOn-premise IP-safe 6-Stage Explainability DAG JSON artifacts.
audit_logsTamper-evident SHA-256 hash-chained (prev_hash + entry_hash) HIPAA compliance log.