Skip to content

Commit c852ac3

Browse files
committed
feat: harden O-QT evidence contracts and live validation
1 parent 8689e77 commit c852ac3

29 files changed

Lines changed: 6433 additions & 208 deletions

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,18 @@ BYPASS_AUTH=False
1313

1414
# O-QT QSAR Toolbox WebAPI Connection
1515
QSAR_TOOLBOX_API_URL=http://localhost:5000
16+
17+
# Optional QSAR Toolbox client tuning
18+
# These settings are useful when your Toolbox host is slow or load-sensitive.
19+
# The MCP favors bounded, explicit partial results over indefinite waiting.
20+
# QSAR_LIGHT_TIMEOUT_SECONDS=30
21+
# QSAR_HEAVY_TIMEOUT_SECONDS=300
22+
# QSAR_LIGHT_MAX_ATTEMPTS=2
23+
# QSAR_HEAVY_MAX_ATTEMPTS=3
24+
# QSAR_HEAVY_CONCURRENCY=3
25+
26+
# Optional bounded-response safeguards for expensive discovery and hazard helpers
27+
# QSAR_HAZARD_PROFILING_WALLCLOCK_TIMEOUT_SECONDS=25
28+
# QSAR_DISCOVERY_LIST_ALL_TOTAL_WALLCLOCK_TIMEOUT_SECONDS=45
29+
# QSAR_DISCOVERY_LIST_ALL_PER_POSITION_TIMEOUT_SECONDS=6
30+
# QSAR_DISCOVERY_SEARCH_DATABASES_WALLCLOCK_TIMEOUT_SECONDS=20

README.md

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ The current implementation follows a layered model:
6363
- Final suite-level evidence synthesis, BER/WoE logic, and cross-module decisions belong above O-QT in a downstream orchestrator.
6464

6565
See [docs/architecture.md](docs/architecture.md) for the fuller boundary and contract notes.
66+
See [docs/oecd_alignment_review_2025.md](docs/oecd_alignment_review_2025.md) for the OECD 2025 grouping/IUCLID gap analysis and the next contract-focused improvements.
67+
See [docs/cross_suite_alignment_2026.md](docs/cross_suite_alignment_2026.md) for the local AOP/CompTox contract patterns adopted into O-QT.
6668

6769
## What's New In v0.2.0
6870

@@ -71,6 +73,7 @@ This is a maturity and contract release, not a redesign.
7173
- Re-aligned repository identity, package metadata, and release notes around `ToxMCP/oqt-mcp`.
7274
- Clarified the public surface as a primary workflow engine plus secondary expert tools.
7375
- Published portable O-QT handoff schemas for hazard evidence, read-across support, and workflow provenance.
76+
- Hardened the hazard handoff with explicit evidence blocks, applicability-domain review, and richer provenance records for audit-grade downstream review.
7477
- Added explicit downstream-orchestration documentation and examples for contract consumers.
7578
- Documented the current synchronous deployment model instead of implying an async platform that does not exist yet.
7679

@@ -116,7 +119,7 @@ The O-QT MCP server turns that workflow into an **open, programmable interface**
116119
| --- | --- |
117120
| **Primary workflow engine** | Calls the OECD QSAR Toolbox WebAPI to run searches, profilers, metabolism simulators, curated QSAR models, and the flagship `run_oqt_multiagent_workflow` entrypoint. |
118121
| **Grouping/read-across support** | Builds OECD-style grouping dossiers through `build_grouping_justification` with structured similarity and uncertainty reporting. |
119-
| **Portable handoff contracts** | Publishes stable cross-suite handoff schemas for downstream orchestrators and other contract consumers. |
122+
| **Portable handoff contracts** | Publishes stable cross-suite handoff schemas for downstream orchestrators and other contract consumers, including evidence blocks, applicability-domain review, and attachment manifests. |
120123
| **Regulatory-ready reporting** | Generates a comprehensive PDF (ReportLab), Markdown narrative, and JSON provenance bundle. |
121124
| **Enterprise security** | OAuth2/OIDC token validation, RBAC per tool, audit logging, and Docker hardening. |
122125
| **Agent friendly** | Tested with Claude Code, Codex CLI, and Gemini CLI (see [integration guide](docs/integration_guides/mcp_integration.md)). |
@@ -186,6 +189,15 @@ Once running, your MCP host connects to `http://localhost:8000/mcp`.
186189
| Variable | Required | Default | Description |
187190
| --- | --- | --- | --- |
188191
| `QSAR_TOOLBOX_API_URL` || `http://localhost:5000` | Base URL to the OECD QSAR Toolbox WebAPI. |
192+
| `QSAR_LIGHT_TIMEOUT_SECONDS` | Optional | `30` | Per-request timeout for lightweight Toolbox calls. |
193+
| `QSAR_HEAVY_TIMEOUT_SECONDS` | Optional | `300` | Per-request timeout for expensive Toolbox calls such as reports, workflows, and some simulations. |
194+
| `QSAR_LIGHT_MAX_ATTEMPTS` | Optional | `2` | Retry count for lightweight Toolbox calls. |
195+
| `QSAR_HEAVY_MAX_ATTEMPTS` | Optional | `3` | Retry count for expensive Toolbox calls. |
196+
| `QSAR_HEAVY_CONCURRENCY` | Optional | `3` | Concurrency cap for heavy Toolbox calls issued by the MCP. |
197+
| `QSAR_HAZARD_PROFILING_WALLCLOCK_TIMEOUT_SECONDS` | Optional | `25` | Wall-clock cap for the profiling sweep inside `analyze_chemical_hazard`; returns explicit partial evidence if exceeded. |
198+
| `QSAR_DISCOVERY_LIST_ALL_TOTAL_WALLCLOCK_TIMEOUT_SECONDS` | Optional | `45` | Total wall-clock budget for `list_all_qsar_models`. |
199+
| `QSAR_DISCOVERY_LIST_ALL_PER_POSITION_TIMEOUT_SECONDS` | Optional | `6` | Per-endpoint-tree-position timeout while enumerating the QSAR model catalog. |
200+
| `QSAR_DISCOVERY_SEARCH_DATABASES_WALLCLOCK_TIMEOUT_SECONDS` | Optional | `20` | Wall-clock cap for `list_search_databases`; fails fast on timeout. |
189201
| `AUTH_OIDC_ISSUER` | ✅ (prod) || OIDC issuer URL (Auth0, Keycloak, etc.). |
190202
| `AUTH_OIDC_AUDIENCE` | ✅ (prod) || Expected audience in access tokens. |
191203
| `AUTH_OIDC_ALGORITHMS` | ✅ (prod) | `["RS256"]` | Allowed JWT algorithms. |
@@ -200,6 +212,8 @@ Once running, your MCP host connects to `http://localhost:8000/mcp`.
200212

201213
Compatibility note: the current client targets Toolbox WebAPI `/api/v6` routes. Newer Toolbox builds are supported as long as they keep the v6 compatibility layer enabled.
202214

215+
Operational note: on slower Toolbox hosts, prefer tuning the wall-clock safeguards above rather than only increasing retry counts. The MCP is designed to return explicit partial evidence or timeout errors, not to block indefinitely on discovery-heavy endpoints.
216+
203217
See [docs/auth_testing.md](docs/auth_testing.md) for token generation tips and bypass mode safety.
204218

205219
---
@@ -228,8 +242,8 @@ See [docs/auth_testing.md](docs/auth_testing.md) for token generation tips and b
228242
| `get_endpoint_tree` | Returns the endpoint taxonomy used to organise profilers and models. |
229243
| `get_metadata_hierarchy` | Returns the metadata hierarchy useful for filtering experimental data. |
230244
| `list_qsar_models` | Lists QSAR models for a specific endpoint tree position. |
231-
| `list_all_qsar_models` | Enumerates the full QSAR catalog across the endpoint tree (deduplicated). |
232-
| `list_search_databases` | Enumerates searchable inventories in the QSAR Toolbox. |
245+
| `list_all_qsar_models` | Enumerates the full QSAR catalog across the endpoint tree (deduplicated). Returns partial catalog metadata and warnings if enumeration exceeds the configured wall-clock budget. |
246+
| `list_search_databases` | Enumerates searchable inventories in the QSAR Toolbox. Fails fast on timeout rather than waiting through the full heavy retry budget. |
233247
| `run_qsar_model` | Runs a specific QSAR model for a chemId and reports applicability domain status. |
234248
| `run_profiler` | Executes a profiler for a chemId (optionally providing a simulator). |
235249
| `run_metabolism_simulator` | Runs a metabolism simulator using either a chemId or SMILES. |
@@ -301,8 +315,26 @@ See [docs/auth_testing.md](docs/auth_testing.md) for token generation tips and b
301315
- `build_grouping_justification` adds a `grouping_justification` object with target/analogue resolution, similarity assessment, endpoint conclusions, and uncertainty reporting.
302316
- `pdf_report_base64` – base64-encoded, publication-ready PDF.
303317
- `portable_handoffs` – schema-aligned handoff objects for downstream orchestration. `build_grouping_justification` returns `oqtWorkflowRecord.v1` plus `oqtReadAcrossSummary.v1`; `run_oqt_multiagent_workflow` returns `oqtWorkflowRecord.v1` plus `oqtHazardEvidenceSummary.v1`.
318+
- `oqtWorkflowRecord.v1` now declares `rootEntity`, `packageSemantics`, and an auditable `attachments` manifest with checksums when the inline payload is available.
319+
- `oqtHazardEvidenceSummary.v1` now carries request metadata, explicit assessment and decision boundaries, support claims, required external inputs, endpoint summaries, source attribution for model/profiler/simulator evidence, and a qualitative uncertainty block with `semanticCoverage` that explicitly states it is an evidence-completeness assessment rather than a probabilistic estimate.
320+
- `oqtReadAcrossSummary.v1` now promotes explicit assessment and decision boundaries, required external inputs, applicability-domain notes, the portable evidence matrix, and the aspect-level uncertainty table into the published handoff contract.
304321
- Portable downstream contracts are published separately under `schemas/`; see [schemas/README.md](schemas/README.md).
305322

323+
### Metadata & provenance fields
324+
325+
The MCP exposes normalized provenance wherever the Toolbox already returns ownership or study metadata:
326+
327+
- `get_public_qsar_model_info`, `get_profiler_info`, `get_simulator_info`, and `get_calculator_info` include a top-level `provenance` block.
328+
- `list_qsar_models` and `list_all_qsar_models` attach a compact `provenance_summary` to each catalog record.
329+
- `run_qsar_prediction`, `run_qsar_model`, `download_qmrf`, and `download_qsar_report` include `model_provenance`.
330+
- `run_profiler` and `group_chemicals_by_profiler` include `profiler_provenance`.
331+
- `generate_metabolites` and `run_metabolism_simulator` include `simulator_provenance`.
332+
- `analyze_chemical_hazard` now normalizes endpoint study records, endpoint summaries, evidence blocks, applicability-domain review, provenance collections, and a portable `oqtHazardEvidenceSummary.v1` handoff alongside the raw Toolbox payloads. The helper is intentionally bounded: if `profiling/all` is too slow, it returns partial endpoint evidence with explicit uncertainty and warning fields instead of waiting indefinitely.
333+
- Hazard and read-across handoffs now publish machine-readable boundary fields (`assessmentBoundary`, `decisionBoundary`, `decisionOwner`) plus `supports` and `requiredExternalInputs`, so downstream systems can distinguish what O-QT packaged from what still requires expert review, regulatory policy, exposure context, or cross-module synthesis.
334+
- High-level workflow outputs preserve the same normalized metadata inside `log_json.profiler_results[*].profiler_provenance`, `log_json.simulator_results[*].simulator_provenance`, and `log_json.qsar_results[*].model_provenance`.
335+
- Report-style tools (`download_qmrf`, `download_qsar_report`, `download_workflow_report`) now also declare `content_type`; when the Toolbox returns a ZIP bundle rather than a bare PDF, the MCP response includes `archive_entries` and `pdf_report_base64` when a PDF member can be extracted.
336+
- High-level workflows and grouping dossiers accept direct Toolbox `chemId` values as `identifier` inputs, which lets orchestrators bypass flaky search endpoints once a substance has already been resolved.
337+
306338
---
307339

308340
## Running the server

docs/cross_suite_alignment_2026.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Cross-Suite Alignment Review (2026-04-08)
2+
3+
This note records the local cross-suite contract review used to harden O-QT MCP for auditability, verifiability, and regulated downstream use.
4+
5+
## Repos inspected locally
6+
7+
- `AOP_MCP`
8+
- `comptox_mcp_clean_3568d68`
9+
- `PBPK_MCP`
10+
- `Bioactivity-PoD-MCP`
11+
12+
## Patterns adopted into O-QT MCP
13+
14+
### From AOP MCP
15+
16+
- Explicit evidence blocks instead of only free-form summaries.
17+
- Provenance records that say which source populated which contract field and with what transformation confidence.
18+
- Clear separation between evidence packaging and final decision logic.
19+
20+
### From CompTox MCP
21+
22+
- Explicit applicability-domain framing as a first-class review object.
23+
- Stronger metadata and provenance packaging for downstream audit workflows.
24+
- Preference for machine-readable review fields over narrative-only payloads.
25+
26+
### From PBPK MCP
27+
28+
- Machine-readable assessment and decision boundaries rather than only prose caveats.
29+
- Explicit `supports` and `requiredExternalInputs` fields so downstream consumers can tell what the module does and does not claim to decide.
30+
- Stronger uncertainty framing that distinguishes semantic coverage from quantitative confidence.
31+
32+
### From Bioactivity-PoD MCP
33+
34+
- Explicit `decisionOwner` language so handoff objects make ownership boundaries visible.
35+
- Contract emphasis on fit-for-purpose review rather than implied finality.
36+
- Preference for provenance-ready, typed records over narrative-only summaries.
37+
38+
## O-QT changes made from this review
39+
40+
- `oqtHazardEvidenceSummary.v1` now includes:
41+
- `assessmentBoundary`
42+
- `decisionBoundary`
43+
- `decisionOwner`
44+
- `supports`
45+
- `requiredExternalInputs`
46+
- `uncertaintyAssessment.semanticCoverage`
47+
- `oqtReadAcrossSummary.v1` now includes:
48+
- `assessmentBoundary`
49+
- `decisionBoundary`
50+
- `decisionOwner`
51+
- `supports`
52+
- `requiredExternalInputs`
53+
- Read-across provenance schemas now allow retry `attempts` in source records when Toolbox call metadata is available.
54+
55+
## What was intentionally not copied
56+
57+
- AOP draft-authoring semantics, because O-QT is not an authoring server.
58+
- CompTox-style numeric applicability-domain confidence, because O-QT does not currently produce a scientifically defensible quantitative AD confidence estimate.
59+
- PBPK qualification or model-trust governance objects, because O-QT should stay focused on OECD QSAR Toolbox evidence packaging rather than model-qualification workflow management.
60+
- Bioactivity point-of-departure decision objects, because O-QT should not claim ownership of final biological interpretation outside its module scope.
61+
- Suite-level evidence synthesis, because O-QT should remain a module-scoped OECD QSAR Toolbox engine.

0 commit comments

Comments
 (0)