Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 5 additions & 183 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
validate_public_url,
)
from app.mcp import handle_mcp_request
from app.mcp_work_proof import (
generic_work_proof_guidance_json,
work_proof_guidance,
work_proof_guidance_json,
)
from app.me import me_page_context
from app.models import (
Account,
Expand Down Expand Up @@ -1273,189 +1278,6 @@ def list_limit_arg(default: int = 25) -> int:
raise ValueError("limit must be at most 100")
return value

def work_proof_guidance(bounty: Bounty) -> str:
bounty_data = bounty_to_dict(bounty)
availability = (
"open for submissions"
if bounty_data["status"] == "open" and bounty_data["awards_remaining"] > 0
else "not currently open for new submissions"
)
return "\n".join(
[
f"Bounty #{bounty_data['issue_number']}: {bounty_data['title']}",
f"Internal bounty id: {bounty_data['id']}",
f"Repository: {bounty_data['repo']}",
f"Issue: {bounty_data['issue_url']}",
(
f"Status: {bounty_data['status']} ({availability}); "
f"awards remaining: {bounty_data['awards_remaining']} "
f"of {bounty_data['max_awards']}"
),
f"Reward: {bounty_data['reward_mrwk']} MRWK per accepted award",
f"Acceptance: {bounty_data['acceptance']}",
(
"Submit: open a focused PR or issue that links this bounty, include "
"specific test or behavior evidence, then comment /claim with the PR "
"or evidence URL and verification summary."
),
(
"Do not include private keys, seed material, secrets, deployment "
"credentials, private vulnerability details, or price claims."
),
]
)

def work_proof_submission_requirements(
*,
bounty_id: int | None,
issue_number: int | None,
can_submit: bool | None,
) -> dict[str, Any]:
issue_ref = str(issue_number) if issue_number is not None else "<issue_number>"
bounty_ref = str(bounty_id) if bounty_id is not None else "<bounty_id>"
if can_submit is True:
first_action = {
"id": "confirm_award_slot",
"required": True,
"text": "Confirm this bounty is open and has at least one award slot remaining.",
}
elif can_submit is False:
first_action = {
"id": "choose_open_bounty",
"required": True,
"text": (
"Do not open or claim new work for this bounty unless a maintainer reopens it."
),
}
else:
first_action = {
"id": "select_bounty",
"required": True,
"text": "Select a concrete open bounty before submitting work proof.",
}
return {
"reference_formats": [f"Bounty #{issue_ref}", f"Refs #{issue_ref}"],
"claim_command": "/claim",
"attempt_endpoint": f"/api/v1/bounties/{bounty_ref}/attempts",
"evidence_required": [
"focused PR, issue, report, or evidence URL",
"short verification summary",
"tests, command output, screenshots, or reproduction steps when relevant",
],
"acceptance_trigger": "maintainer_mrwk_accepted_label_or_admin_payout",
"public_metadata_must_avoid": [
"private keys",
"seed material",
"secrets",
"deployment credentials",
"private vulnerability details",
"price claims",
],
"next_actions": [
first_action,
{
"id": "check_duplicate_scope",
"required": True,
"text": (
"Confirm no active claim or duplicate PR already covers the same scope."
),
},
{
"id": "keep_scope_focused",
"required": True,
"text": "Keep changes directly tied to one bounty issue.",
},
{
"id": "include_bounty_reference",
"required": True,
"text": (
f"Include Bounty #{issue_ref} or Refs #{issue_ref} in the submission."
),
},
{
"id": "include_review_evidence",
"required": True,
"text": "Include reviewable validation evidence before claiming.",
},
{
"id": "wait_for_maintainer_acceptance",
"required": True,
"text": (
"Payment requires mrwk:accepted or an admin payout; merge or CI "
"alone is not acceptance."
),
},
],
}

def work_proof_guidance_json(bounty: Bounty) -> dict[str, Any]:
bounty_data = bounty_to_dict(bounty)
can_submit = bounty_data["status"] == "open" and bounty_data["awards_remaining"] > 0
availability_warnings = []
if bounty_data["status"] != "open":
availability_warnings.append(f"bounty is {bounty_data['status']}")
if bounty_data["awards_remaining"] <= 0:
availability_warnings.append("bounty has no award slots remaining")
return {
"bounty_id": bounty_data["id"],
"issue_number": bounty_data["issue_number"],
"status": bounty_data["status"],
"availability": "open_for_submissions" if can_submit else "not_currently_open",
"can_submit": can_submit,
"availability_warnings": availability_warnings,
"awards_remaining": bounty_data["awards_remaining"],
"max_awards": bounty_data["max_awards"],
"awards_paid": bounty_data["awards_paid"],
"reward_mrwk": bounty_data["reward_mrwk"],
"available_mrwk": bounty_data["available_mrwk"],
"repository": bounty_data["repo"],
"issue_url": bounty_data["issue_url"],
"title": bounty_data["title"],
"acceptance": bounty_data["acceptance"],
"submission_format": (
"Open a focused PR or issue that links this bounty, include specific "
"test or behavior evidence, then comment /claim with the PR or "
"evidence URL and verification summary."
),
"submission_requirements": work_proof_submission_requirements(
bounty_id=bounty_data["id"],
issue_number=bounty_data["issue_number"],
can_submit=can_submit,
),
"safety_rules": [
"Do not include private keys, seed material, secrets, deployment "
"credentials, private vulnerability details, or price claims."
],
}

def generic_work_proof_guidance_json() -> dict[str, Any]:
return {
"bounty_id": None,
"issue_number": None,
"status": "generic_guidance",
"availability": "unknown_without_bounty",
"can_submit": None,
"availability_warnings": [],
"awards_remaining": None,
"reward_mrwk": None,
"repository": None,
"issue_url": None,
"acceptance": None,
"submission_format": (
"Open a focused PR or issue, reference the MRWK bounty, include test "
"evidence, and wait for a maintainer to apply mrwk:accepted."
),
"submission_requirements": work_proof_submission_requirements(
bounty_id=None,
issue_number=None,
can_submit=None,
),
"safety_rules": [
"Do not include private keys, seed material, secrets, deployment "
"credentials, private vulnerability details, or price claims."
],
}

def optional_bool_arg(field: str, default: bool = False) -> bool:
value = args.get(field, default)
if value is None:
Expand Down
Loading
Loading