Make medication safety status provenance-aware - #19
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the hub’s deterministic medication-safety output provenance-aware by returning a canonical drug_safety.v1 object that separates package identity/review state from mapping/exposure/execution completeness, ensuring incomplete or unapproved data cannot appear “checked”.
Changes:
- Introduces a canonical
SafetyCheckResult(drug_safety.v1) with package metadata, coverage, identity confidence, issues, and warnings; updates engine/team streaming envelopes to emit it. - Hardens drug-safety dataset parsing and governance (package identity + review state gates; parser-boundary validation; severity-floor handling).
- Improves QueryStore completeness handling and context-slice metadata (projection completeness, snapshot consistency, similarity-rank reuse) and updates tests/fixtures accordingly.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_staged_stream.py | Updates In-Depth and context overflow tests to use required_ids and new validation metadata. |
| tests/test_stage_engine_v2.py | Ensures drug-safety preparation receives exposure_complete and asserts canonical safety payload presence. |
| tests/test_querystore_client.py | Extends fake pages and adds tests for chartTruncated / projectionComplete handling. |
| tests/test_patient_ledger_cache.py | Adds coverage for snapshot/projection retention in the cached ledger view. |
| tests/test_dual_provider_conformance_adapter.py | Adapts conformance assertions to required_ids. |
| tests/test_drug_safety.py | Adjusts fixtures to clinically-approved test datasets and adds unresolved-drug limitation tests. |
| tests/test_drug_safety_status.py | Reworks fixture adapter to drive real completeness dimensions and adds extensive provenance/validation tests. |
| tests/test_drug_safety_integration.py | Patches load_dataset to an approved dataset for integration tests; asserts package/coverage fields. |
| tests/test_drug_safety_followthrough.py | Adds tests ensuring relationship-package governance isolates dependent warnings/selection. |
| tests/test_drug_safety_atc.py | Updates ATC behavior to “limited/no deterministic warnings” under unapproved classification data. |
| tests/test_context_sources.py | Adds projection completeness + snapshot/rank reuse + snapshot race retry/fail tests; renames mandatory_ids. |
| tests/test_context_budget.py | Expands context-budget tests for protected tiers and required_ids overflow reporting. |
| tests/factories.py | Ensures test ledgers carry patient_ledger_complete metadata. |
| tests/conformance/dual-provider-conformance.v1.json | Updates fixture expectations for tiering (panel) and adds explicit-signal retention case. |
| server/team.py | Replaces _compute_safety_warnings with _compute_safety_check and threads exposure_complete into context building. |
| server/querystore_client.py | Validates chart completeness/projection metadata; adds slice snapshot/projection metadata and similarity rank support. |
| server/patient_ledger_cache.py | Introduces get_ledger returning records + snapshot + projection completeness; keeps get_records as compatibility. |
| server/engine.py | Emits safetyCheck in streaming envelopes; improves In-Depth draft selection and adds validation summaries. |
| server/drug_safety.py | Adds package/review-state governance, strict parsing/validation, severity-floor support, and canonical SafetyCheckResult. |
| server/drug_data/drug-reference.json | Adds package identity + review state marking bundled data as unreviewed research seed. |
| server/drug_data/cross-reactivity-groups.json | Adds package identity + review state marking bundled cross-reactivity as unreviewed research seed. |
| server/context_sources.py | Renames mandatory_ids→required_ids; adds snapshot consistency checks, similarity-rank reuse, and projection completeness metadata. |
| README.md | Documents drug_safety.v1 contract, package governance, and interaction severity-floor behavior. |
| env.recommended | Adds DRUG_SAFETY_MIN_INTERACTION_SEVERITY. |
Suppressed comments (1)
server/engine.py:1197
- Same issue as the
baremode: thecombinedoutput mode addssafetyStatus(and optionallysafetyWarnings) but does not include the canonicalsafetyCheckpayload. Clients consuming blocking/combined results won't see package/coverage/issue provenance.
bool(request.profile.policies.get("drug_safety")),
)
payload["safetyStatus"] = safety_check.status
if safety_check.warnings:
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Owner
Author
|
@copilot resolve the merge conflicts in this pull request |
…ty-honesty # Conflicts: # server/engine.py Co-authored-by: pmanko <711826+pmanko@users.noreply.github.com>
Co-authored-by: pmanko <711826+pmanko@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes deterministic medication-safety results explicit about what was checked, what data was used, and what remains limited or unavailable.
The hub returns one canonical
drug_safety.v1result with package identity, review state, coverage, warnings, and issues. Incomplete source data cannot be presented as a completed safety check, while valid primary warnings remain available when only the relationship package is limited.Key guarantees
What Changed
chartTruncatedmetadata before caching a patient ledger.Reviewed DDI content and CIEL mapping remain a separately governed medication-knowledge track.
Review Focus
Verification
cb4e05f853f4e9ac545ebe62a6ed7732fd167aa7git diff --checkpassed.