pub trait TurnClaimStore:
Send
+ Sync
+ 'static {
// Required methods
fn claim<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
owner: &'a str,
token: &'a str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>;
fn release<'a>(
&'a self,
token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>;
fn renew<'a>(
&'a self,
owner: &'a str,
tokens: &'a [String],
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<HeldClaim>, A2aError>> + Send + 'a>>;
fn request_cancel<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>;
fn sweep(
&self,
older_than: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + '_>>;
// Provided methods
fn abandoned(
&self,
quiet: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>> { ... }
fn abandoned_except_handed_off(
&self,
quiet: Duration,
hand_off_window: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>> { ... }
fn ended_unreleased(
&self,
quiet: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>> { ... }
fn hand_steering<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
message: &'a str,
capacity: usize,
) -> Pin<Box<dyn Future<Output = Result<Handed, A2aError>> + Send + 'a>> { ... }
fn peek_steering<'a>(
&'a self,
owner: &'a str,
tokens: &'a [String],
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<PendingSteering>, A2aError>> + Send + 'a>> { ... }
fn ack_steering<'a>(
&'a self,
seqs: &'a [i64],
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>> { ... }
fn steering_signals(&self) -> Option<Receiver<()>> { ... }
}Expand description
Where turn claims are kept. See the module documentation.
Every method is one atomic step against storage every replica shares.
Required Methods§
Sourcefn claim<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
owner: &'a str,
token: &'a str,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn claim<'a>( &'a self, scope: &'a str, task_id: &'a str, owner: &'a str, token: &'a str, ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
Claims the task for one turn: inserts the claim, or takes over one
whose time to live has passed. true when this call holds it now,
false when a live claim is held by any turn, this owner’s included.
A store that may run the claim a second time for one call, as the
PostgreSQL store does when the first run lost its connection, answers
true when the claim already carries token: that claim is this
call’s, taken by the run whose answer was lost.
§Errors
The storage’s.
Sourcefn release<'a>(
&'a self,
token: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn release<'a>( &'a self, token: &'a str, ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Deletes the claim token names, if it still holds one. A claim taken
over since is not touched.
§Errors
The storage’s.
Sourcefn renew<'a>(
&'a self,
owner: &'a str,
tokens: &'a [String],
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<Vec<HeldClaim>, A2aError>> + Send + 'a>>
fn renew<'a>( &'a self, owner: &'a str, tokens: &'a [String], ttl: Duration, ) -> Pin<Box<dyn Future<Output = Result<Vec<HeldClaim>, A2aError>> + Send + 'a>>
Extends the claims among tokens that owner still holds to ttl
from now, and reports each one. A token missing from the answer was
taken over or released.
Only the named tokens are extended, never every claim of the owner: a claim the owner no longer tracks (a release that failed, a request dropped while its claim was being written) must expire after its time to live rather than be kept alive by the owner’s other turns.
§Errors
The storage’s.
Sourcefn request_cancel<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
fn request_cancel<'a>( &'a self, scope: &'a str, task_id: &'a str, ) -> Pin<Box<dyn Future<Output = Result<bool, A2aError>> + Send + 'a>>
Marks the live claim on the task, if there is one, so its owner cancels the turn at its next renewal. Whether a claim was marked.
§Errors
The storage’s.
Sourcefn sweep(
&self,
older_than: Duration,
) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + '_>>
fn sweep( &self, older_than: Duration, ) -> Pin<Box<dyn Future<Output = Result<u64, A2aError>> + Send + '_>>
Deletes claims that expired more than older_than ago: left by a
replica that died and never continued. Bounded housekeeping, run by
the renewer now and then; a claim that expired is already free to
take, so this changes no decision.
§Errors
The storage’s.
Provided Methods§
Sourcefn abandoned(
&self,
quiet: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
fn abandoned( &self, quiet: Duration, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
Tasks a turn left running and nobody runs: submitted or working,
no live claim on them, and not written for quiet. At most limit,
as (scope, task_id), the oldest first. What the handler’s reaper
ends (handler::claims::reaper): a replica that died mid-turn, or
stopped its executor past the grace, left them so, and until
2026-10-29 nothing finished them (audit E-F1, run live).
A task a shutdown handed back to its caller (its status message’s
metadata carries executor::HAND_OFF_METADATA_KEY) is left out until
its status is HAND_OFF_WINDOW
old (or the window abandoned_except_handed_off
is given): its caller continues it, and only one nobody continued is the
reaper’s (ADR 0054). Without this a deploy that hands off more turns
than a look ends would fill every look with tasks it must leave.
The default finds none: a claim store that does not share a database with its tasks cannot see them.
§Errors
The storage’s.
Sourcefn abandoned_except_handed_off(
&self,
quiet: Duration,
hand_off_window: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
fn abandoned_except_handed_off( &self, quiet: Duration, hand_off_window: Duration, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
abandoned, leaving out a task handed back to its
caller less than hand_off_window ago (ADR 0054). The reaper calls
this, with HandlerLimits::hand_off_window. The default ignores the
window and asks abandoned, so a claim store of your own keeps
working; the SQL stores bind it, and their abandoned uses
HAND_OFF_WINDOW.
§Errors
The storage’s.
Sourcefn ended_unreleased(
&self,
quiet: Duration,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
fn ended_unreleased( &self, quiet: Duration, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>, A2aError>> + Send + '_>>
Tasks that are finished whose claim is still there and expired for
at least quiet: a turn that did not end the way a turn ends.
A turn that ends releases its claim. A claim that stayed, behind a
terminal task, means the replica holding it stopped (killed, out of
memory, its node gone) after the task reached its terminal state and
before it finished what follows it: the terminal event in the log, the
webhooks, the audit record. The state can reach the store without the
owner: a CancelTask taken on another replica stores canceled and
leaves the ending to the owner’s own processor. The reaper
(abandoned finds the running tasks) calls this to
complete what is missing and release the claim.
Each entry is (scope, task_id), oldest claim first, at most limit.
The default, for a store that has no task table to look in, is none.
§Errors
The storage’s.
Sourcefn hand_steering<'a>(
&'a self,
scope: &'a str,
task_id: &'a str,
message: &'a str,
capacity: usize,
) -> Pin<Box<dyn Future<Output = Result<Handed, A2aError>> + Send + 'a>>
fn hand_steering<'a>( &'a self, scope: &'a str, task_id: &'a str, message: &'a str, capacity: usize, ) -> Pin<Box<dyn Future<Output = Result<Handed, A2aError>> + Send + 'a>>
Stores a steering message (ADR 0036) for the replica that holds the
live claim on the task, unless that claim’s queue already holds
capacity messages. One atomic step: the claim is checked and the
message stored together, so a message is never stored for a claim that
was released first. message is the JSON the holder reads back from
peek_steering; the store does not read it.
What not overriding it costs: the default answers
Handed::Unsupported, so a steering message that reaches a replica
other than the one running the turn is refused instead of delivered.
A server whose turns are always routed to one replica, or that has one
replica, is unaffected. The bundled stores override it, and the
in-memory one is for tests that run several handlers in one process.
§Errors
The storage’s.
Sourcefn peek_steering<'a>(
&'a self,
owner: &'a str,
tokens: &'a [String],
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<PendingSteering>, A2aError>> + Send + 'a>>
fn peek_steering<'a>( &'a self, owner: &'a str, tokens: &'a [String], limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<PendingSteering>, A2aError>> + Send + 'a>>
The steering messages stored for the live claims among tokens that
owner holds, oldest first, at most limit. Reads only: a message
stays until ack_steering names it, so one that
does not fit its turn’s inbox now is offered again at the next look.
What not overriding it costs: the default finds none, so a message
another replica stored for this one is never delivered (it waits until
its claim ends). Override it together with
hand_steering.
§Errors
The storage’s.
Sourcefn ack_steering<'a>(
&'a self,
seqs: &'a [i64],
) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
fn ack_steering<'a>( &'a self, seqs: &'a [i64], ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'a>>
Deletes the steering messages seqs names, once they are in their
turns’ inboxes. Names that are already gone are ignored.
What not overriding it costs: nothing is ever deleted, so a store that
overrides peek_steering alone delivers each
message again at every look. Override all three, or none.
§Errors
The storage’s.
Sourcefn steering_signals(&self) -> Option<Receiver<()>>
fn steering_signals(&self) -> Option<Receiver<()>>
A signal that hand_steering stored a message,
from whichever replica, for the handler to look at once rather than at
its next poll; None when the store sends none.
What not overriding it costs: a handed-off message waits for the handler’s next poll, at the claim renewal interval (one second by default) instead of arriving at once. Correctness does not depend on it: a signal that is lost or never sent is made up by the poll.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".