Skip to content

docs(rag): fix buildRagSourceBlock & applyNumericVerification citations after the src/lib/rag extraction#998

Merged
BigSimmo merged 1 commit into
mainfrom
claude/pr-994-issues-p6bmuj
Jul 20, 2026
Merged

docs(rag): fix buildRagSourceBlock & applyNumericVerification citations after the src/lib/rag extraction#998
BigSimmo merged 1 commit into
mainfrom
claude/pr-994-issues-p6bmuj

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to the merged #994 review. #994 extracted the rag cluster into src/lib/rag/ and did a mechanical src/lib/rag.tssrc/lib/rag/rag.ts path bump on the two safety docs. But several cited symbols do not live in rag.ts at all, so the citations ended up pointing at the wrong file/line — exactly what the CodeRabbit review flagged. #997 (rag-evidence-gates extraction) then shifted rag.ts line numbers again by −129. This PR re-verifies every affected citation against current HEAD so both documents are reproducible again.

Resolves the two review comments on #994:

  • buildRagSourceBlock citations (docs/rag-injection-threat-model.md): the prompt-assembly and per-field render sites (title/file_name/caption/tableTitle/tableLabel/tableTextSnippet/memory_cards/retrieval_synopsis/adjacent_context/section_path/table_facts/indexing_quality/fenced content/id lines) now point at the extracted module src/lib/rag/rag-source-block.ts (lines 112–185), as §6 already noted. answerInstructions (rag.ts:3884) and buildAnswerInput/answer-input assembly (rag.ts:3938, cross-doc brief rag.ts:3998) are retained in rag.ts with corrected line numbers.
  • applyNumericVerification citations (docs/clinical-hazard-analysis.md): the helper and its internals (hasActionableNumericContext, blank-to-gap, per-section scoping, verifyAnswerNumbers, NUMERIC_TOKEN_PATTERN, and the union set — renamed sourceNumericTokenSetsourceClinicalValueAtomSet) now cite their real definition in src/lib/answer-verification.ts plus the call site rag.ts:4753. The companion H6b RAW-field refs also move to rag-source-block.ts.

Scope is limited to these two flagged citation groups across both companion docs. Other pre-existing stale rag.ts references from the same refactor (e.g. sanitizeCitations, deriveConfidence, evaluateEvidenceCoverageGate) were not in scope of these comments and are left for a separate sweep — noted here for visibility.

Verification

  • prettier --check passes on both files (table alignment preserved — replacements are equal-width)
  • Every cited file:line verified by sed/grep against the rebased HEAD (4a72c93)
  • Docs-only change — no unit/UI/eval/readiness gates apply (no source, config, or test code touched)

Risk and rollout

  • Risk: None — documentation-only; no product code, behavior, or configuration changed.
  • Rollback: revert this commit.
  • Provider or production effects: None.

Clinical Governance Preflight

N/A — this change edits only two analysis documents' internal code cross-references. No ingestion, answer generation, search/ranking, source rendering, document access, privacy, production env, or clinical output behavior is modified.

Notes

Rebased onto the current origin/main (4a72c93, includes #997) before verifying, so the line numbers reflect post-#997 rag.ts.


Generated by Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated the clinical hazard analysis to reflect current safety-control references and clarify known verification limitations.
    • Refreshed the RAG injection threat model with current prompt-data handling, sanitization boundaries, attack vectors, and citation/provenance risks.
    • Updated referenced code locations throughout both documents for improved accuracy.

…ations after #994/#997

PR #994 extracted the rag cluster into src/lib/rag/ and did a mechanical
`src/lib/rag.ts` -> `src/lib/rag/rag.ts` path bump on the two safety docs, but
several symbols do not live in rag.ts at all — leaving the citations pointing at
the wrong file/line (flagged in the #994 review). #997 then shifted rag.ts line
numbers again. This re-verifies every affected citation against the current code.

- rag-injection-threat-model.md: all `buildRagSourceBlock` field/assembly
  citations now point at `src/lib/rag/rag-source-block.ts` (the extracted module,
  as §6 already noted); `answerInstructions`/`buildAnswerInput` remain in
  `rag.ts` with corrected line numbers; numeric-verification helpers point at
  `answer-verification.ts` with the renamed `sourceClinicalValueAtomSet`.
- clinical-hazard-analysis.md: `applyNumericVerification` and its helpers
  (`hasActionableNumericContext`, blank-to-gap, per-section scoping,
  `verifyAnswerNumbers`, token patterns, union scoping) now cite their real
  definition in `answer-verification.ts` plus the call site `rag.ts:4753`; the
  H6b RAW-field refs point at `rag-source-block.ts`.

Every cited file:line was verified against HEAD; docs pass `prettier --check`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GmHShvB83oyi7sLUFRvnYB
@supabase

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

@coderabbitai

coderabbitai Bot commented Jul 20, 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: b4c40753-dd65-4bc9-ae52-6381e7f2fedb

📥 Commits

Reviewing files that changed from the base of the PR and between 4a72c93 and 7be78a4.

📒 Files selected for processing (2)
  • docs/clinical-hazard-analysis.md
  • docs/rag-injection-threat-model.md

📝 Walkthrough

Walkthrough

Updated two safety documents with current code references and revised descriptions of numeric verification, prompt-field handling, fencing, injection vectors, mitigations, and citation-scoping behavior. No exported or public entities were changed.

Changes

Safety documentation updates

Layer / File(s) Summary
Clinical hazard control references
docs/clinical-hazard-analysis.md
Updated H1 and H6 hazard references and the “working well” numeric-faithfulness citations.
RAG injection threat-model wiring
docs/rag-injection-threat-model.md
Revised prompt-field mappings, attack vectors, mitigation references, key file index, and numeric-scoping follow-up citation.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/pr-994-issues-p6bmuj

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

@BigSimmo
BigSimmo marked this pull request as ready for review July 20, 2026 17:07
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@BigSimmo
BigSimmo merged commit b57acf2 into main Jul 20, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the claude/pr-994-issues-p6bmuj branch July 20, 2026 17:07
BigSimmo pushed a commit that referenced this pull request Jul 20, 2026
PR #998 (merged) already refreshed the file:line citations after the rag.ts
decomposition, so this trims the parallel #1000 down to the one durable
complement #998 left untouched: line 14 still claimed each control is "cited at
its present location" — an absolute-currency claim that re-stales on every
refactor. Replace it with an as-of-#998 note plus guidance to search by the
named symbol when a line has drifted (docs:check-links validates the path, not
the line).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Jc1ZYHFjXjn6mE6U6riVU
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