openloops.board_refresh#
Keep the phone board within a day of GitHub, without a session remembering to.
The board (openloops.board) is built by hand once: gather, classify, build. Left
alone it goes stale (a board built 2026-10-27 was still that build on 2026-11-09, with
210 of its 420 cards closed and 222 new items missing). refresh_board() is the
rebuild as one deterministic, model-free step meant to run from a timer (ol
install-refresh-job) or by hand (ol board-refresh WORK):
gather the open items (
openloops.tasks.gather()) over the scope saved inWORK/refresh.json(flags given on the command line are saved there first, and whatOPENLOOPS_OWNERS/OPENLOOPS_EXCLUDE_REPOSor the default owners resolve to is saved as explicit lists, so a timer without that environment sweeps the same scope:pin_env_scope());merge them with the live
WORK/board/tasks.json(merge_refresh(), pure): the earlier record of every id still open is kept, with its title and url refreshed from GitHub and nothing re-classified; each new id gets the free heuristic record;if nothing opened, closed or was retitled, stop (
rebuilt: False);otherwise rebuild into a temporary directory and move each file into place (
os.replace: the receiver job readstasks.jsonat any moment); the new ids accumulate inWORK/new-items.jsonfor a session’s classifier brief;publish (a directory, or
host:dirthroughscp) whenever the local board’s files differ from the last ones published, and only then record it.
Guards, because a wrong rebuild is worse than a stale one:
an incomplete sweep (
listed: false) never rebuilds;a saturated sweep (some search hit its cap) adds but never closes;
closing more than
max_close_fractionof a board of at leastGUARD_MIN_LIVEcards is refused unlessforce: those closes are withheld(and named in
refresh.json), while additions and retitles still go through, so a refusal never freezes the board;a
tasks.json,board.jsonorrefresh.jsonthat exists but does not parse (or, forrefresh.json, holds a value of the wrong shape) raises rather than being read as empty, and a first run with noboard.jsonraises rather than publishing default settings;an owner-edited
kit.html(one that differs from the packaged template) is kept.
A board whose page keeps its state in a claude.ai Artifact cannot be republished from
here: the result says needs_republish: True and a session republishes it.
What it touches: GitHub through gather (read-only); files under WORK; and, when
publishing, the destination directory or the remote host (scp with the user’s own
keys). It never calls a model.
Module Attributes
Where the items that got only the heuristic record are listed, for a classifier brief. |
|
the gather scope, run specs/extras, where to publish, and the hash of the |
|
A rebuild may close at most this fraction of the live cards without |
|
...once the board has at least this many cards (a small board may empty legitimately). |
Functions
|
A publisher that copies the board's files to |
|
Whether |
|
|
|
The rebuild's records, the new candidates, and the plan. |
|
Save what the environment makes the sweep's scope into |
|
Diff the ids now open against the ids on the live board. |
|
Rebuild |
|
Save the |
Classes
|
What a fresh sweep changes relative to the live board. |
Exceptions
Publishing the rebuilt board failed. |
- openloops.board_refresh.DFLT_MAX_CLOSE_FRACTION = 0.5#
A rebuild may close at most this fraction of the live cards without
force…
- openloops.board_refresh.GUARD_MIN_LIVE = 10#
…once the board has at least this many cards (a small board may empty legitimately).
- openloops.board_refresh.NEW_ITEMS_FILE = 'new-items.json'#
Where the items that got only the heuristic record are listed, for a classifier brief.
- exception openloops.board_refresh.PublishError[source]#
Bases:
RuntimeErrorPublishing the rebuilt board failed. The local board is in place; the next run retries, because the published marker is recorded only after a success.
- class openloops.board_refresh.RefreshPlan(kept, added, closed, withheld=(), updated=())[source]#
Bases:
objectWhat a fresh sweep changes relative to the live board.
withheldare ids missing from a saturated sweep, kept rather than closed;updatedare kept ids whose title or url changed on GitHub.
- openloops.board_refresh.STATE_FILE = 'refresh.json'#
the gather scope, run specs/extras, where to publish, and the hash of the
tasks.jsonlast published.- Type:
The refresh’s own state
- openloops.board_refresh.dir_publisher(destination, *, timeout=300)[source]#
A publisher that copies the board’s files to
destination.destinationis a directory, orhost:dir(seeis_remote_destination()), which goes throughscp -o BatchMode=yes(never a password prompt that would hang a timer) withtimeoutseconds. A local copy replaces each file atomically; the remote copy does not (scpwrites in place), so a reader on the host can, for a moment, see a partly written file. A failure raises, so a timer’s log says the board did not move.
- openloops.board_refresh.is_remote_destination(destination)[source]#
Whether
destinationnameshost:dir(forscp) rather than a local path.Remote only when the text before the first colon is a plausible host (non-empty, no
/or\, not a one-letter Windows drive such asC:) and the whole thing is not an existing local path.>>> [is_remote_destination(d) for d in ('tw:/srv/board', 'me@host:board')] [True, True] >>> [is_remote_destination(d) for d in (r'C:\Users\x\dest', '/tmp/a:b', 'board')] [False, False, False]
- Return type:
- openloops.board_refresh.load_state(work_dir)[source]#
WORK/refresh.json:{}when missing, an error when it exists but is unreadable or holds a scope value of the wrong shape.
- openloops.board_refresh.merge_refresh(live, candidates, *, saturated=(), withhold_closes=False)[source]#
The rebuild’s records, the new candidates, and the plan. No I/O.
Every id still open keeps its earlier record (never re-classified), with
REFRESHED_FIELDStaken from the sweep; new ids get the heuristic record. Asaturatedsweep did not list everything, so an id it did not see is kept (withheld), never closed;withhold_closesdoes the same for a sweep whose closes were refused.>>> live = [{'id': 'a/b#1', 'title': 'Old', 'ask': 'ENRICHED'}, {'id': 'a/b#2'}] >>> seen = [{'id': 'a/b#1', 'title': 'New', 'url': 'https://github.com/a/b/issues/1'}] >>> records, fresh, plan = merge_refresh(live, seen) >>> [(r['id'], r['title'], r['ask']) for r in records], plan.closed, plan.updated ([('a/b#1', 'New', 'ENRICHED')], ('a/b#2',), ('a/b#1',)) >>> records, _, plan = merge_refresh(live, seen, saturated=['label:manual-task']) >>> [r['id'] for r in records], plan.closed, plan.withheld (['a/b#1', 'a/b#2'], (), ('a/b#2',))
- openloops.board_refresh.pin_env_scope(work_dir, *, environ=None, resolve_owners=None)[source]#
Save what the environment makes the sweep’s scope into
WORK/refresh.json.A launchd timer does not get the shell’s
OPENLOOPS_OWNERSorOPENLOOPS_EXCLUDE_REPOS, so a scope that lives only there would make the timer sweep a different set of repositories than a run by hand (and could put an excluded client repo on the board). Each is written as an explicit list, but only whererefresh.jsonhas no value yet (a flag given earlier, or an earlier pin, wins). With noOPENLOOPS_OWNERS,resolve_owners(e.g.openloops.obligations.configured_owners()) supplies the default owners; when it is not given they stay unset here and the first sweep’s resolved owners are pinned instead. Returns what was saved.>>> import tempfile >>> with tempfile.TemporaryDirectory() as tmp: ... env = {'OPENLOOPS_OWNERS': 'me, org', 'OPENLOOPS_EXCLUDE_REPOS': 'org/x-*'} ... first = pin_env_scope(tmp, environ=env) ... second = pin_env_scope(tmp, environ={'OPENLOOPS_OWNERS': 'other'}) >>> first, second ({'owners': ['me', 'org'], 'exclude_repos': ['org/x-*']}, {})
- openloops.board_refresh.plan_refresh(current, previous)[source]#
Diff the ids now open against the ids on the live board.
>>> plan = plan_refresh(['a#1', 'a#2', 'a#4'], ['a#1', 'a#3']) >>> plan.kept, plan.added, plan.closed, plan.changed (('a#1',), ('a#2', 'a#4'), ('a#3',), True) >>> plan_refresh(['a#1'], ['a#1']).changed False
- Return type:
- openloops.board_refresh.refresh_board(work_dir, *, owners=None, exclude_owners=None, exclude_repos=None, searches=None, review_prs=None, run_specs=None, run_extras=None, publish_to=None, force=False, max_close_fraction=0.5, publish=None, gather=<function gather>, settings=None)[source]#
Rebuild
WORK/boardwhen the set of open items changed. Returns what happened.The scope keywords (
ownerstopublish_to) are saved intoWORK/refresh.jsonwhen given and read from it when not (remember_scope()); their defaults are every kind of item and PRs awaiting review, likeboard-gather --all-kinds.run_specs/run_extrasare passed to every rebuild, asboard-buildtakes them.forcerebuilds even when nothing changed and overrides the close guard (never the incomplete-sweep one). What the environment sets (OPENLOOPS_OWNERS,OPENLOOPS_EXCLUDE_REPOS) and, failing that, the owners the sweep resolved, are pinned intorefresh.jsonwhere it has no value yet (pin_env_scope()).publishreplaces the publisher built frompublish_to(seedir_publisher());gatherreplaces the sweep;settingsoverride the existingboard.json(and are required when there is none).statusisrebuilt,unchanged,incomplete,partial(rebuilt with additions/retitles while a mass close was refused) orrefused(a mass close was refused and nothing else changed). Refused closes are withheld, never dropped:refused_closes(a count) andrefused_close_idsare returned and kept inrefresh.jsonuntil a run no longer refuses, andremedyis the command that applies them. A publish failure raisesPublishErrorafter the local rebuild is in place.>>> import tempfile >>> item = {'id': 'a/b#1', 'url': 'https://github.com/a/b/issues/1', ... 'repo': 'a/b', 'title': 'Add a key', 'src': 'label:manual-task'} >>> sweep = lambda **kw: {'listed': True, 'candidates': [item], 'error': None} >>> with tempfile.TemporaryDirectory() as tmp: ... first = refresh_board(tmp, gather=sweep, settings={'title': 'Mine'}) ... again = refresh_board(tmp, gather=sweep) >>> first['rebuilt'], first['added'], again['status'] (True, 1, 'unchanged')
- openloops.board_refresh.remember_scope(work_dir, **given)[source]#
Save the
givenscope values (None= not given) intoWORK/refresh.json.Returns the full scope: what was saved, then defaults. Both
ol board-refreshandol install-refresh-jobgo through here, so the timer needs onlyWORK.>>> import tempfile >>> with tempfile.TemporaryDirectory() as tmp: ... _ = remember_scope(tmp, owners=['me']) ... scope = remember_scope(tmp, exclude_repos=None) >>> scope['owners'], scope['review_prs'] (['me'], True)