ADR 0582 clause 3 composes the bus's user list without the controller's write on the lease key and update of the lease's bucket. Records.LeaseCut, set by the grants part from the write's second step, drops the controller's $KV grant on the lease, denies it the bucket's update, purge, delete and message delete (its $JS.API.> reaches them), and lets the grants part write the key holder alone. The bus module's tools account may read and update the lease's bucket, for the expiry tool the write and the hand-back call. Without the cut the lists equal the controller's golden. Tests: rows added to TestTheCopiedComposerComposesAsTheControllers' tables (the cut on and off; the tools account's lease grants); no new test function. (issue 774, 774/S2) Claude-Session: https://claude.ai/code/session_01NcbgfJ9Gum47zkFKWRaovL
42 lines
2.1 KiB
Go
42 lines
2.1 KiB
Go
package buscompose
|
|
|
|
import "slices"
|
|
|
|
// **The lease write's grants** (novox/hq ADR 0582 clause 3, issue 774). Composed with Records.LeaseCut, the list takes
|
|
// from the controller its write of the lease's key and every update, purge and delete of the lease's bucket, and gives
|
|
// the grants part the key `holder`, which it creates naming itself and deletes at a hand-back (clause 5). Whatever the
|
|
// records, the bus module's tools account may read and update the lease's bucket, for the tool that removes and
|
|
// restores its expiry; no other bucket's.
|
|
|
|
// leaseStream is the lease bucket's stream.
|
|
var leaseStream = "KV_" + LeaseBucket
|
|
|
|
// LeaseHolderWrite is the grants part's write of the lease's one key, from the cut.
|
|
func LeaseHolderWrite() string { return "$KV." + LeaseBucket + "." + leaseKey }
|
|
|
|
// LeaseCutDenied are the controller's subjects of the lease's bucket that its `$JS.API.>` reaches and the cut refuses:
|
|
// the bucket's update (its expiry), purge and delete, and a message's delete (the key's last value).
|
|
func LeaseCutDenied() []string {
|
|
return []string{"$JS.API.STREAM.UPDATE." + leaseStream, "$JS.API.STREAM.PURGE." + leaseStream,
|
|
"$JS.API.STREAM.DELETE." + leaseStream, "$JS.API.STREAM.MSG.DELETE." + leaseStream}
|
|
}
|
|
|
|
// LeaseExpiryGrants are the bus module's tools account's read and update of the lease's bucket, for its expiry.
|
|
func LeaseExpiryGrants() []string {
|
|
return []string{"$JS.API.STREAM.INFO." + leaseStream, "$JS.API.STREAM.UPDATE." + leaseStream}
|
|
}
|
|
|
|
// writesTheLease is the controller holding the lease, or, from the cut, the grants part writing its key holder alone.
|
|
func writesTheLease(p Principal, pattern string) bool {
|
|
if p.Kind == KindController {
|
|
return true
|
|
}
|
|
return p.Kind == KindModule && p.Module == GrantsModule && p.LeaseCut && pattern == LeaseHolderWrite()
|
|
}
|
|
|
|
// setsLeaseExpiry is the bus module's tools account updating the lease's bucket: the writers table's one exemption from
|
|
// stream definitions being the controller's beside ASSIGNMENTS' removal (ADR 0582 clause 3).
|
|
func setsLeaseExpiry(p Principal, pattern string) bool {
|
|
return p.Kind == KindProcess && len(p.Removes) > 0 && slices.Contains(LeaseExpiryGrants(), pattern)
|
|
}
|