Integrations and safe changes
| Term | Meaning |
|---|---|
| Study route | The stateless route POST /v1/study/rheumaai-reply. |
| Study pin | A study context that forces all model calls to one provider and one model. |
| Allowlist | The list of tools that the study route can use (RHEUMAI_STUDY_TOOL_ALLOWLIST). |
| Paid ceiling | The maximum number of paid tool calls in the study route (RHEUMAI_STUDY_MAX_PAID_CALLS). |
| Smoke test | A short run against a live service that checks the main path. |
| Turn | One request and its response. |
| Clinician allowlist | The list of clinicians with access. The monorepo API controls it. |
Main integrations
Section titled “Main integrations”| Integration | Use | Expected failure behavior |
|---|---|---|
| Supabase | Users, conversations, messages, state and search | Persistent chat can fail or degrade. |
| S3-compatible storage | Conversation files | RheumAI can parse the text and skip the persistent upload. |
| LLM providers | Planning, tools, response and evaluation | Outside pinned study requests, resilientChatCompletion can use a fallback. |
| PubMed | Biomedical evidence and verified PMIDs | The output must state that no PMID is verified. |
| Semantic Scholar / OpenScholar | Additional literature | The tool logs the failure. The pipeline can continue. |
| Local knowledge / graph | Specialized retrieval | The pipeline can use a different retrieval method or a direct response. |
| BiobadamexAI study harness | Calls the study route with a de-identified note | The route returns 401 without a valid bearer token. It returns 503 if the key is not set. |
| Privy | Clinician session in the chat | requireAuth returns 401 without a valid token. |
| Monorepo API | Clinician allowlist (GET /api/users/me) and legal acceptance (GET /api/legal/acceptance) |
The chat returns 403 without access or without legal acceptance. It returns 503 if the API does not respond. |
Variables that set behavior
Section titled “Variables that set behavior”This list gives the names of the configuration variables. It never gives their values.
- Server:
PORT,HOST,CORS_ORIGINS. - Access:
PRIVY_APP_ID,PRIVY_APP_SECRET,MONOREPO_API_URL. - Study:
RHEUMAI_STUDY_API_KEY,CORS_STUDY_ORIGINS,RHEUMAI_STUDY_TOOL_ALLOWLIST,RHEUMAI_STUDY_MAX_PAID_CALLS. - Models:
REPLY_LLM_PROVIDER,REPLY_LLM_MODEL,HYP_LLM_PROVIDER,HYP_LLM_MODEL,STRUCTURED_LLM_MODEL. - ORVS:
ORVS_ENABLED,ORVS_VERSION. - Storage and database: provider-specific variables. Do not copy their values into docs.
Invariants
Section titled “Invariants”Do not break these rules:
- The study route stays stateless. It stays closed if its key is missing.
- Note bodies never go into logs or error responses.
- A study pin forces one provider and one model. It disables the fallback to a different model.
- By default, the allowlist excludes the tools that cost money. The default paid ceiling is zero.
- Each published PMID comes from the set that RheumAI retrieved in the current turn.
- Normal clinical chat ends in
REPLY, unless an explicit protocol flow or research flow applies. - A RheumAI failure never authorizes a registry submission.
- Only a clinician authorizes final clinical data.
- The chat never allows access if it cannot verify the clinician allowlist or the legal acceptance.
Change and test map
Section titled “Change and test map”The paths in this table are relative to apps/bioagent/.
| Change | Review | Minimum checks |
|---|---|---|
| Route mounting or CORS | src/index.ts and the Elysia plugins |
bun run build, an API smoke test that changes no data |
| Access layer | src/middleware/requireAuth.ts, requireAllowlist.ts, requireLegalAcceptance.ts |
bun test src/middleware/requireAllowlist.test.ts src/middleware/requireLegalAcceptance.test.ts |
| Chat order or fallbacks | src/routes/chat.ts, src/services/chat/* |
Tool tests and a synthetic smoke test |
| Study route | src/study/* |
bun test src/study/rheumaai-reply-route.test.ts src/study/tool-cap.test.ts |
| Providers or models | src/llm/* |
bun test src/llm/resilient.test.ts and the pin tests |
| ORVS or citations | src/tools/verification/* and the PMID gate |
Unit tests, with an allowed PMID case and a fabricated PMID case |
| Files or labs | src/tools/file-upload/*, src/tools/lab-interpretation/* |
Lab tests with synthetic fixtures |
| Dynamic tools | src/tools/index.ts |
Start the registry and examine the loaded and failed tools |
| Client | client/src/* |
bun run check, bun run build |
Recommended local verification
Section titled “Recommended local verification”Run pnpm install --frozen-lockfile at the root of the monorepo. Then run these commands in apps/bioagent/:
bun run checkbun run buildbun test src/study/rheumaai-reply-route.test.ts \ src/study/tool-cap.test.ts \ src/tools/lab-interpretation/lab-interpretation.test.ts \ src/tools/knowledgeGraph/knowledgeGraph.test.tsAt the documented commit, this focused set passes 26 tests with 0 failures. At startup, the tool registry can show warnings for tools without configuration or without index.ts (for example, aegis-pharmacovigilance). The focused tests are not a complete check of server health.
Smoke tests that call external services need a valid configuration. For routine changes, do not run them against production or with real notes.
Code states
Section titled “Code states”- Active:
src/index.ts, chat or a loaded tool imports the code, and observed tests support it. - Configurable: active only when a variable or a provider is present.
- Experimental: comparison modes, benchmarks and scripts that are not the default.
- Placeholder or broken: a registered folder without an
index.ts, an import that fails, or an integration that needs missing credentials. - Legacy: kept for compatibility, but not preferred.
Do not document a folder as working only because it exists. Confirm its import, its configuration and its tests.
Automated coverage does not include these areas: main chat, deep research, requireAuth, community and Telegram. The client tests cover only some modules in client/src/. For changes in these areas, do synthetic smoke tests in addition to the current tests.