Repository navigation
fix(autonudge): resume a paused goal loop from its cycle count - #16353
Conversation
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check one case: Play on a loop stopped at its cycle limit now keeps the time already used, but the copy still promises "a fresh budget". Suggestions
[UX-REVIEWED] 213cb4d Description read[DESCRIPTION-READ] 32c94db50c1fb8a53b788d00e27364b63336f1c74c4d670840a7502ada89eb53 That sha256 names everything this verdict read: the PR description, plus the 3 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 |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check one case before merge: paused time still counts against the time budget. A loop resumed shortly before its budget runs out gets only seconds of running time. [DESIGN-REVIEWED] 213cb4d Description read[DESCRIPTION-READ] 41e7e95fb4a55ab5e25e7c6776d9fdb017a1356c218543a22c086f8a98f694f3 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ human override accepted@pepmach overrode this lane for |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
9a9b623 to
f21161c
Compare
|
/ai-review override first-principles f21161c: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; the fresh-budget reset stays only for the two endings where the budget itself ran out (cycle_cap, runtime_budget), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
f21161c to
51603c3
Compare
|
Re the Opus and Design advisories on the two-press edge (budget elapsed during a manual pause; paused by hand at exactly the cap): folded into 51603c3. Play now also resets when the allowance is already spent at the press -- cap reached, or the timer's own |
|
/ai-review override first-principles 51603c3: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; the fresh-budget reset stays for a loop whose allowance is spent (stopped on cycle_cap/runtime_budget, or its cap or budget already spent at the press), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
51603c3 to
60f6a8a
Compare
|
/ai-review override first-principles 60f6a8a: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; the fresh-budget reset stays for a loop whose allowance is spent (stopped on cycle_cap/runtime_budget, or its cap or budget already spent at the press), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
|
60f6a8a: the GPT/Opus finding is fixed -- spent-ness is now |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
60f6a8a to
150a255
Compare
|
/ai-review override first-principles 150a255: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; the fresh-budget reset stays for a loop whose allowance is spent (stopped on cycle_cap/runtime_budget, or its cap or budget already spent at the press), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
|
150a255: the GPT finding on preserved malformed counters is fixed at the boundary the adjudication named -- |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
150a255 to
430716a
Compare
|
/ai-review override first-principles 430716a: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; the fresh-budget reset stays for a loop whose allowance is spent (stopped on cycle_cap/runtime_budget, or its cap or budget already spent at the press), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
Play on a paused goal loop reset its cycle count and runtime clock whatever had stopped it, so a loop a person paused at cycle 7 of 24 came back as cycle 1 of 24. The fresh-budget reset exists for a spent bound, where Play would otherwise be re-stopped on its first tick; a pause with allowance left spent nothing. Reset each counter on its own, and only when the bound behind it is spent: a spent cycle cap (the loop stopped on cycle_cap, or its count has reached a non-zero cap) zeroes cycle_count; a spent time budget (it stopped on runtime_budget, or the clock ran a non-zero budget out by the press, since the clock keeps running through a pause) re-anchors created_ts. The other counter is kept, so an overnight pause at 7 of 24 comes back at 7 of 24 on a fresh clock. The reason is read from the pre-write snapshot since the revival clears the field; the bounds are read type-safely because the store is agent-writable, and _load now repairs a malformed cycle_count or created_ts at the boundary since a resume no longer overwrites them. monitor_update bound raises and reconciler re-arms were never reset and stay that way. Pin the rule as a parametrized test through authorize_and_update_nudge (red first on main for the five non-budget reasons), and make the RFC, the owning spec, the route and authz comments and the popover comments say what the code now does.
430716a to
213cb4d
Compare
|
/ai-review override first-principles 213cb4d: Product-owner ruling on 2026-10-02 (repo owner): a paused goal loop resumes from its breakpoint, not from cycle 1; a spent bound resets only its own counter (a spent cycle cap zeroes the count, a spent time budget re-anchors the clock), since Play there is otherwise a dead press. The RFC edit in this PR records that decision rather than proposes one; the RFC's own motivation for the reset named limit stops only. |
|
Design disposition, 213cb4d: the per-bound reset is adopted. |
Human judgment recorded@pepmach marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for
This decision applies only to this commit. A new push requires a new judgment. |
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed: Play now resumes a paused loop from its cycle count, and a spent limit resets only its own counter, so a pause at 7 of 24 comes back at 7 of 24. No runaway path: only the dashboard route sends fresh_run, and the timer's cap check matches cap_reached. Tests were red first. Nits: firing.py still writes stop reasons as literal strings rather than the new constants; a cap-stopped loop with little time left gets only seconds after Play, though the copy promises a fresh budget.
Problem / Motivation
Goal: Resume a manually paused goal loop from the cycle it stopped at, instead of restarting its cycle count and clock.
Since #16030, pressing Play on a paused goal loop resets its cycle count and runtime clock, so a loop paused at cycle 7 of 24 comes back as cycle 1 of 24 and the popover reads "Goal active (cycle 1)". That reset was meant for a loop that ran out of budget, where Play would otherwise be a dead press. For a loop a person paused, it throws away where the loop was. This PR keeps the reset for the cycle-limit and time-limit endings only, and resumes every other paused loop from its breakpoint.
Why it matters
Max cycles is a lifetime limit a person typed. A pause should not quietly turn it into a fresh allowance, and the cycle readout after Play should match what actually ran.
Not a goal
What changed (motivation → approach → change)
Symptom: Play on a loop paused by hand at cycle 7 of 24 revived it at cycle 1 of 24. Root cause: the dashboard
PATCH /api/autonudge/{loop_id}route (src/kiro_crew/dashboard/handlers/autonudge.py) passesfresh_run=Trueon every press, and_update_unserializedinsrc/kiro_crew/autonudge_service/mutations.pyappliedcycle_count = 0andcreated_ts = time.time()on any revival carrying that flag. The reset exists for a spent bound, where Play would otherwise be re-stopped on its first tick; a pause with allowance left spent nothing.Change:
src/kiro_crew/autonudge_service/model.pynames the two budget endings asCYCLE_CAP_REASONandRUNTIME_BUDGET_REASON(together_BUDGET_EXHAUSTED_REASONS, from which_TERMINAL_BOUND_REASONSis built) and adds two type-safe predicates,cap_reachedandbudget_elapsed, the timer's two pre-fire checks read through_positive_numberbecause the store is agent-writable. The revival branch inmutations.pynow resets each counter on its own, underfresh_runonly:cycle_countis zeroed when the cycle cap is spent (the loop stopped oncycle_cap, orcycle_count >= max_cycleswith a non-zero cap as the bounds stand after the same update);created_tsis re-anchored when the time budget is spent (it stopped onruntime_budget, or the clock has run a non-zero budget out by the press). The at-the-press readings exist because the wall clock keeps running through a pause, so a hand-paused loop whose budget elapsed, or paused at exactly its cap, gets the same one-press resume instead of a re-stop on the first press; no time-spent-paused field is added. The other counter is kept: a loop paused by hand at 7 of 24 with an hour of budget and resumed the next morning comes back at 7 of 24 on a fresh clock (rowsbudget-elapsed-during-pause,paused-at-cap,both-spent). The stop reason is read from the pre-write snapshot since the revival clears the field; a non-string reason matches neither bound. Because a resume now preserves the counters,_loadinsrc/kiro_crew/autonudge.pyrepairs a malformedcycle_countorcreated_tsat the store boundary with the_repair_numberidiom already used foridle_secsand the start-failure streak;max_cyclesandmax_runtime_secsare left as stored, because repairing a malformed limit to 0 would quietly remove it. The facade re-exports the two reason constants for the tests. A loop paused by hand (manual), stopped by the agent (autonudge_stop), stood down on an unanswered approval (approval_stalled), or whose last cycle could not run (structural_terminal,session_start_failures) keeps both counters while cycles and time remain. Agentmonitor_updatebound raises and the apps' reconciler re-arms pass nofresh_runand are unchanged. Theupdate()docstring, themax_runtime_secsfield comment, the route comment and theauthorize_and_update_nudgedocstring insrc/kiro_crew/autonudge_authz.pystate the rule.Prose: the owning spec
docs/system-specs/modules/learn-cron-dashboard.md(AutoNudge paragraph), the RFCdocs/request-for-change/rfc-goal-popover-pause-play-controls.md(title, summary, resume section, compatibility, alternatives: the coupled reset is recorded as rejected) and two comments inwebsite/src/components/AutoNudgePopover.tsxnow state the per-bound rule. No user-facing string changes:paused_cycle_cap/paused_runtime_budgetstill say "Play resumes it with a fresh budget", which stays true.Backwards compatibility
Compatible: no route, field or key changes. The only behaviour change is that the dashboard route's revival now resets only the counter behind a spent bound and keeps the rest, which for a pause with allowance left is what every revival did before #16030.
Removes nothing: the fresh-budget reset still applies to every spent bound; the change narrows what it resets, hides no path and deletes no record.
Tests
test/test_autonudge.py::test_the_users_resume_resets_only_the_counter_behind_a_spent_bound(parametrized, 12 rows): a loop armed 600 s ago is deactivated with each stop reason, then revived throughauthorize_and_update_nudge(active=True, fresh_run=True). The five non-budget reasons with cycles and time left keep both counters (the manual row carries a 3600 s budget to pin "budget left, breakpoint kept");cycle_capzeroes the count and keeps the clock;runtime_budgetre-anchors the clock and keeps the count; a manual pause at exactly the cap (24 of 24) zeroes the count only; a manual pause whose 300 s budget elapsed while paused re-anchors the clock only; both spent resets both; an agent-written row whose reason is a list, and one whose cap and budget are strings, reset nothing instead of raising. Red first on unmodifiedorigin/main(9eb318e): the five non-budget rows failed withAssertionError: assert (0 == 7)while the two budget rows passed, which is the reported symptom.test_revival_runs_a_fresh_budget_and_a_running_save_keeps_the_old_oneandtest_a_bare_revival_keeps_the_count_so_a_reconciler_cannot_mint_a_fresh_allowancestill pass, pinning the one-press resume for a cap- and a budget-stopped loop and the no-reset rule for a bare revival.test/test_autonudge_start_failures.py::test_a_malformed_persisted_counter_is_normalised_at_load(the existing streak table, now also overcycle_countandcreated_ts): a string,null, negative, fractional,NaNor oversized value stored in any of them loads as a finite non-negative number and the timer's first wake does not raise.Manual verification
N/A — unit coverage sufficient: the fix is one condition in the service's revival branch, exercised through the same chokepoint the dashboard route calls; the frontend change is comments only, with
npm run buildand the popover's vitest spec (70 tests) green.Screenshots / video
Why no screenshot: the only frontend change is two code comments in
website/src/components/AutoNudgePopover.tsx; no rendered string or markup changes.Related Issues
Follow-up to #16030.
Pattern harvest
Not generalizable: a single opt-in flag applied without the stop-reason qualifier it was documented to depend on; the reason set now lives beside the flag's consumer, so a second site cannot drift from it.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)