Skip to content

Changelog — 2026-04-17 (Session 42 — Wave 1 Complete)

Wave 1 Intake Restructuring delivered end-to-end in this session.

Step 1 — Layer State Model

  • app/services/layer_state.py: PatientLayerState (5 layers, high-water-mark completion, deep-merge data)
  • Alembic migration 050dec95da56: nullable layer_state column on cases
  • 25 tests

Step 2 — Scoring Config + Scorers

  • config/scoring.yaml: all weights/thresholds for PFS/HSS/FMS
  • app/services/scoring_config.py: YAML loader with Flagsmith override
  • pfs_scorer.py: PFS pure function (0-100, 4 bands)
  • hss_scorer.py: HSS reframes existing matching engine
  • fms_scorer.py: sigmoid conversion probability
  • 20 tests

Step 3 — 4 Layer Extractors

  • intent_extractor.py: case type, emotional state, urgency, decision stage
  • travel_extractor.py: mobility, oxygen, hospitalization + T1-T4 tier
  • logistics_extractor.py: country, passport, timeline + auto visa derivation
  • financial_extractor.py: funding source, budget range + qualification gate
  • Shared _base.py: LLM call wrapper, JSON fence stripping, completion helper
  • 20 tests

Step 4 — Prompt Layer Contexts

  • 7 layer context YAMLs (intent, medical, travel, logistics, financial, remediation, multi_layer)
  • prompt_loader.load_layer_context(): auto-routes to remediation when PFS band is needs_attention
  • 11 tests

Step 5 — Triage Agent LangGraph

  • app/agents/triage_agent.py: supervisor graph with reducer pattern
  • _merge_layer_deltas reducer enables safe parallel extractors (Step 1 review concern)
  • _append_messages reducer for conversation history
  • 5 nodes: choose_layer, generate_response, run_extractors, compute_pfs_node, conditional routing
  • run_triage_turn() public entry point
  • 12 tests

Step 6 — Audit Tables

  • graph_node_audit_log, scoring_audit_log, extraction_audit_log
  • Append-only with indexes on case_id + created_at
  • Alembic migration 2372ccf4bfe8

Step 7 — LangGraph Checkpointing

  • app/agents/checkpointing.py: AsyncPostgresSaver via DATABASE_URL_ADMIN
  • Added langgraph-checkpoint-postgres + psycopg[binary] to requirements
  • Added database_url_admin to Settings

Step 8 — PFS Remediation Behavior

  • Wired via route_by_pfs + remediation.yaml layer context
  • load_layer_context auto-routes to remediation when band is needs_attention

Step 9 — Tests

  • 88 new Wave 1 tests (23 layer_state + 20 scorers + 20 extractors + 11 layer_contexts + 12 triage_agent + 2 rls)
  • All passing

Step 10 — Integration

  • triage_agent_v3 feature flag (default false — backward compat)
  • Existing orchestrator path unchanged until flag is enabled
  • Rollback: flip flag to false in Flagsmith (no deploy needed)

Metrics

  • ~25 new files
  • ~3,200 lines added
  • 88 new tests (122 including DAO tests on branch)
  • 0 critical code review issues
  • 3 important review issues addressed (deep-merge, thread-safety doc, downgrade warning)