Skip to main content

Module tasks

Module tasks 

Source
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 within BUDGET; 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 passes worker::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, an optin_changed claim 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_tasks without 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 (tasks channel): 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 propose sends it at once off the tool call (send_now), and the scheduler and lean-ctx cloud sync send 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 answers proposed, 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§

AmendInput
What an amendment of a result says (see amend).
ClaimGranted
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.
EvidenceInput
One piece of evidence as a caller names it.
ListFilter
GET …/tasks filters.
TaskListing
A task list as the Instance shows it.
TaskView
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 agent holds on this machine (a new session of the same agent) and keep them renewed.
amend
Amend the result of vault task number as agent (the rules of lean_ctx_protocol::cloud::tasks::amend_rule and may_amend). Fails closed: it checks the request, the screening and the task (read only) and then refuses, sending nothing, because no Cloud serves AMEND_ROUTE yet; 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). None when Cloud does not apply or there is nothing to say. Never waits for Cloud.
claim
Claim task number for bus agent agent in session session_id.
claim_root
The checkout to act on claim number from: project_root, unless its vault holds no claim of agent on number while 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_root with right; Err says why not (no request made).
keep_cli_claims
Keep CLI claims alive (lean-ctx #3): lean-ctx cloud tasks claim ends 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 within RENEW_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_read serves that with its age), so no caller takes tasks since claimed or closed for current.
list_read
list and, 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 number back; reason is 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 limit tasks of list, one line each.
render_listing
render_list of a listing; a partial one says so under the tasks.
render_result_ack
What a result did, from Cloud’s answer: submitted waits for a second agent’s check, done or failed ends the task.
render_task
One task with its updates and result.
render_verify_ack
What a verdict did (C0 2.2 E48): done, or open again.
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_read serves that with its age).
show_read
show and, when Cloud holds reads (429) or is not reachable, the age of the last good answer served instead. A task Cloud does not know is CloudError::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, or failed for TaskOutcome::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 number as agent (C0 2.2 E48): accept makes 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§

IdleClock
How long the MCP session this process serves has had no tool call in flight; None while a call runs or when no session is served.