openloops.runbook_issue#

One manual-task issue, from its number to a reviewed run plan, with no agent in between.

ADR-018 amendment (2026-12-04). The openloops-runbook skill plans many issues at once and rewrites their commands; for one issue whose body already carries the command, an agent in between costs the owner more attention than it saves. ol runbook-issue REF does the planner’s mechanical part in code and keeps the parts that matter:

  • still needed? the issue must be open, a manual-task, filed by the owner’s own login, and waiting on no open issue; and every step’s check is the issue’s own **Verify:** line, so a task that is already done runs nothing;

  • safe? the deterministic floor (openloops.command_risk.risk_floor()), then the independent reviewer (the shipped openloops-risk-reviewer agent, run as claude -p), which can only raise a level; a weak check means the issue is not closed;

  • run, watched: the plan is shown, the owner’s one yes approves it at its hash, and openloops.runbook_run runs it at his terminal;

  • done? the Verify line is run again, and openloops.closer closes the issue only when it passes.

Pure: plan_from_issue(), apply_review(), review_prompt(), parse_review(). I/O: gather_facts(), claude_reviewer(). Imported by nothing in the core; tools.runbook_issue loads it lazily. claude_reviewer() is the one place openloops asks a model, and only when the owner runs this command.

Module Attributes

DFLT_REVIEW_MODEL

The reviewer runs on the strongest tier (the agent definition says model: opus).

DFLT_REVIEW_TIMEOUT

Seconds the reviewer may take before the plan is refused for want of a review.

Functions

plan_id(ref)

The plan id for an issue: one plan per issue, replaced when planned again.

plan_from_issue(issue, *[, keep_open, ...])

A plan of one step per shell block of issue's body, in order, each checked first by the issue's own **Verify:** line.

gather_facts(plan, *[, run])

Facts a tool gathered for each step, for the reviewer: the hosts it reaches by ssh and, for each folder it works in that is a git checkout, its status and remote.

review_prompt(plan, facts)

What the reviewer is given: each step's command, folder and check, and the facts.

parse_review(text, *, ids)

The reviewer's JSON list, one object per step id in ids; an error otherwise.

apply_review(plan, reviews)

plan with each step's review stored and its level raised to the reviewer's.

claude_reviewer(*[, claude, model, timeout])

The default reviewer: the shipped openloops-risk-reviewer instructions, run as claude -p with no tools and no saved session.

newer_commands(body, comments)

Each shell block a comment gives that the body does not, oldest first.

comment_bodies(ref, *[, gh])

The comments of issue ref posted after its body was last edited, oldest first.

openloops.runbook_issue.DFLT_REVIEW_MODEL = 'opus'#

The reviewer runs on the strongest tier (the agent definition says model: opus).

openloops.runbook_issue.DFLT_REVIEW_TIMEOUT = 300#

Seconds the reviewer may take before the plan is refused for want of a review.

openloops.runbook_issue.apply_review(plan, reviews)[source]#

plan with each step’s review stored and its level raised to the reviewer’s.

A review can only raise a level. No undo named means discuss. A weak check on the issue’s last step means the issue is not closed by this run (close: false).

>>> p = Plan('p', 'now', steps=[Step('s1', 'o/r#1', 'echo hi', level='run')])
>>> q = apply_review(p, [{'id': 's1', 'level': 'show', 'undo': 'none',
...                       'weak_check': True}])
>>> q.steps[0].level, q.steps[0].close
('discuss', False)
Return type:

Plan

openloops.runbook_issue.claude_reviewer(*, claude='claude', model='opus', timeout=300)[source]#

The default reviewer: the shipped openloops-risk-reviewer instructions, run as claude -p with no tools and no saved session. Raises when it cannot run or its answer cannot be read: a plan without its review is refused, never run on the floor alone unless the owner says so (--no-review).

Return type:

Callable[[Plan, Mapping[str, Sequence[str]]], list[dict[str, Any]]]

openloops.runbook_issue.comment_bodies(ref, *, gh=None)[source]#

The comments of issue ref posted after its body was last edited, oldest first.

Read only to find shell blocks in them (newer_commands()). A comment older than the body’s last edit was already folded into it, or superseded by it.

Return type:

list[str]

openloops.runbook_issue.gather_facts(plan, *, run=None)[source]#

Facts a tool gathered for each step, for the reviewer: the hosts it reaches by ssh and, for each folder it works in that is a git checkout, its status and remote. Reads only.

Return type:

dict[str, list[str]]

openloops.runbook_issue.newer_commands(body, comments)[source]#

Each shell block a comment gives that the body does not, oldest first.

A plan runs the body’s blocks only. An agent that refreshed the ask in a comment (a corrected command, a new Verify) left the body stale: running it would run the old command. Whitespace is ignored when comparing.

>>> body = "```bash\nnpm trust github x\n```"
>>> newer_commands(body, ["Fixed:\n```bash\nnpm publish && npm trust github x\n```"])
['npm publish && npm trust github x']
>>> newer_commands(body, ["Same:\n```bash\nnpm  trust github x\n```", "no code"])
[]
Return type:

list[str]

openloops.runbook_issue.parse_review(text, *, ids)[source]#

The reviewer’s JSON list, one object per step id in ids; an error otherwise.

>>> parse_review('```json\n[{"id": "s1", "level": "show"}]\n```', ids=['s1'])
[{'id': 's1', 'level': 'show'}]
Return type:

list[dict[str, Any]]

openloops.runbook_issue.plan_from_issue(issue, *, keep_open='', made_by='ol runbook-issue', now=None)[source]#

A plan of one step per shell block of issue’s body, in order, each checked first by the issue’s own **Verify:** line. Pure.

issue is what openloops.closer.read_issue() returns (ref, title, body). keep_open is a reason the issue must stay open after the run (the closer would refuse it, or it has no Verify line); the last step then has close: false and the reason in its note.

>>> body = '**Verify:** `test -f done`\n\n```bash\ntouch done\n```'
>>> p = plan_from_issue({'ref': 'o/r#3', 'title': 'Make it', 'body': body})
>>> [(s.id, s.command, s.check, s.close) for s in p.steps]
[('s1', 'touch done', 'test -f done', True)]
Return type:

Plan

openloops.runbook_issue.plan_id(ref)[source]#

The plan id for an issue: one plan per issue, replaced when planned again.

>>> plan_id('thorwhalen/_private-issues#202')
'issue-thorwhalen-_private-issues-202'
Return type:

str

openloops.runbook_issue.review_prompt(plan, facts)[source]#

What the reviewer is given: each step’s command, folder and check, and the facts. Not the issue’s text, not the floor’s levels: a second opinion has not read the first.

>>> p = Plan('p', 'now', steps=[Step('s1', 'o/r#1', 'echo hi', cwd='~')])
>>> text = review_prompt(p, {'s1': ['clean checkout']})
>>> 'echo hi' in text, 'clean checkout' in text, 'o/r#1' in text
(True, True, False)
Return type:

str