openloops.tasks#
Everything you could act on, as one list of task records: gather, classify, merge.
openloops.owed() answers “what do I owe, and is it still owed?” for one label.
A task board needs a wider net and a different answer: every open item across a fleet
that asks something of the human (the manual-task issues, the issues titled
“Decide…”, the PRs waiting on their review), each turned into a task record saying
what to do, where to do it, how long it takes and on which device.
Three steps, each a plain function:
gather()sweeps several owners withgh search, one query per owner and kind so no owner’s results crowd out another’s, with no 50-row cap (the search API’s own ceiling of 1000 per query is the limit, and a query that reaches it is reported as saturated, never truncated quietly). Exclusions are keyword arguments.classify()turns each candidate into a record through aclassifier=. The default,heuristic_classify(), is deterministic: label, title and body patterns decide the tier, the pattern and the minutes, and the deep-link builders point at the exact settings page. No model is called, here or anywhere in openloops. The richer path is the classifier brief shipped with theopenloops-phone-boardskill: a subagent reads each item and writes records in the same schema, whichmerge_records()lays over the heuristic ones.merge_records()combines record sources by URL, later sources winning, and normalises every record toTASK_FIELDS.
The record schema is Task, defined once, here. The board page, the build
step and the classifier brief all read it; a field added anywhere else is a field the
others do not know about.
Read-only, like the rest of openloops. Gathering runs gh search; nothing here
comments, closes, labels or approves anything.
>>> candidate = {
... 'url': 'https://github.com/acme/widget/issues/7', 'repo': 'acme/widget',
... 'number': 7, 'title': 'Add the NPM_TOKEN secret so CI can publish',
... 'body': '', 'labels': ['manual-task'], 'created': '2026-08-01',
... }
>>> record = heuristic_classify(candidate)
>>> record['tier'], record['pattern'], record['id']
('browser', 'github-settings', 'acme/widget#7')
>>> [link['label'] for link in record['links']]
['GitHub: Actions secrets', 'Issue']
Module Attributes
Where the human does the thing, cheapest first. |
|
Whether the item still asks anything of the human. |
|
The controlled vocabulary of repeated chores. |
|
Every key on every record, in schema order. |
|
(search terms, the field they match). |
Functions
|
Set only |
|
One normalised record per candidate, through |
|
Every open item that asks something of the human, across |
|
A repository settings page (a key of |
|
A task record from a gathered candidate, by patterns alone. |
|
The records in JSON files (each a list, or an envelope with |
|
Records from several sources, one per item, later sources winning. |
|
npm package settings: trusted publisher, publishing access, 2FA requirement. |
|
PyPI trusted publishers: a project's page, or the pending-publisher page. |
Classes
|
A heuristic: when |
|
One thing the human could act on. |
- openloops.tasks.DFLT_SEARCHES = {'agent-decided': ('agent-decided', 'label'), 'decide': ('Decide', 'title'), 'needs-user': ('"Needs the user"', 'body')}#
(search terms, the field they match). A
labelmatch is a label name rather than text:agent-decidedissues are the record of a decision an agent made and the owner can veto (ADR-010).- Type:
Extra searches beyond the label, by name
- openloops.tasks.PATTERNS = ('npm-trusted-publisher', 'npm-first-publish', 'npm-scope', 'npm-other', 'pypi-trusted-publisher', 'pypi-release', 'api-key', 'github-settings', 'server-chore', 'decision', 'review-pr', 'merge-bot-pr', 'record', 'device-test', 'listen-look', 'live-check', 'purchase', 'mac-only', 'other')#
The controlled vocabulary of repeated chores. A run on the board groups one pattern.
- class openloops.tasks.Rule(pattern, tier, minutes, regex)[source]#
Bases:
NamedTupleA heuristic: when
regexmatches title + body, the item is this pattern.
- openloops.tasks.STATUSES = ('open', 'likely-done', 'not-for-user', 'stale')#
Whether the item still asks anything of the human.
- openloops.tasks.TASK_FIELDS = ('id', 'url', 'kind', 'org', 'repo', 'title', 'ask', 'tier', 'minutes', 'links', 'decision', 'prompt', 'machine', 'unblocks', 'pattern', 'pattern_key', 'status', 'note', 'source', 'created', 'review', 'command')#
Every key on every record, in schema order.
- openloops.tasks.TIERS = ('tap', 'browser', 'session', 'physical', 'mac-only')#
Where the human does the thing, cheapest first. The board sorts and filters on it.
- class openloops.tasks.Task(id, url=None, kind='issue', org=None, repo=None, title='', ask='', tier='session', minutes=None, links=list(), decision=None, prompt=None, machine=None, unblocks=list(), pattern='other', pattern_key=None, status='open', note=None, source=None, created=None, review=None, command=None)[source]#
Bases:
objectOne thing the human could act on. Every record carries every field.
decisionis{question, options, recommendation}orNone;linksare{label, url}with the item itself last;promptis a paste-ready request for a coding session (session tier).sourcesays how the item was found andcreatedwhen it was opened (YYYY-MM-DD).commandis the issue’s shell command (its first shell code block outside “What I found”, at mostMAX_COMMAND_CHARS), orNone: the board’s “Runnable by command” filter and the run plans of ADR-018 key on it.reviewis{verdict, disagreement_risk, reason, concerns}orNone:verdictone ofREVIEW_VERDICTS(the gate’s route),disagreement_riskone ofREVIEW_RISKS,reasona string andconcernsa list of{concern, stance, severity, reason}withstanceinREVIEW_STANCESandseverityinREVIEW_SEVERITIES. It is written by a separate, external preference step at board-build time; this package only carries it (normalised, never raising) and the board page shows it.>>> Task.from_mapping({'id': 'a/b#1', 'tier': 'nope', 'pattern': 'x'}).tier 'session'
- classmethod from_mapping(record)[source]#
Normalise a record from any source: unknown keys dropped, bad vocabulary fixed.
A value outside its vocabulary becomes the field’s safe default (
sessiontier,otherpattern,openstatus) rather than an error, because one sloppy classifier record must not sink a board of three hundred.- Return type:
- openloops.tasks.apply_reviews(records, reviews)[source]#
Set only
reviewon records, from{id, review}overlays; nothing else changes.Overlays match by
idor by GitHub URL (ids derived asTaskdoes); an overlay for an id no record has is ignored. The review is normalised.>>> recs = [{'id': 'a/b#1', 'tier': 'tap'}] >>> out = apply_reviews(recs, [{'url': 'https://github.com/a/b/issues/1', ... 'review': {'disagreement_risk': 'low'}}, ... {'id': 'x/y#9', 'review': {'disagreement_risk': 'high'}}]) >>> [(r['tier'], r['review']['disagreement_risk']) for r in out] [('tap', 'low')]
- openloops.tasks.classify(candidates, *, classifier=<function heuristic_classify>)[source]#
One normalised record per candidate, through
classifier.>>> classify([{'url': 'https://github.com/a/b/issues/1', 'title': 'Decide the name'}])[0]['tier'] 'tap'
- openloops.tasks.gather(*, owners=None, exclude_owners=(), exclude_repos=None, label='manual-task', searches=(), review_prs=False, limit=1000, timeout=30.0, run_gh=None, rate_limit_retries=2, rate_limit_backoff=65.0, sleep=<built-in function sleep>)[source]#
Every open item that asks something of the human, across
owners, deduplicated.One query per owner and per kind: the
label(manual-task), each named search insearches(keys ofDFLT_SEARCHES), and withreview_prsthe open PRs requesting your review.ownersdefaults toopenloops.obligations.configured_owners();exclude_repos(owner/name globs) defaults toOPENLOOPS_EXCLUDE_REPOS.run_ghreplaces theghrunner (run_gh(args, timeout=...) -> stdout).The result is an envelope:
listedisFalsewith anerrorwhen any query failed, because a partial sweep presented as a whole one is the failure that matters.saturatednames the queries that hitlimit.A query GitHub refuses for the search rate limit (30 a minute) waits
rate_limit_backoffseconds and is retried up torate_limit_retriestimes before it counts as failed, so a many-owner sweep completes in one call.>>> def fake(args, *, timeout): ... return json.dumps([{'number': 1, 'title': 'Add a key', ... 'url': 'https://github.com/acme/w/issues/1', ... 'repository': {'nameWithOwner': 'acme/w'}, 'labels': [], 'body': ''}]) >>> report = gather(owners=['acme'], run_gh=fake) >>> report['listed'], [c['id'] for c in report['candidates']] (True, ['acme/w#1'])
- openloops.tasks.github_settings_url(repo, section)[source]#
A repository settings page (a key of
GITHUB_SETTINGS).>>> github_settings_url('acme/widget', 'pages') 'https://github.com/acme/widget/settings/pages'
- Return type:
- openloops.tasks.heuristic_classify(candidate, *, rules=(('mac-only', 'mac-only', 10, '\\b(macos|mac app|keychain|xcode|launchd|on the mac)\\b'), ('npm-first-publish', 'session', 10, 'npm.*(first publish|not (yet )?on npm|does not exist)|first publish.*npm'), ('npm-trusted-publisher', 'browser', 3, 'npm.*trusted publish|trusted publish.*npm'), ('npm-scope', 'browser', 3, 'npm (org|scope)|claim .*scope'), ('pypi-trusted-publisher', 'browser', 3, 'pypi.*(trusted|pending) publish|(trusted|pending) publish.*pypi'), ('pypi-release', 'session', 5, 'pypi.*(release|upload)|(release|upload).*pypi'), ('decision', 'tap', 2, '\\A\\s*(decision|decide|confirm|should|reopen|choose|pick)\\b|\\A[^\\n]*\\?|\\A[^\\n]*\\bdecide\\b'), ('github-settings', 'browser', 3, '\\b(secret|deploy key|github pages|environment|actions settings|repo(sitory)? settings)\\b'), ('api-key', 'browser', 5, '\\b(api key|api token|access token|create (an )?account|sign up)\\b'), ('purchase', 'browser', 5, '\\b(purchase|buy|paid plan|subscription|invoice|billing)\\b'), ('record', 'physical', 15, '\\brecord (yourself|a|an|audio|video|your)\\b|\\bvoice sample\\b'), ('device-test', 'physical', 10, '\\b(on (a|your) (phone|device)|test on (ios|android|a device))\\b'), ('listen-look', 'physical', 10, '\\b(listen to|look at|judge|eyeball)\\b'), ('live-check', 'session', 5, '\\blive (check|test|run)\\b|\\breal (api )?key\\b'), ('server-chore', 'session', 5, '\\b(deploy|install|ssh|sudo|server|cron|systemd)\\b'), ('decision', 'tap', 2, '\\b(go-ahead|which option|options?:|recommend(ation|ed)?:?\\*\\*)')), machines=None)[source]#
A task record from a gathered candidate, by patterns alone. No model, no network.
rulesare tried in order against the title and body;machinesmaps an owner to the machine its session-tier prompts name. Status is alwaysopen: whether an ask was already done is a judgement only a reader of the thread can make (the classifier brief’s job).>>> pr = {'url': 'https://github.com/acme/w/pull/3', 'repo': 'acme/w', ... 'title': 'Bump lodash from 4.17.20 to 4.17.21', 'body': ''} >>> heuristic_classify(pr)['pattern'], heuristic_classify(pr)['links'][0]['url'] ('merge-bot-pr', 'https://github.com/acme/w/pull/3/files')
- openloops.tasks.load_records(paths)[source]#
The records in JSON files (each a list, or an envelope with
candidates).Globs are expanded, in sorted order, so
out_*.jsonreads a batch directory. A glob that matches nothing raises: the batches a subagent failed to write must not quietly turn into a board built from the heuristic alone.
- openloops.tasks.merge_records(*sources)[source]#
Records from several sources, one per item, later sources winning.
Keyed by
id(derived from the URL for a GitHub item, so the two sources agree); a record with no id and no URL is dropped. A later record replaces the earlier one whole, except that an emptyurlorcreatedis filled from it: the classifier brief reads threads, the gatherer knows dates; acommandis kept when the later record has nocommandkey. Areviewis kept when the later record has noreviewkey and the samedecision; a later record with the key (evennull) replaces it, and a changed decision drops it.>>> heuristic = [{'id': 'a/b#1', 'url': 'u1', 'tier': 'browser', 'created': '2026-01-02'}] >>> enriched = [{'id': 'a/b#1', 'url': 'u1', 'tier': 'tap', 'ask': 'Say yes'}] >>> [(r['tier'], r['ask'], r['created']) for r in merge_records(heuristic, enriched)] [('tap', 'Say yes', '2026-01-02')] >>> kept = [{'id': 'a/b#1', 'url': 'u1', 'review': {'disagreement_risk': 'low'}}] >>> merge_records(kept, enriched)[0]['review']['disagreement_risk'] 'low' >>> newer = [{'id': 'a/b#1', 'url': 'u1', 'review': {'disagreement_risk': 'high'}}] >>> merge_records(kept, newer)[0]['review']['disagreement_risk'] 'high'