feat(miner): wire attempt-metering.ts into the iterate loop for a real mid-attempt budget abort#5437
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | a760181 | Commit Preview URL Branch Preview URL |
Jul 12 2026, 08:25 PM |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5437 +/- ##
==========================================
+ Coverage 94.48% 94.52% +0.03%
==========================================
Files 554 554
Lines 44450 44467 +17
Branches 14662 14668 +6
==========================================
+ Hits 41999 42032 +33
+ Misses 1776 1754 -22
- Partials 675 681 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - fixes requiredReview updated: 2026-07-12 20:34:32 UTC
🛑 Suggested Action - Manual Review
Review summary Blockers
Nits — 7 non-blocking
CI checks failing
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk 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.
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 Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
f72c9a1 to
81d8d95
Compare
…l mid-attempt budget abort Closes #5395 - iterate-loop.ts now accumulates real per-iteration usage (turns, costUsd, and wall-clock time measured around each driver invocation via an injected clock) into attempt-metering.ts's AttemptMeterTotals, and evaluates it every iteration against an optional AttemptBudget -- a breach on any axis now abandons mid-attempt via the same costCeilingReached signal iterate-policy.ts already exposed for the narrower, never-wired maxTotalTurns field it replaces. - attempt-input-builder.js's buildAttemptLoopInput sets that budget from AmsPolicySpec.capLimits -- the same cap ceilings the Governor's cross-cycle GovernorCapUsage already enforces after the fact (loop-cli.js's saveCapUsage between loop cycles), so one runaway attempt can no longer burn through the whole cross-cycle budget before anything reacts. - tokens stays an honest 0: no CodingAgentDriver reports a real per-iteration token count today. - Split runIterateLoop into a thin wrapper over an internal core so the new finalMeterTotals/budgetBreaches fields attach once at a single always-reached return point, rather than threading them onto the core's own genuinely-unreachable v8-ignored fallback branch (which vitest's ignore-comment doesn't suppress from Codecov's raw patch view).
81d8d95 to
61478a0
Compare
…y a same-iteration pass Flagged by gittensory's own review on PR #5437: the previous design fed a budget breach into iterate-policy.ts's costCeilingReached signal, whose precedence checks selfReview.kind === "pass" first -- so an iteration that both breaches the ceiling and produces a clean self-review would hand off instead of abandoning, silently defeating the point of wiring a mid-attempt abort in at all. A reached budget ceiling is now checked and, if breached, acted on directly in iterate-loop.ts BEFORE self-review even runs -- self-review is skipped entirely once the ceiling is breached, since its verdict can no longer change an already-decided outcome. The spend/turns/time already happened either way; this only stops it from silently buying a pass on the SAME iteration that broke the ceiling.
…g check Codecov flagged 2 partial branches on the ceiling check added in the prior commit: every existing test either omitted budget entirely or set one that immediately breached, so the "budget configured but comfortably within limits" branch never ran. Adds that case at both the engine's own iterate-loop level and through the real runMinerAttempt pipeline.
Closes #5395
Summary
iterate-loop.tsnow accumulates real per-iteration usage (turns,costUsd, and wall-clock time measured around each driver invocation via an injected clock) intoattempt-metering.ts'sAttemptMeterTotals, and evaluates it every iteration against an optionalAttemptBudget. A breach on any axis abandons mid-attempt -- a hard, unconditional stop checked BEFORE self-review even runs, so a same-iteration pass can never bypass it (see "Precedence fix" below).attempt-input-builder.js'sbuildAttemptLoopInputsets that budget fromAmsPolicySpec.capLimits-- the same cap ceilings the Governor's cross-cycleGovernorCapUsagealready enforces after the fact (loop-cli.js'ssaveCapUsagebetween loop cycles). One runaway attempt can no longer burn through the entire cross-cycle budget before anything reacts.tokensstays an honest 0 -- noCodingAgentDriverreports a real per-iteration token count today.packages/gittensory-miner/docs/coding-agent-driver.md's stale "zero production callers" note.Precedence fix (per this repo's own review on this PR)
The first version fed a budget breach into
iterate-policy.ts'scostCeilingReachedsignal, whose own precedence checksselfReview.kind === "pass"first -- so an iteration that both breached the ceiling and produced a clean self-review would hand off instead of abandoning, silently defeating the point of a mid-attempt abort. Fixed by checking the budget directly initerate-loop.tsand, on a breach, abandoning before self-review ever runs -- self-review is skipped entirely once the ceiling is breached, since its verdict can no longer change an already-decided outcome.A note on the wrapper-split refactor
runIterateLoopis now a thin wrapper over an internalrunIterateLoopCore. The newfinalMeterTotals/budgetBreachesresult fields attach once at the wrapper's single always-reached return point, rather than being threaded onto the core's own genuinely-unreachable,/* v8 ignore */-guarded fallback branch. vitest's ignore-comment only suppresses its own text-reporter percentage -- it does not change what's written to the raw lcov Codecov reads -- so putting new fields directly on that branch would have shown as a real, unexercisable uncovered patch line.Test plan
tsc --noEmit --incremental falseclean (root +packages/gittensory-engine)npm run test --workspace @jsonbored/gittensory-engine-- 525/525 passingnpx vitest run test/unit test/contract-- all passing (excluding 2 pre-existing, environment-specific real-git test files unrelated to this diff)iterate-loop.tsandattempt-input-builder.js, confirmed via the root vitest suite specifically (the new hard-ceiling-precedence path is exercised throughrunMinerAttempt's real, unmocked call intorunIterateLoop, not just the engine's ownnode:testsuite)npm run docs:drift-check/manifest:drift-check/engine-parity:drift-checkall cleannpm audit --audit-level=moderate-- 0 vulnerabilitiesgit diff --checkclean