Expand description
Task lineage: which job a task belongs to, and how far down the job’s tree it is (ADR 0034).
§The gap this closes
A2A has no link from a task to the tasks its agent starts on other
agents, so an operator could stop a whole server or a whole tenant but not
one job, and a job’s tree could be rebuilt only from trace ids (audit
H10). A lineage names the job by its root, counts the hops from it in
depth, and may name the task that delegated this one. A server halts a
job by its root (HaltScope::Root in a2a-protocol-server), and
tree arranges any set of tasks into the job’s tree.
§Wire shape
Not part of A2A v1.0. It ships as the declared extension
https://a2a-rust.com/extensions/lineage/v1, in the style of
lease and budget:
{"root": "...", "depth": n, "parentTaskId": "..."} in Message.metadata
under a2a-rust.com/lineage, and the URI in Message.extensions. A server
records the lineage a new task was sent with in Task.metadata under the
same key. The full contract, for an implementation in another language, is
the book’s “Swarm extensions” reference page, and the vectors in this
crate’s extensions/lineage-v1/ are run by its tests.
rootnames the job: 1 toMAX_LINEAGE_ID_BYTESbytes with no control character. A message with no lineage starts a job, whose root is the message’scontextId.depthis the sender’s depth plus one; 0 is the job’s first task. It is at mostMAX_LINEAGE_DEPTH.parentTaskId, optional, is the delegating task’s id on its own agent: an opaque name, not an address. A task at depth 0 has none.
A lineage is the caller’s claim. It scopes a halt and labels spans; it never authorizes anything (ADR 0034, Decision 4).
use a2a_protocol_types::lineage::Lineage;
use a2a_protocol_types::message::Message;
// The parent's own lineage: the job it serves, at depth 0.
let parent = Lineage::origin("job-42");
let mut message = Message::user_text("m1", "summarise these");
parent.child("parent-task-7").unwrap().attach(&mut message);
let read = Lineage::read(&message).unwrap().unwrap();
assert_eq!(read.root, "job-42");
assert_eq!(read.depth, 1);
assert_eq!(read.parent_task_id.as_deref(), Some("parent-task-7"));Structs§
- Lineage
- Where a task sits in its job’s tree. See the module docs.
- Lineage
Node - One task of a job’s tree, with the tasks it delegated.
Constants§
- LINEAGE_
EXTENSION_ URI - The extension URI a card declares and a message names in
extensions. - LINEAGE_
METADATA_ KEY - The
Message.metadataandTask.metadatakey a lineage travels under. - MAX_
LINEAGE_ DEPTH - The deepest a task may be: the same number of hops as the actor chain of ADR 0021, past which token exchange already fails.
- MAX_
LINEAGE_ ID_ BYTES - The longest a
rootorparentTaskIdmay be, in bytes: the defaultmax_id_lengthofa2a-protocol-server, so a context id that server accepts is a root its children accept.
Functions§
- tree
- The tree of the job
root, from whichever oftasksbelong to it.