Skip to content

refactor(queue): extract live CI-aggregate/merge-state resolution into its own module - #4960

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

refactor(queue): extract live CI-aggregate/merge-state resolution into its own module#4960
JSONbored merged 1 commit into
mainfrom
refactor/4013-extract-ci-resolution

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Part of refactor(queue): split processors.ts into cohesive modules #4013's module-split sequence for src/queue/processors.ts. Step 6, after transient-locks.ts (refactor(queue): extract transient-lock primitives into their own module #4157), signal-snapshot.ts (refactor(queue): extract signal-snapshot generation into its own module #4820), duplicate-detection.ts (refactor(queue): extract duplicate-cluster adjudication into its own module #4823), slop-detection.ts (refactor(queue): extract AI-slop-advisory gating/orchestration into its own module #4946), and review-evasion.ts (refactor(queue): extract review-evasion close-enforcement guards into their own module #4957).
  • Moves the live CI-aggregate/merge-state caching and resolution layer into src/queue/ci-resolution.ts: cachedFetchLiveCiAggregate, fetchLiveCiAggregateWithRequiredContexts, cachedLiveCiAggregate, refreshLiveCiAggregate, reuseOrRefreshLiveCiAggregate, cachedLiveMergeState, refreshLiveMergeState, reuseOrRefreshLiveMergeState, cachedRequiredStatusContexts, evictLiveFactOnReject, liveFactKey, liveFactTokenPart, expectedCiContextsKeyPart, resolvedRequiredContextsKeyPart. Pure mechanical move, no behavior change.
  • LiveGithubFacts (the request-scoped memo these functions read/write) and RequiredStatusContextsLookup stay in processors.ts — both are foundational types used across dozens of unrelated call sites there, not specific to this concern — so ci-resolution.ts imports them back type-only, which creates no runtime circular dependency even though processors.ts also imports several functions from this file for its own remaining call sites (primeLiveMergeState's liveFactKey/liveFactTokenPart use, one remaining cachedRequiredStatusContexts caller, and 6 disposition/readiness call sites for the other exported functions).
  • No re-export shim needed: none of these functions were ever exported from processors.ts before, so there's no existing external import { ... } from "../../src/queue/processors" to preserve.
  • One real, previously-invisible coverage gap surfaced by isolating this code: cachedLiveCiAggregate's own request-scoped cache-hit branch (a second call within the same webhook pass reusing the first call's in-flight/settled promise, the whole point of the #4498 memo) had no direct test. Added a small dedicated test/unit/ci-resolution.test.ts that imports the function directly and asserts a second call with the same facts + args reuses the first result without a second live fetch, rather than trying to thread a full webhook simulation through two call sites that happen to share a cache key.

Part of #4013 (more extraction steps remain in the sequence — not closing the tracking issue).

Test plan

  • npx tsc --noEmit -p . — zero errors
  • npx vitest run test/unit test/integration — 697/698 files passed (1 skipped, pre-existing)
  • npm run test:coverage (unsharded) — 94.44% statements / 93.42% branches / 93.61% functions / 95.03% lines, no threshold failures; ci-resolution.ts itself is 100% line + branch + function covered
  • npm run docs:drift-check, npm run manifest:drift-check, npm run engine-parity:drift-check — all ok
  • 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.

…o its own module

Part of #4013's module-split sequence (step 6, after transient-locks.ts,
signal-snapshot.ts, duplicate-detection.ts, slop-detection.ts, and
review-evasion.ts): the live CI-aggregate/merge-state caching and
resolution functions move to src/queue/ci-resolution.ts. Pure
mechanical move, no behavior change.

LiveGithubFacts (the request-scoped memo these functions read/write)
stays in processors.ts -- it is a foundational type used across dozens
of unrelated call sites there -- so this file imports it back
type-only, which creates no runtime circular dependency even though
processors.ts also imports several functions from this file for its
own remaining call sites. liveFactKey/liveFactTokenPart and
cachedRequiredStatusContexts are exported for the same reason: each
still has one remaining caller left in processors.ts.

Isolating this code surfaced a genuine, previously-invisible coverage
gap: cachedLiveCiAggregate's own request-scoped cache-hit branch (a
second call within the same webhook pass reusing the first call's
in-flight/settled promise) had no direct test. Added one, importing
the function directly rather than threading a full webhook simulation
through two call sites that happen to share a cache key.
@JSONbored
JSONbored force-pushed the refactor/4013-extract-ci-resolution branch from 4ddcce0 to f76a6d6 Compare July 11, 2026 04:40
@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.26%. Comparing base (b94589c) to head (f76a6d6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4960   +/-   ##
=======================================
  Coverage   94.26%   94.26%           
=======================================
  Files         448      449    +1     
  Lines       38900    38900           
  Branches    14172    14172           
=======================================
+ Hits        36669    36670    +1     
  Misses       1574     1574           
+ Partials      657      656    -1     
Flag Coverage Δ
shard-1 46.81% <98.50%> (-0.02%) ⬇️
shard-2 33.32% <61.19%> (+<0.01%) ⬆️
shard-3 31.40% <0.00%> (-0.01%) ⬇️
shard-4 32.60% <74.62%> (-0.55%) ⬇️
shard-5 34.14% <0.00%> (+0.61%) ⬆️
shard-6 45.86% <82.08%> (+0.61%) ⬆️

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

Files with missing lines Coverage Δ
src/queue/ci-resolution.ts 100.00% <100.00%> (ø)
src/queue/processors.ts 95.37% <ø> (-0.07%) ⬇️
🚀 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 04:49:31 UTC

3 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 clean, verbatim step-6 extraction of the live CI-aggregate/merge-state caching layer out of processors.ts into a new ci-resolution.ts, matching the established #4013 module-split sequence (steps 1-5 already merged). Comparing the added file to the removed block in processors.ts, the function bodies, comments, and logic are byte-for-byte identical — only the export keyword was added to the functions processors.ts still calls directly, and LiveGithubFacts/RequiredStatusContextsLookup are now exported and imported back type-only, which is correctly erased at compile time and creates no runtime circular dependency despite processors.ts importing runtime functions from ci-resolution.ts. The new test/unit/ci-resolution.test.ts exercises a genuinely previously-uncovered branch (the request-scoped memo hit in cachedLiveCiAggregate) via a real two-call sequence against the same facts/key, not a fabricated scenario. All CI checks including codecov/patch are green.

Nits — 3 non-blocking
  • src/queue/ci-resolution.ts:40-45 carries the FNV-1a magic numbers (0x811c9dc5, 0x01000193) flagged by the linter, but this is pre-existing code moved verbatim from processors.ts, not new logic introduced by this diff — no action needed unless you want to name the constants while you're in here.
  • The deep-nesting flag on ci-resolution.ts:156 (fetchLiveCiAggregateWithRequiredContexts' .catch().then() chain) and the long-file flag on processors.ts are both pre-existing shapes carried over by the move, not regressions from this PR.
  • Consider a one-line note in the PR description confirming byte-identical diff (e.g. via `git diff --stat` on the moved block) so reviewers can trust the 'pure move' claim without a manual side-by-side, given how large the moved block is.

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. LLM value judgment: moderate — It's a well-scoped, low-risk mechanical continuation of an established file-decomposition effort that also closes a real, previously-invisible test gap, though by itself it's incremental engineering hygiene rather than a functional improvement.
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: Python, TypeScript, Ruby, Go, JavaScript, MDX, Shell, Solidity
  • 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 merged commit 2451811 into main Jul 11, 2026
18 checks passed
@JSONbored
JSONbored deleted the refactor/4013-extract-ci-resolution branch July 11, 2026 05:30
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