Repository navigation
Conversation
e9dfc21 to
04941ae
Compare
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — 🔴 changes requested (blocking)Reviewed BLOCKING: a loop's final nudge turn can be expired while it is still running. A cycle cap or runtime budget that is already spent now wakes the timer immediately, even when the re-arm comes from a mid-turn path that previously waited a full interval. BLOCKING — src/kiro_crew/autonudge_service/timers.py:1112 Trigger: a dashboard loop with |
ffd360f to
09e646e
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: [DESIGN-REVIEWED] 8101e7b Description read[DESCRIPTION-READ] 7cbced9f2f9406bc30c38c4373a9c6d3ef4abdab33dfbb45eb6765be24c5a14b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
09e646e to
e853317
Compare
e853317 to
25e49fd
Compare
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (5 items) — 4 justifiedIntent: stop a prompt loop as soon as its runtime budget or cycle cap runs out, instead of up to a full interval later. FIX.
[FIRST-PRINCIPLES-REVIEWED] 8101e7b Description read[DESCRIPTION-READ] 29abeeaf44703059978de9f434e8c3b9efc3f6314b97c9fa4ad29c613fc4f0d4 That sha256 names the PR description this verdict read. Recompute it with |
…a full interval The cycle cap and the runtime budget are checked only when a loop's timer wakes, and _arm_from_deadline always armed toward the interval deadline. A loop whose interval is longer than its remaining budget slept past the budget, and the turn that ended the last allowed cycle re-armed a full fresh interval. Either way the loop sat active with a spent bound for up to a day, emitted no expired event, and refused a create-only arm on its slot. Cap the armed delay at the runtime budget left, and arm at once when the cycle cap is reached, so the timer's existing bound branches stop the loop on time. Structured monitors keep their own deadline because their tick re-arms itself. Closes kirodotdev#26764
A loop held for a person stops at the hold before either bound is checked, so the early wake for a spent cap or budget re-armed it at zero on every tick. The bound shortening now skips a held loop. A budget-bound wake is padded by one monotonic clock tick, because the event loop can run a timer up to one tick early and the budget check would then find the budget unspent. Also marks the two delay-recording sleep patches in the budget tests flake-ok.
25e49fd to
8101e7b
Compare
|
Status at Finding ( Suggested design: shorten the delay only on arms made after the turn has ended (the AI-assisted, posted on behalf of iamwhatever |
|
[operator: bolichen97] Continuing this in #35437; thanks for the start. |
…ter (#35437) _timer stops a loop on a spent runtime budget only when it wakes, but _arm_from_deadline armed toward the interval deadline alone. A loop whose budget was shorter than its interval stayed active with the budget spent for up to a full interval (a day at most): no expired event, and a create-only arm on its slot was refused. The timer now wakes one second after a budget that runs out before the next deadline; the second keeps a timer asyncio runs a clock tick early from firing a turn. A budget already spent arms as before, since app reconcilers revive such a loop every few seconds. Part of #26764. Builds on #26767.
|
Thanks for starting this. A maintainer continued this work in #35437, which has since merged on main, so I'm closing this PR as superseded. Please reopen if anything here is still missing from main. |
Problem / Motivation
Goal: a prompt loop stops when its runtime budget or cycle cap is spent, not up to a full interval later.
Both bounds are enforced only when the loop's timer wakes (
_timerinsrc/kiro_crew/autonudge_service/firing.py), but_arm_from_deadlinealways arms toward the interval deadline, so:monitor_start(interval_secs=86400, max_runtime_secs=600)arms an 86400 s timer; the budget runs out at 600 s but nothing wakes the loop until the next day.notify_turn_completere-arms a fresh full interval, and the cap is applied only when that timer next wakes.In both cases the loop stays
activewith its bound spent for up to a day, emits noexpiredevent, and refuses a create-onlymonitor_starton its slot.Why it matters
A long-interval loop that has hit its budget or cycle cap looks like it is still running on the dashboard, sends the user no stop notification, and holds its session slot — so a new
monitor_starton that slot is refused — for up to the 86400 s maximum interval.Not a goal
finally, so arming them at delay 0 could spin. They are explicitly left out._timerthemselves, which already deactivate and emitexpiredcorrectly once the timer wakes.What changed (motivation → approach → change)
Symptom: a spent runtime budget or cycle cap leaves the loop armed for its full interval. Root cause:
_arm_from_deadlinepicks the arm delay from the interval alone and never from the bounds.Change: in
_arm_from_deadline(src/kiro_crew/autonudge_service/timers.py), for a prompt loop (not a structured monitor): arm with delay 0 whencap_reached(loop), otherwise cap the delay at the runtime budget left (max_runtime_secs - runtime_elapsed(loop, created_ts), floored at 0). The existing bound branches in_timerthen deactivate the loop withstopped_reasonruntime_budgetorcycle_capand emitexpiredon time. The bounds are read through the model's defensive readers (cap_reached,_positive_number), so a malformed stored bound means no bound rather than a raise. A loop held for approval or a person still returns from its tick without arming, and a work-ledger extension re-arms through this same function with the raised bound, so neither path spins.Backwards compatibility
Compatible: a loop with no cycle cap and no runtime budget, or whose budget is longer than its interval, arms exactly as before.
Tests
test/test_autonudge_budget.py:test_a_budget_shorter_than_the_interval_stops_the_loop_when_it_is_spent(F7) andtest_a_spent_cycle_cap_stops_the_loop_without_waiting_an_interval(F8). Each drives the loop withasyncio.sleeprecorded and asserts the loop ends inactive withstopped_reasonruntime_budget/cycle_capand thatexpiredwas emitted._arm_from_deadline,notify_turn_complete,_finish_fire_cycle,timers.pyor autonudge gave 2415 passed. The change touches no frontend file.Manual verification
On
mainthe two tests reproduce both bugs (armed ~86400 s past a 600 s budget; re-armed a full interval after the cap). On this branch both stop on time.Related Issues
Closes #26764
Sibling sweep
Swept: grep for the arming and bound-check sites in
autonudge_service/(_arm_from_deadline,_timer,notify_turn_complete,_finish_fire_cycle).Sibling:
src/kiro_crew/autonudge_service/firing.py-- not affected -- the cap and budget branches (lines 203 and 251) that run when the timer wakes; this PR only makes the timer wake on time.Related open PRs (not duplicates): #21377 adds a held-subject-read branch at the top of
_arm_from_deadline, and #22855 adds an overdue backstop; both touch this area, so whichever lands second needs a small rebase.Pattern harvest
Rule candidate: review-prompt
Pattern: a bound (cap or budget) enforced only at wake time, while the thing that schedules the wake ignores the bound and arms for the full interval.
Checklist
Contribution License Agreement
Contributed under the project's Apache-2.0 license, as the Licensing section of CONTRIBUTING.md describes.