openloops.runbook_run#
Run an approved run plan: exactly the approved commands, no model, close on the check.
ADR-018. A plan (openloops.runbook.Plan) is written by an agent and approved by
the owner once, by its hash. This module is the executor, and it holds no judgement:
it refuses a plan with no approval for its current hash, an approval older than
DFLT_APPROVAL_HOURS, or a planopenloops.runbook.validate()rejects (therisk floor is recomputed from the text, so a plan cannot talk its way past it);
it runs each step’s command exactly as written, in order, with a time limit, its output captured to a local log (mode 0600) and never posted anywhere;
before a step it runs the step’s check, and skips the command when the check already passes, so running a plan twice is harmless;
a step whose dependencies did not succeed is skipped; a step that needs a person at a terminal (
Step.interactive) runs only when the owner started the run from one (tty=True);after an issue’s last step it hands the outcome to
openloops.closer, which closes the issue only on a passing check (ADR-015).
ol runbook run PLAN --only-checks needs no approval: it runs no command, only the
checks, and closes what already passes (the closer’s four conditions still apply).
Nothing in the core imports this module. run_step() is the one place a step’s
command is run; ol do (ADR-015 §2) is meant to call it too.
Functions
|
|
|
Write plan under |
|
A plan by id, or by the path of a plan file. |
|
Record the owner's approval of plan's current hash. |
|
The live approval of plan's current hash, or |
|
The stored plans, newest first, each |
|
Run one step's command; |
|
One task step end to end, short of reporting: check first, then run. |
|
Run plan's approved steps, in order; return the run report (also stored). |
|
Run command with |
- openloops.runbook_run.approval_of(plan, *, store, now=None, hours=48)[source]#
The live approval of plan’s current hash, or
None.Nonetoo for an approval of another plan with the same steps, one dated in the future or without a time zone, and one older thanhours.
- openloops.runbook_run.approve(plan, *, via, discussed=(), store, now=None)[source]#
Record the owner’s approval of plan’s current hash.
viasays how the owner approved ("terminal","board:<event id>","session: <the owner's words>");discussednames thediscuss-level steps the owner said yes to by name. A plan that does not validate is not approvable.
- openloops.runbook_run.load_plan(ref, *, store)[source]#
A plan by id, or by the path of a plan file.
- Return type:
- openloops.runbook_run.plans(*, store, now=None, include_ran=False)[source]#
The stored plans, newest first, each
{plan, title, hash12, state, counts, page, created}.stateiswaiting(no live approval for its current hash: it needs the owner),approved(approved, no run since), orran(a report exists since the approval).ranplans are left out unlessinclude_ran.
- openloops.runbook_run.run_plan(plan, *, store, runner=<function shell_runner>, run_check=<function default_run_check>, close=None, log_dir=None, tty=False, only_checks=False, only=None, dry_run=False, now=None)[source]#
Run plan’s approved steps, in order; return the run report (also stored).
onlylimits the run to some step ids (a pilot): the others areheld, and an issue with a held step is not reported (it closes when its last step has run).only_checksruns no command, needs no approval, and closes only on the issue’s own Verify line (a check the planner wrote needs the owner’s approval of the plan).dry_runruns nothing and writes nothing.closedefaults toopenloops.closer.report()with the owners and login resolved once per run;log_dirto~/.local/share/openloops/runbooks/logs.
- openloops.runbook_run.run_step(step, *, runner=<function shell_runner>, tty=False, log_path=None)[source]#
Run one step’s command;
okwhen it exits 0 and its output matchesexpect.Returns
{status, ok, why, tail};tailis the end of the output, for the local report only.
- openloops.runbook_run.run_task(step, *, runner=<function shell_runner>, run_check=<function default_run_check>, tty=False, log_path=None, checks_only=False)[source]#
One task step end to end, short of reporting: check first, then run.
resultisalready-done(its check passes: the command did not run),not-run(checks_only),needs-terminal(an interactive step withouttty),okorfailed. ADR-015 §2’sol dois this plusopenloops.closer.report().
- openloops.runbook_run.runbooks_store(root=None)[source]#
~/.local/share/openloops/runbooks/:plans/,approvals/,reports/.- Return type:
- openloops.runbook_run.save_plan(plan, *, store)[source]#
Write plan under
plans/<id>.json; returns its hash.- Return type:
- openloops.runbook_run.shell_runner(command, *, cwd, timeout, tty, log_path)[source]#
Run command with
bash; return(exit status, output).Output goes to log_path (created 0600). With
ttythe step gets a real terminal (throughscript, so a login prompt, a one-time code or anisattycheck behaves as at a prompt) and its output is read back from the log. Withoutttyinput is closed, so a step that waits for input fails instead of hanging.Noneis a step that could not run or ran out of time.