Repository navigation
Conversation
|
👋 Hi! This PR is currently in draft status. Workflow runs won't be auto-approved until it's marked as ready for review. When you're ready, click "Ready for review" and the workflows will be approved on the next cycle automatically. |
b698e48 to
cb8c9b5
Compare
cb8c9b5 to
90be992
Compare
90be992 to
3e3ea0a
Compare
3e3ea0a to
252b301
Compare
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of I have direct, grounded evidence across the backend, channel, handlers, tests, frontend, and i18n portions of this ~14k-line patch. My findings don't depend on the pending agents, so I'll finalize. Design-Verdict: CONCERNS Sound correctness goal (refuse stale-directory/stale-agent sessions at claim time), but it bundles two new subsystems and four separable contract changes into one ~14k-line PR, and it removes a recovery lever it only promises to replace. WatchRemoving the only in-band recovery for a wedged channel member. The retirement-arm subsystem compensates for a root cause left unfixed. The spec text states the arm store exists only because "a cold start holds no registry entry until its provider binds," names that as "the ONLY open root cause," and rejects the simpler claim-states-its-own-requirement alternative because of it — then defers the fix. The result is intricate machinery (arm map, monotonic generation, transfer/supersede/spend matrix, park-and-settle guard, multiple source-text census tests) that every future teardown/writer must satisfy. High long-term maintenance surface for a mechanism the author says a later registry change would largely delete. Scope/blast radius. This one PR carries claim-time cwd validation, the arm subsystem, a separate lifecycle-lease/turn-active marker subsystem, the SuggestionsLand the drain-gate unification and the channel log-lock fix as their own small PRs first — both are self-contained and would shrink the concurrency-heavy core to a reviewable diff. [DESIGN-REVIEWED] f8b4d6a |
02cee22 to
c0bc80b
Compare
c0bc80b to
3f8f14e
Compare
Open PR relationship auditThis 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
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
bolichen97
left a comment
There was a problem hiding this comment.
The core fix is right and minimal: _consume_pending_reset now passes skip_if_busy=True so the busy check and the teardown are one step under the session lock, matching the sibling discard_conversation call in the same function, and the ambiguous reset return (session is not None) is correctly disambiguated with a has_session presence probe rather than has_active_turn — presence is the right signal since a turn holding the semaphore with no prompt in flight is invisible to the latter. mark_retire_on_next_claim keying on the string rather than the session object is the load-bearing detail: a cold start holds no registry entry, so an object pin would miss exactly the provider already en route to the pre-change directory. The stale-cwd check is placed correctly in _reacquire_and_validate (semaphore held, so eviction cannot land under a streaming reply) instead of the pre-semaphore reuse decision, it normalizes both sides through Path so /p/a vs \\p\\a doesn't evict every warm session on Windows, and it guards on both sides being non-empty so a provider reporting no binding fails open rather than churning. The cwd_moved teardown ordering (pop under the permit, release in finally) is deliberate and argued, and the idempotence note makes the interrupted case safe. Collapsing _last_turn_auth_required into _queue_held is justified by the measurement that no site distinguished the two, and it fixes the real pre-existing leak where a signed-out CLI held the tail drain but not _run_pending_synthesis, which drains the queue too. Grepped the head: no stale _last_turn_auth_required references remain in chat_runner/chat_orchestrator/state.
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of I have enough to reconcile. Key facts: this is the fork lane (no blind read), and the PR's "screenshots" are The copy itself is sound: refusal strings state cause + remedy ("Context kept for {{roles}} — still working. Try again when they finish."), the workspace-unavailable notice asserts + offers an action, warn-vs-danger severity is correctly separated, and the destructive confirm button restates the act ("Clear context and delete messages"). No hedged-state notice, no BLOCK-class hard swap (the new row marks are async acknowledgments, lens 4, not a transform of a persistent element). UX-Verdict: CONCERNS Usable and well-copied, but no first-time reader has seen any of it — the PR's screenshots point at a deleted fork commit, not attachments, so nothing rendered was verifiable here. Evidence gaps
Suggestions
[UX-REVIEWED] f8b4d6a |
… clears A claim could reuse a session bound to a superseded project or agent, so a turn's relative writes landed in the directory the user had just moved away from. The refusal is now raised at claim time and a refused clear is reported instead of silently reading as done. Re-roll: unreachable timing assertion on a loaded CI runner
|
🤖 Kiro Crew [operator: chenmingwei23]: This PR has been inactive for 7+ days. I reviewed the blockers but they require your input:
When you've addressed these, the pipeline will re-assess on its next cycle. |
|
Thanks for this, @rnoack1, and for the honest rewrite of the description — that made the review much easier. Closing as superseded. The one-line guard this PR set out to add has already landed on What remains is ~12.6k lines across 89 files touching core ACP/session/channel code, with no single coherent fix left to land against current You're very welcome to reopen this, or to open a smaller PR scoped to one of the specific windows you describe (the claim-time cwd validation, or the clear-context busy refusal) if you'd like to pursue those individually. Thanks again. |
Problem / Motivation
This description previously claimed the change adds an atomic
skip_if_busyguard to the queued project-change reset. That claim was false against this base and has been rewritten. Verified at merge base9f3c07dc78b7:chat_runner.py:3879already readsreset_ok = await state.sessions.reset(pending_key, skip_if_busy=True), andeffective_session_key(slot)is already resolved at the switch handlers (7 sites inchat_handlers.py). This diff adds neither — 0 added lines matching either. The one-line guard the old title named has landed upstream independently, so the red-then-green verification the old text described could not occur against this base.What remains is larger than that headline and is stated below on its own terms.
A slot's project can change while a session bound to the OLD directory is still reachable. Three windows stay open once the queued reset is allowed to decline:
slot.projectis invisible to a directory test, so the switched-away agent could serve the next turn.resetnorhas_sessioncan see it, and a probe-then-act sequence cannot protect against it.Separately,
api_channel_clear_contextwas destructive on a busy member, and the earlier wording here got that backwards. It claimed the endpoint "reported success for a clear it did not perform"; verified at the merge base, the handler calledstate.sessions.reset(agent.session_key)with the manager defaultskip_if_busy=False, so the clear was performed — it tore down a session whose reply was still streaming. The reported-success half was real but narrower: a member holding a key with no live session counted as cleared. Both are fixed here; the defect to audit is the destructive one.Why it matters
A turn served by a session bound to the wrong directory writes its relative paths into the wrong project — silent, and not visible in the transcript. The clear-context case is worse than silent: the endpoint answered
okwhile the agent kept its full history.Wire-contract changes a caller must know about
Called out explicitly because these are observable at the boundary rather than internal:
409 {"error", "code": "turn_in_flight", "busy": [...]}when nothing cleared200 {"ok": false, "cleared": [...], "busy": [...]}ok, not the status: 200 withok: falsemeans some roles were kept503 {"error", "code": "workspace_unavailable"}200whereapi_chat_slot_projectpreviously answered409409as "retry the set": the retry was always going to succeed, so the difference is one fewer round trip, not a different final state. An UNAUTHORIZED rebind still refuses.slot.claim_cwd, which states nothing for a project that was never set, so this covers ONLY a project that was explicitly clearedbypass_cwdin the claim's pool decision.What changed
Four distinct pieces. They are listed separately because they are separable, and the third and fourth are contract changes rather than internal fixes.
1. Claim-time cwd validation (
session_allocation.py,_reacquire_and_validate) — the reuse decision now validates the bound directory at the moment of the claim rather than trusting the caller to state one.2. A retirement-arm subsystem (new:
mark_retire_on_next_claim,note_project_change,RetireArm.agent,spend_retire_arm,discard_all_retire_arms,CWD_CLEARED, plus a per-key generation counter — all 0 occurrences at base). This replaces the base's documented leave-armed-and-retry policy at the consume site, where the base comment argues the opposite ("leaving it armed is always safe"). Two producers exist and are not interchangeable; the distinction is enforced by source-text census tests.3. A
_queue_helddrain-gate unification (state.py,chat_runner.py) — one predicate replaces per-cause booleans across four drain gates. Renames_last_turn_auth_required.4. A channel API contract change —
api_channel_clear_contextmoves from unconditional clear to skip-busy, adding a409 turn_in_flight, and the total-refusal case returns before the shared message buffers are wiped or saved. The refusal surfaces as an in-pageErrorNoticeabove the composer; it carries noaskAgenthand-off, deliberately, because navigating away would destroy an unsent draft in the composer directly beneath it.The unconditional clear was also the only in-band recovery for a wedged member turn, so what bounds such a turn matters. It is bounded, and not by this diff: every ACP prompt resolves its wait from
agent.chat_turn_timeout_secs— default 14400s (4h), clamped to 300s..86400s — applied inacp/session_handle.pyvia_effective_prompt_timeout_asyncand enforced by the transport wait on_turn_done. Channel members are dispatched byhandlers_channel.py's_spawn_agent_task, a barecreate_taskthat adds no ceiling of its own, so that prompt timeout is the whole bound.retry when idletherefore names an event that arrives. Noforceparameter is added: it could only make the refusal disappear by discarding the state of a turn that is still running.Also in this commit, declared
Three changes ride along that the four pieces above do not imply. They are named here so a
reviewer does not meet them as unexplained scope.
channel.py) —postandapi_channel_clear_contextnow share one_log_lock, and the thread-parent resolution happens under it rather than before it. Derivedfrom piece 4: making the clear skip busy members is what put
awaits between the decision towipe and the wipe. Without the lock a concurrent post is acknowledged and then wiped away by
_save(), and a threaded reply can name a parent the wipe already removed.ErrorNoticewarnseverity axis — one consumer,ChannelPage. A withheld clear isnot a failure, so it needed chrome that is not the danger variant.
website/capture/clear-context-busy-refusal.{html,tsx},website/scripts/capture-clear-context-busy-refusal.mjs, and the agent-switch pairwebsite/capture/agent-switch-notice.{html,tsx}withwebsite/scripts/capture-agent-switch-notice.mjs. Evidence harnesses, not shipped surface:nothing in the app imports them, and each frame is written only if its own assertions hold.
The frames are NOT committed at this head, and the earlier claim that they were is withdrawn:
git diff --diff-filter=Aagainst the base returns ZERO image files. They were force-added past.gitignore:100-106, which states that PR review evidence "is uploaded as a GitHub attachment ... never committed", and they were removed for that reason. The embeds above therefore pin fork commit4eed28cec1, which still resolves because that commit persists in the fork, NOT this head -- so they are viewable but are not tree evidence. Every frame regenerates on demand from the committed harnesses (website/scripts/capture-clear-context-busy-refusal.mjs, which carries therowmarksandconfirmsscenes, andwebsite/scripts/capture-agent-switch-notice.mjs). Re-attaching them as GitHub user-attachment assets needs the web uploader: thisgh(2.96.0) has no--attachonpr createorpr editand/pulls/7161/attachments404s, so it is owed to a maintainer rather than automatable here.(extracted from
App.tsxso the real toast is capturable) andwebsite/src/utils/agentSwitchFeedback.ts, the chokepoint that mapsturn_in_flightandworkspace_unavailableto the copy that toast shows. Listed because the 503 wire row aloneimplies a status code, not a rendered surface.
Out of scope, stated explicitly
The arm settle is probe-then-act over a
linked_session_keywritten outsideslot._lock, soa rebind landing after the last pass would leave the arm on the abandoned key. That is closed
at cause here rather than left as a residual.
dashboard/chat_utils.pyadds a synchronousnon-blocking guard:
settling_keyexcludes the settle-and-arm region,bind_linked_session_keyis the single writer and PARKS a rebind arriving inside it, and
key_rebind_deferredreportsone so the settle publishes nothing and retracts its source arm. Deliberately not
slot._lock:it is not reentrant and one transfer already runs inside it, and seven of the eight writers are
synchronous functions that cannot acquire an asyncio lock at all.
All eight assignment sites across five modules route through that single writer --
dashboard/handlers/cron.py:1602,dashboard/chat_persistence.py:1105/:1639/:1647,dashboard/state.py:6609/:6631,dashboard/workflow_inject.py:158,dashboard/cron_inject.py:398. A NINTH surface sets the key without ever naming the attribute:get_or_create_slot(linked_session_key=...), which every channel and cron surfacing passes. Itneeds no guard, because the factory returns an existing slot BEFORE reaching the bind, so it can
only bind a slot it just minted -- where no arm can yet be settling. That is worth stating
rather than assuming: the completeness census covering the other eight matches dotted
assignments and is structurally blind to a keyword, so
test_the_slot_factory_binds_its_keyword_only_when_it_mints_the_slotpins it at runtime andfails if that bind is ever moved above the early return.
Tests
Each new assertion was mutation-verified: the unmutated test passes first, then the guard is removed and the test is confirmed to fail on its own assertion rather than on an error.
Total refusal must not destroy the shared channel log — reverting the 409 to run after the buffer wipe fails on "the shared message log must SURVIVE a total refusal ... got 0".
The refusal carries a machine-readable
code, satisfying the repo's error-code contract ratchet.clearContextBusyMessage(4 cases): names every refusing role, empty when nothing refused or the field is absent, and ignores a non-array value rather than rendering[object Object].Two pre-existing drain leaks, repaired deliberately. Unifying the four drain gates on
_queue_heldalso closes two leaks that predate this change: the synthesis dispatch and the stage handoff never consulted the old_last_turn_auth_requiredflag, so both could drain a queue a gate had withheld. They are named here rather than left implicit because the unification is required by the core fix and reverting only these two sites would leave the new gate deliberately inconsistent across the four.Arm/generation behaviour, the producer census, and the consume-site census. Every session-ending teardown is also enumerated from the module and must declare itself spend-side or keep-side, so a new teardown that classifies itself nowhere fails the guard rather than passing unnoticed.
Reachability of the remaining CI failures, classified rather than dismissed — none is called flaky:
Backend Lint & Type Check (3.12)read cancelled, not failed: the job hit its 15-minute cap whileCheck formatting (black, baselined)was still running, and that step passed. flake8 then ran 87s and emitted nothing, and mypy was skipped. The gate's workload is a fixed("src", "test")scan of 3,394 files, independent of this diff — measured cold-cache locally at 30s at this head versus 29s at the previous one — and the job has been at 13m50s / 14m24s / 15m17s across three consecutive shas. Named for a maintainer rather than worked around, since the cap lives in.github/which a fork PR may not touch.src/test/AppSdkSharedModulesCov80.test.ts(2) andsrc/test/ContextBreakdownPanel.test.tsx(2) fail on an unmodifiedupstream/maincheckout on this host —npx vitest run src/test/AppSdkSharedModulesCov80.test.ts src/test/ContextBreakdownPanel.test.tsx→Tests 4 failed | 16 passedwith none of this diff present. They also passed in CI's shards 1 and 3 at this PR's own head, so the difference is host-side and upstream of this change.test_dashboard_state_ws.py::TestSlotsBroadcastCarriesFoldersandtest_remote_crew_execution.py::...interrupted_roware now ATTRIBUTED rather than left open, and neither is failing. Both suites were run at the merge base28dcab655dfaa50fa3167158097a5ce39ea29c8eon an unmodified detached checkout (verified unmodified: zero occurrences of this branch's markers) and again at head, with the SAME harness and a positive control per suite — an assertion armed inside the exact class or function named, which reported1 failedeach time, so a green run could have failed for the intended reason. Base: 89 and 191 passed. Head: 89 and 191 passed. Trees clean after disarming. Mechanism, not just pass/fail: both suites do reachdashboard/state.py, which this branch modifies, so they are not structurally isolated — but they exercise the slot's FOLDER projection (44 and 3 references tofolders) and carry ZERO references to the three surfaces this branch changes in that class (claim_cwd,project_cleared,linked_session_key). At head all 12 backend check-runs pass exceptBackend Tests (Windows) (4), whose sole failure is an xdist wall-clock bound and whose log names neither test; and neither test appears on a FAILED line across the 14 most recent shas of this branch, under a search positive-controlled against two known failures it does find.Pattern harvest
Rule candidate: a probe followed by a separate act cannot protect a resource whose state can change between the two — so the guard must be the decision itself, taken atomically with the mutation, or a flag the claimant must satisfy. The in-flight cold start is what proves it here: it holds no registry entry, so both probes read it as absent and no amount of probing closes the window.
Rule candidate: an endpoint that reports on work it also performs must answer a refusal BEFORE it mutates shared state. Ordered the other way, the report contradicts the effect — and when the mutation is persisted, the contradiction is irreversible.
Screenshots
Two error states appear below, and they lead differently on purpose: a partial clear leads Context partially cleared, a total refusal leads Not cleared in warn chrome, because a withheld clear is not a failure. Failed to clear context is reserved for a genuine error such as a 500. Leading a partial with the failure title contradicted its own body, which ends by naming what was cleared.
The clear-context controls surface a refusal that was previously swallowed, and no longer destroy a streaming reply to do it. A partial refusal answers 200 with the refusing roles in
busy— a field no caller read, so a "cleared" click silently cleared nothing for those roles. A total refusal answers409 turn_in_flightbefore any shared state is touched.The banner states what was kept and what was cleared, in the page's own vocabulary. Naming only the kept roles let a partial refusal read as a total one, sending the user back through the confirm dialog to re-clear what had already cleared. It also renders in its OWN notice, without the agent hand-off: a clear-context refusal can sit above an unsent composer draft, and the hand-off unmounts the page and destroys it -- the same reason the composer's own failure notice omits it. The channel page's busy badge already says working, so the copy says "still working" rather than introducing "a turn is in flight" for the same state, and
{{roles}}is never the subject of a verb — a comma-joined list of two roles has to read as well as one, which a singular verb cannot do in the translated catalogs. Both the 200 and the 409 render the same catalog string: the 409 is recognised by itscode, not its prose, so the backend's English never lands in a localized page. The surface is anErrorNotice, not a native dialog, and because the per-agent button lives in the agents side panel while the banner sits above the composer, the notice is scrolled into view when it appears.Partial clear-all, two of three roles mid-turn:
The per-agent control, its addressed role refusing:
The 409 total refusal — same localized string, none of the backend's English:
The generic failure path, which already rendered inline before this change and now carries no agent hand-off:
Contrast — nothing refused, so the clear is acknowledged rather than silent:
The agent-switch
503 workspace_unavailablenotice, the other new surface:Each scene captures a light and a dark frame. Each frame is written only if its own assertions hold: the banner carries every refusing role, the kept claim, the cause and the retry; the 409 frame additionally asserts the backend's prose did not leak; and every scene asserts zero dialogs.
Reproduce: