Skip to content

fix(meetings): release a meeting whose agents were retired out from under it - #7899

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
SaRedfiche:fix/meetings-abandoned-active-latch-5904
Sep 18, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
SaRedfiche:fix/meetings-abandoned-active-latch-5904

Conversation

@SaRedfiche

@SaRedfiche SaRedfiche commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A Meetings meeting can be left permanently wedged. POST /start initializes the
three meeting agents serially (~38s with the default roster), and any dashboard
chat turn during that window triggers the gateway-wide "Kiro identity changed"
session reconcile, which retires the meeting's agent sessions out from under it
while it is still initializing. The MeetingSession object survives, never
became dispatch-ready, and because it is young its .expired flag is still
False, so it keeps holding the single-active-meeting latch with no live agent
slot behind it. The meeting is left status: active with no live session:
starting any new meeting answers 409 meeting_already_active (issue #5904).

Why it matters

The user cannot start a new meeting, and the wedged one shows as active while
doing nothing. There is no self-recovery for the latch: it only releases if the
user happens to start a different meeting.

What changed (motivation to approach to change)

Root cause: the single-active latch keys on MeetingSession.expired, a pure TTL
that has no idea whether the session's agent slots still exist. A swept-mid-init
meeting is un-live but not expired, so it slips through the guard.

The naive signal "all agent slots gone from the registry" is ambiguous: the
ordinary idle sweep (session_cleanup._expire_idle, 3600s) also reaps a
merely-quiet established meeting's slots (they are not persistent/channel-exempt),
and that meeting is fully recoverable — its next line resumes the slots via
dispatch_to_agent -> get_or_create. Treating that as terminal would drop a
recoverable meeting.

So abandoned is defined to fire ONLY for the genuine #5904 state, requiring
BOTH:

  • not became_ready — a new monotonic flag set the first time
    _ActiveMeeting.resume_dispatches opens the session's ingress (i.e. agent init
    completed and it became usable). This excludes every established meeting, which
    by definition already became ready.
  • every installed agent slot is gone from the session registry.

The /start single-active guard releases the latch for such a meeting, and the
outgoing meeting gets the same terminal end_meeting_meta teardown expiry
already uses. (abandoned is deliberately NOT surfaced in the status-poll
payload — it has no consumer there; the latch guard reads the property
directly.)

The dispatch path deliberately does NOT tear down on abandoned (only on
expired): an idle-reaped established meeting must keep resuming on its next
line. The identity-sweep root cause is a maintainer design decision, left
untouched.

Tests

  • test_meetings_session.py::TestAbandoned pins the discriminator: all slots
    live -> False; never-ready + no slot live -> True; established
    (became_ready=True) + all slots reaped -> False
    (the load-bearing guard for
    the idle-reap case); one surviving slot -> False; no manager / no slots ->
    False.
  • test_meetings_routes.py::test_start_releases_an_abandoned_meeting_holding_the_latch
    models mid-init retirement (slots gone AND became_ready False) and asserts a
    fresh /start returns 200, the wedged meeting is written non-active, and the
    new meeting takes over.
  • Test double: FakeSessionManager.has_session / live_keys (defaults all-live,
    so existing meetings tests are unaffected).

Manual verification

N/A, unit coverage sufficient. Backend session-lifecycle logic exercised end to
end over the real aiohttp router with the fake session manager; no UI, socket, or
external service involved.

Related Issues

Fixes #5904

Pattern harvest

Rule candidate: review-prompt
Pattern: a liveness signal ("resource gone from the registry") used as a
single-owner-latch release condition, when the same observable state also arises
from a fully-recoverable cause (idle reclamation resumes on next use). Gate the
terminal action on a positive "reached the ready/committed state" marker so a
recoverable transient is never treated as terminal.

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): N/A, no user docs affected
  • No secrets, credentials, or internal references in the diff

Why no screenshot: backend session-lifecycle change only; no rendered UI delta.

@SaRedfiche
SaRedfiche requested review from a team and hoang-phan98 September 2, 2026 15:26
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — 🟡 CONCERNS

Design-level review of 1ff21b0b1af7e1abd1e2c9d5568cc278759641ab via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Description promises abandoned "is surfaced in the status poll," but no hunk touches any status/poll handler — a phantom claim.

Watch

  • Phantom description → diff gap: "abandoned is surfaced in the status poll" has no backing code, so the dashboard state visibility the description promises does not exist and a reader will look for it.
    Clears when: the claim is removed from the description, or the surfacing hunk lands in this PR.
  • Release keys on slot retirement, but the same wedge exists without one: _safe_dispatch catches only Exception, so a CancelledError mid-init (e.g. handler cancellation during the ~38s window) kills the start after ACTIVE.set with slots still live — abandoned reads False and the latch holds until TTL. The general fix is transactional cleanup in handle_start_meeting (undo the install when the start dies after installing); the shipped detect-at-next-start repair covers only the swept variant.
    Clears when: the author confirms the cancellation-with-live-slots variant is out of scope with a tracked follow-up, or adds start-failure cleanup.

[DESIGN-REVIEWED] 1ff21b0

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — 🟡 CONCERNS

Premise-level review of 1ff21b0b1af7e1abd1e2c9d5568cc278759641ab 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/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Description claims "abandoned is surfaced in the status poll" — no hunk ships it; status() is untouched, so the record overstates what merged.

Not justified as shipped

  • Item 6 — undelivered claim: the description states "abandoned is surfaced in the status poll," but MeetingSession.status() (domain/session.py:642) and handle_get_meeting are unchanged in the diff; nothing exposes the flag.
    Subtraction: remove that sentence from the description — the fix is complete without it.
    Clears when: the description no longer claims the status-poll surfacing, or the diff actually contains the hunk that ships it.

What this change ships

Inventory (6 items) — 5 justified

Intent: FIX — a meeting whose agent sessions were retired mid-init must stop wedging the single-active latch and blocking every new /start (issue #5904).

  1. /start now succeeds instead of 409 when the active meeting was retired mid-init — justified
  2. The replaced wedged meeting is persisted terminal, not left active — justified
  3. Sessions record having finished init (became_ready), read by the new abandoned signal — justified
  4. resume_dispatches gains mark_ready, passed only by the post-init start path — justified
  5. Test double gains has_session/live_keys, defaulting all-live — justified
  6. Status poll unchanged despite the description declaring abandoned surfaced there — undelivered claim: sentence has no matching hunk

[FIRST-PRINCIPLES-REVIEWED] 1ff21b0

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

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

Review details

FINDING -- src/kiro_crew/apps/builtins/meetings/backend/routes/_common.py:148 -- an identity sweep after agent init removes every slot, but "session.became_ready = True" makes abandoned false and subsequent starts return 409 -> Fix: set readiness only when at least one initialized slot remains live. (origin: validation)
[GPT-REVIEWED] 1ff21b0

@github-actions

github-actions Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review (fork) — ✅ no blocking findings

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

Review details

I've independently verified the core safety argument:

  • abandoned is read only by the start-meeting guard, which runs entirely inside START_LOCK (meeting_lifecycle.py:302-394); agent init (set → suspend → init_agents → resume_dispatches) runs under that same lock, so no competing start can observe the mid-init window.
  • became_ready short-circuits abandoned to False (session.py:52-53) and is set only by the start path via mark_ready=True after init_agents (line 394 → diff), never by the /status active unpause path.
  • has_session(queue.key) folds keys identically to get_or_create (session_allocation.py:361-378), so slot-liveness reads are consistent — an established-then-reaped meeting keeps became_ready=True and reads not-abandoned.
  • dispatch_admission deliberately tears down only on expired, not abandoned, keeping recoverable meetings dispatch-recoverable.

The residual edges (partial init-failure leaving live slots; no self-heal on disk absent a new start) are pre-existing behaviors, not regressions on the changed lines. Nothing survives falsification, and I found no grounded new defect.

No findings.

[OPUS-REVIEWED] 1ff21b0

@SaRedfiche
SaRedfiche force-pushed the fix/meetings-abandoned-active-latch-5904 branch from f8c4f84 to e47f63b Compare September 2, 2026 17:01
@SaRedfiche

Copy link
Copy Markdown
Contributor Author

agents.py / meeting_lifecycle.py — "recoverable idle sessions are terminated" — fixed in e47f63b07.

Meeting quiet for the idle timeout -> idle sweep removes every agent slot -> the meeting is ended/latch-released instead of resuming via get_or_create.

Confirmed legitimate against source (session_cleanup._expire_idle reaps meeting slots; they are not persistent/channel-exempt). The dispatch-path teardown on abandoned was reverted, and abandoned was redefined to require BOTH slots-gone AND not became_ready (a new monotonic flag set the first time resume_dispatches opens ingress). An established meeting whose idle slots were reaped keeps became_ready=True, so it no longer reads abandoned and resumes on its next line. Only a meeting retired mid-init (never ready) releases the latch.

@SaRedfiche

Copy link
Copy Markdown
Contributor Author

agents.py:394 / session.py:660 / meeting_lifecycle.py:301 — idle-reaped-but-resumable meeting killed on its next line — fixed in e47f63b07.

abandoned becomes True on an established meeting whose idle slots were reaped (resume SID preserved, resumable via get_or_create), so it is torn down instead of resuming.

Legitimate and the same root issue GPT caught. Resolved exactly as suggested (gate abandoned so an idle-reaped resumable meeting is not treated as terminal): abandoned now additionally requires not became_ready, where became_ready is set once the meeting finishes init and opens ingress. An idle-reaped established meeting has became_ready=True -> abandoned short-circuits to False -> the lazy get_or_create resume path is preserved. The dispatch path no longer tears down on abandoned at all (only expired).

@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 labels Sep 2, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

Open PR relationship audit

This is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion.

Relationship findings

  • PR #5741 is OVERLAPPING relative to this PR. The goals differ or the implementations can complement each other; this is not a duplicate claim. Recommended action for PR #5741: KEEP. Independent goals, both wanted, but they collide mechanically. Whichever merges second must reapply: after 5741 the 'only expired tears down here' rule lives in _common.dispatch_admission and now governs the import producer too, so 7899's abandoned-versus-expired reasoning belongs on the shared transaction rather than on the deleted inline block. Files: src/kiro_crew/apps/builtins/meetings/backend/routes/agents.py, test/meetings_helpers.py.

No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Sep 7, 2026
@bolichen97
bolichen97 force-pushed the fix/meetings-abandoned-active-latch-5904 branch from e47f63b to 2726986 Compare September 8, 2026 16:46
@bolichen97

Copy link
Copy Markdown
Contributor

Rebased onto main acc99f217 by a maintainer as part of the 2026-09-08 open-PR audit (was 749 commits behind).

One conflict, in routes/agents.py: main's #5741 deleted the inline admission block your NOTE annotated and extracted it into _common.dispatch_admission. Resolution: took main's version of agents.py verbatim (your only change there was that comment) and moved the NOTE, unchanged, onto the if session.expired: branch in _common.dispatch_admission, where the expired-only teardown now lives. No behaviour change. Everything else (domain/session.py, meeting_lifecycle.py, the tests) applied cleanly.

Gates run locally on the changed files: black, isort, flake8 (the two black hits are pre-existing baselined files, also failing on main), and pytest test/test_meetings_session.py test/test_meetings_routes.py -> 295 passed.

Please review the comment relocation. A maintainer push makes the maintainer the last pusher, so a second approver is needed under the repo's last-push rule. Reply if anything looks wrong.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 8, 2026
@SaRedfiche
SaRedfiche force-pushed the fix/meetings-abandoned-active-latch-5904 branch from 2726986 to 2d6d2b9 Compare September 10, 2026 19:49
@SaRedfiche

Copy link
Copy Markdown
Contributor Author

Pushed 2d6d2b943 to clear the one red that was tied to this diff: the comment-history gate (check_comment_history.py). It flagged three files whose history-narration comment count grew, all from issue-number references this change added:

The gate's doctrine is that change history lives in git and the PR, not in code comments, so I removed only the issue-number narration and kept the behavioral descriptions verbatim (e.g. "The case this guards: a gateway-wide session sweep ..."). The diff vs the prior head is exactly three lines, one per file. check_comment_history.py now passes; test_meetings_session.py + test_meetings_routes.py = 295 passed, flake8/black clean.

This was amended onto your rebased head 27269868c (not re-based onto the newer main) to keep your base intact — only the three comment lines changed.

The other two reds on the prior head were unrelated to this diff: Build Desktop (arm) built its installers and failed only on FinalizeArtifact: (403) Forbidden (artifact-upload infra), and Backend Tests (Windows) shard 4 was a single test/test_work_ledger.py sharing-violation flake (21223 passed, 1 failed) in an unrelated module. Both should clear on the re-run this push triggers.

@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 readiness: checking Automated validation is still running labels Sep 10, 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 Sep 18, 2026
@NicholasRBowers

NicholasRBowers commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

PR description — "abandoned is surfaced in the status poll" claim with no backing hunk — span=4ec6237aed97 — fixed (description edited).

the description states "abandoned is surfaced in the status poll," but MeetingSession.status() and handle_get_meeting are unchanged in the diff; nothing exposes the flag.

Correct: the surfacing line was deleted from MeetingSession.to_dict in an earlier round (the lane's own prior BLOCK, applied as suggested at head 8b98f84fb), and the description sentence was a leftover. Applied the stated clear-condition: the claim is removed from the PR description, replaced with an explicit note that abandoned is deliberately NOT surfaced (zero consumers; the latch guard reads the property directly).


Historical (head 8b98f84fb): the zero-consumer "abandoned": self.abandoned, rider in to_dict was fixed — line deleted per the review's subtraction; property and internal consumers unchanged; 819 meetings tests green.

@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 Sep 18, 2026
@NicholasRBowers
NicholasRBowers force-pushed the fix/meetings-abandoned-active-latch-5904 branch from 8b98f84 to 8562f20 Compare September 18, 2026 02:11
@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 Sep 18, 2026
…mid-init

A gateway-wide session sweep (the dashboard's 'Kiro identity changed'
reconcile) can retire a meeting's agent sessions while it is still
initializing. The MeetingSession survives, never became dispatch-ready, and is
young enough that .expired stays False, so it holds the single-active-meeting
latch with no live slot: the meeting wedges status active and every new /start
answers 409 (issue kirodotdev#5904).

Add MeetingSession.abandoned, true only when BOTH:
  - the meeting never became dispatch-ready (new monotonic became_ready flag,
    set only by the post-init start path via an explicit mark_ready flag on
    resume_dispatches, i.e. agent init completed), AND
  - every installed agent slot is gone from the session registry.
The /start single-active guard releases the latch for such a meeting (and the
outgoing meeting gets the same terminal end_meeting_meta teardown expiry
already uses).

The dispatch path deliberately does NOT tear down on abandoned (only on
expired): the became_ready condition excludes an established meeting whose idle
agent slots were reaped by the ordinary idle sweep (session_cleanup._expire_idle,
meeting slots are not persistent/channel-exempt) - that meeting resumes its
slots via get_or_create on its next line and must stay recoverable. Gating on
became_ready is what tells that recoverable idle-reaped case apart from a
genuinely-wedged mid-init retirement.

Review amendments (original fix by Robert Fisher):
  - became_ready is set only behind resume_dispatches(mark_ready=True), passed
    solely by the start path after init_agents completes; a routine
    /status active unpause can no longer falsely mark a retired-mid-init
    meeting ready (regression test proven red-before-green).
  - abandoned is not surfaced in the status-poll payload (zero consumers;
    the latch guard reads the property directly).

The identity-sweep root cause is a maintainer design decision, left untouched.

Fixes kirodotdev#5904

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
@NicholasRBowers
NicholasRBowers force-pushed the fix/meetings-abandoned-active-latch-5904 branch from 8562f20 to 1ff21b0 Compare September 18, 2026 03:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 18, 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.

Reviewed the full production diff on 1ff21b0. 释放初始化期间全部代理已被回收、从未就绪的会议占用。

已完整审查会议初始化、abandoned状态及START_LOCK替换路径。写前main与已审查main一致,完整diff SHA256未变;已就绪会议仍可空闲恢复。

Fresh REST checks: current-head PR Readiness success; no effective change request or unresolved review hold; CODEOWNERS/UX eligibility and the distinct last pusher verified. Optional baseline failures, if present, remain recorded and are not claimed green. This approval does not bypass branch protection.

@bolichen97
bolichen97 merged commit 4ce4cd5 into kirodotdev:main Sep 18, 2026
98 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 18, 2026
@chenmingwei23 chenmingwei23 removed the drive-to-green PR claimed by drive-to-green pipeline label Sep 18, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…mid-init (kirodotdev#7899)

A gateway-wide session sweep (the dashboard's 'Kiro identity changed'
reconcile) can retire a meeting's agent sessions while it is still
initializing. The MeetingSession survives, never became dispatch-ready, and is
young enough that .expired stays False, so it holds the single-active-meeting
latch with no live slot: the meeting wedges status active and every new /start
answers 409 (issue kirodotdev#5904).

Add MeetingSession.abandoned, true only when BOTH:
  - the meeting never became dispatch-ready (new monotonic became_ready flag,
    set only by the post-init start path via an explicit mark_ready flag on
    resume_dispatches, i.e. agent init completed), AND
  - every installed agent slot is gone from the session registry.
The /start single-active guard releases the latch for such a meeting (and the
outgoing meeting gets the same terminal end_meeting_meta teardown expiry
already uses).

The dispatch path deliberately does NOT tear down on abandoned (only on
expired): the became_ready condition excludes an established meeting whose idle
agent slots were reaped by the ordinary idle sweep (session_cleanup._expire_idle,
meeting slots are not persistent/channel-exempt) - that meeting resumes its
slots via get_or_create on its next line and must stay recoverable. Gating on
became_ready is what tells that recoverable idle-reaped case apart from a
genuinely-wedged mid-init retirement.

Review amendments (original fix by Robert Fisher):
  - became_ready is set only behind resume_dispatches(mark_ready=True), passed
    solely by the start path after init_agents completes; a routine
    /status active unpause can no longer falsely mark a retired-mid-init
    meeting ready (regression test proven red-before-green).
  - abandoned is not surfaced in the status-poll payload (zero consumers;
    the latch guard reads the property directly).

The identity-sweep root cause is a maintainer design decision, left untouched.

Fixes kirodotdev#5904

Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
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.

Meeting agents retired mid-init by dashboard chat 'Kiro identity changed' reconcile — meeting wedges status:active, never transcribes

5 participants