Skip to content

fix(scoring): anchor the draft title pattern to genuine markers - #1529

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
Dexterity104:fix/anchor-draft-title-pattern
Jun 28, 2026
Merged

fix(scoring): anchor the draft title pattern to genuine markers#1529
JSONbored merged 2 commits into
JSONbored:mainfrom
Dexterity104:fix/anchor-draft-title-pattern

Conversation

@Dexterity104

Copy link
Copy Markdown
Contributor

Summary

  • The open PR draft check in classifyOpenPullRequest matched any title beginning with the letters "draft", so real work such as "Drafting a new feature", "Draftsman tool", and "draft-js upgrade" was classified as a draft.
  • Draft titles are excluded from the merge_ready and stale_likely_close buckets, so pendingMergedPrCount and pendingClosedPrCount in detectPendingPrScenario came out lower than reality whenever one of those PRs was otherwise countable.
  • The same over-broad expression was reused in normalizeTitle to strip a draft prefix for duplicate detection, so the dedup key for those titles was corrupted (for example "Draft tooling" collapsed onto "tooling").
  • A single anchored DRAFT_TITLE_PATTERN now matches only genuine markers ([draft], Draft:, and Draft - with a spaced dash) and is shared by both the classifier and the normalizer so they stay consistent. Requiring a space before the dash keeps hyphenated names such as draft-js and draft-mode from matching.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked an issue, or this is small enough that the summary explains why an issue is not needed.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Nothing was skipped. The full suite ran through npm run test:ci plus npm audit --audit-level=moderate, all green.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Not applicable. The change is backend only, with no visible UI, frontend, docs, or extension changes.

Notes

  • The change is backend only and does not touch auth, sessions, CORS, the GitHub App, OpenAPI, MCP, the UI, docs, or changelogs.
  • Coverage of every changed line is complete, including both sides of the new condition in isDraftPullRequest. Regression tests cover the misclassified titles, the genuine markers, and the dedup key behavior in normalizeTitle.
  • The normalizer change was verified to never cluster distinct PRs together and to remove the earlier false clustering of titles such as "Draft tooling".

@Dexterity104
Dexterity104 requested a review from JSONbored as a code owner June 26, 2026 14:02
@dosubot dosubot Bot added the size:S label Jun 26, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.53%. Comparing base (758e524) to head (23d9baf).
⚠️ Report is 43 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1529   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files         204      204           
  Lines       22084    22084           
  Branches     7972     7972           
=======================================
  Hits        21097    21097           
  Misses        412      412           
  Partials      575      575           
Files with missing lines Coverage Δ
src/scoring/pending-pr-scenarios.ts 96.29% <100.00%> (ø)
src/signals/contributor-open-pr-monitor.ts 96.15% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jun 26, 2026
@Dexterity104
Dexterity104 force-pushed the fix/anchor-draft-title-pattern branch from 3891436 to e71eae4 Compare June 26, 2026 22:13
@loopover-orb

loopover-orb Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review — held for maintainer review

4 files · 1 AI reviewers · no blockers · readiness 66/100 · CI green · clean

⏸️ Held for maintainer review — Touches a guarded path — held for manual review

Review summary
Replaces two ad-hoc draft-title regexes with a single exported `DRAFT_TITLE_PATTERN` that is anchored to genuine markers (`[draft]`, `Draft:`, `Draft -`). The root cause (over-broad `^[?\s*draft\s*]?` matching any title starting with the letters "draft") is correctly identified and fixed at the right layer. The shared constant eliminates the previous sync risk between `isDraftPullRequest` and `normalizeTitle`. Regex is correct: `\[\s*draft\s*\]` handles bracketed form, `\s*:` catches `Draft:` and `draft :`, `\s+-` requires a space before the dash and thus rejects `draft-js`/`draft-mode` while accepting `Draft - spike` and `Draft -spike`. Tests exercise the real production path (no fabricated payloads) and cover both false-positive and true-positive cases.

Signal Result Evidence
Code review ✅ No blockers 1 reviewers, synthesized
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Review load ✅ 20/20 Readiness component derived from cached public PR metadata and labels; size label size:S.
Validation evidence ❌ 5/25 Cached preflight status is hold.
Open PR queue ❌ 3/10 28 open PR(s), 14 likely reviewable, 14 unlinked.
Contributor context ✅ Confirmed Gittensor contributor Dexterity104; Gittensor profile; 101 PR(s), 11 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Nits — 5 non-blocking
  • The constant's comment (`pending-pr-scenarios.ts:40`) lists `"Draft -"` as a marker but omits the space-before-colon variant (`"draft :"`) that `\s*:` also accepts — add it so a reader can verify all matched forms without running tests: `"[draft]", "Draft:", "draft :", "Draft -"`.
  • In `normalizeTitle` (`contributor-open-pr-monitor.ts:249`) the title is `.toLowerCase()`-ed before `.replace(DRAFT_TITLE_PATTERN, "")`, making the `/i` flag redundant for that step (same applies to the `/^wip:\s*/i` replace below). Harmless but mildly confusing to maintainers wondering why both are present.
  • Expand the inline comment on `DRAFT_TITLE_PATTERN` to enumerate all four accepted surface forms — `[draft]`, `Draft:`, `draft :`, `Draft -` — with a one-liner example each; the current comment omits the space-colon variant and a future reader must run the tests to confirm it matches.
  • The `normalizeTitle` function could drop the upfront `.toLowerCase()` entirely and rely on the `/i` flags already present on all three replace patterns, which would make the function's reliance on case-insensitive regex explicit rather than hiding it behind a pre-lowercase step.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Review context
  • Author: Dexterity104
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: TypeScript, Python, Rust, JavaScript, Clojure, Cuda, Go, HTML
  • Official Gittensor activity: 101 PR(s), 11 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Explain no-issue PR.
  • Fix blocker.
  • Expect slower review.
  • Refresh registry data or choose a registered active repo.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review details

Generated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative.

Replaces two ad-hoc draft-title regexes with a single exported `DRAFT_TITLE_PATTERN` that is anchored to genuine markers (`[draft]`, `Draft:`, `Draft -`). The root cause (over-broad `^[?\s*draft\s*]?` matching any title starting with the letters "draft") is correctly identified and fixed at the right layer. The shared constant eliminates the previous sync risk between `isDraftPullRequest` and `normalizeTitle`. Regex is correct: `\[\s*draft\s*\]` handles bracketed form, `\s*:` catches `Draft:` and `draft :`, `\s+-` requires a space before the dash and thus rejects `draft-js`/`draft-mode` while accepting `Draft - spike` and `Draft -spike`. Tests exercise the real production path (no fabricated payloads) and cover both false-positive and true-positive cases.

Nits (4)

  • The constant's comment (`pending-pr-scenarios.ts:40`) lists `"Draft -"` as a marker but omits the space-before-colon variant (`"draft :"`) that `\s*:` also accepts — add it so a reader can verify all matched forms without running tests: `"[draft]", "Draft:", "draft :", "Draft -"`.
  • In `normalizeTitle` (`contributor-open-pr-monitor.ts:249`) the title is `.toLowerCase()`-ed before `.replace(DRAFT_TITLE_PATTERN, "")`, making the `/i` flag redundant for that step (same applies to the `/^wip:\s*/i` replace below). Harmless but mildly confusing to maintainers wondering why both are present.
  • Expand the inline comment on `DRAFT_TITLE_PATTERN` to enumerate all four accepted surface forms — `[draft]`, `Draft:`, `draft :`, `Draft -` — with a one-liner example each; the current comment omits the space-colon variant and a future reader must run the tests to confirm it matches.
  • The `normalizeTitle` function could drop the upfront `.toLowerCase()` entirely and rely on the `/i` flags already present on all three replace patterns, which would make the function's reliance on case-insensitive regex explicit rather than hiding it behind a pre-lowercase step.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@dosubot dosubot Bot added the lgtm label Jun 28, 2026
@JSONbored
JSONbored merged commit 8817fbc into JSONbored:main Jun 28, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants