local_exec
Module: local_exec
Section titled “Module: local_exec”Contents
Section titled “Contents”Modules
handler- Local-exec governance request handler.token_store- Approval token state machine for HITL local-exec governance.
Module: handler
Section titled “Module: handler”Local-exec governance request handler.
[LocalExecHandler::decide] is the entry point for governance decisions:
- Fresh request (no
approval_token): apply the configured [DefaultAction] and, when the action isPendingHitl, issue a new approval token inTokenState::Pendingstate bound to the request context. - Retry with token (
approval_tokenpresent): validate the token against the store. [TokenValidationResult::Valid] producesallow; [TokenValidationResult::Pending] producespending_hitl(keep polling); every other state is a fail-closeddeny.
[LocalExecHandler::decide_management] handles operator approval and
revocation commands over the same UDS endpoint:
local.exec.approve— transitions aPendingtoken toApproved, making it consumable by the nextfirma-runretry.local.exec.revoke— transitions aPendingorApprovedtoken toRevoked, permanently blocking the corresponding execution.
All deny paths include a human-readable reason string so operators can
diagnose why a launch was blocked.
Module: token_store
Section titled “Module: token_store”Approval token state machine for HITL local-exec governance.
The [TokenStore] trait defines the contract. Tokens go through:
Pending → Approved (operator explicitly approves via management API)Pending → Revoked (operator explicitly revokes via management API)Pending → Expired (TTL elapsed before operator decision)Approved → Consumed (single successful validate_and_consume call)Approved → Expired (TTL elapsed before firma-run retried after approval)Every property listed in the architecture spec is enforced:
- Short-lived: tokens carry an absolute expiry.
- Single-use: the
Consumedtransition is atomic; a second call returns [TokenValidationResult::AlreadyConsumed]. - Server-side tracked: state lives in the store, never on the wire.
- Context-bound: each token is bound to the fingerprint,
session_id,sandbox_id, and optionallyagent_idthat were present at issuance. Any mismatch returns [TokenValidationResult::ContextMismatch] or [TokenValidationResult::FingerprintMismatch]. - Operator-gated:
Pendingtokens return [TokenValidationResult::Pending] on retry until an operator explicitly approves them. Only [TokenState::Approved] tokens are consumable.
The default implementation is [InMemoryTokenStore]. Alternative backends
(Redis, distributed stores, test doubles) implement [TokenStore] and are
passed to [super::handler::LocalExecHandler] via
[super::handler::LocalExecHandler::with_store].