openloops.runbook#
Run plans: the owner’s command-line manual tasks, planned by an agent, run without one.
A manual-task issue often ends in a shell command the owner is asked to paste. With
dozens of them, pasting becomes mindless, and the safety of running a command yourself
is lost. A run plan puts the judgement back (ADR-018):
an agent (the
openloops-runbookskill) re-checks each issue, orders the commands, has an independent reviewer rate each one, rewrites them to lower the risk, and writes aPlan;the owner approves the plan once, by its
plan_hash();openloops.runbook_runruns exactly the approved commands, with no model in the loop, and closes each issue only on its passing check (ADR-015).
This module is the pure part: the plan record, its hash, the one grammar of an issue
reference (parse_ref()), and the checks a plan must pass before it can be approved
(validate()). The risk reading of a command is openloops.command_risk. No I/O,
no network, no model.
>>> p = Plan('p', '2026-11-30', steps=[Step('s1', 'o/r/1', 'gh issue view 1 -R o/r')])
>>> validate(p), p.steps[0].issue
([], 'o/r#1')
Functions
|
|
|
sha256 over what runs: each step's |
|
What is wrong with plan, as messages; |
|
The one-line summary: steps that run unattended, need hands, wait for a yes; held items. |
Classes
|
One command of a plan, for one issue. |
|
A run plan: the steps that will run, and everything kept out of them. |
- class openloops.runbook.Plan(id, created, steps=list(), discuss=list(), skipped=list(), made_by='', title='', page='', schema=1)[source]#
Bases:
objectA run plan: the steps that will run, and everything kept out of them.
discussholds what is not instepsbecause it needs the owner’s word ({issue, why, recommendation, command});skippedholds what needs nothing ({issue, why}: already done, closed, no command).pageis where the owner reads it (a link). Onlystepsis hashed: the approval binds to what runs.
- class openloops.runbook.Step(id, issue, command, cwd=None, check=None, expect=None, after=list(), close=True, timeout=900, interactive=False, level='show', reasons=list(), review=None, rewrites=list(), note='')[source]#
Bases:
objectOne command of a plan, for one issue.
commandruns as written, incwd(~expanded), withbash.checkis the read-only command whose exit 0 means the issue’s ask is done (the issue’s**Verify:**field, or one the planner wrote, which the owner approves with the plan); it is run before the command (already done: skip it) and after.expectis a regular expression the command’s output must contain.afternames the steps that must have succeeded first.closesays this is the issue’s last step, so a passing check closes the issue.rewritesrecords each risk-lowering change as{before, after, why}.reviewis the independent reviewer’s{level, reasons};levelandreasonsare the combined verdict.
- openloops.runbook.counts(plan)[source]#
The one-line summary: steps that run unattended, need hands, wait for a yes; held items.
>>> counts(Plan('p', 'd', steps=[Step('s1', 'o/r#1', 'npm login', interactive=True)], skipped=[{}])) {'runs': 0, 'hands': 1, 'decide': 0, 'skipped': 1}
- openloops.runbook.parse_ref(ref)[source]#
(owner, repo, number)fromo/r#3,o/r/3or an issue URL. One grammar.>>> parse_ref('acme/widget#12'), parse_ref('acme/widget/12') (('acme', 'widget', 12), ('acme', 'widget', 12)) >>> parse_ref('https://github.com/acme/widget/issues/12') ('acme', 'widget', 12)
- openloops.runbook.plan_hash(plan)[source]#
sha256 over what runs: each step’s
HASHED_FIELDS, in order.>>> p = Plan('p', '2026-11-30', steps=[Step('s1', 'o/r#1', 'true')]) >>> h = plan_hash(p); len(h) 64 >>> p.steps[0].note = 'reworded'; plan_hash(p) == h True >>> p.steps[0].command = 'true && false'; plan_hash(p) == h False
- Return type:
- openloops.runbook.validate(plan, *, discussed=(), check=<function risk_floor>)[source]#
What is wrong with plan, as messages;
[]when it may be approved and run.The floor is recomputed here, from the text, by
check(ADR-015 §3’s seam; the default reads the text,openloops.command_risk.risk_floor()), so a plan that claimsrunfor a deploy is caught. Adiscussstep is allowed only if its id is in discussed (the owner said yes to that step by name);refusenever is.>>> ok = Plan('p', 'd', steps=[Step('s1', 'o/r#1', 'gh issue view 1 -R o/r', check='true')]) >>> validate(ok) [] >>> bad = Plan('p', 'd', steps=[Step('s1', 'o/r#1', 'rm -rf ~/x', after=['s9'])]) >>> for m in validate(bad): print(m) s1: needs the owner's yes by name (irreversible: deletes files) s1: runs after s9, which is not an earlier step