Skip to content

refactor(dashboard): compose the chat handlers from chat_api owners - #16427

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/d02-chat-handlers
Oct 3, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/d02-chat-handlers

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the dashboard chat API easier to read and change safely by moving four endpoint families out of the 15,900-line chat_handlers.py into dashboard/chat_api/ owners, with no change in behaviour.

src/kiro_crew/dashboard/chat_handlers.py held the core chat HTTP endpoints and their helpers in one 840 KB module. A change to resume, close or the slot detail read meant opening and reviewing a file that also holds the send path, every selection transaction and the approval routes.

Why it matters

chat_handlers.py is one of the most edited backend files: more than 60 open PRs touch it. Each of the four families moved here is a cohesive state machine with its own locks and races (the source-link unlink transaction, the bounded transcript page, the resume transaction, the close path). Each can now be read, reviewed and changed on its own, while every caller, route and test seam keeps working unchanged.

Not a goal

What changed (motivation → approach → change)

Four endpoint families leave the 15,900-line chat_handlers.py so each can be read and changed on its own; nothing a caller, route or test sees changes.

Owner (dashboard/chat_api/) Holds
source_links.py the source-link list and the field-scoped unlink transaction
slot_detail.py the slot list, the bounded slot detail page with its durable-prefix and live-window merge, and the context meter fields
resume.py resume_slot_from_history (materialise, hydrate, reconcile) and the resume route
slot_lifecycle.py close_slot and delete, the cleanup sweep, the conversation reset
__init__.py compose, which runs every owner function on the facade's globals

The four families move as whole function bodies. The only edits are comment and docstring rewords the comment-history gate requires on added lines, plus two type: ignore[arg-type] pragmas and their comment in resume_slot_from_history. mypy checks the owner before DashboardState's inferred attributes, so a closure there loses the narrowing of history_key to str. A block-by-block comparison against the base found 44 identical blocks apart from those edits.

chat_handlers.py stays the only import path and the only patch surface. It imports every moved name back, and chat_api.compose (the technique chat_turn uses) rebinds each owner function onto its globals. A patch of kiro_crew.dashboard.chat_handlers.<name> therefore still reaches moved code, records keep that module's logger, and module state (_test_interleave, the lock registries, the in-flight unlink tasks) stays on the facade. Owners import the facade only under TYPE_CHECKING, and never import kiro_crew.acp, kiro_crew.providers or chat_turn.

Read-only tests that pinned moved code by path were widened under coordinator grants to read chat_handlers.py plus the owners, with unchanged thresholds (table below). The error-code baseline and the non-egress redaction registry name the owners, and learn-cron-dashboard.md lists the owners, what stays and where new code goes.

Integration-owner edits. Each widened file is proven by planting a violation in an owner (red) and reverting (green); the re-pinned ceiling fails at 910 and passes at 911:

File Grant Edit
test/test_json_object_body_guard.py R5(d) 3 register rows re-keyed to owners; owner floor
test/test_pending_boundary_consumer_semantics.py R5(d) 4 readers and the guarded-load file re-keyed
test/test_transcript_derivation_seam.py R5(d) plumbing rows re-keyed; owner floor
test/test_incomplete_archive_fails_closed.py, test/test_mid_chain_read_failure_fails_closed.py R5(d) read facade + owners
test/test_ws_event_scoping.py G1(a) two scans read facade + owners; create-count floor
test/test_dashboard_source_link_unlink.py G1(b) hydration site re-keyed to ("resume", ...)
test/test_truncating_save_recreate_order.py G1(c, e) five text pins and the truncating-save list cover owners
test/test_ask_question_roundtrip.py G1(d) both chokepoint scans count facade + owners
test/test_queued_prompt_durability.py G1(e) the "durable": absence check covers owners
test/test_dashboard_chat.py G2 the session-teardown scan covers owners; floor of 2 handler teardown sites
test/test_source_corpus.py G3 blocking-on-loop ceiling re-pinned to the true value: 911 (kept 910, the four chat_api owners that hold async included)
error-code-baseline.json R5(b) chat_handlers.py 45 → 41, chat_api/slot_detail.py 1, chat_api/slot_lifecycle.py 3; total unchanged
src/kiro_crew/security_posture.py R5(c) NON_EGRESS_REDACTION_MODULES + the two owners that call a redactor (resume, slot_detail)

Backwards compatibility

Compatible: every module-level name chat_handlers bound before this change still resolves there as the same object, every route dispatches to the same handler objects, and kiro_crew.dashboard.chat re-exports them unchanged.

Reader: src/kiro_crew/dashboard/chat.py:api_chat_slot_detail -- chat -- re-exports the facade object (test_the_chat_facade_reexports_the_handler_objects)
Reader: src/kiro_crew/dashboard/routes/chat.py:register -- chat -- binds chat., the facade objects (test_every_route_still_dispatches_to_the_facade_handler)
Reader: src/kiro_crew/dashboard/session_control.py:resume_slot_from_history -- chat -- imported from chat_handlers at call time (test_session_control_revive.py)
Reader: src/kiro_crew/dashboard/session_control.py:close_slot -- chat -- imported from chat_handlers at call time (test_session_control.py)
Reader: src/kiro_crew/dashboard/session_transfer.py:_materialise_slot_from_history -- chat -- imported from chat_handlers at call time (test_session_transfer.py)
Reader: src/kiro_crew/dashboard/session_transfer.py:_redact_history_rows -- chat -- imported from chat_handlers at call time (test_session_transfer.py)
Reader: src/kiro_crew/dashboard/chat_threads.py:_reconcile_slot_window -- chat -- imported from chat_handlers at call time (test_chat_handlers_composition_contract.py)
Reader: src/kiro_crew/dashboard/chat.py:api_chat_slots_cleanup -- chat -- re-exports the facade object (test_truncating_save_recreate_order.py)

Tests

  • test/test_chat_handlers_composition_contract.py (new). Contracts no other test pinned, written before the move and green on the base:

    • the bare 404 a delete answers;
    • the app-isolation 404 and its audit;
    • the no_conversation_log refusal on the route and in the core;
    • the resume record fields;
    • the off-loop restore prefetch;
    • the close path's conductor wake (committed drain only).

    Composition checks: every base name and every route still resolves to the facade object; each moved name keeps its base kind and signature; owner functions run on the facade's globals and read no unbound name; a facade patch reaches moved code; the import edges hold. A corpus-derived scan shows no owner captures a name tests rebind. A pinned list of constructs and calls that guards read only in chat_handlers.py (the turn dispatch, the peer calls and their gate, the pick chokepoint, the permission-resolution and approval-mode sites, the queue clear, the three baselined imports) appears in the facade and in no owner, and no owner reads a harness identity. Every other test that reads chat_handlers.py by path or source was swept for reach, and each one that lost reach is widened above.

  • 24 mutation proofs, one per widened guard plus the new contract checks: planted in an owner → red, reverted → green.

  • Manifest at the first base (fae38c3c4, 170 files: 10,187 passed) and at this head (manifest + guards: 11,606 passed, 1 skipped, 5 xfailed, 0 failed). local-gate.py --dry-run selects 1,334 backend and 374 frontend files, so the targeted manifest ran instead (SD14).

  • Per-file line coverage on the manifest: resume 82.3%, slot_detail 81.1%, slot_lifecycle 88.5%, source_links 93.9%, __init__ 98.3% (floor 80).

Manual verification

N/A — no user-visible change. A wheel built from this tree ships kiro_crew/dashboard/chat_api/*. An installed-mode import composes the owners and registers the same handler objects.

Related Issues

Part of #16536

Campaign refactor scope D02; follows #16224 (chat runner, merged as 139de6e). Duplicated compose helper: #16231.

Follow-up candidates (stay in the facade; the pin that holds each):

  • api_chat — test_crew_log_emit and test_queued_prompt_durability read the facade module source; test_chat_turn_timeout_consistency, test_remote_crew_doc and test_decisions_model_route_app_actor read the facade by path.
  • agent, model, effort, workspace and bulk-model selection — test_remote_crew_execution counts four pick calls in the facade source; test_decisions_model_route_apply slices api_chat_slot_model from the facade file; test_ask_question_roundtrip counts reset call sites.
  • stop and interrupt — test_session_control_doc, test_remote_crew_execution, test_stop_turn_boundary_mirror.
  • mode and approval — test_approval_modes_enforcement WRITERS, the approval_resolved producer count in test_ws_event_scoping.
  • summary — session-summary.md names its routes in this file (R3).
  • slot create and reload — test_start_priority reads api_chat_slot_create and reload_slot_session by function name in this file; the reload route stays beside its core.

Docs that still cite chat_handlers.py for a moved symbol (owner in brackets), for one docs-sync follow-up:

  • docs/feature-map/README.md rows 68 and 74 (the slot list, chat_api/slot_detail.py), 95 (source links, chat_api/source_links.py) and 117 (api_chat_slot_detail, chat_api/slot_detail.py);
  • docs/system-specs/modules/learn-cron-dashboard.md:2439 (AutoNudge row, the nudge restore after a failed close, chat_api/slot_lifecycle.py);
  • rfc-session-tag-change-event.md:288,303 (the tag restore, chat_api/resume.py) and rfc-issue-radar-crews.md:537,621 (the idle cleanup threshold, chat_api/slot_lifecycle.py);
  • rfc-transcript-section-markers.md:72,80,89,605,621 (the conversation reset) and rfc-perpetual-agent.md:526 (the close path's question release), both chat_api/slot_lifecycle.py; rfc-resumable-subagent-sessions.md:107 (the resume route, chat_api/resume.py);
  • src/kiro_crew/dashboard/session_memory.py:239 and test/test_session_memory.py:88 (chat_api/resume.py).

Dotted cites that still resolve through the facade: learn-cron-dashboard.md:3525 (chat_handlers._hydrate_slot_from_history), history.md:1658 (chat_handlers._reconcile_slot_window), instances.md:1935 (chat_handlers._slot_still_ours), session-control.md:1507 (chat_handlers.resume_slot_from_history), rfc-crew-log-wake.md:94 and :177 (chat_handlers.close_slot).

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@bolichen97
bolichen97 requested a review from a team as a code owner October 3, 2026 08:08
@bolichen97
bolichen97 requested a review from buluoray October 3, 2026 08:08
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 68549f5c8e647e573fb5fe4840341be1626d98bc — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Make sure the bytecode-sweep contract test runs in the required CI lane: owner modules' own imports are inert, so only that test catches an unbound name.

[DESIGN-REVIEWED] 68549f5

Description read

[DESCRIPTION-READ] 55bd2ae13a8b14b72c13cadc37fe14a193267baaa1235c6d26e64abe70aebf0c

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

Premise-level review of 68549f5c8e647e573fb5fe4840341be1626d98bc — 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

chat_api.compose is a third copy of chat_turn.compose. Apart from its docstring it is byte-identical, so the split doubles a mechanism that already exists.

Not justified as shipped

What this change ships

Inventory (6 items) — 5 justified

Intent: make the chat API endpoints easier to review and change by splitting the 15,900-line handlers file, with no behaviour change. This is a refactor (neither FIX nor ADDITION).

  1. Source-link list/unlink code now lives in chat_api/source_links.py — justified
  2. Slot list/detail page code now lives in chat_api/slot_detail.py — justified
  3. Resume transaction now lives in chat_api/resume.py — justified
  4. Close/delete/cleanup/reset now live in chat_api/slot_lifecycle.py — justified
  5. New chat_api.compose rebinds owner functions onto the facade's globals — duplicate of chat_turn/__init__.py:compose
  6. Read-only guard tests, the error-code baseline, the redaction registry and the corpus ceiling now count the owner files — justified

[FIRST-PRINCIPLES-REVIEWED] 68549f5

Description read

[DESCRIPTION-READ] 2de91264df25c456d71387a730bfc96d28cf8d7d447e706745d7c3b2b863c51e

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

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 68549f5c8e647e573fb5fe4840341be1626d98bc — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 68549f5

Verdict parsed from the review's SHA-scoped output markers for commit 68549f5c8e647e573fb5fe4840341be1626d98bc.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 68549f5c8e647e573fb5fe4840341be1626d98bc: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 68549f5c8e647e573fb5fe4840341be1626d98bc and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 68549f5

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 68549f5c8e647e573fb5fe4840341be1626d98bc: <one-sentence reason>

@bolichen97

Copy link
Copy Markdown
Contributor Author

accepted-and-deferred: this PR's frozen Not-a-goal excludes it ("Removing the duplicated compose helper ... hoisting it is tracked in #16231").
Why a copy and not an import: chat_api may not import chat_turn.compose, because only chat_runner imports a chat_turn module (D01's pinned boundary). A shared helper means editing chat_turn/ and slack/gateway_runtime/, which are owned by other scopes and outside this PR's claim.
The copy adds nothing to reconcile: chat_api.compose, _functions_of and _rebind are AST-identical to chat_turn's once docstrings are stripped, so the #16231 hoist replaces it with one import, the same as for the other two copies.
Tracking: issue #16231 (labels deferred-finding and refactor, assignee bolichen97, with a Due: line) owns the hoist; chat_api becomes its third call site.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 3, 2026 15:10
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 3, 2026
dashboard/chat_handlers.py held the core chat HTTP endpoints and their
helpers in one 15,900-line module. Four endpoint families move into
owners under dashboard/chat_api/: source links (list and unlink), slot
detail (the slot list, the bounded transcript page and the context
meter), resume from History, and the slot lifecycle after create (close
and delete, the cleanup sweep, the conversation reset). The bodies move
unchanged apart from comment and docstring rewords the comment-history
gate requires and two mypy pragmas in resume_slot_from_history.

chat_handlers.py stays the only import path and the only patch surface.
It imports every moved name back, and chat_api.compose runs each owner
function on its globals, so a patch of chat_handlers.<name> still
reaches moved code, logs keep the chat_handlers logger, and module state
stays on the facade. The send path, slot create and reload,
stop/continue/interrupt, the selection transactions, mode and approval,
context and note, and summary stay in the facade, as does the code that
read-only guards pin to that file by path or function name.

The guards that read the moved code by path now read chat_handlers.py
plus its chat_api owners, with unchanged thresholds, and the
source-corpus blocking-on-loop ceiling is re-pinned to its true value.
The error-code baseline, the non-egress redaction registry and the
dashboard module list in learn-cron-dashboard.md name the owners.
@bolichen97
bolichen97 force-pushed the refactor/d02-chat-handlers branch from 3563d38 to 68549f5 Compare October 3, 2026 15:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

accepted-and-deferred. This PR's frozen Not-a-goal excludes this: "Removing the duplicated compose helper ... hoisting it is tracked in #16231".
The suggested subtraction is the #16231 task, not something this PR can do: it moves chat_turn.compose into a neutral dashboard module. That means editing chat_turn/__init__.py and adding a module outside chat_api/, both outside this PR's claim (D01 owns chat_turn/).
The copy adds nothing to reconcile: its compose, _functions_of and _rebind are AST-identical to chat_turn's with docstrings stripped. When the hoist lands, chat_api/__init__.py drops all three for one import, as chat_turn and slack/gateway_runtime will.
Tracking: issue #16231 (labels deferred-finding and refactor, an assignee and a Due: line) owns the hoist, and chat_api is its third call site. The same answer was given on 3563d38 for span 281a6005a952.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 3, 2026

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

Verdict: APPROVE

Reviewed at head 68549f5c8e647e573fb5fe4840341be1626d98bc (diff base 44ea05c0ed). I did not run the full suite. CI on this head, latest run per check: 83 success, 12 skipped, 0 failure. The two earlier Issue Gate failures and the cancelled GPT 6.1 Review were superseded by green re-runs. Auto-merge is ON and no human review has been posted yet.

Blocking

None.

Non-blocking follow-ups

  1. Third compose copy. chat_api/__init__.py:compose is the same as chat_turn/__init__.py:compose except for the docstring (the first-principles bot raised this, and I checked it). The author deferred it to #16231 with a stated reason (the chat_turn import fence). Behaviour is correct, so this does not gate. #16231 should hoist it into one neutral module.
  2. Log record location changes. Records emitted by moved code keep the kiro_crew.dashboard.chat_handlers logger name. Their module, filename and lineno now name the owner file. The PR discloses this. Anything that greps logs by filename=chat_handlers.py will stop matching those records.
  3. Class __module__ changes. _DurablePrefixMismatch and _NudgeRetireFailed now report __module__ as their owner module, not chat_handlers. Identity is unchanged, so except chat_handlers._X still catches them. Only reprs and pickling by reference differ. The PR body says "every name … the same object" (true), and the chat_api docstring states the class caveat.
  4. Reference cycle in compose. _swap calls itself recursively through its own closure cell, so the rebound dict (the pre-rebind originals) is reference-cyclic. It lives until the next GC pass and is then collected (verified: zero stale originals after gc.collect()). This happens once at import and is harmless. A del _swap or an iterative unwrap would make it collect immediately.
  5. Stale doc cites. The PR body lists the docs that still cite chat_handlers.py for moved symbols (feature-map rows 68/74/95/117, learn-cron-dashboard.md:2439, several RFCs, session_memory.py:239). They should land in the planned docs-sync follow-up.

What I verified

#16020 priority-queue wiring (merge 1423dfbf17):

  • 1423dfbf17 is an ancestor of this head. The PR does not touch chat_runner.py, chat_threads.py, request_priority.py or start_priority.py.
  • I replayed all 291 distinct added lines of #16020 across those files plus chat_handlers.py against the head (facade + chat_turn/* + chat_api/*). Zero lines are missing.
  • The wiring is intact at head:
    • chat_runner.py:5707 (_turn_start_priority), :7487 (_turn_priority), :9145, :17259, :17832;
    • chat_handlers.py:2576, :6125, :8521 (schedule_eager_spawn(..., start_priority=owner_start_priority(request)));
    • chat_threads.py:727, :965.
  • Counts in base chat_handlers.py vs head (facade + owners) are equal: schedule_eager_spawn 5/5, owner_start_priority 4/4, _eager_spawn 7/7.
  • test/test_start_priority.py and the contract file: 222 passed.

Nothing dropped or altered:

  • AST inventory of base chat_handlers.py vs head facade + 4 owners, with docstrings stripped and comments not in the AST:
    • all 178 top-level defs, classes and name assignments are present;
    • 0 bodies differ in code. Three moved definitions (_same_persisted_body, _is_answered_permission, api_chat_slot_reset_conversation) differ only in docstring/comment wording ("no longer" -> "does not"), confirmed by diffing their source segments;
    • 0 names are defined twice;
    • the only new defs are compose, _functions_of and _rebind.
  • No module-level side-effect statement was lost: the base has one (if TYPE_CHECKING:), and the head adds only the compose(...) call. No import was dropped from the facade.
  • Owners have no non-constant default args. The only decorator is @contextlib.asynccontextmanager on a nested function created at call time, which therefore runs on rebound globals.
  • Same inventory on git merge-tree origin/main HEAD: the merge is clean, again 0 missing and 0 changed against current origin/main. Four main commits since the base touched chat_handlers.py; none changed a moved body.
  • Runtime probe (file under scratch) importing the composed facade:
    • all 43 owner functions and methods have __globals__ is chat_handlers.__dict__;
    • every LOAD_GLOBAL they read (including nested code objects) is bound on the facade or in builtins;
    • every top-level facade binding of a moved name is the rebound object;
    • after gc.collect() no un-rebound original survives anywhere, so no registry or container captured a stale copy.

Auth, owner, app-isolation and CSRF:

  • The moved bodies are AST-identical, so the in-handler checks are unchanged. That covers api_chat_slot_delete app-ownership (slot_lifecycle.py:1003) and _check_slot_app_ownership / _reauthorize_after_await in the source-link unlink (source_links.py:267,391,451,713). It also covers is_owner_dashboard_request in the slot list (slot_detail.py:68).
  • Symbol counts base → head: is_owner_dashboard_request 18/18, app_isolation 30/30. The +1 on _check_slot_app_ownership and _reauthorize_after_await comes from owner import lines.
  • CSRF and token auth are middleware-level. routes/, chat.py, origin.py and token_auth.py are untouched by the diff.
  • security_posture.NON_EGRESS_REDACTION_MODULES adds chat_api/resume.py and chat_api/slot_detail.py, the two owners that call a redactor. The error-code-baseline.json total is conserved (45 → 41 + 1 + 3).

Mutations (each reverted; git status --short clean after each). All were run against test/test_chat_handlers_composition_contract.py:

Mutation Result Tests that went red
compose made a no-op 11 red test_every_owner_function_runs_on_the_facade_globals, test_a_patch_of_the_facade_reaches_an_owner_function, test_compose_rebinds_functions_and_class_members, test_a_second_facade_import_recomposes_the_owners_onto_it, test_every_global_an_owner_function_reads_is_bound_on_the_facade, test_an_app_cannot_delete_a_slot_it_does_not_own[foreign/unscoped], test_resume_* ×2, test_the_handover_exit_wakes_the_conductor_* ×2
Owner function reads a name bound only in its owner (_OWNER_ONLY_FLAG in _slot_still_ours) 1 red test_every_global_an_owner_function_reads_is_bound_on_the_facade
App-ownership check in api_chat_slot_delete neutered (slot_lifecycle.py:1003 → if False and …) 2 red test_an_app_cannot_delete_a_slot_it_does_not_own[foreign], [unscoped]

Fail-open / fail-closed:

  • The one new runtime mechanism is compose. If it is wrong, an owner function reads its own module's globals. That fails open for test reach (a patch would miss the moved code) and for unbound names (a NameError at request time). Both are pinned by the contract tests above.
  • No new error path or refusal was added to production logic.

@bolichen97
bolichen97 merged commit f33b103 into main Oct 3, 2026
113 of 116 checks passed
@bolichen97
bolichen97 deleted the refactor/d02-chat-handlers branch October 3, 2026 20:44
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
jcjaskula-aws added a commit to jcjaskula-aws/KiroCrew that referenced this pull request Oct 3, 2026
Serialise both favourite writes under one lock. Each is a read-modify-write
of one file on a worker thread, so two dashboard tabs writing at once would
each write back the snapshot they read and one change would be lost.

Resolve the path off the event loop. realpath and the sensitivity check both
walk the filesystem, and on a stalled network mount either would freeze every
request and the heartbeat; the add handler now hands all three probes to one
worker-thread call.

Drop the 100-entry cap and its 409. Both write verbs are owner-gated, so the
bound had no caller to defend against, and a list curated by hand should not
refuse an entry. This also removes a raw `favorites_full` code the write
notice could have shown.

Give the write-failure notice the same agent hand-off decision as its sibling
read notices: on when the mount opts in through errorHandoff, closing the
popover as it hands off.

Move the Browse pane's favourite toggle out of the Back / Select row onto a
row of its own, with its action as visible text, so the row keeps two
controls and the toggle explains itself without a tooltip.

Make the remove test portable: a bare "/a" exists on GitHub Windows runners,
whose workspace root is D:\a. Replace the capture fixtures' home-directory
paths with a neutral /home/dev tree, and add a Browse scene to the capture.

A favourites file that exists but cannot be read -- a hand edit with a
trailing comma, a permission change -- read as an empty list on every
path, so the next star click wrote back that empty snapshot plus one
entry and replaced the user's whole list. Unlike the recents window it
cannot be rebuilt. The write paths now load strictly: an unreadable file
raises, both write verbs answer 409 favorites_unreadable naming the file,
and nothing on disk is touched. The display read stays tolerant.

An opening favourites read that answers after a star write landed no
longer publishes its older list over the write's; it still settles the
landing tab, which waits on it.

Register the three favourites routes in the route-composition contract
that kirodotdev#16427 added after this branch was cut. Add capture scenes for the
favourites read failure, a refused write, and Browse on a directory that
is already a favourite.
jcjaskula-aws added a commit to jcjaskula-aws/KiroCrew that referenced this pull request Oct 3, 2026
Serialise both favourite writes under one lock. Each is a read-modify-write
of one file on a worker thread, so two dashboard tabs writing at once would
each write back the snapshot they read and one change would be lost.

Resolve the path off the event loop. realpath and the sensitivity check both
walk the filesystem, and on a stalled network mount either would freeze every
request and the heartbeat; the add handler now hands all three probes to one
worker-thread call.

Drop the 100-entry cap and its 409. Both write verbs are owner-gated, so the
bound had no caller to defend against, and a list curated by hand should not
refuse an entry. This also removes a raw `favorites_full` code the write
notice could have shown.

Give the write-failure notice the same agent hand-off decision as its sibling
read notices: on when the mount opts in through errorHandoff, closing the
popover as it hands off.

Move the Browse pane's favourite toggle out of the Back / Select row onto a
row of its own, with its action as visible text, so the row keeps two
controls and the toggle explains itself without a tooltip.

Make the remove test portable: a bare "/a" exists on GitHub Windows runners,
whose workspace root is D:\a. Replace the capture fixtures' home-directory
paths with a neutral /home/dev tree, and add a Browse scene to the capture.

A favourites file that exists but cannot be read -- a hand edit with a
trailing comma, a permission change -- read as an empty list on every
path, so the next star click wrote back that empty snapshot plus one
entry and replaced the user's whole list. Unlike the recents window it
cannot be rebuilt. The write paths now load strictly: an unreadable file
raises, both write verbs answer 409 favorites_unreadable naming the file,
and nothing on disk is touched. The display read stays tolerant.

An opening favourites read that answers after a star write landed no
longer publishes its older list over the write's; it still settles the
landing tab, which waits on it.

Register the three favourites routes in the route-composition contract
that kirodotdev#16427 added after this branch was cut. Add capture scenes for the
favourites read failure, a refused write, and Browse on a directory that
is already a favourite.

Reword the favourites read-failure notices: "Pick a project from Recent or
Browse" could be read as an instruction to star a folder or switch tabs.
They now say "Use Recent or Browse.", which can only mean the tabs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants