-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Audit Recommendations for Provenance and Safety #1254
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
17 commits
Select commit
Hold shift + click to select a range
748b853
Implement audit recommendations for provenance and safety
BigSimmo be03131
Merge branch 'main' into apply-audit-remediation-fixes
github-actions[bot] eb2b4e2
Merge branch 'main' into apply-audit-remediation-fixes
github-actions[bot] be6243f
Merge branch 'main' into apply-audit-remediation-fixes
github-actions[bot] ac0c67b
fix: keep locality audit out of pr-local and preserve threshold compa…
BigSimmo 828c223
Merge remote-tracking branch 'origin/apply-audit-remediation-fixes' i…
BigSimmo 5b920f9
style: prettier format babysit threshold and locality audit files
BigSimmo b3b1eb7
merge: integrate origin/main; keep locality audit out of pr-local
BigSimmo 91aeb19
docs: babysit sweep ledger row for #1254
BigSimmo 8359580
Merge remote-tracking branch 'origin/main' into apply-audit-remediati…
cursoragent ee6a56b
fix: preserve source governance threshold boundaries
cursoragent 7c5a31b
docs: record PR 1254 babysit pass
cursoragent e9392c9
fix: harden threshold conflict detection
cursoragent 5b616da
test: scope ui assertions to visible containers
cursoragent a4c5f28
docs: clarify duplicate PR 1254 ledger row
cursoragent c37ae59
docs: sync PR 1254 policy body
cursoragent b5aa92f
docs: remove temporary PR policy body sync file
cursoragent 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
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,80 @@ | ||
| import * as nextEnv from "@next/env"; | ||
| import { auditSourceAuthorityDocuments, type SourceAuthorityDocument } from "@/lib/source-authority-metadata"; | ||
|
|
||
| const loadEnvConfig = | ||
| nextEnv.loadEnvConfig ?? | ||
| (nextEnv as unknown as { default?: { loadEnvConfig?: typeof nextEnv.loadEnvConfig } }).default?.loadEnvConfig; | ||
|
|
||
| async function loadAdminClient() { | ||
| const { createAdminClient } = await import("@/lib/supabase/admin"); | ||
| return createAdminClient(); | ||
| } | ||
|
|
||
| function asSourceAuthorityDocument(row: { | ||
| id?: string | null; | ||
| title?: string | null; | ||
| file_name?: string | null; | ||
| source_path?: string | null; | ||
| metadata?: unknown; | ||
| }): SourceAuthorityDocument { | ||
| return { | ||
| id: row.id ?? undefined, | ||
| title: row.title ?? "", | ||
| file_name: row.file_name ?? "", | ||
| source_path: row.source_path ?? null, | ||
| metadata: | ||
| row.metadata && typeof row.metadata === "object" && !Array.isArray(row.metadata) | ||
| ? (row.metadata as Record<string, unknown>) | ||
| : null, | ||
| }; | ||
| } | ||
|
|
||
| export async function main() { | ||
| if (loadEnvConfig) { | ||
| loadEnvConfig(process.cwd()); | ||
| } | ||
|
|
||
| const supabase = await loadAdminClient(); | ||
| const documents: SourceAuthorityDocument[] = []; | ||
| const pageSize = 1000; | ||
|
|
||
| for (let from = 0; ; from += pageSize) { | ||
| const { data, error } = await supabase | ||
| .from("documents") | ||
| .select("id,title,file_name,source_path,status,metadata") | ||
| .eq("status", "indexed") | ||
| .order("id", { ascending: true }) | ||
| .range(from, from + pageSize - 1); | ||
|
|
||
| if (error) throw new Error(error.message); | ||
| documents.push(...(data ?? []).map(asSourceAuthorityDocument)); | ||
| if (!data || data.length < pageSize) break; | ||
| } | ||
|
|
||
| const report = auditSourceAuthorityDocuments(documents); | ||
|
|
||
| if (!report.passed) { | ||
| console.error("FAIL: Source authority metadata verification failed."); | ||
| if (report.missing_australian_locality_count > 0) { | ||
| console.error(`- Missing Australian locality metadata: ${report.missing_australian_locality_count} documents`); | ||
| } | ||
| if (report.authority_conflict_count > 0) { | ||
| console.error(`- Authority conflicts: ${report.authority_conflict_count} documents`); | ||
| } | ||
| process.exitCode = 1; | ||
| } else { | ||
| console.log("PASS: Source authority metadata verification passed."); | ||
| } | ||
| } | ||
|
|
||
| if (process.argv[1] && import.meta.url === `file://${process.argv[1]}`.replace(/\\/g, "/")) { | ||
| main().catch((error) => { | ||
| console.error(error instanceof Error ? error.message : error); | ||
| process.exitCode = 1; | ||
| }); | ||
| } else if (process.argv[1] && process.argv[1].endsWith("verify-locality-metadata.ts")) { | ||
| main().catch((error) => { | ||
| console.error(error instanceof Error ? error.message : error); | ||
| process.exitCode = 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
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.