Repository navigation
refactor(apps): split routes.py into a facade and nine owners - #22131
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Sensitive Change ReviewSensitive files changed:
|
Sensitive change review
|
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this is a behaviour-neutral split that follows the existing Notes
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This is a pure verbatim split that the 2,000-line cap in AGENTS.md requires. The edits outside Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: keep the app-management REST routes under the file-line cap without changing behaviour. This is a refactor (neither a FIX nor an ADDITION).
[FIRST-PRINCIPLES-REVIEWED] 40f7228 Description read[DESCRIPTION-READ] ede1a4b22d54ec5ce41e85ba71993e43e857d31baeb18f50e89f64bf1c4ff3cf That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
|
HOLD (merge conflict) at 17c0b5a. GitHub now reports this branch as CONFLICTING with At this head the split is faithful. All 62 functions of — crew-pr-reviewer (r112) |
17c0b5a to
b4a8157
Compare
Sensitive change review
|
|
|
b4a8157 to
4cfbb28
Compare
|
96679be to
1c17ada
Compare
Sensitive change review
|
|
Refreshed onto main It is the split recipe re-run on fresh main, not a hand rebase:
CI is re-running. |
|
|
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
1c17ada to
40f7228
Compare
Sensitive change review
|
|
|
iamwhatever
left a comment
There was a problem hiding this comment.
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)
Problem / Motivation
Goal: Bring
src/kiro_crew/apps/routes.pyunder the 2,000-line cap by moving its code into ten sibling modules, one endpoint family each, with no change in behaviour.apps/routes.pywas 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
kiro_crew.apps.routes.What changed (motivation → approach → change)
Every top-level definition moves verbatim into the owner of its endpoint family, and
apps/routes.pybecomes akiro_crew._facade_mirrorfacade (the shape of the mergedapps/bridges.pyandapps/manager.pysplits). Amonkeypatch.setattrormock.patchofkiro_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.txtcounts against this path (13 sites, row unchanged), the units that call them (handle_uninstall_appandhandle_migrate_cleanupcall_run_uninstall), the art route (it keeps the_ART_IMAGE_EXTENSIONSimport and both art-extension screening sites in one file, astest_app_art_route.pypins) 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 reasonroutes.pyends at 1,852 lines instead of the 1,600 the campaign aims for; it is under the 2,000-line cap.src/kiro_crew/apps/routes.pyhandle_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_routesroutes_lifecycle.pyroutes_proxy.pyroutes_static.py,routes_art.pyroutes_listing.pyroutes_install.py,routes_uninstall.pyroutes_enable.pyroutes_registry.pyOwners 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.pystays its own small module (137 lines): it holds the uninstall preview and the cron-cleanup retry the kept_run_uninstallcalls, which belong to no other owner. Every owner logs askiro_crew.apps.routes(L25). The facade keeps its import header byte-identical for importers (asetup.cfgF401 row, accounted for bytest_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).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 theroutes_*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 aTYPE_CHECKINGgroup (with a self-test); nothing outside the family imports an owner (relative imports resolved, with a self-test).test_file_menu_items.py,test_app_denial_code.py,test_mcp_stub_freeze_ratchet.py.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 intest_dashboard_agents_composition_contract.py), and the duplicate-set half oftest_app_art_route.py::test_both_art_paths_screen_on_the_SAME_extension_set(a duplicate set planted inroutes_static.py); itscount == 3half readsroutes.pyunchanged, which keeps the import and both screening sites._run_uninstall, the route table or the git-tree removal site by path keep readingapps/routes.py, unchanged.-n0and one at-n 3;test_flake_pattern_ratchet.pypasses.7d6bfb49ca, which carries fix(security): tier redaction rules and redact through one composed pass #22592's singleredact(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 oversrc/kiro_crew: no issues in 3,450 files; semgrep 1.78 with the CI configs and--baseline-commit: 0 findings.bcd95337f5, before fix(security): tier redaction rules and redact through one composed pass #22592):scripts/run_scoped_tests.py's ownrelated_targetsover the diff with the bare stem dropped for generic-stem files (the facade's stemroutesalone matches about 960 test files), plus every test file that imports or patcheskiro_crew.apps.routesand 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 therjiebadependency 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 oversrc/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 agit archiveexport, imports the facade and all nine owners.scripts/local-gate.py --base <main> --dry-runselects 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
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
loggerbinding in each owner islogging.getLogger("kiro_crew.apps.routes")instead ofgetLogger(__name__);_blocked_repos = {"KiroCrew"}inhandle_registriescarries 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_scriptalias comment travels with that import intoroutes_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 kepthandle_app_config'sconfig_path = data_dir / "config.json"carries a trailing# noqa: F811(the header'sconfig.loader.config_pathimport 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, exceptsrc/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 baseroutes.py; one is blank), re-shown because the kepthandle_uninstall_appshares its request-handling boilerplate with the deletedhandle_update_appjust 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) andhandle_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.txtin the campaign control root).Citations and references
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 citesrfc-everything-is-an-app.md(apps/routes.py:2336,apps/routes.py:503) andrfc-s3-backup.md(apps/routes.py:310) become symbol cites, and their three docs-lintline-refrows are deleted; comments and docstrings inapps/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), andtest_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.routes.pykeeps (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 athandle_uninstall_previewinroutes_uninstall.py; it stays verbatim so the kept code is byte-identical to the base.apps/builtins/auto_improvement/spine/agent_discovery.py_LOW_VALUE_MARKERSgains"/apps/routes_", so the auto-improvement agent keeps ranking the route code last, as it rankedroutes.py..github/file-line-cap-baseline.txtrow forapps/routes.pydeleted (1,852 lines);.github/sync-io-in-async-fs-baseline.txtunchanged (13 src/kiro_crew/apps/routes.py);error-code-baseline.jsonredistributes theapps/routes.pyrow (60 / 8 / 2) overroutes.py(22 / 2 / 1) and seven owner rows, totals unchanged,_compliantuntouched;security_posture.py:routes_enable.py,routes_lifecycle.py,routes_listing.pyandroutes_registry.pyjoinNON_EGRESS_REDACTION_MODULESas partitions of the "App lifecycle output" sink, whose row keeps namingapps/routes.py;setup.cfggains thesrc/kiro_crew/apps/routes.py: F401row (Master ruling, S32 precedent);test/campaign_facade_inventories/kiro_crew.apps.routes.jsonfreezes the facade's 124 BASE public names and 93 rebound homes.__module__: moved handlers report their owner module; no test or production code reads a routes function's__module__(route-order tests compare__qualname__, unchanged).handle_install_appand_fetch_git_blobstay onroutes.py; the one onhandle_registry_install_streammoves with it toroutes_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).security_posture.pyis 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: fourNON_EGRESS_REDACTION_MODULESrows 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.pykeeps to owners once the sync-io fs gate reads a move as a move (or their blocking calls leave the loop).Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)