Skip to content

refactor(cli): split cli.py into parser registrars and mirror owners - #20844

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g21-cli
Oct 16, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-g21-cli

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring src/kiro_crew/cli.py from 3,862 lines to 1,114, under the 2,000-line cap, with the kirocrew command line behaving exactly as before.

cli.py is the entry point for every kirocrew command and one of the most-edited files in the tree (18 commits in the last 7 days). Its main() alone was 2,502 lines: about 1,950 of argparse definitions, then the boot steps and the dispatch chain. That is past the repository's 2,000-line rule, so every change to a command's arguments meant editing one giant function.

Part of #20192

Why it matters

A file this size can't follow the code-style rule (no hand-written file over 2,000 lines), and the next command added to it pushes it further over. With the parser split by help section and the helpers in modules of their own, a new command's arguments go into a small registrar module, and cli.py keeps only the entry point. Its CI baseline row for the line cap goes away.

Not a goal

  • No behaviour change: every command, option, default, help text and exit code stays the same. A test or reviewer finding that asks for one is out of scope.
  • Fixing the product-name spelling in the two workspace --dir help strings (they still say "KiroCrew data home"). That is a user-visible text change and belongs in its own PR.
  • Splitting cli_commands.py, cli_server.py or cli_doctor.py, or any test file.
  • Changing how main() dispatches, or the order of its boot steps.

What changed (motivation → approach → change)

main() was one function holding three jobs: build the argparse tree, run the boot steps, dispatch. The boot steps and the dispatch chain are pinned to main by tests and by the token-mint guard (security/inline_payload._MINT_SURFACE_RE names kiro_crew.cli and none of the new cli_* modules), and the gateway command's own flags are read from cli.py's text by pod.runtime_boot.target_supports_flag. So those stay. What moves is everything a reader never needs in the entry point:

New module Lines Owns
cli_parser_gateway.py 378 argparse registrars of the "Start here", "Run the gateway" and "Set it up" commands, all but gateway
cli_parser_agent.py 861 registrars of "Work with the agent", "Memory and knowledge" and "Extend it"
cli_parser_admin.py 674 registrars of "Security and privacy", "Move it and back it up" and "Develop Kiro Crew itself"
cli_logging.py 449 console and gateway.log logging, the log-queue listener and its drains
cli_jail.py 198 the process-isolation jail gate
cli_gateway_boot.py 303 what the gateway branch prepares before asyncio.run
cli_knowledge.py 273 the knowledge and consolidate handlers

Each registrar is one register_<command>_parser(sub) holding that command's base block verbatim; main() calls them in the base registration order (perf, bench and desktop keep their own modules' registrars). The four helper modules are owners of a kiro_crew._facade_mirror facade, so every name cli.py had still resolves on kiro_crew.cli as the same object, and a monkeypatch/mock.patch through kiro_crew.cli reaches the module that reads the name. cli.py keeps binding every project name it imported before (# noqa: F401 where only an owner reads it now). The registrars are plain modules: they read no name a test patches through the facade, and a test pins that.

Registries follow the moved code: .github/file-line-cap-baseline.txt loses cli.py's row; the boot-path rule in AUTOSDE.yaml also covers the four owners and cli_parser_*.py, all imported on import kiro_crew.cli (path globs only); and src/kiro_crew/security_posture.py lists cli_logging.py instead of cli.py as the non-egress module that installs log redaction. The owning spec (docs/system-specs/modules/cli.md) gains a module-layout section, and seven spec sentences in six files that named cli.py as the home of moved code now name the new module.

Backwards compatibility

Compatible: every name kiro_crew.cli bound before still resolves there as the same object (test/campaign_facade_inventories/kiro_crew.cli.json, 46 names, checked by test/test_campaign_facades_base_public_names.py); the console script, python -m kiro_crew and every import path are unchanged.

Reader: src/kiro_crew/platform_compat.py:exit_after_failed_restart_exec -- chat -- imports drain_log_queue_before_hard_exit from kiro_crew.cli at call time; the facade serves the cli_logging function (test_restart_pruned_interpreter_guard.py, test_gateway_exit_path.py)
Reader: src/kiro_crew/slack/events.py:_handle_restart -- chat -- same lazy from kiro_crew.cli import drain_log_queue_before_hard_exit, same object (test_gateway_exit_path.py)
Reader: src/kiro_crew/slack/gateway_runtime/exit_path.py:_shutdown_and_exit -- chat -- same lazy import, same object; its _stop_log_queue_listener import is served the same way (test_gateway_exit_path.py, test_restart_waits_for_cut_turns.py)

Move audit

src/kiro_crew/cli.py: 3902 -> 1121 lines; moved 31.13% (python-ast)
   changed: main [FunctionDef] 2542 lines
   changed: _fd_targets_file [FunctionDef] 16 lines

move_audit.py counts main as one unit. The supplementary per-statement audit finds all 519 top-level statements of the base main AST-identical at HEAD (462 in the registrar modules, 57 still in cli.py), so main changed only by losing them and gaining the registrar calls. The only other changed unit, _fd_targets_file, rewords one docstring line ("Used to detect" -> "Detects") for the comment-history gate. One kept line changes: the facade's logger = logging.getLogger(__name__) becomes logging.getLogger("kiro_crew.cli") — the same object under a normal import, and the one the owners bind, so the mirror's one-object-per-name install also holds when the file runs as __main__ (python -m kiro_crew.cli, which at base ran the body and exited 0; test_the_facade_installs_when_it_runs_as_main pins it). Comment-only edits in moved code: 21 leading comments that only repeated the command name are dropped (the registrar's name says it), the base's misplaced # policy — governance model inspection comment moves from above tailnet to above policy, the cloud block's comment spells "Kiro Crew", and three moved comments that pointed at text left behind in cli.main now say where it is (--no-jail comment "above" -> "in cli.main"; the deferred dashboard.urls import's "cli.py's module scope" -> "the module scope import kiro_crew.cli loads"). The two workspace --dir help strings keep their base text and carry # brand-ok (help text is behaviour).

Behaviour proof: the full argparse tree main() builds — every subparser's format_help(), every action's option strings, dest, default, type, choices, help and metavar, argument and mutually-exclusive groups, and the order of the subcommand map — dumps byte-identical at base and HEAD.

Changes main made to the moved code while this PR was open moved the same way and are in the dumps and audit above:

Upstream change Base change in cli.main Home at this head
#19357 (kas) the kas parser block and its dispatch branch cli_parser_gateway.register_kas_parser, called after register_sandbox_parser; the dispatch branch stays in main
#20980 (spawn run --agent/--crew) two epilog lines and two spawn_run.add_argument calls cli_parser_agent.register_spawn_parser
#21159 (consolidation message) _consolidate_cmd's refused-pass message cli_knowledge._consolidate_cmd

This head was pushed onto the branch from outside the campaign's push queue. Running the split recipe on current main produces the same commit, byte for byte in cli.py and cli_parser_agent.py and hunk for hunk in every file, so it is the head that was reviewed. The Goal line's figures were measured at this PR's first base; at this head cli.py goes from 3,902 lines to 1,121.

Diff alignment: git diff and git diff --minimal add the same lines in every changed file except cli.py, where the default diff adds 202 lines and --minimal 124. The 78 extra lines are unchanged code that stays in cli.py, shown by git's default (heuristic) diff as removed and added again: the sub = parser.add_subparsers(...) call, the gateway parser block, and the register_perf_parser / register_bench_parser / register_desktop_parser calls. No blank-line or comment layout of cli.py lines the two up at this base (every single and paired layout toggle in main's parser region was tried), and the added-line gates that read the default diff pass on these lines.

Tests

  • test/test_cli_split_facade.py (new): the patch scan reads every spelling tests use and nothing else; it finds 14 known seams (non-vacuity); every scanned name is routed to every owner holding it, with a blinded-index self-test; a patch of each scanned name through the facade reaches every holder; owners, no exclusion, no forwards; no owner or registrar imports the facade or an owner; served names from outside the family stay visible to type checkers, and every base public name type-checks through the facade (with a self-test); owners log as kiro_crew.cli; the log-queue slot lives in cli_logging and a facade write lands there; registrars read no patched name (with a self-test); main calls every registrar exactly once, before hide_internal_commands; the facade installs when the file runs as __main__; and scripts/leaf_test_scope.corpus_gates derives the file as a corpus gate, since it reads the whole test tree.
  • test/test_cli_split_dispatch.py (new): runs the real main for every command but gateway (test_cli.py's lock-refusal and --seed tests drive that branch in-process), with the boot steps and the handler as recorders, and pins which handler each command reaches and with what, the prologue's order, the KIROCREW_PORT refusals and the bare-kirocrew banner. These branches were exercised only by subprocess tests, which coverage does not see.
  • test/test_cli_gateway_boot.py (new): the lock-refusal port and bind-address diagnostics, the configured port read through a cli.KiroCrewConfig patch. It is a separate 69-line file because these are the cli_gateway_boot owner's own coverage-floor tests, under the test_cli_<module>.py convention.
  • Re-pointed source pins (assertions unchanged, each with a mutation proof that turns it red in the new home): test_pod.py (pod --approval choices, pod_* names), test_packaged_docs_runtime_facts_b78.py, test_denied_commands_security.py, test_file_delivery_consent.py, test_internal_python_isolation.py, test_platform_cpp_seam_coverage.py, test_spawn_audit.py (BENIGN row), test_cli_lazy_imports.py (its function-local import scan walks cli.main joined with the cli_parser_* registrar functions, so the kas block's cli_kas import keeps its case: the same 50 node ids as on main), and the negative pins test_aws_consent.py, test_owner_only_files.py, test_cli.py::TestBannerBranding now scan cli.py joined with every split-out module. Comments in those files that named cli.py as the home of a moved construct now name the new one (two in test_pod.py, one in test_platform_cpp_seam_coverage.py, one docstring in test_denied_commands_security.py); no assertion changed.
  • Local run at this head: the cli test floor (142 files that import, patch or read kiro_crew.cli or a split-out module, the kas and spawn run --agent/--crew tests, plus the facade, line-cap, encoding and flake guards): 11052 passed, 18 skipped, 0 failed; mypy over src/kiro_crew clean. scripts/local-gate.py --dry-run selects 2144 backend and 648 frontend files, so the floor is the targeted run and CI runs the full matrix. New tests: 5 runs at -n0 and one at -n 3 (92 passed), all green; no sleep, clock or port in them.
  • Gates run locally: flake8, isort, black, mypy (src/kiro_crew), comment history, brand, harness parity, subprocess encoding, agent-sdk boundary, sync-io-in-async (with a planted-call proof that it scans both moved coroutines), memory-store seam, file line cap, docs lint, feature map, semgrep (CI command, 0 findings).

CI path references

No workflow file changes. AUTOSDE.yaml rule no-new-work-on-gateway-boot-path (blocking) named src/kiro_crew/cli.py; it now also names src/kiro_crew/cli_gateway_boot.py, src/kiro_crew/cli_jail.py, src/kiro_crew/cli_knowledge.py, src/kiro_crew/cli_logging.py and src/kiro_crew/cli_parser_*.py. All of them are imported at module scope by import kiro_crew.cli, which the gateway runs before asyncio.run, so the code that left cli.py stays under the rule that covered it there. Path globs only; the rule text is unchanged.

Prose citations (L29)

Comments and docstrings that named cli.py as the home of a moved construct; only the cited path changed:

  • test/test_pod.py:8029 cli.py -> cli_parser_admin.py (the pod --approval choices); :8049 cli.py repeats the choices literal -> cli_parser_admin.py repeats ...
  • test/test_platform_cpp_seam_coverage.py:107 cli.py -> cli_jail.py (the ctx.jail two-step)
  • test/test_denied_commands_security.py:565-568 docstring: cli.py builds its parser inline in main() -> cli.main() builds its parser inline from the cli_parser_* registrars
  • src/kiro_crew/acp/runtime.py:772 (see cli.py) -> (see cli_logging.py) (the RotatingFileHandler)
  • src/kiro_crew/history_index_worker.py:97 (see cli.py and session_lifecycle.py) -> (see cli_logging.py and session_lifecycle.py) (the os._exit drain)
  • src/kiro_crew/memory.py:251, test/test_memory_stores.py:542 cli.pytakes the first -> cli_knowledge.pytakes the first (MemoryStore() in _consolidate_cmd)
  • test/test_consolidate_cmd.py:25 paths in cli.py -> paths in cli_knowledge.py
  • src/kiro_crew/pod/runtime.py:188 The top-level ``cli.py`` repeats the literal -> The top-level ``cli_parser_admin.py`` repeats the literal
  • src/kiro_crew/acp/client_lifecycle.py:108 (see cli.py) -> (see cli_logging.py) (the RotatingFileHandler)
  • src/kiro_crew/acp/client_lifecycle.py:167 (session_allocation.py calls -> (session_allocation_parts/get_or_create.py calls (where provider.client.rekey is called, as acp/session_provider.py already says)

Manual verification

N/A — unit coverage sufficient: the change moves code without changing it, and the argparse-tree dump plus the per-statement audit prove that directly.

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

Contribution License Agreement

Contributed under the project's Apache-2.0 license (see CONTRIBUTING.md).

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 14:23
@bolichen97
bolichen97 requested a review from mbriones98 October 15, 2026 14:23
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 571f929
  • What rule changed: one row of NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py now names cli_logging.py instead of cli.py, because _setup_cli_logging and its install_log_redaction() calls moved there verbatim; no rule text, regex or allow/deny logic changed.
  • Before -> after (what was allowed/blocked, now): before, the drift guard classified the install_log_redaction() call site in cli.py as a non-egress installer; after, it classifies the same call site in cli_logging.py the same way, and nothing allowed or blocked changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the redaction drift guard would misclassify the CLI log-redaction installer site and test_security_posture would fail; no command, secret path or user access depends on this row.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes; test_security_posture.py passes on this head, and a mutation that reverts the row to "cli.py" turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and test_allowlist_has_no_stale_entries red.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 106-file cli test floor passed on this head (9342 passed, 18 skipped), and the argparse tree kirocrew builds is byte-identical to main's.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.cli held still resolves there as the same object, checked by test_campaign_facades_base_public_names.py and test_cli_split_facade.py.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_cli_logging.py, test_facade_mirror_guards.py and the cli floor all passed locally on this head.
  • How to undo: revert this one commit; the row and the moved logging code return to cli.py together.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for bc8edc9.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision bc8edc99582a8160cd902f9293bfaaedbb2af08a 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 added the readiness: checking Automated validation is still running label Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

Check that the one kept-line change, logging.getLogger("kiro_crew.cli"), leaves python -m kiro_crew.cli exiting as it did at base.

Not justified as shipped

  • Item 9 — undeclared: - AcpSessionProvider.rekey (session_allocation.py calls → session_allocation_parts/get_or_create.py is a comment fix unrelated to the cli split.

What this change ships

Inventory (9 items) — 8 justified

Intent: keep cli.py under the 2,000-line cap without changing how kirocrew behaves. This is a refactor; it is neither a FIX nor an ADDITION.

  1. cli.py is split into three parser-registrar modules and four helper modules; the CLI tree dumps byte-identical — justified
  2. Every name kiro_crew.cli bound before still resolves there, through the existing _facade_mirror used by 33 modules — justified
  3. cli.py's row leaves the line-cap baseline — justified
  4. The boot-path rule in AUTOSDE.yaml also covers the new cli_* modules — justified
  5. The security posture lists cli_logging.py as the module that installs log redaction — justified
  6. The facade logger is pinned by name, so the mirror also installs when run as __main__ — justified
  7. Source-scanning tests now read cli.py plus its split-out modules; no assertion is deleted — justified
  8. Spec and comment pointers name the new home of the moved code — justified
  9. A comment in client_lifecycle.py now points at session_allocation_parts/get_or_create.py — undeclared

[FIRST-PRINCIPLES-REVIEWED] bc8edc9

Description read

[DESCRIPTION-READ] cc016d9ff9b842ea80f724fbc8a2bde25981d8ba639795b8dcd7f72ce4f89b40

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] bc8edc9

Description read

[DESCRIPTION-READ] b7f482416e0c78845c42dfb06303ad07d64508333a81229b40a2ad79e916eac1

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] bc8edc9

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

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bc8edc9

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 14:35
@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 15, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-g21-cli branch from 571f929 to 6645984 Compare October 15, 2026 16:34
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 6645984
  • What rule changed: one row of NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py now names cli_logging.py instead of cli.py, because _setup_cli_logging and its install_log_redaction() calls moved there verbatim; no rule text, regex or allow/deny logic changed.
  • Before -> after (what was allowed/blocked, now): before, the drift guard classified the install_log_redaction() call site in cli.py as a non-egress installer; after, it classifies the same call site in cli_logging.py the same way, and nothing allowed or blocked changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the redaction drift guard would misclassify the CLI log-redaction installer site and test_security_posture would fail; no command, secret path or user access depends on this row.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes; test_security_posture.py passes on this head, and a mutation that reverts the row to "cli.py" turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and test_allowlist_has_no_stale_entries red.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 106-file cli test floor passed on this patch (9342 passed, 18 skipped; this head is the same patch rebased), and the argparse tree kirocrew builds is byte-identical to main's.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.cli held still resolves there as the same object, checked by test_campaign_facades_base_public_names.py and test_cli_split_facade.py.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_cli_logging.py, test_facade_mirror_guards.py and the cli floor all passed locally on this patch (rebased unchanged onto main).
  • How to undo: revert this one commit; the row and the moved logging code return to cli.py together.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Oct 15, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-g21-cli branch from 6645984 to 25464a7 Compare October 15, 2026 21:58
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main 10b7fa7 and re-cut with the split recipe. This head supersedes the earlier head 6645984.

  • Upstream port: feat(kas): run kas from kiro crew's own pinned engine bundle #19357 added the kas command to cli.main. Its parser block moved unchanged into cli_parser_gateway.register_kas_parser, and main calls it after register_sandbox_parser, the same place it registers on main. Its dispatch branch stays in main.
    • The full argparse tree dumps byte-identical on main and on this head.
    • All 517 statements of main's main() are found unchanged at this head.
    • test_cli_split_dispatch.py gains a kas status row.
  • Facade inventory: following the new one-file-per-facade layout, the kiro_crew.cli names (46 base public names, 42 rebound) now live in test/campaign_facade_inventories/kiro_crew.cli.json. test_campaign_facades_base_public_names.py is unchanged from main.
  • test_cli_lazy_imports.py: its function-local import scan now walks cli.main together with the cli_parser_* registrar functions, so the kas block's import keeps its case. The collected node ids are the same 50 as on main.
  • metrics.md: keeps main's text. That sentence names the kirocrew run CLI, whose session manager lives in cli_server.py, not in any module this PR splits out.
  • Diff alignment: git diff and git diff --minimal add the same lines in all 38 changed files (cli.py: 124 and 124). CI is re-running on the new head.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 25464a7
  • What rule changed: one row of NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py now names cli_logging.py instead of cli.py, because _setup_cli_logging and its install_log_redaction() calls moved there verbatim; no rule text, regex or allow/deny logic changed.
  • Before -> after (what was allowed/blocked, now): before, the drift guard classified the install_log_redaction() call site in cli.py as a non-egress installer; after, it classifies the same call site in cli_logging.py the same way, and nothing allowed or blocked changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the redaction drift guard would misclassify the CLI log-redaction installer site and test_security_posture would fail; no command, secret path or user access depends on this row.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes; test_security_posture.py passes on this head, and a mutation that reverts the row to "cli.py" turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and test_allowlist_has_no_stale_entries red.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 141-file cli test floor ran on this head (10994 passed, 18 skipped; the 10 failures are test_cli.py doctor tests that flag this host's nearly full disk and fail identically on an unmodified export of main), and the argparse tree kirocrew builds is byte-identical to main's, the kas command included.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.cli held still resolves there as the same object, checked by test_campaign_facades_base_public_names.py (inventory test/campaign_facade_inventories/kiro_crew.cli.json) and test_cli_split_facade.py.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_cli_logging.py, test_facade_mirror_guards.py and test_spawn_audit.py passed locally on this head, with main's new acp/kas_bundle.py rows kept beside this row.
  • How to undo: revert this one commit; the row and the moved logging code return to cli.py together.

@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
  • gateway's flags stay in cli.py for pod.runtime_boot.target_supports_flag

Disposition: verified, no change needed. The gateway parser block is the one command block this split keeps inline in cli.main, so its flag literals ("--no-tunnel", "--no-crons" and the rest) are still in src/kiro_crew/cli.py's text.
target_supports_flag reads the checkout's own cli.py, and test/test_pod.py::TestBootTimeSettings::test_the_probe_accepts_this_very_repo passes on this head.
The split recipe pins it too: gateway is its only STAYS command, and the module-layout section of docs/system-specs/modules/cli.md says new gateway flags go in cli.py for this reason.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 16, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 5cea02b
  • What rule changed: one row of NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py now names cli_logging.py instead of cli.py, because _setup_cli_logging and its install_log_redaction() calls moved there verbatim; no rule text, regex or allow/deny logic changed.
  • Before -> after (what was allowed/blocked, now): before, the drift guard classified the install_log_redaction() call site in cli.py as a non-egress installer; after, it classifies the same call site in cli_logging.py the same way, and nothing allowed or blocked changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the redaction drift guard would misclassify the CLI log-redaction installer site and test_security_posture would fail; no command, secret path or user access depends on this row.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes; test_security_posture.py passes on this head, and a mutation that reverts the row to "cli.py" turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and test_allowlist_has_no_stale_entries red.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 142-file cli test floor ran on this patch (10885 passed, 18 skipped, 0 failed), and the argparse tree kirocrew builds is byte-identical to main's, the kas command included.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.cli held still resolves there as the same object, checked by test_campaign_facades_base_public_names.py (inventory test/campaign_facade_inventories/kiro_crew.cli.json) and test_cli_split_facade.py.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_cli_logging.py, test_facade_mirror_guards.py and test_spawn_audit.py passed locally on this head, with main's new acp/kas_bundle.py rows kept beside this row.
  • How to undo: revert this one commit; the row and the moved logging code return to cli.py together.

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

Copy link
Copy Markdown
Contributor Author
  • gateway's flags stay in cli.py for pod.runtime_boot.target_supports_flag

Disposition: verified, no change needed. The gateway parser block is the one command block this split keeps inline in cli.main, so its flag literals ("--no-tunnel", "--no-crons" and the rest) are still in src/kiro_crew/cli.py's text.
target_supports_flag reads the checkout's own cli.py, and test/test_pod.py::TestBootTimeSettings::test_the_probe_accepts_this_very_repo passes on this head.
The split recipe pins it too: gateway is its only STAYS command, and the module-layout section of docs/system-specs/modules/cli.md says new gateway flags go in cli.py for this reason.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • gateway's flags stay in cli.py for pod.runtime_boot.target_supports_flag

Disposition: verified, no change needed. The gateway parser block is the one command block this split keeps inline in cli.main, so its flag literals ("--no-tunnel", "--no-crons" and the rest) are still in src/kiro_crew/cli.py's text.
target_supports_flag reads the checkout's own cli.py, and test/test_pod.py::TestBootTimeSettings::test_the_probe_accepts_this_very_repo passes on this head.
The split recipe pins it too: gateway is its only STAYS command, and the module-layout section of docs/system-specs/modules/cli.md says new gateway flags go in cli.py for this reason.

@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. The triage automation held this on a size, path or move-check rule only; every review lane is clean. Any lane note is accepted as follow-up work.

@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 16, 2026
mbriones98
mbriones98 previously approved these changes Oct 16, 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 5cea02b; no behavior change.

cli.py was 3,862 lines and main() alone 2,502, past the 2,000-line cap.
main() keeps the prologue, the top-level parser with the gateway command
(pod's target_supports_flag reads its flags from cli.py) and the internal
mcp-* servers, the boot steps and the dispatch chain. Every other
command's arguments move verbatim into one register_<command>_parser per
command in cli_parser_gateway/agent/admin, called in the same order. The
jail gate, gateway-launch helpers, knowledge/consolidate handlers and the
CLI logging move to cli_jail, cli_gateway_boot, cli_knowledge and
cli_logging, owners of a kiro_crew._facade_mirror facade, so every name
kiro_crew.cli held still resolves there and a patch through it reaches
the module that reads it. The argparse tree main() builds is unchanged.

Part of #20192
@bolichen97
bolichen97 dismissed stale reviews from mbriones98 and KiroCrewCaptain via bc8edc9 October 16, 2026 20:34
@bolichen97
bolichen97 force-pushed the refactor/linecap-g21-cli branch from 5cea02b to bc8edc9 Compare October 16, 2026 20:34
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: bc8edc9
  • What rule changed: one row of NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py now names cli_logging.py instead of cli.py, because _setup_cli_logging and its install_log_redaction() calls moved there verbatim; no rule text, regex or allow/deny logic changed.
  • Before -> after (what was allowed/blocked, now): before, the drift guard classified the install_log_redaction() call site in cli.py as a non-egress installer; after, it classifies the same call site in cli_logging.py the same way, and nothing allowed or blocked changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the redaction drift guard would misclassify the CLI log-redaction installer site and test_security_posture would fail; no command, secret path or user access depends on this row.
  • Evidence checked (which sandbox result proves it): no sandbox behaviour changes; test_security_posture.py passes on this head, and a mutation that reverts the row to "cli.py" turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted and test_allowlist_has_no_stale_entries red.
  • No regression:
    • Tools still work (which tools/commands were run, result): the 142-file cli test floor ran on this patch (10885 passed, 18 skipped, 0 failed), and the argparse tree kirocrew builds is byte-identical to main's, the kas command included.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.cli held still resolves there as the same object, checked by test_campaign_facades_base_public_names.py (inventory test/campaign_facade_inventories/kiro_crew.cli.json) and test_cli_split_facade.py.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_cli_logging.py, test_facade_mirror_guards.py and test_spawn_audit.py passed locally on this head, with main's new acp/kas_bundle.py rows kept beside this row.
  • How to undo: revert this one commit; the row and the moved logging code return to cli.py together.

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

bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author
  • logging.getLogger("kiro_crew.cli") keeps python -m kiro_crew.cli exiting as at base

Disposition: verified, no change needed. At base python -m kiro_crew.cli runs the module body as __main__ and exits 0, because the file has no __main__ guard and main() is not called.
Bound by its literal name, the facade logger is the same object the owners bind, so the mirror's one-object-per-name install also passes under __main__. Under getLogger(__name__) the install would refuse the module, and the run would die on import.
test/test_cli_split_facade.py::test_the_facade_installs_when_it_runs_as_main runs python -m kiro_crew.cli status in a subprocess and asserts exit status 0. Under a normal import __name__ is kiro_crew.cli, so getLogger returns the same logger as at base.

@bolichen97

bolichen97 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author
  • Nothing to check

Disposition: acknowledged. The First Principles verdict for this head asks for nothing. The lane's earlier question, whether the gateway flags stay in cli.py for pod.runtime_boot.target_supports_flag, still holds. The gateway parser block is the one command block kept inline in cli.main, and test_the_probe_accepts_this_very_repo passes.

@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 16, 2026
@bolichen97
bolichen97 merged commit 140e38b into main Oct 16, 2026
109 of 112 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-g21-cli branch October 16, 2026 22:43
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 16, 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.

4 participants