Spaces:
Sleeping
A newer version of the Gradio SDK is available: 6.26.0
Deterministic Diagnostics for Bio-AI Integrity
Version 1.8.4 (Active deterministic bio diagnostics note)
This document is the active deterministic diagnostics specification for STEM BIO-AI's bio-focused deterministic lane. The local lane is implemented as evidence-bearing repository diagnostics inside stem_ai/detector_bio.py. The optional AI lane remains advisory, opt-in, and non-authoritative.
1. Executive Summary
Traditional LLM-based auditing suffers from "hallucination of safety." To reach the strongest structural audit-readiness tier, STEM-BIO-AI must move from interpreting claims (README analysis) to measuring reality (Code/Config analysis). We therefore separate the problem into two lanes:
Lane A -- Deterministic local diagnostics
- Fast, reproducible, no network requirement.
- Produces line-level or string-level evidence suitable for
evidence_ledger. - Handles syntax integrity, placeholder patterns, silent mock fallbacks, and unsafe bio-tool subprocess construction.
Lane B -- Optional AI-assisted semantic review
- Runs only as an explicit second pass.
- Consumes extracted evidence packets, not arbitrary raw repository text by default.
- Helps with nuanced SMILES plausibility review, medicinal-chemistry style pattern review, and ranking suspicious molecules for manual inspection.
The local deterministic lane is authoritative for hard findings. The AI lane is advisory and may elevate review priority, but it must not silently override deterministic evidence.
1A. Implementation Status (STEM BIO-AI v1.8.4)
Implemented now:
SMILES-DECEPTLane A0 conservative surface scannerSMILES-DECEPTLane A1 optional RDKit validation laneSILENT-MOCKfallback detectionTRACE-MANIFESTtraceability surface detectionRUN-TRACEbio-tool subprocess heuristics- Markdown / explain report surfacing for bio deterministic diagnostics
- Registry-driven regulatory traceability attachment using deterministic evidence without score override
- Performance-oriented AST context reuse, node pre-bucketing, generated-path pruning, and optional RDKit gating that preserve detector semantics while reducing scan overhead
Implemented as evidence-only:
- Findings are emitted into
evidence_ledger - Findings appear in Markdown, HTML, PDF summaries, and
--explain - Findings do not change
final_scoreorformal_tier
Not yet implemented:
- AI-assisted Lane B semantic review
MOUNT-AUDITIFU-DEEP-SCANSAFETY-INTERRUPT
2. Technical Roadmap
2.1 [SMILES-DECEPT] SMILES Mock & Integrity Scanner
- Objective: Identify "Chemistry Slop" — where a model claims to produce biological molecules but outputs placeholders or invalid SMILES.
- Implementation:
- Lane A0 / Stdlib-Only Surface Scan: Default path with no chemistry dependency; focuses on malformed or suspicious SMILES-like strings and unsafe parser usage patterns.
- Lane A1 / Optional Chemistry Parser Validation: If RDKit is installed, validate candidate SMILES via
MolFromSmiles(...)and treat parser failure as stronger deterministic evidence. This lane remains local and optional. - Lane A / Phase 1 (Local Heuristic): Scan for hardcoded strings matching SMILES-like patterns. Flag strings with low entropy (e.g.,
CCCCCCCCCC), extremely short length (< 4 heavy atoms unless explicitly example/test context), repeated placeholder patterns, or molecule lists where a large fraction are duplicated. - Lane A / Phase 2 (Local Grammar & State Machine):
- Balanced Parentheses: Verify branching logic integrity using a stack-based counter for
(and). - Ring Label Pairing: Tokenize one-digit ring labels (
1-9) and two-digit labels (%10,%11, etc.) and verify that each label closes correctly while active. Already-closed labels may be reused later within the same SMILES string, so the implementation must maintain an active closure map rather than enforce a naive global digit-count rule. - Bracket Integrity: Verify
[and]are paired and contain syntactically plausible atom tokens. - Token Validity: Verify basic element symbol validity (B, C, N, O, P, S, F, Cl, Br, I, etc.), bond markers, aromatic symbols, and ring tokens.
- Boundary Note: This phase is a conservative syntax-screen, not a full SMILES parser. It is expected to catch obvious malformed strings and suspicious structure tokens, but not to establish full cheminformatics correctness without an external chemistry engine.
- Balanced Parentheses: Verify branching logic integrity using a stack-based counter for
- Lane A / Phase 3 (Surface Safety Checks):
- Parser-Guard Pattern: Detect
MolFromSmiles(...),Chem.MolFromSmiles(...),dm.to_mol(...), or equivalent calls and verify that the returned object is checked forNoneor handled via explicit error logic before downstream use. - Placeholder Context Check: Flag suspicious reuse of trivial molecules (
CCO,c1ccccc1,CCCC, etc.) in non-example, non-test, non-doc contexts. - Entropy/Redundancy Check: Flag batches where a high proportion of outputs are identical, near-identical, or structurally repetitive placeholder strings.
- Parser-Guard Pattern: Detect
- Lane B / Optional AI-Assisted Review:
- Input: Deterministic evidence packet containing extracted candidate SMILES, file/line references, parser-guard findings, duplication statistics, and context snippets.
- Task: Ask an AI model to classify whether suspicious strings look like placeholders, malformed chemistry, low-diversity output, or domain-inappropriate output for the claimed task.
- Output Contract: AI must cite each reviewed molecule by finding ID, return a confidence bucket, and distinguish
syntax concern,semantic concern, andmanual review needed. - Boundary: AI review is advisory only. It does not prove chemical validity and does not override local parser-guard or syntax findings.
- Public Wording Constraint: This detector should be described as a conservative SMILES surface integrity scanner. It does not establish full chemical validity, medicinal usefulness, synthetic feasibility, binding plausibility, or efficacy.
- Required Dependency: None (Python Standard Library).
- Optional Dependency: RDKit for Lane A1 chemistry parser validation.
2.2 [MOUNT-AUDIT] Bio-Infrastructure Volume Scanner
- Objective: Identify "BioClaw" failure modes — writable mounts on sensitive biological databases or clinical data directories.
- Implementation:
- Surface Scan: Recursive search for
Dockerfile,docker-compose.yml, and Kubernetes manifests. - Rigor Check: Flag volume mappings that omit the
:ro(read-only) flag when mapping to known data directories (/data,/datasets,/models,/workspace). - Permission Shadowing: Detect
chmod 777,chmod -R a+w, privileged container settings, writable host-path or PVC mounts, or ownership/mode changes that make sensitive biological artifacts writable or obscure expected access boundaries. - Evidence: File path + line number of the insecure mount/permission.
- Surface Scan: Recursive search for
- Dependency: None.
2.3 [RUN-TRACE] Bio-Insecure Subprocess Analysis
- Objective: Identify "Biomni" failure modes — unvalidated shell execution in medical analysis pipelines.
- Implementation:
- AST Analysis: Extend
detector_ast.pyto tracesubprocess.*,os.system, andeval. - Context Check: Identify if shell execution is used for critical bio-tools (e.g.,
blast,samtools,bwa,bcftools) and check ifshell=Trueis enabled (High Risk). - Taint Check (Heuristic): Flag calls where the command string is constructed via f-strings, concatenation, or
.format()using variables that are likely external-input carrying (e.g.,query,input,sample,user_path,request_path). Simple string formatting alone is not sufficient for a hard finding. - Severity Policy (Initial Release):
shell=Truewith known bio-tool invocation ->warnshell=Trueplus external-input taint indicators ->high-priority warn- direct
os.system(...)with external-input taint indicators ->high-priority warn - initial release output is evidence-only and does not change final score until benchmark calibration is complete
- False-Positive Boundary: Paths derived from fixed internal config, repository constants, or static workflow definitions should not be treated as equivalent to user-controlled request input.
- AST Analysis: Extend
- Dependency: None (
aststdlib).
2.4 [SILENT-MOCK] Library Fallback Detector
- Objective: Identify silent fallbacks to mock/simulated data when biological dependencies are missing (Empirical pattern found in
Biomni/immunology.py). - Implementation:
- Import-Time Fallback: Scan for
try...except...blocks surroundingimport rdkit,import biopython,import scanpy, etc., where theexceptblock sets ause_mock = Trueflag, logs "Using simulated data", or silently swaps to a synthetic provider. - Runtime Fallback: Detect production-path branches such as
if USE_MOCK,DEMO_MODE,SIMULATE_DATA, or environment-driven mock toggles that redirect real analysis code into synthetic output paths without an explicit hard-stop or visible disclosure. - Residual Test Logic in Production: Flag
skipif,mock,fake,dummy, or simulation-oriented control flow that appears in non-test runtime modules and influences output generation. - Severity Policy:
- mock surface present but clearly disclosed and non-clinical/demo scoped ->
warn - mock/simulated output continues through functional analysis path without explicit boundary ->
fail candidate - final score mapping should remain gated behind benchmark evidence; initial release should emit evidence and recommended severity
- mock surface present but clearly disclosed and non-clinical/demo scoped ->
- Integrity Penalty: If
clinical_adjacent_severityis high, a silent fallback to mock data without a hard error is a clinical risk aligned withC3/C4.
- Import-Time Fallback: Scan for
- Dependency: None.
2.5 [TRACE-MANIFEST] Traceability Artifact Scanner
- Objective: Identify evidence of Art 12 (Record-keeping) intent via versioned configuration and hash manifests.
- Implementation:
- Heuristic: Scan for files matching
manifest.json,checksums.txt,model_hashes.yaml, or.lockfiles that include cryptographic hashes of non-code artifacts (models, datasets). - Config Tracking: Flag usage of
hydra,pydantic-settings, or.envfiles that explicitly version environment parameters. - Runtime Log Schema Surface: Detect files or schema fragments such as
audit_log_schema.json,event_log_schema.yaml,decision_event,override_event,model_version,dataset_hash,operator_id,timestamp,input_hash, andoutput_hash.
- Heuristic: Scan for files matching
- Dependency: None.
2.6 [IFU-DEEP-SCAN] Transparency & Misuse Detector
- Objective: Move beyond simple disclaimers to identify Art 13 (Transparency) structural components.
- Implementation:
- Regex Scan: Search for high-fidelity section headers:
Intended Use,Foreseeable Misuse,Interpretation Guidance,Accuracy Metrics,Cybersecurity Posture. - Scoring Boundary: Higher weight should apply only when a target section has a non-empty body and includes specific misuse cases, boundary language, and metric or limitation references. Headers alone are not sufficient evidence.
- Regex Scan: Search for high-fidelity section headers:
- Dependency: None.
2.7 [SAFETY-INTERRUPT] Human Oversight Interface Detector
- Objective: Identify the mechanism for Art 14 (Human Oversight) via code-level entry points.
- Implementation:
- AST Analysis: Scan for signal handlers (
signal.signal), explicit "Stop" flags in config loops, ortry...except KeyboardInterruptblocks that transition to aSAFE_STATE. - CLI Logic: Detect boolean flags like
--force,--override,--manualin Argparse/Click definitions that allow a human to bypass or reverse an AI-driven decision. - Reason-Capture Surface: Detect override reason fields, reviewer identity fields, escalation notes, or post-hoc review capture surfaces associated with manual interruption or override.
- AST Analysis: Scan for signal handlers (
- Dependency: None (
aststdlib).
3. Integration with STEM-BIO-AI CORE
These diagnostics align with the current Code Integrity (C1-C6) and bio-diagnostic surfaces in the 1.8.4 line:
- SMILES-DECEPT -> bio deterministic diagnostics surface first; possible future linkage to
C3or a dedicated bio-integrity lane after benchmark review - MOUNT-AUDIT -> future hardening candidate; not currently shipped in the active runtime
- RUN-TRACE -> bio deterministic diagnostics surface first; may later inform
C4or downstream governance review if benchmarked - SILENT-MOCK -> bio deterministic diagnostics surface first; conceptually adjacent to
C6when mock or demo behavior weakens local/self-host trust boundaries, but not currently score-linked - TRACE-MANIFEST -> Stage 4 / regulatory-traceability support surface, not a direct Code Integrity penalty lane
Regulatory Relevance Note: These mappings are engineering-risk mappings inside STEM-BIO-AI CORE. They should not be restated externally as direct evidence of legal compliance without the traceability boundaries described in REGULATORY_MAPPING.md.
Current boundary note: C4, C5, and C6 are now intentionally split:
C4is reserved for executable fail-open exception behavior in codeC5is reserved for unsupported legal/compliance or clinical-boundary integrity warningsC6is reserved for mock-auth, auto-login, or no-auth local/self-host trust-boundary warnings
The deterministic bio diagnostics lane can support or contextualize these surfaces, but it does not silently rewrite them.
4. Two-Lane SMILES Review Policy
SMILES review is feasible in both a simple local lane and a more precise AI-assisted lane, but they answer different questions.
4.1 What local deterministic review can do well
- Detect malformed or suspicious SMILES surface patterns without network access.
- Detect missing parser guards around common cheminformatics parsers.
- Detect placeholder, duplicated, or low-diversity molecule output surfaces.
- Produce exact evidence that a human can verify line-by-line.
- Serve as a deterministic pre-filter before any optional chemistry-engine or AI-assisted review.
4.2 What local deterministic review cannot prove
- Medicinal usefulness.
- Synthetic feasibility.
- Binding plausibility.
- Biological efficacy.
- Full chemical validity beyond the implemented grammar checks.
- Correct interpretation of every legal SMILES edge case without a dedicated chemistry parser.
4.3 What AI-assisted review can add
- Triage suspicious SMILES batches into likely placeholder output vs. plausible chemistry.
- Compare claimed task context (e.g. kinase inhibitor design, antibody linker, fragment generation) against the style of generated molecules.
- Highlight unusual protecting groups, unrealistic repetition, or domain-mismatched outputs for manual review.
4.4 AI lane constraints
- AI review is opt-in and must be separated from the deterministic lane.
- AI should receive extracted evidence packets first, not unrestricted repository dumps.
- AI findings must cite deterministic finding IDs.
- AI may escalate review priority but may not erase deterministic FAIL/WARN findings.
- If AI is unavailable, the deterministic lane remains complete and operational.
5. Why Deterministic-First?
- Verifiability: A score of "FAIL" must point to a specific line of code or exact SMILES string that a human can verify.
- Security: Auditing clinical or bio-adjacent code should not require sending raw code to a 3rd-party model by default.
- Speed: Deterministic scans run in milliseconds; AI escalation is slower and should be reserved for ambiguous cases.
- Governance: The deterministic lane creates the evidence substrate that later advisory or AI systems must cite.
6. Scoring and Release Boundary
These detectors should not all enter scoring at the same time.
SMILES-DECEPT
- Initial mode: evidence-only
- Candidate later mapping:
C3or a new bio-integrity detail lane after benchmark review
RUN-TRACE
- Initial mode: evidence-only
- Reason: heuristic taint detection is useful for triage but too noisy to score before calibration
SILENT-MOCK
- Initial mode: evidence + recommended severity
- Strongest candidate for eventual
C3/C6score impact after benchmark confirmation
Any future score impact must be justified by commit-pinned benchmark evidence and explicit false-positive review.
7. Proposed Output Shape for SMILES Review
{
"detector": "BIO_smiles_decept",
"finding_id": "BIO_smiles_decept:src/generator.py:88:001",
"status": "detected",
"severity": "warn",
"smiles_text": "CCCCCCCCCC",
"issues": [
"low_entropy_placeholder_pattern",
"duplicate_batch_pattern"
],
"local_parser_guard": "not_detected",
"ai_review": {
"enabled": false,
"status": "not_requested",
"semantic_concern": null,
"confidence_bucket": null
}
}
This shape preserves the rule that deterministic evidence is primary while still allowing optional AI annotations later.
8. Next Steps
- Build commit-pinned fixture sets:
- positive controls: known silent-mock, unsafe subprocess, malformed/placeholder SMILES repos
- negative controls: mature bioinformatics repos with legitimate subprocess usage and explicit parser guards
- ambiguous controls: demo/tutorial repos where mock data is clearly scoped and disclosed
- Develop: Continue extending
stem_ai/detector_bio.pyand its fixture set while preserving deterministic evidence contracts. - Verify (Local Lane): Measure precision, recall, false-positive classes, and false-negative classes on commit-pinned fixtures for syntax, parser-guard, silent-mock, and subprocess findings.
- Verify (AI Lane): Add an optional provider-neutral advisory packet for suspicious SMILES batches and compare AI annotations against deterministic flags.
- Calibrate: Only after benchmark evidence and reproducible detector output should any SMILES-derived or subprocess-derived signal affect final scoring.