Skip to content

BNN-13 feat: validate bounty submission requirements#46

Open
shuibui wants to merge 3 commits into
bountydotnew:mainfrom
shuibui:bnn-13-requirement-validation
Open

BNN-13 feat: validate bounty submission requirements#46
shuibui wants to merge 3 commits into
bountydotnew:mainfrom
shuibui:bnn-13-requirement-validation

Conversation

@shuibui
Copy link
Copy Markdown

@shuibui shuibui commented May 29, 2026

Summary

  • Adds a reusable bounty requirement parser/validator for acceptance criteria, requirements, constraints, deliverables, and expected behavior sections.
  • Validates fake-bounty PR references against the bounty body before processing the catch.
  • Appends a concise missing-requirements summary to the decline comment and stores validation metadata in Tripwire events.
  • Documents the exported validation API and helper behavior for the new requirement parsing module.

Refs #42

Validation

  • corepack pnpm install --frozen-lockfile
  • corepack pnpm --filter @tripwire/core test -- bounty-requirements
    • 96 test files passed, 389 tests passed.
  • corepack pnpm --filter @tripwire/core typecheck
  • corepack pnpm exec prettier --check packages/core/src/bounty-requirements.ts packages/core/src/bounty-requirements.test.ts packages/core/src/fake-bounty.ts apps/web/src/routes/api/github/webhook.ts packages/core/src/index.ts
    • All matched files use Prettier code style.

Review Notes

  • Handles lowercase colon headings such as requirements: and checkbox criteria, covering the review gap from the previously closed PR Validate bounty submission requirements #44.
  • Latest CodeRabbit run reported no actionable comments after the JSDoc coverage follow-up.
  • The remaining Vercel status is a preview authorization request for the upstream Bounty team, not a code failure.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@shuibui is attempting to deploy a commit to the Bounty Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a bounty requirement validation system and integrates it into fake-bounty detection. A new bounty-requirements module parses requirement criteria from bounty descriptions using markdown section detection and list extraction, then validates submissions by computing term overlap and coverage ratios. The fake-bounty handler now computes requirement validation details when a bounty reference is matched and appends formatted missing-requirements information to decline comments while recording validation metadata in logs. The new module is re-exported from the package entry point and consumed by the webhook handler.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly aligns with the main objective: adding bounty submission requirement validation. It accurately captures the primary feature being introduced.
Docstring Coverage ✅ Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

🧹 Nitpick comments (1)
packages/core/src/bounty-requirements.ts (1)

1-18: ⚡ Quick win

Add JSDoc to exported interfaces and functions.

All exported items in this module lack JSDoc documentation. Since this module is part of the public API (re-exported from packages/core/src/index.ts), adding documentation will improve the developer experience for consumers.

As per coding guidelines, "Use JSDoc for exported functions/types only."

📝 Suggested JSDoc additions
+/**
+ * Represents a single requirement criterion extracted from a bounty description.
+ */
 export interface BountyRequirementCriterion {
   id: string
   sourceHeading: string
   text: string
 }

+/**
+ * Represents a matched requirement criterion with the terms found in the submission.
+ */
 export interface BountyRequirementMatch {
   criterion: BountyRequirementCriterion
   matchedTerms: string[]
 }

+/**
+ * Validation result for a bounty submission against extracted requirement criteria.
+ */
 export interface BountyRequirementValidation {
   status: "no_criteria" | "valid" | "missing_requirements"
   coverage: number
   requiredCount: number
   matched: BountyRequirementMatch[]
   missing: BountyRequirementCriterion[]
 }

+/**
+ * Extracts requirement criteria from a bounty body by detecting requirement sections
+ * and parsing list items and paragraphs under those headings.
+ *
+ * `@param` body - The markdown body of the bounty description
+ * `@returns` Array of extracted requirement criteria
+ */
 export function extractBountyRequirementCriteria(
   body: string
 ): BountyRequirementCriterion[] {

+/**
+ * Validates a submission's text against the requirements extracted from a bounty body.
+ * Uses term-based matching to determine coverage of requirement criteria.
+ *
+ * `@param` opts.bountyBody - The markdown body of the bounty description
+ * `@param` opts.submissionText - The text content of the submission to validate
+ * `@returns` Validation result with status, coverage, and matched/missing criteria
+ */
 export function validateBountySubmissionRequirements(opts: {
   bountyBody: string
   submissionText: string
 }): BountyRequirementValidation {

+/**
+ * Formats a validation result into a human-readable message listing missing criteria.
+ * Returns null if the validation status is not "missing_requirements".
+ *
+ * `@param` validation - The validation result to format
+ * `@returns` Formatted message string or null
+ */
 export function formatBountyRequirementValidation(
   validation: BountyRequirementValidation
 ): string | null {

Also applies to: 121-162, 179-213, 215-233

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/core/src/bounty-requirements.ts` around lines 1 - 18, Add JSDoc
comments to all exported types and functions in this module (e.g.,
BountyRequirementCriterion, BountyRequirementMatch, BountyRequirementValidation
and any exported functions or other exported interfaces referenced in the file)
so they are documented in the public API; for each exported symbol provide a
one-line description, document properties/params and return types where
applicable, and include any important notes or expected invariants; follow the
project's JSDoc style used elsewhere (brief summary + `@param/`@returns/@remarks
as appropriate) and apply the same to the other exported blocks mentioned (lines
~121-162, 179-213, 215-233) so every exported item in the file has JSDoc.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/core/src/bounty-requirements.ts`:
- Around line 1-18: Add JSDoc comments to all exported types and functions in
this module (e.g., BountyRequirementCriterion, BountyRequirementMatch,
BountyRequirementValidation and any exported functions or other exported
interfaces referenced in the file) so they are documented in the public API; for
each exported symbol provide a one-line description, document properties/params
and return types where applicable, and include any important notes or expected
invariants; follow the project's JSDoc style used elsewhere (brief summary +
`@param/`@returns/@remarks as appropriate) and apply the same to the other
exported blocks mentioned (lines ~121-162, 179-213, 215-233) so every exported
item in the file has JSDoc.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7ea0cdfe-7518-4345-b086-e5f226163f87

📥 Commits

Reviewing files that changed from the base of the PR and between 5610f54 and 9198d8b.

📒 Files selected for processing (5)
  • apps/web/src/routes/api/github/webhook.ts
  • packages/core/src/bounty-requirements.test.ts
  • packages/core/src/bounty-requirements.ts
  • packages/core/src/fake-bounty.ts
  • packages/core/src/index.ts

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.

1 participant