Skip to content

feat(issue-radar): wake an idle crew only when claimable work or capacity grew - #25435

Open
oliviergaumond wants to merge 1 commit into
kirodotdev:mainfrom
oliviergaumond:feat/crew-pickup-due
Open

oliviergaumond wants to merge 1 commit into
kirodotdev:mainfrom
oliviergaumond:feat/crew-pickup-due

Conversation

@oliviergaumond

@oliviergaumond oliviergaumond commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

One commit on the latest main, now that #22123 has merged. Review this commit.

Problem / Motivation

Goal: an idle Issue Radar crew spends no model turn unless something it could act on, claimable work or free capacity, has grown.

An Issue Radar crew arms an AutoNudge loop that fires a full model turn every 300 s whether or not anything changed. In #20552 a crew with no actionable work burned about 200 credits over 3.2 h on 38 no-op turns. #22123 moves most wakes onto the watcher (new in-scope issues, @mentions) and keeps the idle timer as a fallback. One case still needs that fallback: #22123 consumes a scope-label or new-issue signal on first sight, so an issue that appears while the crew is at max_open never wakes it once a slot frees. Only the next idle turn finds it, so the paid 300 s turn stays.

Why it matters

Every crew pays roughly 288 turns a day for nothing while its repo is quiet, and per-turn cost grows with the conversation. That makes crews too expensive to leave running unattended, which is what they are for.

Not a goal

What changed (motivation → approach → change)

The base design already makes the watcher the crew's clock and AutoNudge the backstop "only when the watcher has nothing and the crew stalled" (docs/request-for-change/rfc-issue-radar-crews.md, status partial, Mental model table and §4). This change makes the code match that.

  • Approach. Gating the AutoNudge tick cannot make a crew free: a crew loop has no probe, and even a probe-gated loop fires after 10 quiet ticks. So the decision lives in the watcher, which already reads forge state without a model.
  • Pickup-due wake (crew_runtime_pickup.py, from detect_new_work). Per live crew it keeps the claimable numbers, free slots and open item numbers in crew-wake-checks.json, and wakes a crew with room when a candidate is new or its slots or open items changed (a turn takes one issue). A turn that takes nothing commits what it saw. The pickup reason rides its turn in crew-wake-inflight.json like a mention ask, so a turn that ends before the model reads it (permit timeout, cancel, restart) hands it back and the crew is woken again; an arrival turn that commits pickup names it too. It runs whatever crew_wake_on_new_work says: that setting gates feat(issue-radar): the watcher wakes crews on new work and @mentions #22123's arrival wakes, while pickup is what wakes a crew once its idle clock is a day, so the open-issues page is read for every repo with a live crew.
  • Idle gap without a setting. crew_runtime_session.py: 300 s (ACTIVE_IDLE_SECS) while an item is acting, 86400 s (DEFAULT_IDLE_SECS) otherwise. The watchdog retimes a loop only while its interval is the one the app last wrote (crew_loop_gaps.py), with a precondition re-checked under the service lock, so an interval set through PATCH /api/autonudge/{loop_id} is kept, even 300 or 86400. The crew editor's read-only idle wake shows 86400 and its line names both gaps; the crew_wake_on_new_work hint says pickup still runs with the switch off (all 12 catalogs in website/src/i18n/locales/ plus the pseudolocale).
  • An item signal is held until the crew steps on the item (new crew_runtime_signal_hold.py, from sweep_repo). A started turn may handle another item or fail partway, so a signalled item's mark keeps its old fingerprint with the new one as pending, written before the wake. It commits only once a turn carrying it started and the item's ledger shows a step after that start; until then the signal is raised again at the phase's recheck cadence. Bound: at most SIGNAL_TURNS (2) started turns without a step, and only a new signal restarts the count. A turn that stepped on another item it carried is refunded (credit_turn), and the bound waits for a charged turn still running. Each turn is stamped right before its dispatch (dispatched_at), so a step the previous turn wrote meanwhile does not count. Item-signal reasons ride crew-wake-inflight.json: a turn handing one back unread is refunded (return_turns), and one still carried is not raised again.
  • Resume. A paused crew keeps no signal marks, so watchdog_cycle wakes a resumed crew with open items once, unless its STOP file halted the loop.
  • Brief. crew_brief.md explains the pickup-due wake reason.

Backwards compatibility

Compatible: the pickup section of crew-wake-checks.json and the pending field of a crew-signals.json mark are additive, and a missing or malformed one reads as absent; loops armed at 300 s are moved by the existing watchdog pass, and a loop on any other interval keeps it.

Removes nothing: no setting, field, key, record or capability is taken away; the idle default changes for crews with nothing acting.

Tests

test/test_issue_radar_crew_pickup.py (new, 60 tests):

  • Pickup: wakes for room plus claimable work, a freed slot, room regained, a new candidate, a claim with room left (then not again for the same choice), a claim that offsets a closed item, a reopened issue, and with crew_wake_on_new_work off; no wake at max_open, for candidates leaving the page, after a failed forge read, over a quiet day, for a crew with an acting item, or on an item-signal turn. A turn that never reached the model (a queued turn whose permit wait times out in the real _capped_run_chat, a restart, an arrival turn) gets its pickup back, and a same-count pickup cannot take over one still queued.
  • Held signals: a turn that advances one of two items gets the other raised again; a started turn that records nothing gets its signal raised again; a step by the turn already running does not count; a turn that advanced another carried item is not charged (also when it is still running at the next sweep), and one that advanced two settles both; the bound waits for a charged turn still running, and a turn that ends with no step still counts; a step the previous turn writes during the wake does not handle the signal; the bound stops a signal no turn steps on, a non-signal field does not restart it, new movement does, and a dropped wake does not count, and neither does a turn that never reached the model; a signal whose turn still waits for the model is not raised again; a first look at a waiting item whose CI already finished is raised and held, while running CI and an acting item seed silently.
  • Idle gap: the day-long default, 300 s mid-item, the watchdog moving a loop both ways, keeping an operator interval, its lock precondition, an unreadable ledger answering 300 s, and a stood-down loop left alone; a resumed or relaunched crew with open items is woken once, one with none or with a STOP file is not; an operator's 300 or 86400 is kept, a retimed loop is retimed again from its record, and a retime the service did not apply is tried again.

Updated: test/test_issue_radar_deps.py's fires-once case now records the crew's step before asserting no re-fire; #22123's opt-in test in test/test_issue_radar_crew_runtime_wake.py asserts no arrival wake while pickup still runs; test/test_issue_radar_crew_close_race.py pins crew_loop_gap; arrival-turn expectations in test_issue_radar_crew_runtime_wake.py and test_issue_radar_crew_runtime_sweep.py now include the pickup reason, and the ask tests' setup consumes its first-look pickup turn; IssueRadarCrewEditor.test.tsx now reads both DEFAULT_IDLE_SECS and ACTIVE_IDLE_SECS from the backend source, so either side drifting fails it. .github/black-baseline.txt drops test/test_issue_radar_crew_runtime.py, which is now black-clean.

Red before: the reviewer's two cases (test_a_turn_that_advances_one_of_two_items_gets_the_other_raised_again, test_a_started_turn_that_records_nothing_gets_its_signal_raised_again) fail on 05edee9c22. Each later fix's test fails on the head before it, including the three never-reached-the-model cases on 945efce0f0. Determinism (testing-conventions D12): 20 runs at -n0, 10 at -n 4, one shuffled order (187 tests), all green.

Gates on the head: every test/test_issue_radar_*.py, test/test_slot_close_nudge_race.py and test/test_facade_mirror_guards.py and test/test_gateway_notice_sites.py (2261 passed); src/apps/issue-radar/ and src/i18n/ vitest (2902 passed), tsc, i18n:check and eslint; black, isort, flake8, mypy, comment-history, brand, file-line-cap, harness parity and the flake ratchet exit 0. Semgrep was not run locally (not installed); the three tempfile.TemporaryDirectory() roots CI's test-radar-store-root-self-removed flagged are now tmp_path. scripts/local-gate.py's first backend batch had 47 failures (file explorer, sandbox, real codex), and the same node IDs fail on clean origin/main on this host.

Manual verification

N/A — unit coverage sufficient for the backend: the tests drive the real sweep (detect_new_work, sweep_repo), launch_crew and watchdog_cycle with a fake forge client and AutoNudge service.

Screenshots / video

The crew editor's read-only "Idle wake" field now shows the backstop and names both gaps (CrewEditor.tsx, backstop_fixed):

Idle wake field, dark

Idle wake field, light

Captured with website/scripts/capture-crew-editor-idle-wake.mjs against the website/capture/crew-editor-idle-wake harness (the real dialog and provider, network stubbed); the script asserts the field reads 86400 and the line names 300 and 86400 before shooting. The settings hint for crew_wake_on_new_work (wake_new_work_hint) now says that with the switch off a crew still wakes when it has a free slot and something new to pick up; that is a text-only change to an existing line.

Related Issues

Part of #20552

App repo: KiroCrewCaptain/kirocrew-app-issue-radar#4

Builds on #22123 (merged).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable): crew_brief.md
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 28, 2026
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 6, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Hi @oliviergaumond, a user asked in Slack today to prioritize #20552 (T1). This PR is the claimed fix. It is still a draft, so it can't be reviewed or merged yet.

When it's ready, please mark it "Ready for review", rebased on the latest main with 1–2 commits, and I'll review it on that head. #22123 by @migh000 targets the same issue. Please say here if one of the two should be closed so reviews don't split.

AI-assisted, sent by CommunityCrew

@oliviergaumond
oliviergaumond marked this pull request as ready for review November 7, 2026 12:01
@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Thanks @bolichen97. Neither should close: they're complementary. #22123 is the wake-signal groundwork, as your review there says, and #25435 is the idle-tick gate for #20552 defect 1, stacked on it.

#25435 is now marked ready and rebased on the latest main (bab2387339) as two commits:

  1. 6b0bea547a: feat(issue-radar): the watcher wakes crews on new work and @mentions #22123's c00d5af774, unchanged (same diff, migh000's authorship kept).
  2. 05edee9c22: ours. Please review this one (git diff HEAD~1 HEAD).

When #22123 merges, I'll drop its commit so #25435 is a single commit.

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

Requesting changes on 05edee9. Thanks for marking it ready and rebasing, @oliviergaumond. I reviewed only the last commit, as the body asks. The first commit is identical to #22123's 180f836. The idle-tick gate is the right fix for #20552 defect 1. The watchdog's precondition re-check under the AutoNudge lock looks correct, and operator-set intervals are left alone. The 3 touched test files pass on this head (94 passed). One thing blocks it:

A signalled item that a started turn does not handle can now wait up to 24 h.

  • sweep_repo in crew_runtime.py writes each signalled item's new fingerprint before the wake (around line 1661). The new restore puts the old fingerprint back only when the wake started no turn (not results.get(cid)).
  • "Started" means the turn was dispatched, not that the item was handled. The brief's per-turn protocol advances only the single most advanceable item per turn.
  • Example: in one sweep, item A becomes mergeable and item B's requester replies. One wake carries both reasons. The turn handles A and stops. B's signal is already marked as handled. If no item is in an acting phase, the loop stays at DEFAULT_IDLE_SECS = 86400, so B waits for the daily backstop. Before this commit, the 300 s tick picked it up within minutes.
  • A started turn that fails partway (usage limit, ACP error, turn ceiling, restart) loses its signals the same way.
  • Fix, either of:
    1. Keep the pre-wake mark for each signalled item with a signalled_at time, and commit the new fingerprint only once that item's ledger record is newer than signalled_at. Otherwise raise the signal again.
    2. Smaller: have crew_loop_gap return ACTIVE_IDLE_SECS while any open item has a signal newer than its last ledger step.
  • Tests: two items signal in one sweep and the turn records progress on only one, so the other is raised again next sweep; and a started turn that records nothing gets its signal raised again.

Non-blocking:

  • If _wake_and_settle raises or is cancelled at shutdown, the restore never runs. Writing once after the wake, in try/finally, closes that window.
  • The daily backstop still fires one full turn every 86400 s, so "Part of #20552" is right and the issue should stay open. Defect 2 (usage-limit brake and stand-down) is still open too: watcher-dispatched turns don't count toward stand-down, and there is no usage-limit pause or notice. #21919 only stops a stood-down loop from being revived.
  • crew_runtime_pickup.py:119 counts free slots as max_open - len(set(issue numbers)), not the open_slot_count its docstring names.
  • Two branches have no test: crew_loop_gap's failed-ledger-read fallback (acting = True), and _retime_loop skipping a stood-down loop.

AI-assisted, sent by CommunityCrew

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of fb3162bdf2036b5eca5b0d8e11be86b11ac9a764 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the "Wake crews when new work appears" hint. The PR rewrites that hint, but neither committed screenshot shows the settings toggle it sits under.

Evidence gaps

  • The wake_new_work_hint copy in CrewProtocolSettings.tsx:469 now reads "Off: a crew still wakes when it has a free slot and something new to pick up; otherwise it waits for its idle timer." No image shows it: attachment-01.png and attachment-02.png show only the crew editor's "Idle wake" field. A dark and a light screenshot of the Issue Radar crew settings, showing that toggle and its new hint, would close this gap.

Notes

  • The "Idle wake" field and its line ("every 86400s otherwise") show a day as a raw number of seconds, so most users can't read the shipped default at a glance. Format it as a duration, e.g. "every 5 min while it works on an issue, once a day otherwise".
  • The backstop_fixed line says "works on an item", but the rest of the UI says "issue". Use "issue" in the en.manual.json string and the other catalogs.
  • The two "Idle wake" screenshots were not shown to a first-time reader, because this fork lane has no blind read. A maintainer who wants that read can push the branch to this repository.

[UX-REVIEWED] fb3162b

Description read

[DESCRIPTION-READ] 8582198ee61305799c97c2e4bda4a032183beb0323086769ea53c8191c189eb9

That sha256 names everything this verdict read: the PR description, plus the 5 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of fb3162bdf2036b5eca5b0d8e11be86b11ac9a764 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. The day-long default sits inside the shape the base RFC rfc-issue-radar-crews.md (status partial) already records: "Clock | the Issue Radar watcher" and "Backstop clock | AutoNudge, only when the watcher has nothing and the crew stalled".

Notes

  • Item 5 — oversized: about 370 lines of new state (pending, turns, last, credit_turn, return_turns, charge_turns) exist only because waiting-phase items lose the 300 s fallback ("a signalled item's mark keeps its old fingerprint with the new one as pending"). Subtraction: delete crew_runtime_signal_hold's pending, charge and refund bookkeeping, and have crew_loop_gap return ACTIVE_IDLE_SECS while any of the crew's items holds an uncommitted signal. That reuses the retime path this PR already adds.

What this change ships

Inventory (10 items) — 9 justified

Intent: stop an idle Issue Radar crew paying a model turn every 300 s when nothing it could act on has changed. This is an ADDITION that changes a default.

  1. A crew with nothing acting now waits a day between idle turns instead of 5 minutes — justified
  2. A crew with an item being worked on stays at 300 s, and the watchdog moves its loop between the two gaps — justified
  3. A new pickup-due wake when a crew has room and new claimable work, or a slot freed — justified
  4. The open-issues page is now read for every live crew, whatever the settings — justified
  5. An item's signal (CI, review, reply) is raised again until the crew records a step on that item, at most twice — oversized
  6. The first look at a waiting item now raises an outcome that already settled, instead of recording it silently — justified
  7. A resumed crew that has open items gets one wake — justified
  8. An interval the operator set through PATCH is kept, tracked in the new crew-loop-gaps.json — justified
  9. The crew editor shows 86400, its line names both gaps, and the hint text changes in 13 locales, with screenshot capture — justified
  10. The crew brief explains the pickup-due wake — justified

[FIRST-PRINCIPLES-REVIEWED] fb3162b

Description read

[DESCRIPTION-READ] b6089602b7a5d7f70a5f829170f03356d9b8e52932716a9cc60fc9d70eb4237d

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed fb3162bdf2036b5eca5b0d8e11be86b11ac9a764 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] fb3162b

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 8, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

@oliviergaumond, this PR has been ready for over 24 hours with a merge conflict and an open change request, so per the team SOP CommunityCrew is taking it over. We will open an in-repo PR from latest main that keeps your commit and authorship, adds a fix for the change request (signalled items a started turn does not handle), and links back here. If you push a fix here first, tell us and we will use yours instead.

AI-assisted, sent by CommunityCrew

@bolichen97

Copy link
Copy Markdown
Contributor

Update: this PR is stacked on #22123, so it waits on #22123 merging. Once #22123 is in, we will rebuild on latest main with your commit (credit kept) plus our fix for the change request, and link the PR here.

AI-assisted, sent by CommunityCrew

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 9, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Nov 9, 2026
@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Thanks @bolichen97. I've pushed the fix here myself, so CommunityCrew doesn't need to take this over. Head eb7193a3c2, on latest main, two commits: #22123's 6d15c642f6 unchanged, then ours.

Blocking finding: fixed (option 1). A signalled item keeps its old fingerprint, with the new one held as pending. The new one is committed only after a turn carrying the signal has started and the crew has recorded a step on that item. Until then the signal is raised again at the phase's recheck cadence. Bound: at most two started turns without a step; a dropped wake doesn't count, and only a new signal restarts it. Your two cases are test_a_turn_that_advances_one_of_two_items_gets_the_other_raised_again and test_a_started_turn_that_records_nothing_gets_its_signal_raised_again; both fail on 05edee9c22.

Non-blocking:

  • The held mark is written before the wake, so a sweep that is cancelled or shut down raises the signal again on the next sweep.
  • Pickup docstring corrected.
  • Both untested branches now have tests.
  • Part of #20552 stays.

From the rebase: #22123 now gates the open-issues read behind crew_wake_on_new_work (off by default). Pickup-due still reads that page whatever the switch says, because it's what wakes a crew with room now that the idle turn is a day. The switch's hint and the editor's "Idle wake" line say so (screenshots in the description).

CI: the backend and frontend failures were ours and are fixed. Coverage failed only because of those two. GPT 6.1 shows "verdict not published"; could a maintainer re-run it?

Ready for another look.

@oliviergaumond
oliviergaumond force-pushed the feat/crew-pickup-due branch 2 times, most recently from f3d0628 to d7af5d7 Compare November 10, 2026 14:53
@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Rebased onto 93511d9363 and fixed the red Backend Ratchets & Boundaries / Frontend Ratchets & i18n (both the line-cap gate). Now 24f0e6ea48:

  • Merged with main, crew_runtime.py came to 2,002 lines, over the 2,000-line cap. I moved the per-phase re-read cadence (RECHECK_SEC, _DEFAULT_RECHECK_SEC, _is_due) whole into crew_runtime_signal_hold.py, and the facade still serves those names. crew_runtime.py is now 1,970 lines; check_file_line_cap.py passes, and the facade-mirror guard passes with the manifest updated. No behaviour change.
  • Locally on the rebased head: the backend Issue Radar set (2,248), mypy, the frontend typecheck, i18n and vitest (2,932) pass.

The other red jobs on e7ab6f71d0 look like runner-image problems on ubuntu-26.04, not this change:

  • E2E, Render Benchmark and i18n Render Gate: Playwright does not support chromium on ubuntu26.04-x64.
  • test_terminal_handler_pty_integration.py: the image's systemd PROMPT_COMMAND hook.
  • test_codex_inner_sandbox_approval.py: the real codex adapter.

bolichen97
bolichen97 previously approved these changes Nov 16, 2026

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

Approving 24f0e6ea48: the line-cap red is fixed. crew_runtime.py is 1970 lines now, with the signal hold moved to crew_runtime_signal_hold.py, and the behaviour I approved earlier is unchanged. The 6 touched radar test files pass locally: 392 tests.

Heads-up so CI doesn't bounce this: main gained the Semgrep rule kirocrew.test-radar-store-root-self-removed (#37622). It rejects tempfile.TemporaryDirectory()/mkdtemp() in test/test_issue_radar*.py, because the radar store re-creates its root on read after cleanup. This PR touches two such files:

  • test/test_issue_radar_crew_pickup.py:85, :573, :849 (new setUp roots)
  • test/test_issue_radar_crew_runtime.py:230, :244, :264, :281, :419, :576, :612

The fix is mechanical and matches test_issue_radar_crew_runtime_wake.py and #37888: take the root from tmp_path, e.g. an autouse fixture method def _root(self, tmp_path): self.root = tmp_path in the unittest classes, and the tmp_path fixture for the with blocks. I approved the held fork CI for this head. Auto merge is on and lands it once SAST is green.

AI-assisted, sent by Bolin Review bot

@bolichen97
bolichen97 enabled auto-merge (squash) November 16, 2026 11:38
auto-merge was automatically disabled November 16, 2026 12:16

Head branch was pushed to by a user without write access

@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Fixed the upheld GPT 6.1 blocker (unconsumed dispatches exhaust the held-signal budget), now c335eb83b5:

  • Item-signal wake reasons now ride the same in-flight carry as asks and pickups (crew_wake_inflight), so the turn's consumption hook marks each one consumed or handed back.
  • A turn that hands its reason back (permit timeout, cancel, restart) has its charge refunded at the next sweep (crew_runtime_signal_hold.return_turns). The row is removed only after the refund is saved.
  • While a turn still carries the reason, the held signal is neither raised again nor committed (resolve_mark(..., waiting)). Once the model consumes it, the normal bound applies.
  • detect_new_work leaves those rows out of the mention queue and the settle step.
  • Shortcut: an item reason the in-flight file has no room for (per-crew cap) still rides the wake and is charged the old way.

Red first, against 24f0e6ea48: test_a_turn_that_never_reached_the_model_does_not_count_toward_the_bound and test_a_signal_whose_turn_waits_for_the_model_is_not_raised_again both failed. They pass now, and so do 10/10 repeat runs. The held-signal test helper now models the admission hook the way the real runner does.

Backend Issue Radar set: 2,250 passed. mypy (whole package), black, isort, flake8, comment-history, brand, line-cap and flake-ratchet gates pass.

bolichen97
bolichen97 previously approved these changes Nov 16, 2026

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

Approving c335eb83b5.

  • The GPT 6.1 blocker is fixed the right way: item-signal reasons now ride crew_wake_inflight beside asks and pickups. A turn that hands its reason back (permit timeout, cancel, restart) gets its charge refunded at the next sweep (return_turns → return_turn), and while a turn still carries the reason, resolve_mark(..., waiting=True) neither re-raises nor commits it. Both failure paths are safe: an unreadable in-flight file refunds nothing and holds nothing, and a failed settle_returned only costs one extra wake, never a lost one.
  • crew_runtime.py is 1990 lines, still under the cap. The 6 touched radar test files pass locally: 394 tests.

Still open from my last review: test/test_issue_radar_crew_pickup.py (3 roots) and test/test_issue_radar_crew_runtime.py (9) still use tempfile.TemporaryDirectory(), which the Semgrep rule kirocrew.test-radar-store-root-self-removed rejects. SAST will stay red until they take their root from tmp_path (see test_issue_radar_crew_runtime_wake.py for the pattern). I approved the held fork CI for this head. Auto merge is on.

AI-assisted, sent by Bolin Review bot

@bolichen97
bolichen97 enabled auto-merge (squash) November 16, 2026 12:38
@bolichen97

Copy link
Copy Markdown
Contributor

@oliviergaumond thanks for the held-signal fix in c335eb8; my approval stands. Three checks still block the merge:

  1. GPT 6.1 Review: the adjudication upheld F1 (MEDIUM). Resuming a paused crew whose only slot holds an awaiting-merge item can leave the merged item unresolved until the daily backstop (crew_runtime_session.py:86, with sweep_repo evicting the marks and resolve_mark seeding silently). A reconciliation turn on resume when the crew has open items would close it. F2 was rated LOW and not upheld.
  2. PR Hygiene: this changes the wheel copy of the adopted issue-radar app (crew_runtime.py, crew_runtime_pickup.py, crew_brief.md and 5 more). Land it in KiroCrewCaptain/kirocrew-app-issue-radar first, then add a line App repo: KiroCrewCaptain/kirocrew-app-issue-radar#<PR> (or @<commit>) to the PR body. No push needed for that one.
  3. SAST (Semgrep): rule kirocrew.test-radar-store-root-self-removed still fires on tempfile.TemporaryDirectory in test/test_issue_radar_crew_pickup.py and test/test_issue_radar_crew_runtime.py. An autouse fixture that sets self.root = tmp_path fixes it (see test(issue-radar): take the auto-merge test's store root from tmp_path #37888).

Backend Lint was cancelled, not failed; it will rerun on your next push.

AI-assisted, sent by Bolin Review bot

@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Now dfd0d4181a:

  • Adopted app. Issue Radar is pinned for adoption (feat(apps): pin issue-radar and auto-improvement for adoption #36446), so this change is ported to the app repo as KiroCrewCaptain/kirocrew-app-issue-radar#4, merged three-way with only imports differing. Its full suite passes there (3,743 backend; UI typecheck, 1,678 tests and a reproducible ui/dist). The body names it in an App repo: line.
  • GPT 6.1, resume defers reconciliation (upheld). A paused crew keeps no signal marks, so a PR that merged while it was paused is seeded silently on resume. watchdog_cycle now sends a crew with open items one wake (RESUMED_REASON) when it switches the crew's loop back on, or relaunches it, through the existing wake_crew path. Red first: test_resuming_a_crew_with_open_items_wakes_it_once and test_relaunching_a_crew_with_open_items_wakes_it_once failed on c335eb83b5. test_resuming_a_crew_with_no_open_items_leaves_it_to_its_loop pins the no-wake case.
  • SAST test-radar-store-root-self-removed. The three tempfile.TemporaryDirectory() roots in test/test_issue_radar_crew_pickup.py are now an autouse tmp_path fixture, as in test_issue_radar_crew_runtime_wake.py.
  • The second GPT finding (an operator interval of exactly 300 or 86400 s) was downgraded and is unchanged.

Backend Issue Radar set: 2,253 passed. mypy (whole package), black, isort, flake8, line cap (crew_runtime.py 1,992 lines), comment-history, brand and flake ratchet pass.

bolichen97
bolichen97 previously approved these changes Nov 16, 2026

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

Re-approving dfd0d41. Thanks @oliviergaumond, two of the three blockers are fixed:

  • GPT F1: watchdog_cycle now marks a crew resumed when it relaunches the slot or re-activates a paused loop, and wakes it once with RESUMED_REASON when _has_open_items says it holds open work. An unreadable ledger answers yes, which is the right side to fail on. The three new tests cover resume with items, resume without items, and relaunch.
  • PR Hygiene: the body now names KiroCrewCaptain/kirocrew-app-issue-radar#4.
  • test_issue_radar_crew_pickup.py now uses the tmp_path autouse fixture.

Locally on the head, test_issue_radar_crew_pickup.py and test_issue_radar_crew_runtime.py pass (133 passed).

Still open: test/test_issue_radar_crew_runtime.py has 9 tempfile.TemporaryDirectory uses left, which the Semgrep rule kirocrew.test-radar-store-root-self-removed covers (test/test_issue_radar*.py). The same autouse fixture fixes it. I approved the 33 held fork CI runs; auto merge is on.

AI-assisted, sent by Bolin Review bot

@bolichen97
bolichen97 enabled auto-merge (squash) November 16, 2026 14:08
oliviergaumond added a commit to oliviergaumond/kirocrew-app-issue-radar that referenced this pull request Nov 16, 2026
Port of kirodotdev/KiroCrew#25435 (core head dfd0d4181a), merged
three-way onto this tree, so only the imports differ.

An idle crew's AutoNudge loop is now a day-long backstop instead of a
300 s model turn; a crew with an acting item keeps 300 s. The watcher
wakes a crew with room when a slot frees or a claimable issue appears
(crew_runtime_pickup.py). An item signal stays raised until the crew
records a step on that item, bounded at two turns that reached the
model (crew_runtime_signal_hold.py); item reasons ride the in-flight
carry so a turn that never reached the model hands its signal back.
A resumed crew with open items gets one wake. The crew editor's two
hint strings change in every catalog, and ui/dist is rebuilt.
auto-merge was automatically disabled November 16, 2026 14:42

Head branch was pushed to by a user without write access

@oliviergaumond

Copy link
Copy Markdown
Contributor Author

Now a720bd1f31 (app port updated to match: KiroCrewCaptain/kirocrew-app-issue-radar#4 at 9b2e0cbf55, 3,747 passed):

  • GPT 6.1, operator intervals overwritten (upheld). As the adjudication suggested, the app now records the interval it last wrote on each crew's loop (crew_loop_gaps.py, crew-loop-gaps.json, keyed by crew and loop id). launch_crew records the armed gap, and _retime_loop moves a loop only while its live interval still equals that record. An operator's 300 or 86400 is therefore kept. A loop armed before the record existed is still treated as the app's when it sits on 300 or 86400, so existing 300 s loops still move to the backstop. Red first on dfd0d4181a: test_an_operator_pin_at_the_old_five_minute_gap_is_kept and test_an_operator_pin_at_the_day_gap_is_kept_while_an_item_acts. test_a_retimed_loop_is_retimed_again_from_its_record pins the normal path.
  • Opus 5.5, the resume wake defeats the STOP file. The wake now fires only when the loop is actually active after the pass, and only when the crew's STOP sentinel is absent (_resume_wakes). Red first on dfd0d4181a: test_a_crew_halted_by_its_stop_file_is_not_woken, with both a service that declines the revival and one that accepts it.

Backend Issue Radar set: 2,257 passed. mypy (whole package), black, isort, flake8, line cap (crew_runtime.py 1,997), comment-history, brand and flake ratchet pass. The new tests pass 8/8 repeat runs.

bolichen97
bolichen97 previously approved these changes Nov 16, 2026

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

Re-approving a720bd1. Both new fixes look right:

  • crew_loop_gaps.py records the interval the app last wrote per crew and loop id, and _retime_loop moves a loop only while its live interval still equals that record (or, with no record, sits on one of the two gaps). When the precondition refuses, the new value is still recorded, so the next pass sees the operator's interval differ from the record and keeps it.
  • _resume_wakes wakes a resumed crew only when its loop is active after the pass and no STOP sentinel exists, so an operator's STOP file still wins.

Still open from my last note: test/test_issue_radar_crew_runtime.py keeps 9 tempfile.TemporaryDirectory uses, which the Semgrep rule kirocrew.test-radar-store-root-self-removed flags. Auto merge is on.

AI-assisted, sent by Bolin Review bot

@bolichen97
bolichen97 enabled auto-merge (squash) November 16, 2026 15:07
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 16, 2026
bolichen97
bolichen97 previously approved these changes Nov 16, 2026

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

Re-approving 588fae3. The only change since a720bd1 moves the STOP-sentinel exists() check in _resume_wakes onto a thread, so the watchdog no longer touches the disk on the event loop. Held fork CI runs approved; auto merge is on.

Reminder: test/test_issue_radar_crew_runtime.py still has 9 tempfile.TemporaryDirectory uses for the Semgrep rule kirocrew.test-radar-store-root-self-removed.

AI-assisted, sent by Bolin Review bot

…city grew

The new-work signals fire once, on first sight, so an issue that arrived
while a crew was at max_open was consumed, and nothing woke the crew when
a slot freed. Only the 300 s idle turn covered that, one model turn every
five minutes for a crew with nothing to do.

The sweep now raises pickup-due per live crew from the open-issues page.
It stores the last observed state per crew (sorted claimable numbers,
free slots, the numbers of its open items) in crew-wake-checks.json and
wakes when the crew has something new to decide: a claimable number not
in that state, a different number of free slots, or a different set of
open items. A turn takes one issue, so with room left the next pick is
due. Candidates only leaving is written at once without a wake, and a
turn that takes nothing commits what it saw, so the same choice never
wakes the crew twice. The state commits only after wake_crew reports a
started turn, and the pickup reason rides that turn in
crew-wake-inflight.json like a mention ask: a turn that ends before the
model reads its prompt (permit timeout, cancel, gateway restart) hands
it back, which clears the crew's state so the same sweep wakes it again.
A failed open-issues read wakes nobody and writes nothing.
First observation counts as growth, so a freshly launched or upgraded
crew gets its selection turn.

Pickup-due runs whatever crew_wake_on_new_work says: that setting gates
only the scope-label and new-issue wakes, while pickup is what wakes a
crew with room once its idle clock is the day-long backstop. So the
open-issues page is read for every repo with a live crew. Candidates
exclude only the crew's open items, so an issue it resolved and someone
reopened counts. A crew with an acting item is not read: the brief has it
advance that item first. When another signal wakes the crew in the same
sweep, pickup-due commits only with a selection turn (scope-label,
new-issue or human-answered), whose reasons then name it too.

The idle clock now depends on the crew's items. A crew with an item in an
acting phase keeps the 300 s gap; any other crew gets a day-long
backstop. launch_crew arms the right interval, and the watchdog moves a
loop between those two values when the phase changes, with a
precondition the service re-checks under its lock. A loop on any other
interval was set through PATCH /api/autonudge/{loop_id} and is left
alone. The crew editor's read-only idle wake shows the backstop, and its
line names both gaps. The crew_wake_on_new_work hint says a crew still
wakes for a free slot and something new to pick up when it is off.

With the idle turn a day away, it can no longer be what picks up an item
signal (CI, review, reply, conflict, merge, unblocked) that a started
turn did not handle: the brief advances one item per turn, and a turn can
fail partway. So a signalled item's mark keeps its old fingerprint, with
the new one beside it as pending, written before the wake, and the new
one is committed only once a turn carrying the signal has started and the
item's ledger shows a step newer than that start (its last_progress_at, or
any event on it), so a step by a turn that never saw the signal does not
count. Until then the signal is raised again at the item's phase recheck
cadence. A pending signal is carried to at most two started turns that
record no step on its item; then it is committed, so a crew that looked
and did nothing is not paid for again. A wake that started no turn does
not count, and only a new signal on the item restarts the count: a field
no signal reads moving under it does not.

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

Re-approving fb3162b. Both AI findings from 588fae3 are handled:

  • _retime_loop now records the gap only when svc.update returned a loop with that interval. A None from an operator's precondition, a pause quiescing the loop, or a shutdown leaves the record as it was, so an operator's value is kept and anything else retries next pass. A legacy loop already on the right gap is recorded once.
  • resolve_mark compares a first look at a waiting item with first_look_basis, so an outcome that settled before the watcher first read the item (CI finished, a verdict, a conflict, a merge) still reaches the crew instead of waiting for the day-long backstop. Running CI, comment counts and blockers still seed silently.

Held fork CI runs approved; auto merge is on. Still open: the 9 tempfile.TemporaryDirectory uses in test/test_issue_radar_crew_runtime.py for the Semgrep radar rule.

AI-assisted, sent by Bolin Review bot

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants