refactor(queue): extract plan-input builder from runAgentMaintenancePlanAndExecute - #4688
Conversation
…lanAndExecute Move the ~30-value planAgentMaintenanceActions object literal into a named, independently-typed buildAgentMaintenancePlanInput helper so the orchestrator threads fewer inline values. Pure code motion, no behavior change (#4607).
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-10 12:35:11 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4688 +/- ##
=======================================
Coverage 94.14% 94.14%
=======================================
Files 436 436
Lines 38530 38532 +2
Branches 14049 14049
=======================================
+ Hits 36273 36275 +2
Misses 1599 1599
Partials 658 658
🚀 New features to boost your workflow:
|
Summary
processors.tsmega-function breakup). This PR does only therunAgentMaintenancePlanAndExecuteslice of that issue —maybePublishPrPublicSurfaceandprocessGitHubWebhookare separate, much larger follow-ups, not touched here.planAgentMaintenanceActions(...)call." This PR extracts that ~79-line inline object literal into anew, named, independently-typed
buildAgentMaintenancePlanInputhelper (colocated insrc/queue/processors.ts, right above the orchestrator, matching the existing pattern already usedthere for
applyPrecisionBreakers/agentHoldAuditDetail/agentDispositionLabels/resolveLiveMigrationCollisionHold).(
...(x !== undefined ? { x } : {})), every comment explaining a non-obvious decision, and the exactset of already-resolved local values feeding the call are preserved verbatim; only the shape of how
they reach
planAgentMaintenanceActionschanged. Control flow, short-circuit ordering, error handling,and every computed value are unchanged.
runAgentMaintenancePlanAndExecuteshrinks from 717 to 665 lines (-52), with the extracted79-line inline object replaced by a 27-line call passing the same already-in-scope local variables by
name to the new helper.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Note on the issue link: this is
Part of #4607, notCloses/Fixes, since the issue explicitly coverstwo more functions (
maybePublishPrPublicSurface,processGitHubWebhook) as separate follow-up PRs — seethe issue body: "this is expected to land as multiple sequential PRs (one per function)."
Validation
git diff --checknpm run actionlint— not run; no.github/workflows/**files touched.npm run typecheck— clean, both before and after rebasing onto latestmain.npm run test:coverage— not run as the literal full-suite command (see explanation below); ascoped coverage run proved the diff itself is fully covered.
npm run test:workers— not run; notest/workers/**-relevant code touched.npm run build:mcp/npm run test:mcp-pack— not run; no MCP package changes.npm run ui:openapi:check/npm run ui:lint/npm run ui:typecheck/npm run ui:build— notrun; no
apps/gittensory-ui/**or API/schema changes.npm audit --audit-level=moderate— not run; no dependency changes.If any required check was skipped, explain why:
src/queue/processors.tswith no UI, MCP,workers, schema, OpenAPI, or dependency surface touched, so those gates are left to CI rather than
duplicated locally (they path-filter out for this diff anyway). The two checks that matter for a pure
refactor — typecheck and the exercising test suite — were run directly, in full, in the foreground,
twice (once pre-rebase, once immediately after rebasing onto the latest
main):npm run typecheck: clean both times.npx vitest run test/unit/queue.test.ts: 807/807 tests passed, unmodified, both times. This isthe primary test file exercising
runAgentMaintenancePlanAndExecute(via the higher-level webhookprocessing / auto-action-convergence suites) and
planAgentMaintenanceActions. No existing assertionwas touched — an unmodified green run of the exact pre-existing suite is the correctness signal for a
zero-behavior-change extraction.
npx vitest run test/unit/queue.test.ts --coverage, then cross-referenced the resultingcoverage/lcov.infoagainst the exact added-line ranges fromgit diff --unified=0(the newbuildAgentMaintenancePlanInputfunction and the rewritten call site). Zero uncovered lines and zerouncovered branches within those ranges — the extraction is fully exercised by the existing suite
transitively, so no new dedicated test file was added for it (a hand-built
RepositorySettings/PullRequestRecord/ gate fixture for a new test file would be disproportionate —RepositorySettingsalone is a 432-line type with no existing minimal-fixture helper in the codebase).
Safety
UI Evidencesection below... — N/A, no visible/UI changes (backend-only refactor).CHANGELOG.mdintentionally not touched.UI Evidence
Not applicable — this PR has no visible/UI/frontend/docs surface; it is a backend-only, behavior-preserving
extraction inside
src/queue/processors.ts.Notes
maintainer-only).maybePublishPrPublicSurfaceinto named steps, andsplitting
processGitHubWebhookinto per-event-type handlers.