Skip to content

feat(issue-radar): the watcher wakes crews on new work and @mentions - #22123

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
migh000:crew-wake-signals
Nov 10, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
migh000:crew-wake-signals

Conversation

@migh000

@migh000 migh000 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Removing the idle timer. It stays as a slower fallback for anything the watcher cannot see.
  • Waking on every comment. Only a comment that mentions the crew's forge identity, written by someone else, wakes it.
  • Webhooks. This stays poll-based, on the watcher's existing cadence.
  • A second idle-gap knob. The loop's own idle_secs stays the only idle-gap setting.

What changed (motivation → approach → change)

Groundwork for #20552, not its fix: launch_crew still arms the idle loop at idle_secs=300, so an idle crew still takes a turn every 5 minutes. #25435 or a follow-up gates that tick.

  • Goal → approach: the watcher wakes crews on signals it reads without a model.
  • Signals (in crew_runtime.py):
    • #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 already the crew's own item. A crew with an empty scope gets #N new-issue for issues above its high-water mark instead. Both are off unless the new repo crew setting crew_wake_on_new_work is on; off, no marks are kept.
    • #N asked <id> (!N for 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.alice is another account). Off unless the new repo crew setting crew_answer_mentions is 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.md and crew_ledger_spec.md say 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.
    • The mention scan moves by update time (GitHub: one comments page sorted by update, reading on through a same-time tie, 5 pages per sweep; GitLab: oldest-updated threads first, 10 per sweep; 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.
    • Each signal seeds silently on first observation, so turning this on does not replay history. A signal is committed only after 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; marks for issues still on the page are evicted last, so a bounded mark list never makes an old issue new again. State lives in crew-wake-checks.json.
  • Timers:
    • 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.
  • Forge reads:
  • Ask guards (crew_wake_inflight.py): an ask stays on disk until the model consumes it.
  • Settings UI: repo Settings → Protocol settings gets a switch for each setting, translated in website/src/i18n; SettingToggle moved to its own file to be shared.
  • Brief: crew_brief.md tells the crew how to answer a question it was asked without changing the item's phase.
  • RFC: none; every new wake is additive and opt-in per repo.

Backwards compatibility

Compatible. Every new wake is opt-in per repo: crew_wake_on_new_work and crew_answer_mentions both 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 of test/test_issue_radar_crew_runtime_sweep.py for the line cap; the shared _FakeClient stub moved to test/issue_radar_crew_runtime_helpers.py:

  • new-work wakes are off unless the repo opts in, only a JSON true turns them on, and turning them on seeds from that moment;
  • a scope label wakes once, after a silent first look;
  • claimed, needs-human, skipped and own issues wake nobody;
  • a busy crew is woken again on the next sweep, and a mention on a busy crew stays pending;
  • an empty-scope crew wakes for a new issue;
  • mention wakes are off unless the repo opts in, and only a JSON true turns them on;
  • a mention wakes the crew and names the comment;
  • the crew's own mention wakes nobody;
  • a mention goes to the crew whose scope matches;
  • a bot's mention, an edited old comment and a repeated comment id wake the crew once at most;
  • a mention is answered by one crew, the thread's owner first, else the first by id;
  • after a handover, a mention goes to the crew holding the issue now;
  • a GitHub tie wider than a page is read through, and one past the page cap resumes next sweep;
  • a boundary second split across pages is not skipped;
  • a full ask queue holds questions back instead of dropping them;
  • scope marks keep no labels;
  • a page of edited old comments cannot stall GitHub mentions;
  • a GitLab thread past the per-sweep cap keeps its question, even at a cursor tie;
  • eviction keeps marks for issues still on the page;
  • the watcher ceiling renews trust before it lapses;
  • GitHub reads every thread in one call;
  • mentions match the whole username;
  • GitLab notes drop system notes and read back to the floor;
  • the GitLab open-issue read is ordered by update;
  • the GitHub comment read is one page with an encoded cursor, and the GitHub updated-issue read leaves out PRs;
  • the watcher interval comes from the environment, clamped;
  • a mention past the body cut is matched on the whole comment, on both providers, and the GitHub pattern is Go-regexp safe;
  • a consumed ask whose first write fails is written again before the turn ends, so it is never handed back.

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.tsx covers the switches: off unless saved true, 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.py and test_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 are navLabels.test.tsx timing 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 on apps/builtins/issue_radar/, scripts/check_file_line_cap.py and 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.png

Light: temp-screenshots/crew-wakes/crew-wakes-light.png

Related 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:

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 fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Oct 19, 2026
@migh000
migh000 force-pushed the crew-wake-signals branch 2 times, most recently from 3080bb2 to f14f797 Compare October 19, 2026 23:37
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 20, 2026
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 20, 2026
@migh000

migh000 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto #21541 bda236a (on main 4be2da2): 7435a3f. No conflicts.

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

migh000 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 8caabfc (#21541): pushed 748d5eb. The comment-body and MR-row reads are now bounded, the same way #21541 bounds its issue rows. Same local checks as on #21541: 6,304 passed.

@oliviergaumond

Copy link
Copy Markdown
Contributor

@migh000 I rebased this stack (#21541 + this PR) onto current main while building a follow-up. You can reuse it if it saves you a rebase.

Rebased commits (your authorship kept, content unchanged), on main @ 0618aa561d in oliviergaumond/KiroCrew feat/crew-pickup-due:

Conflicts. Only one, in #21541's commit: the golden tables in test/test_entry_types_facade.py, which main had also changed. I kept main's rows (including work/charged) and regenerated the radar/recorded row digest and the session render digest from the merged code. This PR's commit applied cleanly.

Tests on that base: test/test_issue_radar*.py, the entry-types / facade-mirror / line-cap tests and src/kiro_crew/apps/builtins/issue_radar/tests give 3301 passed.

To take it:

git fetch https://github.com/oliviergaumond/KiroCrew feat/crew-pickup-due
git checkout -B <your-branch> 8201521dd8   # for #21541
git checkout -B <your-branch> deac4ff097   # for this PR

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 max_open never wakes it once a slot frees. It adds a model-free pickup-due wake for "more room or a new claimable issue". It also makes the idle timer a 24 h backstop, but only for crews with nothing in an acting phase. It stays a draft until #21541 and this PR land.

@bolichen97

Copy link
Copy Markdown
Contributor

[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:

  • A mention wakes ONE crew. That is the crew holding an open item for the thread. If no crew holds one, it is a crew with a finished item for it, then the first crew whose scope matches, then the first crew by id. Before, every crew on the repo could answer the same question from the same account.
  • Comments by GitHub App bots (name[bot]) no longer wake a crew.
  • The mention scan now moves by update time and keeps a separate creation floor. A page of edited old comments, a same-second tie wider than a page, or more than 10 updated GitLab threads can no longer hide a question.
  • A GitLab MR is no longer matched to a crew by the labels of the issue with the same number.
  • Seen marks for issues still on the open-issues page are evicted last, so a full mark list cannot make an old issue new again.
  • KIROCREW_ISSUE_RADAR_POLL_SECS is clamped to 15..300. The sweep renews an unattended crew's 900 s trust grant, and an hour-long interval let that grant lapse mid-turn.
  • The new wake tests moved to test/test_issue_radar_crew_runtime_wake.py for the 2,000-line test file cap. Each new case fails on the code before its fix.

@github-actions github-actions Bot removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention labels Nov 3, 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.

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:

  1. 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-tree against current main shows no conflict, so rebasing onto the latest main and force-pushing with lease should leave c00d5af as the one commit.

  2. This PR alone does not fix #20552. launch_crew in crew_runtime_session.py still arms the loop with idle_secs=DEFAULT_IDLE_SECS (300) and max_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_mentions on, crew_runtime.py:1313 drops 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 on author_association (collaborator or member).
  • In crew_mention_scan.py:106-110, a tie resume re-reads pages 1..start-1 on every sweep, and start grows each time, which adds rate-limit pressure.
  • Two failure paths have no test: GitHub list_repo_comments_since raising (rate limit), and _read_open_issues returning None.

AI-assisted, sent by CommunityCrew

@migh000

migh000 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @bolichen97. Both blockers are addressed on 180f836.

  1. Merge commit: rebased onto main bab2387339; the branch is one commit again. The patch is byte-identical to c00d5af774 (no file it touches changed on main in between). Locally: the four issue-radar runtime/wake test files (248 passed), flake-pattern ratchet, isort, flake8, mypy on apps/builtins/issue_radar/, diff-scoped semgrep and the black baseline gate all exit 0.
  2. Not the fix for Issue Radar crew idle loop burns credits on no-op turns and never brakes on usage-limit (stand-down is structurally unreachable for crews) #20552: the description now says this PR is groundwork for Issue Radar crew idle loop burns credits on no-op turns and never brakes on usage-limit (stand-down is structurally unreachable for crews) #20552, links it as Part of #20552, and states that launch_crew still arms the idle loop at 300 s, so the idle-tick gate is left to feat(issue-radar): wake an idle crew only when claimable work or capacity grew #25435 or a follow-up.

On the non-blocking points:

  • Any GitHub user can @mention the crew: mention wakes stay off unless the operator turns on crew_answer_mentions, and crew_brief.md / crew_ledger_spec.md ask for a dedicated crew account. An author_association filter is a reasonable next step; I'd rather do it in a follow-up than widen this PR.
  • Tie resume re-reads pages 1..start-1 and the two untested failure paths: agreed, also for the follow-up.

@migh000

migh000 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@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 action_required. Two jobs also failed on a GitHub API rate limit, not on the change: Sensitive Change Review ("Could not read the PR from the API ... re-run this job") and Fork PR Description ("could not list check-runs"). Could you approve the runs and re-run those two? I don't have write access to do either.

bolichen97
bolichen97 previously approved these changes Nov 7, 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 on 180f836. Both blockers from my last review are fixed:

  1. The branch is one commit again. git range-diff shows 180f836 is identical to c00d5af, the head I reviewed, now on main bab2387.
  2. 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

@migh000

migh000 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author
  • span=99c87ef36a50 Incomplete GitLab notes reads permanently skip older mentions

Rebutted (disproportionate): needs one GitLab thread with more than 250 new notes since the last finished scan, on crew_answer_mentions, which is off by default.
The skip is logged as a warning (crew_mention_scan.py:251) and the question stays on the forge; the cost is one missed wake, not lost data.
A persisted per-thread notes cursor adds a second resume mechanism to a scan that already carries cursor, floor and page carries. Opus adjudication downgraded it on the same grounds.

@migh000

migh000 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

@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?

@iamwhatever

Copy link
Copy Markdown
Contributor

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.

  • Policy: with crew_answer_mentions on, a comment from any account other than the crew's own login or a [bot] (crew_runtime.py L1311-L1317) wakes an unattended crew. That crew reads the comment and answers under the gateway's forge login (crew_brief.md L678-L694). The setting is opt-in, but who may trigger the agent is a maintainer's call.
  • Follow-ups without issues: the author deferred (1) an author_association filter so only collaborators or members can wake a crew, (2) the GitHub tie resume that re-reads pages 1..start-1 every sweep, and (3) tests for list_repo_comments_since raising and _read_open_issues returning None. Please open one issue per item and link them in the description.

First Principles and Opus size notes (consumption tracking, poll re-read, crew_runtime.py past 1,600 lines) do not block.

To clear: a maintainer accepts the mention-wake admission rule, and the three follow-up issues are linked.

— crew-pr-reviewer (r149)

@migh000

migh000 commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

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 crew_answer_mentions, and #32661 is the narrowing to trusted accounts. That one needs a maintainer's ruling: accept the rule as it ships here (opt-in, any non-bot account), or ask for the #32661 filter in this PR before merge.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

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:

  • Consider removing KIROCREW_ISSUE_RADAR_POLL_SECS from watch.py. It retimes all three watcher passes. The Goal already holds at the existing 60 s poll, and the "Not a goal" section says the watcher keeps its existing cadence.
  • Update docs/system-specs/modules/issue-radar.md in the same commit. Cover the new wake signals, crew_answer_mentions, crew-wake-checks.json and crew-wake-inflight.json.
  • crew_runtime.py grows from 1,291 to 1,865 lines. Move the new-work and mentions section into its own owner module.

@migh000

migh000 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in crew_runtime.py (bab2387 -> ece4f40); new head 5e08621. The one conflict was the session import list, where main added _GRANTS and this PR adds _ADMISSION_HOOK; both are kept.

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 crew_wake_on_new_work defaults to off, so an existing crew takes turns exactly as before, on its idle clock, until an operator turns it on. While it is off no marks are kept and, with mentions also off, the sweep skips the open-issues read; turning it on seeds from that moment. No dashboard toggle in this PR.

Tests: test_new_work_wakes_are_off_unless_the_repo_opts_in, plus the four issue-radar runtime/wake files and the flake-pattern ratchet (317 passed). isort, flake8, mypy, the black baseline gate, the line-cap check and diff-scoped semgrep exit 0.

@bolichen97 this dismisses your approval and the fork runs need approving again, sorry for the extra round.

bolichen97
bolichen97 previously approved these changes Nov 8, 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 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 neither crew_answer_mentions nor crew_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_work too.

This approval does not count toward merge. @iamwhatever, could you give the counting review on this head?

AI-assisted, sent by CommunityCrew

@migh000

migh000 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

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 temp-screenshots/crew-wakes/; a fork author cannot attach images.

Frontend tests cover the switches (off unless saved true, one-key patch, disabled until the write answers, unchanged on a failed write). tsc, eslint, i18n:check, i18n:render, gen:ui --check, phantom-classes, restyle ratchet and jscpd pass; the backend tests are unchanged (249 passed).

@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 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 no aria-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 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 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_store reports _BOOL_SETTINGS: forwarded from ...crew_store_records, manifest has None. The PR adds _BOOL_SETTINGS to crew_store_records.py:190 and the crew_store facade forwards it, but the facade's TYPE_CHECKING manifest (the import block from crew_store_records around line 148) does not list it. Fix: add _BOOL_SETTINGS to that block, then run test/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

@migh000

migh000 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Fixed in 203c81b: _BOOL_SETTINGS is now listed in the crew_store facade's TYPE_CHECKING import block from crew_store_records. That is the only change from 70786ab.

Locally on this tree, test/test_facade_mirror_guards.py plus the issue-radar crew runtime and crew store tests give 547 passed, 1 skipped. isort, flake8 and mypy on the issue-radar backend are clean.

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 .github/workflows/build-wheel.yml since then (GitHub refuses that without the workflow scope). The runs on this head need a maintainer's approval again.

@migh000

migh000 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in crew_ledger_spec.md, RepoSettings.tsx and the i18n locale catalogs (285971e -> 85413b7); new head 6d15c64, no conflicts. The change is the same as 203c81b (_BOOL_SETTINGS in the crew_store facade manifest).

Locally on this head: test_facade_mirror_guards.py plus the issue-radar crew runtime and crew store tests, 547 passed, 1 skipped; tsc, i18n:check, gen:ui --check and the issue-radar settings vitest clean. The fork runs need a maintainer's approval again.

@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 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: _finalize sets finalized = True, then awaits _tell_admission(slot, prompt, True).
  • crew_wake_inflight._resolve calls _write, which calls atomic_write. An OSError there goes up through _on_admission.
  • _tell_admission (lines 375-382) catches every Exception and only logs a warning.
  • Both later if consumed: await _finalize() calls then do nothing, because finalized is 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

@migh000

migh000 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: admission write settlement in _capped_run_chat

  • Failed consumption writes permanently latch settlement

fixed in 3f04c0a: _tell_admission returns whether the hook succeeded, and _finalize clears finalized when the shielded write completed and failed, so the end-of-turn settlement writes the consumed ask again.
A cancel that lands while the shielded write is still in flight keeps finalized set and re-raises, so two writes never race.
Regression test test_failed_consumed_write_is_retried_before_turn_finishes: the first atomic_write raises OSError, the second succeeds, and the ask ends consumed; with the fix reverted it fails (writes == 1, ask still carried).

@migh000

migh000 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Fixed in 3f04c0a, as you suggested: _tell_admission now returns whether the hook succeeded, and _finalize clears finalized when the write completed and failed, so the end-of-turn path writes it again. A cancel during the shielded write still keeps the flag set.

The test you asked for is test_failed_consumed_write_is_retried_before_turn_finishes in test/test_issue_radar_crew_runtime_wake.py: the first _write raises, the second succeeds, and the row ends consumed. It fails with the fix reverted and passed 20 of 20 runs.

The head is rebased on main ddb535e, which also carries the kirocrew-worktree-dev size fix that turned Backend Tests (3) red on the last head. Locally: the issue-radar runtime, wake and crew-store tests with the facade and skill-size guards, 569 passed, 1 skipped; isort, flake8, black, mypy, the flake-pattern ratchet, tsc, i18n:check and gen:ui --check clean.

The fork runs on this head need a maintainer's approval again. Thanks for tracing it so precisely.

@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 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:1533 adds asyncio.wait_for(..., timeout=_TEST_CEILING_SECS) with _TEST_CEILING_SECS = 5. The ratchet refuses a new wait_for under 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.
@migh000

migh000 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@bolichen97 Fixed in 7795e2d, as you suggested: the new test now awaits the turn with await await_until(asyncio.ensure_future(crs._capped_run_chat(...)), what=...), and the 5 s _TEST_CEILING_SECS is gone.

Locally on this head: test_wait_discipline_ratchet.py and the flake-pattern ratchet pass, as do the issue-radar runtime, wake and crew-store tests with the facade and skill-size guards (622 passed, 1 skipped) and the GitLab client tests. The new test passed 20 of 20 runs and still fails with the F2 fix reverted. isort, flake8, the black gate and mypy are clean.

The head is rebased on main fb3c586, which had touched gitlab_client.py, RepoSettings.tsx and the i18n catalogs; tsc, i18n:check, gen:ui --check and the settings vitest pass on it. The fork runs need a maintainer's approval again.

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

@migh000

migh000 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @bolichen97 for the approval. On 7795e2d all 94 checks and every fork review lane pass, and PR Readiness reads readiness: passed.

I can't enable auto-merge from this fork account (EnablePullRequestAutoMerge is refused for migh000). Could a maintainer merge it, or add the counting review if that is still needed? If you'd rather have it rebased on current main first, I'm happy to do that.

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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants