Flamehaven commited on
Commit
817fe64
·
verified ·
1 Parent(s): a8b52da

release: v1.8.2 ICH M15 citation alignment

Browse files
Files changed (1) hide show
  1. README.md +533 -545
README.md CHANGED
@@ -1,545 +1,533 @@
1
- ---
2
- title: STEM BIO-AI
3
- emoji: "🧬"
4
- colorFrom: blue
5
- colorTo: green
6
- sdk: gradio
7
- sdk_version: "5.29.0"
8
- python_version: "3.11"
9
- app_file: app.py
10
- pinned: false
11
- ---
12
-
13
- # STEM BIO-AI
14
-
15
- <p align="center">
16
- <img src="docs/assets/logo.png" alt="STEM BIO-AI logo" width="390">
17
- </p>
18
-
19
- <p align="center">
20
- <b>Deterministic evidence-surface scanner for bio/medical AI repositories.</b><br>
21
- No LLM. No API key. No model runtime. No secrets sent anywhere.
22
- </p>
23
-
24
- <p align="center">
25
- <a href="https://github.com/flamehaven01/STEM-BIO-AI/actions/workflows/python-package.yml"><img src="https://github.com/flamehaven01/STEM-BIO-AI/actions/workflows/python-package.yml/badge.svg" alt="CI"></a>
26
- <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/stable-v1.8.0-informational.svg" alt="v1.8.0"></a>
27
- <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.9%2B-blue.svg" alt="Python 3.9+"></a>
28
- <a href="https://pypi.org/project/stem-ai/"><img src="https://img.shields.io/pypi/v/stem-ai.svg" alt="PyPI"></a>
29
- <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="Apache 2.0"></a>
30
- <a href="https://huggingface.co/spaces/Flamehaven/stem-bio-ai"><img src="https://img.shields.io/badge/demo-Hugging%20Face%20Space-yellow.svg" alt="HF Space"></a>
31
- <a href="https://doi.org/10.5281/zenodo.20154479"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.20154479.svg" alt="DOI"></a>
32
- </p>
33
-
34
- ---
35
-
36
- **Navigation:**
37
- [Why](#why-stem-bio-ai)
38
- [Quick Start](#quick-start) •
39
- [Verification](#verification-path)
40
- [Architecture](docs/ARCHITECTURE.md) •
41
- [Trust Boundary](#runtime--security--compliance-boundary)
42
- [CLI Reference](docs/CLI_REFERENCE.md) •
43
- [Scoring Rationale](docs/SCORING_RATIONALE.md)
44
-
45
- ---
46
-
47
- ## Why STEM BIO-AI
48
-
49
- Bio and medical AI repositories vary enormously in evidence quality — from rigorous academic tools to marketing-grade demos that carry clinical language with no data provenance, no reproducibility path, and no clinical-use disclaimer. Manual review is slow and inconsistent.
50
-
51
- STEM BIO-AI scans the **observable repository surface** — README, docs, code structure, CI configuration, dependency manifests, changelogs — and maps detected signals to a structured evidence tier (T0–T4). The scan runs in seconds on a local clone, produces machine-readable JSON and PDF reports, and makes every scoring decision traceable to a specific file, line, and pattern.
52
-
53
- > A T4 score means strong observable evidence signals. It does not mean the repository is safe for clinical deployment — that requires independent expert validation.
54
-
55
- ---
56
-
57
- ## Quick Start
58
-
59
- ```bash
60
- git clone https://github.com/flamehaven01/STEM-BIO-AI.git
61
- cd STEM-BIO-AI
62
- pip install stem-ai
63
- ```
64
-
65
- ```bash
66
- # editable local install with PDF output support
67
- pip install -e .[pdf]
68
-
69
- # fastest path: scan a local repository
70
- stem /path/to/bio-ai-repo
71
-
72
- # 7-page full evidence packet with proof trace
73
- stem scan /path/to/bio-ai-repo --level 3 --format all --explain
74
- ```
75
-
76
- ```bash
77
- # workflow-oriented CLI
78
- stem scan /path/to/bio-ai-repo --level 2
79
- stem scan /path/to/bio-ai-repo --policy strict_clinical_adjacency
80
- stem gate /path/to/bio-ai-repo --min-tier T2
81
- stem policy list
82
- stem policy explain strict_clinical_adjacency
83
- stem policy derive --clinical-strictness 4 --code-integrity-priority 3 --reproducibility-priority 2 --structured-limitations-requirement 3
84
- stem policy simulate /path/to/bio-ai-repo --clinical-strictness 4 --code-integrity-priority 3 --reproducibility-priority 2 --structured-limitations-requirement 3
85
- stem policy simulate /path/to/bio-ai-repo --profile-file policy/drafts/scoring_profile.reproducibility_first.v1.json
86
- stem advisory validate /path/to/bio-ai-repo
87
- stem advisory packet /path/to/bio-ai-repo --output advisory_out
88
- stem advisory check-response /path/to/bio-ai-repo --response provider_advisory.json
89
- ```
90
-
91
- ```bash
92
- # backward-compatible shortcuts still work
93
- stem /path/to/bio-ai-repo --level 3 --format all --explain
94
- stem audit /path/to/bio-ai-repo --tier-gate T3 --quiet
95
- ```
96
-
97
- Clone the target repository first; the CLI operates on local paths only.
98
-
99
- Calibration profiles are implemented in `mirror_only` mode in `1.8.0`. `--policy` changes what profile is surfaced in artifacts, while `policy derive` and `policy simulate` provide governed preview lanes without mutating the authoritative deterministic score path. `policy simulate --profile-file <path>` allows local schema-valid profile experiments without registering a new named policy. In the current rule scope, `strict_clinical_adjacency` is the only release-grade named recommendation; stronger reproducibility postures still fall back to `preview_only` simulation deltas rather than a named profile.
100
-
101
- Researchers and domain specialists are expected to influence calibration through `derive`, `simulate`, and documented preview/profile proposals. The intent interview uses a governed `1–5` posture scale, while official score-affecting policy changes still require profile promotion rather than direct ad hoc tuning.
102
-
103
- Full CLI reference: [`docs/CLI_REFERENCE.md`](docs/CLI_REFERENCE.md)
104
-
105
- ## Verification Path
106
-
107
- Use the same verification surface exposed in CI and package smoke tests:
108
-
109
- ```bash
110
- pip install -e ".[pdf]"
111
- python -m py_compile stem_ai/cli.py stem_ai/scanner.py stem_ai/render.py stem_ai/app.py
112
- stem --help
113
- python -m stem_ai --help
114
- python -m pytest -q
115
- python -m build
116
- ```
117
-
118
- Primary references:
119
-
120
- - [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)
121
- - [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
122
- - [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
123
- - [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
124
- - [`SECURITY.md`](SECURITY.md)
125
-
126
- ## Document Map
127
-
128
- Use these docs by review purpose:
129
-
130
- **Core operation**
131
- - [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)
132
- - [`docs/CLI_REFERENCE.md`](docs/CLI_REFERENCE.md)
133
- - [`docs/DETERMINISTIC_DIAGNOSTICS.md`](docs/DETERMINISTIC_DIAGNOSTICS.md)
134
- - [`docs/UI_HTML_REPORT.md`](docs/UI_HTML_REPORT.md)
135
-
136
- **Scoring and evidence**
137
- - [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
138
- - [`docs/EXAMPLE_AUDITS.md`](docs/EXAMPLE_AUDITS.md)
139
- - [`docs/CALIBRATION_PROFILE_DESIGN.md`](docs/CALIBRATION_PROFILE_DESIGN.md)
140
- - [`docs/regulatory_basis_registry.v1.json`](docs/regulatory_basis_registry.v1.json)
141
-
142
- **Trust boundary and governance**
143
- - [`SECURITY.md`](SECURITY.md)
144
- - [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
145
- - [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
146
- - [`docs/ADVISORY_SECRET_HANDLING.md`](docs/ADVISORY_SECRET_HANDLING.md)
147
- - [`docs/REGULATORY_MAPPING.md`](docs/REGULATORY_MAPPING.md)
148
- - [`docs/AIRI_DATA_GOVERNANCE.md`](docs/AIRI_DATA_GOVERNANCE.md)
149
- - [`docs/THIRD_PARTY_DATA.md`](docs/THIRD_PARTY_DATA.md)
150
-
151
- **Public proof surfaces**
152
- - Demo: [Hugging Face Space](https://huggingface.co/spaces/Flamehaven/stem-bio-ai)
153
- - Example audits: [`docs/EXAMPLE_AUDITS.md`](docs/EXAMPLE_AUDITS.md)
154
- - Scoring rationale: [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
155
-
156
-
157
- ---
158
-
159
- ## Triage Tiers
160
-
161
- - **T0 Rejected (0–39):** insufficient evidence — do not rely on without independent expert validation
162
- - **T1 Quarantine (40–54):** exploratory review only — expert validation required before any use
163
- - **T2 Caution (55–69):** research reference and supervised non-clinical technical review only
164
- - **T3 Supervised (70–84):** supervised institutional review candidate
165
- - **T4 Candidate (85–100):** strong evidence posture clinical deployment still requires independent validation
166
-
167
- Clinical-adjacent repositories without an explicit disclaimer are **hard-capped at T2** (score ≤ 69).
168
- Repositories with unbounded CA-DIRECT claims are **hard-capped at T0** (score ≤ 39).
169
-
170
- Tier boundary derivation and calibration gap disclosures: [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md).
171
-
172
- ---
173
-
174
- ## Scoring Model
175
-
176
- ```
177
- Final = (Stage 1 × 0.40) + (Stage 2R × 0.20) + (Stage 3 × 0.40) − C1 Penalty
178
- ```
179
-
180
- | Stage | Weight | What Is Measured |
181
- |-------|-------:|-----------------|
182
- | **Stage 1** README Evidence | 40% | Bio-domain vocabulary; H1–H6 hype-claim penalties; R1–R5 responsibility signals (limitations, regulatory framing, clinical disclaimer, demographic-bias, reproducibility) |
183
- | **Stage 2R** Repo-Local Consistency | 20% | Vocabulary overlap across README, docs, package metadata, CI, and tests; limitation repetition; contradiction, staleness, and unsupported-workflow deductions |
184
- | **Stage 3** Code/Bio Responsibility | 40% | CI presence; domain test coverage; changelog hygiene (T3); data provenance and IRB/dataset citation (B1); bias/limitation measurement evidence (B2); conflict-of-interest disclosure (B3) |
185
- | **Stage 4** Replication Evidence | Separate lane | Containers; reproducibility targets; dependency locks/pins; dataset and model artifact references; seed, CLI, and citation signals; license/use-scope restrictions |
186
- | **C1–C6** Code Integrity | Penalty / advisory | Hardcoded credentials (C1, −10 pts); dependency pinning and external-service fragility (C2); deprecated patient-adjacent paths (C3); fail-open exception handlers (C4); compliance and clinical-boundary integrity (C5); mock-auth or no-auth local/self-host boundary warnings (C6) |
187
-
188
- Stage 4 is reported as `replication_score` / `replication_tier` and does **not** affect `score.final_score`. Full scoring rationale and calibration gap disclosures are in [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md).
189
-
190
- ---
191
-
192
- ## Architecture
193
-
194
- ```mermaid
195
- flowchart LR
196
- A[Target repository] --> B[LOCAL_ANALYSIS scanner]
197
- B --> C[Stage 1\nREADME evidence]
198
- B --> D[Stage 2R\nRepo-local consistency]
199
- B --> E[Stage 3\nCode/bio responsibility]
200
- B --> F[Stage 4\nReplication lane]
201
- B --> K[C1–C6\nCode integrity]
202
- B --> CC[CC1–CC3\nAST contract detectors]
203
- C --> G[Weighted evidence score]
204
- D --> G
205
- E --> G
206
- K --> G
207
- CC --> R[code_contract + AIRI coverage]
208
- F --> H[replication_score / tier]
209
- G --> I[Canonical JSON result]
210
- H --> I
211
- R --> I
212
- I --> L[Evidence ledger]
213
- I --> M[Explain trace]
214
- I --> N[Markdown report]
215
- I --> O[PDF packets 1p / 5p / 7p]
216
- I --> P[Interactive HTML dashboard]
217
- ```
218
-
219
- Core modules: `stem_ai/scanner.py`, `stem_ai/render.py`, `stem_ai/cli.py`, `stem_ai/detectors.py`, `stem_ai/detector_surface.py`, `stem_ai/detector_ast.py`, `stem_ai/detector_bio.py`, `stem_ai/detector_contract.py`, `stem_ai/detector_stage4.py`, `stem_ai/evidence.py`, `stem_ai/airi_risk_mapping.py`, `stem_ai/app.py`
220
-
221
- ---
222
-
223
- ## Output Artifacts
224
-
225
- Each run writes to `--out DIR` (default: `stem_output/`).
226
- The plain `stem <repo>` and `stem scan <repo>` path now defaults to `--level 3`, which emits the full 7-page evidence packet unless you select a lower level explicitly.
227
- `audits/` is retained only for historical benchmark and reference artifacts; routine CLI output should land in `stem_output/<repo_slug>/`.
228
-
229
- | Level | Pages | Audience | Artifacts |
230
- |-------|------:|---------|-----------|
231
- | `--level 1` | 1 | Executive / triage (legacy) | Score, tier, stage cards, code integrity summary |
232
- | `--level 2` | 5 | Standard audit review | Level 1 + Stage 1/2R/3/4 breakdown, AIRI summary, closeout page |
233
- | `--level 3` | 7 | Full evidence packet | Level 2 + Stage 4 replication page, code integrity deep dive, remediation roadmap, metadata page |
234
-
235
- ```
236
- <repo>_experiment_results.json # machine-readable score + full evidence object
237
- <repo>_report.html # interactive 5-section HTML dashboard (v1.7.0+)
238
- <repo>_report.md # human-readable audit report
239
- <repo>_brief_1p.pdf # Level 1 executive dashboard
240
- <repo>_detailed_5p.pdf # Level 2 standard review packet
241
- <repo>_detailed_7p.pdf # Level 3 full review packet
242
- <repo>_explain.txt # --explain: file/line/snippet proof trace
243
- ```
244
-
245
- ---
246
-
247
- ## HTML Report Dashboard
248
-
249
- `--format html` generates a self-contained interactive dashboard (v1.7.0+). Single `.html` file no network, no external dependencies.
250
-
251
- <p align="center">
252
- <img src="docs/assets/html_report_preview.png" alt="STEM BIO-AI interactive HTML dashboard" width="760">
253
- </p>
254
-
255
- **Example interactive HTML audit**
256
- - Open in browser: <https://htmlpreview.github.io/?https://raw.githubusercontent.com/flamehaven01/STEM-BIO-AI/main/docs/assets/report-preview/yorkeccak_bio_report.html>
257
- - Raw HTML artifact: [`docs/assets/report-preview/yorkeccak_bio_report.html`](docs/assets/report-preview/yorkeccak_bio_report.html)
258
-
259
- **5 sections:** Executive Summary · Decision Path · Code Integrity · AIRI Risk Triggers · Evidence Detail
260
-
261
- Interactive features: sticky scroll-spy nav · repo hyperlink in the hero header · `?` tooltip icons on every metric · click-to-expand integrity cards · covered/gaps + domain filtering for AIRI risks · FAIL/WARN/PASS/INFO filter on the evidence ledger.
262
-
263
- Current `1.8.0` HTML semantics:
264
-
265
- - `Decision Path` explains score construction and policy posture with `Configured, Not Rewritten`
266
- - `Code Integrity` surfaces the split between `C4` fail-open exceptions, `C5` compliance/boundary integrity, and `C6` mock-auth/no-auth trust boundaries
267
- - `AIRI Risk Triggers` distinguishes the **full local AIRI registry**, the **curated runtime bundle**, and the **detector mapping registry**
268
- - covered AIRI rows carry bounded `why mapped` reasoning derived from detector-trigger evidence plus the local detector-mapping registry
269
-
270
- This is a review aid, not a claim that AIRI independently verified the repository.
271
-
272
- ---
273
-
274
- ## Report Preview
275
-
276
- <p align="center">
277
- <img src="docs/assets/report-preview/7p-1.png" alt="STEM BIO-AI full 7-page packet — page 1" width="760">
278
- </p>
279
-
280
- **Sample PDF:** [Download the 7-page full packet preview](docs/assets/report-preview/yorkeccak_bio_detailed_7p.pdf)
281
-
282
- <details>
283
- <summary>View all 7 full-packet preview pages</summary>
284
-
285
- | Page 1 | Page 2 |
286
- |--------|--------|
287
- | <img src="docs/assets/report-preview/7p-1.png" alt="Page 1"> | <img src="docs/assets/report-preview/7p-2.png" alt="Page 2"> |
288
-
289
- | Page 3 | Page 4 |
290
- |--------|--------|
291
- | <img src="docs/assets/report-preview/7p-3.png" alt="Page 3"> | <img src="docs/assets/report-preview/7p-4.png" alt="Page 4"> |
292
-
293
- | Page 5 | Page 6 |
294
- |--------|--------|
295
- | <img src="docs/assets/report-preview/7p-5.png" alt="Page 5"> | <img src="docs/assets/report-preview/7p-6.png" alt="Page 6"> |
296
-
297
- | Page 7 |
298
- |--------|
299
- | <img src="docs/assets/report-preview/7p-7.png" alt="Page 7"> |
300
-
301
- </details>
302
-
303
- ---
304
-
305
- ## Detection Methods
306
-
307
- Every scored item maps to a concrete, inspectable detection method. No inference, no LLM judgment.
308
-
309
- <details>
310
- <summary>Full detection table</summary>
311
-
312
- | Component | Detection Method |
313
- |-----------|-----------------|
314
- | Stage 1 baseline | Non-zero README present (+60 base) |
315
- | Stage 1 domain signal | Bio-domain keyword regex in README and package metadata |
316
- | Stage 1 hype penalties (H1–H6) | Regex: clinical certainty, regulatory approval, autonomous replacement, breakthrough marketing, universal generalization, perfect accuracy claims |
317
- | Stage 1 responsibility signals (R1–R5) | Regex: limitations section, regulatory framework, clinical disclaimer (CA-severity-weighted), demographic-bias disclosure, reproducibility provisions |
318
- | Stage 2R consistency | Vocabulary set intersection across README/docs/package/tests; limitation repetition; clinical-boundary contradiction, version-staleness, and workflow-support deductions |
319
- | Stage 3 T1 CI | `.github/workflows/` contains at least one file |
320
- | Stage 3 T2 domain tests | `tests/` directory text contains bio-domain vocabulary (regex) |
321
- | Stage 3 T3 changelog | CHANGELOG file presence + bug-fix/patch/security entry detection (3-tier: 0/+5/+15) |
322
- | Stage 3 B1 data provenance | Dependency manifest presence + IRB/dataset-citation language detection (3-tier: 0/+10/+15) |
323
- | Stage 3 B2 bias measurement | Bias/limitations vocabulary + quantitative measurement evidence (subgroup analysis, AUROC, demographic parity) (3-tier: 0/+8/+15) |
324
- | Stage 3 B3 COI/funding | Funding, grant, sponsor, conflict-of-interest language in README/docs/FUNDING.md |
325
- | Stage 4 containers | Dockerfile or compose file present |
326
- | Stage 4 reproducibility target | Makefile with reproduce/eval/benchmark/test targets |
327
- | Stage 4 dependency lock | Environment/lock/requirements file; exact pins or hash evidence |
328
- | Stage 4 artifact references | Dataset/model/checkpoint URLs or checksum files |
329
- | Stage 4 citation/interface | CITATION.cff; argparse CLI entry points (AST) |
330
- | Stage 4 license restriction | Non-commercial, research-only, academic-only, no-clinical-use restrictions in LICENSE/README |
331
- | CA severity | Clinical/diagnostic phrase regex in README, docs, and package metadata |
332
- | C1 credentials | AWS `AKIA*`, OpenAI `sk-*`, GitHub `ghp_*`, `api_key=...` patterns; obvious placeholders excluded from penalty |
333
- | C2 dependency pinning | `==` or hash pin vs. loose `>=`, `~=`, `<`, `>` ranges |
334
- | C3 deprecated paths | Patient-metadata patterns in `deprecated/`, `legacy/`, `archive/` directories |
335
- | C4 fail-open | `except Exception: pass` or `except: pass` in Python source (AST) |
336
- | C5 compliance boundary integrity | Unsupported legal/compliance claims or missing clinical-boundary integrity in reviewed sources |
337
- | **CC1** clinical zero default | AST scan of function defaults: keyword-only and positional params named `confidence_threshold`, `score_threshold`, `min_confidence`, etc. defaulted to `0.0` |
338
- | **CC2** API contract | README-declared names cross-checked against `__all__` exports; phantom APIs flagged |
339
- | **CC3** shallow validator | `validate_*` / `check_*` functions using only `len()` (no regex structure check) flagged as insufficient for clinical/PII validation |
340
-
341
- Stage 2R and Stage 3 rubric artifacts now surface additive `detector_id` and `decision_basis` fields so reviewers can see which bounded detector or contradiction rule produced a deduction or credit.
342
-
343
- </details>
344
-
345
- ---
346
-
347
- ## AI Advisory Contract
348
-
349
- The advisory system exports a sanitized, provider-neutral handoff packet and validates provider responses — without making any provider API call.
350
-
351
- ```bash
352
- stem advisory validate /path/to/repo # offline contract check
353
- stem advisory packet /path/to/repo # export sanitized input packet
354
- stem advisory check-response /path/to/repo --response FILE
355
- ```
356
-
357
- **Non-negotiable rules (enforced by the validator):**
358
- - Provider output cannot override `score.final_score` or `score.formal_tier`
359
- - Every advisory item must cite exact `finding_id` strings from `allowed_finding_ids`
360
- - Raw repository source text is not included in provider packets
361
- - Responses containing clinical safety, efficacy, regulatory, or medical-advice claims are rejected
362
- - `allowed_finding_ids` is capped at 40 entries per packet
363
-
364
- **Packet hardening added in v1.5.7:**
365
- - `provider_request` now carries a secret-free request schema plus deterministic argument-validation status
366
- - `contract_schemas` exports the advisory input/output contract shapes for downstream validators
367
- - `packet_contract` confirms allowlist parity, snippet omission, and non-negative omission counts before handoff
368
-
369
- **Secret boundary hardening added in v1.5.9:**
370
- - provider-specific environment variables are recognized before the generic advisory key fallback
371
- - provider handoff metadata exports endpoint-policy validation and the expected env-var name, never the key value
372
- - embedded-credential URLs are rejected; cloud providers require `https`; plain `http` is limited to localhost
373
- - `.env` files are ignored by default; `.env.example` documents supported variable names only
374
- - `--advisory call` is now the explicit provider-call boundary, with centralized redaction, logging-policy export, child-env allowlist reporting, and artifact pre-write sanitization
375
-
376
- Full contract: [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
377
- Secret policy: [`docs/ADVISORY_SECRET_HANDLING.md`](docs/ADVISORY_SECRET_HANDLING.md)
378
- Runtime boundary: [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
379
-
380
- ---
381
-
382
- ## The AI Risk Repository (AIRI)
383
-
384
- STEM BIO-AI uses local derived data from the MIT **AI Risk Repository (AIRI)** as a broader risk-vocabulary layer around deterministic repository findings.
385
-
386
- Upstream references:
387
-
388
- - MIT AI Risk Repository: <https://airisk.mit.edu/>
389
- - AI Incident Tracker: <https://airisk.mit.edu/ai-incident-tracker>
390
-
391
- How AIRI is used here:
392
-
393
- - AIRI does **not** replace the local scoring and audit system
394
- - AIRI does **not** prove harm, causality, clinical safety, or regulatory status
395
- - AIRI helps place local findings into a wider risk vocabulary for review
396
-
397
- In the current `1.8.0` line, AIRI is used through three local governed layers:
398
-
399
- 1. full normalized local registry
400
- 2. curated runtime bundle used by deterministic scans
401
- 3. detector-to-risk mapping registry plus known-gap tracking
402
-
403
- This allows STEM BIO-AI to keep scan behavior local and deterministic while still surfacing broader AI risk language, provenance, and bundle-scope boundaries in runtime artifacts.
404
-
405
- License / provenance note:
406
-
407
- - Upstream AIRI source license: `MIT`
408
- - Local attribution and usage details: [`docs/AIRI_DATA_GOVERNANCE.md`](docs/AIRI_DATA_GOVERNANCE.md), [`docs/THIRD_PARTY_DATA.md`](docs/THIRD_PARTY_DATA.md)
409
-
410
- ---
411
-
412
- ## Runtime / Security / Compliance Boundary
413
-
414
- STEM BIO-AI can help teams become more **audit-ready**, but it does not by itself create certification, attestation, or legal compliance.
415
-
416
- What can be prepared internally:
417
-
418
- - runtime and security evidence review
419
- - control-matrix and evidence-room preparation
420
- - validation-package assembly for electronic records / signature workflows
421
- - gap assessment for logging, access control, change control, retention, and traceability
422
- - independent third-party audit readiness and penetration-test readiness
423
-
424
- What still requires external review or attestation:
425
-
426
- - SOC 2 report issuance
427
- - ISO 13485 certification
428
- - strong `21 CFR Part 11 compliant` claims
429
- - `independent audit passed` claims
430
-
431
- In other words: internal teams can do substantial readiness work, but external claims still require external auditors, certification bodies, or independent assessors.
432
-
433
- Related boundary guidance: [`docs/REGULATORY_MAPPING.md`](docs/REGULATORY_MAPPING.md)
434
-
435
- ---
436
-
437
- ## MICA Memory Layer
438
-
439
- The repository keeps a versioned MICA memory layer under `memory/` for agent-session initialization,
440
- drift control, and release provenance. Historical snapshots are retained as archive; the active layer
441
- is selected by `memory/mica.yaml`.
442
-
443
- The active package now follows the non-breaking `MICA v0.2.4` runtime contract:
444
-
445
- - `memory/mica.yaml` is the composition contract
446
- - `python tools/mica_pct.py .` validates package integrity
447
- - `python tools/mica_runtime.py . --format text` emits a portable session summary
448
- - `python tools/mica_runtime.py . --format session-report` emits an opening-state gate packet
449
- - `python tools/mica_invoke.py . --mode guided --format json` compiles a host-consumable activation packet
450
- - `mica_invoke.bat . --mode forced` is the Windows forced-preflight entry point
451
- - DI binding remains progressive rather than speculative
452
- critical invariants are not mass-rewritten just to satisfy schema formality
453
-
454
- Operational reference: [`docs/MICA_MEMORY.md`](docs/MICA_MEMORY.md)
455
-
456
- ---
457
-
458
- ## Web Demo
459
-
460
- Live demo: [huggingface.co/spaces/Flamehaven/stem-bio-ai](https://huggingface.co/spaces/Flamehaven/stem-bio-ai)
461
-
462
- <p align="center">
463
- <img src="docs/assets/HF-STEM-BIO_AI.png" alt="STEM BIO-AI Hugging Face Space" width="760">
464
- </p>
465
-
466
- The Space runs the same deterministic local scanner on public GitHub repositories. No provider API call is made.
467
-
468
- Run locally:
469
-
470
- ```bash
471
- pip install -e .[demo]
472
- python app.py
473
- ```
474
-
475
- ---
476
-
477
- ## Repository Structure
478
-
479
- ```
480
- STEM-BIO-AI/
481
- stem_ai/ # Core Python package
482
- docs/ # API contract, advisory runtime/secret policy, scoring rationale, MICA policy, report previews
483
- memory/ # Versioned MICA archive/playbook/lessons; active layer selected by mica.yaml
484
- audits/ # Historical benchmark/reference artifacts only
485
- stem_output/ # Default live CLI output root (generated, ignored)
486
- scripts/ # Benchmark and validation scripts
487
- tests/ # Regression test suite
488
- app.py # HuggingFace Spaces / Gradio entry point
489
- pyproject.toml # Package metadata and extras
490
- SKILL.md # Universal agent skill definition
491
- CHANGELOG.md # Version history
492
- ```
493
-
494
- ---
495
-
496
- ## Agent Skill Install
497
-
498
- ```bash
499
- # Claude Code
500
- git clone --depth 1 https://github.com/flamehaven01/STEM-BIO-AI.git ~/.claude/skills/stem-bio-ai
501
-
502
- # Generic agent frameworks
503
- git clone --depth 1 https://github.com/flamehaven01/STEM-BIO-AI.git ~/.agents/skills/stem-bio-ai
504
- ```
505
-
506
- ---
507
-
508
- ## Contributing
509
-
510
- See [CONTRIBUTING.md](CONTRIBUTING.md). High-value areas: rubric discrimination examples, clinical-adjacency trigger refinements, additional bio-domain benchmark repositories, report rendering improvements.
511
-
512
- ---
513
-
514
- ## Citation
515
-
516
- Preferred citation metadata lives in [`CITATION.cff`](CITATION.cff).
517
-
518
- Current concept DOI-backed archive for the `1.8.0` line:
519
- - <https://doi.org/10.5281/zenodo.20154479>
520
-
521
- ```bibtex
522
- @software{stem-bio-ai,
523
- author = {Yun, Kwansub},
524
- title = {STEM BIO-AI: Deterministic Evidence-Surface Scanner for Bio/Medical AI Repositories},
525
- version = {1.8.0},
526
- year = {2026},
527
- doi = {10.5281/zenodo.20154479},
528
- url = {https://doi.org/10.5281/zenodo.20154479}
529
- }
530
- ```
531
-
532
- ---
533
-
534
- ## License
535
-
536
- Apache 2.0. See [LICENSE](LICENSE).
537
-
538
- Maintained by [flamehaven01](https://github.com/flamehaven01)
539
-
540
-
541
-
542
-
543
-
544
-
545
-
 
1
+ # STEM BIO-AI
2
+
3
+ <p align="center">
4
+ <img src="docs/assets/logo.png" alt="STEM BIO-AI logo" width="390">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <b>Deterministic evidence-surface scanner for bio/medical AI repositories.</b><br>
9
+ No LLM. No API key. No model runtime. No secrets sent anywhere.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/flamehaven01/STEM-BIO-AI/actions/workflows/python-package.yml"><img src="https://github.com/flamehaven01/STEM-BIO-AI/actions/workflows/python-package.yml/badge.svg" alt="CI"></a>
14
+ <a href="CHANGELOG.md"><img src="https://img.shields.io/badge/stable-v1.8.2-informational.svg" alt="v1.8.2"></a>
15
+ <a href="pyproject.toml"><img src="https://img.shields.io/badge/python-3.9%2B-blue.svg" alt="Python 3.9+"></a>
16
+ <a href="https://pypi.org/project/stem-ai/"><img src="https://img.shields.io/pypi/v/stem-ai.svg" alt="PyPI"></a>
17
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="Apache 2.0"></a>
18
+ <a href="https://huggingface.co/spaces/Flamehaven/stem-bio-ai"><img src="https://img.shields.io/badge/demo-Hugging%20Face%20Space-yellow.svg" alt="HF Space"></a>
19
+ <a href="https://doi.org/10.5281/zenodo.20154479"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.20154479.svg" alt="DOI"></a>
20
+ </p>
21
+
22
+ ---
23
+
24
+ **Navigation:**
25
+ [Why](#why-stem-bio-ai)
26
+ [Quick Start](#quick-start)
27
+ [Verification](#verification-path)
28
+ [Architecture](docs/ARCHITECTURE.md)
29
+ [Trust Boundary](#runtime--security--compliance-boundary)
30
+ [CLI Reference](docs/CLI_REFERENCE.md)
31
+ [Scoring Rationale](docs/SCORING_RATIONALE.md)
32
+
33
+ ---
34
+
35
+ ## Why STEM BIO-AI
36
+
37
+ Bio and medical AI repositories vary enormously in evidence quality — from rigorous academic tools to marketing-grade demos that carry clinical language with no data provenance, no reproducibility path, and no clinical-use disclaimer. Manual review is slow and inconsistent.
38
+
39
+ STEM BIO-AI scans the **observable repository surface** — README, docs, code structure, CI configuration, dependency manifests, changelogs — and maps detected signals to a structured evidence tier (T0–T4). The scan runs in seconds on a local clone, produces machine-readable JSON and PDF reports, and makes every scoring decision traceable to a specific file, line, and pattern.
40
+
41
+ > A T4 score means strong observable evidence signals. It does not mean the repository is safe for clinical deployment — that requires independent expert validation.
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ```bash
48
+ git clone https://github.com/flamehaven01/STEM-BIO-AI.git
49
+ cd STEM-BIO-AI
50
+ pip install stem-ai
51
+ ```
52
+
53
+ ```bash
54
+ # editable local install with PDF output support
55
+ pip install -e .[pdf]
56
+
57
+ # fastest path: scan a local repository
58
+ stem /path/to/bio-ai-repo
59
+
60
+ # 7-page full evidence packet with proof trace
61
+ stem scan /path/to/bio-ai-repo --level 3 --format all --explain
62
+ ```
63
+
64
+ ```bash
65
+ # workflow-oriented CLI
66
+ stem scan /path/to/bio-ai-repo --level 2
67
+ stem scan /path/to/bio-ai-repo --policy strict_clinical_adjacency
68
+ stem gate /path/to/bio-ai-repo --min-tier T2
69
+ stem policy list
70
+ stem policy explain strict_clinical_adjacency
71
+ stem policy derive --clinical-strictness 4 --code-integrity-priority 3 --reproducibility-priority 2 --structured-limitations-requirement 3
72
+ stem policy simulate /path/to/bio-ai-repo --clinical-strictness 4 --code-integrity-priority 3 --reproducibility-priority 2 --structured-limitations-requirement 3
73
+ stem policy simulate /path/to/bio-ai-repo --profile-file policy/drafts/scoring_profile.reproducibility_first.v1.json
74
+ stem advisory validate /path/to/bio-ai-repo
75
+ stem advisory packet /path/to/bio-ai-repo --output advisory_out
76
+ stem advisory check-response /path/to/bio-ai-repo --response provider_advisory.json
77
+ ```
78
+
79
+ ```bash
80
+ # backward-compatible shortcuts still work
81
+ stem /path/to/bio-ai-repo --level 3 --format all --explain
82
+ stem audit /path/to/bio-ai-repo --tier-gate T3 --quiet
83
+ ```
84
+
85
+ Clone the target repository first; the CLI operates on local paths only.
86
+
87
+ Calibration profiles are implemented in `mirror_only` mode in `1.8.0`. `--policy` changes what profile is surfaced in artifacts, while `policy derive` and `policy simulate` provide governed preview lanes without mutating the authoritative deterministic score path. `policy simulate --profile-file <path>` allows local schema-valid profile experiments without registering a new named policy. In the current rule scope, `strict_clinical_adjacency` is the only release-grade named recommendation; stronger reproducibility postures still fall back to `preview_only` simulation deltas rather than a named profile.
88
+
89
+ Researchers and domain specialists are expected to influence calibration through `derive`, `simulate`, and documented preview/profile proposals. The intent interview uses a governed `1–5` posture scale, while official score-affecting policy changes still require profile promotion rather than direct ad hoc tuning.
90
+
91
+ Full CLI reference: [`docs/CLI_REFERENCE.md`](docs/CLI_REFERENCE.md)
92
+
93
+ ## Verification Path
94
+
95
+ Use the same verification surface exposed in CI and package smoke tests:
96
+
97
+ ```bash
98
+ pip install -e ".[pdf]"
99
+ python -m py_compile stem_ai/cli.py stem_ai/scanner.py stem_ai/render.py stem_ai/app.py
100
+ stem --help
101
+ python -m stem_ai --help
102
+ python -m pytest -q
103
+ python -m build
104
+ ```
105
+
106
+ Primary references:
107
+
108
+ - [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)
109
+ - [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
110
+ - [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
111
+ - [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
112
+ - [`SECURITY.md`](SECURITY.md)
113
+
114
+ ## Document Map
115
+
116
+ Use these docs by review purpose:
117
+
118
+ **Core operation**
119
+ - [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md)
120
+ - [`docs/CLI_REFERENCE.md`](docs/CLI_REFERENCE.md)
121
+ - [`docs/DETERMINISTIC_DIAGNOSTICS.md`](docs/DETERMINISTIC_DIAGNOSTICS.md)
122
+ - [`docs/UI_HTML_REPORT.md`](docs/UI_HTML_REPORT.md)
123
+
124
+ **Scoring and evidence**
125
+ - [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
126
+ - [`docs/EXAMPLE_AUDITS.md`](docs/EXAMPLE_AUDITS.md)
127
+ - [`docs/CALIBRATION_PROFILE_DESIGN.md`](docs/CALIBRATION_PROFILE_DESIGN.md)
128
+ - [`docs/regulatory_basis_registry.v1.json`](docs/regulatory_basis_registry.v1.json)
129
+
130
+ **Trust boundary and governance**
131
+ - [`SECURITY.md`](SECURITY.md)
132
+ - [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
133
+ - [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
134
+ - [`docs/ADVISORY_SECRET_HANDLING.md`](docs/ADVISORY_SECRET_HANDLING.md)
135
+ - [`docs/REGULATORY_MAPPING.md`](docs/REGULATORY_MAPPING.md)
136
+ - [`docs/AIRI_DATA_GOVERNANCE.md`](docs/AIRI_DATA_GOVERNANCE.md)
137
+ - [`docs/THIRD_PARTY_DATA.md`](docs/THIRD_PARTY_DATA.md)
138
+
139
+ **Public proof surfaces**
140
+ - Demo: [Hugging Face Space](https://huggingface.co/spaces/Flamehaven/stem-bio-ai)
141
+ - Example audits: [`docs/EXAMPLE_AUDITS.md`](docs/EXAMPLE_AUDITS.md)
142
+ - Scoring rationale: [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md)
143
+
144
+
145
+ ---
146
+
147
+ ## Triage Tiers
148
+
149
+ - **T0 Rejected (0–39):** insufficient evidence — do not rely on without independent expert validation
150
+ - **T1 Quarantine (40–54):** exploratory review only — expert validation required before any use
151
+ - **T2 Caution (55–69):** research reference and supervised non-clinical technical review only
152
+ - **T3 Supervised (70–84):** supervised institutional review candidate
153
+ - **T4 Candidate (85–100):** strong evidence posture — clinical deployment still requires independent validation
154
+
155
+ Clinical-adjacent repositories without an explicit disclaimer are **hard-capped at T2** (score ≤ 69).
156
+ Repositories with unbounded CA-DIRECT claims are **hard-capped at T0** (score ≤ 39).
157
+
158
+ Tier boundary derivation and calibration gap disclosures: [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md).
159
+
160
+ ---
161
+
162
+ ## Scoring Model
163
+
164
+ ```
165
+ Final = (Stage 1 × 0.40) + (Stage 2R × 0.20) + (Stage 3 × 0.40) − C1 Penalty
166
+ ```
167
+
168
+ | Stage | Weight | What Is Measured |
169
+ |-------|-------:|-----------------|
170
+ | **Stage 1** README Evidence | 40% | Bio-domain vocabulary; H1–H6 hype-claim penalties; R1–R5 responsibility signals (limitations, regulatory framing, clinical disclaimer, demographic-bias, reproducibility) |
171
+ | **Stage 2R** Repo-Local Consistency | 20% | Vocabulary overlap across README, docs, package metadata, CI, and tests; limitation repetition; contradiction, staleness, and unsupported-workflow deductions |
172
+ | **Stage 3** Code/Bio Responsibility | 40% | CI presence; domain test coverage; changelog hygiene (T3); data provenance and IRB/dataset citation (B1); bias/limitation measurement evidence (B2); conflict-of-interest disclosure (B3) |
173
+ | **Stage 4** Replication Evidence | Separate lane | Containers; reproducibility targets; dependency locks/pins; dataset and model artifact references; seed, CLI, and citation signals; license/use-scope restrictions |
174
+ | **C1–C6** Code Integrity | Penalty / advisory | Hardcoded credentials (C1, −10 pts); dependency pinning and external-service fragility (C2); deprecated patient-adjacent paths (C3); fail-open exception handlers (C4); compliance and clinical-boundary integrity (C5); mock-auth or no-auth local/self-host boundary warnings (C6) |
175
+
176
+ Stage 4 is reported as `replication_score` / `replication_tier` and does **not** affect `score.final_score`. Full scoring rationale and calibration gap disclosures are in [`docs/SCORING_RATIONALE.md`](docs/SCORING_RATIONALE.md).
177
+
178
+ ---
179
+
180
+ ## Architecture
181
+
182
+ ```mermaid
183
+ flowchart LR
184
+ A[Target repository] --> B[LOCAL_ANALYSIS scanner]
185
+ B --> C[Stage 1\nREADME evidence]
186
+ B --> D[Stage 2R\nRepo-local consistency]
187
+ B --> E[Stage 3\nCode/bio responsibility]
188
+ B --> F[Stage 4\nReplication lane]
189
+ B --> K[C1–C6\nCode integrity]
190
+ B --> CC[CC1–CC3\nAST contract detectors]
191
+ C --> G[Weighted evidence score]
192
+ D --> G
193
+ E --> G
194
+ K --> G
195
+ CC --> R[code_contract + AIRI coverage]
196
+ F --> H[replication_score / tier]
197
+ G --> I[Canonical JSON result]
198
+ H --> I
199
+ R --> I
200
+ I --> L[Evidence ledger]
201
+ I --> M[Explain trace]
202
+ I --> N[Markdown report]
203
+ I --> O[PDF packets 1p / 5p / 7p]
204
+ I --> P[Interactive HTML dashboard]
205
+ ```
206
+
207
+ Core modules: `stem_ai/scanner.py`, `stem_ai/render.py`, `stem_ai/cli.py`, `stem_ai/detectors.py`, `stem_ai/detector_surface.py`, `stem_ai/detector_ast.py`, `stem_ai/detector_bio.py`, `stem_ai/detector_contract.py`, `stem_ai/detector_stage4.py`, `stem_ai/evidence.py`, `stem_ai/airi_risk_mapping.py`, `stem_ai/app.py`
208
+
209
+ ---
210
+
211
+ ## Output Artifacts
212
+
213
+ Each run writes to `--out DIR` (default: `stem_output/`).
214
+ The plain `stem <repo>` and `stem scan <repo>` path now defaults to `--level 3`, which emits the full 7-page evidence packet unless you select a lower level explicitly.
215
+ `audits/` is retained only for historical benchmark and reference artifacts; routine CLI output should land in `stem_output/<repo_slug>/`.
216
+
217
+ | Level | Pages | Audience | Artifacts |
218
+ |-------|------:|---------|-----------|
219
+ | `--level 1` | 1 | Executive / triage (legacy) | Score, tier, stage cards, code integrity summary |
220
+ | `--level 2` | 5 | Standard audit review | Level 1 + Stage 1/2R/3/4 breakdown, AIRI summary, closeout page |
221
+ | `--level 3` | 7 | Full evidence packet | Level 2 + Stage 4 replication page, code integrity deep dive, remediation roadmap, metadata page |
222
+
223
+ ```
224
+ <repo>_experiment_results.json # machine-readable score + full evidence object
225
+ <repo>_report.html # interactive 5-section HTML dashboard (v1.7.0+)
226
+ <repo>_report.md # human-readable audit report
227
+ <repo>_brief_1p.pdf # Level 1 executive dashboard
228
+ <repo>_detailed_5p.pdf # Level 2 standard review packet
229
+ <repo>_detailed_7p.pdf # Level 3 full review packet
230
+ <repo>_explain.txt # --explain: file/line/snippet proof trace
231
+ ```
232
+
233
+ ---
234
+
235
+ ## HTML Report Dashboard
236
+
237
+ `--format html` generates a self-contained interactive dashboard (v1.7.0+). Single `.html` file — no network, no external dependencies.
238
+
239
+ <p align="center">
240
+ <img src="docs/assets/html_report_preview.png" alt="STEM BIO-AI interactive HTML dashboard" width="760">
241
+ </p>
242
+
243
+ **Example interactive HTML audit**
244
+ - Open in browser: <https://htmlpreview.github.io/?https://raw.githubusercontent.com/flamehaven01/STEM-BIO-AI/main/docs/assets/report-preview/yorkeccak_bio_report.html>
245
+ - Raw HTML artifact: [`docs/assets/report-preview/yorkeccak_bio_report.html`](docs/assets/report-preview/yorkeccak_bio_report.html)
246
+
247
+ **5 sections:** Executive Summary · Decision Path · Code Integrity · AIRI Risk Triggers · Evidence Detail
248
+
249
+ Interactive features: sticky scroll-spy nav · repo hyperlink in the hero header · `?` tooltip icons on every metric · click-to-expand integrity cards · covered/gaps + domain filtering for AIRI risks · FAIL/WARN/PASS/INFO filter on the evidence ledger.
250
+
251
+ Current `1.8.0` HTML semantics:
252
+
253
+ - `Decision Path` explains score construction and policy posture with `Configured, Not Rewritten`
254
+ - `Code Integrity` surfaces the split between `C4` fail-open exceptions, `C5` compliance/boundary integrity, and `C6` mock-auth/no-auth trust boundaries
255
+ - `AIRI Risk Triggers` distinguishes the **full local AIRI registry**, the **curated runtime bundle**, and the **detector mapping registry**
256
+ - covered AIRI rows carry bounded `why mapped` reasoning derived from detector-trigger evidence plus the local detector-mapping registry
257
+
258
+ This is a review aid, not a claim that AIRI independently verified the repository.
259
+
260
+ ---
261
+
262
+ ## Report Preview
263
+
264
+ <p align="center">
265
+ <img src="docs/assets/report-preview/7p-1.png" alt="STEM BIO-AI full 7-page packet page 1" width="760">
266
+ </p>
267
+
268
+ **Sample PDF:** [Download the 7-page full packet preview](docs/assets/report-preview/yorkeccak_bio_detailed_7p.pdf)
269
+
270
+ <details>
271
+ <summary>View all 7 full-packet preview pages</summary>
272
+
273
+ | Page 1 | Page 2 |
274
+ |--------|--------|
275
+ | <img src="docs/assets/report-preview/7p-1.png" alt="Page 1"> | <img src="docs/assets/report-preview/7p-2.png" alt="Page 2"> |
276
+
277
+ | Page 3 | Page 4 |
278
+ |--------|--------|
279
+ | <img src="docs/assets/report-preview/7p-3.png" alt="Page 3"> | <img src="docs/assets/report-preview/7p-4.png" alt="Page 4"> |
280
+
281
+ | Page 5 | Page 6 |
282
+ |--------|--------|
283
+ | <img src="docs/assets/report-preview/7p-5.png" alt="Page 5"> | <img src="docs/assets/report-preview/7p-6.png" alt="Page 6"> |
284
+
285
+ | Page 7 |
286
+ |--------|
287
+ | <img src="docs/assets/report-preview/7p-7.png" alt="Page 7"> |
288
+
289
+ </details>
290
+
291
+ ---
292
+
293
+ ## Detection Methods
294
+
295
+ Every scored item maps to a concrete, inspectable detection method. No inference, no LLM judgment.
296
+
297
+ <details>
298
+ <summary>Full detection table</summary>
299
+
300
+ | Component | Detection Method |
301
+ |-----------|-----------------|
302
+ | Stage 1 baseline | Non-zero README present (+60 base) |
303
+ | Stage 1 domain signal | Bio-domain keyword regex in README and package metadata |
304
+ | Stage 1 hype penalties (H1–H6) | Regex: clinical certainty, regulatory approval, autonomous replacement, breakthrough marketing, universal generalization, perfect accuracy claims |
305
+ | Stage 1 responsibility signals (R1–R5) | Regex: limitations section, regulatory framework, clinical disclaimer (CA-severity-weighted), demographic-bias disclosure, reproducibility provisions |
306
+ | Stage 2R consistency | Vocabulary set intersection across README/docs/package/tests; limitation repetition; clinical-boundary contradiction, version-staleness, and workflow-support deductions |
307
+ | Stage 3 T1 CI | `.github/workflows/` contains at least one file |
308
+ | Stage 3 T2 domain tests | `tests/` directory text contains bio-domain vocabulary (regex) |
309
+ | Stage 3 T3 changelog | CHANGELOG file presence + bug-fix/patch/security entry detection (3-tier: 0/+5/+15) |
310
+ | Stage 3 B1 data provenance | Dependency manifest presence + IRB/dataset-citation language detection (3-tier: 0/+10/+15) |
311
+ | Stage 3 B2 bias measurement | Bias/limitations vocabulary + quantitative measurement evidence (subgroup analysis, AUROC, demographic parity) (3-tier: 0/+8/+15) |
312
+ | Stage 3 B3 COI/funding | Funding, grant, sponsor, conflict-of-interest language in README/docs/FUNDING.md |
313
+ | Stage 4 containers | Dockerfile or compose file present |
314
+ | Stage 4 reproducibility target | Makefile with reproduce/eval/benchmark/test targets |
315
+ | Stage 4 dependency lock | Environment/lock/requirements file; exact pins or hash evidence |
316
+ | Stage 4 artifact references | Dataset/model/checkpoint URLs or checksum files |
317
+ | Stage 4 citation/interface | CITATION.cff; argparse CLI entry points (AST) |
318
+ | Stage 4 license restriction | Non-commercial, research-only, academic-only, no-clinical-use restrictions in LICENSE/README |
319
+ | CA severity | Clinical/diagnostic phrase regex in README, docs, and package metadata |
320
+ | C1 credentials | AWS `AKIA*`, OpenAI `sk-*`, GitHub `ghp_*`, `api_key=...` patterns; obvious placeholders excluded from penalty |
321
+ | C2 dependency pinning | `==` or hash pin vs. loose `>=`, `~=`, `<`, `>` ranges |
322
+ | C3 deprecated paths | Patient-metadata patterns in `deprecated/`, `legacy/`, `archive/` directories |
323
+ | C4 fail-open | `except Exception: pass` or `except: pass` in Python source (AST) |
324
+ | C5 compliance boundary integrity | Unsupported legal/compliance claims or missing clinical-boundary integrity in reviewed sources |
325
+ | **CC1** clinical zero default | AST scan of function defaults: keyword-only and positional params named `confidence_threshold`, `score_threshold`, `min_confidence`, etc. defaulted to `0.0` |
326
+ | **CC2** API contract | README-declared names cross-checked against `__all__` exports; phantom APIs flagged |
327
+ | **CC3** shallow validator | `validate_*` / `check_*` functions using only `len()` (no regex structure check) flagged as insufficient for clinical/PII validation |
328
+
329
+ Stage 2R and Stage 3 rubric artifacts now surface additive `detector_id` and `decision_basis` fields so reviewers can see which bounded detector or contradiction rule produced a deduction or credit.
330
+
331
+ </details>
332
+
333
+ ---
334
+
335
+ ## AI Advisory Contract
336
+
337
+ The advisory system exports a sanitized, provider-neutral handoff packet and validates provider responses without making any provider API call.
338
+
339
+ ```bash
340
+ stem advisory validate /path/to/repo # offline contract check
341
+ stem advisory packet /path/to/repo # export sanitized input packet
342
+ stem advisory check-response /path/to/repo --response FILE
343
+ ```
344
+
345
+ **Non-negotiable rules (enforced by the validator):**
346
+ - Provider output cannot override `score.final_score` or `score.formal_tier`
347
+ - Every advisory item must cite exact `finding_id` strings from `allowed_finding_ids`
348
+ - Raw repository source text is not included in provider packets
349
+ - Responses containing clinical safety, efficacy, regulatory, or medical-advice claims are rejected
350
+ - `allowed_finding_ids` is capped at 40 entries per packet
351
+
352
+ **Packet hardening added in v1.5.7:**
353
+ - `provider_request` now carries a secret-free request schema plus deterministic argument-validation status
354
+ - `contract_schemas` exports the advisory input/output contract shapes for downstream validators
355
+ - `packet_contract` confirms allowlist parity, snippet omission, and non-negative omission counts before handoff
356
+
357
+ **Secret boundary hardening added in v1.5.9:**
358
+ - provider-specific environment variables are recognized before the generic advisory key fallback
359
+ - provider handoff metadata exports endpoint-policy validation and the expected env-var name, never the key value
360
+ - embedded-credential URLs are rejected; cloud providers require `https`; plain `http` is limited to localhost
361
+ - `.env` files are ignored by default; `.env.example` documents supported variable names only
362
+ - `--advisory call` is now the explicit provider-call boundary, with centralized redaction, logging-policy export, child-env allowlist reporting, and artifact pre-write sanitization
363
+
364
+ Full contract: [`docs/API_CONTRACT.md`](docs/API_CONTRACT.md)
365
+ Secret policy: [`docs/ADVISORY_SECRET_HANDLING.md`](docs/ADVISORY_SECRET_HANDLING.md)
366
+ Runtime boundary: [`docs/ADVISORY_RUNTIME.md`](docs/ADVISORY_RUNTIME.md)
367
+
368
+ ---
369
+
370
+ ## The AI Risk Repository (AIRI)
371
+
372
+ STEM BIO-AI uses local derived data from the MIT **AI Risk Repository (AIRI)** as a broader risk-vocabulary layer around deterministic repository findings.
373
+
374
+ Upstream references:
375
+
376
+ - MIT AI Risk Repository: <https://airisk.mit.edu/>
377
+ - AI Incident Tracker: <https://airisk.mit.edu/ai-incident-tracker>
378
+
379
+ How AIRI is used here:
380
+
381
+ - AIRI does **not** replace the local scoring and audit system
382
+ - AIRI does **not** prove harm, causality, clinical safety, or regulatory status
383
+ - AIRI helps place local findings into a wider risk vocabulary for review
384
+
385
+ In the current `1.8.0` line, AIRI is used through three local governed layers:
386
+
387
+ 1. full normalized local registry
388
+ 2. curated runtime bundle used by deterministic scans
389
+ 3. detector-to-risk mapping registry plus known-gap tracking
390
+
391
+ This allows STEM BIO-AI to keep scan behavior local and deterministic while still surfacing broader AI risk language, provenance, and bundle-scope boundaries in runtime artifacts.
392
+
393
+ License / provenance note:
394
+
395
+ - Upstream AIRI source license: `MIT`
396
+ - Local attribution and usage details: [`docs/AIRI_DATA_GOVERNANCE.md`](docs/AIRI_DATA_GOVERNANCE.md), [`docs/THIRD_PARTY_DATA.md`](docs/THIRD_PARTY_DATA.md)
397
+
398
+ ---
399
+
400
+ ## Runtime / Security / Compliance Boundary
401
+
402
+ STEM BIO-AI can help teams become more **audit-ready**, but it does not by itself create certification, attestation, or legal compliance.
403
+
404
+ What can be prepared internally:
405
+
406
+ - runtime and security evidence review
407
+ - control-matrix and evidence-room preparation
408
+ - validation-package assembly for electronic records / signature workflows
409
+ - gap assessment for logging, access control, change control, retention, and traceability
410
+ - independent third-party audit readiness and penetration-test readiness
411
+
412
+ What still requires external review or attestation:
413
+
414
+ - SOC 2 report issuance
415
+ - ISO 13485 certification
416
+ - strong `21 CFR Part 11 compliant` claims
417
+ - `independent audit passed` claims
418
+
419
+ In other words: internal teams can do substantial readiness work, but external claims still require external auditors, certification bodies, or independent assessors.
420
+
421
+ Related boundary guidance: [`docs/REGULATORY_MAPPING.md`](docs/REGULATORY_MAPPING.md)
422
+
423
+ ---
424
+
425
+ ## MICA Memory Layer
426
+
427
+ The repository keeps a versioned MICA memory layer under `memory/` for agent-session initialization,
428
+ drift control, and release provenance. Historical snapshots are retained as archive; the active layer
429
+ is selected by `memory/mica.yaml`.
430
+
431
+ The active package now follows the non-breaking `MICA v0.2.4` runtime contract:
432
+
433
+ - `memory/mica.yaml` is the composition contract
434
+ - `python tools/mica_pct.py .` validates package integrity
435
+ - `python tools/mica_runtime.py . --format text` emits a portable session summary
436
+ - `python tools/mica_runtime.py . --format session-report` emits an opening-state gate packet
437
+ - `python tools/mica_invoke.py . --mode guided --format json` compiles a host-consumable activation packet
438
+ - `mica_invoke.bat . --mode forced` is the Windows forced-preflight entry point
439
+ - DI binding remains progressive rather than speculative
440
+ critical invariants are not mass-rewritten just to satisfy schema formality
441
+
442
+ Operational reference: [`docs/MICA_MEMORY.md`](docs/MICA_MEMORY.md)
443
+
444
+ ---
445
+
446
+ ## Web Demo
447
+
448
+ Live demo: [huggingface.co/spaces/Flamehaven/stem-bio-ai](https://huggingface.co/spaces/Flamehaven/stem-bio-ai)
449
+
450
+ <p align="center">
451
+ <img src="docs/assets/HF-STEM-BIO_AI.png" alt="STEM BIO-AI Hugging Face Space" width="760">
452
+ </p>
453
+
454
+ The Space runs the same deterministic local scanner on public GitHub repositories. No provider API call is made.
455
+
456
+ Run locally:
457
+
458
+ ```bash
459
+ pip install -e .[demo]
460
+ python app.py
461
+ ```
462
+
463
+ ---
464
+
465
+ ## Repository Structure
466
+
467
+ ```
468
+ STEM-BIO-AI/
469
+ stem_ai/ # Core Python package
470
+ docs/ # API contract, advisory runtime/secret policy, scoring rationale, MICA policy, report previews
471
+ memory/ # Versioned MICA archive/playbook/lessons; active layer selected by mica.yaml
472
+ audits/ # Historical benchmark/reference artifacts only
473
+ stem_output/ # Default live CLI output root (generated, ignored)
474
+ scripts/ # Benchmark and validation scripts
475
+ tests/ # Regression test suite
476
+ app.py # HuggingFace Spaces / Gradio entry point
477
+ pyproject.toml # Package metadata and extras
478
+ SKILL.md # Universal agent skill definition
479
+ CHANGELOG.md # Version history
480
+ ```
481
+
482
+ ---
483
+
484
+ ## Agent Skill Install
485
+
486
+ ```bash
487
+ # Claude Code
488
+ git clone --depth 1 https://github.com/flamehaven01/STEM-BIO-AI.git ~/.claude/skills/stem-bio-ai
489
+
490
+ # Generic agent frameworks
491
+ git clone --depth 1 https://github.com/flamehaven01/STEM-BIO-AI.git ~/.agents/skills/stem-bio-ai
492
+ ```
493
+
494
+ ---
495
+
496
+ ## Contributing
497
+
498
+ See [CONTRIBUTING.md](CONTRIBUTING.md). High-value areas: rubric discrimination examples, clinical-adjacency trigger refinements, additional bio-domain benchmark repositories, report rendering improvements.
499
+
500
+ ---
501
+
502
+ ## Citation
503
+
504
+ Preferred citation metadata lives in [`CITATION.cff`](CITATION.cff).
505
+
506
+ Current concept DOI-backed archive for the `1.8.0` line:
507
+ - <https://doi.org/10.5281/zenodo.20154479>
508
+
509
+ ```bibtex
510
+ @software{stem-bio-ai,
511
+ author = {Yun, Kwansub},
512
+ title = {STEM BIO-AI: Deterministic Evidence-Surface Scanner for Bio/Medical AI Repositories},
513
+ version = {1.8.0},
514
+ year = {2026},
515
+ doi = {10.5281/zenodo.20154479},
516
+ url = {https://doi.org/10.5281/zenodo.20154479}
517
+ }
518
+ ```
519
+
520
+ ---
521
+
522
+ ## License
523
+
524
+ Apache 2.0. See [LICENSE](LICENSE).
525
+
526
+ Maintained by [flamehaven01](https://github.com/flamehaven01)
527
+
528
+
529
+
530
+
531
+
532
+
533
+