Skip to main content

Module prs

Module prs 

Source
Expand description

The Kanban and GitHub (docs/specs/SPEC_WARDEN_KANBAN_2026_10_20.md §6.9, D5):

  • Finding the PR. When an agent holding one task opens a PR, the card gets the PR’s address once GitHub lists it, so the card links to it without the agent naming it. A result that names one PR (“PR #12”) does the same at hand-in, when that PR is from the branch the agent is on: a result that only mentions someone else’s PR links nothing, so that PR’s merge can’t close the task.
  • Closing on merge. A task in Review whose PR has merged is accepted: the merge was the review. Off with the setting kanban:closeonmerge.
  • Merged, then Released (SPEC_KANBAN_STAGES_COLOURS_AND_NARROW_VIEW_2026_10_23.md §4): a task’s PR that merged is recorded with when (work_prs.rs), so the board can show the task in Merged even while its agent still holds it; and once a release of the repository was made from a commit at or after that merge, the task is recorded as in that release (Released). main is linear (a merge queue), so a release made after a merge contains it.

srv holds no GitHub credential, so both read GitHub’s public API without one: they work for public repositories, and a private one stays as it was (the agent links its PR with Tasks, the operator accepts by hand). The unauthenticated API allows 60 calls an hour per address, shared with everything else on the computer (several AgentMux instances run on a busy one, the update check among them), so this spends at most HOURLY_BUDGET and stops until GitHub’s reset when told it is over. (Measured: an unauthenticated 304 answer counts against the limit like a 200, so asking with an ETag would save nothing.) A task dev build doesn’t ask at all, unless AGENTMUX_KANBAN_PR_POLL is set: it shares the computer’s limit and its Kanban with the instance the person uses.

Structs§

PrRef
A PR on GitHub: owner/repo and its number.

Enums§

PrState
What GitHub says about a PR.

Constants§

HOURLY_BUDGET
The most calls this srv makes in an hour.
SETTING_CLOSE_ON_MERGE
The setting that stops a merged PR closing its task (default on).

Functions§

close_merged
A task’s PR merged: accept it, if it is still in Review. Returns whether it moved (another srv on this computer may have got there first).
close_on_merge_enabled
Whether closing on merge is on (kanban:closeonmerge, default on).
find_opened
An agent holding work_id was seen at seen_ms opening a PR from branch in repo (from owner’s fork when --head named one): look for it on GitHub a few times as it appears, and link the first found that was created by then. Without --head, gh may have pushed to a fork of the user’s, whose owner srv doesn’t know: the last look takes the newest open PRs and matches the branch instead.
is_from_branch
Whether GitHub’s answer for a PR says it is from branch of repo (owner/repo).
link
Link a task to its PR, unless it has one already; source says whose finding it is (the holder’s own gh pr create, or a hand-in’s text). Returns whether it did.
link_if_from
A hand-in named pr while its agent was on branch of repo (its origin): link it if that PR is from that branch of that repository, so a PR the result only mentions (someone else’s, one it built on, a fork’s same-named branch) isn’t taken for the task’s own.
merged_at
When GitHub’s answer for one PR says it merged (ms).
parse_pr_ref
The PR a card’s link names: a GitHub PR address, owner/repo#12, or #12 / 12 in the card’s repository.
pick_opened
The PR a just-seen gh pr create opened, from a list GitHub gave: the first created since since_ms (less [CREATED_SLACK_MS]), from branch when one is given. An older PR from the same branch (merged long ago, or open before this command) is not this command’s.
pr_in_text
The one PR a hand-in’s text names (“PR #12”, a PR address), when it names exactly one; None for none or several.
pr_state
The state in GitHub’s answer for one PR.
release_containing
The first release (oldest; not a draft) made from a commit at or after merged_ms, from GitHub’s list of a repository’s releases: its tag and when it was published (ms). A release’s created_at is the date of the commit it was made from.
report_of
What GitHub’s answer for one PR tells the card’s list: its state, head, and when it was opened and last changed. None for an answer that names no state.
run_merge_loop
The merge loop: every minute, ask GitHub about the PRs of the tasks that are due a look; record merges and releases, and accept a task in Review whose PR merged. Started once, after super::install.