Skip to content

refactor(dashboard): give each chat turn one state object - #20526

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g01-chat-runner-p2
Oct 15, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g01-chat-runner-p2

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Give a dashboard chat turn one shared state object and let chat_runner.py compose its chat_turn/ owners by discovery, so the next PRs can move _run_chat code into owners without changing a turn's behaviour or touching the tests that read it.

src/kiro_crew/dashboard/chat_runner.py is 20,849 lines and _run_chat alone is 12,062; the campaign rule is that no hand-written file goes over 2,000 lines. Three things stop code from leaving _run_chat today. Its nested functions share state through nonlocal closure cells, so a block that moves to another module loses the cell. Every owner name has to be re-exported from the runner by hand, so the runner cannot shrink. And about fifty tests read the runner's text by path, so a construct that moves goes out of their sight.

Why it matters

Every dashboard, Slack and channel turn runs through _run_chat. Without a turn object, a moved phase would read a stale copy of a value a closure rewrote, for example the reply text the steer cut clears. Without discovery, every new owner grows the runner by its re-exports. Without the union read, a guard that reads the runner by path would pass vacuously once its construct moves. This PR lays all three foundations while moving nothing out of _run_chat.

Not a goal

  • No code leaves _run_chat in this PR; phases move in the next PRs of the series.
  • No change to what a turn does: no new behaviour, no fixes.
  • No re-pointing of tests owned by other live campaign scopes (test_dashboard_chat.py, test_prompts.py, spec_builder test_routes.py); their deltas are relayed to those scopes, and they are re-pointed here once those scopes land.

What changed (motivation → approach → change)

_run_chat now builds one turn_locals._ChatTurn(message=message) as its first statement. A value a closure writes (assistant_text, which the steer cut writes from the steer handler's task, the consumption reports, the usage-row latch) is spelled turn.<name> at every site, so every reader shares one cell, as the closure cell did. A value a closure reads after the turn rebinds it (message, client, the crew-log ids, the per-turn stats, the turn's project snapshot _turn_project) is copied onto the turn right after each store and read off it inside the closure. A nested function stays a closure cell, so the turn holds no closure and an ended turn is freed by reference counting, as before. Reading an attribute the turn has not set raises UnboundLocalError (a NameError), as the unbound local did.

chat_turn.compose now finds the package's modules with pkgutil and binds each owner name on the runner unless the runner already holds the same object; a different object under one name fails the import. A patch of chat_runner.<name> still reaches every owner function, and the 13 per-owner aliases and the hand-kept owner tuple are gone.

Area Change
chat_runner.py S1 turn object (turn.x at every closure-written site, copies after each late-bound store, the nonlocal lines gone); compose by discovery; two comments restated
chat_turn/__init__.py, chat_turn/turn_locals.py owner_modules() (already-imported modules first), the binding with its collision check; _ChatTurn (the one input its closures read off it, message, and 36 values its closures share)
test_chat_runner_composition_contract.py _STAYS_IN_THE_RUNNER becomes _GUARDED_CONSTRUCT_HOMES ({pattern: homes}); _RUNNER_FILE_DEFS becomes _TASK_ENTRY_HOMES ({entry: home}) plus a stall-attribution reach test
new tests test_chat_runner_compose_binding.py (binding, collisions, owner set, every runner import is read); test_chat_runner_turn_plumbing.py (every store of a name read off the turn is copied at once, every binding form counted; a closure-written name is never bare; no closure declares nonlocal; an unset name raises UnboundLocalError)
test_chat_runner_turn_shared_state.py a row that the turn object itself dies without the collector
36 source-reading tests read every chat_turn/ module, then the runner, as one text (budget-neutral); two use (?:turn\.)?assistant_text, including the reply-text reset sweep's AST check; recovery_l1 checks both context-build arms and both suppression payments
learn-cron-dashboard.md, test_source_pin_budget.py the composition section; budget rows for the two new guards

Backwards compatibility

Compatible: every name chat_runner bound at the base is still bound, as the same object (the base-names contract test), and every patch target still reaches the code it reached.

Removes nothing: no public def, route, key or file leaves; the runner's per-owner module aliases (_owner_*, private) are replaced by compose discovery.

Tests

  • Two new test files with self-tests on synthetic source, so no rule passes vacuously, and a turn-object row in test_chat_runner_turn_shared_state.py.
  • Renamed contract node ids: test_a_construct_the_runner_guards_count_stays_in_the_runner[...] → test_a_construct_guards_count_lives_only_in_its_homes[...]; test_a_task_entry_stays_defined_in_the_runner_file[...] → test_a_task_entry_is_defined_in_its_home_file[...]; new test_a_stalled_task_entry_reads_as_a_dashboard_chat_turn[...].
  • Every source-reading test touched here has a mutation of the production text that turns it red, run with pytest and recorded in the campaign's guard-reach sweep. That is 73 mutants, every one killed:
    • 57 for the union reads (three of them mutate every site of a construct that appears more than once, and one plants an owner broadcast without a slot);
    • 4 for the dual-form pins;
    • 9 for this PR's own guards;
    • 3 for the turn's lifetime and plumbing: a closure stored on the turn, a closure that declares nonlocal, and the runner's own suppression payment.
  • Union reads, by BASE line: metrics/test_context_trace.py:294, :399; metrics/test_turn_profile.py:478; metrics/test_usage_turns.py:320; test_autonudge_banner.py:1472; test_channel_connect_row.py:276; test_chat_hooks.py:131; test_chat_runner_early_recovery_actor.py:164; test_chat_turn_timeout_consistency.py:223; test_credential_redaction_switch.py:268; test_credential_sources.py:222; test_crew_log_emit.py:823/824, :2888, :3218, :6178, :6218; test_crew_log_order.py:275; test_dashboard_approval.py:2341, :2675; test_decisions_compaction_hook.py:442; test_deny_audit_first.py:352; test_external_logout_detection_baseline.py (the turn-gate pin); test_leaked_toolcall_notice.py:445, :507; test_mcp_session_report.py:452; test_member_turn_context.py:304; test_post_compaction_continuation.py:387, :446, :604; test_promise_only_autoapprove_parity.py:60; test_recovery_l1_chat_runner.py:246; test_redaction_blocked_links.py:525; test_refusal_inband_notice.py:676, :766; test_runloop_integration.py:1572; test_runtime_death_is_a_process_event.py:398, :758, :892; test_session_control.py:2882; test_session_control_set_model.py:383/432, :450; test_start_priority.py:907; test_stderr_redact_then_tail.py:408; test_steer_requeue.py:468; test_subagent_stop_reason_consistency.py:1985; test_turn_duration_recorded.py:169; test_turn_metric_all_surfaces.py:231, :328; test_wake_judge_feedback.py:1955; test_ws_event_scoping_frames.py (the approval_resolved scan's roots).
  • 294 test files that import, patch or read chat_runner or chat_turn, plus the flake, wait, line-cap and base-names guards: 20,177 passed, 0 failed (-n 3 --dist loadgroup).
  • The characterization suite (test_chat_runner_turn_*.py), which pins whole turns, passes unchanged except for the added turn-object row.
  • New tests: 5 runs at -n0 green.
  • mypy over src/kiro_crew: clean. semgrep 1.78 (CI configs, baseline at the base): 0 findings, 0 parse errors (per-rule timeouts on the 20,955-line runner). black, isort, flake8 (no per-file ignore), comment-history, brand, agent-sdk, subprocess-encoding and sync-io gates: clean. Installed-mode import of the built wheel: every owner, turn_locals included, imports.

Line cap (scripts/check_file_line_cap.py): 0 failures. chat_runner.py grows by 33 lines (20,922 → 20,955; the copies onto the turn); the next PRs of the series move about 2,400 lines out of it. The union reads grow seven already-baselined test files by 7 to 41 lines each (reported, not failed); test_subagent_stop_reason_consistency.py uses a three-line form of the read to stay at 2,000 lines. Every file's default and --minimal diffs add the same lines except docs/system-specs/modules/learn-cron-dashboard.md: 48 added and 14 removed under the default diff, 47 and 13 under --minimal. The difference is one blank line before "What stays in chat_runner.py", shown as removed and re-added; it carries no gate token.

Manual verification

N/A — a structural refactor; the turn-level characterization suite and the mutation-proven source pins are the verification.

Related Issues

Part of #20192

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

Move audit

N/A for moves: nothing leaves _run_chat in this PR. The move audit's changed units are _run_chat (the S1 re-plumbing only) and the compose call at the end of the file. Recipe: every change is produced by a script and re-applies from main byte-for-byte.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 14, 2026 22:32
@bolichen97
bolichen97 requested a review from mbriones98 October 14, 2026 22:32
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 14, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 14, 2026 23:05
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision b7afca5a24b7b1ed1f890fa3cc018f8c6a693d4c touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the plumbing guard catches every way a mirrored local can be rebound (augmented, tuple, walrus, for, with … as); a missed copy leaves closures reading stale values.

[DESIGN-REVIEWED] b7afca5

Description read

[DESCRIPTION-READ] 21a5c2940be31a400507da08ff187bf6b256fe72edb526ce24dab9c3544e4134

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 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — 🟡 CONCERNS

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

61 turn.x = x copies add a second store for read-after-rebind values whose only readers are still closures inside _run_chat. Those closures could keep reading the closure cell.

Not justified as shipped

  • Item 2 — zero consumers: the PR copies values like turn._turn_t0 = _turn_t0 and turn._crew_log_sid = _crew_log_sid right after each store. Yet "No code leaves _run_chat in this PR", and every reader is still a nested closure. Each value now has two spellings, kept in sync only by test_chat_runner_turn_plumbing.py.
    Subtraction: drop the read-after-rebind copies and their _ChatTurn declarations. Keep only the names closures write (the former nonlocals). Add each copy in the PR that moves its first reader out.
    Clears when: a phase outside _run_chat reads the copied name off turn.
  • Item 5 — one consumer, generalized: all 40 rows of _GUARDED_CONSTRUCT_HOMES and _TASK_ENTRY_HOMES map to the single value _RUNNER_HOME. "So the next PRs can move" is the only support.
    Subtraction: keep the flat tuples until a construct actually gets a second home.
    Clears when: a row names a home other than chat_runner.py.

What this change ships

Inventory (6 items) — 4 justified

Intent: prepare _run_chat so code can leave it under the 2,000-line cap, with no change to turn behaviour. This is a refactor (an ADDITION of plumbing).

  1. Closure-written values (the former nonlocals) live on one _ChatTurn — justified
  2. Read-after-rebind values copied onto the turn after each store — zero consumers outside _run_chat
  3. compose finds owners by discovery; 13 aliases and the owner tuple deleted — justified
  4. The runner fails to import when it and an owner bind different objects under one name — justified
  5. Contract test maps each construct and task entry to its homes, plus a stall-reach test — one consumer, generalized
  6. 36 source-reading tests read the owners plus the runner as one text; spec updated — justified

[FIRST-PRINCIPLES-REVIEWED] b7afca5

Description read

[DESCRIPTION-READ] 2cc547e7b6127592ebf2b4c2e399ce018b45751ec20088727e3a98a6b42a33d5

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 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] b7afca5

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

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

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] b7afca5

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

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 14, 2026
mbriones98
mbriones98 previously approved these changes Oct 15, 2026

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

Checks green and readiness passed at 9bb72ba; no behavior change.

_run_chat's nested functions shared its state through nonlocal
closure cells, so no block could leave the function without losing
the cell, and every chat_turn owner name had to be re-exported from
the runner by hand.

_run_chat now builds one turn_locals._ChatTurn as its first statement.
A name a closure writes is spelled turn.<name> at every site; a name a
closure reads after the turn rebinds it is copied onto the turn right
after each store and read off it inside the closure. A nested function
stays a closure cell, so the turn holds no closure and an ended turn
is still freed by reference counting. An unset name raises
UnboundLocalError, as the unbound local did.

chat_turn.compose finds the package's modules and binds each owner
name on the runner unless the runner already holds that object; a
different object under one name fails the import. Patches of
chat_runner.<name> keep reaching every owner function.

The composition contract maps each path-guarded construct and task
entry to its home file. Tests that read the turn's code as text read
every chat_turn module and then the runner as one text, so a construct
they pin may live in either. Two new tests pin the binding and the
turn's plumbing, each with self-tests on synthetic source, and a
characterization row pins that the turn object dies without the
collector.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-g01-chat-runner-p2 branch from 9bb72ba to b7afca5 Compare October 15, 2026 02:38
@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 labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles Subtraction: _ChatTurn.__init__ takes 25 inputs, only message is read off the turn -- fixed in b7afca5

Legitimate: 24 of the 25 inputs had no reader on the turn. The S1 recipe now puts on the turn only the inputs something reads off it (closure-written or late-bound), so _run_chat builds turn = _ChatTurn(message=message) and the other 24 stay locals.
The change is in chat_turn/turn_locals.py alone: the 24 input annotations and constructor parameters are gone, __init__(self, *, message) is left, and the module docstring says the turn holds the inputs its closures read. chat_turn/__init__.py is unchanged.
Each input goes onto the turn in the phase PR that cuts the code reading it out of _run_chat; test_chat_runner_turn_plumbing.py's copy rule then requires its copy after every store.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the plumbing guard must catch every rebind of a value that lives as a local and on turn -- already covered

uncopied_stores counts every binding form: plain and tuple assignment, += (AugAssign), annotated assignment, for targets, with ... as, except ... as, a walrus anywhere in the statement's own expressions, def/class names and import aliases. A for, with or except binding needs its copy as the first statement of the body it binds.
Each form has a synthetic self-test row in test_the_copy_rule_sees_every_store_shape, and the real-code rule runs over _run_chat and every turn-first owner function; mutant S1-a-store-without-its-copy (dropping one turn.message = message) turns it red.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main c64afca (the PR was DIRTY): main's #17729 added _turn_project to _run_chat, a value a closure reads after the turn rebinds it, so it lives on the turn (_turn_project: "str" in turn_locals.py); #20521's chat_api joins in test_chat_turn_timeout_consistency.py and test_ws_event_scoping_frames.py sit beside this PR's chat_turn joins. CI re-running.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=d3024f609f71 Item 2: the turn.x = x copies have no reader outside _run_chat -- rebutted

In the frozen goal: this PR gives the turn one state object "so the next PRs can move _run_chat code into owners", and "No code leaves _run_chat in this PR" is its Not-a-goal line. The series was approved as a turn object first, then one phase group per PR.
The copies have readers today: every closure reads a late-bound name as turn.x. The closures read the copies, and a closure cut out later keeps reading the same attribute with no edit.
Dropping the copies and adding each one in the PR that moves its reader would spread the S1 rewrite of _run_chat (12,121 lines) over every phase PR. test_chat_runner_turn_plumbing.py's copy rule would then hold for some names, not all.
The "Clears when" is the phase PRs of this series: they move closures that read these names off the turn.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=c2652fba9f0c Item 5: every homes-map row names chat_runner.py -- rebutted

The maps replace two lists of the same constructs (_STAYS_IN_THE_RUNNER, _RUNNER_FILE_DEFS), so they add no rows. What changes is that a row can now name its home.
The next PR of the series moves 82 of the runner's helpers into chat_turn owners. With the maps, each moved construct's row changes to the owner that holds it, one value per row.
Keeping the flat tuples here would put the guard rewrite inside that 2,400-line move, where a reviewer has to tell a guard change from moved code. This PR is where the guard's shape is reviewed on its own.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the plumbing guard must catch every rebind of a value that lives as a local and on turn -- already covered

uncopied_stores counts every binding form: plain and tuple assignment, += (AugAssign), annotated assignment, for targets, with ... as, except ... as, a walrus anywhere in the statement's own expressions, def/class names and import aliases. A for, with or except binding needs its copy as the first statement of the body it binds.
Each form has a synthetic self-test row in test_the_copy_rule_sees_every_store_shape, and the real-code rule runs over _run_chat and every turn-first owner function; mutant S1-a-store-without-its-copy (dropping one turn.message = message) turns it red.

@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 15, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by a maintainer who read the review lane notes and accepted them as follow-up work.

@bolichen97
bolichen97 merged commit efb4cf7 into main Oct 15, 2026
102 of 104 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-g01-chat-runner-p2 branch October 15, 2026 04:55
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 15, 2026
@cruisercohen

Copy link
Copy Markdown
Contributor

Post-merge audit of head b7afca5 (merged while I was reviewing): correct. Reviewed as a change to how a turn holds its state, not as a move, and I found no change in what a turn does.

What I checked, independently of the PR's own guards:

  • Equivalence of _run_chat: I took the base _run_chat, removed its nonlocal lines and rewrote each of the 14 names those lines declared to turn.<name>. I took the head _run_chat, dropped the turn = _ChatTurn(message=message) line and every turn.<x> = <x> copy, and read each copied name back as the bare local. The two ASTs are identical (docstrings aside). So the head runs the base's statements, in the base's order, with no new or lost statement.
  • The 14 closure-written names (assistant_text, chunk_seq, the consumption and usage latches, the terminal-directive pair, the cadence fields and others) are never read or written bare anywhere in _run_chat or its closures. All 14 are declared on _ChatTurn, and no closure declares nonlocal any more.
  • The 23 copied names: all 61 places where the outer function binds one are followed at once by turn.<x> = <x> (the two three-way tuple unpacks of the spec hooks are followed by their three copies). No closure writes a copied name on the turn, and no copied name is bound by except ... as, a walrus or del. Closure reads therefore see the value the base's cell held at every point.
  • Lifetime: of the 18 closures that reach turn (directly or through another closure), only _steer_segment_cut is stored beyond a call, on the slot, and the slot drops it at turn end exactly as before. _queue_recovery is passed only to awaited helpers, and no lambda captures turn. So no new long-lived holder keeps an ended turn, or the client on it, alive. Reading an attribute that has not been set raises UnboundLocalError, which is a NameError, the class the unbound cell raised.
  • Composition: compose discovery binds nothing new on the runner. _ChatTurn is imported explicitly, and every other owner name the runner reads was already bound there. No owner name shadows a builtin. The only names the runner stops binding are the 13 private _owner_* module aliases, and nothing in the source or the tests reads them. The desktop build installs into a real site-packages tree, so pkgutil.iter_modules sees every owner there.
  • Tests: the 290 test files that import, patch or read chat_runner or chat_turn (the edited ones included): 19,630 passed, 0 failed.

Non-blocking: since the package directory is now the owner list, a stray module left in chat_turn/ (for example after a hand-copied downgrade) is imported and composed, and a name in it that clashes with a different object stops chat_runner from importing. A pip install removes files by its record, so this only matters for hand-modified trees.

I have nothing to add to the review lanes. The First Principles concerns are about scope and were answered on the PR; they do not affect correctness.

bolichen97 pushed a commit that referenced this pull request Oct 15, 2026
Eight 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), kept
byte-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 copy did. The eight facades call it once
at their foot; the package __init__ files keep only their docstrings.

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.

Closes #16231
bolichen97 pushed a commit that referenced this pull request Oct 15, 2026
Eight 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), kept
byte-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 copy did. The eight facades call it once
at their foot; the package __init__ files keep only their docstrings.

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
bolichen97 pushed a commit that referenced this pull request Oct 15, 2026
Eight 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), kept
byte-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 copy did. The eight facades call it once
at their foot; the package __init__ files keep only their docstrings.

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
bolichen97 pushed a commit that referenced this pull request Oct 16, 2026
Eight 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), kept
byte-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 copy did. The eight facades call it once
at their foot; the package __init__ files keep only their docstrings.

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
bolichen97 pushed a commit that referenced this pull request Oct 16, 2026
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
bolichen97 added a commit that referenced this pull request Oct 16, 2026
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

Co-authored-by: w <w@k.local>
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.

4 participants