Skip to main content

Module dupes

Module dupes 

Source
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: its review_branch, and each run in Task::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 screen let work through.
Signal
What kind of identifier matched.

Functions§

chain_judge
Ask the [roles] dupes_judge chain, or inherit chatter when 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 (and review_branch, for a review-only run) points at. repo is the repository the new work is for; ignore_task is a task being edited, whose own claims never count.
check_with
check with the forge lookup supplied: open_pr(repo, n) says whether pull request n of repo is 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. hits is check’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 a duplicate: true answer refuses (with its reason).
screen_with_config
screen with the production judge: dupes_judge, inheriting chatter when unset. No config (None) means no judge, so a hit is let through unjudged.

Type Aliases§

JudgeFuture
A judge: given the instruction and the matched claims, rules on them. Owned arguments, so a boxed future needs no borrow.