Skip to content

Refs #406: Accept full issue URL bounty references#494

Open
er1c-cartman wants to merge 2 commits into
ramimbo:mainfrom
er1c-cartman:fix-406-full-issue-url-refs
Open

Refs #406: Accept full issue URL bounty references#494
er1c-cartman wants to merge 2 commits into
ramimbo:mainfrom
er1c-cartman:fix-406-full-issue-url-refs

Conversation

@er1c-cartman
Copy link
Copy Markdown

@er1c-cartman er1c-cartman commented May 27, 2026

Summary

Bounty #406 small fix.

This aligns the pre-submission tools with the webhook payout path by accepting full GitHub issue URLs such as https://github.com/ramimbo/mergework/issues/406 as bounty references. The webhook already recognizes same-repo full issue URLs, but scripts/submission_quality_gate.py and scripts/pr_queue_health.py only recognized shorthand forms such as Refs #406.

What Changed

  • Added GitHub issue URL parsing to submission_quality_gate.py while preserving existing Bounty #<issue>, Refs #<issue>, and /claim #<issue> behavior.
  • Added the same support to pr_queue_health.py so live queue reports do not falsely flag PRs that link the bounty with a full same-repo issue URL.
  • Scoped live-mode URL matching to the current repo so foreign issue URLs are ignored.
  • Added regression tests for accepted same-repo full URLs and ignored foreign URLs.

Evidence

Without this, a PR body that links https://github.com/ramimbo/mergework/issues/406 can be payable through the webhook path but fail or be flagged by the agent-facing preflight scripts as missing a bounty reference.

Validation

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 35 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev ruff check scripts/submission_quality_gate.py scripts/pr_queue_health.py tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -> passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev ruff format --check scripts/submission_quality_gate.py scripts/pr_queue_health.py tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -> passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m mypy scripts/submission_quality_gate.py scripts/pr_queue_health.py -> passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 417 passed
  • git diff --check -> passed

Summary by CodeRabbit

  • New Features

    • Full GitHub issue URLs are accepted as valid bounty references.
    • Submission and queue analyses apply repo-aware filtering so references only match when they belong to the same repository.
  • Bug Fixes

    • Stricter bounty-reference matching reduces partial/false matches and improves missing-reference reporting (now acknowledges GitHub issue URLs).
  • Tests

    • Added tests covering in-repo, cross-repo, and title-handling scenarios for full GitHub issue URL references.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0d3608d7-d6ac-421e-b6e2-dafb19caa41c

📥 Commits

Reviewing files that changed from the base of the PR and between 0d25261 and 755939b.

📒 Files selected for processing (2)
  • scripts/submission_quality_gate.py
  • tests/test_submission_quality_gate.py

📝 Walkthrough

Walkthrough

Adds strict issue-number boundaries and full GitHub issue URL parsing to bounty-reference extraction in queue-health and submission-quality pipelines, threads an optional repo filter through extraction and PR-matching, and updates error messages and live-load payloads to include repo-aware behavior.

Changes

Bounty reference extraction with repo-scoped GitHub issue URL support

Layer / File(s) Summary
Regex patterns and bounty reference extraction
scripts/pr_queue_health.py, scripts/submission_quality_gate.py
Add ISSUE_NUMBER_BOUNDARY and GITHUB_ISSUE_URL_RE; tighten BOUNTY_REF_RE; extend _bounty_refs to accept optional repo and parse both shorthand and full GitHub issue URLs, filtering URL-derived refs to matching repo and deduplicating.
pr_queue_health.py pipeline integration
scripts/pr_queue_health.py
analyze_queue normalizes repo from input and passes it to _bounty_refs during PR normalization; load_live_queue now returns repo; missing-bounty detail now lists GitHub issue URL as an accepted source.
submission_quality_gate.py PR matching and helpers
scripts/submission_quality_gate.py
Add repo-aware _matching_pr_bounty_refs and thread optional repo through _similar_open_prs so PR similarity checks only match URL-derived bounty refs when repo matches.
submission_quality_gate.py pipeline integration
scripts/submission_quality_gate.py
evaluate_submission derives normalized repo, uses _bounty_refs(text, repo), passes repo to _similar_open_prs, and updates missing-bounty messaging. _load_live_context computes referenced_bounties using repo-aware extraction and includes repo in its returned payloads.
Test coverage
tests/test_pr_queue_health.py, tests/test_submission_quality_gate.py
Add tests to verify same-repo GitHub issue URLs are accepted as bounty references and foreign-repo URLs are ignored; update assertions for missing-bounty messages to include GitHub issue URL phrasing.

Possibly related PRs

  • ramimbo/mergework#438: Updates bounty-reference parsing regex and "missing bounty reference" message in the same two scripts to recognize additional reference formats.
  • ramimbo/mergework#325: Extends submission_quality_gate.py logic by adding repo-scoped filtering to _bounty_refs and _matching_pr_bounty_refs for GitHub issue URL support.
  • ramimbo/mergework#324: Modifies pr_queue_health.py bounty-reference parsing and queue analysis pipeline; this PR extends that with stricter GitHub issue URL and repo-aware load_live_queue data.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Refs #406: Accept full issue URL bounty references' directly names the changed surface—adding support for full GitHub issue URLs as bounty references—which aligns with the main objective and changes across both scripts.
Description check ✅ Passed The description includes a clear summary, explains the problem addressed, documents changes across both scripts, lists validation results, and provides evidence of issue alignment. Required sections match the template structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Mergework Public Artifact Hygiene ✅ Passed PR modifies only code/test files, not documentation. No investment, price, or payout claims found. README correctly describes MRWK as native coin with future snapshot/bridge/onchain support.
Bounty Pr Focus ✅ Passed PR diff implements full GitHub issue URL support with repo-scoping in both scripts. Tests confirm same-repo URLs accepted, foreign URLs rejected. Changes focused solely on bounty reference parsing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@GHX5T-SOL GHX5T-SOL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 0d25261247710692f530989082bf4e227293675a as a non-author.

Requesting changes because the new full GitHub issue URL path is not equivalent to the existing Refs #<issue> path in duplicate detection. _title_from_submission() skips lines containing BOUNTY_REF_RE, but it does not skip a line that is only a full issue URL. When a submission starts with the new supported format, the URL becomes the extracted submission title, so _similar_open_prs() compares the open PR title against the URL and misses the duplicate/similar-work warning.

Local repro on this head:

/tmp/gitted-bin/uv run --extra dev python -c 'from scripts.submission_quality_gate import evaluate_submission; data={"repo":"ramimbo/mergework","submission_text":"https://github.com/ramimbo/mergework/issues/319\n\nHarden the bounty submission checks\n\nValidation: pytest passed.","bounties":[{"number":319,"state":"OPEN","awards_remaining":1}],"pull_requests":[{"number":12,"title":"Harden the bounty submission checks","body":"Refs #319","state":"OPEN","url":"https://github.com/ramimbo/mergework/pull/12"}]}; result=evaluate_submission(data); print(result["bounty_reference"]); print(result["similar_open_prs"])'

Output:

319
[]

The equivalent first-line shorthand still finds the similar open PR:

Refs #319 -> [{'number': 12, 'title': 'Harden the bounty submission checks', 'url': 'https://github.com/ramimbo/mergework/pull/12'}]

Impact: the PR fixes the primary bounty-reference check, but a common copy-paste style for full URLs can bypass the gate that warns agents about already-open similar work on the same bounty. A targeted fix would make _title_from_submission() ignore GITHUB_ISSUE_URL_RE-only lines, matching the existing shorthand behavior, and add a regression where the full issue URL appears before the human title.

Validation I ran:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /tmp/gitted-bin/uv run --extra dev python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 35 passed.
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 /tmp/gitted-bin/uv run --extra dev python -m pytest -q -> 417 passed.
  • /tmp/gitted-bin/uv run --extra dev ruff check . -> passed.
  • /tmp/gitted-bin/uv run --extra dev ruff format --check . -> 79 files already formatted.
  • /tmp/gitted-bin/uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok.
  • /tmp/gitted-bin/uv run --extra dev python -m mypy app -> success.
  • git diff --check upstream/main...HEAD -> clean.
  • git diff --no-ext-diff upstream/main..HEAD | gitleaks stdin --no-banner --redact --exit-code 1 -> no leaks found.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 321652fe-db26-44fc-8efd-875389324635

📥 Commits

Reviewing files that changed from the base of the PR and between d8532d4 and 0d25261.

📒 Files selected for processing (4)
  • scripts/pr_queue_health.py
  • scripts/submission_quality_gate.py
  • tests/test_pr_queue_health.py
  • tests/test_submission_quality_gate.py

Comment thread scripts/submission_quality_gate.py
Copy link
Copy Markdown

@jtc268 jtc268 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 0d25261247710692f530989082bf4e227293675a.

I found a separate fallback-path issue from the existing duplicate-title finding. The PR correctly threads repo through normal live-context paths, but _load_live_context() drops repo in the GitHub-load exception return. That means when gh is unavailable or times out, evaluate_submission() receives no repo context and _bounty_refs() stops filtering full issue URLs to the target repo. A foreign issue URL can then pass the bounty-reference check as if it belonged to ramimbo/mergework.

Local repro on this head:

import scripts.submission_quality_gate as gate

def fail(args):
    raise RuntimeError("simulated gh outage")

gate._run_gh_json = fail
ctx = gate._load_live_context(
    "ramimbo/mergework",
    "https://github.com/other/repo/issues/123

Summary: test

Validation: pytest passed",
    "https://api.mrwk.ltclab.site",
)
result = gate.evaluate_submission(ctx)
print(ctx)
print(result["bounty_reference"])
print(result["checks"][0])

Observed output includes no repo in ctx, then bounty_reference becomes 123 and the first check is PASS bounty_reference: found bounty reference #123. Expected behavior is to keep the target repo in the fallback context so foreign GitHub issue URLs remain ignored and the submission fails the missing-reference check.

Suggested fix: add "repo": repo to the exception return from _load_live_context() and add a regression covering a foreign full issue URL under simulated GitHub-load failure.

Validation on this head:

  • uv run --extra dev python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 35 passed
  • uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean

@er1c-cartman
Copy link
Copy Markdown
Author

Addressed the review feedback in 755939b.

Changes:

  • _title_from_submission() now skips full GitHub issue URL lines before selecting the similarity title, so URL-first submissions still compare against the real work title.
  • _load_live_context() now preserves repo in the GitHub-load fallback payload, so foreign issue URLs remain filtered when gh is unavailable.
  • Added focused regressions for both cases.

Validation rerun:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 37 passed
  • scoped Ruff check -> passed
  • scoped Ruff format check -> passed
  • scoped mypy -> passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 419 passed
  • git diff --check -> passed

Copy link
Copy Markdown
Contributor

@GHX5T-SOL GHX5T-SOL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 755939baf836de3b632f37d71d111b3c9a3619d4 as a follow-up to my earlier changes-requested review on 0d25261247710692f530989082bf4e227293675a.

The update resolves my blocker: _title_from_submission() now skips full GitHub issue URL lines, so a URL-first submission still compares the real title against open PR titles. I also checked the separate fallback-path issue raised by another reviewer: _load_live_context() now preserves repo when GitHub loading fails, so foreign full issue URLs remain filtered.

Local verification:

  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 37 passed
  • URL-first duplicate repro now returns the similar open PR instead of []
  • simulated gh outage with https://github.com/other/project/issues/319 now keeps repo=ramimbo/mergework and fails the bounty-reference check
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m pytest -q -> 419 passed
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python scripts/docs_smoke.py -> docs smoke ok
  • Ruff check/format on changed files -> passed / already formatted
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 uv run --extra dev python -m mypy app -> success
  • git diff --check origin/main...HEAD -> clean
  • diff-only Gitleaks -> no leaks found

GitHub readback shows PR #494 is open, non-draft, CLEAN, with successful CI and CodeRabbit checks. No further blockers from my review.

Copy link
Copy Markdown

@INDICUMA INDICUMA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed current head 755939baf836de3b632f37d71d111b3c9a3619d4 as a non-author.

I checked the repo-scoped full GitHub issue URL handling across both affected tools. The current head now keeps shorthand references and same-repo full issue URLs aligned, filters foreign issue URLs when repo is known, preserves repo through _load_live_context() fallback paths, and keeps duplicate/similar-open-PR detection working when the submission starts with a full issue URL before the human title.

Independent verification:

  • ./.venv312/bin/python -m pytest tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -q -> 37 passed
  • URL-first submission repro now returns the similar open PR instead of []
  • simulated gh outage with https://github.com/other/project/issues/319 keeps repo=ramimbo/mergework, leaves bounty_reference as None, and fails the bounty-reference check as expected
  • ./.venv312/bin/python -m pytest -q -> 419 passed
  • ./.venv312/bin/python -m ruff check scripts/submission_quality_gate.py scripts/pr_queue_health.py tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -> passed
  • ./.venv312/bin/python -m ruff format --check scripts/submission_quality_gate.py scripts/pr_queue_health.py tests/test_submission_quality_gate.py tests/test_pr_queue_health.py -> 4 files already formatted
  • ./.venv312/bin/python -m mypy app scripts/submission_quality_gate.py scripts/pr_queue_health.py -> success
  • ./.venv312/bin/python scripts/docs_smoke.py -> docs smoke ok
  • git diff --check origin/main...HEAD -> clean

I do not see further blockers on the current head. No secrets, wallet material, private data, production mutation, price/exchange/liquidity claim, or off-ramp claim was used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants