Skip to content

refactor: split cli_server.py and mcp_shared.py into facade owners - #21648

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s32-cli-server
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s32-cli-server

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring cli_server.py (4,003 lines) and mcp_shared.py (3,504 lines) under the 2,000-line cap without changing what either does, so new work on the CLI's server commands and on the MCP stdio plumbing 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. mcp_shared.py grew 89 lines past its baseline row while this campaign ran. Every server command (stop, restart, update, token, ...) shares one file, and so do the stdio wire, the tool-call model, the tool policy and the dispatch loop of every managed MCP server.

Security fence change (maintainer attention)

The inline-payload mint gate (security/inline_payload.py, _MINT_SURFACE_RE) named kiro_crew.cli_server as a credential-mint surface. The token command, the gateway peer proof, stop, restart and update now live in cli_server_requests, cli_server_peer, cli_server_stop, cli_server_restart and cli_server_update, which the old pattern does not match, so python -c "from kiro_crew.cli_server_restart import _restart; _restart()" (which prints a fresh token URL) would no longer be denied. Branches 1 and 3 of the pattern widen from cli_server(?![a-z0-9_]) to cli_server(?:_[a-z0-9]+)*(?![a-z0-9_]), and nothing else in the pattern changes. That restores the reach the gate had over this code before the split; it denies nothing it did not deny before. test_cli_server_facade.py pins it both ways: every owner path is a mint surface, security.is_denied refuses the payload above, and a neighbouring module (cli_setup, a made-up cli_serverless) is not one. Without the widening, those cases are red; see Tests. security.md names the owners in the sentence that lists the mint surface. The security package's line total is unchanged (the edit is two lines in place). The Master granted this edit.

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. These two are among the most-edited files in the tree: cli_server.py grew 451 lines in one change while this PR was in review, and _run_stdio_dispatch_loop alone grew from 707 to 1,317 lines in two weeks.

Not a goal

  • No behaviour change: every moved definition keeps its body; the few line edits are listed under Move audit.
  • No change to which names kiro_crew.cli_server and kiro_crew.mcp_shared offer, or to how a test patches them.
  • No decomposition of _run_stdio_dispatch_loop itself: it moves whole and stays one 1,317-line function.
  • No change to the mint gate beyond restoring its reach over the moved code.

What changed (motivation → approach → change)

Each file becomes a mirror facade (kiro_crew._facade_mirror, the shape cli.py and mcp_core.py already use) over sibling owner modules. The facade keeps its import header byte-identical and the code that sits on top, imports its owners, and serves every name they define, so kiro_crew.cli_server.<name> and kiro_crew.mcp_shared.<name> resolve as before, and a monkeypatch.setattr or mock.patch through the facade reaches every module that holds the name.

File Keeps Owners (lowest layer first)
cli_server.py 4,003 → 896 file-delivery approve, status, gateway, run, service, sandbox, logs cli_server_peer.py 410 (the gateway peer proof every local-secret send takes, _CLI_LOOPBACK), cli_server_requests.py 417 (token, logout, update approve), cli_server_stop.py 757 (stop, gateway-pid, the shared refusals), cli_server_restart.py 1,015, cli_server_update.py 870
mcp_shared.py 3,504 → 320 run_mcp_stdio_loop, the process identity it declares, the hard-exit handlers mcp_shared_wire.py 470, mcp_shared_calls.py 543, mcp_shared_policy.py 1,024, mcp_shared_dispatch.py 1,487

Each global the family rebinds at run time (_stdout_fd, _framing, the policy's failure state) stays in the one owner that rebinds it, beside every reader. The owners log under the facade's name, and the moved exception and enum classes (ToolCancelled, _GatewayPeerRefused, _ConnectedPeerVerdict) keep their facade's module name. The owners are top-level files, so _PACKAGE_DIR stays the package directory that serves_managed_tools measures from. The specs (cli.md, mcp.md) gain owner maps; registries keyed by path follow the moved code (spawn audit, internal-python sites, call-site auth coverage, the redaction registries); and the facades get per-file F401 ignores in setup.cfg, backed by frozen 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.cli_server.json, kiro_crew.mcp_shared.json), and a patch through either facade reaches every owner holding the name (test_cli_server_facade.py, test_mcp_shared_facade.py, test_facade_mirror_guards.py).

The take-away check flags the public mcp_shared defs that moved to owners; each is still served by the facade:

Reader: src/kiro_crew/mcp_core.py:call_tool_with_logging -- chat -- imported from kiro_crew.mcp_shared, which serves the mcp_shared_calls function object (test_mcp_shared_facade.py)
Reader: src/kiro_crew/mcp_cron.py:call_tool_with_logging -- cron -- same facade import, same object (test_campaign_facades_base_public_names.py)
Reader: src/kiro_crew/apps/builtins/mochi/mcp_server.py:call_tool_with_logging -- app -- same facade import, same object (test_campaign_facades_base_public_names.py)
Reader: src/kiro_crew/mcp_core.py:drive_deferred -- chat -- imported from kiro_crew.mcp_shared, served from mcp_shared_calls (kiro_crew.mcp_core.json rebound check)
Reader: src/kiro_crew/mcp_core.py:map_deferred -- chat -- imported from kiro_crew.mcp_shared, served from mcp_shared_calls (kiro_crew.mcp_core.json rebound check)
Reader: src/kiro_crew/mcp_core_parts/identity.py:spawned_without_gateway_identity -- chat -- imported from kiro_crew.mcp_shared, served from mcp_shared_policy (test_identity_topology.py)
Reader: src/kiro_crew/mcp_core_parts/identity.py:external_client_identity_note -- chat -- imported from kiro_crew.mcp_shared, served from mcp_shared_policy (test_identity_topology.py)
Reader: src/kiro_crew/mcp_shared.py:snapshot_stdout_fd -- chat -- run_mcp_stdio_loop reads the facade binding of the mcp_shared_wire function (test_mcp_shared_sigterm_hard_exit.py)
Reader: src/kiro_crew/mcp_shared.py:release_stdout_fd -- chat -- run_mcp_stdio_loop reads the facade binding of the mcp_shared_wire function (test_mcp_shared_sigterm_hard_exit.py)
Reader: src/kiro_crew/mcp_shared_dispatch.py:serves_managed_tools -- chat -- the dispatch loop imports it from mcp_shared_policy; a facade patch reaches both (test_app_mcp_tool_policy_scope.py)
Reader: src/kiro_crew/mcp_shared_dispatch.py:respond -- chat -- the dispatch loop imports it from mcp_shared_wire; a facade patch reaches both (test_mcp_shared.py)
Reader: src/kiro_crew/mcp_shared_dispatch.py:notify -- chat -- the dispatch loop imports it from mcp_shared_wire; a facade patch reaches both (test_mcp_shared_deferred_tools.py)

Move audit

move_audit.py --base <merge-base> --head <this head>:

src/kiro_crew/cli_server.py: 4003 -> 896 lines; moved 70.04% (python-ast)
   changed: _update [FunctionDef] 408 lines
   changed: _restart [FunctionDef] 331 lines
   changed: _stop [FunctionDef] 254 lines
   changed: _refresh_agent_config [FunctionDef] 42 lines
   changed: _stop_mcp_gateway_daemon [FunctionDef] 31 lines
   changed: _wait_for_pids_exit [FunctionDef] 30 lines
   changed: _pid_exited [FunctionDef] 7 lines
src/kiro_crew/mcp_shared.py: 3504 -> 320 lines; moved 100.0% (python-ast)

The audit marks a whole unit changed when any line in it changed. Those seven units carry 14 changed lines of
their 1,103, and every one is a deliberate non-move edit:

Edit Units Lines Why
logging.getLogger(__name__) → logging.getLogger("kiro_crew.cli_server") _update x7, _refresh_agent_config, _stop_mcp_gateway_daemon 9 L25: the moved commands keep the logger name the log formats (%(name)s) and filters show; the facade's own _gateway/_run_task keep __name__, which is the same name there
KiroCrew → Kiro Crew in prose _stop (docstring, comment), _wait_for_pids_exit, _restart (docstrings) 4 brand gate: a moved line is an added line
"no longer exists" → "does not exist" _pid_exited docstring 1 comment-history gate

Glue, not moves: the facades' header imports (importlib as _importlib, kiro_crew._facade_mirror, TYPE_CHECKING, and
the owner names the kept code reads), the mirror install at each facade's foot, each owner's import header,
logger = logging.getLogger("kiro_crew.mcp_shared") in the three mcp owners that log, the
__module__ pins on ToolCancelled, _GatewayPeerRefused and _ConnectedPeerVerdict, and one
comment on a kept facade line: # noqa: F811 on _file_delivery_approve's local
dashboard_socket_path import, which pyflakes reads as a redefinition now that only the owners
read the header's import of that name (the AST is unchanged). The split is reproducible from any base by the recipe in the
campaign's scratch/S32/recipe/ (name-keyed, never line-keyed).

L36 parity (default diff vs --minimal, identical + lines), every changed file equal; the two facades:
cli_server.py 116/3223 both, mcp_shared.py 109/3293 both. Diff size: 799,320 bytes.

Tests

  • test/test_cli_server_facade.py, test/test_mcp_shared_facade.py (new; 59 tests, 5 runs at -n0 and one at -n 3 green): 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; each runtime-rebound global lives with its writer and every reader; every BASE public name and every served name type-checks through the facade; the owners log under the facade name; the moved exception and enum classes keep the facade module; _PACKAGE_DIR; the frozen import inventory that stands in for F401, with a planted-import self-test; and the mint fence (every owner path is a mint surface, the _restart payload is denied, neighbours are not).
  • test/campaign_facade_inventories/kiro_crew.cli_server.json, kiro_crew.mcp_shared.json (new): every public name each module bound at BASE still resolves, and each re-bound import is its home's object.
  • Re-pointed or joined source pins (assertions unchanged), each with a mutation that turns it red, listed below.
  • Local gate floor at this head: the related backend set from local-gate --dry-run (501 files) plus every file naming either module and the campaign guards, 514 files at -n 3: 36,138 passed, 114 skipped, 6 xfailed, 1 failed. The one failure is test/test_extras.py::test_requirements_match_setup_cfg[teams], which was red on main at that base (the PyJWT 2.15.0 bump left extras.py at 2.13.0) and is fixed on main since; it is outside this diff. mypy src/kiro_crew: no issues in 2,803 files. isort/black/flake8 clean (isort --check-only src/kiro_crew test conftest.py xdist_budget.py). Comment-history, brand, harness-parity, black, subprocess-encoding, agent-sdk, sync-io, line-cap, memory-store and feature-map gates, docs_lint.py, woke on added lines: clean. Semgrep 1.78 with the CI configs and --baseline-commit: 0 findings (semgrep cannot fully parse test/test_cli.py or .github/workflows/build.yml, on main as well). Installed-mode smoke from a git-archive wheel: all eleven modules import from the wheel.
  • Per-file coverage of the new modules (cli: the 50 test files naming cli_server; mcp: the related set): cli_server_peer 97%, cli_server_requests 92%, cli_server_stop 96%, cli_server_restart 97%, cli_server_update 95%, the cli_server facade 87%, mcp_shared_wire 93%, mcp_shared_calls 98%, mcp_shared_policy 95%, mcp_shared_dispatch 94% (floor 80%).

Mutation proofs (each red, file restored after): revert the fence widening; rename _spawn_detached_gateway in the restart owner (spawn audit, internal-python sites); drop -P from its argv (stdlib shadow); plant a second "setup", "--agent-only" in an owner (agent refresh count); plant http://localhost:{port} in an owner (loopback literal); plant an unpinned subprocess.run(text=True) in an owner (encoding gate); plant the dashboard import in an owner (skill observer); drop the update owner and the requests owner from _SOURCES (call-site auth, one each); strip redact from the update owner (sink row) and from the calls owner (non-egress row); bind _framing on the facade (rebound-global home); revert one owner logger literal; drop the ToolCancelled.__module__ and _GatewayPeerRefused.__module__ pins.

CI path references

  • .github/workflows/build.yml: the windows_installer path filter gains 'src/kiro_crew/cli_server_*.py' beside 'src/kiro_crew/cli_server.py'.
  • AUTOSDE.yaml: the no-new-work-on-gateway-boot-path rule's file patterns gain "src/kiro_crew/cli_server_*.py" (the facade imports its owners on the boot path).

Re-pointed source pins (L30)

  • test/test_spawn_audit.py:1300,1301,1308,1311 BENIGN_SPAWNS: cli_server.py::_spawn_detached_gateway → cli_server_restart.py::, ::_update, ::_refresh_agent_config, ::_update_wheel → cli_server_update.py::.
  • test/test_internal_python_isolation.py:31-32: rows → cli_server_restart.py / cli_server_update.py.
  • test/test_stdlib_shadow.py:53: _CLI_SERVER path → cli_server_restart.py.
  • test/test_mcp_call_site_auth_coverage.py: _SOURCES gains the five cli owners and mcp_shared_policy.py; _KNOWN_UNRESOLVED cli_server.py:_update_wheel → cli_server_update.py:_update_wheel and cli_server.py:_probe_dashboard_health → cli_server_requests.py:_probe_dashboard_health.
  • Facade joined with every owner (L40(8)): test/test_update_agent_refresh.py:109, test/test_cli.py:4723, test/test_subprocess_encoding_gate.py:247, test/test_skill_read_observer.py:182.
  • src/kiro_crew/security_posture.py: _REDACTION_SINKS "CLI update output" cli_server.py → cli_server_update.py (L55: the row names the module that holds the redact_credentials calls; the posture panel shows the new path); NON_EGRESS_REDACTION_MODULES mcp_shared.py → mcp_shared_calls.py, mcp_shared_dispatch.py, mcp_shared_policy.py.

Citation edits (L29)

  • test/test_spawn_audit.py:1124 cli_server.py::_spawn_detached_gateway → cli_server_restart.py::_spawn_detached_gateway
  • test/test_loopback_proxy.py:222 cli_server.py → cli_server_update.py
  • test/test_update_git_guard.py:141 cli_server.py::_update() → cli_server_update.py::_update()
  • test/test_update_wheel_dispatch.py:260,568 cli_server.py → cli_server_update.py
  • test/test_mcp_skill_registry.py:182 mcp_shared.py → mcp_shared_calls.py
  • test/test_security.py:6408 mcp_shared.py → mcp_shared_policy.py
  • test/test_wait_tool_early_end.py:64 mcp_shared.py → mcp_shared_calls.py
  • docs/system-specs/modules/governance.md:3659 cli_server.py → cli_server_update.py
  • docs/system-specs/modules/platform-context.md:824 _token in cli_server.py → cli_server_requests.py
  • src/kiro_crew/platform/interfaces.py:445 (docstring) _token in cli_server.py → cli_server_requests.py
  • docs/request-for-change/rfc-update-architecture.md:160,265,478 cli_server.py → cli_server_update.py
  • docs/request-for-change/rfc-everything-is-an-app.md:176 cli_server.py:1507 → `_run_task` in `cli_server.py` (the docs-lint baseline row for that line cite goes with it)
  • docs/system-specs/common/code-style.md:19 MCP protocol version mcp_shared.py → mcp_shared_dispatch.py; read as mcp_shared
  • docs/architecture/mcp.md:1527 _UNRESOLVED_REFUSES_CALL (mcp_shared.py) → (mcp_shared_policy.py)
  • Owner maps added to the owning specs: docs/system-specs/modules/cli.md (after cli.py's) and docs/architecture/mcp.md (after mcp_core.py's).

References not edited (cost)

  • website/electron/windows-port.js:273 and website/electron/test/windows-port.test.js:383 say "cli_server.py's stop path"; the stop path is now cli_server_stop.py (L50: a backend split leaves website/** comments to the batched docs PR).

Baselined growth (L56 addendum 1)

  • test/test_cli.py: baseline row 10,498, main 10,575, HEAD 10,577 (+2: the L40(8) facade+owner join black wraps over three lines). Its split scope (T59) has not launched.

Baselined growth (L56 addendum 1b)

  • src/kiro_crew/security_posture.py: baseline row 3,181, main 3,345, HEAD 3,347 (+2: one NON_EGRESS_REDACTION_MODULES row per mcp owner that holds a redactor call, in place of the facade's row).

Notes for reviewers

  • Logger names (L25): the owners log as kiro_crew.cli_server / kiro_crew.mcp_shared, the names at BASE.
  • ToolCancelled.__module__ stays kiro_crew.mcp_shared, and _GatewayPeerRefused.__module__ and _ConnectedPeerVerdict.__module__ stay kiro_crew.cli_server (exception and enum classes). Other moved classes report their owner module; nothing in the tree reads their __module__ (no pickling, no repr or log of it, no test).
  • _run_stdio_dispatch_loop is one 1,317-line function, so mcp_shared_dispatch.py sits at 1,487 lines with little headroom under 1,600; it grew 610 lines in the last two weeks. Its decomposition is a later, tier-G change.
  • CodeQL: the dismissed false positive refactor(artifacts): consolidate publishing onto web deploy #570 (py/clear-text-logging-sensitive-data, in _stop) moves verbatim to cli_server_stop.py.
  • Ported upstream changes: fix(mcp): keep the policy for a long-path, relative or missing handler on another drive #20746 (serves_managed_tools, _path_is_under) is in mcp_shared_policy.py, and fix(cli): prove the gateway peer before sending the local secret #20993 (the gateway peer proof before every local-secret send) is in cli_server_peer.py, cli_server_requests.py, cli_server_stop.py, cli_server_restart.py and cli_server_update.py; every unit those changes touched has an AST identical to main's.
  • More than four owners for cli_server.py stay top-level files rather than a cli_server_parts/ package: a package is in the cross-platform gate's scan, and the moved stop and update code holds POSIX-only lines (os.getuid, os.kill, sh -c) that are correct where they sit.

Manual verification

N/A — a structural move; behaviour is pinned by the existing suites that drive every moved command and server path, run unmodified through the facades.

Related Issues

Part of #20192

Follow-up: #21320 (comment citations in website/ left unedited, listed below)

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 17:15
@bolichen97
bolichen97 requested a review from buluoray October 17, 2026 17:15
@bolichen97

bolichen97 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: c380de7
  • What rule changed: The inline-payload mint fence (_MINT_SURFACE_RE in security/inline_payload.py) now matches the kiro_crew.cli_server_<role> owner modules as well as kiro_crew.cli_server; security_posture.py re-keys the "CLI update output" sink row and the mcp_shared.py non-egress row to the owner modules that now hold those redactor calls.
  • Before -> after (what was allowed/blocked, now): Before, every server command was denied in an inline payload through kiro_crew.cli_server; the split moves the gateway peer proof, the token requests, stop, restart and update to cli_server_peer/_requests/_stop/_restart/_update, and the widened branches deny them the same way (python -c "from kiro_crew.cli_server_restart import _restart; _restart()" is refused at this head). Nothing else is newly denied, and the posture panel names cli_server_update.py and the three mcp_shared_* owners where it named the old files.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): an inline payload that names a module spelled kiro_crew.cli_server_<x> is refused as a mint; cli_setup, cli_serverless and every other module are matched exactly as before, so no ordinary command is newly blocked and no secret path opens.
  • Evidence checked (which sandbox result proves it): test_cli_server_facade.py pins every owner path as a mint surface in four spellings, security.is_denied refusing the _restart payload, and cli_setup/cli_serverless as non-surfaces; reverting the widening turns the owner and _restart tests red; the security package total stays at its 29,574-line budget (the edit is line-neutral).
  • No regression:
    • Tools still work (which tools/commands were run, result): the related set plus guards, 514 test files at -n 3: 36,138 passed, 1 failed (test_extras.py::test_requirements_match_setup_cfg[teams], red on main and outside this diff), including the argv-floor, inline-payload, denied-commands and security-posture suites; mypy clean on 2,803 files.
    • Backward compatible (old config / old data / old callers still work, how checked): the regex only adds matches for the new owner paths, and every kiro_crew.cli_server spelling still matches (the pins at test_argv_floor_inline_and_brace_scope.py:322,367 and test_inline_payload_scoped_regressions.py:333 pass unchanged).
    • Existing tests (which suites passed on this head): test_argv_floor_inline_and_brace_scope.py, test_inline_payload_scoped_regressions.py, test_denied_commands_security.py, test_security_posture.py, test_security_gate_liveness.py, test_cli_server_facade.py, test_mcp_shared_facade.py.
  • How to undo: revert this commit, or narrow the two branches back to cli_server(?![a-z0-9_]) and restore the two posture rows to cli_server.py and mcp_shared.py.

@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 17, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) October 17, 2026 17:35
@bolichen97
bolichen97 force-pushed the refactor/linecap-s32-cli-server branch from fb25e2e to 20cec79 Compare October 17, 2026 18:51
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision c380de7fb4292de447324bd7550788261608da6e 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 17, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security/inline_payload.py

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for c380de7.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that no test or caller assigns mcp_shared._stdout_fd, _framing or the policy failure state through the facade. Those globals are rebound only inside their owners.

[DESIGN-REVIEWED] c380de7

Description read

[DESCRIPTION-READ] 7969d7db0e98b29def44e79058b41fc61ee15a8510119aca49d456ac9552052d

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of c380de7fb4292de447324bd7550788261608da6e — 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: PASS

Before merging, confirm the seven "changed" bodies in the move audit (_update, _restart, _stop, …) only changed how names resolve, not behaviour.

What this change ships

Inventory (9 items) — 9 justified

Intent: bring cli_server.py and mcp_shared.py under the 2,000-line cap with no change in behaviour (ADDITION of structure, no user-visible change).

  1. cli_server.py split into five owner modules behind a mirror facade (kiro_crew._facade_mirror, which other facades already use) — justified
  2. mcp_shared.py split into four owner modules behind the same facade mechanism — justified
  3. Both rows removed from .github/file-line-cap-baseline.txt — justified
  4. The inline-payload mint gate (_MINT_SURFACE_RE) now also matches the cli_server_* owner modules — justified
  5. CI path filter in build.yml and the AUTOSDE rule glob extended to cli_server_*.py — justified
  6. Path-keyed registries moved to the new owner files (_REDACTION_SINKS, NON_EGRESS_REDACTION_MODULES, spawn audit, call-site auth) — justified
  7. F401 ignores in setup.cfg for both facades, backed by frozen import inventories — justified
  8. Prose path references updated in specs, two RFCs, a docstring and test comments; one docs-lint baseline row dropped — justified
  9. New facade tests, and source-scanning tests now read every owner module — justified

[FIRST-PRINCIPLES-REVIEWED] c380de7

Description read

[DESCRIPTION-READ] cbf4689f6345424bb2a921783036273a8228dc4550939218c76c11b10d32298e

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] c380de7

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

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

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] c380de7

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

Comment thread src/kiro_crew/cli_server_stop.py Dismissed
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ human override accepted

@bolichen97 overrode this lane for c380de7fb4292de447324bd7550788261608da6e via /ai-review override (this commit only).

[SCOPE-REVIEWED] c380de7

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

Copy link
Copy Markdown
Contributor Author

/ai-review override scope 20cec79: the 8 newly refused rows are inline payloads naming cli_server_ owner paths. They are the moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open('src/kiro_crew/cli_server_requests.py').read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 marked the scope AI finding as false positive, not applicable, or explicitly accepted for 20cec7958ca1d9520a7340802a04c040fd02fa21.

the 8 newly refused rows are inline payloads naming cli_server_ owner paths. They are the moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open('src/kiro_crew/cli_server_requests.py').read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

This decision applies only to this commit. A new push requires a new judgment.

@bolichen97

bolichen97 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author
  • rebutted: the 8 newly-refused owner-path rows are the moved twins of rows main already refuses

Not a defect. The mint surface in security.md (the inline-interpreter paragraph) names kiro_crew.cli_server "as an import or as a file path"; this split moves the token, stop, restart and update code into cli_server_<role> files, and the widened branch keeps that refusal on the files that now hold it.
security.is_denied probes (env -i): main refuses the same three payloads naming src/kiro_crew/cli_server.py; main ALLOWS exec(open('src/kiro_crew/cli_server_requests.py').read()); _token(None) without the widening; this head refuses it and the cli_server_update.py ast.parse row; an mcp_shared_wire.py path read stays allowed on both.
Narrowing to import spellings only would re-open that exec-the-owner mint, so the refusal set is unchanged from main for the moved code. The scope override for this head is issuecomment-6239281193.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted: the 12 newly-refused owner-path rows are the moved twins of rows main already refuses

Not a defect. The mint surface in security.md (the inline-interpreter paragraph) names kiro_crew.cli_server "as an import or as a file path"; this split moves the token, stop, restart and update code into cli_server_<role> files, and the widened branch keeps that refusal on the files that now hold it.
security.is_denied probes (env -i): main refuses the same three payloads naming src/kiro_crew/cli_server.py; main ALLOWS exec(open('src/kiro_crew/cli_server_requests.py').read()); _token(None) without the widening; this head refuses it and the cli_server_update.py ast.parse row; an mcp_shared_wire.py path read stays allowed on both.
Narrowing to import spellings only would re-open that exec-the-owner mint, so the refusal set is unchanged from main for the moved code. The same class was ruled and overridden at the previous head (issuecomment-6239281193); this head carries the identical patch.

@bolichen97

Copy link
Copy Markdown
Contributor Author

/ai-review override scope bdfb14f: same patch as 20cec79 (-U0 identical, rows aside). All 12 newly refused rows are inline payloads naming cli_server_ owner paths, moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open(src/kiro_crew/cli_server_requests.py).read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 marked the scope AI finding as false positive, not applicable, or explicitly accepted for bdfb14f159a072f62079939b7e074043f5bbf66f.

same patch as 20cec79 (-U0 identical, rows aside). All 12 newly refused rows are inline payloads naming cli_server_ owner paths, moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open(src/kiro_crew/cli_server_requests.py).read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

This decision applies only to this commit. A new push requires a new judgment.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • checked: the facades never bind a runtime-rebound global

mcp_shared.py imports _stdout_fd, _framing and the five policy failure globals only inside if TYPE_CHECKING:; at run time each exists in one namespace, its writer's (mcp_shared_wire, mcp_shared_policy), and _internal_caller_name stays in the facade with its writer set_internal_caller.
Pinned by test_mcp_shared_facade.py::test_each_rebound_global_lives_with_its_writer_and_every_reader (holders and readers of each name are exactly its writer) and ::test_a_facade_write_of_a_rebound_global_lands_with_its_writer (a facade write lands in the writer and never binds on the facade).
The cli_server family has no global rebinds.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • intended: the mint fence covers every cli_server_<role> module by name

The cli_server_ prefix is the facade's owner family: the facade, its contract test (test_cli_server_facade.py, which requires the owner set to equal every cli_server_* sibling) and the spec (cli.md layout, security.md mint surface "with its cli_server_<role> owners") all treat it as one module split across files, so a future owner holding server commands is covered without a second fence edit.
The match is anchored to kiro_crew. / kiro_crew/ plus the exact prefix and an underscore, so neighbours stay outside it: cli_setup and cli_serverless are pinned as non-matches in test_cli_server_facade.py. Erring wide fails closed (a refused inline payload), never open.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: checking Automated validation is still running labels Oct 18, 2026
cli_server.py (4,003 lines) and mcp_shared.py (3,504) were past the
2,000-line cap. Each becomes a kiro_crew._facade_mirror facade over
sibling owners, so every name either module held still resolves on it
and a patch through it reaches every module that holds the name.

cli_server.py keeps file-delivery approve, status, gateway, run,
service, sandbox and logs. The gateway peer proof and _CLI_LOOPBACK move
to cli_server_peer, the token, logout and update-approve requests to
cli_server_requests, and stop, restart and update to cli_server_stop,
cli_server_restart and cli_server_update. mcp_shared.py keeps run_mcp_stdio_loop, its process
identity and its hard-exit handlers; the wire, the tool-call model, the
tool policy and the dispatch loop move to mcp_shared_wire,
mcp_shared_calls, mcp_shared_policy and mcp_shared_dispatch. Each global
rebound at run time stays with its writer and readers, the owners log
under the facade names, and the moved exception and enum classes keep
their module names.

The inline-payload mint fence widens cli_server to cli_server_<role>,
so the moved token, stop, restart and update commands stay mint
surfaces. Path-keyed registries, specs and CI path lists follow the
moved code.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-s32-cli-server branch from bdfb14f to c380de7 Compare October 18, 2026 19:57
@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 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted: the 9 newly-refused owner-path rows are the moved twins of rows main already refuses

Not a defect. The mint surface in security.md (the inline-interpreter paragraph) names kiro_crew.cli_server "as an import or as a file path"; this split moves the token, stop, restart and update code into cli_server_<role> files, and the widened branch keeps that refusal on the files that now hold it.
security.is_denied probes (env -i): main refuses the same three payloads naming src/kiro_crew/cli_server.py; main ALLOWS exec(open('src/kiro_crew/cli_server_requests.py').read()); _token(None) without the widening; this head refuses it and the cli_server_update.py ast.parse row; an mcp_shared_wire.py path read stays allowed on both.
Narrowing to import spellings only would re-open that exec-the-owner mint, so the refusal set is unchanged from main for the moved code. The same class was ruled and overridden at the previous head (issuecomment-6239281193); this head carries the identical patch.

@bolichen97

Copy link
Copy Markdown
Contributor Author

/ai-review override scope c380de7: same patch as bdfb14f (-U0 identical, rows aside). All 9 newly refused rows are inline payloads naming cli_server_ owner paths, moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open(src/kiro_crew/cli_server_requests.py).read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 marked the scope AI finding as false positive, not applicable, or explicitly accepted for c380de7fb4292de447324bd7550788261608da6e.

same patch as bdfb14f (-U0 identical, rows aside). All 9 newly refused rows are inline payloads naming cli_server_ owner paths, moved twins of payloads base already refuses for src/kiro_crew/cli_server.py (security.md mint surface: import or file path). Probed at base vs head: base allows exec(open(src/kiro_crew/cli_server_requests.py).read()); _token(None) and head refuses it; non-mint paths stay allowed. Narrowing would reopen that token mint.

This decision applies only to this commit. A new push requires a new judgment.

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

Copy link
Copy Markdown
Contributor Author
  • checked: facade writes of the rebound globals land in their writer

Unmodified tests do assign them through the facade (test_mcp_shared_cache.py, test_identity_topology.py, test_managed_tool_policy_include.py, mcp_shared_helpers.py, test_mcp_shared.py for _framing/_stdout_fd), and they pass at this head: kiro_crew._facade_mirror routes a facade setattr or plain assignment to the module that holds the name, which for each rebound global is only its writer (mcp_shared_wire or mcp_shared_policy), and the facade never binds it.
Pinned by test_mcp_shared_facade.py::test_a_facade_write_of_a_rebound_global_lands_with_its_writer (the write lands in the writer, nothing binds on the facade, the mirror reports no divergence) and ::test_each_rebound_global_lives_with_its_writer_and_every_reader.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • confirmed: the seven changed bodies differ only in docstrings and the logger name literal

AST check of each changed unit against cli_server.py on main (8fd2af9): _update, _refresh_agent_config and _stop_mcp_gateway_daemon equal main's AST once logging.getLogger("kiro_crew.cli_server") is read back as logging.getLogger(__name__) (the same logger object, since __name__ was kiro_crew.cli_server there); _restart, _stop, _wait_for_pids_exit and _pid_exited equal it once docstrings are set aside (brand spelling, and "no longer exists" -> "does not exist"). The other edit in _stop is a comment. No statement, call or name resolution changed.

@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 on the watch holder's request. Every check on the head passes; the triage cron held it on a size, path, checklist or lane-note rule. Any standing lane note stays on the record.

@bolichen97
bolichen97 merged commit 9bf0016 into main Oct 18, 2026
112 of 117 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-s32-cli-server branch October 18, 2026 22:07
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 2026
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.

3 participants