Skip to content

fix: Explain allowed, and Reachable and Holders listed, beside an error on a host's transaction - #164

Merged
Michael McQuade (giraffesyo) merged 2 commits into
canaryfrom
fix/round25-lows
Nov 25, 2026
Merged

Michael McQuade (giraffesyo) merged 2 commits into
canaryfrom
fix/round25-lows

Conversation

@giraffesyo

@giraffesyo Michael McQuade (giraffesyo) commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Explain allowed, and Reachable and Holders listed, beside an error on a host's transaction
    • The problem: Explain, Reachable and Holders read in one snapshot. On a pool that is a transaction of their own, and a failed read returned the zero value. Under WithTx, or on a DB whose Begin gives a savepoint of the host's transaction, the read ran directly on the host's transaction and returned whatever it had read beside the error. With a host transaction at READ COMMITTED and a change replacing the subject's conditional grants as they were read, the reread from fix: a check denied, and Permissions and Holding left out, what every moment allowed where a conditional grant was replaced as it ran, as extending one does #160 gave up with rbac: conflict: a grant was revoked or replaced as its condition was read; try again. Explain still returned Decision{Allowed: true} with the grant that allowed it, and Reachable returned the scopes it had reached. Holders, when its read of the holders' label values failed, returned the list before the label decided it. A host that logged the error and then read d.Allowed or reach.Scopes would act on an answer the call had refused, though any error means no.
    • The fix: The snapshot's read now returns the zero value beside an error on every DB: a transaction of its own, the host's transaction, or a savepoint-giving wrapper. That one point covers Explain, Reachable and Holders, and the reads they make inside AsOf. No caller used the partial value. The architecture notes now say that a failed read returns nothing.
  • Values some calls return beside an error on purpose, now stated
    • The problem: I checked every exported call that returns a value with an error. Grantable, Permissions, Holding, Filter, Grants, Denies, Eligibilities, Conflicts, Memberships, MembershipsOf, Groups, Members, GroupsOf, CustomRoles, Roles, Activate, Path, New, Chain and Sign already return the zero value. Export returns from, which its doc says. History returns after, and DeleteExpired and PruneHistory return the count from batches that had already committed, but their docs didn't say so.
    • The fix: History's doc now says that on an error it returns no records and after, so a read goes on from where it was. DeleteExpired's and PruneHistory's docs now say that on an error they return how many the earlier batches removed. All three values are true and safe, so the behavior is unchanged.

Testing

  • TestAReadOfOneSnapshotThatGivesUpOnTheHostsTransactionReturnsNothing (subtests WithTx and a wrapper around the host's transaction, at READ COMMITTED): the readingRoles hook replaces the subject's conditional grants on every read, so the reread gives up. Explain and Reachable must return ErrConflict with the zero value.
    • Without the fix in the pgx.Tx branch, the WithTx subtest fails: Explain after 6 reads = {Allowed:true Grants:[{Scope:{Type:cluster ID:c1} Binding:{... Role:cluster.admin Principal:{Kind:user ID:u} ...}}] ...}, rbac: conflict: a grant was revoked or replaced as its condition was read; try again and Reachable after 6 reads = {All:false Scopes:[] Conditional:[{Type:cluster ID:c1}] ...}, rbac: conflict: ....
    • Without the fix in the savepoint (nested) branch, the wrapper subtest fails with the same two messages.
  • TestHoldersWhoseReadFailsOnTheHostsTransactionReturnsNothing: a pgx.Tx wrapper given to WithTx fails the read of the holders' label values once their grants are read. Without the fix, it fails: Holders = [{Principal:{Kind:user ID:u} Grants:[...] Groups:[] Conditional:false MaybeDenied:false}], timeout: context already done: context canceled.
  • The round's reproduction now shows Explain and Reachable returning the zero value beside ErrConflict under WithTx at READ COMMITTED.
  • golangci-lint: 0 issues.
  • Full suite (make tidy-check lint vulncheck and go test -race -shuffle=on -cover ./...) with GODEBUG=fips140=only against PostgreSQL 18, on f96ff5e: passed (2850.175s, coverage: 95.0% of statements).

Checklist

  • make check passes
  • No exported name, stored value or table was renamed (they are contract once released)

🤖 Generated with pw code

@giraffesyo
Michael McQuade (giraffesyo) marked this pull request as ready for review November 25, 2026 05:12
@giraffesyo
Michael McQuade (giraffesyo) merged commit 165131b into canary Nov 25, 2026
10 checks passed
@giraffesyo
Michael McQuade (giraffesyo) deleted the fix/round25-lows branch November 25, 2026 05:51
@github-actions github-actions Bot mentioned this pull request Nov 25, 2026
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.

1 participant