Skip to content

refactor(queue): extract job-dispatch.ts from processors.ts - #4971

Merged
JSONbored merged 1 commit into
mainfrom
refactor/4013-extract-job-dispatch
Jul 11, 2026
Merged

refactor(queue): extract job-dispatch.ts from processors.ts#4971
JSONbored merged 1 commit into
mainfrom
refactor/4013-extract-job-dispatch

Conversation

@JSONbored

@JSONbored JSONbored commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Test plan

  • npx tsc --noEmit -p . clean
  • Full unsharded npm run test:coverage: 703 files / 13935 tests passed, 0 failed
  • src/queue/job-dispatch.ts: 100% statements/branches/functions/lines
  • npm run docs:drift-check, manifest:drift-check, engine-parity:drift-check all pass
  • npm audit --audit-level=moderate: 0 vulnerabilities

@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.29%. Comparing base (c8bb830) to head (abc7474).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4971      +/-   ##
==========================================
+ Coverage   94.27%   94.29%   +0.01%     
==========================================
  Files         451      452       +1     
  Lines       38900    38900              
  Branches    14172    14172              
==========================================
+ Hits        36674    36679       +5     
+ Misses       1574     1572       -2     
+ Partials      652      649       -3     
Flag Coverage Δ
shard-1 46.81% <71.77%> (-0.02%) ⬇️
shard-2 33.33% <15.32%> (+0.01%) ⬆️
shard-3 31.40% <2.41%> (-0.01%) ⬇️
shard-4 32.60% <13.70%> (-0.55%) ⬇️
shard-5 34.15% <0.80%> (+0.61%) ⬆️
shard-6 45.86% <14.51%> (+0.61%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/queue/job-dispatch.ts 100.00% <100.00%> (ø)
src/queue/processors.ts 95.26% <ø> (-0.03%) ⬇️
🚀 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:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 11, 2026
@loopover-orb

loopover-orb Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-11 06:14:36 UTC

4 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This is the final step of the #4013 processors.ts extraction sequence: it moves the top-level processJob dispatcher (a pure switch over JobMessage["type"]) verbatim into a new src/queue/job-dispatch.ts, exports 15 previously-unexported handlers (plus processGitHubWebhook) from processors.ts for one-directional import-back, and adds a re-export shim so existing call sites keep working. The switch body is byte-identical to the removed block, ~28 now-orphaned imports are correctly pruned from processors.ts, and CI (tsc, full test suite, coverage, drift checks) is green on this exact commit. Two new tests cover previously-untested branches (retry-orb-relay dispatch, notify-evaluate with neither events nor legacy event) using realistic payloads rather than fabricated states.

Nits — 5 non-blocking
  • src/queue/processors.ts's `export { processJob } from "./job-dispatch"` combined with job-dispatch.ts importing back from processors.ts forms an actual module-graph cycle, contrary to the PR description's 'no cycle' claim — it's safe here since nothing runs at module-eval time across the boundary, but worth calling out explicitly rather than asserting no cycle exists.
  • src/queue/job-dispatch.ts: the `recapture-preview` case uses `break;` while every other case uses `return;` — pre-existing inconsistency carried over from processors.ts, worth aligning for consistency now that the switch has a fresh home.
  • The 45/15/900 second constants in the backfill-registered-repos branch (job-dispatch.ts) are unexplained magic numbers, though they're moved as-is from the original file rather than introduced by this PR.
  • Consider naming the 45/15/900 delay constants (e.g. DELAY_STEP_SECONDS_FULL/RESUME, MAX_DELAY_SECONDS) while this code is already being touched, since it's now sitting in its own dedicated file.
  • A short comment on the processors.ts re-export line noting it's a live-binding re-export (not a fresh cycle risk) would preempt future confusion given the module-graph shape.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
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.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 423 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 423 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 423 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • 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.
  • 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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 11, 2026
@JSONbored
JSONbored force-pushed the refactor/4013-extract-job-dispatch branch from 46841ff to 9e8336d Compare July 11, 2026 05:43
Final step of #4013. Moves the top-level processJob dispatcher (a pure
switch over JobMessage["type"]) into its own file. This is the most
interdependent piece of the split -- job-dispatch.ts imports most of its
handlers back from processors.ts (which stays large; nothing else in
processors.ts functions (and processGitHubWebhook) are exported for this
one-directional import-back. processors.ts re-exports processJob for
src/index.ts, src/server.ts, and the test suite.

Also removes ~28 imports in processors.ts that were orphaned once
processJob (their only remaining caller) moved out, and adds two
regression tests for job-dispatch branches that were untested even in
the original file (retry-orb-relay dispatch; a notify-evaluate payload
with neither the events array nor the legacy singular event field).
@JSONbored
JSONbored force-pushed the refactor/4013-extract-job-dispatch branch from 9e8336d to abc7474 Compare July 11, 2026 06:01
@JSONbored
JSONbored merged commit 2aa6158 into main Jul 11, 2026
18 checks passed
@JSONbored
JSONbored deleted the refactor/4013-extract-job-dispatch branch July 11, 2026 06:23
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. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant