Repository navigation
refactor(dashboard): split cron.py handlers into cron_* owner modules - #21672
Conversation
Sensitive change review
|
Sensitive Change ReviewSensitive files changed:
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 9aefb4f Description read[DESCRIPTION-READ] 2855316426d15f30dd4d332b99770a8bbdcb2a727e9bbabd590360265ebbfdf6 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 Before merge, check that per-owner What this change shipsInventory (6 items) — 6 justifiedIntent: a maintainer wants
[FIRST-PRINCIPLES-REVIEWED] 9aefb4f Description read[DESCRIPTION-READ] 5a9fb1a4f087b603e83ec0e9e172e445887a2318a0a44607fc4ae19ed0c0bda2 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: |
|
86857c4 to
b46d18c
Compare
|
|
b46d18c to
ab5aa7b
Compare
|
Rebased onto main 330812e for the refresh (L16 port of #21872: _surface_lesson_saved and its call move with the lesson routes into cron_lessons.py; cron.py now goes 4,131 -> 264 lines). The patch differs from b46d18c's; the READY range-diff lists the change. This head supersedes b46d18c. CI re-running. |
|
c28f344 to
72818cc
Compare
|
Rebased onto main 310ad48 for the refresh (L16 port across #21893, which split test_ephemeral_sessions.py: the two comment re-points move to test_ephemeral_sessions.py:473-474 and test_ephemeral_sessions_recognition.py:963, byte for byte). The patch differs from c28f344's; the READY range-diff lists the change. This head supersedes c28f344. CI re-running. |
|
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Every review lane on the head is clean (only runner notices and PR Scope / Opus size warnings); held by the triage cron on size or path rules alone. Approved on the watch holder's request.
dashboard/handlers/cron.py held every cron, cron-folder and lesson route in 4,101 lines, over the 2,000-line cap. Each top-level unit moves verbatim into one of nine sibling owners (cron_shared, cron_caller_session, cron_lesson_supersede, cron_lessons, cron_jobs, cron_script_source, cron_secret_grants, cron_runs, cron_board). cron.py stays the import and patch path as a kiro_crew._facade_mirror facade with no code of its own, so a patch of cron.<name> reaches every owner that binds the name. Each owner that defines routes runs guard_owner_surface_routes over its own routes, with its share of the four member-scoped routes, so the same 19 routes stay owner surfaces. Every owner logs under the facade's logger name, and _ChatFolderGone keeps the facade module. Path-keyed pins, rows, citations and the owning spec follow the moved code. The store-unreadable ratchet keeps excluding the grant handlers by file name, as BASE did. Part of #20192
72818cc to
9aefb4f
Compare
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Every review lane on the head is clean (only runner notices and PR Scope size warnings); held by the triage cron on size, path or checklist rules alone. Approved on the watch holder's request.
Problem / Motivation
Goal:
src/kiro_crew/dashboard/handlers/cron.pydrops from 4,101 lines to a 263-line facade, with every cron, cron-folder and lesson route behaving exactly as before.The cron, cron-folder and lesson routes all lived in one 4,101-line module. That is over the repository's 2,000-line cap, and with 13 commits in the last seven days it is one of the hottest files a feature PR lands in.
Why it matters
A file over the cap blocks the line-cap guard from going strict, and a 4,000-line handler module is where review and merge conflicts concentrate. Splitting it by responsibility gives each route family an owner that new work can go to.
Not a goal
prompts.py; that is its own PR, cut in parallel.What changed (motivation → approach → change)
The module is cut along its route families.
cron.pystays the import and patch path for callers, the handlers package and tests, but becomes akiro_crew._facade_mirrorfacade with no code of its own: a read ofcron.<name>is served by the owner that binds it, and a write (monkeypatch.setattr,mock.patch) reaches every owner holding the name, as it reached the one module before.dashboard/handlers/)cron_shared.py_selcron_caller_session.py_recognize_sessionand the headless-mode refusalcron_lesson_supersede.pycron_lessons.pyPOST/DELETE/GET /api/lessonsand the lesson-store selectioncron_jobs.pyat, the job tab's chat folder,POST /api/crons/toolscron_script_source.pyGET /api/crons/{id}/scriptcron_secret_grants.pyPUT /api/crons/{job_id}/secretsand its one promotion pathcron_runs.pycron_board.pyGET /api/cronsand the cron-folder routesEvery unit moves byte for byte. At BASE one
guard_owner_surface_routescall wrapped every route except the four member-scoped ones; now each owner makes that call over its own routes, so the same 19 routes stay owner surfaces. Path-keyed pins, baselines, citations and the owning spec follow the moved code.Backwards compatibility
Compatible: every name
cron.pybound at BASE still resolves on it to the same object (test/campaign_facade_inventories/kiro_crew.dashboard.handlers.cron.json), and every patch through it still reaches every reader (test/test_cron_handler_facade.py).Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_tools -- cron -- registered from the handlers package, which re-exports the facade's served route (test_cron_handler_facade.py::test_every_route_keeps_the_guard_it_had)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_crons_create -- cron -- same re-export, still wrapped as an owner surface (test_cron_handler_facade.py::test_every_route_keeps_the_guard_it_had)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_delete -- cron -- same re-export (test_dashboard_cron_delete_handler.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_batch_delete -- cron -- same re-export (test_dashboard_cron_batch_delete_handler.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_update -- cron -- same re-export (test_cron_update_member_recapture.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_secret_grant -- cron -- same re-export (test_cron_secret_env.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_run -- cron -- same re-export (test_dashboard_cron_run_guard.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_cancel -- cron -- same re-export (test_cron_cancel.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_to_chat -- cron -- same re-export (test_dashboard_cron_to_chat_handler.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_enable -- cron -- same re-export (test_cron_handler_json_contract.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_ack -- cron -- same re-export (test_cron_handler_json_contract.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_history -- cron -- same re-export (test_dashboard_cron_path_id.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_history_detail -- cron -- same re-export (test_dashboard_cron_path_id.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_script_source -- cron -- same re-export (test_dashboard_cron_script_source.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_history_all -- cron -- same re-export (test_r16_cron_app_read_ownership.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_lessons_create -- cron -- same re-export, still unwrapped as a member-scoped route (test_lesson_write_outcome.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_lessons_delete -- cron -- same re-export, member-scoped (test_lessons_list_repo_scope.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_lessons -- cron -- same re-export, member-scoped (test_lessons_list_window.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_crons -- cron -- same re-export (test_cron_timezone_display.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_folders -- cron -- same re-export (test_dashboard_cron_folders.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_folders_create -- cron -- same re-export (test_dashboard_cron_folders.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_folders_update -- cron -- same re-export (test_dashboard_cron_folders.py)
Reader: src/kiro_crew/dashboard/server_runtime/mcp_routes.py:api_cron_folders_delete -- cron -- same re-export (test_dashboard_cron_folders.py)
Reader: src/kiro_crew/dashboard/handlers/memory.py:_recognize_session -- crew page --
from .cron import _recognize_sessionresolves through the facade to the owner's object (test_headless_memory_recognition.py)Tests
test/test_cron_handler_facade.py(new). Every name the test trees patch through the facade reaches every module holding it, and the undo restores them. The owners are exactly thecron_*.pysiblings, in layer order. The facade forwards no legacy table and defines no code. Every route keeps the guard it had: 19 wrapped once, the four member-scoped routes unwrapped. Every name served from outside the family stays visible to type checkers. One logger, named for the facade._ChatFolderGonekeeps the facade module.python -m kiro_crew.dashboard.handlers.cronstill imports.test/campaign_facade_inventories/kiro_crew.dashboard.handlers.cron.json(new, L52): 93 BASE public names, 69 re-bound by import;check_inventory.pyreports no missing name.test_json_object_body_guard.py(10 rows),test_persistence_writer_inventory.py,test_sqlite_compat_resolver.py,test_transcript_derivation_seam.py,test_dashboard_source_link_unlink_hydration.py(the_KNOWN_HYDRATION_SITESrow, which test: split four 3,000-line test files by topic under the line cap #21245 moved there fromtest_dashboard_source_link_unlink.py).test_cron_create_config_off_loop.pynow scans the facade joined with every owner (its universal half).test_cron_store_unreadable_boundaries.pycarries its file-name exclusion tocron_secret_grants.py.-n 3, 14,854 passed, 19 skipped, 0 failed. Three files (test_dev_fleet_server_coverage.py, test_sensitive_change_review.py, test_file_line_cap.py) need a git checkout and were run in the worktree: 485 passed.mypy src/kiro_crew: no issues in 2,690 files. A wheel smoke imports every new module from an installed wheel. Per-file coverage of the new modules from that run: cron_shared 100%, cron_caller_session 100%, cron_lesson_supersede 100%, cron_script_source 100%, cron_lessons 97.1%, cron_board 95.0%, cron_runs 94.4%, cron_jobs 90.6%, cron_secret_grants 82.0%. After the rebase onto main2c9c873f2f: 214 files at-n 3, 13,976 passed, 19 skipped, 1 failed. The failure is a 120 s timeout intest_session_allocation_bindings.py's whole-tree corpus scan, the known environment flake test_session_allocation_bindings facade-patch tree scan takes ~60s and times out at 120s on CI #21441, which is load-sensitive on this host: it takes 128 s on unmodified main and 139 s here, and passes on both with the timeout raised. After the refresh, gated on main8335fa0164(which carries that test's fix, test: read only the facade's own files in the session allocation patch scan #21640) and pushed on462c24f32fwith an identical -U0 patch, the 19 cron and pin test files pass: 1,121 passed, 0 failed, the session-allocation scan included. Per-file coverage of the owners: cron_shared, cron_caller_session, cron_lesson_supersede, cron_script_source 100%, cron_lessons 97.1%, cron_board 95.0%, cron_runs 94.4%, cron_jobs 90.6%, cron_secret_grants 82.0%.Manual verification
N/A — a pure move. The route, patch-reach and guard behaviour is pinned by the unit tests above, and the related test files pass unchanged.
Related Issues
Part of #20192
Follow-up: #21358 (the two secret-grant handlers read, decide and write without the store probe; the file-name exclusion keeps BASE coverage until that lands)
Follow-up: #21320 (comment citations in files other scopes own, listed below)
Rows and baselines
.github/file-line-cap-baseline.txt: thedashboard/handlers/cron.pyrow is deleted, since the file ends under 2,000 lines (L45). No other row changes..github/docs-lint-baseline.txt: theline-reftriple forrfc-resumable-subagent-sessions.mddashboard/handlers/cron.py:141is deleted. That citation now names the symbol (cron_lesson_supersede.py,_classify_contradiction).error-code-baseline.json: thedashboard/handlers/cron.pybucket (missing_code 28, dynamic_status 5) is redistributed tocron_jobs.py17/4,cron_runs.py6/1 andcron_lessons.py5 (test/test_error_code_contract.py --update). Totals 1046/18/38 are unchanged, and_compliantkeeps main's value.Move audit
move_audit.py --origin src/kiro_crew/dashboard/handlers/cron.py: 4131 -> 264 lines; moved 99.84% (python-ast); 71 of 72 units moved unchanged._surface_lesson_savedand its call inapi_lessons_create(#21872, which landed after this split was cut) move with the lesson routes intocron_lessons.py, byte for byte.guard_owner_surface_routes(...)call (6 lines). It is glue: each owner makes the call over its own routes.logger = logging.getLogger(__name__)binding becomeslogging.getLogger("kiro_crew.dashboard.handlers.cron")in each owner (L25): one logger, the original name.cron_runs: the list GET,api_crons;cron_board: the helpers incron_shared), and the moved section header incron_jobs.pyreadsCron jobs._ChatFolderGone.__module__ = "kiro_crew.dashboard.handlers.cron"(class__module__rule).Diff layout (L36)
cron.pyis pure glue (no kept code). Default diff adds 237 lines,--minimal235. The two re-shown lines are the blank lines of the facade's import header. L41 exception accepted by the Master for pure-glue facades. A layout search over 10 variants found no equal layout.Baselined growth (L56 addendum 1b)
src/kiro_crew/security_posture.py: baseline row 3,181, main 3,409 lines, HEAD 3,415 (+6).NON_EGRESS_REDACTION_MODULESreplaces thedashboard/handlers/cron.pyrow with the seven owners whose text carries the redactor calls (cron_board,cron_jobs,cron_lessons,cron_runs,cron_script_source,cron_secret_grants,cron_shared): exact-path rows the drift guard requires, no comment. The row stays as main has it.Prose citations (L29)
Path-only corrections of comments, docstrings and docs that name where a moved definition lives:
src/kiro_crew/apps/routes.py:1547comment:dashboard/handlers/cron.py->cron_shared.py(the unreadable-store answer)src/kiro_crew/dashboard/handlers/autonudge.py:1296docstring:handlers/cron.py->handlers/cron_shared.py(the 503 it mirrors)src/kiro_crew/dashboard/handlers/core.py:4057docstring:cron.py->cron_shared.py(_invalid_path_id_response)src/kiro_crew/dashboard/handlers/computer_use.py:155docstring:cron.py->cron_shared.py(the late-bound_sel()sibling list; refactor(dashboard): split prompts.py handlers into prompts_* owners #21549 re-pointed theprompts.pyentry on the next line, refactor(dashboard): split handlers/sessions.py into sessions_parts #21532 thesessions.pyone)src/kiro_crew/dashboard/handlers/sessions_parts/history_reads.py:99-100comment:handlers/cron.py->handlers/cron_caller_session.py(the live-and-shared session prefixes; refactor(dashboard): split handlers/sessions.py into sessions_parts #21532 moved this comment out ofsessions.py, and the bullet is rewrapped within its three lines)src/kiro_crew/dashboard/handlers/_shared.py:3633docstring:handlers/cron.py->handlers/cron_lessons.py(api_lessons_create)src/kiro_crew/mcp_tools/learn.py:332andsrc/kiro_crew/taskrunner_parts/run_reporting.py:152comments:dashboard/handlers/cron.py->cron_lessons.py(api_lessons_create)test/test_app_routes.py:262,:291:handlers/cron.py->handlers/cron_shared.pytest/test_mcp_cron_thread_ts.py:287docstring:dashboard/handlers/cron.py->cron_jobs.pytest/test_ephemeral_sessions.py:473-474andtest/test_ephemeral_sessions_recognition.py:963comments (test: split four session, knowledge and monitor test files by topic #21893 split the file):handlers/cron.py/cron.py's->handlers/cron_lessons.py/cron_lessons.py's(the route readscron_lessons' own_get_memorybinding; the facade mirror carries the test'shandlers.cron._get_memorypatch to it)test/test_dashboard_cron_to_chat_handler.py:1docstring:(handlers/cron.py L169-L205)->(handlers/cron_runs.py, api_cron_to_chat)docs/request-for-change/rfc-resumable-subagent-sessions.md:146(dashboard/handlers/cron.py:141->cron_lesson_supersede.py(_classify_contradiction); itsline-refbaseline row is deleted) anddocs/system-specs/modules/session.md:723(->cron_lesson_supersede.py)References not edited (cost / owner)
src/kiro_crew/mcp_cron.py:2679,:3387(dashboard/handlers/cron.py→cron_jobs.py) and:3076(→cron_board.py): S19's split target (refactor: split llm_helpers.py and mcp_cron.py into owner modules #21598, not merged yet); S19 re-points them when it lands second.website/src/test/AutoNudgePopover.test.tsx:337(prosehandlers/cron.py): L50.handlers/cron._SCRIPT_SOURCE_MAX_BYTESin cron_script.py,dashboard.handlers.cron._lesson_jsonl_storein security/init.py).CI path references
None: no workflow names
dashboard/handlers/cron.py;AUTOSDE.yaml'sdashboard/handlers/**globs already cover the owners.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.