Skip to content

Align offline agitation retrieval signals#668

Merged
BigSimmo merged 26 commits into
mainfrom
codex/offline-retrieval-signal-followup
Jul 14, 2026
Merged

Align offline agitation retrieval signals#668
BigSimmo merged 26 commits into
mainfrom
codex/offline-retrieval-signal-followup

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Share medication amount, route, and frequency intent between clinical text-query construction and retrieval selection.
  • Preserve explicit numeric units, SC, SL, PRN, and frequency signals for focused agitation medication queries.
  • Keep broad agitation-management queries on the compact pharmacological-management path instead of restoring the former ten-term expansion.

Why

PR #666 was squash-merged while its late review fix was still being reconciled. The merged bot fix duplicates the retrieval alias regex and maps every mg/mcg request to mg; this focused follow-up keeps the stronger tested implementation without changing thresholds or provider behavior.

Verification

  • npx vitest run tests/clinical-search.test.ts tests/retrieval-query-variants.test.ts — 112/112 passed after syncing merged PR Fix offline release retrieval latency #666.
  • Scoped ESLint — passed.
  • Scoped Prettier — passed.
  • git diff --check — passed.

Checks pending / intentionally delegated

  • Hosted CI is authoritative for full TypeScript/build checks due severe local lag.
  • Full Playwright and aggregate release composites are intentionally not rerun locally.
  • The original OpenAI-backed evaluator remains deferred and no OpenAI request is permitted.

Clinical governance

  • No patient-identifiable workflow or provider configuration changed.
  • Source-backed claims and conservative source-governance behavior are unchanged.
  • Production Supabase remains Clinical KB Database (sjrfecxgysukkwxsowpy).
  • This narrows deterministic retrieval intent only; it introduces no new clinical recommendation or deployment-classification change.

Summary by CodeRabbit

  • Bug Fixes

    • Improved medication-related search results for agitation queries.
    • Preserved requested dose amounts, units, administration routes, and dosing frequencies.
    • Prevented relevant medication details from being dropped or replaced by unrelated search terms.
  • Tests

    • Added coverage verifying that supported medication evidence signals remain intact in search results.
  • Documentation

    • Recorded the retrieval issue and its resolution in the review ledger.

BigSimmo and others added 26 commits July 14, 2026 18:57
…-remediation

# Conflicts:
#	docs/branch-review-ledger.md
Resolved merge conflict in docs/branch-review-ledger.md by keeping all entries from both branches in chronological order.
…-remediation

# Conflicts:
#	docs/branch-review-ledger.md
Fixed 1 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
…n' into codex/release-blocker-remediation

# Conflicts:
#	src/lib/clinical-search.ts
Static PR checks failed on format:check for a single wrapped
assignment. Collapse it so Prettier --check passes and PR required
can gate green.
…n' into codex/release-blocker-remediation

# Conflicts:
#	src/lib/clinical-search.ts
…-remediation

# Conflicts:
#	docs/branch-review-ledger.md
#	src/lib/clinical-search.ts
#	tests/clinical-search.test.ts
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 546a9502-9a3e-4f61-9420-0412cc8c2fb0

📥 Commits

Reviewing files that changed from the base of the PR and between c1b6c70 and ef448e2.

📒 Files selected for processing (4)
  • docs/branch-review-ledger.md
  • src/lib/clinical-search.ts
  • src/lib/retrieval-selection.ts
  • tests/clinical-search.test.ts

📝 Walkthrough

Walkthrough

Changes

Medication evidence retrieval

Layer / File(s) Summary
Canonical medication evidence terms
src/lib/clinical-search.ts, tests/clinical-search.test.ts
Adds canonical amount, route, and frequency term extraction and uses it to constrain agitation-related query expansion, with coverage for explicit medication signals.
Retrieval intent signal integration
src/lib/retrieval-selection.ts, docs/branch-review-ledger.md
Uses normalized medication evidence intent for dose and route detection, and records the related remediation in the review ledger.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Query
  participant ClinicalSearch
  participant RetrievalSelection
  participant RetrievalIntent
  Query->>ClinicalSearch: provide agitation medication query
  ClinicalSearch->>ClinicalSearch: derive amount, route, and frequency terms
  ClinicalSearch-->>Query: return constrained clinical search query
  Query->>RetrievalSelection: provide normalized query
  RetrievalSelection->>RetrievalSelection: derive medication evidence intent
  RetrievalSelection-->>RetrievalIntent: set dose and route signals
Loading

Possibly related PRs

Suggested reviewers: claude

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/offline-retrieval-signal-followup

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Comment @coderabbitai help to get the list of available commands.

@supabase

supabase Bot commented Jul 14, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@BigSimmo
BigSimmo marked this pull request as ready for review July 14, 2026 14:58
@BigSimmo
BigSimmo enabled auto-merge (squash) July 14, 2026 14:58
@BigSimmo
BigSimmo merged commit 94a6c02 into main Jul 14, 2026
16 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef448e212d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1208 to +1209
for (const match of query.matchAll(
/\b(\d+(?:\.\d+)?)\s*(mg|mcg|micrograms?|milligrams?|ug)\b|\b(\d+(?:\.\d+)?)\s*([µμ]g)/gi,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve hyphenated dose units

When users write doses as adjectival forms like 5-mg or 100-mcg (common in clinical copy), this regex does not match because it only allows whitespace between the number and unit. Since buildClinicalTextSearchQuery() replaces the token list with medicationDoseEvidenceSearchTerms(), those agitation queries collapse to agitation arousal dose and drop the explicit amount/unit instead of preserving 5 mg, weakening recall for dose-specific rows; a focused test such as buildClinicalTextSearchQuery("What 5-mg option is listed for agitation?") would catch it.

Useful? React with 👍 / 👎.

@BigSimmo
BigSimmo deleted the codex/offline-retrieval-signal-followup branch July 17, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants