Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
fix(claims): preserve retained owners and ignore declined requests (#2010)
Alpamys Makazhane5ef131ec30e
diff --git a/changelog.d/0.76.0/2010.fixed.md b/changelog.d/0.76.0/2010.fixed.mdnew file mode 100644index 00000000..1acf3548--- /dev/null+++ b/changelog.d/0.76.0/2010.fixed.md@@ -0,0 +1,4 @@+- **Keep the claim board with the accepted owner when a competing take is declined (#2010).**+ A maintainer's explicit reaffirmation is checked against the matching open pull request,+ preserving that author's claim date and PR link. Declined requests no longer appear as+ unconfirmed owners; quoted or withdrawn decline instructions do not reject a request.diff --git a/scripts/claim_board.py b/scripts/claim_board.pyindex 0c67fc50..785afb10 100644--- a/scripts/claim_board.py+++ b/scripts/claim_board.py@@ -68,6 +68,7 @@ _ClaimTarget = tuple[str | None, tuple[str, str] | None]_ACCEPT_EVENT = 0_UNCERTAIN_ACCEPT_EVENT = 1_TERMINAL_EVENT = 2+_DECLINE_EVENT = 3class BoardError(Exception):@@ -175,7 +176,66 @@ def _terminal_targets(body: str) -> list[_ClaimTarget]:return targets-def _claim_state(comments: list[dict], number: int) -> tuple[str | None, str | None, bool, bool]:+def _declined_requests(body: str, number: int) -> list[_ClaimTarget]:+ body = re.sub(r"`+[^`\n]*`+", "", body)+ addressed = re.match(+ r"^\s*(?:(?:thank you|thanks|confirmed)\s*[,!:]?\s*)?@([a-z0-9-]+)\b",+ body, re.IGNORECASE,+ )+ if addressed is None:+ return []+ login = addressed.group(1).casefold()+ for fact in re.split(r"(?<=[.!?;])\s+|\n", body[addressed.end():].lstrip(" ,:!")):+ fact = fact.strip()+ if fact.endswith("?") or _CONDITIONAL_RE.search(fact):+ continue+ if "@" in fact and not re.search(rf"@{re.escape(login)}\b", fact, re.IGNORECASE):+ continue+ if re.match(+ rf"(?:\b(?:this issue|it)|#{number}\b)\s+is not yours\b|"+ rf"(?:so\s+)?(?:please\s+)?do not open (?:a )?(?:separate|competing) "+ rf"pull request for #{number}\b",+ fact, re.IGNORECASE,+ ):+ return [(login, None)]+ return []+++def _retained_pr(body: str, prs: list[dict], number: int, when: str) -> dict | None:+ body = re.sub(r"`+[^`\n]*`+", "", body)+ # A later clause can withdraw the apparent assertion; keep the whole paragraph.+ context = re.sub(r"@[a-z0-9-]+", "", body, flags=re.IGNORECASE)+ if re.search(+ r"\b(?:not|no longer|old|earlier|previous|withdrawn|superseded|incorrect)\b",+ context, re.IGNORECASE,+ ):+ return None+ for fact in re.split(r"(?<=[.!?;])\s+|\n", body):+ if fact.endswith("?") or _CONDITIONAL_RE.search(fact):+ continue+ retained = re.search(+ rf"(?:^|,\s+so\s+)(?:#{number}\b|this issue)\s+(?:stays|remains) with "+ r"@([a-z0-9-]+)\b", fact, re.IGNORECASE,+ )+ if retained is None:+ continue+ login = retained.group(1)+ matches = [+ pr for pr in prs+ if _login(pr).casefold() == login.casefold() and pr.get("state") == "open"+ and pr.get("created_at") and pr["created_at"] <= when+ and re.search(+ rf"#{pr['number']}\b\s+by\s+@{re.escape(login)}\b", body, re.IGNORECASE+ )+ ]+ if len(matches) == 1:+ return matches[0]+ return None+++def _claim_state(+ comments: list[dict], number: int, prs: list[dict] | None = None+) -> tuple[str | None, str | None, bool, bool, int | None]:"""Reduce trusted owner facts, keeping scoped claims until explicitly completed/released."""events: list[tuple[str, int, int, int, str | dict | list[_ClaimTarget]]] = []for index, item in enumerate(sorted(comments, key=lambda entry: entry["created_at"])):@@ -183,7 +243,11 @@ def _claim_state(comments: list[dict], number: int) -> tuple[str | None, str | Ncreated, updated = item["created_at"], item.get("updated_at", item["created_at"])terminal_at = createdseen = set()- for part, body in enumerate(_claim_paragraphs(item.get("body", ""))):+ paragraphs = _claim_paragraphs(item.get("body", ""))+ declined = _declined_requests("\n\n".join(paragraphs), number)+ if declined:+ events.append((created, index, -1, _DECLINE_EVENT, declined))+ for part, body in enumerate(paragraphs):named = _named_confirmation(body, number)requests = [reply for reply in comments@@ -215,28 +279,37 @@ def _claim_state(comments: list[dict], number: int) -> tuple[str | None, str | Nelif _login(item):events.append((item["created_at"], index, -1, _ACCEPT_EVENT, item))replies: list[dict] = []- active: dict[_ClaimTarget, tuple[str | None, str | None]] = {}+ active: dict[_ClaimTarget, tuple[str | None, str | None, int | None]] = {}terminal = False- for _, _, part, action, value in sorted(events):+ for when, _, part, action, value in sorted(events):if isinstance(value, dict):replies.append(value)continueif isinstance(value, str):+ retained = _retained_pr(value, prs or [], number, when)+ if retained is not None:+ login = _login(retained)+ active[(login.casefold(), None)] = (+ login, retained["created_at"][:10], retained["number"]+ )+ continue+ if _declined_requests(value, number):+ continueif action == _UNCERTAIN_ACCEPT_EVENT and terminal:- active[(None, _scope(value))] = (None, None)+ active[(None, _scope(value))] = (None, None, None)continueacceptance = _acceptance(value, replies, number)if acceptance is not None:login, since, scope = acceptance- active[(login.casefold() if login else None, scope)] = (login, since)+ active[(login.casefold() if login else None, scope)] = (login, since, None)continuefor login, scope in value:- terminal = True-def matches(author: str | None, subject: tuple[str, str] | None) -> bool:return (login is None or author == login) and (scope is None or subject == scope)- active = {key: claim for key, claim in active.items() if not matches(*key)}+ if action != _DECLINE_EVENT:+ terminal = True+ active = {key: claim for key, claim in active.items() if not matches(*key)}replies = [item for item in repliesif not matches(_login(item).casefold(), _scope(item.get("body", "")))@@ -244,18 +317,18 @@ def _claim_state(comments: list[dict], number: int) -> tuple[str | None, str | Nowners = {login for login, _ in active}if active:if None in owners or len(owners) != 1:- return None, None, True, terminal- login, since = min(active.values(), key=lambda claim: claim[1] or "")- return login, since, True, terminal+ return None, None, True, terminal, None+ login, since, pr = min(active.values(), key=lambda claim: claim[1] or "")+ return login, since, True, terminal, prfor item in replies:if _TAKE_RE.search(item.get("body", "")):- return _login(item), item["created_at"][:10], False, terminal- return None, None, False, terminal+ return _login(item), item["created_at"][:10], False, terminal, None+ return None, None, False, terminal, Nonedef find_claimant(comments: list[dict], issue_number: int) -> tuple[str | None, str | None, bool]:"""Return (login, since date, confirmed); several active owners need "see thread"."""- login, since, confirmed, _ = _claim_state(comments, issue_number)+ login, since, confirmed, _, _ = _claim_state(comments, issue_number)return login, since, confirmed@@ -303,7 +376,7 @@ def classify(issue: dict, comments: list[dict], prs: list[dict], now: datetime, is_open=_always_open) -> dict:labels = label_names(issue)- login, since, confirmed, terminal = _claim_state(comments, issue["number"])+ login, since, confirmed, terminal, claimed_pr = _claim_state(comments, issue["number"], prs)block = blocker(issue, comments, is_open)claimed = confirmed or ("claimed" in labels and not terminal)if block:@@ -327,7 +400,8 @@ def classify("difficulty": difficulty(issue),"kind": kind,"state": state,- "pr": find_pr(prs, issue["number"], login) if kind != "free" and metrics else None,+ "pr": (claimed_pr or find_pr(prs, issue["number"], login))+ if kind != "free" and metrics else None,"quiet": quiet_days(comments, login, now) if kind != "free" and metrics else None,}diff --git a/tests/test_claim_board.py b/tests/test_claim_board.pyindex 3220b249..b591f023 100644--- a/tests/test_claim_board.py+++ b/tests/test_claim_board.py@@ -283,6 +283,171 @@ def test_late_competitor_request_does_not_replace_the_confirmed_incumbent():assert row["pr"] == 91 and row["quiet"] == 13+def test_reaffirmed_open_pr_outranks_a_declined_competing_take():+ """#1432's owner claimed through a PR before the competing issue comment."""+ comments = [+ comment("bob", "I'd like to take this one. Here is my plan.",+ "2026-10-03T10:33:31Z"),+ comment(+ board.MAINTAINER,+ "Thank you, @bob. The plan is sound.\n\n"+ "#7 already has an open pull request: #91 by @alice, opened on 2026-09-30. "+ "An open pull request counts as a claim and the first claim stands, "+ "so #7 stays with @alice.\n\n"+ "So please do not open a separate pull request for #7.\n\n"+ "If #91 is released, this thread will say so.",+ "2026-10-04T15:51:20Z",+ ),+ ]+ prs = [dict(pull(91, "alice", "Thread the freeze plan into layer selection."),+ title="Respect the freeze plan (#7)", state="open",+ created_at="2026-09-30T15:33:36Z")]+ row = board.classify(issue(7, ("claimed",)), comments, prs, NOW)+ assert row["state"] == "claimed by `@alice` since 2026-09-30"+ assert row["pr"] == 91 and row["quiet"] is None+ assert board.render([row], NOW).splitlines()[-1] == (+ "| #7 | `Some title` | - | claimed by `@alice` since 2026-09-30 | #91 | - |"+ )+++ "reply",+ [+ "Thank you, @bob. The plan is sound.\n\n"+ "Please do not open a separate pull request for #7.",+ "Confirmed, @bob: this issue is not yours.",+ "Confirmed, @bob: #7 is not yours.",+ ],+)+def test_an_explicitly_declined_take_is_not_an_unconfirmed_owner(reply):+ comments = [+ comment("bob", "I'll take this.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, reply, "2026-10-04T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(92, "bob", "Refs #7")], NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None+++def test_an_edited_old_decline_cannot_become_a_positive_confirmation():+ comments = [+ comment(board.MAINTAINER, "Confirmed, @bob: this issue is not yours.",+ "2026-10-01T10:00:00Z", "2026-10-04T10:00:00Z"),+ comment("bob", "I'll take this.", "2026-10-03T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(92, "bob", "Refs #7")], NOW)+ assert row["state"] == "claimed by `@bob` since 2026-10-03 (unconfirmed)"+ assert row["pr"] == 92 and row["quiet"] == 11+++def test_a_declined_reacceptance_cannot_create_an_uncertain_accepted_owner():+ comments = [+ comment("bob", "Taking item 2.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @bob: item 2 is yours.\n\n"+ "Confirmed, @bob: this issue is not yours; item 2 remains unclaimed.",+ "2026-10-02T10:00:00Z", "2026-10-08T10:00:00Z"),+ comment(board.MAINTAINER, "The claim is released.", "2026-10-05T10:00:00Z"),+ comment("bob", "Taking item 2 again.", "2026-10-07T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(92, "bob", "Refs #7")], NOW)+ assert row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None+++ "metadata",+ [+ {"user": {"login": "carol"}},+ {"state": "closed"},+ {"created_at": "2026-10-05T10:00:00Z"},+ {"number": 92},+ ],+)+def test_reaffirmed_pr_owner_needs_matching_open_prior_pr_metadata(metadata):+ comments = [+ comment("bob", "I'll take this.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, "Thank you, @bob.\n\n#7 stays with @alice. "+ "#91 by @alice already carries it.\n\n"+ "Please do not open a competing pull request for #7.",+ "2026-10-04T10:00:00Z"),+ ]+ pr = dict(pull(91, "alice", "Fixes #7"), state="open",+ created_at="2026-09-30T10:00:00Z")+ pr.update(metadata)+ row = board.classify(issue(7, ("claimed",)), comments, [pr], NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None+++def test_a_declined_request_can_be_accepted_after_a_new_take():+ comments = [+ comment("bob", "I'll take this.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @bob: this issue is not yours.",+ "2026-10-02T10:00:00Z"),+ comment("bob", "I'll take this again.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed.", "2026-10-04T10:00:00Z"),+ ]+ row = board.classify(issue(7), comments, [pull(92, "bob", "Refs #7")], NOW)+ assert row["state"] == "claimed by `@bob` since 2026-10-03"+ assert row["pr"] == 92 and row["quiet"] == 11+++def test_declining_a_competitor_and_a_conditional_release_preserve_the_active_owner():+ comments = [+ comment("alice", "I'll take this.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @alice: it is yours.",+ "2026-10-02T10:00:00Z"),+ comment("bob", "I'll take this too.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, "Thank you, @bob. Please do not open a separate "+ "pull request for #7. If the claim is released, this thread will say so.",+ "2026-10-04T10:00:00Z"),+ ]+ row = board.classify(issue(7), comments, [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "claimed by `@alice` since 2026-10-01"+ assert row["pr"] == 91 and row["quiet"] == 13+++ "reply",+ [+ "Thank you, @bob. The earlier instruction, "+ "`do not open a separate pull request for #7`, no longer applies.",+ "Thank you, @bob. The earlier instruction, "+ "do not open a separate pull request for #7, no longer applies.",+ "Thank you, @bob. The old note was "+ "`#91 by @alice, so #7 stays with @alice`; it is no longer correct.",+ "Thank you, @bob. It is not true that #7 stays with @alice. "+ "#91 by @alice is the old pull request.",+ "Thank you, @bob. The old note said #91 by @alice carries it, "+ "so #7 stays with @alice; that is no longer correct.",+ "Thank you, @bob. #91 by @alice carries it, so #7 stays with @alice. "+ "That ruling is no longer correct.",+ ],+)+def test_quoted_or_negated_claim_instructions_do_not_change_a_take_request(reply):+ comments = [+ comment("bob", "I'll take this.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, reply, "2026-10-04T10:00:00Z"),+ ]+ prs = [dict(pull(91, "alice", "Refs #7"), state="open",+ created_at="2026-09-30T10:00:00Z"), pull(92, "bob", "Refs #7")]+ row = board.classify(issue(7, ("claimed",)), comments, prs, NOW)+ assert row["state"] == "claimed by `@bob` since 2026-10-03 (unconfirmed)"+ assert row["pr"] == 92 and row["quiet"] == 11++[email protected]("verb", ["stays", "remains"])+def test_direct_current_retention_names_the_verified_open_pr_owner(verb):+ comments = [comment(board.MAINTAINER, f"#7 {verb} with @alice. "+ "#91 by @alice is the current open pull request.",+ "2026-10-04T10:00:00Z")]+ prs = [dict(pull(91, "alice", "Fix the layer selection."), state="open",+ created_at="2026-09-30T10:00:00Z")]+ row = board.classify(issue(7, ("claimed",)), comments, prs, NOW)+ assert row["state"] == "claimed by `@alice` since 2026-09-30"+ assert row["pr"] == 91 and row["quiet"] is None++def test_accepting_an_overlapping_second_owner_does_not_silently_pick_a_winner():comments = [comment("alice", "I'll take item 2.", "2026-10-01T10:00:00Z"),