Expand description
The protocol between the rig launcher (the rig crate’s binary) and the
rig-harness agent it builds and runs: the RIG_HOME layout, session ids,
the environment the launcher passes to the agent, and the exit code with
which the agent asks for a restart. The launcher and rig-harness both use
this crate, so the two sides cannot drift apart. It uses only std, and
it changes with rig-harness.
Modules§
- env
- The environment variables of the protocol.
Structs§
- Agent
Description - What a built agent’s plugins add to the command line, as the agent
writes it when the launcher sets
env::DESCRIBE: their commands, their options and the secrets they ask for, and the plugins whose agent-loop systems clash, forrig plugin check --build. The launcher keeps one per build (Home::described) and reads the command line against it. - Described
Command - A plugin’s command,
rig <name> <usage>. - Described
Flag - A plugin’s option,
--nameor--name VALUE. - Described
Secret - A secret a plugin asks for, which reaches the agent as
secret_variableof its name. - Home
- The
RIG_HOMElayout. Every file the launcher and the agent write lives under this one root. - Invocation
- The agent’s arguments, in the canonical form the launcher passes on
(
Invocation::to_args): the model, each plugin option as--name=VALUE, then the print prompt after--print --, or a plugin’s command and its arguments. The launcher reads the user’s command line against the agent’sAgentDescriptionreport first (AgentDescription::invocation), sorig -p "…"and the agent binary run alone agree on them. - RunDir
- A launcher’s own directory, outside every session, which lives while the launcher runs: the file that tells it the agent started, and the log of a sessionless run that failed, which outlives the launcher.
- Session
Dir - A session’s directory. The agent keeps the session there through its
store, which a plugin may replace (by default in the folders
logs,blobsandfiles), so only the plain files beside the store are named here: the markers of a session an agent started in (Self::started), logged to (Self::is_saved) and being deleted (Self::is_deleting), the text log, the lock of the launcher running it, its working directory, its name and the session to switch to. - Session
Id - A session’s id: digits and dashes, so it is safe as a path segment. The launcher makes one per new session; the agent makes its own when it runs without the launcher.
Enums§
- Start
Reason - Why the agent process started, which the launcher passes in
env::START. A switch to another session (/new,/resume) starts it asNeworResumed; a crash is no reason, since the launcher never restarts a crashed agent.
Constants§
- BEVY_
VERSION - The one Bevy version of the agent and of every plugin: a Bevy plugin only works with the exact Bevy version of its app.
- ESSENTIAL_
PLUGINS - The plugins whose absence takes away the way back from inside the
agent, by type path, with what goes:
rig plugin disable,rig plugin listand/pluginswarn on them.rig plugin enablefrom a shell always brings one back. - INVOCATION_
USAGE - The arguments
Invocation::parsetakes, for usage texts. - RELOAD_
EXIT_ CODE - The exit code with which the agent asks its launcher to restart it on the staged build.
- RESERVED_
COMMANDS - The launcher’s own first words, which no plugin’s command may take.
- VERSION
- The version of rig: of the workspace, the launcher and the harness they build together. It stamps generated projects, so a new launcher regenerates and rebuilds the agent; a plugin reads it to say which rig wrote something.
Functions§
- essential
- What goes when the plugin
type_pathis left out, if it is one of theESSENTIAL_PLUGINS. - first_
errors - At most
countlines of a build’s output from the first one that starts witherror, as cargo writes a compiler error; none when no line does. - is_free
- Whether no live process holds the lock file at
path: it is missing, or it can be locked now. A failure that hides the answer counts as held. - is_name
- Whether
namecan name a plugin’s option or command: lowercase ASCII letters, digits and dashes, starting with a letter. - launcher
- The launcher that started this agent, if one did: it sets both
env::LAUNCHERandenv::SESSION. A nested agent, run by this agent’s shell, inherits only the launcher’s path, which the model uses. - lock_
file - Opens the lock file at
pathfor writing, creating it whencreate. Every lock between launchers and agents is such a file, held withstd::fs::File::try_lockorstd::fs::File::lock. - secret_
variable - The variable that carries the secret
name:env::SECRET_PREFIXand the name in upper case,-as_(cryptisRIG_SECRET_CRYPT). - secret_
variables - Every secret variable (
env::SECRET_PREFIX) in this process’s environment: what a process this one starts must not inherit.