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(maintainer): clear completed claims and preserve scoped ownership (#1974)
Alpamys Makazhanf529e3075f0a
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.mdindex e5f47445..927b1f0b 100644--- a/CONTRIBUTORS.md+++ b/CONTRIBUTORS.md@@ -237,6 +237,7 @@ Listed by first contribution. PR numbers link the work.- Accepted leading UTF-8 signatures in JSON, CSV and TXT datasets while preserving embedded U+FEFF content ([#1922](https://github.com/MakazhanAlpamys/Soup/issues/1922), [#1954](https://github.com/MakazhanAlpamys/Soup/pull/1954)).- **AmixDigital** ([@Amix29](https://github.com/Amix29))+ - Added native Sesame CSM fine-tuning for transcript/audio pairs, training the backbone and depth decoder while keeping the Mimi codec frozen; documented supported inputs, refusals and the scoped Apple Silicon evidence ([#265](https://github.com/MakazhanAlpamys/Soup/issues/265), [#1769](https://github.com/MakazhanAlpamys/Soup/pull/1769)).- Gave `soup monitor` a real Apple Silicon path, where it had reported nothing but an NVIDIA-shaped blank since v0.44.1. The security work is the part worth naming: fixed absolute executable paths so `PATH` cannot influence what runs, `sudo -n` that never prompts and never reads a password, stderr pattern-matched for permission markers but never printed, and a parser that returns `[]` against a billion-laughs entity bomb, an XXE `file:///` reference, 5,000-deep nesting and embedded NUL bytes. **Three guards had no test holding them up and they closed all three in twenty minutes** — most importantly the call site that decides which implementation every Linux and Windows user gets, where `if True or detect_apple_silicon()` had left 126 tests passing. Their oversize-payload test had also been asserting on `b"x" * (CAP + 1)`, which is not a valid plist and returns `[]` whether the cap exists or not; they rebuilt it around a valid oversized document. The test file shrank by 18 lines and **every deletion was an upgrade** — membership assertions became adjacency assertions. Asked to confirm the live plist schema, they said plainly that the Mac is not theirs and they cannot authenticate `sudo`, rather than guessing — while confirming the two things they could check against the real binary ([#481](https://github.com/MakazhanAlpamys/Soup/pull/481))- Wrapped Aider's Polyglot benchmark as `soup eval aider`, and **verified the upstream contract before writing a line** — the `aider-chat` wheel carries no benchmark at all (235 entries, zero matching `benchmark`, an `args.py` with 135 `add_argument` calls and no `--polyglot`), so they wrapped the real source/image harness instead of a flag that does not exist, and said so in the issue first. The container contract held up to everything I threw at it: `--rm`, a `readonly` corpus mount, no `docker.sock`, no `--privileged`, `shell=False`, and credentials inherited **by name** so no secret value reaches argv. **The blocker was a test that could not fail** — `pytest.raises(match="symlink")` searches the whole message, the message embeds the path, and pytest's tmp_path is named after the test function, so removing both symlink guards still left 16 tests passing while a *different* guard tripped the assertion. They fixed it with the isolating case I could not have asked for more precisely: a symlink whose target stays **inside** the result root, which is the one case `is_under` containment cannot catch. Also closed three hardening gaps in the same push — non-finite counts escaping as bare `ValueError`, `--image=--privileged` landing in the image argv slot, and an exercises directory resolving outside cwd — and validated the new image check in **both** directions, since a validator that rejects `ghcr.io/org/img:tag` is worse than the bug ([#482](https://github.com/MakazhanAlpamys/Soup/pull/482))- Caught that layer streaming's core promise — the frozen base "lives in CPU RAM" — was **false on Apple Silicon**: from PyTorch 2.7 on, `torch.empty(device="cpu", pin_memory=True)` hands back an `mps:0` tensor whose `is_pinned()` is false, so a 256 MiB store raised `torch.mps.current_allocated_memory()` by exactly 256 MiB. Their CHANGELOG entry says out loud that the shipped `soup train` path already gated pinning on CUDA, so the fix is the lower-level boundary rather than a user-visible bug — declining a bigger claim than the evidence supports. **All three guards I flagged had nothing holding them up**, including the MPS gate itself, where the only test was `skipif`-gated and therefore skipped everywhere but a Mac: disabling the gate entirely left 15 tests passing. Their replacement is platform-independent and **fails on a Windows box**, which is the difference between coverage and green-because-skipped. They also rebuilt the test that could not discriminate the real bug — it simulated the misplaced allocation with `device="meta"`, so a guard narrowed to `== "meta"` would have let the actual `mps` tensor through — and folded in the `require_pin` announcement so pinning is never dropped in silence ([#480](https://github.com/MakazhanAlpamys/Soup/pull/480))@@ -934,6 +935,9 @@ Listed by first contribution. PR numbers link the work.- **DBVamsi** ([@DBVamsi](https://github.com/DBVamsi))- Refused `training.neftune_alpha` at config load on tasks that never apply it, and documented the supported tasks ([#1820](https://github.com/MakazhanAlpamys/Soup/issues/1820), [#1883](https://github.com/MakazhanAlpamys/Soup/pull/1883))+- **dipesh-singh07** ([@dipesh-singh07](https://github.com/dipesh-singh07))+ - Made oversized integer baseline scores follow the existing usage-error path across the writer, reader and eval gate; the shared finite-score helper preserves healthy controls, and removing the overflow handler fails 14 regressions ([#1865](https://github.com/MakazhanAlpamys/Soup/issues/1865), [#1903](https://github.com/MakazhanAlpamys/Soup/pull/1903)).+---Want to join this list? See [CONTRIBUTING.md](CONTRIBUTING.md) — good first issues arediff --git a/changelog.d/0.76.0/1865.fixed.md b/changelog.d/0.76.0/1903.fixed.mdsimilarity index 100%rename from changelog.d/0.76.0/1865.fixed.mdrename to changelog.d/0.76.0/1903.fixed.mddiff --git a/changelog.d/0.76.0/1974.fixed.md b/changelog.d/0.76.0/1974.fixed.mdnew file mode 100644index 00000000..73efb6b1--- /dev/null+++ b/changelog.d/0.76.0/1974.fixed.md@@ -0,0 +1 @@+- Respect completed and released claims on the claim board, preserve active scoped owners across unrelated edits to old comments, and recognise leading Taking requests when linking ready or draft pull requests. A completion in the same paragraph also clears an uncertain repeated acceptance. (#1974 by @MakazhanAlpamys)diff --git a/scripts/claim_board.py b/scripts/claim_board.pyindex e740e2ec..0c67fc50 100644--- a/scripts/claim_board.py+++ b/scripts/claim_board.py@@ -32,20 +32,42 @@ GUIDE_URL = f"https://github.com/{REPO}/blob/main/CONTRIBUTING.md#how-work-is-quTITLE_WIDTH = 60GENERATED_PREFIX = "Generated: "-_CONFIRM_RE = re.compile(r"^\s*confirmed\b|\b(?:is|are) yours\b", re.IGNORECASE | re.MULTILINE)+_CONFIRM_RE = re.compile(+ r"^\s*confirmed\b|\b(?:is|are|it['’]s) yours\b", re.IGNORECASE | re.MULTILINE+)_NAMED_CONFIRM_RE = re.compile(r"^\s*confirmed\s*[,!:]?\s*@([a-z0-9-]+)\b", re.IGNORECASE)_LEADING_LOGIN_RE = re.compile(r"^\s*@([a-z0-9-]+)\b([^@\n]*)", re.IGNORECASE)_DIRECT_CONFIRM_RE = re.compile(- r"^\s*(?:confirmed(?:[,.!]|$)|(?:it|this) is yours\b)", re.IGNORECASE+ r"^\s*(?:confirmed(?:[,.!]|$)|(?:it(?: is|['’]s)|this is) yours\b)", re.IGNORECASE)-_TAKE_RE = re.compile(+_CLASSIC_TAKE_RE = re.compile(r"\b(?:i'd like to take|i would like to take|i'll take|i will take|take this"r"|claim this|i claim)\b",re.IGNORECASE,)+_TAKE_RE = re.compile(_CLASSIC_TAKE_RE.pattern + r"|^\s*(?:i am )?taking\b", re.IGNORECASE)+_SCOPE_RE = re.compile(r"\b(item|fix)[ -](\d+)\b", re.IGNORECASE)+_TERMINAL_RE = re.compile(+ r"\b(?:is|was|has been) (?:completed|fulfilled|released)\b|\bis now done\b",+ re.IGNORECASE,+)+_TERMINAL_SUBJECT_RE = re.compile(+ r"^(?:(?:status|claim metadata) update:\s*)?(?:the\s+)?(?:accepted\s+)?"+ r"(?:claim\b|(?:item|fix)[ -]\d+\b|[a-z-]+\s+slice\b)",+ re.IGNORECASE,+)+_CLEAR_ALL_RE = re.compile(+ r"^(?:this issue is free to take|no remaining slice has an accepted claim)\b",+ re.IGNORECASE,+)+_CONDITIONAL_RE = re.compile(r"\b(?:if|unless|once|when|only after|as long as)\b", re.IGNORECASE)_LINK_WORDS = r"(?:close[sd]?|fix(?:es|ed)?|resolve[sd]?|refs?|part of)"_AFTER_RE = re.compile(r"\bafter\s+#(\d+)", re.IGNORECASE)_DIFFICULTY_RE = re.compile(r"^difficulty:(\d+)$")+_ClaimTarget = tuple[str | None, tuple[str, str] | None]+_ACCEPT_EVENT = 0+_UNCERTAIN_ACCEPT_EVENT = 1+_TERMINAL_EVENT = 2class BoardError(Exception):@@ -77,51 +99,164 @@ def _named_confirmation(body: str, issue_number: int) -> tuple[str, bool] | Nonenamed = _NAMED_CONFIRM_RE.match(body)if named:acceptance = body[named.end() :].split("@", 1)[0].split("\n", 1)[0]- owns = bool(re.search(r"\b(?:is|are) yours\b", acceptance, re.IGNORECASE))+ owns = bool(re.search(r"\b(?:is|are|it['’]s) yours\b", acceptance, re.IGNORECASE))return named.group(1), ownsleading = _LEADING_LOGIN_RE.match(body)if leading and re.search(- rf"(?:#{issue_number}\b|\bthis issue)\s+is yours\b", leading.group(2), re.IGNORECASE+ rf"(?:(?:#{issue_number}\b|\bthis issue)\s+is|it(?:['’]s|\s+is)) yours\b",+ leading.group(2), re.IGNORECASE,):return leading.group(1), True+ thanks = re.match(r"^\s*thanks\s*,?\s+@([a-z0-9-]+)\b([^@]*)", body, re.IGNORECASE)+ if thanks and re.search(r"\b(?:item|fix) \d+ is yours\b", thanks.group(2), re.IGNORECASE):+ return thanks.group(1), Truereturn None-def find_claimant(comments: list[dict], issue_number: int) -> tuple[str | None, str | None, bool]:- """Return (login, since date, confirmed).-- Prefer the latest direct acceptance, binding a named login to an API author.- A generic acceptance needs the preceding contributor's own take request.- Ambiguous claim evidence returns (None, None, True), for "claimed (see thread)".- Without acceptance, retain the first take request as unconfirmed.- """- ordered = sorted(comments, key=lambda item: item["created_at"])- for index in range(len(ordered) - 1, -1, -1):- comment = ordered[index]- body = comment.get("body", "")- if _login(comment) != MAINTAINER or not _CONFIRM_RE.search(body):+def _claim_paragraphs(body: str) -> list[str]:+ """Ignore quoted examples; only the author's own prose can change a claim."""+ lines, fenced = [], False+ for line in body.splitlines():+ if line.lstrip().startswith(("```", "~~~")):+ fenced = not fenced+ elif not fenced and not line.lstrip().startswith(">"):+ lines.append(re.sub(r'"[^"\n]*"', "", line))+ parts = re.split(+ r"\n\s*\n|(?<=[.!?])\s+(?=confirmed\s*[,!:]?\s*@)",+ "\n".join(lines), flags=re.IGNORECASE,+ )+ return [part.strip() for part in parts if part.strip()]+++def _scope(body: str) -> tuple[str, str] | None:+ match = _SCOPE_RE.search(body)+ return (match.group(1).lower(), match.group(2)) if match else None+++def _acceptance(+ body: str, earlier: list[dict], number: int+) -> tuple[str | None, str | None, tuple[str, str] | None] | None:+ facts = re.split(r"(?<=[.!?;])\s+|\n", body)+ if not any(+ _CONFIRM_RE.search(fact) and not fact.endswith("?") and not _CONDITIONAL_RE.search(fact)+ for fact in facts+ ):+ return None+ named = _named_confirmation(body, number)+ if named is not None:+ login, owns = named+ matches = [item for item in earlier if _login(item).casefold() == login.casefold()]+ requests = [item for item in matches if _TAKE_RE.search(item.get("body", ""))]+ if not owns and not requests:+ return None+ if matches:+ item = (requests or matches)[-1]+ return _login(item), item["created_at"][:10], _scope(body) or _scope(item["body"])+ return None, None, _scope(body)+ if _DIRECT_CONFIRM_RE.match(body) and earlier:+ previous = earlier[-1]+ if _TAKE_RE.search(previous.get("body", "")):+ return _login(previous), previous["created_at"][:10], _scope(previous["body"])+ if any(_TAKE_RE.search(item.get("body", "")) for item in earlier):+ return None, None, _scope(body)+ return None+++def _terminal_targets(body: str) -> list[_ClaimTarget]:+ targets: list[_ClaimTarget] = []+ for sentence in re.split(r"(?<=[.!?;])\s+|\n", body):+ if sentence.endswith("?") or _CONDITIONAL_RE.search(sentence):+ continue+ if _CLEAR_ALL_RE.search(sentence):+ targets.append((None, None))+ elif _TERMINAL_SUBJECT_RE.match(sentence) and _TERMINAL_RE.search(sentence):+ named = re.search(r"@([a-z0-9-]+)\b", sentence, re.IGNORECASE)+ targets.append((named.group(1).casefold() if named else None, _scope(sentence)))+ return targets+++def _claim_state(comments: list[dict], number: int) -> tuple[str | None, str | None, bool, bool]:+ """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"])):+ if _login(item) == MAINTAINER:+ created, updated = item["created_at"], item.get("updated_at", item["created_at"])+ terminal_at = created+ seen = set()+ for part, body in enumerate(_claim_paragraphs(item.get("body", ""))):+ named = _named_confirmation(body, number)+ requests = [+ reply for reply in comments+ if named and _login(reply).casefold() == named[0].casefold()+ and _TAKE_RE.search(reply.get("body", ""))+ and (_scope(body) is None or _scope(reply["body"]) == _scope(body))+ and reply["created_at"] <= updated+ ]+ # Only a request that postdates creation establishes an appended acceptance.+ # An unrelated edit must not replay an old acceptance, in any paragraph.+ appended = bool(requests) and not any(+ reply["created_at"] <= created for reply in requests+ )+ key = (named[0].casefold(), _scope(body)) if named else None+ uncertain = key in seen and any(+ reply["created_at"] > created for reply in requests+ )+ accepted_at = updated if appended or uncertain else created+ events.append((accepted_at,+ index, part,+ _UNCERTAIN_ACCEPT_EVENT if uncertain else _ACCEPT_EVENT, body))+ seen.add(key)+ # An edit timestamp cannot date an old release. Keep its creation time,+ # except when it follows an appended acceptance in this same comment.+ terminal_at = max(terminal_at, accepted_at)+ targets = _terminal_targets(body)+ if targets:+ events.append((terminal_at, index, part, _TERMINAL_EVENT, targets))+ elif _login(item):+ events.append((item["created_at"], index, -1, _ACCEPT_EVENT, item))+ replies: list[dict] = []+ active: dict[_ClaimTarget, tuple[str | None, str | None]] = {}+ terminal = False+ for _, _, part, action, value in sorted(events):+ if isinstance(value, dict):+ replies.append(value)continue- earlier = [item for item in ordered[:index] if _login(item) not in (MAINTAINER, "")]- named = _named_confirmation(body, issue_number)- if named is not None:- login, owns = named- matches = [item for item in earlier if _login(item).casefold() == login.casefold()]- if not owns and not any(_TAKE_RE.search(item.get("body", "")) for item in matches):+ if isinstance(value, str):+ if action == _UNCERTAIN_ACCEPT_EVENT and terminal:+ active[(None, _scope(value))] = (None, None)continue- if matches:- item = matches[-1]- return _login(item), item["created_at"][:10], True- return None, None, True- if _DIRECT_CONFIRM_RE.match(body) and earlier:- previous = earlier[-1]- if _TAKE_RE.search(previous.get("body", "")):- return _login(previous), previous["created_at"][:10], True- if any(_TAKE_RE.search(item.get("body", "")) for item in earlier):- return None, None, True- for comment in ordered:- if _login(comment) not in (MAINTAINER, "") and _TAKE_RE.search(comment.get("body", "")):- return _login(comment), comment["created_at"][:10], False- return None, None, False+ acceptance = _acceptance(value, replies, number)+ if acceptance is not None:+ login, since, scope = acceptance+ active[(login.casefold() if login else None, scope)] = (login, since)+ continue+ for 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)}+ replies = [+ item for item in replies+ if not matches(_login(item).casefold(), _scope(item.get("body", "")))+ ]+ owners = {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+ for item in replies:+ if _TAKE_RE.search(item.get("body", "")):+ return _login(item), item["created_at"][:10], False, terminal+ return None, None, False, terminal+++def 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)+ return login, since, confirmeddef _always_open(number: int) -> bool:@@ -168,9 +303,9 @@ def classify(issue: dict, comments: list[dict], prs: list[dict], now: datetime, is_open=_always_open) -> dict:labels = label_names(issue)- login, since, confirmed = find_claimant(comments, issue["number"])+ login, since, confirmed, terminal = _claim_state(comments, issue["number"])block = blocker(issue, comments, is_open)- claimed = "claimed" in labels or confirmed+ claimed = confirmed or ("claimed" in labels and not terminal)if block:kind, state = "blocked", f"blocked: {block}"elif claimed and login:@@ -182,14 +317,18 @@ def classify(kind, state = "claimed", "claimed (see thread)"else:kind, state = "free", "free"+ metrics = claimed or (not terminal and any(+ _login(item) == login and _CLASSIC_TAKE_RE.search(item.get("body", ""))+ for item in comments+ ))return {"number": issue["number"],"title": issue["title"],"difficulty": difficulty(issue),"kind": kind,"state": state,- "pr": find_pr(prs, issue["number"], login) if kind != "free" else None,- "quiet": quiet_days(comments, login, now) if kind != "free" else None,+ "pr": 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 8ed9d6d6..3220b249 100644--- a/tests/test_claim_board.py+++ b/tests/test_claim_board.py@@ -23,8 +23,13 @@ def issue(number, labels=("help wanted",), title="Some title"):return {"number": number, "title": title, "labels": [{"name": n} for n in labels]}-def comment(login, body, created):- return {"user": {"login": login}, "body": body, "created_at": created}+def comment(login, body, created, updated=None):+ return {+ "user": {"login": login},+ "body": body,+ "created_at": created,+ "updated_at": updated or created,+ }def pull(number, login, body):@@ -131,6 +136,380 @@ def test_latest_named_confirmation_replaces_a_completed_claim():assert row["pr"] == 1700 and row["quiet"] == 6[email protected]("labels", [("help wanted",), ("help wanted", "claimed")])+ "number, login, scope, acceptance, terminal",+ [+ (+ 1199,+ "Faisal-Fayaz",+ "fix 2",+ "Confirmed, @Faisal-Fayaz: fix 2 is yours.",+ "Status update: fix 2 by @Faisal-Fayaz is completed by merged #1728; "+ "fix 3 was completed by #1588. Thank you. The accepted fix-2 claim is "+ "fulfilled, so the stale `claimed` label is removed. This issue remains "+ "open for the explicitly unclaimed fix 1.",+ ),+ (+ 797,+ "Amix29",+ "item 2",+ "Confirmed, @Amix29: item 2 of the 2026-10-05 scope is yours.",+ "Claim metadata update: the accepted item-2 slice is completed by #1778, "+ "as recorded above, so the stale `claimed` label is removed. Items 1, 3 "+ "and 4 remain open and unclaimed. This issue stays open.",+ ),+ (+ 839,+ "sloemo01",+ "dropout item",+ "Welcome back, @sloemo01: the dropout item is yours again, the `claimed` "+ "label and the assignment are restored. Your plan matches the three points "+ "of the 2026-10-02 check-in, and #1784 is in review.",+ "Status update: the accepted dropout slice by @sloemo01 is completed by "+ "#1784 (merged as `1f9e1515`). Thank you. Its `claimed` label and completed "+ "assignment are cleared; this issue stays open for the separately listed "+ "CUDA/NF4 streaming qualification and micro-benchmark work. No remaining "+ "slice has an accepted claim in this thread.",+ ),+ (+ 1186,+ "chiliec",+ "item 3",+ "Thanks, @chiliec: item 3 is yours again and the claimed label is restored; "+ "#1782 is in review.",+ "Claim metadata update: item 3 is completed by #1746 and #1782, as "+ "recorded above, so the completed slice no longer reserves this aggregate "+ "issue. The stale `claimed` label is removed. Items 1 and 2 remain open "+ "and unclaimed; this is not a closure of those modality defects.",+ ),+ ],+)+def test_completed_claim_slices_are_free_despite_historical_acceptance(+ labels, number, login, scope, acceptance, terminal+):+ """The four live aggregate issues kept old claims after their accepted slices merged."""+ comments = [+ comment(login, f"I'll take {scope}.", "2026-10-01T10:00:00Z"),+ comment(+ board.MAINTAINER,+ acceptance,+ "2026-10-02T10:00:00Z",+ ),+ comment(board.MAINTAINER, terminal, "2026-10-03T10:00:00Z"),+ ]+ row = board.classify(+ issue(number, labels), comments, [pull(1990, login, f"Refs #{number}")], NOW+ )+ assert row["kind"] == "free" and row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None+++def test_appended_completion_overrides_acceptance_in_the_same_edited_comment():+ comments = [+ comment("alice", "I'll take fix 2.", "2026-10-01T10:00:00Z"),+ comment(+ board.MAINTAINER,+ "Confirmed, @alice: fix 2 is yours.\n\n"+ "Status update: fix 2 by @alice is completed by merged #90. "+ "The accepted fix-2 claim is fulfilled, so the stale `claimed` label is removed. "+ "Fix 1 remains open and unclaimed.",+ "2026-10-02T10:00:00Z",+ "2026-10-10T10:00:00Z",+ ),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None++[email protected]("separator", ["\n\n", " "])+def test_appended_acceptance_does_not_outlive_its_later_completion_in_the_same_comment(separator):+ comments = [+ comment(+ board.MAINTAINER,+ "Thanks for the detailed plan.\n\nConfirmed, @bob: item 2 is yours."+ + separator + "Item 2 is completed by merged #92.",+ "2026-10-02T10:00:00Z",+ "2026-10-10T10:00:00Z",+ ),+ comment("bob", "Taking item 2.", "2026-10-07T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(92, "bob", "Refs #7")], NOW)+ assert row["kind"] == "free" and row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None+++def test_issue_release_discards_old_requests_before_a_new_take_and_confirmation():+ comments = [+ comment("alice", "I'll take this", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed", "2026-10-02T10:00:00Z"),+ comment(board.MAINTAINER, "The claim is released. This issue is free to take.",+ "2026-10-03T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [], NOW)+ assert row["state"] == "free" and row["quiet"] is None+ comments.append(comment("bob", "I'll take this", "2026-10-05T10:00:00Z"))+ assert board.classify(issue(7, ("claimed",)), comments, [], NOW)["state"] == "free"+ comments.append(comment(board.MAINTAINER, "Confirmed", "2026-10-06T10:00:00Z"))+ row = board.classify(issue(7, ("claimed",)), comments, [pull(91, "bob", "Refs #7")], NOW)+ assert row["state"] == "claimed by `@bob` since 2026-10-05"+ assert row["pr"] == 91 and row["quiet"] == 9++[email protected]("take_text", ["Taking item 2.", "I am taking proposed fix 2."])[email protected]("draft", [False, True])+def test_leading_taking_request_binds_generic_acceptance_and_open_refs_pr(take_text, draft):+ comments = [+ comment("alice", take_text, "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, go ahead.", "2026-10-02T10:00:00Z"),+ ]+ pr = dict(pull(91, "alice", "Refs #7"), draft=draft)+ row = board.classify(issue(7), comments, [pr], NOW)+ assert row["state"] == "claimed by `@alice` since 2026-10-01"+ assert row["pr"] == 91 and row["quiet"] == 13+++def test_late_competitor_request_does_not_replace_the_confirmed_incumbent():+ comments = [+ comment("alice", "I'll take item 2.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @alice: item 2 is yours.",+ "2026-10-02T10:00:00Z"),+ comment("bob", "Taking item 2 too.", "2026-10-03T10:00:00Z"),+ ]+ prs = [pull(91, "alice", "Refs #7"), pull(92, "bob", "Refs #7")]+ row = board.classify(issue(7), comments, prs, NOW)+ assert row["state"] == "claimed by `@alice` since 2026-10-01"+ assert row["pr"] == 91 and row["quiet"] == 13+++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"),+ comment(board.MAINTAINER, "Confirmed, @alice: item 2 is yours.",+ "2026-10-02T10:00:00Z"),+ comment("bob", "Taking item 2.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @bob: item 2 is yours.",+ "2026-10-04T10:00:00Z"),+ ]+ prs = [pull(91, "alice", "Refs #7"), pull(92, "bob", "Refs #7")]+ row = board.classify(issue(7), comments, prs, NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None+++def test_completing_item_two_preserves_the_accepted_item_three_owner():+ comments = [+ comment("alice", "I'll take item 2.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @alice: item 2 is yours.",+ "2026-10-02T10:00:00Z"),+ comment("bob", "Taking item 3.", "2026-10-03T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @bob: item 3 is yours.",+ "2026-10-04T10:00:00Z"),+ comment(board.MAINTAINER, "Item 2 is completed by merged #90. "+ "The completed slice's `claimed` label is removed.",+ "2026-10-05T10: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_two_acceptances_in_one_edited_owner_comment_report_see_thread():+ """#808 has two accepted slices, with the second appended after a later take."""+ comments = [+ comment("alice", "I'll take item 2.", "2026-10-01T10:00:00Z"),+ comment(+ board.MAINTAINER,+ "Thanks @alice, and sorry for the wait. Item 2 is yours: the checkpoint flags.\n\n"+ "Confirmed, @bob: item 3 is yours, distinct from @alice's accepted item 2.",+ "2026-10-02T10:00:00Z",+ "2026-10-10T10:00:00Z",+ ),+ comment("bob", "Taking item 3.", "2026-10-05T10:00:00Z"),+ ]+ prs = [pull(91, "alice", "Refs #808"), pull(92, "bob", "Refs #808")]+ row = board.classify(issue(808), list(reversed(comments)), prs, NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None+++ "login, body",+ [+ ("bob", "The claim is released. The `claimed` label is removed."),+ (board.MAINTAINER, "> The claim is released.\nThe claim is not released."),+ (board.MAINTAINER, "```text\nThe claim is released.\n```\nThe claim remains active."),+ (board.MAINTAINER, "Do not remove the `claimed` label. Item 2 is not completed."),+ (board.MAINTAINER, 'The contributor wrote "The claim is released."; that is incorrect.'),+ (board.MAINTAINER, "The claim is released? Please confirm before we free it."),+ (board.MAINTAINER, "The claim is released only after #99 lands."),+ (board.MAINTAINER, "Do not write `This issue is free to take` until it is released."),+ (board.MAINTAINER, "Do not write `The stale claimed label is removed` yet."),+ (board.MAINTAINER, "It is not true that this issue is free to take."),+ (board.MAINTAINER, "The stale claimed label is removed because other slices are open; "+ "@alice retains item 2."),+ ],+)+def test_third_party_quoted_or_negated_terminal_text_does_not_clear_claim(login, body):+ comments = [+ comment("alice", "I'll take item 2.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "Confirmed, @alice: item 2 is yours.",+ "2026-10-02T10:00:00Z"),+ comment(login, body, "2026-10-03T10:00:00Z"),+ ]+ row = board.classify(+ issue(7), comments, [pull(91, "alice", "Refs #7")], NOW, lambda number: False+ )+ assert row["state"] == "claimed by `@alice` since 2026-10-01"+ assert row["pr"] == 91++[email protected]("prefix", ["", "Thanks for the detailed plan.\n\n"])+def test_unrelated_edit_of_old_acceptance_does_not_resurrect_a_released_claim(prefix):+ comments = [+ comment("alice", "I'll take this", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, prefix + "Confirmed, @alice: it is yours.\n\nTypo corrected.",+ "2026-10-02T10:00:00Z", "2026-10-10T10:00:00Z"),+ comment(board.MAINTAINER, "The claim is released. This issue is free to take.",+ "2026-10-05T10:00:00Z"),+ ]+ row = board.classify(issue(7, ("claimed",)), comments, [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None++[email protected]("prefix", ["", "Thanks for the detailed plan.\n\n"])+ "take, acceptance, release",+ [+ ("I'll take this.", "it is yours.", "The claim is released. This issue is free to take."),+ ("Taking item 2.", "item 2 is yours.", "Item 2 is released."),+ ],+)+def test_unrelated_edit_of_old_release_preserves_a_later_confirmed_owner(+ prefix, take, acceptance, release+):+ comments = [+ comment("alice", take, "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, f"Confirmed, @alice: {acceptance}",+ "2026-10-02T10:00:00Z"),+ comment(board.MAINTAINER, prefix + release + "\n\nTypo corrected.",+ "2026-10-05T10:00:00Z", "2026-10-10T10:00:00Z"),+ comment("bob", take, "2026-10-07T10:00:00Z"),+ comment(board.MAINTAINER, f"Confirmed, @bob: {acceptance}",+ "2026-10-08T10:00:00Z"),+ ]+ prs = [pull(91, "alice", "Refs #7"), pull(92, "bob", "Refs #7")]+ row = board.classify(issue(7, ("claimed",)), comments, prs, NOW)+ assert row["kind"] == "claimed"+ assert row["state"] == "claimed by `@bob` since 2026-10-07"+ assert row["pr"] == 92 and row["quiet"] == 7+ assert board.render([row], NOW).splitlines()[-1] == (+ "| #7 | `Some title` | - | claimed by `@bob` since 2026-10-07 | #92 | quiet 7 d |"+ )++[email protected]("separator", ["\n\n", " "])+def test_appended_same_scope_reacceptance_reports_uncertain_edit_chronology(separator):+ comments = [+ comment("alice", "Taking item 2.", "2026-10-01T10:00:00Z"),+ comment(+ board.MAINTAINER,+ "Confirmed, @alice: item 2 is yours." + separator+ + "Confirmed, @alice: item 2 is yours again.",+ "2026-10-02T10:00:00Z",+ "2026-10-08T10:00:00Z",+ ),+ comment(board.MAINTAINER, "The claim is released.", "2026-10-05T10:00:00Z"),+ comment("alice", "Taking item 2 again.", "2026-10-07T10:00:00Z"),+ ]+ row = board.classify(issue(7), comments, [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None++[email protected]("separator", ["\n\n", " "])+def test_explicit_completion_clears_an_uncertain_reacceptance_in_the_same_comment(separator):+ comments = [+ comment("alice", "Taking item 2.", "2026-10-01T10:00:00Z"),+ comment(+ board.MAINTAINER,+ "Confirmed, @alice: item 2 is yours.\n\n"+ "Confirmed, @alice: item 2 is yours again." + separator+ + "Item 2 is completed by merged #92.",+ "2026-10-02T10:00:00Z",+ "2026-10-08T10:00:00Z",+ ),+ comment(board.MAINTAINER, "The claim is released.", "2026-10-05T10:00:00Z"),+ comment("alice", "Taking item 2 again.", "2026-10-07T10:00:00Z"),+ ]+ row = board.classify(issue(7), comments, [pull(92, "alice", "Refs #7")], NOW)+ assert row["kind"] == "free" and row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None+++ "offer",+ [+ "@alice, the vision and audio sites are yours if you want them.",+ "If you want the other two afterwards, say so and they are yours.",+ ],+)+def test_a_conditional_offer_does_not_accept_an_earlier_take(offer):+ comments = [+ comment("alice", "Taking this one.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, offer, "2026-10-02T10:00:00Z"),+ ]+ row = board.classify(issue(7), comments, [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "free"+ assert row["pr"] is None and row["quiet"] is None++[email protected]("ownership", ["it's yours", "it’s yours", "it is yours"])+def test_named_remainder_acceptance_keeps_the_active_owner_over_an_older_taking_request(ownership):+ """#806's explicit remainder acceptance must outrank the completed earlier slice."""+ comments = [+ comment("AmirF194", "Taking this one. Scoping the fix to the flash-attn/liger half.",+ "2026-09-14T18:33:58Z"),+ comment("dchaudhari7177", "I'd like to take the reasoning_effort remainder.",+ "2026-10-03T10:28:10Z"),+ comment(board.MAINTAINER, f"@dchaudhari7177, {ownership}. Nobody else claimed the "+ "remainder after I opened it to anyone on 09-24, so I've labelled the issue "+ "`claimed`. Thanks for tracing it first.", "2026-10-04T15:51:53Z"),+ ]+ row = board.classify(issue(806, ("claimed",)), comments,+ [pull(1587, "dchaudhari7177", "Refs #806")], NOW)+ assert row["state"] == "claimed by `@dchaudhari7177` since 2026-10-03"+ assert row["pr"] == 1587 and row["quiet"] == 11++[email protected]("take_text, expected_pr, expected_quiet", [+ ("Taking item 2.", None, None),+ ("I'll take this.", 91, 13),+])+def test_unconfirmed_blocked_claim_metrics_preserve_the_existing_fallback(+ take_text, expected_pr, expected_quiet+):+ comments = [comment("alice", take_text, "2026-10-01T10:00:00Z")]+ row = board.classify(issue(7, ("infra-blocked",)), comments,+ [pull(91, "alice", "Refs #7")], NOW)+ assert row["state"] == "blocked: infra-blocked"+ assert row["pr"] == expected_pr and row["quiet"] == expected_quiet+++def test_arbitrary_slice_acceptance_after_taking_stays_conservatively_claimed():+ """#275's old recipe prose cannot safely identify or clear a numbered claim slice."""+ comments = [+ comment("alice", "Taking `some-recipe`.", "2026-10-01T10:00:00Z"),+ comment(board.MAINTAINER, "@alice: `some-recipe` is yours.",+ "2026-10-02T10:00:00Z"),+ ]+ row = board.classify(issue(275), comments, [], NOW)+ assert row["state"] == "claimed (see thread)"+ assert row["pr"] is None and row["quiet"] is None++@pytest.mark.parametrize("confirmation",[@@ -327,9 +706,14 @@ def test_confirm_regex_cases():def test_take_regex_cases():- for text in ("unclaimed", "claimed by bob", "I claimed it"):+ for text in (+ "unclaimed", "claimed by bob", "I claimed it", "Thanks for taking this", "I am not taking"+ ):assert not board._TAKE_RE.search(text), text- for text in ("I'd like to take", "I'll take it", "take this", "claim this", "I claim"):+ for text in (+ "I'd like to take", "I'll take it", "take this", "claim this", "I claim",+ "Taking item 2.", "I am taking proposed fix 2.",+ ):assert board._TAKE_RE.search(text), text