Skip to content

refactor(apps): split routes.py into a facade and nine owners - #22131

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s51-routes
Oct 21, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s51-routes

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring src/kiro_crew/apps/routes.py under the 2,000-line cap by moving its code into ten sibling modules, one endpoint family each, with no change in behaviour.

apps/routes.py was 5,188 lines on the shrink-only line-cap baseline. The repository rule is that no hand-written file exceeds 2,000 lines (scripts/check_file_line_cap.py), and every change to the app management REST API (install, update, uninstall, enable, the registry, the UI and art routes, the backend proxy) landed in that one file.

Why it matters

Reviews, merges and blame of any app-route change paid for the whole 5,200-line file, and the next feature PR would have grown a file the cap already forbids. With one owner per endpoint family, new work has an obvious home and the file leaves the line-cap baseline.

Not a goal

  • No behaviour change: no route, status code, error text, lock, redaction, spawn or logging change.
  • No change to the import path or patch surface: callers and tests keep using kiro_crew.apps.routes.
  • No new tests of new behaviour; the new test file pins the split itself.
  • No change to the website or any CI workflow.

What changed (motivation → approach → change)

Every top-level definition moves verbatim into the owner of its endpoint family, and apps/routes.py becomes a kiro_crew._facade_mirror facade (the shape of the merged apps/bridges.py and apps/manager.py splits). A monkeypatch.setattr or mock.patch of kiro_crew.apps.routes.<name> still reaches every owner that reads the name, and a read is served by the owner that defines it.

The facade also keeps, verbatim and in place, the five handlers whose blocking file-system calls .github/sync-io-in-async-fs-baseline.txt counts against this path (13 sites, row unchanged), the units that call them (handle_uninstall_app and handle_migrate_cleanup call _run_uninstall), the art route (it keeps the _ART_IMAGE_EXTENSIONS import and both art-extension screening sites in one file, as test_app_art_route.py pins) and the route table (it names every handler, and owners never import the facade). The fs gate (#22084) counts a moved blocking call as an added one, so moving those handlers would fail it (campaign ruling L67). That is the only reason routes.py ends at 1,852 lines instead of the 1,600 the campaign aims for; it is under the 2,000-line cap.

Module under src/kiro_crew/apps/ Lines Owns
routes.py 1,852 the facade and import path; handle_install_app, handle_uninstall_app + _run_uninstall, handle_app_config, handle_app_art_file, _fetch_git_blob + handle_blob_proxy, handle_migrate_cleanup, register_app_routes
routes_lifecycle.py 224 steps install, update, uninstall, enable and disable share (off-loop register, backend start and stop, the startup-hook refusal, the warning redactor)
routes_proxy.py 447 the reverse proxy to an app's backend and its per-app secret cache
routes_static.py, routes_art.py 515, 280 an installed app's UI bundle and the dev-mode toggle; reading declared art, and the repository validators and fetch bounds the blob proxy shares with the registry routes
routes_listing.py 354 the app list, one app (each with its cached update state), its manifest, the publish providers
routes_install.py, routes_uninstall.py 306, 137 update and external registration; the uninstall preview and the bounded cron deregistration retry
routes_enable.py 766 enable, disable, open
routes_registry.py 851 browsing, refreshing and installing from the registry, and the app-update bell notes the catalog listing raises; the configured registry list

Owners import only the owners before them and never the facade; the facade imports the owner names its own handlers call, and every import that ran inside a handler still runs there. routes_uninstall.py stays its own small module (137 lines): it holds the uninstall preview and the cron-cleanup retry the kept _run_uninstall calls, which belong to no other owner. Every owner logs as kiro_crew.apps.routes (L25). The facade keeps its import header byte-identical for importers (a setup.cfg F401 row, accounted for by test_routes_facade.py). The owning spec (app-kit-platform.md §29) records the layout; the tests and registries that read this file by path follow their constructs.

Backwards compatibility

Compatible: every name the module bound before is still served at kiro_crew.apps.routes, as the same object its owner holds, or still defined in the facade (test_routes_facade.py::test_every_base_module_name_resolves_through_the_facade, test_campaign_facades_base_public_names.py, test_facade_mirror_guards.py).

  • Reader: src/kiro_crew/apps/manager_builtins.py:invalidate_app_secret_cache -- app -- call-time import of the facade, served from routes_proxy.py; test_app_slot_ownership.py
  • Reader: src/kiro_crew/apps/routes.py:invalidate_app_secret_cache -- app -- the facade imports it from routes_proxy.py for its kept install and uninstall handlers; test_app_slot_ownership.py
  • Reader: src/kiro_crew/apps/routes.py:handle_list_apps -- app -- the route table the facade keeps imports it from routes_listing.py; test_app_hook_health.py
  • Reader: src/kiro_crew/apps/routes_listing.py:collect_publish_providers -- app -- same module as its caller handle_publish_providers, and served by the facade; test_publish_providers.py
  • Reader: src/kiro_crew/apps/routes.py:handle_publish_providers -- app -- the route table the facade keeps imports it from routes_listing.py; test_apps_instances_loop_offload.py
  • Reader: src/kiro_crew/apps/routes.py:handle_get_app -- app -- the route table the facade keeps imports it from routes_listing.py; test_app_routes.py
  • Reader: src/kiro_crew/apps/routes.py:handle_get_manifest -- app -- the route table the facade keeps imports it from routes_listing.py; test_app_routes.py
  • Reader: src/kiro_crew/apps/routes.py:handle_update_app -- app -- the route table the facade keeps imports it from routes_install.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_register_external -- app -- the route table the facade keeps imports it from routes_install.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_uninstall_preview -- app -- the route table the facade keeps imports it from routes_uninstall.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_enable_app -- app -- the route table the facade keeps imports it from routes_enable.py; test_builtin_app_lifecycle.py
  • Reader: src/kiro_crew/apps/routes.py:handle_disable_app -- app -- the route table the facade keeps imports it from routes_enable.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_open_app -- app -- the route table the facade keeps imports it from routes_enable.py; test_s29_spawn_env_regression.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registry -- app -- the route table the facade keeps imports it from routes_registry.py; test_registry_refresh.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registry_refresh -- app -- the route table the facade keeps imports it from routes_registry.py; test_registry_refresh.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registry_install -- app -- the route table the facade keeps imports it from routes_registry.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registry_install_stream -- app -- the route table the facade keeps imports it from routes_registry.py; test_apps_routes_coverage.py
  • Reader: src/kiro_crew/apps/routes.py:handle_app_ui_file -- app -- the route table the facade keeps imports it from routes_static.py; test_app_ui_file_route.py
  • Reader: src/kiro_crew/apps/routes.py:handle_app_dev_mode -- app -- the route table the facade keeps imports it from routes_static.py; test_app_dev_mode.py
  • Reader: src/kiro_crew/apps/routes.py:handle_app_api_proxy -- app -- the route table the facade keeps imports it from routes_proxy.py; test_gateway_appkit_endpoints_signed_proxy.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registries -- app -- the route table the facade keeps imports it from routes_registry.py; test_registries_api.py
  • Reader: src/kiro_crew/apps/routes.py:handle_registries_refresh -- app -- the route table the facade keeps imports it from routes_registry.py; test_registries_api.py

No user-visible change: the security posture panel's "App lifecycle output" row still names apps/routes.py, which keeps _run_uninstall's redactor calls.

Tests

  • test/test_routes_facade.py (new): the facade serves a mirror over exactly the routes_* modules beside it; every module-level name the one-module file bound resolves through it to its owner's object or to the facade's own code; the handlers the fs baseline pins stay defined here; every import the facade binds is accounted for (with a planted-import self-test; F401 is off for this file); every owner logs as the facade; every served name is in a TYPE_CHECKING group (with a self-test); nothing outside the family imports an owner (relative imports resolved, with a self-test).
  • Re-pointed source pins (L30), assertions unchanged, each with a one-mutation reach proof (the mutated owner turns the test red, rc 1; all green unmutated): test_file_menu_items.py, test_app_denial_code.py, test_mcp_stub_freeze_ratchet.py.
  • Facade joined with its owners (L30 / L40(8)), assertions unchanged, each mutation-proven by a planted violation in an owner: test_builtin_app_lifecycle.py (two scans), test_apps_instances_loop_offload.py::test_registries_config_write_is_not_dispatched_with_a_bare_to_thread, test_conditional_get.py::test_every_media_route_uses_the_shared_helper (name and zero-argument signature kept for its caller in test_dashboard_agents_composition_contract.py), and the duplicate-set half of test_app_art_route.py::test_both_art_paths_screen_on_the_SAME_extension_set (a duplicate set planted in routes_static.py); its count == 3 half reads routes.py unchanged, which keeps the import and both screening sites.
  • Tests that read _run_uninstall, the route table or the git-tree removal site by path keep reading apps/routes.py, unchanged.
  • Determinism: the new file passes 5 runs at -n0 and one at -n 3; test_flake_pattern_ratchet.py passes.
  • At this head (main 7d6bfb49ca, which carries fix(security): tier redaction rules and redact through one composed pass #22592's single redact( pass): the related set (80 files: every test file this change edits, the facade, mirror, posture, redaction call-site, composed-pass, tier, error-code, inventory, line-cap and sync-io guards, and the tree scanners main changed) passed 4,816, 0 failed; check_inventory, line cap, both sync-io ledgers, flake8, isort, black, docs_lint, comment-history, brand and harness are clean; mypy over src/kiro_crew: no issues in 3,450 files; semgrep 1.78 with the CI configs and --baseline-commit: 0 findings.
  • Local floor on the previous re-cut (main bcd95337f5, before fix(security): tier redaction rules and redact through one composed pass #22592): scripts/run_scoped_tests.py's own related_targets over the diff with the bare stem dropped for generic-stem files (the facade's stem routes alone matches about 960 test files), plus every test file that imports or patches kiro_crew.apps.routes and the facade, mirror, posture, error-code, inventory, line-cap, flake, boot-path and sync-io guards: 480 files, 28,288 passed, 47 skipped, 1 failed (-n 3). The one failure, test_search_segment_route.py::test_one_dictionary_per_host, was environmental: the local venv predated the rjieba dependency feat(search): split Chinese queries into words with a shared dictionary #22303 added, and with it installed the file passes (32 passed). Owner coverage on that floor: 90-100% per module (floor 80%). mypy over src/kiro_crew: no issues in 3,437 files. scripts/check_sync_io_in_async.py: both ledgers pass. semgrep 1.78 with the CI configs and --baseline-commit: 0 findings, no parse errors. The installed wheel, built from a git archive export, imports the facade and all nine owners. scripts/local-gate.py --base <main> --dry-run selects about 3,540 backend test files, so it was not run whole (SD14); CI runs it.

Manual verification

N/A — structural move. The move audit proves the bodies are unchanged, and the related tests and guards run them; a fresh interpreter imports the facade first, and through each of its importers (dashboard/routes/system.py, dashboard/handlers/security_trusted_apps.py, dashboard/handlers/security.py, apps/manager_builtins.py, dashboard/server.py), without a cycle.

Move audit

src/kiro_crew/apps/routes.py: 5227 -> 1852 lines; moved 98.27% (python-ast)
   changed: handle_register_external [AsyncFunctionDef] 76 lines
   changed: _check_min_version [FunctionDef] 6 lines

The two changed units differ from BASE only in their docstrings: "KiroCrew" → "Kiro Crew" (brand gate on moved lines); with that substitution applied to BASE, both are AST-identical. Every other unit is AST-identical. Other non-move edits, all AST-neutral: the logger binding in each owner is logging.getLogger("kiro_crew.apps.routes") instead of getLogger(__name__); _blocked_repos = {"KiroCrew"} in handle_registries carries a trailing # brand-ok: comment (the GitHub repository name); two own-line # nosemgrep: markers sit above pre-existing findings that semgrep's path-keyed baseline would read as new (_notify_builtin_service's returned warning string, handle_app_api_proxy's secret-read failure log); the _run_lifecycle_script alias comment travels with that import into routes_enable.py; ten moved comment lines (nine edits in seven units) that pointed "above", "below" or "in this file" at code now in another module name that module; and kept handle_app_config's config_path = data_dir / "config.json" carries a trailing # noqa: F811 (the header's config.loader.config_path import stays for the facade surface while its other readers moved).

Diff alignment (L36)

Every changed file adds the same lines under git's default diff and --minimal, except src/kiro_crew/apps/routes.py: 276 added under the default diff, 143 under --minimal (L41 exception granted by the campaign Master for this file). The 133 lines only the default diff shows as added are byte-identical kept code (every one is a line of the base routes.py; one is blank), re-shown because the kept handle_uninstall_app shares its request-handling boilerplate with the deleted handle_update_app just above it: handle_uninstall_app (head lines 341-401, 43 lines), the start of _run_uninstall (404-468, 57), handle_app_art_file (1013-1014, 2) and handle_app_config (1116-1157, 31). None carries a gate token (brand, comment history, internal content, model ids, woke, cross-platform, file-system calls); every added-line gate passes on the default diff, the sync-io gate included. A search over 32 layouts (the type-checking manifest at the end or after each kept unit, the glue imports in two spellings, the owner imports in the header or after the logger) found none below 141 at the original base (reports/S51/l36-layout-search.txt in the campaign control root).

Citations and references

  • Corrected (SD27 / L29), each on its own line: the owning spec app-kit-platform.md (writer and reader cites of moved code, plus the new §29 owner map), docs/feature-map/README.md (the Handler cells of six rows name the defining modules, plus the one-line facade note beside the cron and prompts ones), security.md (3), governance.md, docs/architecture/app-platform-trust-model.md, docs/app-kit/manifest-reference.md, src/kiro_crew/deploy/DESIGN.md; the RFC line cites rfc-everything-is-an-app.md (apps/routes.py:2336, apps/routes.py:503) and rfc-s3-backup.md (apps/routes.py:310) become symbol cites, and their three docs-lint line-ref rows are deleted; comments and docstrings in apps/manifest.py (2), apps/proxy_auth.py, apps/registry_pipeline/install.py, dashboard/server.py, dashboard/server_runtime/app_platform.py, dashboard/state_parts/dashboard_state.py, dashboard/token_auth_paths.py, publish_governance.py, apps/builtins/dev_fleet/http_api.py (2), apps/builtins/crew_companion/store.py, apps/builtins/meetings/backend/routes/audio_import.py, seven builtin platform tests (auto_research, aws_control, command_bar, crew_companion, personal_shopper, spec_builder, workflows), and test_app_proxy_auth.py (2), test_md_notebook.py, test_app_proxy_target_ratchet.py, test_builtin_app_platform_declarations.py, test_lifecycle_hooks.py, test_s29_spawn_env_regression.py (2), test_open_command_bus_locators.py (module docstring), test_setup_hooks_contract.py, test_file_menu_items.py, test_app_denial_code.py, test_mcp_stub_freeze_ratchet.py.
  • Kept as written: every cite of a handler routes.py keeps (install, uninstall, config, art, blob proxy, migrate-cleanup, the route table) and module-name prose. Inside kept _run_uninstall, the comment "the same shape the preview offloads above" now points at handle_uninstall_preview in routes_uninstall.py; it stays verbatim so the kept code is byte-identical to the base.
  • Granted data edit (Master ruling): apps/builtins/auto_improvement/spine/agent_discovery.py _LOW_VALUE_MARKERS gains "/apps/routes_", so the auto-improvement agent keeps ranking the route code last, as it ranked routes.py.
  • Registries: .github/file-line-cap-baseline.txt row for apps/routes.py deleted (1,852 lines); .github/sync-io-in-async-fs-baseline.txt unchanged (13 src/kiro_crew/apps/routes.py); error-code-baseline.json redistributes the apps/routes.py row (60 / 8 / 2) over routes.py (22 / 2 / 1) and seven owner rows, totals unchanged, _compliant untouched; security_posture.py: routes_enable.py, routes_lifecycle.py, routes_listing.py and routes_registry.py join NON_EGRESS_REDACTION_MODULES as partitions of the "App lifecycle output" sink, whose row keeps naming apps/routes.py; setup.cfg gains the src/kiro_crew/apps/routes.py: F401 row (Master ruling, S32 precedent); test/campaign_facade_inventories/kiro_crew.apps.routes.json freezes the facade's 124 BASE public names and 93 rebound homes.
  • Function __module__: moved handlers report their owner module; no test or production code reads a routes function's __module__ (route-order tests compare __qualname__, unchanged).
  • CodeQL: the dismissed false positives on handle_install_app and _fetch_git_blob stay on routes.py; the one on handle_registry_install_stream moves with it to routes_registry.py (re-dismissed as UI language: non-catalog BCP-47 tag is accepted but only half-applies (English chrome + foreign-language tool-call pills) #1130).
  • CI path references: none. security_posture.py is sensitive, so this PR carries the Sensitive change review comment.

Baselined growth (L56 addendum 1)

src/kiro_crew/security_posture.py: main row 3,181, main 3,470 -> HEAD 3,475 (+5: four NON_EGRESS_REDACTION_MODULES rows and their one comment line, which the redactor census requires for the new owners). Its own split scope (S40) has not launched; the row is unchanged.

Related Issues

Part of #20192
Follow-up: #22459 moves the handlers routes.py keeps to owners once the sync-io fs gate reads a move as a move (or their blocking calls leave the loop).

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

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 19, 2026 08:45
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 40f722883d2ddee74dd731b03e2f05b84d6f8166 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

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

github-actions Bot commented Oct 19, 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 40f7228.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 17c0b5a
  • What rule changed: No redaction or gate rule changes. security_posture._REDACTION_SINKS row "App lifecycle output" now names apps/routes_lifecycle.py (where the shared dual-pass _redact_warning moved verbatim) instead of apps/routes.py, and apps/routes_enable.py, routes_listing.py, routes_registry.py, routes_uninstall.py join NON_EGRESS_REDACTION_MODULES as partitions of that sink.
  • Before -> after (what was allowed/blocked, now): Before, every redactor call of the app routes sat in apps/routes.py; after, the same calls sit unchanged in the owner modules (move audit: AST-identical units), so every warning, script output, install log and notice is redacted exactly as before; only the posture panel's module column for this sink changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A redactor call dropped in the move would leak a credential or exfiltration URL into an install, enable or uninstall response; the move audit, the sink tests and the census guard rule that out.
  • Evidence checked (which sandbox result proves it): No sandbox or command-floor path changes; test_security_posture.py (every named sink module exists and calls a redactor, every redactor call site is classified, no stale allowlist entry, partial-cover disclosure) passes, and dropping the two scanner calls from _redact_warning turns test_every_named_sink_module_actually_redacts red.
  • No regression:
    • Tools still work (which tools/commands were run, result): The 394-file local floor (every test that imports or patches kiro_crew.apps.routes plus the facade, mirror, posture and error-code guards) passed with 0 failures; the installed wheel imports the facade and all ten owners.
    • Backward compatible (old config / old data / old callers still work, how checked): Every name the module bound is still served at kiro_crew.apps.routes as the owner's own object (test_routes_facade.py, test_campaign_facades_base_public_names.py, test_facade_mirror_guards.py); no config, data or route changes.
    • Existing tests (which suites passed on this head): The CI matrix on this head; locally test_security_posture.py, test_routes_facade.py, test_facade_mirror_guards.py, test_error_code_contract.py and the 394-file floor.
  • How to undo: Revert this one commit; the row and the four allowlist entries go back with the code.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 40f722883d2ddee74dd731b03e2f05b84d6f8166 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: this is a behaviour-neutral split that follows the existing _facade_mirror precedent. The path-reading tests now scan the whole module family, so none of their pins were weakened.

Notes

  • routes.py stays at 1,852 lines because of the fs-baseline ruling. That leaves less than 150 lines of room before the 1,600-line split trigger. The next handler added to the kept set should go to an owner rather than grow the facade.

[DESIGN-REVIEWED] 40f7228

Description read

[DESCRIPTION-READ] dca0470c35bb1dd88421ab0a1bb23329f70585b9cf12d1019faf2bf35937f8b5

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 40f722883d2ddee74dd731b03e2f05b84d6f8166 — 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 does not.

First-Principles-Verdict: PASS

This is a pure verbatim split that the 2,000-line cap in AGENTS.md requires. The edits outside routes.py only re-point paths and baselines to follow the moved code.

Notes

  • Item 6 — undeclared: "/apps/routes_", was added to _LOW_VALUE_MARKERS in auto_improvement/spine/agent_discovery.py. It ranks the new owners the same as /routes.py was ranked before the split, so nothing behaves differently. It is the only non-pointer edit the description never mentions.

What this change ships

Inventory (7 items) — 6 justified

Intent: keep the app-management REST routes under the file-line cap without changing behaviour. This is a refactor (neither a FIX nor an ADDITION).

  1. apps/routes.py goes from 5,188 to 1,852 lines. It becomes a facade, and nine new routes_*.py modules own the endpoint families — justified
  2. routes.py leaves the line-cap baseline, and the docs-lint baseline is updated — justified
  3. error-code-baseline.json is split per owner, with the same totals — justified
  4. The four new owners join NON_EGRESS_REDACTION_MODULES as partitions of the sink already registered for routes.py — justified
  5. A setup.cfg F401 row keeps the facade's import header — justified
  6. The new owners get the auto-improvement low-value ranking marker — undeclared
  7. Path-only edits to comments, docs and tests re-point to the owners, plus the facade pin test_routes_facade.py and spec §29 — justified

[FIRST-PRINCIPLES-REVIEWED] 40f7228

Description read

[DESCRIPTION-READ] ede1a4b22d54ec5ce41e85ba71993e43e857d31baeb18f50e89f64bf1c4ff3cf

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 40f7228

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

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

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 40f7228

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

Comment thread src/kiro_crew/apps/routes_art.py Fixed
Comment thread src/kiro_crew/apps/routes_art.py Fixed
Comment thread src/kiro_crew/apps/routes_registry.py Dismissed
@bolichen97
bolichen97 enabled auto-merge (squash) October 19, 2026 09:05
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the "/apps/routes_" entry in _LOW_VALUE_MARKERS

rebutted: the entry keeps the ranking this code already had; it lowers nothing. At the base every app route lived in src/kiro_crew/apps/routes.py, which the existing "/routes.py" marker already ranks last.
After the split the same code sits in apps/routes_<role>.py, which "/routes.py" no longer matches, so without the entry it would start ranking normally; with it, ranking is unchanged.
It is documented in the PR body (Citations and references, "Granted data edit (Master ruling)") and follows the "/bridges_" precedent of #21948; the narrower /apps/routes_ spelling leaves aws_control/backend/routes_parts/ alone.

@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 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (merge conflict) at 17c0b5a.

GitHub now reports this branch as CONFLICTING with main. Main has since changed files this PR also edits, including security_posture.py, both .github baselines and the governance/security specs. To clear this, rebase onto main and resolve the conflicts; the new head needs a fresh review.

At this head the split is faithful. All 62 functions of apps/routes.py are AST-identical in the ten owners, every owner keeps the kiro_crew.apps.routes logger, and the auth and proxy files change only comments. The "App lifecycle output" sink row follows its 30 redactor calls with no row dropped. All AI lanes pass, the _LOW_VALUE_MARKERS punchline is answered, and the four CodeQL alerts match base false positives that were already dismissed.

— crew-pr-reviewer (r112)

@bolichen97 bolichen97 changed the title refactor(apps): split routes.py into a facade and ten owners refactor(apps): split routes.py into a facade and nine owners Oct 19, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s51-routes branch from 17c0b5a to b4a8157 Compare October 19, 2026 17:42
@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 19, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: b4a8157
  • What rule changed: No redaction or gate rule changes. security_posture.NON_EGRESS_REDACTION_MODULES gains apps/routes_enable.py, routes_lifecycle.py, routes_listing.py and routes_registry.py as partitions of the "App lifecycle output" sink, whose _REDACTION_SINKS row keeps naming apps/routes.py (which keeps _run_uninstall and its dual-pass redactor calls).
  • Before -> after (what was allowed/blocked, now): Before, every redactor call of the app routes sat in apps/routes.py; after, the moved calls sit unchanged in the four owners (move audit: AST-identical units) and the kept ones stay in routes.py, so every warning, script output, install log and notice is redacted exactly as before and the posture panel is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A redactor call dropped in the move would leak a credential or exfiltration URL into an install, enable or uninstall response; the move audit, the sink tests and the census guard rule that out.
  • Evidence checked (which sandbox result proves it): No sandbox or command-floor path changes; test_security_posture.py (every named sink module exists and calls a redactor, every redactor call site is classified, no stale allowlist entry, no module in both buckets, partial-cover disclosure) passes on this change.
  • No regression:
    • Tools still work (which tools/commands were run, result): The 460-file local floor (every test that imports or patches kiro_crew.apps.routes plus the facade, mirror, posture, error-code and sync-io guards) passed with 0 failures; the installed wheel imports the facade and all nine owners.
    • Backward compatible (old config / old data / old callers still work, how checked): Every name the module bound is still served at kiro_crew.apps.routes, as the owner's own object or the facade's own code (test_routes_facade.py, test_campaign_facades_base_public_names.py, test_facade_mirror_guards.py); no config, data or route changes.
    • Existing tests (which suites passed on this head): The CI matrix on this head; locally test_security_posture.py, test_routes_facade.py, test_facade_mirror_guards.py, test_error_code_contract.py, test_sync_io_in_async_gate.py and the 460-file floor.
  • How to undo: Revert this one commit; the four allowlist entries go back with the code.

@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 19, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: a mock.patch on a name the kept facade handlers and an owner both read

verified: a patch on the facade reaches the kept handlers and the owner. kiro_crew._facade_mirror writes a set on kiro_crew.apps.routes to the facade and to every owner that binds the same object.
invalidate_app_secret_cache is defined in apps/routes_proxy.py and read by the kept handle_install_app and _run_uninstall in apps/routes.py, which resolve it from the facade's own globals.
Probe at this head: under mock.patch("kiro_crew.apps.routes.invalidate_app_secret_cache") the mock is bound in routes and routes_proxy, and in both handlers' __globals__; on exit every holder is restored.
CI pins the same path: test_app_slot_ownership.py patches that facade name and asserts the uninstall calls it. test_facade_mirror_guards.py and test_routes_facade.py check reach for every patched name in the test corpus, this one included.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: are the moved definitions byte-identical to base

verified: the bodies are compared, not just the names. move_audit.py (merge-base 3e39e7a963, this head) compares each unit's AST: routes.py: 5188 -> 1848 lines; moved 98.26%, with 2 changed units, _check_min_version and handle_register_external, both docstring brand respellings.
A byte comparison of all 85 top-level units of the base routes.py against their homes finds 76 byte-identical. 7 match on tokens and differ only in a comment: 2 own-line nosemgrep markers, 1 brand-ok, the ruled # noqa: F811, and comment cites re-pointed to routes.py. The other 2 are the docstring edits.
Every one of these edits is listed in the PR body under the move audit.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 19, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s51-routes branch from b4a8157 to 4cfbb28 Compare October 19, 2026 20:55
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: the "/apps/routes_" marker only keeps the moved code at the rank "/routes.py" gave it

verified: the diff adds that one string to _LOW_VALUE_MARKERS in auto_improvement/spine/agent_discovery.py and nothing else there; "/routes.py" is unchanged beside it.
At base all this code lived in apps/routes.py, which "/routes.py" already ranks low. After the split it sits in apps/routes_<role>.py, which "/routes.py" does not match, so the new marker restores the same rank. The /apps/ prefix keeps it from matching other modules such as aws_control/backend/routes_parts/.

@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 21, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s51-routes branch from 96679be to 1c17ada Compare October 21, 2026 05:36
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 1c17ada
  • What rule changed: No redaction or gate rule changes. security_posture.NON_EGRESS_REDACTION_MODULES gains apps/routes_enable.py, routes_lifecycle.py, routes_listing.py and routes_registry.py as partitions of the "App lifecycle output" sink, whose _REDACTION_SINKS row keeps naming apps/routes.py (which keeps _run_uninstall and its dual-pass redactor calls).
  • Before -> after (what was allowed/blocked, now): Before, every redactor call of the app routes sat in apps/routes.py; after, the moved calls sit unchanged in the four owners (move audit: AST-identical units) and the kept ones stay in routes.py, so every warning, script output, install log and notice is redacted exactly as before and the posture panel is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A redactor call dropped in the move would leak a credential or exfiltration URL into an install, enable or uninstall response; the move audit, the sink tests and the census guard rule that out.
  • Evidence checked (which sandbox result proves it): No sandbox or command-floor path changes; test_security_posture.py (every named sink module exists and calls a redactor, every redactor call site is classified, no stale allowlist entry, no module in both buckets, partial-cover disclosure) passes on this change.
  • No regression:
    • Tools still work (which tools/commands were run, result): The 480-file local floor (every test that imports or patches kiro_crew.apps.routes plus the facade, mirror, posture, error-code and sync-io guards) passed (one environment-only failure, a dependency the local venv lacked, passes once it is installed); the installed wheel imports the facade and all nine owners.
    • Backward compatible (old config / old data / old callers still work, how checked): Every name the module bound is still served at kiro_crew.apps.routes, as the owner's own object or the facade's own code (test_routes_facade.py, test_campaign_facades_base_public_names.py, test_facade_mirror_guards.py); no config, data or route changes.
    • Existing tests (which suites passed on this head): The CI matrix on this head; locally, on the recipe re-cut this head rebases unchanged (-U0 identical), the 480-file floor (every test that imports or patches kiro_crew.apps.routes, plus the facade, mirror, posture, error-code, inventory, line-cap and sync-io guards) with 28,288 passed and one environment-only failure that passes once its new dependency is installed, and test_security_posture.py, test_routes_facade.py, test_facade_mirror_guards.py, test_app_update_status.py and test_app_update_notify.py among them.
  • How to undo: Revert this one commit; the four allowlist entries go back with the code.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Refreshed onto main 41987ae89b. This head, 1c17adaa3d, supersedes the earlier rebase at 96679be216.

It is the split recipe re-run on fresh main, not a hand rebase:

CI is re-running.

@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 21, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the same facade-mirror split as bridges.py and manager.py, with the import path and patch surface intact

agreed, and verified at this head. Every name the pre-split module bound resolves through kiro_crew.apps.routes, including #22457's _installed_app_detail and _announce_app_updates and its update_status / update_notify imports. The inventory covers 124 names and 93 rebound homes, and check_inventory reports 124/124.
A facade patch still reaches every owner that reads the name: test_facade_mirror_guards.py and test_routes_facade.py cover it.
The handlers routes.py keeps, because the sync-io fs baseline pins them, move to their family owners under #22459.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: a verbatim split required by the line cap, with no change to defaults or behaviour

verified at this head. Main 41987ae89b's routes.py has 87 top-level units, and a byte comparison against their homes finds 78 byte-identical. That includes every unit #22457 and #16517 added or changed, which the split recipe re-ran on fresh main to place.
The other 9 have no code change: 7 differ only in a comment (two nosemgrep markers, cite wording, one brand-ok, one # noqa: F811) and 2 only by a docstring brand respelling.
The move audit reads 5236 -> 1855 lines; moved 98.27%.

@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 21, 2026
apps/routes.py was 5,188 lines, over the 2,000-line cap. Every
definition moves verbatim into the owner of its endpoint family
(lifecycle, proxy, static, art, listing, install, uninstall, enable,
registry), and routes.py becomes a kiro_crew._facade_mirror facade,
so every import path and patch target of kiro_crew.apps.routes keeps
working. The facade keeps the handlers whose blocking file-system
calls the sync-io fs baseline counts against it, the units that call
them, the art route and the route table, verbatim and in place, so it
ends at 1,848 lines. Owners log as kiro_crew.apps.routes. Path-keyed
pins, the error-code and line-cap baselines, the owning spec and the
citations follow the move.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-s51-routes branch from 1c17ada to 40f7228 Compare October 21, 2026 07:53
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 40f7228
  • What rule changed: No redaction or gate rule changes. security_posture.NON_EGRESS_REDACTION_MODULES gains apps/routes_enable.py, routes_lifecycle.py, routes_listing.py and routes_registry.py as partitions of the "App lifecycle output" sink, whose _REDACTION_SINKS row keeps naming apps/routes.py (which keeps _run_uninstall and its dual-pass redactor calls).
  • Before -> after (what was allowed/blocked, now): Before, every redactor call of the app routes sat in apps/routes.py; after, the moved calls sit unchanged in the four owners (move audit: AST-identical units) and the kept ones stay in routes.py, so every warning, script output, install log and notice is redacted exactly as before and the posture panel is unchanged.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A redactor call dropped in the move would leak a credential or exfiltration URL into an install, enable or uninstall response; the move audit, the sink tests and the census guard rule that out.
  • Evidence checked (which sandbox result proves it): No sandbox or command-floor path changes; test_security_posture.py (every named sink module exists and calls a redactor, every redactor call site is classified, no stale allowlist entry, no module in both buckets, partial-cover disclosure) passes on this change.
  • No regression:
    • Tools still work (which tools/commands were run, result): The related set at this head (every test that imports or patches kiro_crew.apps.routes, the posture and redaction call-site guards, the facade, mirror, error-code and sync-io guards) passed with 0 failures; mypy and semgrep are clean; the installed wheel imports the facade and all nine owners.
    • Backward compatible (old config / old data / old callers still work, how checked): Every name the module bound is still served at kiro_crew.apps.routes, as the owner's own object or the facade's own code (test_routes_facade.py, test_campaign_facades_base_public_names.py, test_facade_mirror_guards.py); no config, data or route changes.
    • Existing tests (which suites passed on this head): The CI matrix on this head; locally, on the recipe re-cut this head rebases unchanged (-U0 identical), 80 related test files with 4,816 passed and 0 failed, among them test_security_posture.py, test_redaction_call_sites.py, test_redaction_composed_pass.py, test_redaction_tiers.py, test_routes_facade.py, test_facade_mirror_guards.py and test_error_code_contract.py; the 480-file floor passed on the previous re-cut.
  • How to undo: Revert this one commit; the four allowlist entries go back with the code.

@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 merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 21, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: a behaviour-neutral split on the _facade_mirror precedent, with the path-reading tests now scanning the whole family

agreed, and verified at this head.
The universal scans join the facade with every owner listed in routes._OWNERS: test_builtin_app_lifecycle.py (two scans), test_apps_instances_loop_offload.py, test_conditional_get.py, and the duplicate-set half of test_app_art_route.py. Each join was mutation-proven by planting a violation in an owner.
The single-construct pins re-point to the one file that holds the construct (routes_listing.py, routes_enable.py). Their assertions are unchanged.
The posture guards follow #22592's single redact( pass. A planted redact( in routes_proxy.py and a removed one in routes_registry.py both fail test_security_posture.py.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: a pure verbatim split required by the 2,000-line cap, with the outside edits only re-pointing paths and baselines

verified at this head. Main has 87 top-level units in routes.py; 78 land byte-identical in the family, including every unit #22457, #16517 and #22592 changed.
The other 9 differ only in a comment or a docstring brand spelling. The move audit reads 5227 -> 1852 lines; moved 98.27%.
The edits outside the family are path re-points and cite fixes, the own rows of the baselines and registries, and the facade inventory.
error-code-baseline.json redistributes its counts with totals unchanged, and the posture rows still match the modules that call a redactor.

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

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

APPROVE at 40f7228.

The r114 ask is done: #22459 tracks moving the handlers routes.py keeps. It carries deferred-finding and an owner, it is linked from the description, and the Design suggestion has a disposition pointing at it.

The re-cut split is still faithful. An AST comparison against merge base 098bc0a finds every definition of base routes.py identical in the facade or an owner, apart from two docstring brand respellings. The route table stays in routes.py unchanged. The 21 redactor-call lines of base routes.py now sit in the facade and exactly the four owners added to NON_EGRESS_REDACTION_MODULES. The auth and proxy files outside the family change only comments. Every AI lane passes on this head and its punchlines are answered, the moved CodeQL alerts are dismissed as before, and checks are green.

— crew-pr-reviewer (r117)

@bolichen97
bolichen97 merged commit d290fab into main Oct 21, 2026
111 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-s51-routes branch October 21, 2026 16:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 21, 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