Package com.tnsai.accountability
Record Class AgentLiabilityRecord
java.lang.Object
java.lang.Record
com.tnsai.accountability.AgentLiabilityRecord
- Record Components:
agentId- stable id fromAgentPrincipal.id()agentVersion- version stamp fromAgentPrincipal.version(); changes when the agent's behaviour changesinvokedAt- wall-clock instant the action startedaction- typed descriptor — seeActionscope- theAuthorityScopein force at invocationliability- severity tier — seeLiabilityClasscorrelationId- shared id linking this record to broader observability (an OTel trace id, an LLMCallLog entry, the wider transaction)outcome- post-action result hash or error message; empty when the action is still in flightsignature- optional cryptographic signature; populated when the issuingAgentPrincipalProvideris signing each record
public record AgentLiabilityRecord(String agentId, String agentVersion, Instant invokedAt, Action action, AuthorityScope scope, LiabilityClass liability, String correlationId, Optional<String> outcome, Optional<byte[]> signature)
extends Record
Append-only audit record produced for every agent action (TNS-298).
Pairs a verifiable agent identity with the action it took, the
scope it had, and the outcome.
Append-only contract
Records are immutable after creation — no edits, no deletes. TheLiabilitySink stores them as a write-once log; auditors
trust that a record they read today is identical to the one written
at invokedAt. Implementations that can't enforce this
(e.g. an in-memory sink) document the limitation explicitly.
Identity vs. observability
The framework already ships rich observability (LLMCallLog,
OpenTelemetry spans, hook events). This record is the
accountability view — short, audit-friendly, signed when
possible. Auditors join it with observability data via
correlationId when they need full call detail.- Since:
- 0.10.0 (TNS-298)
-
Constructor Summary
ConstructorsConstructorDescriptionAgentLiabilityRecord(String agentId, String agentVersion, Instant invokedAt, Action action, AuthorityScope scope, LiabilityClass liability, String correlationId, Optional<String> outcome, Optional<byte[]> signature) Creates an instance of aAgentLiabilityRecordrecord class. -
Method Summary
Modifier and TypeMethodDescriptionaction()Returns the value of theactionrecord component.agentId()Returns the value of theagentIdrecord component.Returns the value of theagentVersionrecord component.Returns the value of thecorrelationIdrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theinvokedAtrecord component.Returns the value of theliabilityrecord component.outcome()Returns the value of theoutcomerecord component.scope()Returns the value of thescoperecord component.Optional<byte[]> Returns the value of thesignaturerecord component.Optional<byte[]> Defensive copy of the signature bytes — mutations to the returned array don't affect the underlying record.final StringtoString()Returns a string representation of this record class.Build a failure-outcome record.withSuccess(String resultHash) Build a successful-outcome record.
-
Constructor Details
-
AgentLiabilityRecord
public AgentLiabilityRecord(String agentId, String agentVersion, Instant invokedAt, Action action, AuthorityScope scope, LiabilityClass liability, String correlationId, Optional<String> outcome, Optional<byte[]> signature) Creates an instance of aAgentLiabilityRecordrecord class.- Parameters:
agentId- the value for theagentIdrecord componentagentVersion- the value for theagentVersionrecord componentinvokedAt- the value for theinvokedAtrecord componentaction- the value for theactionrecord componentscope- the value for thescoperecord componentliability- the value for theliabilityrecord componentcorrelationId- the value for thecorrelationIdrecord componentoutcome- the value for theoutcomerecord componentsignature- the value for thesignaturerecord component
-
-
Method Details
-
withSuccess
Build a successful-outcome record. Convenience for the common "the action ran, here's the result hash" path. -
withFailure
Build a failure-outcome record. Convenience for "the action failed, here's the error class + message" path. Auditors get a record either way — failures are the most important signal. -
signatureCopy
Defensive copy of the signature bytes — mutations to the returned array don't affect the underlying record.- Returns:
- empty when no signature was attached
-
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). -
agentId
Returns the value of theagentIdrecord component.- Returns:
- the value of the
agentIdrecord component
-
agentVersion
Returns the value of theagentVersionrecord component.- Returns:
- the value of the
agentVersionrecord component
-
invokedAt
Returns the value of theinvokedAtrecord component.- Returns:
- the value of the
invokedAtrecord component
-
action
Returns the value of theactionrecord component.- Returns:
- the value of the
actionrecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
liability
Returns the value of theliabilityrecord component.- Returns:
- the value of the
liabilityrecord component
-
correlationId
Returns the value of thecorrelationIdrecord component.- Returns:
- the value of the
correlationIdrecord component
-
outcome
Returns the value of theoutcomerecord component.- Returns:
- the value of the
outcomerecord component
-
signature
Returns the value of thesignaturerecord component.- Returns:
- the value of the
signaturerecord component
-