Expand description
Task 20 (Commit B) — session-scoped exact extension runtime leases (spec §7.5, mirroring the §7.4 MCP lease discipline).
Deferred manifest-declared extension tools execute ONLY through this
manager, strictly AFTER the ExecutionGate has authorized the exact
call. One ExtensionRuntimeManager is shared by the ExtensionManager
(which owns the retained internal launch records) and the Runtime
(which mints per-session capabilities and the durable session-end
scope):
- a lease is keyed by (session, plugin) and PINNED to the launch-record
fingerprint (manifest + cwd + resolved config) it was acquired under;
per-key SINGLE-FLIGHT acquisition (a
Startingplaceholder holding awatchreceiver whose stored state makes wakeups lost-proof) guarantees concurrent first calls never spawn duplicate children, and the manager map lock is NEVER held across process/pipe I/O; - acquisition re-reads the retained launch record, RE-VALIDATES the
manifest (permissions included), starts exactly one child
(
kill_on_drop), initializes ONCE, and requires the runtime’s registered declarations to match the manifest’s passive declarations EXACTLY (tool names, descriptions, canonical schema digests — and provider declarations when present) BEFORE any call; a mismatch shuts the child down and fails closed; - every call validates the selected exact tool name and canonical
schema digest against the pinned validated listing BEFORE
tool.call; - revocation/termination semantics are exact and honest: revocation
marks the lease cancelled under the per-lease call permit; a call
that already passed the gate check MAY complete and then shuts the
child down; NO call passes after revocation returns.
kill_on_dropon the child is the hard backstop once the lastArcdrops; - idle leases are reaped opportunistically with a CONSTANT per-pass
scan cap; session end is the drop of the LAST owner of the shared
durable
ExtensionSessionEndGuardscope. No PID signalling, no long-lived task, no unbounded channel; - lease failures carry ONLY static text, local identities, and numeric metadata — extension-reported error content is withheld (length only), and no launch-record (secret) config ever appears anywhere.
Structs§
- Extension
Lease Capability - Typed per-session lease capability handed to tool contexts: the exact session identity plus the shared manager. Never widens to a plugin grant — every call re-validates the exact tool and launch record.
- Extension
Runtime Manager - Session-scoped exact extension runtime lease manager. See module docs.
- Extension
Session EndGuard - Durable last-owner session scope. The Runtime mints ONE of these per
tool session (wrapped in an
Arcshared by every runtime clone and in-flight stream); streams HOLD it, never construct or drop their own. Leases therefore survive across provider turns, and only the drop of the LAST owner — true session end — terminates the session’s leases. - Lazy
Extension Handler - Lazy
ExtensionHandlerfor deferred hook/provider/user capabilities (Task 20 Commit C). Registered/subscribed at load WITHOUT a process; the first AUTHORIZED use (a matching hook event delivered by the permission-checkedHookBussubscription, a selected provider complete/stream, or an explicit user sidecar/command/settings action) single-flights through the SAME per-plugin lease manager — starting and exact-validating the child once. Discovery, load, search, and diagnostics never acquire.
Enums§
- Extension
Lease Error - Typed lease failures. Static text, local identities, and numeric metadata only — never extension-controlled content, never config.
Constants§
- DEFAULT_
IDLE_ MAX - Default idle bound for opportunistic reaping (parity with MCP leases).
- MAX_
LIVE_ LEASES - Hard cap on simultaneously live leases per manager.
- REAP_
SCAN_ MAX - Reap passes scan up to the full capped map so idle entries can never starve behind an active HashMap iteration prefix.