Skip to content

feat(miner-manage): add rejection state machine (closed/rejected → disengaged) - #4441

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
dhgoal:feat/miner-rejection-state-machine
Jul 9, 2026
Merged

feat(miner-manage): add rejection state machine (closed/rejected → disengaged)#4441
JSONbored merged 1 commit into
JSONbored:mainfrom
dhgoal:feat/miner-rejection-state-machine

Conversation

@dhgoal

@dhgoal dhgoal commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Adds the missing rejection state machine (Closes #4278).

packages/gittensory-miner/lib/rejection-templates.js (#2324) has a fully-implemented renderer with zero callers outside its own test. This adds the detector + classifier that finally drives it:

  • extractPrOutcomeFields(prPayload) — pull state/merged/merged_at/closed_at from the GET /pulls/{n} payload the poller already fetches (ci-poller.js's fetchHeadSha GETs the full body and discards all but head.sha). Pure — no second API call, no behavioral change to the existing fetch.
  • isRejectedPr / classifyRejectionReason — detect closed-without-merge (a merged PR is also state:closed, so it's excluded) and map it to gate_close / superseded_by_duplicate / maintainer_close_no_reason. Documented zero-signal fallback to maintainer_close_no_reason; an explicit gate close outranks a duplicate signal.
  • resolveRejection — the full transition to the DISENGAGED_OUTCOME per-PR outcome + the rendered courtesy note (this is renderRejectionMessage's first real caller).

Design decisions documented in-module (both called out by the issue): disengaged is a per-PR outcome (the manage-poll.js ready/needs-work/open family), not a per-repo run-state — and this module deliberately does not mutate manage-poll.js's or run-state.js's enum as a side effect (a poller adopts DISENGAGED_OUTCOME explicitly). Still no GitHub write — local classification + local note only, matching the templates module's boundary.

Test

test/unit/miner-rejection-state-machine.test.ts — field extraction (full + malformed/missing), rejection detection (closed-unmerged vs merged vs open), each reason bucket + the zero-signal fallback + gate-over-duplicate precedence, the full resolveRejection transition for every reason, and null for non-rejections. 8 tests pass; build:miner + test:miner-pack + typecheck green.

@dhgoal
dhgoal requested a review from JSONbored as a code owner July 9, 2026 18:36
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 9, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

superagent-security Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.01%. Comparing base (861e8b7) to head (e89f5f7).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4441   +/-   ##
=======================================
  Coverage   94.01%   94.01%           
=======================================
  Files         418      418           
  Lines       37417    37417           
  Branches    13677    13677           
=======================================
  Hits        35178    35178           
  Misses       1583     1583           
  Partials      656      656           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 9, 2026
@loopover-orb

loopover-orb Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-09 19:14:17 UTC

3 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · unstable

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
AI review could not be completed for this PR head. Gittensory is holding this PR for manual review instead of relying on deterministic signals alone.

Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4278
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 85 registered-repo PR(s), 51 merged, 7 issue(s).
Contributor context ✅ Confirmed Gittensor contributor dhgoal; Gittensor profile; 85 PR(s), 7 issue(s).
Gate result ✅ Passing No configured blocker found.
Linked issue satisfaction

Partially addressed
The PR adds a well-tested classifier and renderer wiring (resolveRejection calling renderRejectionMessage) and documents the outcome-vs-run-state design decision, but it never actually wires into ci-poller.js's fetchHeadSha or manage-poll.js's outcome vocabulary (no diff to either file), and it does not persist the rendered note/classification via a local event ledger as the issue explicitly requi

Review context
  • Author: dhgoal
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 85 PR(s), 7 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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

…isengaged)

New packages/gittensory-miner/lib/rejection-state-machine.js: the missing detector + classifier that
turns a closed-without-merge PR into a rejection-reason bucket and, for the first time, drives
renderRejectionMessage (previously caller-less). Pure — no GitHub calls, no network, no writes.

- extractPrOutcomeFields: pull state/merged/merged_at/closed_at from a PR payload the poller already
  fetches (no second API call, no change to ci-poller's fetchHeadSha).
- isRejectedPr / classifyRejectionReason: closed-without-merge detection + map to gate_close /
  superseded_by_duplicate / maintainer_close_no_reason (documented zero-signal fallback; gate outranks duplicate).
- resolveRejection: the full transition to the 'disengaged' per-PR outcome + the rendered courtesy note.

Design decisions documented in-module: 'disengaged' is a per-PR outcome (manage-poll family), NOT a
run-state; this module does not silently expand another module's enum.

Closes JSONbored#4278
@JSONbored
JSONbored merged commit 2ea3cdb into JSONbored:main Jul 9, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

feat(miner-manage): rejection state machine (closed/rejected → disengaged)

2 participants