Repository navigation
refactor(slack): split interactions.py and events.py into owner modules - #22079
Conversation
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check before merge: [DESIGN-REVIEWED] 27859f4 Description read[DESCRIPTION-READ] b0933635410edd38f7893afd26fac546a56cbfb8d85dbc6f6a6ed359141afd80 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that What this change shipsInventory (8 items) — 8 justifiedIntent: bring two Slack modules under the 2,000-line cap that AGENTS.md mandates, without changing behaviour. This is a FIX (a refactor).
[FIRST-PRINCIPLES-REVIEWED] 27859f4 Description read[DESCRIPTION-READ] f5365a6bbb50c3a803347c234a1694a33570be89f703814e7e008a432ae9aa34 That sha256 names the PR description this verdict read. Recompute it with |
Sensitive change review
|
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
|
Disposition: rebutted (checked; the allowlist is exact)
|
|
Disposition: rebutted (checked; no stale binding exists)
|
cd15878 to
762986d
Compare
|
Disposition: rebutted (the boot path is exercised; a live Slack click is out of reach here)
|
|
Disposition: rebutted (the description names both files)
|
|
Disposition: rebutted (facade reads are live, not install-time)
|
|
Disposition: rebutted (checked; the boot path writes all six owners)
|
|
HOLD at 27859f4. The code reads as sound and I would approve it, but one Sensitive Change Review run failed on this head (run 39354504086); I re-ran it. Once that clears, a fresh look can approve it. — crew-pr-reviewer (r114) |
iamwhatever
left a comment
There was a problem hiding this comment.
Approved at 27859f4e5a984d65564975559c8cee928bf765b0.
The r112 blocker (the conflict) is gone. By AST against the merge base, all 81 events.py units and 76 of 77 interactions.py units reappear unchanged in one owner each. The exception is init, which now writes _orch through the mirror facade (interactions.py#L117), so the facade and all five owners that import _orch get the orchestrator. Every owner import resolves to the same source as before. The only global rebinds stay with their readers in events_home_tab.py. The six new NON_EGRESS_REDACTION_MODULES rows (security_posture.py#L2639-L2649) are exactly the owners that call a redactor, and no row is dropped. Both lane punchlines on this head are answered.
One CI note: the newest Sensitive Change Review run on this head failed with "Could not read the PR from the API ... re-run this job". That is an API read error, not a code failure. The same check passed on this head earlier, and PR Readiness passed after it. A rerun should clear it.
I read the code and CI but did not run the tests.
— crew-pr-reviewer (r114)
The Sensitive Change Review re-run passed on this head; auto-merge waits for the required PR Readiness check.
Problem / Motivation
Goal: Bring
slack/interactions.py(3,892 lines) andslack/events.py(3,718 lines) under the 2,000-line cap without changing what either does, so new Slack interaction and event-routing work lands in modules sized for it.Both files are past the repository's 2,000-line cap for hand-written files and are listed in
.github/file-line-cap-baseline.txt;events.pyhad already grown 33 lines past its row. Every Block Kit handler (tool approvals, OPTIONS, session controls, the settings modals, review drafts) shares one file, and every slash command, the Home tab, the block-text recovery, the session queue and the message router share the other.Why it matters
A file over the cap makes every feature PR that touches it grow a baselined file, which the line-cap guard reports and the campaign must later undo. Both files are edited every week (
events.pytook 6 commits in the 7 days before this branch).Not a goal
kiro_crew.slack.eventsandkiro_crew.slack.interactionsoffer, or to how a test patches them._route_messageordispatch: each stays one function._route_message: the router stays inevents.py, so the alert stays where it is.What changed (motivation → approach → change)
Each file becomes a mirror facade (
kiro_crew._facade_mirror, the shapecli_server.pyandmcp_shared.pyuse) over sibling owner modules. The facade keeps every line of its import header, adding only the mirror's glue imports, keeps the code that sits on top (and, ininteractions.py, imports the owner names that code reads), imports its owners, and serves every name they define, sokiro_crew.slack.events.<name>andkiro_crew.slack.interactions.<name>resolve as before, and amonkeypatch.setattrormock.patchthrough the facade reaches every module that holds the name.interactions.py3,892 → 874init,dispatch,_handle_resume_choice(with_resume_locksand_RESUME_TAB_CLOSED_MSG)interactions_context.py160 (the_orchslot, the view registry, the acknowledge buttons),interactions_modals.py592,interactions_settings.py561,interactions_options.py853,interactions_sessions.py682,interactions_approvals.py511events.py3,732 → 1,516init_socket_mode,_route_messageevents_block_text.py456,events_queue.py380,events_slash.py821,events_home_tab.py442,events_voice.py188,events_inbound.py279_handle_resume_choicestats the session file inside itsasync def, a call the sync-io gate's fs baseline records againstinteractions.py, so it stays there withdispatch, its one caller; the facade imports, in owner order, the 35 owner names those two read. Every interactions owner reads_orch, and aglobalrebind ininit()would reach only the facade's namespace.initstays in the facade and writes it through the facade (setattr(_sys.modules[__name__], "_orch", orchestrator)), so the mirror sets it in the facade and every owner; that is the one edited line of code. The owners log under their facade's name; the slash-command and view-callback registrations run at import beside their handlers, in the original order (the Forward to Agent submission is registered byinit(), as before). Theslack-gatewayspec gains an owner map; registries keyed by path follow the moved code; and the facades get per-file F401 ignores insetup.cfg, backed by import inventories.Backwards compatibility
Compatible: every name either module bound before the split still resolves on it and is the same object (
test/campaign_facade_inventories/kiro_crew.slack.interactions.json,kiro_crew.slack.events.json), and a patch through either facade reaches every owner holding the name (test_interactions_facade.py,test_events_facade.py,test_facade_mirror_guards.py).The take-away check flags the public defs that moved to owners; each is still served by its facade:
Reader: src/kiro_crew/slack/gateway_runtime/service_boot.py:run -- chat -- its function-local
from kiro_crew.slack.events import SeenCache, init_socket_modeandfrom kiro_crew.slack.interactions import initresolve through the facades (test_slack_gateway_run.py)Reader: src/kiro_crew/slack/interactions_sessions.py:_handle_stop_confirm -- chat -- its function-local
from kiro_crew.slack.events import _entry_owner, slack_stop_in_flightresolves through the events facade, which serves slack_stop_in_flight from events_queue (test_stop_clears_only_its_own_sender_slack.py)Reader: src/kiro_crew/slack/interactions_sessions.py:_handle_inline_stop -- chat -- the same facade import of slack_stop_in_flight (test_slack_inline_stop.py)
Reader: src/kiro_crew/slack/events_slash.py:register_slash_command -- chat -- the ten sub-command registrations run beside it at import, in the original order (test_events_facade.py)
Reader: src/kiro_crew/slack/interactions.py:init -- chat -- the facade binds register_view_handler from interactions_context for the forward shortcut (test_interactions_facade.py)
Reader: src/kiro_crew/slack/interactions.py:dispatch -- chat -- reads handle_view_submission and handle_view_closed as facade globals bound from interactions_modals, so a facade patch reaches it (test_slack_interactions_coverage.py)
Reader: src/kiro_crew/slack/interactions_sessions.py:_handle_stop_confirm -- chat -- calls ack_button from interactions_context, the object the facade serves (test_slack_interactions_coverage.py)
Move audit
move_audit.py --base <merge-base> --head <this head>:init(7 lines):global _orch/_orch = orchestratorbecamesetattr(_sys.modules[__name__], "_orch", orchestrator)with a comment. This is the one code edit, granted by the campaign Master.events.py's module docstring (theExprunit): its sentence about the dedup cache now says the cache lives inevents_inbound; prose only.interactions_modals.py"Used to neutralize" -> "It neutralizes" (comment-history gate).events.py(a file the black baseline lists) in the new owners, which must be black-clean; the AST is unchanged.events.pyitself keeps its unformatted router and stays in the black baseline.L36 parity (default diff vs
--minimal, identical+lines): 52 of the 53 changed files are equal,events.py100/2316 both;interactions.pyis covered by the L41 exception the campaign Master granted for it (below). Diff size: 693,971 bytes.L41 exception,
src/kiro_crew/slack/interactions.py: the default diff adds 129 lines,--minimal101. The default diff re-shows new-file lines 581-620 (27 non-blank lines:_resume_locks, the_RESUME_TAB_CLOSED_MSGassignment and the first 22 lines of_handle_resume_choice, throughif not session_key: return) and the blank line 822. All are byte-identical kept code: the start of the kept run that follows the 1,818-line deletion betweendispatchand the resume choice. No added-line gate token is on them, every added-line gate passes on the default diff, and neither fs call of the resume choice is among them. Layout search (default/minimal, difference):dispatch(one per line / grouped)_resume_locks(one per line / grouped)import kiro_crew._facade_mirror asvsfrom kiro_crew import_handle_session_resume(three placements)_handle_resume_choice(three placements)dispatchleft in an owner (not runnable: it would need the facade)Tests
test/test_interactions_facade.py,test/test_events_facade.py(new, 65 tests): the test trees' patch targets through each facade reach every module holding the name (with a non-vacuity scan of known seams); the owner list, its layering and that no owner imports its facade; thatdispatchand the resume choice stay in the facade;initwrites_orchinto the facade and every owner, a secondinitrebinds them all, and a patch ofinteractions._orchreaches each of them; each runtime-rebound global (_skills_loader,_home_tab_collect_sem) lives with its writer and every reader; a fresh import registers the view callbacks and the ten slash commands in the original order, each as the function the facade serves; every owner imports on its own, before its facade; every BASE public name and every served name type-checks through the facade; the owners log under the facade name; and the import inventory that stands in for F401: an import is accounted for when the module had it before the split, when it is the glue's own or names what its owner defines, or when the family's own code reads it; a planted self-test shows an import nothing reads, and an owner import of a name that owner does not define, both fail, while an import a kept function reads passes. They pin the BASE names, registrations and rebound globals as subsets, never as an exact namespace, so a later addition to either facade does not trip them.test/test_interactions_approvals.py,test/test_interactions_options.py(new, 68 tests): the native tool-approval press, the review-draft handlers' refusals and cleanups, the auth-denied ephemeral, the revise turn; the OPTIONS click and submit paths, stale-control refusal, theaction::payload cap and the thread-to-dashboard import. They bring both owners from 78.9% and 81.2% to 100% line coverage.test/campaign_facade_inventories/kiro_crew.slack.events.json,kiro_crew.slack.interactions.json(new): every public name each module bound at BASE still resolves, and each re-bound import is its home's object (check_inventory.py: 94/94 and 71/71).read_textscan; the Stop handlers' owner scoping; therun_config_writefloor (an interactions and an events owner);config_dirin an async owner;remaining // 60; theperson_priority(notcount; the restart's SEL and log drains; eachNON_EGRESS_REDACTION_MODULESrow the change touches or keeps (the facade's included); the log-site census; theinitwrite (reverted to a facade-localglobal); that the resume choice stays in the facade; and that the facade holds_orch. With the six owner boot-smoke rows removed,test_a_second_boot_touches_only_known_module_globals(KIROCREW_INTEGRATION=1) lists exactly those six keys whenever the second boot reachesinit(three of five runs).-n0and one at-n 3, all green.test_flake_pattern_ratchet.pyandtest_wait_discipline_ratchet.pypass.-n 3(the 399 below plus the skill-usage, restart, exit-path and sync-io gate tests): 22,207 passed, 48 skipped, 0 failed.local-gate --dry-runselects 1,565 backend and 640 frontend files (SD14), so the floor is every test file naming either module or an owner, everytest_slack*file, every corpus gate that mentions slack, the mirror, the redaction registries or the patched writers, and every test that reads, by path or name, a file whose comment this PR re-points.src/kiro_crew: no issues in 3,332 files. isort (isort --check-only src/kiro_crew test conftest.py xdist_budget.py), flake8 and black clean. Comment-history, brand, harness-parity, black, subprocess-encoding, agent-sdk, sync-io, memory-store, feature-map and line-cap gates,docs_lint.pyand woke 0.19 on added lines: clean. Semgrep 1.78 with the CI configs and--baseline-commit <merge-base>over all 46 changed code and JSON files: 0 findings, 0 errors.events_block_text99.2%,events_queue97.6%,events_slash98.5%,events_home_tab92.5%,events_voice100%,events_inbound97.9%,interactions_context100%,interactions_modals98.0%,interactions_settings97.3%,interactions_options100%,interactions_approvals100%; the facadeevents.py98.5% (floor 80%). Re-measured at this head over the 26 floor files that name the interactions family:interactions.py91.6% (it holdsdispatchand the resume choice),interactions_sessions87.8%,interactions_context100%,interactions_modals98.0%,interactions_settings97.3%. The two files fix(slack): spool the pre-ingestion message, not temp paths and file bodies #21829 changed, re-measured at this head over the 16 Slack event, queue and stop test files alone:events_queue96.9%,events.py95.8%.CI path references
None: no workflow path filter or workflow file list names either file, and
AUTOSDE.yaml'ssrc/kiro_crew/slack/**/*.pyrule already covers the owners. The.githubbaselines that list them are covered under Move audit and Re-pointed source pins.Re-pointed source pins (L30)
Assertions unchanged; each has a mutation that turns it red (listed under Tests). Line numbers are this head's.
test/test_stop_clears_only_its_own_sender.py:682-683:("slack", "interactions.py", ...)->interactions_sessions.pyfor_handle_stop_confirmand_handle_inline_stop(theevents.py/_route_messagerow is unchanged: the router stays).test/test_sel_hard_exit_flush.py:432_PATHS:slack/events.py->slack/events_slash.py(_handle_restart).test/test_options_click_validation.py:264,289:inspect.getsourceof the facade and every_OWNERSmodule.test/test_slack_sessions_view.py:1548: the AST of the facade and every owner.test/test_start_priority.py:1068,test/test_sel_hard_exit_flush.py:252,test/test_cli_logging.py:1019:slack/events.py-> everyslack/events*.py.test/test_run_config_write.py:37_SLACK_SOURCESandtest/test_safety_override.py:1259: the owner file names beside their facades.test/test_no_config_dir_in_async.py:151-156_ASYNC_CHECKED_FILES: the six interactions owners.src/kiro_crew/security_posture.pyNON_EGRESS_REDACTION_MODULES(:2639-2640,:2646-2649): besideslack/interactions.py, which keeps the calls indispatchand the resume choice, its four owners that hold redactor calls;slack/events_home_tab.pyandslack/events_slash.pybesideslack/events.py, which keeps the router's calls.test/test_security_posture.py:295-298_BASELINE_LOG_SITE_CENSUS:slack/events.py: 2->slack/events_home_tab.py: 1,slack/events_slash.py: 1.test/integration/test_boot_smoke.py:460-465_KNOWN_SECOND_BOOT_CHANGES: beside("kiro_crew.slack.interactions", "_orch"), which stays, the six owners that hold_orch. With those six rows removed, the second-boot witness lists exactly those six keys as unexplained.Citation edits (L29)
Only the cited path changes; none of these files is a split target of a live scope.
docs/system-specs/modules/slack-gateway.md:171-172Files rowsslack/events.py,slack/interactions.py-> the same rows plus "the import path and patch surface of theevents_*/interactions_*owners", and a new "Event and interaction owners" section at:424docs/system-specs/modules/slack-gateway.md:1050#### Slash Command (events.py)->(events_slash.py)docs/system-specs/modules/slack-gateway.md:1173"review-mode draft (interactions.py)" -> "(interactions_approvals.py)"docs/system-specs/modules/slack-gateway.md:1183"the inline Stop button ininteractions.py" -> "ininteractions_sessions.py"docs/system-specs/modules/slack-gateway.md:1202"_handle_sessionsinevents.py" -> "inevents_slash.py"docs/system-specs/modules/slack-gateway.md:1216interactions.py:_handle_session_resume->interactions_sessions.py:_handle_session_resumedocs/system-specs/modules/slack-gateway.md:1232interactions.py:_handle_session_end->interactions_sessions.py:_handle_session_enddocs/system-specs/modules/slack-gateway.md:1307"_resolve_approval_mode(orch)(events.py)" -> "(events_queue.py)"docs/system-specs/modules/slack-gateway.md:1312events.py:_resolve_approval_mode()->events_queue.py:_resolve_approval_mode()docs/system-specs/modules/slack-gateway.md:1515"ack_button()helper ininteractions.py" -> "ininteractions_context.py"docs/system-specs/modules/config.md:1485slack/interactions.py->slack/interactions_modals.py(the voice-config submission)docs/system-specs/modules/session.md:3325"Slash commands (slack/events.py)" -> "(slack/events_slash.py)"docs/guides/remote-and-mobile.md:656"ttl = 3600inslack/events.py" -> "inslack/events_slash.py"docs/architecture/resource-protection.md:40"session_parts/claims.pyplusslack/events.py" -> "plusslack/events.py,slack/events_queue.pyandslack/events_inbound.py"src/kiro_crew/config/validation.py:75(comment)slack/interactions.py->slack/interactions_modals.pytest/test_config_core_owned_sections.py:4(docstring)slack/interactions.py->slack/interactions_modals.pytest/test_sel_hard_exit_flush.py:214and:407(docstrings)slack/events.py->slack/events_slash.pytest/test_cli_logging.py:1003(docstring)slack/events.py->slack/events_slash.pydocs/system-specs/modules/slack-gateway.md:1175heading "Message Queue (session_parts/claims.py+events.py)" -> "... +events.py+events_queue.py+events_inbound.py)" (the drain and stop holds, and themessage_deletedcancellation), and the:1359link to it follows the new anchordocs/system-specs/modules/slack-gateway.md:1186heading "Linked Thread Sync (handler.py+interactions.py)" -> "(handler.py+interactions.py+interactions_sessions.py+interactions_options.py)"src/kiro_crew/pod/runtime_boot.py:638(comment) "slack/events.py falls through to" -> "slack/events_queue.py" (_resolve_approval_mode)src/kiro_crew/slack/files.py:93-94(comment) "slack/events.py", "(not in events.py)" -> "slack/events_voice.py", "(not in events_voice.py)"src/kiro_crew/slack/files.py:117(comment) "slack/events.pyconsumes both" -> "slack/events_voice.py"src/kiro_crew/messaging/attachments.py:185(docstring) "(slack/events.py)" -> "(slack/events_voice.py)"src/kiro_crew/slack/gateway_runtime/exit_path.py:552andsrc/kiro_crew/platform_compat_runtime.py:304(comments) "the orderslack/events.pyuses" -> "slack/events_slash.py" (_handle_restart)test/test_slack_inline_stop.py:6-7andtest/test_session_end_interaction.py:1(docstrings)interactions.py->interactions_sessions.py;test/test_interactions_shortcut.py:1->interactions_modals.pytest/test_stt_reaction.py:1andtest/test_slack_events_coverage_message_helpers.py:275(docstring, comment)slack/events.py->slack/events_voice.py;test/test_review_fixes.py:615,627(docstrings)events.py->events_slash.py;test/test_slack_log_sanitization.py:4-5(docstring) namesslack/events_slash.pyfor the slash-command log site besideslack/events.pyfor the inbound onesrc/kiro_crew/slack/events.py:12-13(kept module docstring) "Also contains the bounded dedup cache (_SeenCache)" -> "The bounded dedup cache ... (SeenCache) lives in :mod:kiro_crew.slack.events_inbound"Baselined growth (L56 addendum 1b)
src/kiro_crew/security_posture.py: baseline row 3,181, main 3,481, HEAD 3,487 (+6: oneNON_EGRESS_REDACTION_MODULESrow per owner that holds a redactor call;interactions.pykeeps its row beside four owner rows, andevents.pykeeps its row beside two).Notes for reviewers
logging.getLogger("kiro_crew.slack.events")or("kiro_crew.slack.interactions"), the names at BASE, socaplog.at_level(logger=...)captures and filters see the same logger.SeenCache,TrustedBotTurnLedger(events_inbound),_StopHold(events_queue) and_BoundedBlockText(events_block_text) report their owner module. None is an exception or enum, and nothing in the tree reads their__module__or__qualname__, pickles them or prints their repr (static sweep ofsrc/and the test trees).py/clear-text-logging-sensitive-data, the_safe_log(text[:80])log line in_route_message) stays inevents.py, unchanged; keeping the router there is why the facade sits at 1,516 lines.src/kiro_crew/security_posture.pyis inSENSITIVE_GLOBS; the edit is the path rows above only. The Sensitive change review comment is posted on this PR.events_parts//interactions_parts/packages, ascli_server_*andmcp_shared_*do, so each owner is a specificrun_scoped_testsstem.Manual verification
N/A — a structural move; behaviour is pinned by the existing suites that drive every moved handler and the router, run unmodified through the facades.
Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.