-
Notifications
You must be signed in to change notification settings - Fork 0
fix: audit P2/P3 hardening (M13 guard, upload rate limit, P0 carry-over) #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1fe13f1
fix: audit P0 RAG cache, synopsis parity, and safety hardening
BigSimmo 1864748
fix: audit P2/P3 M13 guard, upload rate limit, and disposition docs
BigSimmo a7133f2
style: fix Prettier drift on audit P2/P3 files
BigSimmo 2505afd
fix: guard stale inflight cache writes, synopsis numeric exemption, d…
cursoragent 7414960
style: format rag.ts for CI prettier check
BigSimmo 560c32e
fix: use inline search request seq pattern in document search shortcut
BigSimmo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { loadEnvConfig } from "@next/env"; | ||
|
|
||
| import { createAdminClient } from "@/lib/supabase/admin"; | ||
|
|
||
| loadEnvConfig(process.cwd()); | ||
|
|
||
| const M13_HEALTH_MARKER = "commit_document_index_generation.preserve_legacy_artifacts_migration"; | ||
| const M13_MIGRATION = "20260702000000_commit_generation_preserve_legacy_artifacts.sql"; | ||
|
|
||
| type SchemaHealth = { | ||
| ok?: boolean; | ||
| missing?: unknown; | ||
| }; | ||
|
|
||
| function missingMarkers(data: unknown) { | ||
| if (!data || typeof data !== "object" || Array.isArray(data)) return []; | ||
| const missing = (data as SchemaHealth).missing; | ||
| return Array.isArray(missing) ? missing.map(String) : []; | ||
| } | ||
|
|
||
| async function main() { | ||
| const supabase = createAdminClient(); | ||
| const { data, error } = await supabase.rpc("search_schema_health"); | ||
| if (error) { | ||
| console.error("[M13 Migration] FAIL: search_schema_health unavailable:", error.message); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const missing = missingMarkers(data); | ||
| if (missing.includes(M13_HEALTH_MARKER)) { | ||
| console.error( | ||
| `[M13 Migration] FAIL: live commit_document_index_generation is missing the preserve-legacy-artifacts guard.`, | ||
| ); | ||
| console.error(`Apply ${M13_MIGRATION} via the normal Supabase migration workflow, then run:`); | ||
| console.error(" npm run reindex:health"); | ||
| console.error(" npm run check:indexing"); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| if (missing.includes("commit_document_index_generation.signature")) { | ||
| console.error("[M13 Migration] FAIL: commit_document_index_generation RPC is missing on the live project."); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log("[M13 Migration] PASS: commit generation preserve-legacy guard is live."); | ||
| if (missing.length > 0) { | ||
| console.log("[M13 Migration] Note: search_schema_health reported other missing items:", missing.join(", ")); | ||
| } | ||
| } | ||
|
|
||
| main().catch((error) => { | ||
| console.error("[M13 Migration] FAIL:", error instanceof Error ? error.message : error); | ||
| process.exit(1); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { SearchResult } from "@/lib/types"; | ||
|
|
||
| export function clinicalImageEvidenceHaystack(images: SearchResult["images"]) { | ||
| return (images ?? []) | ||
| .map((image) => | ||
| [image.tableTextSnippet, image.accessibleTableMarkdown, image.caption, image.tableTitle, image.tableLabel] | ||
| .filter(Boolean) | ||
| .join(" "), | ||
| ) | ||
| .join(" "); | ||
| } | ||
|
|
||
| export function clinicalResultEvidenceHaystack(result: SearchResult) { | ||
| const tableFactText = (result.table_facts ?? []) | ||
| .map( | ||
| (fact) => | ||
| `${fact.table_title ?? ""} ${fact.row_label ?? ""} ${fact.clinical_parameter ?? ""} ${fact.threshold_value ?? ""} ${fact.action ?? ""}`, | ||
| ) | ||
| .join(" "); | ||
| const memoryCardText = (result.memory_cards ?? []).map((card) => `${card.title} ${card.content}`).join(" "); | ||
| return `${result.title} ${result.file_name} ${result.section_heading ?? ""} ${result.retrieval_synopsis ?? ""} ${result.content} ${tableFactText} ${memoryCardText} ${clinicalImageEvidenceHaystack(result.images)}`.toLowerCase(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /** Matches owner-scoped in-memory RAG cache keys (`rag-cache-v12|ownerId|...` and `ownerId|scope`). */ | ||
| export function ragCacheKeyMatchesOwner(key: string, ownerId: string) { | ||
| return key.includes(`|${ownerId}|`) || key.startsWith(`${ownerId}|`); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.