Skip to main content

Module lineage

Module lineage 

Source
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.

  • root names the job: 1 to MAX_LINEAGE_ID_BYTES bytes with no control character. A message with no lineage starts a job, whose root is the message’s contextId.
  • depth is the sender’s depth plus one; 0 is the job’s first task. It is at most MAX_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.
LineageNode
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.metadata and Task.metadata key 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 root or parentTaskId may be, in bytes: the default max_id_length of a2a-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 of tasks belong to it.