Skip to content

fix(queue): wire lock-heartbeat onLost at both actuation and AI-review call sites - #10254

Merged
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
bitfathers94:fix/issue-10019
Jul 31, 2026
Merged

fix(queue): wire lock-heartbeat onLost at both actuation and AI-review call sites#10254
loopover-orb[bot] merged 2 commits into
JSONbored:mainfrom
bitfathers94:fix/issue-10019

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

test(queue): cover the verdict-flip escalation audit failure path

Reindenting the fresh-verdict block under the new lock-lost guard exposed a
few previously-untested lines: the escalation audit write's error path, and
two type-level ??/truthy fallbacks that are unreachable given the call
site's actual invariants (mirroring the identical annotation already used
elsewhere in this function for the same pattern).

Closes #10019

…w call sites

A holder whose transient lock renewal reports it no longer owns the key (TTL
lapse + re-claim, or a maintainer's forced-re-run steal) never learned about
it -- onLost was documented but no caller supplied it, so a losing pass kept
running to completion: the actuation pass could still merge/close/comment
after another pass took over, and the AI-review pass could still overwrite
the winner's cached verdict. Both heartbeats now pass onLost, which aborts
the publish-and-maintain unit before any further GitHub mutation and
discards the AI-review result in favor of the lock-contended placeholder
instead of persisting it.
Reindenting the fresh-verdict block under the new lock-lost guard exposed a
few previously-untested lines: the escalation audit write's error path, and
two type-level `??`/truthy fallbacks that are unreachable given the call
site's actual invariants (mirroring the identical annotation already used
elsewhere in this function for the same pattern).
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 14:27
@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-31 14:38:03 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR wires an `onLost` callback into both the actuation-lock and AI-review-lock heartbeats so a pass that loses lock ownership mid-flight aborts (throwing `PrActuationLockContendedError`) or discards its verdict (`aiReviewLockContendedResult`) instead of racing the new lock owner. The reindent of the fresh-verdict block to accommodate the new `aiReviewLockLost` guard is mechanical and preserves the existing verdict-flip/cache-write logic unchanged inside the new `else` branch. The added test file directly exercises the wiring at both call sites (mocking `startLockHeartbeat` to synchronously fire `onLost`), which is the right level to test given `startLockHeartbeat`'s own renew mechanics are already covered elsewhere.

Nits — 5 non-blocking
  • The `console.error` calls at src/queue/processors.ts:4506 and :11880 are intentional structured-log emissions (asserted on in the tests), not debug leftovers, but consider using a shared logger helper if one exists elsewhere in this file for consistency.
  • The reindented fresh-verdict block adds several `/* v8 ignore next */` annotations for type-level fallbacks (e.g. `aiReview.findings ?? []`, `aiReview.metadata ?? {}`) — worth double-checking each truly mirrors an existing invariant elsewhere in the function rather than newly asserting unreachability without justification.
  • queue.test.ts's new flip-escalation-audit-failure test mocks `recordAuditEvent` to throw only for one event type, which is a reasonable narrow test but relies on `recordAuditEvent`'s call-order/signature staying stable — a small coupling worth a one-line comment if it isn't already documented elsewhere.
  • Confirm the CI failure noted in BASE BRANCH STATUS context (2 commits behind default) doesn't hide an unrelated regression before merge — not a defect in this diff itself.
  • Consider consolidating the two nearly-identical `onLost` console.error blocks (processors.ts:4506, :11880) into a small shared helper given they log almost the same shape of structured JSON.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #10019
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 ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 140 registered-repo PR(s), 99 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 140 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff wires onLost at both call sites (processors.ts:4436 actuation lock, processors.ts:11655 AI-review lock), each records the required structured console.error with the specified fields and sets a pass-local flag; the actuation flag triggers throwing PrActuationLockContendedError before maintenance mutations, and the AI-review flag causes the fresh-verdict result to be replaced with aiReviewL

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 140 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.38%. Comparing base (9a84fcd) to head (e2cd309).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10254      +/-   ##
==========================================
+ Coverage   80.60%   81.38%   +0.77%     
==========================================
  Files         283      284       +1     
  Lines       59101    62578    +3477     
  Branches     7000     8279    +1279     
==========================================
+ Hits        47641    50927    +3286     
- Misses      11167    11235      +68     
- Partials      293      416     +123     
Flag Coverage Δ
backend 94.50% <100.00%> (?)

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

Files with missing lines Coverage Δ
src/queue/processors.ts 94.50% <100.00%> (ø)

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 2794910 into JSONbored:main Jul 31, 2026
8 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

queue(locks): wire the lock-heartbeat onLost callback at both production call sites

1 participant