openloops.word_close#

Close one issue on the owner’s own word, relayed by an assistant (voice, a chat).

The owner says “close issue 207 in my private issues, not planned” to an assistant that cannot be at his terminal. A close is reversible (reopen), but a wrong one is easy to miss: an obligation drops out of ol owed and nobody notices. So every guard here is in code, not in the assistant’s promise, and every close is visible afterwards.

For one issue per call, close_on_word() refuses unless all of these hold:

  1. the repository is PRIVATE, has no outside collaborators (unreadable counts as shared), and its owner is a trusted one (closer.owners, openloops.closer.close_settings());

  2. the number is an open issue, not a pull request, filed under the person’s own login;

  3. expect_title (a few words of the title the assistant read back) is in the title, compared without case, punctuation or extra spaces: a misheard number fails here;

  4. fewer than cap closes were made this way today (UTC), counted in a local ledger;

  5. a manual-task whose **Verify:** check does not pass is not closed as completed (not planned still is): a report alone never closes an owed task as done, as in openloops.closer.

The close carries the owner’s comment (scrubbed of home paths and credentials, capped), a fixed last line saying how it was closed, and the label WORD_LABEL, so word_closes() (ol voice-log) lists every one for a brief, with how to reopen it.

Seams: gh= ((args, *, input=None) -> (status, stdout), the gh CLI by default), settings= (CloseSettings), ledger= (a JSONL file under ~/.local/share/openloops/), run_check=, now=.

Functions

close_on_word(repo, number, *, reason, ...)

Close issue number of repo if every guard in the module docstring holds.

split_ref(ref)

(repo, number) from OWNER/REPO#NUMBER only: a URL is refused, since gh issue close <url> would ignore the repository it was checked against.

default_ledger()

Where closes made this way are counted: ~/.local/share/openloops/word-closes.jsonl.

title_matches(expect, title)

Whether the words read back are in the title (case, punctuation, spacing ignored).

word_closes(*[, owners, days, gh, now])

Issues closed on the owner's word in the last days, newest first, from GitHub (the label is the record, so any machine can list them).

openloops.word_close.close_on_word(repo, number, *, reason, comment, expect_title, by='bosun', cap=5, gh=<function _gh_cli>, settings=None, ledger=None, run_check=<function default_run_check>, now=None, dry_run=False)[source]#

Close issue number of repo if every guard in the module docstring holds.

Returns {ref, action, reason, title, say}: action is closed, would-close (dry_run) or refused; say is one line to read back to the owner.

Return type:

dict[str, Any]

openloops.word_close.default_ledger()[source]#

Where closes made this way are counted: ~/.local/share/openloops/word-closes.jsonl.

Return type:

Path

openloops.word_close.split_ref(ref)[source]#

(repo, number) from OWNER/REPO#NUMBER only: a URL is refused, since gh issue close <url> would ignore the repository it was checked against.

>>> split_ref('me/_private#207')
('me/_private', 207)
>>> split_ref('https://github.com/me/x/issues/1')
Traceback (most recent call last):
...
ValueError: not OWNER/REPO#NUMBER: 'https://github.com/me/x/issues/1'
Return type:

tuple[str, int]

openloops.word_close.title_matches(expect, title)[source]#

Whether the words read back are in the title (case, punctuation, spacing ignored).

>>> title_matches('Bosun: close #207', '[tp] Bosun -- close #207 now')
True
>>> title_matches('wrong issue', 'Bosun close 207')
False
Return type:

bool

openloops.word_close.word_closes(*, owners=(), days=1, gh=<function _gh_cli>, now=None)[source]#

Issues closed on the owner’s word in the last days, newest first, from GitHub (the label is the record, so any machine can list them).

Each row: {ref, title, closedAt, url, undo} (undo: the command that reopens it).

Return type:

list[Mapping[str, Any]]