feat(governance): RAG behaviour memory + enforced ranking safeguards#1007
Conversation
- docs/rag-behaviour/: durable evidence-backed memory of the 2026-07-20 cycle — behaviour map (imputation sites, comparator chains, gate ladder, second-stage engagement), the two live-refuted approaches with binding third-attempt constraints, and the safeguard stack reference - AGENTS.md 'RAG ranking protection': standing rules every agent session inherits — flag RAG impact before editing, canary pair for behaviour changes, never insert comparator keys above relevance - pr-policy: new blocking gate — PRs touching RAG-ranking protected surfaces fail without an explicit 'RAG impact:' declaration (no-change reason or canary pair); self-test covers undeclared/vague/no-change/ canary cases; workflow failure message generalized - tests/rag-imputation-contract.test.ts: source-text pins on the imputation formulas (app + SQL) and the release comparator key ORDER (score -> similarity -> relevance -> id) — red-proven against a mutated formula; failure message routes editors to the required protocol Restoration context: canary #56 (run 29774459706) confirmed reverted main green 36/36, closing the #55-regression -> revert -> restore arc. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThe PR adds a blocking ChangesRAG ranking protection
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Author
participant PRPolicy
participant RAGContractTests
participant Workflow
Author->>PRPolicy: Submit changed files and PR body
PRPolicy->>PRPolicy: Classify RAG-ranking surfaces
PRPolicy->>PRPolicy: Validate RAG impact declaration
PRPolicy->>RAGContractTests: Run contract checks
RAGContractTests-->>PRPolicy: Formula and ordering results
PRPolicy->>Workflow: Report policy status
Workflow-->>Author: Pass or blocking failure message
Possibly related PRs
Suggested labels: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
The durable close-out of tonight's RAG cycle, per user direction: a permanent memory of what was learned, and enforced safeguards so retrieval/ranking behaviour cannot be changed casually by any future task or session.
RAG impact: no retrieval behaviour change — documentation, policy tooling, and source-pin tests only (confirmed by canary #56: reverted main green 36/36).
docs/rag-behaviour/(new, 4 files): README (standing rules + index), behaviour-map (verified mechanics: the four imputation sites, the comparator chains and their load-bearing relevance fallback, the gate ladder, second-stage engagement rules, live case↔path evidence), refuted-approaches (both live-refuted attempts with numbers, root causes, and the binding constraints for any third attempt), safeguards (the four-layer protection stack).AGENTS.md§ RAG ranking protection: standing rules every agent session inherits — flag RAG impact before editing protected surfaces, canary pair for behaviour changes, never insert comparator keys above the relevance score.RAG impact:declaration — eitherno retrieval behaviour change — <reason>or a canary-pair reference. Self-test covers undeclared/vague (blocked) and no-change/canary (pass) cases. This very PR is gated by its own rule (see the declaration above).tests/rag-imputation-contract.test.ts: source-text pins on the imputation formulas (app + SQL) and the release comparator key ORDER (score → similarity → relevance → id). Red-proven: mutating one constant fails exactly the right test with a message routing the editor to the required protocol.Also closes the loop live: canary #56 (run 29774459706) on reverted main = SUCCESS, restoring the 36/36 baseline and completing the #55-regression → revert → restore arc.
Verification
node scripts/pr-policy.mjs --self-test+npm run check:pr-policy(workflow guard) — pass with the new gate casesnpm run test— 3025 passed / 1 failed: the known container-onlypdf-extraction-budgetartifactnpm run lint+npm run typecheck+ prettier — cleannpm run docs:check-links— 1030 refs resolve (new docs folder included)npm run check:github-actions— pass (workflow edit is message/comment-only)Risk and rollout
Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Notes
refinput), docs+tooling(eval): ADDENDUM 4 close-out — Phase C record, boundary-case policy, artifact trend tool (Phase D) #1006 (eval:trend, §3.1 policy), and this PR. Remaining documented plans (not implemented): word-boundary matcher (own PR), irrelevant@10 labeling audit, Phase E answer-side (separate approval).1d04436).🤖 Generated with Claude Code
https://claude.ai/code/session_01EXsJcLrbZUXwnBeG91cVo9
Generated by Claude Code
Summary by CodeRabbit
New Features
RAG impact:declaration, including either a no-change explanation or validation canary details.Documentation
Tests