Skip to content

feat(miner): track real per-issue attempt-history on the portfolio queue - #5661

Merged
JSONbored merged 1 commit into
mainfrom
miner-portfolio-attempt-history
Jul 13, 2026
Merged

feat(miner): track real per-issue attempt-history on the portfolio queue#5661
JSONbored merged 1 commit into
mainfrom
miner-portfolio-attempt-history

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

buildAttemptGovernorContext hardcoded convergenceInput to a first-attempt-shaped literal on every call — the Governor's fully-built classifyPortfolioConvergence detector (#4286) has never seen real data.

  • portfolio-queue.js gains an additive v3 -> v4 migration: attempts_count, consecutive_failures, reenqueue_count (all INTEGER NOT NULL DEFAULT 0), guarded by the same per-column presence check the leased_at migration already uses
  • attempts_count increments on every real claim (dequeueNext/batchClaim)
  • consecutive_failures + reenqueue_count increment together on every in_progress -> queued transition that did not reach done (markFailed, reclaimStuckItem) — exactly the "cycling queued → in_progress → queued without ever reaching done" the detector's own header names
  • consecutive_failures resets to 0 on markDone; reenqueue_count is a lifetime total, deliberately untouched there
  • requeueItem (a manual reopen of already-completed work) touches no counter — a different transition than the stuck-loop cycle
  • New getAttemptHistory(repoFullName, identifier, apiBaseUrl) returns a real PortfolioConvergenceInput; an item never enqueued reads the same honest zero-state as a genuine first attempt
  • attempt-cli.js reads this item's real history (keyed issue:<n>, matching how portfolio-discovery.js enqueues issue-shaped candidates) and threads it into buildAttemptGovernorContext, which stays pure and just forwards it

Closes #5654

Test plan

  • test/unit/miner-portfolio-queue.test.ts — schema migration (fresh v3 file, and a defensive idempotency test for a file that already carries all three columns), counter correctness across claim/reclaim/markFailed/markDone/requeue sequences, the reachedDone invariant, apiBaseUrl scoping, and a REGRESSION proving a genuinely non-convergent item now produces a PortfolioConvergenceInput that classifyPortfolioConvergence classifies as non_convergent
  • test/unit/miner-attempt-input-builder.test.ts — real convergenceInput threads through unchanged; omitted falls back to the honest zero-state
  • test/unit/miner-attempt-cli.test.ts — the real per-issue read is called with the right key and flows into governor.convergenceInput; the real (non-DI) default is exercised via an isolated tmp store
  • test/unit/miner-migrate-cli.test.ts updated for the new schema version (v4)
  • npm run test:ci green; npm run test:coverage (unsharded) — 100% branch coverage on every new/changed line, verified against lcov.info
  • npm run typecheck, npm run build:miner, npm run test:miner-pack, npm audit --audit-level=moderate all clean

buildAttemptGovernorContext previously hardcoded convergenceInput to a
first-attempt-shaped literal on every call, so the Governor's fully-built
non-convergence detector never saw real data. portfolio-queue.js now gains
an additive attempts_count/consecutive_failures/reenqueue_count schema
migration, incremented/reset on claim, reclaim, markFailed, and markDone,
plus a getAttemptHistory read that attempt-cli.js threads through into
the Governor context for the target issue.

Closes #5654
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 3ebe095 Commit Preview URL

Branch Preview URL
Jul 13 2026, 10:15 PM

@loopover-orb loopover-orb Bot added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. labels Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Warning

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

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-13 22:18:26 UTC

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

⏸️ Suggested Action - Manual Review

  • AI review could not be completed: The dual-model AI review did not return a usable verdict for this change.

Review summary
This PR replaces a hardcoded first-attempt-shaped literal in buildAttemptGovernorContext with a real per-issue attempt-history query, adding an additive v3->v4 migration (three counters guarded by the same column-presence check as the existing leased_at migration) and a getAttemptHistory read wired through attempt-cli.js into the pure composer. The counter semantics are well-reasoned and consistently applied: attempts_count increments on both claim paths, consecutive_failures/reenqueue_count increment together on the same in_progress->queued-without-done transition (markFailed and reclaimStuckItem), consecutive_failures resets on markDone while reenqueue_count stays a lifetime total, and requeueItem correctly leaves counters untouched since it's a different (already-done) transition. Tests are substantial and include a genuine regression exercising the real classifyPortfolioConvergence detector end-to-end, plus migration idempotency for both a fresh v3 file and one that already has the new columns.

Nits — 7 non-blocking
  • The magic PR/issue reference numbers (Track real per-issue attempt-history on the portfolio queue, feed the Governor's convergenceInput #5654) sprinkled through comments in attempt-input-builder.js and portfolio-queue.js are fine as commit-history breadcrumbs but add noise; not necessary to fix.
  • portfolio-queue.js and attempt-cli.js are both approaching/at the ~400-line long-file threshold per the external brief — consider whether portfolio-queue.js's migration list is due for extraction as more migrations accrue.
  • attempt-cli.js's getAttemptHistory call hardcodes no apiBaseUrl (defaulting to github.com) per its own comment — worth a follow-up issue once multi-forge support lands there, though correctly documented as a known limitation.
  • Consider extracting the migration step functions in portfolio-queue.js into a separate migrations module if more are added, to keep the store file under the long-file threshold.
  • The comment density in attempt-input-builder.js/portfolio-queue.js is very high; some of the historical narrative (e.g., referencing the old hardcoded literal) could be trimmed once the change lands, since git history already preserves that context.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • AI review could not be completed — The gate is held for a human reviewer rather than passed automatically; it re-evaluates on the next update.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5654
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: 45 registered-repo PR(s), 36 merged, 333 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 45 PR(s), 333 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence. LLM value judgment: significant — This closes a real, previously-hardcoded gap in the Governor's convergence detection by wiring genuine per-issue attempt-history data end-to-end from schema through to the classifier, with thorough regression coverage proving the detector now fires correctly on real non-convergent data.
Linked issue satisfaction

Addressed
The PR adds the additive attempts_count/consecutive_failures/reenqueue_count schema migration, wires counter updates through claim/markFailed/reclaimStuckItem/markDone, implements getAttemptHistory returning a real PortfolioConvergenceInput, and threads it through attempt-cli.js into buildAttemptGovernorContext without touching non-convergence.ts's classifier, matching the issue's requirements poi

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: 45 PR(s), 333 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
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 &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; 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

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 13, 2026
@JSONbored
JSONbored merged commit b579eb6 into main Jul 13, 2026
17 checks passed
@JSONbored
JSONbored deleted the miner-portfolio-attempt-history branch July 13, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

Track real per-issue attempt-history on the portfolio queue, feed the Governor's convergenceInput

1 participant