Skip to main content

Module agents

Module agents 

Source

Modules§

friction
Friction signals of agent coordination, counted locally for the retro loop: <data>/agents/friction.jsonl, one {"at", "signal", "agent"?, "root"?} line per event (fixed keys and ids, never message text), summed by lean-ctx agent friction [--since <dur>] and per hour, worker and vault by the Cloud connector’s friction counter for the vault bus (V16.1).
host_mirror
Mirror of a host’s own agent-to-agent message (Claude Code SendMessage) onto the local bus scratchpad, so ctx_agent read and the dashboard see direct traffic the host delivers outside lean-ctx.

Structs§

AgentDiary
AgentEntry
AgentRegistry
ContextDepthConfig
DiaryEntry
Directive
One directive for one local agent.
DirectiveIssue
A directive to issue, as the Cloud relay builds it.
DirectiveStore
<agents>/directives.json.
FileLock
LogicalSessionPresence
ProcessIdentityIndex
Compatibility store for process identities.
Release
What DirectiveStore::release_offered did.
ReleaseBody
What the person confirmed in LeanCTX Code for one release of a plan directive (the JSON cloud plan release reads on stdin): the version, the plan’s goal, and the agent’s own brief (null for an agent no part of the plan names). Nothing else is accepted.
ScratchpadEntry
StatedRoles
What LEAN_CTX_ROLE and LEAN_CTX_AGENT_ROLE state, blank values unset.
TransportClient
The host behind an MCP transport, from the initialize handshake.

Enums§

AgentRole
AgentStatus
DiaryEntryType
DirectiveKind
What changed.
DirectiveState
Where the agent stands with one directive.
ReleaseError
Why DirectiveStore::release_offered released nothing.
RoleSource
Verdict
The agent’s answer.

Constants§

ACQUIRE_TIMEOUT
How long FileLock::acquire waits without progress. Threads of this process queue for a crate::core::file_lock::Turn first, and that wait restarts at every handover, so a moving queue never times out; the file lock itself is then polled (25 ms steps) for at most this long, which bounds other processes. Before (GitLab #1295) a waiter behind writers that took it back to back could pass the former 750 ms and fail its tool call. A dead holder’s lock is released by the OS, so waiting longer never makes a stale lock permanent; it only lets a contended call through.
BINDING_METADATA_KEY
Metadata key under which a bus message carries its admission binding. The on-disk shape of ScratchpadEntry is unchanged: metadata already is a string map, and an entry written before bindings existed simply has no such key (the legacy rule of context_admission::stored applies to it).
CLOUD_INBOUND_KEY_PREFIX
Idempotency-key prefix of bus entries another machine’s worker delivered through Cloud (the relay writes them with it).
DIRECTIVE_CATEGORY
The bus category of a directive entry.
DIRECTIVE_SENDER
The sender every directive entry carries on the local bus.
ENGINE_PLACEHOLDER_ROLE
The role an MCP server registers before any agent states one.
MAX_BRIEF_BYTES
Bytes of a released brief (the body’s 8000 characters, UTF-8).
MAX_DIARY_FILE_BYTES
The largest diary file any load reads (100 entries of ordinary agent notes stay far below it).
MAX_GOAL_BYTES
Bytes of a released plan goal (the body’s 4000 characters, UTF-8).
MAX_PROJECT_DIARY_FILES
The most diary files AgentDiary::load_all_for_project reads.
MAX_ROLE_ID_BYTES
Longest role id, in bytes.
REFUSE_REASONS
Reason codes an agent may refuse a directive with (§37.4).
RELEASE_IDS_FILE
The file next to directives.json that holds the release ids of the offered directives ({release_sha256: release_id}, mode 0600). Its name is a secret path (crate::core::io_boundary::is_secret_like): no ctx_* read, search or shell tool and no hooked native read opens it.
UNKNOWN_RELEASE_ID
The error of DirectiveStore::release_offered for a well-formed id no directive carries.

Functions§

ack_hint
How an agent answers directive_id (the last line of every directive).
brief_digest
sha256:<64 hex> of text’s UTF-8 bytes.
declared_permission_role
The permission role stated through the environment: LEAN_CTX_ROLE only. LEAN_CTX_AGENT_ROLE names the agent on the bus (a host such as LeanCTX Code sets it per worker) and never chooses what tools may do.
declared_session_role
The session role stated through the environment (LEAN_CTX_ROLE, then LEAN_CTX_AGENT_ROLE). Anything else an MCP session gets is assumed.
directives_modified
When the records last changed; None while there are none.
is_release_id
Whether rid has the shape of a release id (64 lowercase hex). A directive id (<plan>:<v>:<slot>) never has it.
pending_line
The one-line reminder of a pending directive (stable text, #498).
pending_lines
The reminder lines for agent_id, sorted; None when nothing is pending.
pending_suffix_for
pending_lines for agent_id from disk, re-read only when the file changed: the tool pipeline asks on every call.
register_announce
Register the announce request; the first registration wins.
release_text
The one bus entry a released directive becomes. A plan’s entry is the plan id and version, body’s goal, this agent’s own brief (or, for a plan-wide directive, that no part names it) and how to answer: no other part, no other version, no release id. A decision keeps its text and takes no body.
request_id_conflict
The refusal of a key reused with another request; content-free.
role_id
raw as a role id (coder, reviewer, docs-writer, …): trimmed and lower-cased, 1–48 bytes of [a-z0-9_-] starting with a letter. Free text (a session or display name such as “LeanCTX · Contracts”) is no role id: None, and the caller names it a display name instead.
stated_roles
take_renewed
Whether agent_id’s registration had expired and was renewed since the last call (each renewal is reported once).