Repository navigation
refactor: split transcribe.py, mcp_core.py and hooks.py into owners - #20555
Conversation
Sensitive Change ReviewSensitive files changed:
|
Sensitive change review
|
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check one thing before merge: Suggestions
[DESIGN-REVIEWED] e56a355 Description read[DESCRIPTION-READ] 132ddf5ad995f1132068e5fd7e25d11844955ff6ecdcd043f69f13e0ab94b504 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 Check that the hand-written What this change shipsInventory (8 items) — 8 justifiedIntent: bring three modules over the 2,000-line cap under it, as AGENTS.md requires, with no behaviour change. This is a FIX: a mandated refactor.
[FIRST-PRINCIPLES-REVIEWED] e56a355 Description read[DESCRIPTION-READ] ba7fa3443f509279baebb857f69c99f831e2ac9b1afc04ee0291b791f627f9f4 That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
|
|
Security Scope Review -- 🟡 CONCERNSWhich legitimate operations does Verdict basis: the reviewer's own judgement; no confirmed regression. Security scope review -- adjudicated candidates
No candidate flipped from allowed to refused. Scope-Verdict: CONCERNS TIGHTENING: No new rule. This is a module split that moves code without changing it. The shell deny composite's value types ( ADJUDICATED: 17 candidates, 0 confirmed newly-refused PLATFORM COVERAGE: The diff adds no new path, separator or interpreter assumption to the gate. It does move code that runs on each platform: the hook subprocess environment, the script-hook shell per platform, and the ffmpeg executable resolution.
UNADJUDICATED:
[SCOPE-REVIEWED] e56a355 |
|
Security Scope Review (CONCERNS) on 2b0c2f7: answered, no change needed. The adjudication found 0 newly refused on macOS, Ubuntu and Windows. Each open point:
The only token edit in moved hook code is |
2b0c2f7 to
99f521e
Compare
|
Rebased: base refresh (4-hour rule). 10e53cc -> 3d09514; |
99f521e to
1270d58
Compare
|
Rebased: the branch went DIRTY after main's 04:55Z merges. 3d09514 -> 83e97cd. The one conflict was the shared row table in One prose citation is folded in now that the sandbox split has landed: the Re-gated on the new base under an isolated HOME:
The git-diff / |
987dfd6 to
f5ebbf9
Compare
|
Rebased: base refresh (4-hour rule), b413800 -> 8d33a33. Main changed no split target or owner module in that range, so nothing needed porting. The one conflict was the shared row table in git range-diff against 987dfd6 |
|
|
|
Security Scope Review (CONCERNS) on f5ebbf9: answered, no change needed. The adjudication found 0 newly refused on macOS, Ubuntu and Windows. For the relocated guards the classifier could not judge, I compared each owner's definitions with the base by AST at this head:
|
Each of the three files was over the 2,000-line cap. Whole top-level definitions move, verbatim, into owner modules with one responsibility each; the original path stays the import path and the patch surface. transcribe.py and mcp_core.py become mirror facades (_facade_mirror): the owners read their names as plain globals, and a patch through the facade reaches every module that binds the name. transcribe.py keeps availability, config, the guards, dispatch and segmentation over transcribe_ffmpeg, transcribe_aws and transcribe_local. mcp_core.py keeps the server, its call path, _send and the verbs over the mcp_core_parts package (identity, gateway, governance, crew, history, radar_crew). hooks.py stays a compose facade and gains two hook_runtime owners: hook_types (result and config types) and script_hooks (run_script_hook and ScriptHookStore). HookManager, ScriptHook and uncounted_gate stay: compose does not rebind closure-held or contextmanager functions, and ScriptHook's class body reads a facade constant. The store's one contextmanager is rebound onto the facade's globals after compose. Path-keyed guards that read these files are re-pointed to the owners, the owning specs gain owner maps, and the three line-cap baseline rows are deleted. Part of #20192
f5ebbf9 to
e56a355
Compare
|
Rebased onto c6d6106. This head supersedes f5ebbf9, which went DIRTY when main changed moved code. Three changes against the last reviewed head:
Re-gated on this base under an isolated HOME: 36 files, 2,946 passed, 3 skipped, 5 xfailed. The flake ratchet, docs lint and line-cap check are clean, and mypy found no issues in 2,465 files. The range-diff below is against 987dfd6, the head whose CI and reviews last completed. CI is re-running on e56a355. git range-diff against 987dfd6 |
|
HOLD at
I found no defect. The moved gateway owner holds no transport call sites or header literals, so today's auth-coverage scan still sees every site. I did not re-check AST identity myself; that rests on your move audit and the green guards. Open on this head, before a human approval:
CI is green on this head. — crew-pr-reviewer (r105) |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved by a maintainer who read the review lane findings on this head and accepted them as follow-up work; the findings stay on the record for whoever picks them up.
…1168) mcp_core.py became a mirror facade over mcp_core_parts/ (#20555), but two universal source scans still read only mcp_core.py: the call-site auth-coverage walk (_SOURCES) and the synchronous tool-bound sweep in the inflight-report test. Code added later to an owner module would escape both. Join mcp_core_parts/*.py into each scan's file list; the assertions are unchanged.
Problem / Motivation
Goal: Bring
transcribe.py,mcp_core.pyandhooks.pyunder the 2,000-line cap with no behaviour change, by moving whole definitions into owner modules behind the import paths callers already use.The three files were 2,933, 2,866 and 2,866 lines at the base, over the repository's 2,000-line cap. Part of the line-cap campaign.
Why it matters
A file over the cap is one every feature PR keeps growing: a reviewer cannot hold it, and every edit re-reads thousands of unrelated lines.
mcp_core.pychanges several times a week. The split gives each responsibility a home a contributor can find and a spec says where new work goes, while every caller, patch target and test keeps working through the original module path.Not a goal
HookManagerorScriptHook(a later decomposition scope can moveHookManagerbehind collaborators).What changed (motivation → approach → change)
Each file kept a facade at its original path and moved whole top-level definitions, verbatim, into owners named for one responsibility each. The specs now map each owner and say where new work goes.
transcribe.py_facade_mirror)transcribe_ffmpeg.py1,161 (decoder resolution, authenticated snapshot, spawn, reap),transcribe_aws.py530 (AWS provider, vocabularies),transcribe_local.py331 (whisper.cpp and Apple lanes)mcp_core.py_facade_mirror)mcp_core_parts/identity.py412,mcp_core_parts/gateway.py599,mcp_core_parts/governance.py411,mcp_core_parts/crew.py214,mcp_core_parts/history.py187,mcp_core_parts/radar_crew.py169hooks.pyhook_runtime/hook_types.py413 (result and config types),hook_runtime/script_hooks.py882 (run_script_hook,ScriptHookStore)A mirror facade serves every owner-defined name as
module.<name>, and a patch through it reaches every module that binds the name, so the moved code reads its own globals unchanged.hooks.pykeepsHookManager,ScriptHook,uncounted_gate, the UNC memos and every module-level value:composecannot rebind the closure-heldjudge/on_tool_callor acontextmanagergenerator, andScriptHook's field default reads a facade constant when its class body runs. The store's onecontextmanager(_atomic_mutation) is rebound onto the facade's globals right aftercompose, so a patch throughkiro_crew.hooksstill reaches it. The campaign set the hooks target at 1,700.Guards that read these files by path now read the owner that holds the construct (each with a mutation proof).
security_posture.py's redaction registry lists the new owners, the three rows leave.github/file-line-cap-baseline.txt, and theAGENTS.mdrouter row names thetranscribe_*.pyowners.A few moved lines changed. Added-line gates re-judge moved code: two
no longerdocstring phrases and one comment are reworded in present tense (comment history),KiroCrew→Kiro Crewin one docstring (brand), ands.split('/')[-1]→s.rpartition('/')[2]inScriptHookStore.fire(cross-platform rule 4 scanshook_runtime/; identical for every string, pinned bytest/test_hooks_script_hooks.py). Prose that names where moved code lives now names its new home (listed under Prose citations).Move audit
Upstream changes to moved code are ported byte for byte through the split recipe: #19939's edit to
_resolve_session_key_strictand its removal of_host_pid_hosts_several_sessionsnow live inmcp_core_parts/identity.py. Every other moved unit is AST-identical to the base; the "changed" units differ by the lines named. Git's default diff and--minimaladd the same lines for every changed file excepttranscribe.py(111 added lines vs 110): the default diff re-shows one unchanged blank kept line beside the facade glue, which carries no gate token (L41 exception, ruled by the campaign). Diff size 607,260 bytes.Backwards compatibility
Compatible: every name the three modules bound at the base still resolves on them, to the same object; patches through
kiro_crew.transcribe,kiro_crew.mcp_coreandkiro_crew.hooksreach the moved code.Reader: src/kiro_crew/dashboard/handlers/core.py:list_custom_vocabularies -- crew page -- imported from kiro_crew.transcribe, which serves transcribe_aws's object (test_campaign_facades_base_public_names, test_stt_transcribe_vocabulary)
Reader: src/kiro_crew/mcp_cron.py:strict_identity_diagnosis -- cron --
from kiro_crew.mcp_core importresolves through the mirror to mcp_core_parts.identity (test_strict_identity_diagnostics, test_mcp_core_facade)Reader: src/kiro_crew/mcp_tools/table.py:mcp_core.require_strict_session_key -- chat -- every handler reads it as an attribute of kiro_crew.mcp_core at call time, which the mirror serves and patches (test_mcp_core_facade)
Reader: src/kiro_crew/mcp_work.py:require_strict_session_key -- subagent -- imported from kiro_crew.mcp_core, served by the mirror (test_mcp_work, test_identity_topology)
Reader: src/kiro_crew/acp/kas_wire.py:hooks_mod.run_script_hook -- chat -- hooks re-exports hook_runtime.script_hooks.run_script_hook and compose runs it on hooks' globals (test_hooks_composition_contract, test_kas_hooks_acp)
Logger names: the transcribe owners log through
logging.getLogger("kiro_crew.transcribe"), the facade's own logger object; compose owners log askiro_crew.hooks; mcp_core has no logger. Class__module__: the one moved exception,VocabularyListError, reportskiro_crew.transcribeas at the base, so a traceback or log line names the import path (pinned bytest_transcribe_facade). The other moved classes report their owner, and nothing outside the split reads it: the nine hook classes need it, becausecomposerebinds the methods of exactly the classes whose__module__is the owner's (pinned bytest_hooks_script_hooks), and a sweep of src, tests, scripts and docs found no reader of the module path of_AuthenticatedFfmpeg,PackagedDecoderProbe,_ProfileCredentialResolver,CustomVocabularyorCustomVocabularyListing(no pickling, class formatting, qualified-name key or log of a class object; dataclass reprs carry no module). Static visibility: every project name the mirror facades imported at the base stays bound on them, so no served name needs aTYPE_CHECKINGimport from outside the family (pinned by the two facade tests).Prose citations
Citations that name where a moved construct lives, corrected to its new home (no assertion or code changed):
_session_token_headerdocstring ("every verb below" namesmcp_core), an identity comment (namesmcp_core_parts/governance.py), the_create_ffmpeg_subprocessdocstring (namestranscribeand its owners), the comment above_HOOK_BASE_ENV_KEYS(nameshook_runtime/script_hooks.py).src/kiro_crew/transcribe.py(provider_splits_oversizeddocstring): the strict sandbox'srun/voice-runtimemask is cited atsandbox_tiers.py, where the sandbox split put the strict list.test/test_restart_pruned_interpreter_guard.py: two skip reasons citetranscribe_ffmpeg.py's_open_authenticated_ininstead oftranscribe.py:688.src/kiro_crew/hook_runtime/__init__.pydocstring (a doc-accuracy edit): owners now hold moved classes, a moved class keeps its owner's__module__, andhooks.pyrebinds the onecontextmanager.memory-skills-hooks.md,mcp.md,stt-streaming.md,history.md,context-management.md,crew-mode.md,security.md,metrics.md,remote-and-mobile.md,platform-context.md,rfc-session-tag-change-event.md,rfc-conductor-work-ledger.md,rfc-perpetual-agent.md, and theAGENTS.mdrouter row.security_posture.pygrows by 11 lines (fourmcp_core_partsrows and onescript_hooksrow in its redaction registry); its line-cap row belongs to another campaign scope and is left unchanged, since growth past a row is report-only.References not edited (cost)
website/src/pages/settings/SttSettings.tsx(the comment aboveVOCABULARIES_ACCESS_DENIED) says the code comes "fromtranscribe.py"; the constant is now defined intranscribe_aws.pyand still served askiro_crew.transcribe.VOCABULARIES_ACCESS_DENIED. Left unedited so this backend split does not pull the frontend lanes; queued for the batched docs follow-up.CI path references
N/A: no workflow, AUTOSDE rule or sensitive-change glob names
transcribe.pyormcp_core.py, and every lane that nameshooks.pyalready nameshook_runtime/.Tests
test/test_transcribe_facade.py,test/test_mcp_core_facade.py: every name the test trees patch through the facade (found by the corpus scan, non-vacuity set pinned) reaches every module holding it and the undo leaves one object per name; the owners are exactly the owner modules, layered; the facade forwards no legacy table; the family logs through one logger; a facade write of_API_PORTmoves the gateway owner's cache; an exception or enum class an owner defines reports the facade's module; every base project import stays bound on the facade (one exception,session_pid_mapping_path, is served from the identity owner:test_pid_reader_ratchetcounts each import of the session-pid sidecar path as a reader site). The new tests passed 5 runs at-n0in shuffled order and one at-n 3.test/test_hooks_script_hooks.py: therpartitionspelling equals thesplitit replaced over'','a','a/b','/a/','a//b'; a skills-only hook's directive names each skill by its last segment; a patch ofhooks.copyreaches the store's mutation guard; the classes both owners define keep the owner__module__thatcomposeselects them by, and their methods run on the facade's globals.test_business_counters(2 rows), the hooks contract (owner rows, counts, shape digest over the base shapes, the APPROVAL_DECISIONS guard),test_identity_topology(registry key and both exemptions),test_strict_identity_diagnostics,test_crew_members_doc,test_spawn_audit(5 keys),test_deploy_round15_fixes(negative check now reads the owners too), and the frozen base-name inventories for both mirror facades (test/campaign_facade_inventories/kiro_crew.mcp_core.jsonandkiro_crew.transcribe.json, read bytest_campaign_facades_base_public_names).scripts/local-gate.py --base fbca1a17ef --dry-runselects 3,355 backend and 1,806 frontend files, so the floor ran instead (-n 3). On base 4d37295: the 361 test files that import, patch or read the three modules or their owners (31,136 passed, 46 skipped, 5 xfailed), the 170 tree-scan guards and ratchets (10,962 passed, 76 skipped), and the 61 hook-store files again after the last fix (5,512 passed); mypy oversrc/kiro_crew(no issues in 2,353 files); semgrep with the CI configs and--baseline-commit(0 findings); the comment-history, brand, harness-parity, memory-store, black, subprocess-encoding, agent-sdk and sync-io gates;docs_lint.py;check_file_line_cap.py(0 failures); and every new module imported from a built wheel. After rebasing onto fbca1a1: the three facade tests, the hooks contract,test_campaign_facades_base_public_names,test_restart_pruned_interpreter_guard, the spawn, identity, pid-reader, auth-coverage and mirror guards, and the 10 test files main changed that import these modules (2,194 passed, 5 skipped, 5 xfailed);docs_lint.py,check_file_line_cap.py, the comment-history, brand, harness-parity and black gates, flake8, and semgrep on the files changed since the first run. This head sits on c6d6106 (main changed no split target or owner since fbca1a1; since then the head adds thesandbox_tiers.pycitation and theVocabularyListErrormodule name). There, underenv -iwith an isolated HOME: the facade, contract and posture tests, the re-pointed path guards, and the three test files main added that import these modules (31 files, 2,257 passed, 2 skipped, 5 xfailed; mypy--platform linuxno issues in 2,459 files);docs_lint.pyandcheck_file_line_cap.py.Manual verification
N/A — unit coverage sufficient: a pure move, proven by the move audit and the existing suites; the wheel-install import of every new module is the one manual step, and it passed.
Related Issues
Part of #20192
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)