Skip to content

refactor(queue): extract AI-review orchestration into its own module - #4968

Merged
JSONbored merged 1 commit into
mainfrom
refactor/4013-extract-ai-review-orchestration
Jul 11, 2026
Merged

refactor(queue): extract AI-review orchestration into its own module#4968
JSONbored merged 1 commit into
mainfrom
refactor/4013-extract-ai-review-orchestration

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Part of refactor(queue): split processors.ts into cohesive modules #4013 (more extraction steps remain in the sequence — not closing the tracking issue).
  • Moves the AI-review lock cluster, advisory-eligibility/manifest/token resolution helpers, and the
    runAiReviewForAdvisory orchestration (grounding/RAG/enrichment/impact-map/culture-profile/inline-findings)
    out of processors.ts into src/queue/ai-review-orchestration.ts. Pure mechanical move, no behavior change.
  • processors.ts imports the symbols back for its own remaining internal call sites and re-exports the ones
    with an existing direct import { ... } from "../../src/queue/processors" in the test suite.
  • Fixes two grounding/enrichment wiring tests that registered their fixture repo outside the default
    GITTENSORY_REVIEW_REPOS allowlist, which silently no-op'd the "no installationId" branch they claimed to
    cover (grounding is allowlistRequired), plus adds coverage for the GitHub-token and PR-body optional-chain
    fallbacks these tests were meant to exercise.

Test plan

  • npx tsc --noEmit -p . clean
  • Full unsharded npm run test:coverage: 703 files / 13934 tests passed, 0 failed
  • src/queue/ai-review-orchestration.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.27%. Comparing base (ab45d70) to head (4e0f0c6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4968      +/-   ##
==========================================
+ Coverage   84.42%   94.27%   +9.85%     
==========================================
  Files         450      451       +1     
  Lines       38900    38900              
  Branches    14172    14172              
==========================================
+ Hits        32841    36674    +3833     
+ Misses       4818     1574    -3244     
+ Partials     1241      652     -589     
Flag Coverage Δ
shard-1 46.81% <71.31%> (?)
shard-2 33.32% <7.37%> (+<0.01%) ⬆️
shard-3 31.40% <10.65%> (-0.01%) ⬇️
shard-4 32.60% <37.70%> (-0.55%) ⬇️
shard-5 34.15% <84.42%> (+0.62%) ⬆️
shard-6 45.86% <44.26%> (+0.61%) ⬆️

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

Files with missing lines Coverage Δ
src/queue/ai-review-orchestration.ts 100.00% <100.00%> (ø)
src/queue/processors.ts 95.29% <ø> (+33.88%) ⬆️

... and 86 files with indirect coverage changes

🚀 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 05:45:46 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 a well-executed mechanical extraction of the AI-review orchestration cluster (locks, eligibility/manifest/token helpers, and runAiReviewForAdvisory) from processors.ts into src/queue/ai-review-orchestration.ts, following the same #4013 module-split pattern as the prior transient-locks/signal-snapshot/duplicate-detection/etc. steps. The import-back-and-re-export shim in processors.ts correctly preserves the existing test suite's direct imports, and the two test fixture fixes (switching acme/noinst to the allowlisted acme/widgets in grounding-wiring.test.ts, plus a new enrichment-wiring.test.ts case) are genuine coverage fixes — the prior fixture repo wasn't in the default GITTENSORY_REVIEW_REPOS allowlist, so groundingActive was false and the 'no installationId' branch these tests claimed to cover was silently skipped. I traced the moved function bodies (shouldStartAiReviewForAdvisory, shouldRequirePublicAiReviewForAdvisory, resolveReviewManifestForAiReview, resolveReviewEnrichmentGithubToken, runAiReviewForAdvisory, splitRepoForRag, the lock helpers) against the deleted originals in processors.ts and they are byte-identical moves with no logic changes.

Nits — 5 non-blocking
  • src/queue/ai-review-orchestration.ts: aiReviewLockContendedResult is now `export`ed where it wasn't before in processors.ts — harmless since it's only consumed internally via the import-back shim, but worth a one-line note in the extraction comment for why its visibility widened.
  • The external brief's 'master' terminology flag and 'console debug leftover' at ai-review-orchestration.ts:842 both appear to be pre-existing moved code (the catch-block console.error existed in the original processors.ts), not new additions from this diff — worth double-checking the brief isn't flagging relocated lines as newly added.
  • Confirm AI_REVIEW_NON_CACHEABLE_RETRY_COOLDOWN_MS is actually referenced somewhere after being imported back into processors.ts (not shown in the diff hunks) — tsc passing implies it's used, but it's worth a quick grep to be sure it isn't a dead re-export.
  • test/unit/enrichment-wiring.test.ts:350's GITHUB_PUBLIC_TOKEN test literal is a fixture value, not a real secret, but the external brief's generic_secret_assignment flag is worth a quick glance to confirm no real token leaked in.
  • Since this is step 9 of a long-running extraction sequence (refactor(queue): split processors.ts into cohesive modules #4013), consider linking the specific prior PRs (steps 1-8) in the description for reviewer traceability, the way the file's own top comment does.

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-ai-review-orchestration branch from 84b9d33 to 2178ddb Compare July 11, 2026 05:35
Part of #4013. Moves the AI-review lock cluster, the advisory-eligibility
and manifest/token resolution helpers, and the ~625-line
runAiReviewForAdvisory orchestration (grounding/RAG/enrichment/impact-map/
culture-profile/inline-findings) out of processors.ts into
queue/ai-review-orchestration.ts. processors.ts re-exports the symbols
still imported directly by existing tests.

Also fixes two grounding/enrichment wiring tests that registered a repo
outside the default GITTENSORY_REVIEW_REPOS allowlist, which silently
no-op'd their own "no installationId" assertions, and adds coverage for
the GitHub-token and PR-body optional-chain fallbacks.
@JSONbored
JSONbored force-pushed the refactor/4013-extract-ai-review-orchestration branch from 2178ddb to 4e0f0c6 Compare July 11, 2026 05:39
@JSONbored
JSONbored merged commit c8bb830 into main Jul 11, 2026
18 checks passed
@JSONbored
JSONbored deleted the refactor/4013-extract-ai-review-orchestration branch July 11, 2026 05:53
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