vpf-runner 0.4.0

The reference runner of the Verifiable Plan Format (VPF): runs a plan step by step and proves each step.
Documentation

VPF runner

The reference runner of the Verifiable Plan Format (VPF). vpf-run runs a plan of VPF 1.1 in a folder, step by step: each step is done by an agent, an algorithm, a person or another plan, and a step starts only when every step it waits for has passed its proofs.

cargo install vpf-runner
vpf-run monthly-sales-report.vpf.json --agent "my-agent" --asked "March"

What it does

  • Checks the plan first, with the Rust SDK, and does not run a plan with problems. Tells the person of any date in the plan that has already passed.

  • Starts each step when the steps it waits for are done (after, or the step before) and its not_before has come. While no step can start, it waits for the soonest time.

  • Fills each reference before the text is used: {{id}}, {{id.field}} of a JSON answer, {{asked}} and {{item}}. A skipped step and a missing field give an empty text.

  • Takes the path a choice gives: an answer must be one of the step's choices, or end with one on its last line, and a step whose when names another answer is skipped.

  • Does a step with for_each once for each item of the answer it names, each proven and done again on its own, and answers with the JSON list of their answers. Asks the person before more than 200 items. The items are done at the same time, unless the step says one_by_one: then each item is proven before the next starts.

  • Gives a person's step, and a person's proof, to the people it names, filling references such as {{item}}.

  • Runs a plan's step as the plan it names, in the same folder, giving it the step's asked (its do when absent) as {{asked}}; the step's answer is the answer of that plan's last step. When asked holds named values, the references in every text inside them are filled, the other plan gets them as a JSON object in {{asked}}, and each one as {{asked.name}}.

  • Asks the proofs of a step in order, leaving out a proof whose when names another answer than the one given: it is kept as skipped, with the answer it is for and the one given, not asked, and does not refuse. The first that refuses sends the work back to who made it, with the points against it, and every proof is asked again from the first. A proof with back_to may send it back to earlier steps instead: the person picks them, an agent names them on a line Back to:, and a command writes their ids first, one per line. Those steps are done again with the points, then the steps between, then the refused step.

  • Asks the person before work that cannot be undone (irreversible) starts, telling them what the step does with its references filled, such as its command. A no stops the run, unless it says what is wrong and sends the work back to steps it waits for. It asks before each item and each new attempt. While such work is out, the run's record is kept, and the command's process, output and end are kept beside it: a run that stopped meanwhile waits for the command if it still runs and takes it as it ended. When that is not known, the step's proofs by commands that do not need its answer tell whether it was done; otherwise the person says. Once done, the person gives what it answered; not done, it is done again in a new attempt.

  • After limits.repeats refused attempts (3 when absent), asks the person whether to go on.

  • Refuses only the work of an agent that ends with an error, with the error as the points against it, kept in the attempt as failed, and goes on with the rest of the run; that work is done again like any refused work.

  • When a step passes its deadline, asks the person whether to wait until a later one, go on without the step, or stop.

  • Runs an algorithm's command in the folder. With on_fail: "agent", a failed command goes to an agent, and then the same command runs again as the first proof of the agent's work.

  • Stops a run at limits.deadline or limits.cost, and does not start a run once the month's runs of the plan reach limits.month. It tells the person when four fifths of the month are spent.

  • Keeps a record of each run in .vpf/runs/ in the folder: every step, its answers, each proof asked with its result and points, where refused work was sent, the items of a step, the steps skipped, what the person decided and who, the files each attempt's work changed and the conversation its agent worked in, and each version of the plan the run followed, with who approved it and from which step on.

  • Keeps the record again each time the run is given something, so that a run stopped in the middle, killed or with the computer down, goes on with vpf-run go from there, asking no agent again for what it gave.

  • Holds nothing while a run waits for a person or a time: it keeps the state of the run and ends, and goes on later from where it stands, asking no agent, command or person again for what it was given before. While one step waits, the steps that do not wait for it go on.

  • Takes answers from the people a step names, from elsewhere, and new versions of a plan during a run, approved by the person who asked: the steps that ended stay as they were, and a step that started keeps its id, by and do.

  • Does the steps that wait for none of each other at the same time, and the items of a step, with at most 8 agents and commands working at once (--at-once). An agent that may only read works while nothing else writes, so that a change to the folder is known to be its own.

Waiting and going on

vpf-run --detach plan.vpf.json asks no one at the terminal and waits for no time: whatever the run would ask, and any not_before still to come, leaves the run waiting, and vpf-run ends with the code 3. A run at the terminal waits the same way when no one answers.

Command What it does
vpf-run status Shows the runs that wait, what each waits for, under a key, for whom, and the steps whose time is near.
vpf-run answer <run> <key> <answer> --as <who> Gives a run the answer it waits for: a text; yes, or no and what is wrong (with --back and the steps, or as no>steps: what is wrong, to send it to earlier steps); or an option. A question for named people takes the answer of one of them.
vpf-run go [<run>] Goes on with a waiting run, or with all of them, from where each stands, with the agent command the run started with unless another is given. With --detach, it waits again for what is still to come.
vpf-run change <run> <plan> --approved-by <who> Has a waiting run follow a new version of its plan, from where it stands.

A run is named by its id, or by the start of it. A plan run by a schedule can be gone on with vpf-run go --detach from the computer's own scheduler, so no process is held between steps.

Starts

start.on What vpf-run does
asked Runs once now. Asks the person what they ask when the plan names {{asked}}.
request Runs once now. A request is another program running vpf-run, and --asked is what it carries.
schedule Waits for each day of the week or of the month and time, in the computer's time zone, and runs.
every Runs now, then every so many minutes.
files Waits until a file that matches one of the paths changes, and runs.

--runs N stops a waiting plan after N runs.

With start.from, a run asked for or requested before that date does not start, and a schedule, every or files waits for it. With start.until, no run starts after that date: vpf-run says so and stops. A run already going goes on to its end.

Agents

The runner reaches agents through one command line, given with --agent or VPF_AGENT_COMMAND. The command runs in the folder with the prompt on its input, and what it writes to its output is the answer. It is told:

Variable What
VPF_ROLE work (do a step), fix (fix what stands in a command's way) or judge (prove another agent's work).
VPF_STEP The id of the step it is asked for.
VPF_KEY Where in the run it is asked: the record keeps its answer under this key.
VPF_AGENT The agent the plan names, or empty.
VPF_MODEL The model the plan names, or empty.
VPF_TOOLS The only kinds of tools the agent may use, joined by commas.
VPF_FOLDER The folder.
VPF_CONVERSATION When the step's work was refused and is asked again, the conversation it was done in, or empty.
VPF_COST_LEFT What the run may still spend, when its plan has a cost limit and what it spent is known, or empty.
VPF_COST_FILE A file where the command may write what the answer cost, one number per line.
VPF_CONVERSATION_FILE A file where the command may write the id of the conversation it worked in.

The command must give the agent only the tools VPF_TOOLS names. An agent that proves gets read, and internet too when its proof names it. The runner also checks what it can: an agent whose tools leave out write, and every agent that proves, must not change the folder, and the run stops when one does (the folder's .git and .vpf are not counted). A proving agent is shown the work's answer, the proofs that passed before it, the files the work changed and the lines it changed in small text files. It judges only its own check, and answers PASS or FAIL on its first line, and after FAIL the points against the work. A person who proves work is shown its answer with the question. When an agent does not write its cost, the run's cost is not measured, and the person is told when the plan has a cost limit.

The person

The person is whoever runs vpf-run: they answer a person's step, approve work (yes, or no, what is wrong and which step it goes back to), and decide when work keeps being refused or a deadline passes. A step for named people is shown with their names, and the answer typed is theirs; they can also answer from elsewhere with vpf-run answer. Without an answer, the run waits for one.

Library

The crate vpf-runner holds the same runner as a library: Runner runs a plan with any Agent and any Person. A program that runs plans by the library alone leaves the command out, and with it clap:

[dependencies]
vpf-runner = { version = "0.4", default-features = false }
  • An Agent may be asked from several threads at once, so it is Sync. Its AgentRequest names the step, the key its answer is kept under (to show what the agent does meanwhile under that step), the conversation of the step's refused work, and what the run may still spend. Its AgentAnswer may give the conversation it worked in.
  • A run that waits ends as Outcome::Waiting; Record::reply gives it answers, Record::change a new version of its plan, and Runner::resume goes on with it. Runner::detach asks no one and waits for no time.
  • A host that keeps runs in its own store gives the runner a Keeper: it is told the record each run begins with, and handed each entry the run keeps as soon as it is kept. A run that stopped in the middle is rebuilt from that record and the entries after it with Record::add_entries, and Runner::resume goes on asking none of them again.

Development

cargo fmt --all --check
cargo clippy --all-targets -- -D warnings
cargo test

Commits follow Conventional Commits and carry a Signed-off-by line.

License

Apache License 2.0.