Expand description
Tasks in the engine (H2, C0 1.9 §1): read a project’s tasks, claim one, report short summaries, submit one result with evidence, give it back.
The rules the engine keeps:
- No tool call waits for Cloud (
cache): reads answer from the last data Cloud sent and say when it is stale; changes are queued, and what Cloud answered comes with the caller’s next call. Each queued request ends withinBUDGET; offline or a lapsed lease answers at once. - A claim passes the worker gate first (
worker::admit_claim, L1: the engine’s opt-in for the repo, pause, today’s budget) and goes out under that opt-in; a result passesworker::admit_submit. Cloud checks the same opt-in again (optin_scope,optin_inactive,daily_budget,optin_changed,vetoed); every refusal is shown as it is, anoptin_changedclaim reads the opt-in again once, and a stopped opt-in ends this machine’s claims. - The claim’s lease id and fencing token stay on this machine
(
claims, 0600) and are never printed. This process renews its claims while it runs (keeper) and gives them back on stop. - Text leaving the machine (summaries, proposals, release reasons) passes the outbox screening; a text it refuses is not sent, never rewritten.
- Text arriving from Cloud (titles, goals, summaries of people and other
agents) reaches the agent only fenced as foreign data
(
crate::untrusted::wrap, X5). - Cloud announces claims, releases and results on the bus itself; the engine sends no task frames.
Modules§
- cache
ctx_taskswithout waiting for Cloud (connector rule “Cloud never blocks a tool call”).- claims
- The task claims this machine holds:
<data>/cloud/task-claims.json, 0600. Only the holder ever learns a claim’s lease id and fencing token, so they are kept here and never printed. - fields
- A task’s priority and labels (C0 2.2 E47): the order of work on a board.
- gate
- G6 in the Instance (process v1 §5): the locked-path check on submit and before verify, and the gate’s own rerun of the declared command at the judged commit. Both run here, in the Instance’s process, never through an agent’s shell.
- local
- Local tasks (lean-ctx-tasks) for a project that is not linked to a Cloud vault: where its store lives, which projects use it, the bus notices of every transition and how an agent reads them.
- propose
- Task proposals through the outbox (
taskschannel): an agent task the agent asks for, or a contradiction between two facts (lean-ctx-ae queues those). A proposal is screened when it is queued;ctx_tasks proposesends it at once off the tool call (send_now), and the scheduler andlean-ctx cloud syncsend what is still queued. Cloud answers with the task’s state: a member agent’s task is open at once (owners and maintainers may close it afterwards); a Cloud that still asks for approval answersproposed, and that is what is reported. - reads
- Task reads shared by every process of this Instance (owner 09.11.: Cloud takes large request volumes and does not block at the first limit).
Structs§
- Amend
Input - What an amendment of a result says (see
amend). - Claim
Granted - A granted claim, as the caller may see it (no lease id, no token).
- Connected
- A connected machine, its lease and the Cloud project of a local root.
- Evidence
Input - One piece of evidence as a caller names it.
- List
Filter GET …/tasksfilters.- Task
Listing - A task list as the Instance shows it.
- Task
View - A task as the agent reads it: the view and its local claim.
Constants§
- ABANDONED_
REASON - The reason Cloud records when the daemon gives an abandoned claim back.
- AMEND_
ROUTE - The Cloud route an amendment needs and no Cloud serves yet.
- BUDGET
- The time one task call may take in all.
- DEFAULT_
CLAIM_ MINUTES - Claim length when the caller names none.
- PARTIAL_
NOTE - The line under a partial listing.
Functions§
- adopt_
claims - Take over the unexpired claims
agentholds on this machine (a new session of the same agent) and keep them renewed. - amend
- Amend the result of vault task
numberasagent(the rules oflean_ctx_protocol::cloud::tasks::amend_ruleandmay_amend). Fails closed: it checks the request, the screening and the task (read only) and then refuses, sending nothing, because no Cloud servesAMEND_ROUTEyet; the task stays unchanged. - briefing
- What a session starts with (H2): the claims this machine holds in the
project, then its open tasks from the task cache (a refresh is queued
when they are stale;
cache).Nonewhen Cloud does not apply or there is nothing to say. Never waits for Cloud. - claim
- Claim task
numberfor bus agentagentin sessionsession_id. - claim_
root - The checkout to act on claim
numberfrom:project_root, unless its vault holds no claim ofagentonnumberwhile exactly one other vault does. An agent’s session often runs in another repository than the one it claimed in (the claim names its checkout), and the task number alone then finds the claim the agent holds. - connected
- Whether tasks apply to
project_rootwithright;Errsays why not (no request made). - keep_
cli_ claims - Keep CLI claims alive (lean-ctx #3):
lean-ctx cloud tasks claimends right after claiming, so nothing renewed its claim and an agent running a long gate lost it before submitting. The bus relay’s process renews a claim whose holder has ended at half-time while the claiming agent still works on this machine (registered, not finished, active withinRENEW_IDLE), without becoming its holder; once the agent stops working the claim ends at its expiry in Cloud. Returns how many such claims it kept. - list
- The project’s tasks (shared and coalesced per Instance,
reads). Only a current list: when Cloud holds reads or is not reachable this is an error, not the last good list (list_readserves that with its age), so no caller takes tasks since claimed or closed for current. - list_
read listand, when Cloud holds reads (429) or is not reachable, the age of the last good list served instead.- register_
idle_ clock - Register the idle clock of the served MCP session (
server::mcp_idle, when it starts serving). The first registration wins. Without one the process serves no session and is never idle, so claim renewal runs. - release
- Give task
numberback;reasonis one line. - release_
abandoned_ claims - Give back the claims nobody works on any more (k2 E2E: an ended session’s claim was neither renewed nor released, so nobody else could take the task): a claim that has expired, or whose holding process has ended while its agent no longer works on this machine. Runs in the daemon (the bus relay’s process); returns how many Cloud released.
- release_
own_ claims - Give back every claim this process holds (worker stop, shutdown); returns how many Cloud released. A claim Cloud cannot be reached for is forgotten here and ends at its expiry there.
- render_
list - The first
limittasks oflist, one line each. - render_
listing render_listof a listing; a partial one says so under the tasks.- render_
result_ ack - What a result did, from Cloud’s answer:
submittedwaits for a second agent’s check,doneorfailedends the task. - render_
task - One task with its updates and result.
- render_
verify_ ack - What a verdict did (C0 2.2 E48):
done, oropenagain. - show
- One task (shared and coalesced per Instance,
reads). Only a current answer: when Cloud holds reads or is not reachable this is an error, not the last good answer (show_readserves that with its age). - show_
read showand, when Cloud holds reads (429) or is not reachable, the age of the last good answer served instead. A task Cloud does not know isCloudError::NotFound; a rate limit never reads as one.- submit
- Submit the result of the claimed task
number: it ends the claim. The task waits for a second agent’s check (submitted), or ends at once (done, orfailedforTaskOutcome::Failed). - update
- Report one short summary on the claimed task
number. When the claim lapsed while the agent worked (Cloud: stale claim), the task is claimed again for it and the summary sent once more; another agent’s claim refuses that. - verify
- Check the submitted result of task
numberasagent(C0 2.2 E48):acceptmakes it done,reject(with its reason) opens it again. The agent names itself as on its claims; Cloud refuses the agent that did the work (self_verify) and a task that is not submitted.
Type Aliases§
- Idle
Clock - How long the MCP session this process serves has had no tool call in
flight;
Nonewhile a call runs or when no session is served.