Skip to content

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

Closed
bitfathers94 wants to merge 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10019
Closed

fix(queue): wire lock-heartbeat onLost at both actuation and AI-review call sites#10240
bitfathers94 wants to merge 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10019

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(queue): wire lock-heartbeat onLost at both actuation and AI-review 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.

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.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 13:52
@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-31 14:04:19 UTC

2 files · 1 AI reviewer · no blockers · CI failing · unstable

🛑 Suggested Action - Fix Blockers

Review summary
This wires the previously-documented-but-unused `onLost` callback into both production lock heartbeats: the PR-actuation heartbeat (src/queue/processors.ts:4494) sets `actuationLockLost` and the code re-checks it just before the maintenance pass's merge/close mutation, throwing `PrActuationLockContendedError` to abort; the AI-review heartbeat (src/queue/processors.ts:11880) sets `aiReviewLockLost` and `aiReviewCacheReadDecideAndRun` substitutes `aiReviewLockContendedResult(advisory)` in place of the fresh verdict so a losing pass never overwrites `ai_review_cache`. The added test/unit/lock-heartbeat-onlost.test.ts exercises both the lost and not-lost paths for each site via a mocked `startLockHeartbeat`, verifying zero merge calls and no cache write on loss, and unchanged behavior otherwise — a reasonable isolation strategy since the heartbeat's own renew mechanics are already covered elsewhere.

Nits — 3 non-blocking
  • The `console.error(JSON.stringify(...))` calls at src/queue/processors.ts:4506 and :11880 are flagged by the external brief as debug leftovers, but they match the existing structured-audit-logging convention used elsewhere in this file (e.g. the surrounding `recordAuditEvent` calls) rather than being stray debug output — worth confirming intent but not a real defect.
  • This PR adds to an already very large file (src/queue/processors.ts, ~12k lines) — not something to fix here, but a candidate for the module-extraction pattern already used for ai-review-orchestration.ts and ci-resolution.ts.
  • Consider whether the `actuationLockLost` check should also guard any other GitHub-mutating call between lock acquisition and the maintenance pass, in case future code adds one before the existing check at processors.ts:~4565.

CI checks failing

  • codecov/patch — 86.20% of diff hit (target 99.00%)

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: significant
Linked issue satisfaction

Addressed
The diff wires onLost at both call sites (processors.ts:4436 actuation heartbeat and processors.ts:11655 AI-review heartbeat), each logging the required structured console.error and setting a pass-local flag; the actuation flag throws PrActuationLockContendedError before the maintenance mutation, and the AI-review flag discards the fresh verdict in favor of aiReviewLockContendedResult before the c

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

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.34%. Comparing base (79d7e03) to head (ad912b2).

Files with missing lines Patch % Lines
src/queue/processors.ts 86.20% 1 Missing and 3 partials ⚠️

❌ Your patch check has failed because the patch coverage (86.20%) is below the target coverage (99.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10240      +/-   ##
==========================================
+ Coverage   80.57%   81.34%   +0.77%     
==========================================
  Files         283      284       +1     
  Lines       59095    62585    +3490     
  Branches     6996     8281    +1285     
==========================================
+ Hits        47614    50909    +3295     
- Misses      11188    11257      +69     
- Partials      293      419     +126     
Flag Coverage Δ
backend 94.41% <86.20%> (?)

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.41% <86.20%> (ø)

@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (CI is failing (codecov/patch)). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 31, 2026
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