MCPcopy Create free account
hub / github.com/MetapriseAI/OrgKernel / ExecutionToken

Class ExecutionToken

src/orgkernel/schemas/execution_token.py:94–242  ·  view source on GitHub ↗

Scoped, time-bounded permission token for a specific Mission execution. Issued at Mission APPROVED state. Enforced at the Tool Gateway — out-of-scope calls are blocked before reaching any external system.

Source from the content-addressed store, hash-verified

92
93
94class ExecutionToken(BaseModel):
95 """
96 Scoped, time-bounded permission token for a specific Mission execution.
97 Issued at Mission APPROVED state.
98 Enforced at the Tool Gateway — out-of-scope calls are blocked
99 before reaching any external system.
100 """
101 model_config = {"frozen": True}
102
103 token_id: str = Field(default_factory=_new_token_id)
104 agent_id: str
105 mission_id: str
106 execution_scope: list[str] = Field(
107 min_length=1,
108 description="Whitelist of permitted tool call identifiers.",
109 )
110 immutable_params: dict = Field(
111 default_factory=dict,
112 description="Tool call params that must match exactly.",
113 )
114 bounded_params: list[BoundedParam] = Field(
115 default_factory=list,
116 description="Params with numeric bounds.",
117 )
118 issued_at: datetime = Field(default_factory=_now_utc)
119 expires_at: datetime
120 boundary_snapshot_id: str | None = None
121 token_signature: str | None = Field(
122 default=None,
123 description="Ed25519 signature by Org CA over canonical token payload. Prevents token tampering and Token Grafting.",
124 )
125 used: bool = False
126 invalidated_at: datetime | None = None
127 invalidation_reason: str | None = None
128
129 @field_validator("token_id")
130 @classmethod
131 def _validate_token_id(cls, v: str) -> str:
132 if not _TOKEN_ID_RE.match(v):
133 raise ValueError(f"token_id '{v}' must match ^tok_[a-z0-9]+$")
134 return v
135
136 @field_validator("agent_id")
137 @classmethod
138 def _validate_agent_id(cls, v: str) -> str:
139 if not _AGENT_ID_RE.match(v):
140 raise ValueError(f"agent_id '{v}' must match ^aid_[a-z0-9]+$")
141 return v
142
143 @field_validator("mission_id")
144 @classmethod
145 def _validate_mission_id(cls, v: str) -> str:
146 if not _MISSION_ID_RE.match(v):
147 raise ValueError(f"mission_id '{v}' must match ^msn_[a-z0-9]+$")
148 return v
149
150 @field_validator("execution_scope")
151 @classmethod

Callers 2

_model_to_pydanticFunction · 0.90
mintMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected