Skip to main content

Module app_query

Module app_query 

Source
Expand description

App query block: reads AgentMux’s own state, read-only (the Drone real-world jobs spec §4.2). Deterministic and free: no agent turn, no network.

Block config (node.data):

  • query required, one of:
    • muxbus whether cloud messages are reaching this machine.
    • agents every agent this machine has: how many it wants running, and which of them are not.
    • agent one agent’s availability. Needs agent, its name, written in the graph.
    • tasks Kanban tasks, filtered by holder, state and pr (each optional).
    • lan_peers the other machines this one sees on the LAN, and whether each answered lately.
    • jobs recent job runs: one job’s with job, else the newest run of every job.
    • memory one Global Memory entry, by id or name (entry), read-only. Needs entry, written in the graph. An entry of the system tier is not offered. Nothing here writes Memory.
    • presence which agents on this machine are working on a repository, a path or a branch (repo, path, branch; at least one), from their own work facts. Names, state and how each matched; no goals, no file names, and claims and posts are not read.
  • agent, job, entry the agent’s, the job’s or the Memory entry’s name (a job’s or an entry’s id works too). Never a {{reference}}: a value from outside must not pick whose state the graph reads (§6.2).
  • holder, state, pr task filters. They only find tasks, so each may be built from a {{reference}} (a PR url from the trigger). pr matches a task’s PR link exactly.
  • repo, path, branch the presence filters. They only find who is working there, so each may be built from a {{reference}}.
  • max_chars memory, how much of the entry to return (default 4000, at most 20000).
  • limit tasks and jobs, how many to return (tasks: default 50, at most 200; jobs: default 20, at most 100).

Output, by query:

  • muxbus: { "state", "connected", "signed_in", "since_ms", "last_ok_ms"?, "last_error"? }.
  • agents: { "count": N, "wanted_running": W, "up": U, "all_up": bool, "problem_count": P, "problems": [{ "agent", "state", "detail"? }], "problem_names": "<name (state), ...>" }. An agent is up when it is wanted running and idle, working or waiting on the person; a wanted-running agent that is stopped, starting, limited, signed out or in error is a problem (at most 20 listed). all_up is true with no problem.
  • agent: { "found": bool, "ambiguous"?: true, "state"?, "would"?, "reason"?, ... }, the availability the Agents tool shows. found is false for a name no agent here has.
  • tasks: { "count": N, "tasks": [{ "num", "title", "state", "holder", "pr", "branch" }] }.
  • lan_peers: { "count": N, "answered": M, "peers": [{ "host", "channel", "version", "os", "agents", "last_seen_ms", "last_answered_ms"?, "answered" }] }. answered is true when the peer answered this machine’s own poll (asked every 30 s) in the last two minutes: it is up and reachable from here. It is not a signature check.
  • jobs: (scheduled, Drone and cloud jobs alike, as the run ledger holds them) { "found": bool, "count": N, "runs": [{ "id", "job_id", "job", "state", "outcome", "trigger", "summary", "started_ms", "ended_ms"?, "cost_usd"? }], "last_ok"? }; found is false for a job that matches none. With a job, last_ok is that job’s newest run that finished with outcome ok or findings (a run row, or null when there is none), found whatever limit cuts runs to.
  • memory: { "found": bool, "id"?, "name"?, "content"?, "chars"?, "truncated"? }; found is false for an entry nobody has (or the system tier), with ambiguous when two entries share the name.
  • presence: { "count": N, "agents": [{ "agent", "status", "repo"?, "branch"?, "matched": ["claim", "dirty", ...] }] }.

Every answer of this block is outside text to the run (the taint bits): what an entry or an agent’s branch says is not the graph’s own.

Structs§

JobsFilter 🔒
The filters of a jobs query: one job by name or id (empty is every job) and how many runs.
MemoryFilter 🔒
The filters of a memory query: one Global Memory entry, by id or name, and how much of it to return.
PresenceFilter 🔒
The filters of a presence query: what to ask who is working on; at least one is not empty.
TaskFilter 🔒
The filters of a tasks query; an empty one matches anything.

Enums§

Query 🔒
What the block asks.

Constants§

ANSWERED_WITHIN_SECS 🔒
A peer that answered this machine’s poll within this many seconds counts as answering (the poll is every 30 s, so four missed ones in a row).
DEFAULT_LIMIT 🔒
Tasks returned when the node gives no limit.
DEFAULT_MEMORY_CHARS 🔒
A Memory entry is cut to this many characters when the node gives no max_chars, and never to more than the cap.
DEFAULT_RUNS 🔒
Job runs returned when the node gives no limit, and the most one query returns.
FINISHED_WINDOW_DAYS 🔒
Finished tasks changed within this many days are still seen by a query.
MAX_LIMIT 🔒
The most tasks one query returns.
MAX_MEMORY_CHARS 🔒
MAX_PRESENCE 🔒
The most agents a presence query lists.
MAX_PROBLEMS 🔒
The most agents agents lists as a problem.
MAX_RUNS 🔒
RUN_SUMMARY_CHARS 🔒
A run’s summary is cut to this many characters.
SCAN_LIMIT 🔒
How many board tasks are read before filtering: every open task and the recently finished ones.

Functions§

agent_answer 🔒
agent: the availability view, with found first.
agents_answer 🔒
agents: how many agents the machine wants running and which of those are not up. Pure, so a test can hand it rows.
jobs_answer 🔒
jobs: the named job’s newest runs, or the newest run of every job, newest first, cut to the limit. A job is whatever the run ledger has runs of (scheduled, Drone and cloud jobs alike), and a scheduled job with no run yet.
lan_peers_answer 🔒
lan_peers: the machines on the LAN other than this one (a peer at one of this machine’s own addresses is another channel here), by host name, each with whether it answered the poll lately.
memory_answer 🔒
memory: the Global Memory entry whose id is f.entry, or whose name is (without regard to case), cut to f.max_chars. An entry of the system tier is not offered, and two entries with one name are not guessed between.
muxbus_answer 🔒
muxbus: the delivery state in the words a Condition reads.
plan 🔒
What the node asks, with the filters’ references resolved. Pure, so it is testable without a server.
poll_check 🔒
The question a poll trigger asks (backend::jobs::poll): the App query named by the filter’s query, with the filter’s own keys as its config and no references to resolve.
presence_answer 🔒
presence: the agents whose own work facts (their clones’ uncommitted changes, recent edits, branch and repository) touch what is asked. Claims and posts are not read. Only what Presence who shows of each agent that a graph needs: its name, its state and how it matched; no goal, no file names. Pure over the facts, so a test can hand it some.
run
run_row 🔒
One run, for the graph: what happened and when, with the summary cut.
tasks_answer 🔒
tasks: the tasks that match, newest first as the board lists them, cut to the limit.