Repository navigation
feat(issue-radar): the watcher wakes crews on new work and @mentions - #22123
Conversation
3080bb2 to
f14f797
Compare
f14f797 to
023b57c
Compare
023b57c to
7435a3f
Compare
7435a3f to
748d5eb
Compare
0a0e040 to
9077681
Compare
|
@migh000 I rebased this stack (#21541 + this PR) onto current Rebased commits (your authorship kept, content unchanged), on
Conflicts. Only one, in #21541's commit: the golden tables in Tests on that base: To take it: Follow-up. #25435 (draft) is stacked on top of this for #20552. It closes one gap here: a scope-label or new-issue signal is consumed on first sight, so an issue that appears while the crew is at |
9077681 to
b3a6480
Compare
|
[operator: bolichen97] A maintainer rebased this onto main and fixed the issues the local reviews found. The branch is still #21541's current head plus this PR's one commit (b3a6480). The author is unchanged and the PR stays a draft. What changed in this PR's commit:
|
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on 6a8c769. Thanks for marking it ready, @migh000. The wake logic itself looks sound: 248 tests in the four issue-radar runtime/wake test files pass on this head, failed forge reads leave state alone, and no comment text reaches a prompt or command. Two things block it:
-
The head is a merge commit. 6a8c769 ("Merge branch 'main' into crew-wake-signals") has parents c00d5af and 4312d22, and the repo does not allow merge commits.
git merge-treeagainst current main shows no conflict, so rebasing onto the latest main and force-pushing with lease should leave c00d5af as the one commit. -
This PR alone does not fix #20552.
launch_crewincrew_runtime_session.pystill arms the loop withidle_secs=DEFAULT_IDLE_SECS(300) andmax_cycles=0, so an idle crew still spends a turn every 5 minutes. #20552's first acceptance criterion asks for zero turns over 24h with no work. Your own "Not a goal" section lists "Removing the idle timer". Please describe this PR as the groundwork for #20552, not its fix, and leave the idle-tick gate to #25435 or a follow-up.
Non-blocking, worth a look:
- With
crew_answer_mentionson,crew_runtime.py:1313drops only the crew's own login and[bot]accounts, so any GitHub user can @mention the account and cause billed turns, up to 20 pending asks per crew. Consider filtering onauthor_association(collaborator or member). - In
crew_mention_scan.py:106-110, a tie resume re-reads pages 1..start-1 on every sweep, andstartgrows each time, which adds rate-limit pressure. - Two failure paths have no test: GitHub
list_repo_comments_sinceraising (rate limit), and_read_open_issuesreturningNone.
AI-assisted, sent by CommunityCrew
|
Thanks @bolichen97. Both blockers are addressed on 180f836.
On the non-blocking points:
|
|
@bolichen97 the rebased head 180f836 needs a maintainer to approve its workflow runs: every fork lane (CI, Fast Gate, the review lanes) is waiting in |
bolichen97
left a comment
There was a problem hiding this comment.
Approving on 180f836. Both blockers from my last review are fixed:
- The branch is one commit again.
git range-diffshows 180f836 is identical to c00d5af, the head I reviewed, now on main bab2387. - The description now calls this groundwork for #20552, not its fix, and names #25435 as the idle-tick gate.
The non-blocking notes from that review still stand, but none of them blocks merge.
My approval doesn't count toward merge, because bolichen97 pushed to this branch earlier. @iamwhatever, could you give it the counting approval when you have a moment? The fork CI and AI review lanes are still waiting for maintainer approval of the workflow runs. Merge waits for those to go green.
AI-assisted, sent by CommunityCrew
|
|
@bolichen97 180f836 is review-ready: PR Readiness passed ("Eligible automated validation passed for this revision"), all 92 checks are green, and the one GPT finding was downgraded on adjudication and answered above. GitHub still shows the review requirement as unmet, so it may need a code-owner approval on top of yours. I can't enable auto-merge from a fork; could you (or a code owner) approve if needed and merge? |
|
HOLD at 180f836: this adds a new way for outside accounts to start an agent turn, which is reserved for a human. Three deferred follow-ups also need issues. The wake logic looks careful. Signals seed silently, a signal is committed only after a turn starts, and unreadable state raises instead of being overwritten. Every check is green, and the GPT finding about GitLab threads with more than 250 notes is fairly rebutted: the setting is off by default and the skip is logged.
First Principles and Opus size notes (consumption tracking, poll re-read, To clear: a maintainer accepts the mention-wake admission rule, and the three follow-up issues are linked. — crew-pr-reviewer (r149) |
|
Thanks @iamwhatever. The three follow-ups now have issues, linked under Related Issues in the description:
On the admission rule: mention wakes stay off unless an operator turns on |
|
This changes behaviour users already rely on, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. To propose a design, follow the request-for-change process in CONTRIBUTING.md (docs/request-for-change/). Review result on this head: no blocking defect found. The scope-label and new-issue wakes are on by default for every existing crew, so they change when crews take turns. That is the part that needs a sign-off. The open HOLD on this PR also still needs an answer. A maintainer must accept or narrow the mention admission rule, and the three follow-up issues need links. The new signals are committed only after a turn starts, and unreadable state files fail closed. Both are done well. Optional:
|
|
Rebased: main moved in The same push answers the design sign-off note: the scope-label and new-issue wakes are now opt-in, like mention wakes. A new repo crew setting Tests: @bolichen97 this dismisses your approval and the fork runs need approving again, sorry for the extra round. |
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 5e08621 after the rebase. The new crew_wake_on_new_work setting (default false) is gated correctly: off clears the scope and new-issue marks, turning it on later seeds fresh with no replay, and mention wakes are unchanged. The 4 touched test files pass locally: 249 passed.
Non-blocking:
crew_ledger_spec.md"Per-repo settings" table lists neithercrew_answer_mentionsnorcrew_wake_on_new_work. Two rows (default false, API-only for now) would close that.- A mentions-on / new-work-off test, and an on → off → on assertion, would pin the behaviour the code already has.
- The "Not a goal" bullet could name
crew_wake_on_new_worktoo.
This approval does not count toward merge. @iamwhatever, could you give the counting review on this head?
AI-assisted, sent by CommunityCrew
|
New head 70786ab (rebased on main 285971e): both opt-in wake settings now have a switch in the repo's Protocol settings card, "Wake crews when new work appears" and "Answer @mentions", each with a hint, in all catalogs. Screenshots (dark and light) are under Frontend tests cover the switches (off unless saved |
bolichen97
left a comment
There was a problem hiding this comment.
Re-approving on 70786ab. The two new switches in Protocol settings ("Wake crews when new work appears", "Answer @mentions") send a one-key patch through the existing PUT /crews/settings path, show ON only for a saved true, and stay disabled while a write is in flight. The backend is unchanged from 5e08621. Committed temp-screenshots/ evidence follows the PR template route for fork authors.
Local on this head: vitest (3 issue-radar settings files) 61 passed; the 4 issue-radar pytest files 249 passed; i18n:check, gen:ui --check and tsc clean.
Non-blocking:
CrewProtocolSettings.tsx:232: the hint has no id and the switch has noaria-describedby, so a screen reader misses the "dedicated crew account" warning on Answer @mentions.- The commit message and the 08:29 comment still say there is no dashboard toggle.
- Earlier notes still stand: spec rows for both settings in
crew_ledger_spec.md, and the open mention-wake admission HOLD (#32661) for a maintainer.
CI has not run yet on this fork head; its runs wait on maintainer approval. This approval does not count toward merge. @iamwhatever, could you give the counting review on this head?
AI-assisted, sent by CommunityCrew
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on 70786ab. CI ran on this head, and one backend shard fails on a facade guard this PR trips:
- Backend Tests (3.12, 7),
test_facade_mirror_guards:kiro_crew.apps.builtins.issue_radar.backend.crew_storereports_BOOL_SETTINGS: forwarded from ...crew_store_records, manifest has None. The PR adds_BOOL_SETTINGStocrew_store_records.py:190and thecrew_storefacade forwards it, but the facade'sTYPE_CHECKINGmanifest (the import block fromcrew_store_recordsaround line 148) does not list it. Fix: add_BOOL_SETTINGSto that block, then runtest/test_facade_mirror_guards.py.
Coverage Gate and PR Readiness are red only because of that shard. Main does not have _BOOL_SETTINGS, so this comes from the PR. Everything else on this head passed.
AI-assisted, sent by CommunityCrew
|
@bolichen97 Fixed in 203c81b: Locally on this tree, The head stays on main 285971e. A rebase onto current main also passed the same tests, but the fork token cannot push it because main changed |
|
Rebased: main moved in Locally on this head: |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on 6d15c64. The _BOOL_SETTINGS manifest point from my last review is fixed (crew_store.py:149), and the latest test runs on this head pass.
One blocker is left. It is GPT 6.1's F2, which the adjudication upheld under the blocking AUTOSDE rule persist-before-you-publish. I traced it in the code:
crew_runtime_session.py:420-423:_finalizesetsfinalized = True, then awaits_tell_admission(slot, prompt, True).crew_wake_inflight._resolvecalls_write, which callsatomic_write. AnOSErrorthere goes up through_on_admission._tell_admission(lines 375-382) catches everyExceptionand only logs a warning.- Both later
if consumed: await _finalize()calls then do nothing, becausefinalizedis already set.
The result: a consumed ask stays carried on disk. After a restart or the carry timeout, review puts it back on the queue, and the crew answers the same question again.
Fix: have _tell_admission report whether the hook succeeded. Set finalized only on success, or reset it on failure, so the end-of-turn path retries the write. Please add one test where the first _write raises and the second succeeds; the row should end consumed.
F1 (GitLab threads over 250 notes) was downgraded, so it does not block.
AI-assisted, sent by CommunityCrew
|
self-added: yes
|
|
@bolichen97 Fixed in 3f04c0a, as you suggested: The test you asked for is The head is rebased on main ddb535e, which also carries the The fork runs on this head need a maintainer's approval again. Thanks for tracing it so precisely. |
bolichen97
left a comment
There was a problem hiding this comment.
Requesting changes on 3f04c0a. The F2 fix is right: _tell_admission now returns whether the hook succeeded, _finalize clears finalized when the write fails, and the end-of-turn settlement retries it. The new test drives exactly that case, with a first atomic_write that raises, two writes, and the row ending _DONE.
One blocker is left, and it comes from that new test. Backend Tests (3.12, 5) fails test/test_wait_discipline_ratchet.py, and it fails the same way locally on this head (2 failed):
test/test_issue_radar_crew_runtime_wake.py:1533addsasyncio.wait_for(..., timeout=_TEST_CEILING_SECS)with_TEST_CEILING_SECS = 5. The ratchet refuses a newwait_forunder 30 s in a file the PR touches (this file goes from 0 to 1).
Fix: bound that await with the shared helper the file already imports, for example await await_until(asyncio.ensure_future(crs._capped_run_chat(state, slot, prompt))), which uses the repo's default test timeout. Then run python -m pytest -n0 test/test_wait_discipline_ratchet.py. Coverage Gate and PR Readiness are red only because of this shard.
AI-assisted, sent by CommunityCrew
A crew found new work only through its auto-nudge idle timer, one model turn
per tick. Fast reaction meant a short timer, and on the workshop stand a 30 s
timer cost about $9 an hour while the crew did nothing. The watcher already
reads the forge every poll without a model, so it now wakes the crew itself:
- #N scope-label: an open issue carries a label in the crew's scope and is
not claimed, not needs-human, not in the skip index and not the crew's own
item. A crew with an empty scope gets #N new-issue for issues above its
high-water mark instead. This does not depend on notify_on_new_issue.
- #N asked <id> (!N for a GitLab MR), only when the new repo crew setting
crew_answer_mentions is on (default off: the forge identity is the
gateway's login, often the operator's own account, and a crew would answer
a question asked of that person in their name): a comment by someone other
than the crew's forge identity, and not by a GitHub App bot ("name[bot]"), mentions
that identity as a whole username (a dot followed by a name character
continues it, so @crew-bot.alice is not @crew-bot). Every crew on a repo shares that identity, so ONE crew is
woken: the one holding an open item for the thread, else one with a
finished item for it, else the first by id whose scope matches the issue,
else the first by id. Both forge reads check the whole comment against the login before
cutting its body, so a mention after a long log still counts. An edited old comment and a
comment id seen before wake nobody.
The mention scan moves by update time (GitHub sorts the
repository-comments page by update and reads on through a full page that
shares one update time, 5 pages per sweep, resuming on the next page of the
same window; GitLab reads at most 10 threads updated
since the cursor, tie-safe at the cursor), and a separate creation floor
moves only when a scan reached the present, so a page of edits or a burst of
threads cannot skip a question. GitHub reads overlap the cursor's second by
one second and drop repeats by comment id. When a crew already holds 20
pending asks, the scan stops there and keeps its cursor (logged), so later
questions wait instead of being dropped.
Each signal seeds silently on first observation. Each is committed only once
wake_crew reports that a turn started, so a crew that was mid-turn is woken
again on the next sweep. Scope marks keep issue numbers only, and marks for
issues still on the page are evicted last.
State lives in crew-wake-checks.json.
The idle timer stays the fallback at its 300 s default; a loop's own
idle_secs remains the only knob for it. KIROCREW_ISSUE_RADAR_POLL_SECS
(clamped 15..300, a third of the crew trust grant the sweep renews) sets the
watcher interval. The brief tells
the crew how to answer a question without changing the item's phase.
A wake clears from a crew's pending asks only the asks it carried, so an
ask a sweep could not fold in (its login read failed) waits for the next
wake, and a carried ask is kept on disk (crew-wake-inflight.json) until its
turn is admitted, so a cancel, a permit timeout or a gateway restart before
admission puts it back on the queue. A test pins that a human answer hides
only a needs-decision or needs-investigation pass, never a scope-gate hold.
|
@bolichen97 Fixed in 7795e2d, as you suggested: the new test now awaits the turn with Locally on this head: The head is rebased on main fb3c586, which had touched |
bolichen97
left a comment
There was a problem hiding this comment.
Approving. Head 7795e2df18 replaces the short asyncio.wait_for(..., timeout=5) in test_issue_radar_crew_runtime_wake.py with await_until(asyncio.ensure_future(...)), which is what my change request asked for. CI and all fork review lanes pass on this head.
AI-assisted, sent by CommunityCrew
|
Thanks @bolichen97 for the approval. On 7795e2d all 94 checks and every fork review lane pass, and PR Readiness reads I can't enable auto-merge from this fork account ( |
Problem / Motivation
Goal: a crew reacts within one watcher poll to new work in its scope and to a person @-mentioning it, without paying for a model turn on every idle tick.
Today a crew finds new work only through its auto-nudge idle timer: every tick is a full model turn that re-reads the repository. A newly labelled issue, or a maintainer writing "@crew-bot can you take this?", waits for the next tick. For a fast reaction the operator has to shorten the timer, and every tick then costs a turn whether or not anything changed.
Why it matters
On a workshop stand (GitLab CE, one crew), a 30 s idle timer cost about $9 an hour while the crew did nothing. At the default 300 s a mention waits up to five minutes. The watcher already polls the forge every cycle without a model, so it can tell when there is something to do.
Not a goal
idle_secsstays the only idle-gap setting.What changed (motivation → approach → change)
Groundwork for #20552, not its fix:
launch_crewstill arms the idle loop atidle_secs=300, so an idle crew still takes a turn every 5 minutes. #25435 or a follow-up gates that tick.crew_runtime.py):#N scope-label: an open issue carries a label in the crew's scope and is not claimed, notneeds-human, not in the skip index, and not already the crew's own item. A crew with an empty scope gets#N new-issuefor issues above its high-water mark instead. Both are off unless the new repo crew settingcrew_wake_on_new_workis on; off, no marks are kept.#N asked <id>(!Nfor a GitLab MR): someone other than the crew's forge identity, and not a GitHub App bot (name[bot]), mentions that identity as a whole username (@crew-bot.aliceis another account). Off unless the new repo crew settingcrew_answer_mentionsis on: the identity is the gateway's login, often the operator's own account, and a crew would answer a question asked of that person in their name.crew_brief.mdandcrew_ledger_spec.mdsay it needs a dedicated crew account. One crew answers: the one holding an open item for the thread, else one with a finished item, else the first by id whose scope matches, else the first by id. Edited old comments and comment ids already read wake nobody.crew_mention_scan.py). When a crew already holds 20 pending asks, the scan stops and keeps its cursor, so later questions wait instead of being dropped.wake_crewreports that a turn started, so a crew that was mid-turn is woken again on the next sweep. Scope marks keep issue numbers only; marks for issues still on the page are evicted last, so a bounded mark list never makes an old issue new again. State lives increw-wake-checks.json.KIROCREW_ISSUE_RADAR_POLL_SECS(clamped 15..300) sets the watcher interval (watch.py). The ceiling is a third of the 900 s trust grant an unattended crew holds, because the sweep's watchdog pass is what renews it.list_repo_comments_sinceingithub_client_repo_reads.py. It reuseslist_updated_open_issues, added by feat(issue-radar): a human removing the needs-human label resumes a skipped issue #21541 (merged).list_threads_updated_sinceandlist_thread_commentsingitlab_client_crew_reads.py, re-exported fromgitlab_client.py.crew_wake_inflight.py): an ask stays on disk until the model consumes it.website/src/i18n;SettingTogglemoved to its own file to be shared.crew_brief.mdtells the crew how to answer a question it was asked without changing the item's phase.Backwards compatibility
Compatible. Every new wake is opt-in per repo:
crew_wake_on_new_workandcrew_answer_mentionsboth default to off, so an existing crew takes turns exactly as before, on its 300 s idle clock, until an operator turns one on with its switch in the repo's Protocol settings.Tests
New cases in
test/test_issue_radar_crew_runtime_wake.py(TestNewWorkWakes,TestWakeReads,TestWakeTimers), split out oftest/test_issue_radar_crew_runtime_sweep.pyfor the line cap; the shared_FakeClientstub moved totest/issue_radar_crew_runtime_helpers.py:trueturns them on, and turning them on seeds from that moment;needs-human, skipped and own issues wake nobody;trueturns them on;Each of the seven cases above from "one crew" down fails on the code before its fix, and so does the failed-write case (
writes == 1, the ask stays carried); it passed 20 of 20 runs at-n0.Frontend:
CrewProtocolSettings.test.tsxcovers the switches: off unless savedtrue, a one-key patch to the opposite value, disabled until the write answers, unchanged on a failed write.Run locally on this head: the issue-radar runtime, wake and crew-store test files with
test_facade_mirror_guards.py,test_review_repair_routing_skill.pyandtest_wait_discipline_ratchet.py(622 passed, 1 skipped), the GitLab client tests (290 passed), and the flake-pattern ratchet (68 passed); the scoped frontend tests (15,452 passed; the only reds arenavLabels.test.tsxtiming out, which fails the same way on clean main, plus the style tests the translations were then fixed for);tsc, eslint,i18n:check,i18n:render,gen:ui --check, phantom-classes, restyle ratchet and jscpd. isort, flake8 and black on the changed Python, mypy onapps/builtins/issue_radar/,scripts/check_file_line_cap.pyand the diff-scoped semgrep rules exit 0.Manual verification
The pre-rebase version of this change runs on a GitLab CE workshop stand, applied together with #21541 as a patch over KiroCrew 0.10.0rc4. This rebased revision has not been re-run on a forge; it is covered by the tests above.
Screenshots / video
Protocol settings with "Wake crews when new work appears" on and "Answer @mentions" off, captured with scripted Playwright on a loopback Vite server. Committed under
temp-screenshots/crew-wakes/because a fork author cannot attach images.Dark:
temp-screenshots/crew-wakes/crew-wakes-dark.pngLight:
temp-screenshots/crew-wakes/crew-wakes-light.pngRelated Issues
Part of #20552
Groundwork for #20552: the idle-tick gate that removes the 5-minute idle turn is #25435 or a follow-up. Builds on #21541, now merged.
Follow-ups left out of this PR:
author_association).list_repo_comments_sinceand_read_open_issuesreturningNone.Checklist
crew_brief.mdContribution License Agreement
Contributed under the project's Apache-2.0 license.