Package com.tnsai.security
Class InvocationContext
java.lang.Object
com.tnsai.security.InvocationContext
Trusted interaction provenance, separate from executing agent and executor principal.
Root factories belong to host ingress, not model arguments or arbitrary request fields.
USER denotes an interaction category, not an authenticated account. This API is not a JVM sandbox.
An invocation may carry the AgentPrincipal its dispatches are attributed to. A host that
serves several agents or conversations from one executor passes it here, per call, instead of wiring
it on the shared executor; a dispatch reads the invocation's principal and falls back to the
executor's wired one only when the invocation carries none.
-
Method Summary
Modifier and TypeMethodDescriptionactor()static InvocationContextautonomous(AccessSubject executingAgent, String executorId, AuthorityScope authority) Use only for the actual agent's own initiative, never for forwarded or human work.static InvocationContextautonomous(AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) autonomous(AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.<T> Tcallers()static Optional<InvocationContext> current()delegateTo(AccessSubject nextAgent, String nextExecutorId, AuthorityScope nextAuthority) Trusted host transfer to the actual recipient agent.static AgentPrincipaldispatchPrincipal(AgentPrincipal wired) The principal a dispatch running now is attributed to: the current invocation's, orwiredwhen no invocation is active or it carries none.static InvocationContextotherAgent(AccessSubject callerAgent, AccessSubject executingAgent, String executorId, AuthorityScope authority) Trusted peer ingress.static InvocationContextotherAgent(AccessSubject callerAgent, AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) otherAgent(AccessSubject, AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.The executor principal this invocation's dispatches are attributed to, if the host gave one.voidsubjects()static InvocationContextCarries an unclassified ingress without granting any execution category.static InvocationContextuser(AccessSubject human, AccessSubject executingAgent, String executorId, AuthorityScope authority) Host-owned human interaction boundary; the subject may be a stable anonymous chat identity.static InvocationContextuser(AccessSubject human, AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) user(AccessSubject, AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.static Runnablestatic <T> Callable<T> Captures the current provenance and restores worker state on success, failure or cancellation.
-
Method Details
-
user
public static InvocationContext user(AccessSubject human, AccessSubject executingAgent, String executorId, AuthorityScope authority) Host-owned human interaction boundary; the subject may be a stable anonymous chat identity. Stored@Idempotentresults are shared by everyone presenting the same subjects, roles, origin, agent and executor, so a subject id must name one principal: a single anonymous id shared by many people lets them read each other's cached results. -
user
public static InvocationContext user(AccessSubject human, AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) user(AccessSubject, AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.- Parameters:
principal- the executor principal for this invocation's dispatches, ornullfor the executor's wired one- Since:
- 0.18.6
-
autonomous
public static InvocationContext autonomous(AccessSubject executingAgent, String executorId, AuthorityScope authority) Use only for the actual agent's own initiative, never for forwarded or human work. -
autonomous
public static InvocationContext autonomous(AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) autonomous(AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.- Parameters:
principal- the executor principal for this invocation's dispatches, ornullfor the executor's wired one- Since:
- 0.18.6
-
otherAgent
public static InvocationContext otherAgent(AccessSubject callerAgent, AccessSubject executingAgent, String executorId, AuthorityScope authority) Trusted peer ingress. For an existing invocation use delegateTo to preserve its origin. -
otherAgent
public static InvocationContext otherAgent(AccessSubject callerAgent, AccessSubject executingAgent, String executorId, AuthorityScope authority, AgentPrincipal principal) otherAgent(AccessSubject, AccessSubject, String, AuthorityScope)whose dispatches are attributed toprincipal.- Parameters:
principal- the executor principal for this invocation's dispatches, ornullfor the executor's wired one- Since:
- 0.18.6
-
unknown
Carries an unclassified ingress without granting any execution category. -
cachePartition
-
actor
-
executingAgent
-
onBehalfOf
-
executorId
-
callers
-
authorities
-
principal
The executor principal this invocation's dispatches are attributed to, if the host gave one.- Since:
- 0.18.6
-
dispatchPrincipal
The principal a dispatch running now is attributed to: the current invocation's, orwiredwhen no invocation is active or it carries none. Every check of one dispatch reads it here.- Parameters:
wired- the executor's host-wired principal, ornull- Returns:
- the principal, or
nullwhen neither gives one - Since:
- 0.18.6
-
subjects
-
current
-
delegateTo
public InvocationContext delegateTo(AccessSubject nextAgent, String nextExecutorId, AuthorityScope nextAuthority) Trusted host transfer to the actual recipient agent. The departing agent is derived from this context, never supplied by the caller. Every prior authority and subject remains. A USER peer hop requires USER and OTHER_AGENT; peer work can never become SELF again. A hop to the same agent keeps this invocation's principal; a peer hop drops it, so the recipient's dispatches are attributed to the recipient executor's own wired principal. -
call
- Throws:
Exception
-
run
-
wrap
Captures the current provenance and restores worker state on success, failure or cancellation. -
wrap
-