Repository navigation
Fix pending readmission provider-authority inventory #3903
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
2 commits
Select commit
Hold shift + click to select a range
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
34 changes: 34 additions & 0 deletions
34
supabase/migrations/20261107001000_pending_readmission_provider_authority.sql
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,34 @@ | ||
| -- DRAFT: provider facts observe a readmission's declared pending authority while | ||
| -- retrieval continues to use the old flat ranking metadata until completion. | ||
| -- Validate the pending admission binding and unchanged live snapshot first. | ||
| -- Existing event/source/lease/permission checks and ACLs remain unchanged. | ||
| begin; | ||
| set local lock_timeout='5s'; | ||
| set local statement_timeout='120s'; | ||
|
|
||
| do $$ | ||
| declare signature regprocedure:='public.read_ingestion_generation_inventory(jsonb,uuid)'::regprocedure; | ||
| definition text;needle text;replacement text; | ||
| begin | ||
| definition:=pg_get_functiondef(signature); | ||
| needle:=$old$ for pa_pair in select * from (values | ||
| ('source_role','sourceRole'),('authority_basis','authorityBasis'),('licence_policy','licencePolicy'),$old$; | ||
| replacement:=$new$ -- The immutable event above binds the declaration to this document/source. | ||
| -- A changed live snapshot (including withdrawn rights) must never be hidden | ||
| -- by overlaying pending values. Missing/foreign/malformed blocks fail closed. | ||
| if pa_metadata ? 'pending_reindex_authority' then | ||
| if not ingestion_generation_evidence.pending_reindex_authority_valid(pa_metadata) | ||
| or exists(select 1 from jsonb_each(pa_metadata#>'{pending_reindex_authority,prior}') prior | ||
| where coalesce(pa_metadata->prior.key,'null'::jsonb) is distinct from prior.value) | ||
| then raise exception 'provider_authority_admission_mismatch';end if; | ||
| pa_metadata:=pa_metadata||(pa_metadata#>'{pending_reindex_authority,values}'); | ||
| end if; | ||
| for pa_pair in select * from (values | ||
| ('source_role','sourceRole'),('authority_basis','authorityBasis'),('licence_policy','licencePolicy'),$new$; | ||
| if length(definition)-length(replace(definition,needle,''))<>length(needle) | ||
| or strpos(definition,'pending_reindex_authority')<>0 | ||
| or not exists(select 1 from pg_proc where oid=signature and proowner='postgres'::regrole) | ||
| then raise exception 'pending_provider_authority_preimage';end if; | ||
| execute replace(definition,needle,replacement); | ||
| end $$; | ||
| commit; | ||
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
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.