Expand description
Duplicate-work detection at the moment work is filed.
Two tasks once chased the same commit without knowing about each other: an
open task and its open pull request already covered a change when a chat
filed a second task that named the same branch and commit. Nothing at
filing time said so. This module is that check, and it is deliberately
small: concrete identifiers only - a branch name, a commit SHA, a pull
request number - never text similarity. A false positive costs one
--force; a false negative is the behaviour before this module existed.
A claim is a thing an unfinished piece of work owns: the branches of its candidates and the pull request it opened. The claims come from
- every task that is not
done: itsreview_branch, and each run inTask::runs; - every run that has not reached a terminal status;
- every run that is terminal but whose pull request is still open (the shape of the original accident: the run ended, the PR did not).
Run records are read through a tolerant view rather than RunState::load:
a schema bump must not turn into a silent false negative (the same lesson
as clean::fold_due).
Everything here is synchronous, read-only and takes its roots as arguments, so tests need no process-global home.
Structs§
- Duplicate
- The refusal: one or more
Hits and nothing filed. - Hit
- One reason a new piece of work looks like one already under way.
- Judgement
- The judge’s answer, with the agent that gave it.
Enums§
- Owner
- Who owns the thing that matched.
- Screened
- How
screenlet work through. - Signal
- What kind of identifier matched.
Functions§
- chain_
judge - Ask the
[roles] dupes_judgechain, or inheritchatterwhen unset. With neither role set, use the default agent. Each agent is tried at most once, with a fresh seat; only an error, quota or unusable answer moves on. A usable answer that does not parse ends the chain. - check
- Look for work already in flight that
text(andreview_branch, for a review-only run) points at.repois the repository the new work is for;ignore_taskis a task being edited, whose own claims never count. - check_
with checkwith the forge lookup supplied:open_pr(repo, n)says whether pull requestnofrepois open (Some(url)) or not / unknown (None). It is asked only about numbers the text names that no local record already explained, so a PR magi never produced (opened by hand) still collides.pr_state(repo, n)is the forge’s word on a pull request a run record calls open (None= unreadable, which keeps the claim); see [Staleness].- screen
- The one decision point every caller shares.
hitsischeck’s output: empty passes without the judge being asked. Otherwise the judge is asked once (a long text is squeezed to its head and tail first), and only aduplicate: trueanswer refuses (with its reason). - screen_
with_ config screenwith the production judge:dupes_judge, inheritingchatterwhen unset. No config (None) means no judge, so a hit is let through unjudged.
Type Aliases§
- Judge
Future - A judge: given the instruction and the matched claims, rules on them. Owned arguments, so a boxed future needs no borrow.