Repository navigation
refactor: compose every split facade through one shared helper - #20494
Conversation
Sensitive Change ReviewSensitive files changed:
How to clear this check:
Only the author's comment counts this way. A reviewer can instead |
165dee2 to
7ddda08
Compare
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS One copy of What this change shipsInventory (6 items) — 6 justifiedIntent: let a fix to the facade-rebind technique be made once instead of nine times, with no change in behaviour. This is a FIX (refactor).
[FIRST-PRINCIPLES-REVIEWED] 6dad1f8 Description read[DESCRIPTION-READ] ce645eb4a8138c11aae8b910c40449a0ac5205b95c7b17126f4e62b37c9dd176 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that [DESIGN-REVIEWED] 6dad1f8 Description read[DESCRIPTION-READ] 6f4b2ebc1e2c0817ebda9f6ebe934d33e022cfd316a17fcbc34b596f24ae1438 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 |
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: |
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: |
|
Security Scope Review -- ✅ PASSWhich legitimate operations does Verdict basis: adjudicated, zero confirmed regressions. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: PASS TIGHTENING: None. This diff makes no security rule stricter. The five per-package ADJUDICATED: 14 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: Rows are posix (10) and windows (4). The diff adds no assumption about paths, separators, argv shape, interpreter or environment. The posix rows are the maintainers' own operations in the touched area: the composition-contract and deny-tier pytest runs, [SCOPE-REVIEWED] 6dad1f8 |
7ddda08 to
0e5b761
Compare
0e5b761 to
b7e4e30
Compare
|
[operator: bolichen97] Rebased onto origin/main Choice: option (a), keep main's contract. Conflicts resolved: Tests on this head: the nine composition contracts + |
iamwhatever
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at e39b24a, after a deeper read. This supersedes our earlier HOLD on this head.
On its own base the refactor is statement-for-statement equivalent; I checked the facades with an AST comparison. The problem is what happens when it meets current main.
hooks.pywill fail at import after the rebase. Main (#20555) now rebindsScriptHookStore._atomic_mutationwith_hook_runtime._rebind(...)right after compose (hooks.py). Agit merge-treeof this head onto main auto-mergeshooks.pywith that line kept, while this PR drops thefrom kiro_crew import hook_runtime as _hook_runtimeimport. The result is aNameErrorwhenhooks.pyloads, which takes down the shell deny gate's facade.
Fix: rebase onto main and point that line at the shared helper (import_rebindfromkiro_crew._facade_compose, or add a public rebind there). Make sure main's new hook owners also go through the shared helper.- The branch now conflicts with main in
src/kiro_crew/hook_runtime/__init__.py.
After the rebase, Sensitive Change Review needs the reasoning template for the new head, and a maintainer needs to approve the deny-gate facade rewiring. I did not run the code; the import failure comes from reading the merged file.
— crew-pr-reviewer (r105 deep check)
e39b24a to
8fd7a82
Compare
|
[operator: bolichen97] @iamwhatever thanks for the deeper read. Both points are fixed on the new head 8fd7a82 (rebased onto main 0a008292c, still one commit).
Local runs on the new head:
The Sensitive Change reasoning for the new head and the maintainer approval of the deny-gate facade rewiring are still open human steps. Re-requesting your review. |
Nine owner packages each carried a private copy of compose/_functions_of/ _rebind (slack.gateway_runtime, chat_api, messaging_api, file_api, agent_admin, server_runtime, hook_runtime, slack.handler_runtime, subagent_parts), kept identical only by contract-test pins. Hoist one compose(namespace, owners, host=None) into the neutral kiro_crew/_facade_compose.py, which no facade owns, so the per-package import guards still hold. With host=None it runs the host-less copies' code; with a host class it also swaps and requalifies that class's owner methods, as the Slack gateway's and subagent's copies did. The nine facades call it once at their foot; the package __init__ files keep only their docstrings. Its rebind is public: hooks.py uses it for the one function compose cannot reach, the generator under ScriptHookStore._atomic_mutation. dashboard.chat_turn keeps its own compose: since #20526 it also finds its owners (owner_modules()) and binds on chat_runner every name an owner defines that the runner lacks. That contract is the runner's alone, so chat_runner and its tests are unchanged and only docstrings note it. The byte-identity pins become "the facade composes through the shared helper and the package defines no function"; the synthetic-module probes call the shared helper. Pure refactor: no behaviour change. Refs #16231
8fd7a82 to
6dad1f8
Compare
|
[operator: bolichen97] span=265b57de6a83 fixed in 6dad1f8 (still one commit).
|
|
[operator: bolichen97] @iamwhatever one more push after my reply above: head is now 6dad1f8 (rebased onto main 9b99f5f, still one commit). It also folds in main's new |
|
[operator: bolichen97]
|
|
[operator: bolichen97]
|
|
Hold. This PR is reserved for human review: it rewires the shell deny-gate facade ( Both points from my r105 change request are fixed on this head. To clear this:
I read the source and did not run the code. Reviewed head: 6dad1f8 — crew-pr-reviewer (r107) |
Problem / Motivation
Goal: Every split-module facade composes its owners through one shared helper,
kiro_crew/_facade_compose.py, instead of nine private copies of the same code, with no change in behaviour.Scope after the rebase onto main (2026-10-15):
dashboard.chat_turnis left out of the swap. Since #20526,chat_turn.composealso finds its owners itself (chat_turn.owner_modules()) and binds onchat_runnerevery name an owner defines that the runner lacks; the shared helper has neither, and teaching it both would widen the helper's contract for the other eight facades. Sochat_runner.py,chat_turn.composeand the chat runner contract tests are exactly main's; onlychat_turn/__init__.py's closing docstring paragraph and the spec note it. The other eight facades compose through the shared helper. #16231 stays open for thechat_turncopy, so this PR now saysRefs, notCloses.Scope after the rebase onto main 0a008292c (2026-10-15): main's #20401 added
subagent_parts.compose, the same statements as the shared helper with a requiredhost(SubagentManager). It is folded in:subagent.pycalls_facade_compose(globals(), owners, host=SubagentManager)andsubagent_parts/__init__.pykeeps only its docstring. Main's #20555 also added a directScriptHookStore._atomic_mutationrebind inhooks.py; it now calls the shared helper's publicrebind.Nine owner packages each carried their own private copy of
compose/_functions_of/_rebind:slack.gateway_runtime,dashboard.chat_turn,dashboard.chat_api,dashboard.messaging_api,dashboard.file_api,dashboard.agent_admin,dashboard.server_runtime,hook_runtimeandslack.handler_runtime. The eight host-less copies ran the same code (seven byte-identical,chat_turn's differing only in its docstring), and four contract tests pinned them byte-identical to each other.slack.gateway_runtime's copy also bound the orchestrator class's methods and requalified their names.Why it matters
A fix to the rebind technique had to be made nine times, and the byte-identity pins were the only thing keeping the copies from drifting. Every new split added a tenth copy.
Not a goal
# type: ignorelines): not attempted here; it changes how tests patch the facades.What changed (motivation → approach → change)
The copies existed only because each owner package's composition-contract test forbids importing that package from outside its facade, so no facade could reuse another's copy. A neutral module that no facade owns removes that constraint.
src/kiro_crew/_facade_compose.pyholds the onecompose(namespace, owners, host=None). Its body is theslack.gateway_runtimecopy: withhost=Noneit runs exactly the eight host-less copies' code, and with ahostclass it also swaps and requalifies that class's owner methods, as the Slack gateway's did. The private copies are deleted from nine package__init__.pyfiles (hook_runtime/__init__.py,slack/gateway_runtime/__init__.py,subagent_parts/__init__.pyand the six others; notdashboard/chat_turn/__init__.py, see the scope note), which keep only their docstrings (each now points at the shared helper and no longer explains why it kept its own copy). The nine facades (dashboard/chat_handlers.py,dashboard/handlers/messaging.py,dashboard/handlers/files.py,dashboard/handlers/agents.py,dashboard/server.py,hooks.py,slack/handler.py,slack/gateway.py,subagent.py) importcompose as _facade_composeand call it once at their foot; the gateway passeshost=GatewayOrchestratorandsubagent.pypasseshost=SubagentManager. Comments and docstrings that named<package>.compose, and the composition paragraphs indocs/system-specs/modules/(slack-gateway.md,learn-cron-dashboard.md,messaging.md,memory-skills-hooks.md,subagent.md), now name the shared helper.Backwards compatibility
Compatible: the rebinding code is the same statements, called once per facade at the same point, so every function keeps its globals,
__module__and__qualname__.Each removed
composehad exactly one production caller, its own facade, plus the contract test's synthetic probe (grepped origin/mainsrc/,test/,website/,scripts/,.github/for<package>.compose(,_rebind(,_functions_of(,_requalify(). Every one is repointed here:Reader: src/kiro_crew/dashboard/chat_runner.py:_chat_turn.compose -- chat -- unchanged: still calls chat_turn.compose (main's, with owner_modules() and name binding); test_chat_runner_composition_contract.py and test_chat_runner_compose_binding.py are main's, unchanged and green
Reader: src/kiro_crew/dashboard/chat_handlers.py:_chat_api.compose -- chat -- now calls _facade_compose.compose; test_chat_handlers_composition_contract.py test_a_second_facade_import_recomposes_the_owners_onto_it
Reader: src/kiro_crew/dashboard/handlers/messaging.py:_messaging_api.compose -- subagent -- now calls _facade_compose.compose, still before the owner-surface guard wraps the spawn routes; test_handlers_messaging_composition_contract.py
Reader: src/kiro_crew/dashboard/handlers/files.py:_file_api.compose -- chat -- now calls _facade_compose.compose; test_dashboard_files_composition_contract.py
Reader: src/kiro_crew/dashboard/handlers/agents.py:_agent_admin.compose -- crew page -- now calls _facade_compose.compose; test_dashboard_agents_composition_contract.py test_the_facade_composes_through_the_shared_helper
Reader: src/kiro_crew/dashboard/server.py:_server_runtime.compose -- chat -- now calls _facade_compose.compose; test_dashboard_server_composition_contract.py test_the_facade_composes_through_the_shared_helper
Reader: src/kiro_crew/hooks.py:_hook_runtime.compose -- cron -- now calls _facade_compose.compose at the same foot-of-module point, after the UNC memo priming; test_hooks_composition_contract.py test_the_facade_composes_through_the_shared_helper
Reader: src/kiro_crew/hooks.py:_hook_runtime._rebind -- cron -- main's ScriptHookStore._atomic_mutation rebind now calls the shared helper's public rebind (renamed from _rebind in _facade_compose.py), so hooks.py no longer imports hook_runtime; test_hooks_composition_contract.py test_the_store_mutation_guard_is_rebound_through_the_shared_helper
Reader: src/kiro_crew/subagent.py:_compose_parts -- subagent -- now calls _facade_compose.compose with host=SubagentManager, at the same foot-of-module point; test_subagent_parts_composition_contract.py test_the_facade_composes_through_the_shared_helper and test_compose_rebinds_functions_methods_and_members
Reader: test/test_subagent_parts_composition_contract.py:subagent_parts.compose -- release -- the synthetic probe now calls the shared helper with host=owner.Host
Reader: src/kiro_crew/slack/handler.py:_handler_runtime.compose -- chat -- now calls _facade_compose.compose; test_slack_handler_composition_contract.py test_the_facade_composes_through_the_shared_helper
Reader: src/kiro_crew/slack/gateway.py:_runtime.compose -- cron -- now calls _facade_compose.compose with host=GatewayOrchestrator; test_slack_gateway_composition_contract.py test_compose_rebinds_functions_methods_and_members
Reader: src/kiro_crew/dashboard/chat_handlers.py:_chat_api -- chat -- the facade's private package alias, read only by its compose call; no other reader on origin/main, dropped from _BASE_NAMES in test_chat_handlers_composition_contract.py
Reader: test/test_chat_handlers_composition_contract.py:test_compose_rebinds_functions_and_class_members -- release -- the five host-less probes and the gateway probe now call kiro_crew._facade_compose.compose, so both branches of the helper stay pinned; the chat runner probe still calls chat_turn.compose
Tests
test_compose_rebinds_functions_and_class_membersin the chat handlers, agents, files, messaging and hooks contracts;test_compose_rebinds_functions_methods_and_membersin the Slack gateway contract) now call the shared helper; the gateway one passeshost=Host, so both branches stay pinned.test_the_compose_copy_matches_its_siblingsin the agents, server, hooks and Slack handler contracts) becometest_the_facade_composes_through_the_shared_helper: the facade's_facade_composeIS the shared helper, it is called exactly once, and the owner package's__init__defines no function or class, so no copy can come back.test_the_store_mutation_guard_is_rebound_through_the_shared_helper(hooks contract): the@contextmanagergenerator underScriptHookStore._atomic_mutation, whichcomposecannot reach, is rebound with_facade_compose.rebindonto the facade's globals, andhooks.pynames no_hook_runtime. Main'stest_the_store_mutation_guard_reads_the_facade_globalsstill proves the patch reach.test_subagent_parts_composition_contract.py::test_the_facade_composes_through_the_shared_helper(new):subagent._facade_composeis the shared helper, called once withhost=SubagentManager, andsubagent_parts/__init__.pydefines no function or class.Runs on the rebased head (Linux, Python 3.12):
Re-run on the head rebased onto main 0a008292c (after #20555 split hooks.py into more owners, and with
subagent_partsfolded in): the composition and hook files -> 1308 passed, and the subagent, hooks and facade-inventory contracts -> 406 passed;scripts/local-gate.pyrelated set -> 17128 passed, 18 failed: 17 intest_acp_spawn_offload.py::TestRuntimeProjectedLaunchDocuments, which fail identically on a clean origin/main 0a008292c checkout on this host, andcode_review_sage/tests/test_post_comments.py::TestDismissFinding::test_the_post_path_never_sends_a_dismissed_finding(TypeError in an awaitable mock under the parallel run), which passes 3 of 3 runs alone and touches no file in this diff; isort / flake8 on every changed file andmypy src/kiro_crew/-> clean.black --checkflagsdashboard/handlers/files.pyon origin/main too; left as is.Manual verification
N/A — a pure refactor of import-time wiring; the composition contracts import each facade fresh and second-time in a child interpreter and check the rebinding directly.
Related Issues
Refs #16231 (stays open for the
dashboard.chat_turncopy)Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)