Skip to content

fix(rag): harden GPT-5.6 answer generation#626

Merged
BigSimmo merged 18 commits into
mainfrom
codex/openai-gpt56-rag-upgrade
Jul 14, 2026
Merged

fix(rag): harden GPT-5.6 answer generation#626
BigSimmo merged 18 commits into
mainfrom
codex/openai-gpt56-rag-upgrade

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • Upgrade the centralized OpenAI Responses integration to capability-aware GPT-5.6 workload routing, GPT-5.6-and-later prompt-cache TTL handling, safety identifiers, usage telemetry, and stable provider error codes.
  • Prevent unvalidated clinical prose from reaching the UI, make streamed failure recovery state-aware, fingerprint answer caches, share answer request/SSE contracts, and validate table-fact route UUIDs.
  • Harden claim, numeric, citation, maximum-dose, and source-governance gates; recover rejected generations through deterministic source-safe comparison, extractive, or cited review responses.
  • Resolve all scoped review findings, including empty max-token retry handling, equivalent maximum-dose wording, long-form clinical dose units, privacy-safe eval output, structural Structured Outputs schemas, future GPT cache capability handling, and shared fallback routing tokens.
  • Integrate current main's response-bound feedback tokens and cold-RAG/cache improvements while preserving the final-only typed SSE contract.
  • Update tests, evaluation fixtures, environment guidance, privacy/governance notes, and rollout documentation.

Verification

  • Final local gates on 7e4b535fc53fe61ace561facdb8c7a224c18d86f
    • npm run verify:cheap: runtime/policy/lint/typecheck passed; 239 test files passed, 1 skipped; 2,248 tests passed, 1 skipped.
    • npm run eval:rag:offline: 36 fixture-schema cases and 279/279 tests passed.
    • Focused final OpenAI/RAG/cache/privacy/main-integration tests: 163/163 passed.
    • Focused pre-integration review regressions: 99/99 passed.
    • Preceding integrated head's production build generated 636 static pages and passed the client-bundle secret scan; final-head hosted Build passed.
  • Browser/UI validation
    • Earlier local npm run verify:ui: 158/158 Chromium checks passed.
    • Final-head hosted Critical UI smoke passed in 1m52s and UI regression passed in 10m05s.
  • Hosted CI on 7e4b535f
    • Build, unit coverage, static checks, migration replay, critical UI, full UI regression, advisory UI, Semgrep, Gitleaks, GitGuardian, and aggregate PR required passed.
    • Supabase Preview and release-browser-matrix were skipped by workflow scope.
  • npm run verify:release
    • Not run locally; the hosted release browser matrix was also scope-skipped.
  • Live retrieval quality completed post-merge on current main
    • Ran all 36 golden retrieval cases against 9f4dc13044f3403c9a977a18cecb0c537ca9fd08.
    • 36/36 passed; document recall@5, content recall@5, top-k hit rate, and required-signal coverage were all 1.00.
    • All 10 forced-embedding cases passed; provider/embedding failures, failed cases, and latency-failed cases were all zero.
    • Median latency was 7,086 ms and p90 was 27,390 ms.
  • Approved live answer/provider checks completed before the quota exhaustion
    • Live 15-case RAG: 15/15 grounded and source-hit, with 0 unsupported.
    • Answer-quality safety/grounding checks passed; p95 latency was 10,991 ms.
    • GPT-5.6 canaries and live drift checks passed; the agitation trace improved from 44.4s to 2.42s.
  • npm run check:production-readiness
    • READY: 5 pass, 3 warnings. Warnings are the intentionally absent worktree-local env file and missing OPENAI_SAFETY_IDENTIFIER_SECRET.
  • npm run check:deployment-readiness
    • Not rerun for this non-deployment change; no deployment was performed.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use.
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy).
  • Service-role keys and private document access remain server-only.
  • Demo/synthetic content remains clearly separated from real clinical sources.
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative.
  • Deployment classification/TGA SaMD impact was checked for the clinical decision-support changes.

Notes

  • PR fix(rag): harden GPT-5.6 answer generation #626 was squash-merged as 85137cde853550b59dd67dea7e0d12bb412e6692 on 2026-07-14 before the final provider gate was rerun.
  • The outstanding provider gate subsequently passed 36/36 on current-main commit 9f4dc1304; later main commits through 281d3e0cd changed only documentation, Therapy Compass mockups, and document-viewer code, not the validated OpenAI/RAG path.
  • No follow-up code change, commit, or push was required by the completed evaluation.
  • OPENAI_SAFETY_IDENTIFIER_SECRET remains an operational/privacy follow-up; authenticated Responses requests omit that optional pseudonymous identifier until it is configured.
  • No deployment or production-data mutation occurred.

Summary by CodeRabbit

  • New Features

    • Updated OpenAI configuration to GPT-5.6 models, with expanded workload model selection and optional safety identifiers.
    • Improved prompt-cache behavior (GPT-5.6 TTL-based) and added richer caching/usage telemetry.
  • Bug Fixes

    • Hardened answer streaming to use a safer progress/final/error event contract and removed provisional draft/revising UI output.
    • Strengthened request and document route validation (including UUID checks) and improved handling for incomplete/uncited responses.
  • User Experience

    • Streams now remain stable and user-safe through fallback transitions.
  • Documentation

    • Added and updated OpenAI RAG, capacity, and privacy documentation to match the new model and caching behavior.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR upgrades OpenAI routing to GPT-5.6, adds structured Responses API parsing, safety identifiers, cache fingerprinting, and stricter error handling. It replaces provisional answer streaming with validated final-only SSE, strengthens RAG fallbacks and quality gates, centralizes request validation, and updates tests and operational documentation.

Changes

OpenAI runtime and workload routing

Layer / File(s) Summary
OpenAI request and model configuration
.env.example, src/lib/env.ts, src/lib/openai.ts, src/lib/types.ts
GPT-5.6 workload defaults, prompt-cache TTLs, parsed responses, HMAC safety identifiers, cache-write telemetry, and stable provider error codes are added.
RAG model routing and cache identity
src/lib/document-enrichment.ts, src/lib/model-index-extraction.ts, src/lib/rag-cache.ts, src/lib/rag-versioning.ts
Dedicated indexing and summary models, versioned prompts, and generation fingerprints are wired into RAG processing and cache keys.

Validated final-only answer streaming

Layer / File(s) Summary
Shared request and stream contracts
src/lib/validation/answer-request.ts, src/lib/answer-stream-contract.ts, src/app/api/answer/...
Request validation and SSE event types are centralized; token and revising events are excluded.
Dashboard final-answer rendering
src/components/ClinicalDashboard.tsx, src/lib/sse-heartbeat.ts
Event names are validated, progress and heartbeat activity remain supported, and provisional prose rendering is removed.
Route validation and verification
src/app/api/documents/[id]/table-facts/route.ts, tests/*
UUID route parameters and final-only SSE behavior are covered by tests.

RAG classification, fallback, and quality gates

Layer / File(s) Summary
Classifier and generation flow
src/lib/rag.ts, src/lib/rag-routing.ts
Strict parsed classifier output, versioned memoization, owner safety identifiers, source-safe fallbacks, and post-generation review gates are added.
Extractive and claim quality rules
src/lib/rag-extractive-answer.ts, src/lib/rag-answer-text.ts, src/lib/rag-claim-support.ts
Dose evidence, medication matching, malformed-answer detection, claim boundaries, and citation coverage are tightened.
RAG fixtures and tests
src/lib/rag-eval-cases.ts, src/lib/eval-document-matching.ts, tests/rag-*
Fixtures, aliases, structured classifier mocks, fallback recovery, quality checks, fingerprints, and offline-answer expectations are updated.

Operational configuration and validation support

Layer / File(s) Summary
Deployment, privacy, and rollout documentation
docs/openai-*, docs/privacy-impact-assessment.md, docs/worker-deploy-runbook.md, docs/capacity-review.md
GPT-5.6 routing, prompt-cache TTL behavior, safety identifiers, privacy wording, rollout checks, limits, and worker defaults are documented.
Diagnostics and evaluation output
scripts/check-client-bundle-secrets.mjs, scripts/production-readiness.ts, scripts/eval-answer-quality.ts
Secret scanning, readiness diagnostics, and per-case evaluation output are updated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.06% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately describes the main GPT-5.6 RAG answer-generation hardening changes.
Description check ✅ Passed The description matches the template with Summary, Verification, Clinical Governance Preflight, and Notes, and it includes detailed status for key checks.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/openai-gpt56-rag-upgrade

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

@supabase

supabase Bot commented Jul 13, 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 ↗︎.

@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: 0136ba348b

ℹ️ 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 thread src/lib/openai.ts
BigSimmo added 2 commits July 14, 2026 03:32
# Conflicts:
#	docs/branch-review-ledger.md
#	src/app/api/answer/stream/route.ts
#	src/components/ClinicalDashboard.tsx
#	src/lib/clinical-search.ts
#	src/lib/rag.ts
#	tests/clinical-search.test.ts

@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: f83d7d49b3

ℹ️ 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 thread src/lib/rag-extractive-answer.ts Outdated
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: f83d7d49b3

ℹ️ 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".

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
tests/answer-stream-contract.test.ts (1)

15-22: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Guardrail test is coupled to exact source text, not behavior.

Asserting on raw substrings (StreamingAnswerPreview, event === "token", etc.) protects against literal reintroduction of those tokens, but a harmless rename or restructuring (e.g. switch statement instead of ===) would silently defeat the guard while the underlying regression it protects against could still resurface under different code. Consider a behavior-level test (render the dashboard, feed a token/revising SSE event, assert no provisional text appears) for a more durable guarantee.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/answer-stream-contract.test.ts` around lines 15 - 22, Replace the raw
source-string assertions in the “has no provisional answer rendering path in the
dashboard” test with a behavior-level test that renders ClinicalDashboard, feeds
token and revising SSE events, and verifies no provisional answer text is
displayed. Keep the test focused on preventing provisional rendering rather than
specific implementation names or event-handling syntax.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/eval-answer-quality.ts`:
- Line 126: Remove the owner-scoped answer preview from the JSON object
assembled in the evaluation output so --json omits answer content by default. If
debugging access is required, expose it only through a separate explicit opt-in
path with redaction, without retaining private corpus-derived text in standard
logs or artifacts.

In `@src/lib/rag-answer-text.ts`:
- Around line 293-306: Broaden the unit allowlist in bareDoseFigurePattern to
exempt valid dose phrases using common units such as tablets and mmol, while
preserving the existing numeric and boundary matching behavior. Update only this
pattern so complete phrases like “maximum dose is 2 tablets” and “dose is 10
mmol” are not classified as artifacts.

In `@src/lib/rag-claim-support.ts`:
- Around line 397-401: Centralize the source_backed_review_fallback routing
token used by the claim-support gate and its producers. Define or reuse a shared
constant/helper alongside the existing routing-reason definitions in rag.ts,
then update sourceBackedReviewAnswer in the claim-support flow and all fallback
producers to reference it instead of duplicating the literal token.

In `@src/lib/rag.ts`:
- Around line 1223-1237: Update queryClassifierParseSchema to remove the
max-length, max-item, minimum, and maximum constraints from confidence, reasons,
and expandedTerms so Structured Outputs accepts the schema. Preserve their basic
types, then validate the corresponding bounds after parsing in the classifier
flow.

---

Nitpick comments:
In `@tests/answer-stream-contract.test.ts`:
- Around line 15-22: Replace the raw source-string assertions in the “has no
provisional answer rendering path in the dashboard” test with a behavior-level
test that renders ClinicalDashboard, feeds token and revising SSE events, and
verifies no provisional answer text is displayed. Keep the test focused on
preventing provisional rendering rather than specific implementation names or
event-handling syntax.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 08dbbc5e-eaee-4da1-a94d-1468ed962977

📥 Commits

Reviewing files that changed from the base of the PR and between cef08ee and f83d7d4.

📒 Files selected for processing (55)
  • .env.example
  • docs/branch-review-ledger.md
  • docs/capacity-review.md
  • docs/codex-prompt-playbook.md
  • docs/openai-cross-border-basis.md
  • docs/openai-rag-operations.md
  • docs/privacy-impact-assessment.md
  • docs/search-rag-master-context.md
  • docs/worker-deploy-runbook.md
  • scripts/check-client-bundle-secrets.mjs
  • scripts/eval-answer-quality.ts
  • scripts/production-readiness.ts
  • src/app/api/answer/route.ts
  • src/app/api/answer/stream/route.ts
  • src/app/api/documents/[id]/table-facts/route.ts
  • src/components/ClinicalDashboard.tsx
  • src/lib/answer-stream-contract.ts
  • src/lib/answer-stream-extractor.ts
  • src/lib/document-enrichment.ts
  • src/lib/env.ts
  • src/lib/eval-document-matching.ts
  • src/lib/model-index-extraction.ts
  • src/lib/openai.ts
  • src/lib/rag-answer-text.ts
  • src/lib/rag-cache.ts
  • src/lib/rag-claim-support.ts
  • src/lib/rag-eval-cases.ts
  • src/lib/rag-extractive-answer.ts
  • src/lib/rag-versioning.ts
  • src/lib/rag.ts
  • src/lib/sse-heartbeat.ts
  • src/lib/types.ts
  • src/lib/validation/answer-request.ts
  • tests/answer-progress-ui-smoke.spec.ts
  • tests/answer-responsiveness-gate.test.ts
  • tests/answer-stream-contract.test.ts
  • tests/answer-stream-extractor.test.ts
  • tests/client-secret-surface.test.ts
  • tests/corpus-grounding.test.ts
  • tests/document-enrichment.test.ts
  • tests/document-mutation-routes.test.ts
  • tests/model-index-extraction.test.ts
  • tests/openai-cache.test.ts
  • tests/openai-error-mapping.test.ts
  • tests/openai-safety-identifier.test.ts
  • tests/private-access-routes.test.ts
  • tests/private-rag-access.test.ts
  • tests/rag-answer-fallback.test.ts
  • tests/rag-answer-text.test.ts
  • tests/rag-cache-utils.test.ts
  • tests/rag-claim-support.test.ts
  • tests/rag-classifier-memo.test.ts
  • tests/rag-generation-fingerprint.test.ts
  • tests/rag-offline-answer.test.ts
  • tests/ui-smoke.spec.ts
💤 Files with no reviewable changes (2)
  • tests/answer-stream-extractor.test.ts
  • src/lib/answer-stream-extractor.ts

Comment thread scripts/eval-answer-quality.ts Outdated
Comment thread src/lib/rag-answer-text.ts
Comment thread src/lib/rag-claim-support.ts Outdated
Comment thread src/lib/rag.ts
Remove clinical answer previews from evaluation output, keep valid dose evidence eligible, and validate classifier bounds after Structured Outputs parsing. Verified with focused tests, offline RAG, verify:cheap, and the production build.

@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: d8bebf1039

ℹ️ 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 thread src/lib/openai.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/rag-extractive-answer.ts (1)

1680-1688: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Count distinct cited documents for broad-coverage gating.
src/lib/rag-extractive-answer.ts:1686 Two citations from the same document can still satisfy this check; compare distinct cited document_ids instead of answer.citations.length, and add a regression test for duplicate-document citations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/rag-extractive-answer.ts` around lines 1680 - 1688, Update the
broad-coverage gating condition near broadDocumentCoverageRequested to compare
the number of distinct cited document_id values against the required citation
threshold, rather than answer.citations.length; preserve the existing
source-availability check and add a regression test covering duplicate citations
from one document.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/rag-extractive-answer.ts`:
- Around line 381-388: Update hasMaximumDoseEvidence to recognize spelled-out
dose units, including milligram(s) and the other long-form units already
supported by the dose parser, while preserving existing numeric maximum-dose
patterns. Add regression coverage for wording such as “must not exceed 20
milligrams” and the additional supported long-form units.

---

Outside diff comments:
In `@src/lib/rag-extractive-answer.ts`:
- Around line 1680-1688: Update the broad-coverage gating condition near
broadDocumentCoverageRequested to compare the number of distinct cited
document_id values against the required citation threshold, rather than
answer.citations.length; preserve the existing source-availability check and add
a regression test covering duplicate citations from one document.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f4a19637-b9da-4ac9-924a-6cafd46c221f

📥 Commits

Reviewing files that changed from the base of the PR and between f83d7d4 and d8bebf1.

📒 Files selected for processing (11)
  • docs/branch-review-ledger.md
  • scripts/eval-answer-quality.ts
  • src/lib/rag-answer-text.ts
  • src/lib/rag-claim-support.ts
  • src/lib/rag-extractive-answer.ts
  • src/lib/rag-routing.ts
  • src/lib/rag.ts
  • tests/answer-stream-contract.test.ts
  • tests/extractive-answer-formatting.test.ts
  • tests/rag-answer-text.test.ts
  • tests/rag-classifier-memo.test.ts
💤 Files with no reviewable changes (1)
  • tests/answer-stream-contract.test.ts
🚧 Files skipped from review as they are similar to previous changes (6)
  • tests/rag-answer-text.test.ts
  • docs/branch-review-ledger.md
  • tests/rag-classifier-memo.test.ts
  • src/lib/rag-answer-text.ts
  • src/lib/rag-claim-support.ts
  • src/lib/rag.ts

Comment thread src/lib/rag-extractive-answer.ts
@BigSimmo

BigSimmo commented Jul 13, 2026

Copy link
Copy Markdown
Owner Author

Outstanding provider gate completed post-merge.

PR #626 was already squash-merged as 85137cde853550b59dd67dea7e0d12bb412e6692 before this final validation was requested. The missing live retrieval-quality gate has now run against current-main commit 9f4dc13044f3403c9a977a18cecb0c537ca9fd08:

  • 36/36 golden retrieval cases passed.
  • Document recall@5, content recall@5, top-k hit rate, and required-signal coverage: 1.00.
  • Forced-embedding cases: 10/10 passed.
  • Provider/embedding failures: 0.
  • Failed cases and latency-failed cases: 0.
  • Median latency: 7,086 ms; p90 latency: 27,390 ms.

No code improvement was required by the result, so no follow-up commit or push was created. Later main commits through 281d3e0cd do not touch the validated OpenAI/RAG path. The prior merge hold is therefore fully dispositioned.

@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: 1c6c780f30

ℹ️ 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 thread src/lib/rag-extractive-answer.ts Outdated
BigSimmo added 2 commits July 14, 2026 05:27
Preserve retryable empty max-token responses and accept equivalent maximum-dose wording with long-form units. Verified with focused Vitest, offline RAG, verify:cheap, production readiness, and a production build.
Preserve the shared answer request and final-only SSE contracts while incorporating response-bound feedback tokens from main. Post-merge focused tests, offline RAG, verify:cheap, and production build 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: 0301d59ab8

ℹ️ 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 thread src/lib/rag-extractive-answer.ts Outdated
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

Recognize not-to-exceed and not-more-than maximum-dose evidence. Focused Vitest, typecheck, and the offline RAG contract 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: f2652021c1

ℹ️ 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 thread src/lib/openai.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/rag-extractive-answer.ts`:
- Around line 354-365: Update maximum-dose evidence handling in
doseIntentEvidencePattern and the related
hasMaximumDoseEvidence/factKindForSentence flow so bare “max” or “maximum” no
longer qualifies as dose evidence; require those terms to be paired with “dose”
or a clinical dose value while preserving existing equivalent numeric
maximum-dose phrases. Add the smallest targeted regression asserting that
“Lithium has a maximum treatment duration of two years.” returns false, then run
the narrowest relevant validation.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f1bc3ab-e44b-41e7-8f2d-f5ca558ec4a0

📥 Commits

Reviewing files that changed from the base of the PR and between 1c6c780 and f265202.

📒 Files selected for processing (13)
  • docs/branch-review-ledger.md
  • src/app/api/answer/route.ts
  • src/app/api/answer/stream/route.ts
  • src/components/ClinicalDashboard.tsx
  • src/lib/openai.ts
  • src/lib/rag-answer-text.ts
  • src/lib/rag-extractive-answer.ts
  • src/lib/types.ts
  • tests/extractive-answer-formatting.test.ts
  • tests/openai-cache.test.ts
  • tests/private-access-routes.test.ts
  • tests/rag-answer-fallback.test.ts
  • tests/rag-answer-text.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/lib/types.ts
  • tests/rag-answer-text.test.ts
  • tests/private-access-routes.test.ts
  • src/app/api/answer/route.ts
  • tests/rag-answer-fallback.test.ts
  • src/lib/rag-answer-text.ts
  • src/app/api/answer/stream/route.ts
  • tests/openai-cache.test.ts
  • src/lib/openai.ts
  • src/components/ClinicalDashboard.tsx

Comment thread src/lib/rag-extractive-answer.ts
@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts on this branch.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 14, 2026 05:27
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

auto-merge was automatically disabled July 14, 2026 05:29

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge (squash) July 14, 2026 05:36
auto-merge was automatically disabled July 14, 2026 05:39

Head branch was pushed to by a user without write access

@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot fix all failing CI tests

auto-merge was automatically disabled July 14, 2026 05:59

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge (squash) July 14, 2026 06:04
@BigSimmo
BigSimmo merged commit 85137cd into main Jul 14, 2026
16 checks passed
BigSimmo added a commit that referenced this pull request Jul 14, 2026
…sources.ts (#641)

Audit 2026-07-13 deferred item D3, rag.ts decomposition phase 1 (finding
11). Zero behavior change: 1,014 lines moved verbatim (script-extracted
with boundary guards and per-symbol assertions), nothing rewritten.

Moved: the versioned-RPC plumbing (callVersionedRetrievalRpc, legacy
owner/public merge, RPC error + variant-fanout telemetry), the lexical
chunk / document-lookup / table-fact / embedding-field / index-unit
candidate searchers, the chunk hydrators for memory cards and signal
matches, and the memory-boost merge step.

rag.ts (5,779 -> ~4,790 lines) imports the surfaces it orchestrates and
re-exports callVersionedRetrievalRpc, loadChunksForMemoryCards, and
loadChunksForSignalMatches so existing test imports are untouched. The
extracted module depends only on non-rag lib modules - no import cycle.

Verified: typecheck + lint clean, eval:rag:offline green (279 contract
tests), verify:cheap green (2,301 tests), verify:pr-local green (build +
client-bundle scan). The extracted module is byte-identical whether
generated from the pre- or post-#626 base (the hardening PR touched no
moved range).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@BigSimmo
BigSimmo deleted the codex/openai-gpt56-rag-upgrade branch July 14, 2026 11:42
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.

2 participants