Skip to content

feat(miner): honor kill-switch mid-attempt during iterate-loop - #5799

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
james3773:feat/miner-kill-switch-mid-iteration-v2
Jul 14, 2026
Merged

feat(miner): honor kill-switch mid-attempt during iterate-loop#5799
JSONbored merged 2 commits into
JSONbored:mainfrom
james3773:feat/miner-kill-switch-mid-iteration-v2

Conversation

@james3773

Copy link
Copy Markdown
Contributor

Summary

  • stop rented miner loops as soon as a kill switch trips mid-attempt, not only between loop cycles
  • re-check the live kill scope after handoff so mid-attempt abandon paths halt cleanly and release any in-flight queue claim
  • add miner regression coverage for the new mid-iteration, abandon, and claim-release branches

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Closes #5670

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • npm run test:ci reached cf-typegen:check, but local wrangler types failed with write EPIPE before the miner-specific checks completed. I still ran npm run typecheck plus npx vitest run packages/loopover-engine/test/iterate-loop.test.ts test/unit/miner-attempt-cli.test.ts test/unit/miner-attempt-runner.test.ts test/unit/miner-loop-cli.test.ts successfully for this diff.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

Non-UI change.

Notes

  • Issue #5670 is open and unassigned, and there was no open PR already targeting it at creation time.

Lang-bt and others added 2 commits July 14, 2026 10:29
…ored#5670)

Probe shouldAbort before each driver iteration and re-resolve kill after
handoff so a tripped switch stops the rented loop without opening a PR,
and halt the outer loop immediately with a released queue claim.
Raise patch coverage for JSONbored#5670 abandon/claim-release paths and satisfy validate-code typecheck on the loop-cli spy.
@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 14, 2026
@loopover-orb

loopover-orb Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-14 19:57:52 UTC

11 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
This PR wires a cooperative mid-iteration kill-switch probe into the iterate-loop core, threads a live (disk-re-read) kill-switch check through attempt-cli/attempt-runner so a kill trips after handoff still blocks opening a PR, and has loop-cli release the in-flight queue claim on any kill/pause halt (both top-of-loop and post-attempt). The new `resolveShouldAbort`/`shouldAbort` plumbing is checked correctly before each driver call and iterationsUsed accounting is right (iterationNumber - 1). Test coverage is thorough across all four touched call sites (boolean vs object abort shapes, whitespace-reason fallback, claim-release on both kill and pause, post-handoff re-check) and CI (including codecov/patch) is green.

Nits — 4 non-blocking
  • packages/loopover-miner/lib/attempt-cli.js and loop-cli.js are now 554 and 464 lines respectively, both over this repo's apparent 400-line convention threshold — worth a follow-up split (e.g. extracting the kill-switch resolver into its own module) rather than growing further in the next PR.
  • attempt-cli.js:397-410 — `recordMinerKillSwitchTransition` is imported from `./governor-kill-switch.js`, a file not touched in this diff; confirm that export already exists there (tests and green CI strongly suggest it does, but it's worth calling out since it's invisible in this review).
  • Consider hoisting the doc comment at iterate-loop.ts:89-91 about `IterateLoopShouldAbort`'s abandon semantics onto `resolveShouldAbort` itself so the boolean/object dual-shape contract is documented next to its only implementation.
  • In loop-cli.js the `killSwitchAbandon` branch re-derives `haltReason` via a second `checkKillSwitchFn({ env })` call after the claim was already released via the generic `markFailed` path above — a short comment noting this second check is only for message text (not a second release) would save the next reader from re-deriving that themselves.
Flagged checks (non-blocking)
  • Contributor trust — Contributor flagged for review
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5670
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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 882 registered-repo PR(s), 623 merged, 83 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jony376; Gittensor profile; 882 PR(s), 83 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: jony376
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 882 PR(s), 83 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.
[BETA] Chat with Gittensory

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

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

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 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

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.12%. Comparing base (9b3f4b2) to head (e6c735c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5799      +/-   ##
==========================================
+ Coverage   95.10%   95.12%   +0.01%     
==========================================
  Files         584      584              
  Lines       46440    46487      +47     
  Branches    14849    14856       +7     
==========================================
+ Hits        44169    44219      +50     
+ Misses       1515     1512       -3     
  Partials      756      756              
Flag Coverage Δ
shard-1 43.71% <0.00%> (-0.05%) ⬇️
shard-2 36.24% <76.47%> (+0.04%) ⬆️
shard-3 32.11% <0.00%> (-0.04%) ⬇️
shard-4 32.88% <0.00%> (-0.04%) ⬇️
shard-5 31.60% <0.00%> (-0.04%) ⬇️
shard-6 44.50% <23.52%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
packages/loopover-engine/src/miner/iterate-loop.ts 79.34% <100.00%> (+4.68%) ⬆️
...ckages/loopover-engine/src/miner/iterate-policy.ts 12.50% <ø> (ø)
packages/loopover-miner/lib/attempt-cli.js 97.90% <100.00%> (+0.19%) ⬆️
packages/loopover-miner/lib/attempt-runner.js 100.00% <100.00%> (ø)
packages/loopover-miner/lib/loop-cli.js 98.17% <100.00%> (+1.52%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@james3773
james3773 marked this pull request as ready for review July 14, 2026 17:59
@james3773
james3773 requested a review from JSONbored as a code owner July 14, 2026 17:59
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 14, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

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

@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.

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

@JSONbored
JSONbored merged commit 3525e95 into JSONbored:main Jul 14, 2026
15 of 16 checks passed
This was referenced Jul 14, 2026
This was referenced Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kill-switch implementation

3 participants