symfonic.capabilities.human.capability¶
capability ¶
The capability as one object: registrations in, pauses and resumes out.
A composition root wanting human interaction has one call to make and two verbs to use afterwards. Everything else — which metadata key a payload lives under, which claim binds which scope, which object decides the single winner, whether this deployment may be asked for a drain proof — is a rule, and a rule restated at a call site is a rule that can be restated differently at the next one.
HumanInteractionCapability ¶
HumanInteractionCapability(*, registry: InteractionRegistry, tokens: PauseTokenService, payloads: PausePayloadStore, resumes: ResumeService, binding: Callable[[], Any] | None = None, encode_token: Callable[[Any], str] | None = None, decode_token: Callable[[str], Any] | None = None, turns: TurnCheckpointStore | None = None)
Registrations, tokens, checkpoint commands, and resume, wired once.
Source code in src/symfonic/capabilities/human/capability.py
active
property
¶
True when at least one interaction is registered.
A deployment that registered none must not advertise ask_user: a
tool whose only possible outcome is a refusal is an invitation to pause
a run that can never be resumed.
compile
classmethod
¶
compile(registrations: Iterable[InteractionRegistration], *, signer: Any, ttl: TTLPolicy, consumption: Any = None, ledger: Any = None, checkpoints: Any = None, clock: Callable[[], float] = time.time, pinless_policy: Any = None, audit: Callable[[CrossScopeRedemption], None] | None = None, require_durable: bool = True, binding: Callable[[], Any] | None = None, encode_token: Callable[[Any], str] | None = None, decode_token: Callable[[str], Any] | None = None) -> HumanInteractionCapability
Wire the capability. Every argument is a port or a policy.
Source code in src/symfonic/capabilities/human/capability.py
contribute ¶
Offer the pause point to the turn being compiled (HK1, TA8.34).
A stage and a tool, and :mod:~symfonic.capabilities.human.contribution
holds the reasoning for why both: the tool is how the model asks, the
pre-tool stage is where the run actually stops, and only the stage
sees the reserved call id a pause has to be bound to.
Contributing nothing is a real answer, the same one
DelegationCapability gives for a parent with no children. Three
states produce it, and each is a deployment that cannot serve a pause:
nothing registered, no per-run :class:PauseBinding resolver, or no
way to render a minted envelope as the opaque token a consumer answers
with. Advertising ask_user in any of them would invite the model to
stop a run that could never be resumed -- and a run stopped by a pause
nobody can answer is strictly worse than one that never stopped. The
contribution still carries the capability's name, so a plan records
that human interaction was folded and found nothing rather than that it
was never folded.
request is read for its grants and found to need none. Minting a
token, recording its payload and writing the issuance row all go
through this capability's own ports, which the composition root wired;
none of them is an :class:~symfonic.kernel.contracts.effects.EffectFamily
the plan grants, and declaring one it was not granted is refused at
fold rather than at the point of the effect (STG-8).
Source code in src/symfonic/capabilities/human/capability.py
pause
async
¶
pause(*, pin: Any, scope: Any, run_id: str, session_id: str, thread_id: str, payload: Any, root_run_id: str = '', name: str = ASK_USER, tool_call_id: str = '', checkpoint_id: str | None = None, ttl_seconds: float | None = None, legacy_pinned: bool = False, turn_state: TurnCheckpoint | None = None) -> InteractionEvent
Mint a pause, record its payload, and record the turn it stopped.
turn_state is what makes the pause redeemable (HK2). It is optional
because a caller may have nothing continuable to record -- a transport
minting a pause outside a kernel turn, for instance -- and the returned
event then says resumable=False rather than pretending otherwise.
Source code in src/symfonic/capabilities/human/capability.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 | |