Expand description
Which capsule delegated to this one, and how a delegated child says that it finished.
A child launched by crate::child_launch knows its spawner from one injected environment
variable, SPAWNER_ENV, and from nothing it inherited: the parent’s launcher composes a
SpawnerHandle and applies it in the runtime-owned tail of the child’s environment. A
capsule launched any other way has no handle, records no lineage and contacts nothing.
Knowing your parent and reporting to it are separate. Every handle names the session that
spawned this one and the delegation that created it, which is what the child writes into its
own session_start. Only a handle carrying a CompletionAddress also has somewhere to post
an outcome: a parent that waits on the connection it already holds — every delegation made
through crate::delegation_plane — supplies none, so its child is attributable without
anything being sent anywhere.
The completion names the delegation; the parent’s runtime hands over the answer. Every
field of DelegationOutcome is composed by a runtime — ids, a status word, a path, a
duration — and the one input that could grow, the crash detail, is capped twice: at the 20
stderr lines child_launch retains, and again at MAX_DETAIL_BYTES. Neither
COMPLETION_FILE nor the posted message carries the child’s output. The child leaves its
answer in a result file in its own directories, and the parent’s runtime reads it there itself,
through the child directories it holds, once the child has exited: [result_block] puts it
under a result: line in what the delegating task is told, inside the delegation:<capsule>
fence [outcomes_message] applies. An answer over
[crate::delegation_plane::MAX_OUTPUT_BYTES] is cut there with the cut marked, and the whole
text is kept in the parent’s runtime directory, which every kind of tool reads
([hand_over_answer]). The parent’s commands cannot read the children’s records directories.
Two reporters, one arrival path. The child reports for itself at the end of its own session;
the completion watcher behind the parent’s crate::child_launch::LaunchedChild reports for
a child that could not. Both write COMPLETION_FILE into the child’s directory and both post
the same JSON-RPC SendMessage to the parent’s A2A door. The door hands it to the task that
made the delegation, which reads this file and continues its conversation with
[outcomes_message]; it never becomes a task of its own. A completion that cannot be
delivered is recorded in that file with delivered: false and the refusal’s reason, and a
line goes to stderr; it is not retried beyond the launcher’s single retry and it is not
silently discarded.
Structs§
- Completion
Address - Where a completion is posted.
- Delegation
Outcome - What a delegation left behind: the notification the parent receives, and the shape of
COMPLETION_FILE. - Spawner
- The parent a delegated child belongs to, supplied by the parent at launch.
- Spawner
Handle - The value injected into the child: a
Spawnerplus the delegation id the launcher minted.
Enums§
- Delegation
Status - How a delegated child ended.
- Reporter
- Which of the two reporters built a completion.
Constants§
- COMPLETION_
FILE - The child’s own record of how it ended, in the child’s records directory.
- COMPLETION_
SESSION_ HEADER - Header naming the session a completion is addressed to.
- DELEGATION_
ID_ HEADER - Header naming the delegation a completion reports on. Read by the parent’s door only for a
request classified
completion, which hands the delegation’s outcome to the task that made it. - DELEGATION_
ID_ PREFIX - Prefix on every delegation id. Distinct from
tsk_/ctx_/ses_/wrk_, so a reader oftrace.jsonlcan tell at a glance which id space a value belongs to. - MAX_
DETAIL_ BYTES - Ceiling on
DelegationOutcome::detail, the one field built from something a child wrote. - PARENT_
ENDED_ DETAIL - The
detaila launcher records inCOMPLETION_FILEfor a child its parent ended on purpose: through the handle adelegate-taskcall left with its task, or from inside a plancapsulestep whose task was cancelled. - SPAWNER_
ENV - The variable the parent’s launcher injects into a delegated child, carrying its
SpawnerHandleas compact JSON.
Functions§
- deliver_
completion - Post one completion to the parent’s A2A door.
- new_
delegation_ id - A fresh delegation id, matching
^dlg_[0-9a-f]+$. - read_
completion - The completion the child recorded, or
Nonewhen it recorded none. - record_
terminated - Record a delegation the parent ended itself, without posting it.
- report_
completion - Record
outcomein the child’s records directory, post it, and record what the posting did. - write_
completion - Write
outcometoCOMPLETION_FILEin the child’s records directory, replacing whatever was there.