Package com.tnsai.accountability
Record Class AuthorityScope
java.lang.Object
java.lang.Record
com.tnsai.accountability.AuthorityScope
- Record Components:
allowedActions- whitelist of action types this scope permits; empty set = unrestricted (caller chose not to narrow)targetSystems- whitelist of target system identifiers (e.g."github.com/owner/repo"); empty set = unrestrictedspendCeilingUSD- optional hard cap on cumulative spend within the validity window; empty = no capvalidFor- how long the scope remains in force fromissuedAt; consumers compare wall-clock againstexpiresAt()to decide expiry.null= never expires (seepermanent())issuedAt- when the scope was minted
public record AuthorityScope(Set<ActionType> allowedActions, Set<String> targetSystems, Optional<BigDecimal> spendCeilingUSD, Duration validFor, Instant issuedAt)
extends Record
Pre-declared bounds on what an agent is allowed to do (TNS-298).
Attached to every
AgentLiabilityRecord the framework emits
so auditors can answer "did this agent stay within its declared
authority?" without re-deriving the answer from observability data.
Scope is inclusive — an empty allowedActions means "any
action type", an empty targetSystems means "any target".
Spend and validity windows are explicit limits when present.
- Since:
- 0.10.0 (TNS-298)
-
Constructor Summary
ConstructorsConstructorDescriptionAuthorityScope(Set<ActionType> allowedActions, Set<String> targetSystems, Optional<BigDecimal> spendCeilingUSD, Duration validFor, Instant issuedAt) Creates an instance of aAuthorityScoperecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedActionsrecord component.final booleanIndicates whether some other object is "equal to" this one.Wall-clock instant the scope ceases to be valid, orInstant.MAXfor apermanent()(no-expiry) scope.final inthashCode()Returns a hash code value for this object.booleanissuedAt()Returns the value of theissuedAtrecord component.static AuthorityScopeConvenience: a maximally-permissive scope that never expires.booleanpermits(ActionType action) booleanpermitsTarget(String targetSystem) Returns the value of thespendCeilingUSDrecord component.Returns the value of thetargetSystemsrecord component.final StringtoString()Returns a string representation of this record class.static AuthorityScopeunrestricted(Duration validFor) Convenience: maximally-permissive scope; useful as a development default.validFor()Returns the value of thevalidForrecord component.
-
Constructor Details
-
AuthorityScope
public AuthorityScope(Set<ActionType> allowedActions, Set<String> targetSystems, Optional<BigDecimal> spendCeilingUSD, Duration validFor, Instant issuedAt) Creates an instance of aAuthorityScoperecord class.- Parameters:
allowedActions- the value for theallowedActionsrecord componenttargetSystems- the value for thetargetSystemsrecord componentspendCeilingUSD- the value for thespendCeilingUSDrecord componentvalidFor- the value for thevalidForrecord componentissuedAt- the value for theissuedAtrecord component
-
-
Method Details
-
expiresAt
Wall-clock instant the scope ceases to be valid, orInstant.MAXfor apermanent()(no-expiry) scope. -
isExpired
-
permits
- Returns:
truewhenactionis permitted (whitelist empty = permissive; whitelist populated = membership check).
-
permitsTarget
- Returns:
truewhentargetSystemis permitted (whitelist empty = permissive; populated = membership).
-
unrestricted
Convenience: maximally-permissive scope; useful as a development default. -
permanent
Convenience: a maximally-permissive scope that never expires. Useful for long-lived server beans where a finiteunrestricted(Duration)window would otherwise need a sentinel likeDuration.ofDays(3650).expiresAt()returnsInstant.MAX;isExpired(Instant)is alwaysfalse. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
allowedActions
Returns the value of theallowedActionsrecord component.- Returns:
- the value of the
allowedActionsrecord component
-
targetSystems
Returns the value of thetargetSystemsrecord component.- Returns:
- the value of the
targetSystemsrecord component
-
spendCeilingUSD
Returns the value of thespendCeilingUSDrecord component.- Returns:
- the value of the
spendCeilingUSDrecord component
-
validFor
Returns the value of thevalidForrecord component.- Returns:
- the value of the
validForrecord component
-
issuedAt
Returns the value of theissuedAtrecord component.- Returns:
- the value of the
issuedAtrecord component
-