Skip to content

refactor: split transcribe.py, mcp_core.py and hooks.py into owners - #20555

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/linecap-s10-transcribe
Oct 15, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/linecap-s10-transcribe

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring transcribe.py, mcp_core.py and hooks.py under 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.py changes 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

  • No behaviour change: no fix, no new feature, no new guard.
  • Not decomposing HookManager or ScriptHook (a later decomposition scope can move HookManager behind collaborators).
  • Not splitting any test file, or any other oversized module.
  • Not changing CI logic or any workflow.

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.

File Lines Facade Owners
transcribe.py 2,933 → 1,160 mirror (_facade_mirror) transcribe_ffmpeg.py 1,161 (decoder resolution, authenticated snapshot, spawn, reap), transcribe_aws.py 530 (AWS provider, vocabularies), transcribe_local.py 331 (whisper.cpp and Apple lanes)
mcp_core.py 2,842 → 1,073 mirror (_facade_mirror) mcp_core_parts/identity.py 412, mcp_core_parts/gateway.py 599, mcp_core_parts/governance.py 411, mcp_core_parts/crew.py 214, mcp_core_parts/history.py 187, mcp_core_parts/radar_crew.py 169
hooks.py 2,869 → 1,682 compose (existing) hook_runtime/hook_types.py 413 (result and config types), hook_runtime/script_hooks.py 882 (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.py keeps HookManager, ScriptHook, uncounted_gate, the UNC memos and every module-level value: compose cannot rebind the closure-held judge/on_tool_call or a contextmanager generator, and ScriptHook's field default reads a facade constant when its class body runs. The store's one contextmanager (_atomic_mutation) is rebound onto the facade's globals right after compose, so a patch through kiro_crew.hooks still 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 the AGENTS.md router row names the transcribe_*.py owners.

A few moved lines changed. Added-line gates re-judge moved code: two no longer docstring phrases and one comment are reworded in present tense (comment history), KiroCrew → Kiro Crew in one docstring (brand), and s.split('/')[-1] → s.rpartition('/')[2] in ScriptHookStore.fire (cross-platform rule 4 scans hook_runtime/; identical for every string, pinned by test/test_hooks_script_hooks.py). Prose that names where moved code lives now names its new home (listed under Prose citations).

Move audit

src/kiro_crew/transcribe.py: 2933 -> 1160 lines; moved 97.21% (python-ast)
   changed: _create_ffmpeg_subprocess [AsyncFunctionDef] 47 lines (docstring: "every caller in this module" names the transcribe family)
   changed: provider_splits_oversized [FunctionDef] 22 lines   (kept; docstring cites ``sandbox_tiers.py`` for the strict mask)
src/kiro_crew/mcp_core.py: 2842 -> 1073 lines; moved 92.4% (python-ast)
   changed: _http_error_body [FunctionDef] 92 lines          (one docstring word: brand gate)
   changed: _reverify_refused_target [FunctionDef] 70 lines   (two docstring phrases: comment-history gate)
   changed: _session_token_header [FunctionDef] 25 lines      (docstring: "every verb below" names mcp_core)
src/kiro_crew/hooks.py: 2869 -> 1682 lines; moved 88.83% (python-ast)
   changed: ScriptHookStore.fire [AsyncFunctionDef] 218 lines (the rpartition token)
   changed: Expr [Expr] 18 lines                              (the compose(...) tuple: two owners appended)

Upstream changes to moved code are ported byte for byte through the split recipe: #19939's edit to _resolve_session_key_strict and its removal of _host_pid_hosts_several_sessions now live in mcp_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 --minimal add the same lines for every changed file except transcribe.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_core and kiro_crew.hooks reach 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 import resolves 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 as kiro_crew.hooks; mcp_core has no logger. Class __module__: the one moved exception, VocabularyListError, reports kiro_crew.transcribe as at the base, so a traceback or log line names the import path (pinned by test_transcribe_facade). The other moved classes report their owner, and nothing outside the split reads it: the nine hook classes need it, because compose rebinds the methods of exactly the classes whose __module__ is the owner's (pinned by test_hooks_script_hooks), and a sweep of src, tests, scripts and docs found no reader of the module path of _AuthenticatedFfmpeg, PackagedDecoderProbe, _ProfileCredentialResolver, CustomVocabulary or CustomVocabularyListing (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 a TYPE_CHECKING import 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):

  • Moved or kept text: _session_token_header docstring ("every verb below" names mcp_core), an identity comment (names mcp_core_parts/governance.py), the _create_ffmpeg_subprocess docstring (names transcribe and its owners), the comment above _HOOK_BASE_ENV_KEYS (names hook_runtime/script_hooks.py).
  • src/kiro_crew/transcribe.py (provider_splits_oversized docstring): the strict sandbox's run/voice-runtime mask is cited at sandbox_tiers.py, where the sandbox split put the strict list.
  • test/test_restart_pruned_interpreter_guard.py: two skip reasons cite transcribe_ffmpeg.py's _open_authenticated_in instead of transcribe.py:688.
  • src/kiro_crew/hook_runtime/__init__.py docstring (a doc-accuracy edit): owners now hold moved classes, a moved class keeps its owner's __module__, and hooks.py rebinds the one contextmanager.
  • Docs and specs: 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 the AGENTS.md router row.

security_posture.py grows by 11 lines (four mcp_core_parts rows and one script_hooks row 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 above VOCABULARIES_ACCESS_DENIED) says the code comes "from transcribe.py"; the constant is now defined in transcribe_aws.py and still served as kiro_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.py or mcp_core.py, and every lane that names hooks.py already names hook_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_PORT moves 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_ratchet counts each import of the session-pid sidecar path as a reader site). The new tests passed 5 runs at -n0 in shuffled order and one at -n 3.
  • test/test_hooks_script_hooks.py: the rpartition spelling equals the split it replaced over '', 'a', 'a/b', '/a/', 'a//b'; a skills-only hook's directive names each skill by its last segment; a patch of hooks.copy reaches the store's mutation guard; the classes both owners define keep the owner __module__ that compose selects them by, and their methods run on the facade's globals.
  • Re-pointed path guards (each proven by a mutation at the owner): 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.json and kiro_crew.transcribe.json, read by test_campaign_facades_base_public_names).
  • scripts/local-gate.py --base fbca1a17ef --dry-run selects 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 over src/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 the sandbox_tiers.py citation and the VocabularyListError module name). There, under env -i with 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 linux no issues in 2,459 files); docs_lint.py and check_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

  • 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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/hook_runtime/__init__.py

  • src/kiro_crew/hook_runtime/hook_types.py

  • src/kiro_crew/hook_runtime/script_hooks.py

  • src/kiro_crew/hooks.py

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for e56a355.

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

bolichen97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e56a355
  • What rule changed: None. This is a structural move. Seven result/config types (HookResult, ToolHookResult, ContextRule, AutoReplyHook, TransformHook, UserDeniedPattern, HooksConfig) move verbatim from hooks.py to hook_runtime/hook_types.py. _hook_subprocess_env, ScriptHookResult, run_script_hook and ScriptHookStore move to hook_runtime/script_hooks.py. hooks.py stays the only import path and patch surface, and compose runs the moved functions on its globals. security_posture.py gains registry rows for the five new owner files that hold moved redactor call sites. The hook_runtime/__init__.py edit is docstring only.
  • Before -> after (what was allowed/blocked, now): Unchanged. SHELL_DENY_TIERS, HookManager (the PreToolUse gate: judge/on_tool_call), ScriptHook, uncounted_gate, _screen_windows_links and every module-level value stay in hooks.py. No deny rule, sensitive path, tier or approval decision is added, removed or reworded. The one token edit in moved code is s.split('/')[-1] -> s.rpartition('/')[2] in ScriptHookStore.fire, which gives the same result for every string. test/test_hooks_script_hooks.py pins it over '', 'a', 'a/b', '/a/' and 'a//b'.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): A moved function reads a stale global, so a test patch or the hook-store mutation guard would miss it. That would break script-hook CRUD or firing. It would not widen any gate, because the gate itself does not move.
  • Evidence checked (which sandbox result proves it): No sandbox rule is touched. test_hooks_composition_contract sweeps every owner function's bytecode against the facade namespace, checks that each runs on the facade's globals, and checks that the 82 base shapes are unchanged by digest. The post-compose rebind of ScriptHookStore._atomic_mutation is pinned by test_hooks_script_hooks::test_the_store_mutation_guard_reads_the_facade_globals. scripts/deny_diff.py still reads SHELL_DENY_TIERS from hooks.py.
  • No regression:
    • Tools still work (which tools/commands were run, result): the hook-store and firing suites test_script_hooks, test_fire_tool_hooks, test_hook_events_kas_triggers, test_hooks_json_shared_file, test_hooks and test_gate_tiers pass. The full 61-file hook-store set gave 5,512 passed.
    • Backward compatible (old config / old data / old callers still work, how checked): every name kiro_crew.hooks bound at the base still resolves to the same object (test_hooks_composition_contract::test_every_name_the_facade_bound_at_the_base_still_resolves, plus a fresh-interpreter check). hooks.json and the store's on-disk format are untouched.
    • Existing tests (which suites passed on this head): test_hooks_composition_contract, test_hooks_script_hooks, test_security_posture, test_campaign_facades_base_public_names, docs_lint.py and check_file_line_cap.py re-ran on this head's base c6d6106 under env -i (36 files, 2,946 passed, 3 skipped, 5 xfailed; mypy clean). The 361-file related floor gave 31,136 passed and the 170 tree-scan guards gave 10,962 passed.
  • How to undo: revert the single commit.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision e56a355d9e4784ca51de4f3e5e02c341ae1a25a5 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Advisory — does not block merge.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check one thing before merge: test/test_mcp_call_site_auth_coverage.py _SOURCES still scans only mcp_core.py. Tool code added later to mcp_core_parts/*.py would escape the auth-coverage scan.

Suggestions

  • Glob mcp_core_parts/*.py into _SOURCES in test_mcp_call_site_auth_coverage.py and into files in test_mcp_gateway_inflight_report.py::_synchronous_tool_bounds, the same way test_deploy_round15_fixes.py already does. The PR's spec now tells contributors to put new work in the owners, and these scans would not see it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e56a355d9e4784ca51de4f3e5e02c341ae1a25a5 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check that the hand-written _atomic_mutation rebind after compose is the only contextmanager in either hook_runtime owner. A second one would skip facade patches without any error.

What this change ships

Inventory (8 items) — 8 justified

Intent: 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.

  1. transcribe.py split into transcribe_ffmpeg/_aws/_local behind the existing _facade_mirror — justified
  2. mcp_core.py split into the mcp_core_parts/ owners behind _facade_mirror — justified
  3. hooks.py result types and script hooks moved into hook_runtime/ through the existing compose — justified
  4. ScriptHookStore._atomic_mutation rebound onto the facade's globals, so patches through kiro_crew.hooks still reach it — justified
  5. Three rows dropped from the file-line-cap baseline — justified
  6. Path-reading guards and tests now point at the owner module that holds each construct — justified
  7. Specs, RFCs and the AGENTS.md router cite the new file locations; no RFC status changed — justified
  8. Moved lines reworded for the brand and comment-history gates, plus split('/')[-1] → rpartition('/')[2] — justified

[FIRST-PRINCIPLES-REVIEWED] e56a355

Description read

[DESCRIPTION-READ] ba7fa3443f509279baebb857f69c99f831e2ac9b1afc04ee0291b791f627f9f4

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.

@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 01:05
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e56a355

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

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e56a355

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

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Punchline: no other contextmanager in hook_runtime reads names patched through kiro_crew.hooks

rebutted (verified, no change needed): an AST scan of every hook_runtime/*.py finds one decorator besides @dataclass/staticmethod/classmethod/property, and that is @contextmanager on ScriptHookStore._atomic_mutation. There is no other contextmanager, lru_cache, partial or wraps wrapper.
_atomic_mutation is rebound onto the facade globals in hooks.py right after compose. test_hooks_script_hooks::test_the_store_mutation_guard_reads_the_facade_globals pins this: a patch of hooks.copy reaches the guard, and the test fails when the rebind is dropped.
Every other owner function, plain generators included, is rebound by compose and swept by test_hooks_composition_contract::test_every_owner_function_runs_on_the_facade_globals.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Punchline: the hand-wired _atomic_mutation rebind still picks up patches made through kiro_crew.hooks

rebutted (verified, no change needed): hooks.py re-wraps contextmanager(_rebind(__wrapped__, globals())) right after compose, so the generator's __globals__ is the facade dict and its __module__ and __qualname__ are kept.
test_hooks_script_hooks::test_the_store_mutation_guard_reads_the_facade_globals sets hooks.copy to a recording fake and asserts that ScriptHookStore.create calls it. The test was mutation-proven: dropping the rebind makes it fail.
An AST scan finds this to be the only @contextmanager in hook_runtime/, so it is the one seam compose cannot cover.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- 🟡 CONCERNS

Which legitimate operations does e56a355d9e4784ca51de4f3e5e02c341ae1a25a5 newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: the reviewer's own judgement; no confirmed regression.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 13 classified, 0 newly refused, 13 still allowed.
  • ubuntu-latest (platform posix): 13 classified, 0 newly refused, 13 still allowed.
  • windows-latest (platform windows): 7 classified, 0 newly refused, 7 still allowed.

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 (UserDeniedPattern, ToolHookResult, HooksConfig) and the script-hook runner move into hook_runtime/hook_types.py and hook_runtime/script_hooks.py, and compose then rebinds them onto hooks.py globals. The ScriptHookStore mutation guard is rebound separately: +setattr(ScriptHookStore, "_atomic_mutation", contextmanager(_hook_runtime._rebind(vars(ScriptHookStore)["_atomic_mutation"].__wrapped__, globals()). The diff refuses no new threat. The only way it could refuse more is a defect in the move or the rebind, where a moved deny body reads different globals than before. GATE_TIERS and SHELL_DENY_TIERS stay literal in hooks.py.

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.

  • posix: pytest runs over the moved owners, reads of ~/.kiro/crew/hooks.json and the hooks/ directory, ffmpeg/ffprobe probes, and scoped git diff/grep. These hit the deny-rules (UserDeniedPattern), sensitive-bash and exfil tiers through the rebound bodies.
  • windows: .venv\Scripts\python.exe pytest, type %USERPROFILE%\...\hooks.json, PowerShell Get-ChildItem $env:USERPROFILE\... and ffmpeg.exe. These cover %VAR%/$env: spelling, \ separators and .exe names going through the same rebound tiers.
  • any: scripts/deny_diff.py, aws transcribe list-vocabularies and kirocrew mcp-core.
  • Not probed: UNC paths. The diff makes no UNC assumption.

UNADJUDICATED:
These guards moved with the split, and the classifier cannot settle any of them. I could not compare each moved body against its BASE copy line by line in this run, so "moved without change" is the PR's own claim, not something I checked.

  • Strict session identity. _resolve_session_key_strict and require_strict_session_key move to mcp_core_parts/identity.py. Call path: an MCP tool call reaches gatewayd, which stamps kirocrew.caller; then mcp_core dispatches, a REFLEXIVE_TOOL_MODULES handler runs, and require_strict_session_key() decides. Inputs I would have submitted:
    • a warm-pool session with an empty KIROCREW_SESSION_KEY but a valid gateway caller block;
    • a cron:<id> session calling agent_sleep or monitor_start for its own job;
    • a host-pid caller with a valid HMAC sidecar;
    • each of these should still resolve.
  • Channel and messaging vets. Channel-agent containment and the messaging, browse, channel and memory-write vets move to mcp_core_parts/governance.py. Call path: mcp_core tool call, then the vet, then forward or refuse. Inputs: a Slack thread reply from a bound channel agent to its own thread, a browse to an allowlisted origin, and a memory write to the caller's own workspace.
  • Gateway target re-verification. The refused-target replay and re-verification move to mcp_core_parts/gateway.py. Call path: _send resolves the target, then the replay or re-verify check. Inputs: a call to the local dashboard on its configured port or unix socket after a gateway restart.
  • ffmpeg executable resolution. Resolving the bundled image, fixed system directories or store, plus the authenticated private snapshot, moves to transcribe_ffmpeg.py. Call path: transcribe_audio, ensure_ffmpeg_in_path/_find_ffmpeg, the snapshot, the spawn. Inputs:
    • Homebrew ffmpeg at /opt/homebrew/bin/ffmpeg;
    • a distro build at /usr/bin/ffmpeg;
    • on Windows, C:\Program Files\ffmpeg\bin\ffmpeg.exe;
    • each should still be found and run.
  • Script-hook env allowlist and sandboxed run. _hook_subprocess_env and run_script_hook move to hook_runtime/script_hooks.py. Call path: the Hooks page or api_hook_test, then run_script_hook, the capability gate, and the subprocess. Inputs: a UserPromptSubmit hook that reads an allowlisted _HOOK_BASE_ENV_KEYS variable, on posix and Windows.

[SCOPE-REVIEWED] e56a355

@bolichen97

Copy link
Copy Markdown
Contributor Author

Security Scope Review (CONCERNS) on 2b0c2f7: answered, no change needed.

The adjudication found 0 newly refused on macOS, Ubuntu and Windows. Each open point:

  • ToolHookResult._count reading _GATE_UNCOUNTED. ToolHookResult is defined in hook_runtime/hook_types.py, so compose rebinds its methods onto kiro_crew.hooks' globals. _count therefore reads the facade's one _GATE_UNCOUNTED ContextVar, the one uncounted_gate sets. Two tests in test_hooks_composition_contract pin this: test_every_owner_function_runs_on_the_facade_globals and test_every_global_an_owner_function_reads_is_bound_on_the_facade. The second sweeps every owner function's bytecode against the facade namespace. Both pass on this head.
  • (a) Strict session resolver. test_identity_topology::test_reflexive_tools_route_through_the_strict_gate keeps its direct and gated scans, re-pointed to mcp_core_parts/identity.py and governance.py and mutation-proven at the new home. test_strict_identity_diagnostics is also re-pointed, and test_mcp_core_facade shows a patch of kiro_crew.mcp_core.<name> reaches every holder.
  • (b) Containment and vets. test_mcp_core, test_mcp_core_coverage and test_mcp_core_more_coverage pass unmodified. The vets moved verbatim.
  • (c) Decoder resolution. test_transcribe and test_stt_decoder pass unmodified. test_spawn_audit's BENIGN_SPAWNS rows are re-pointed to transcribe_ffmpeg.py and mutation-proven: an unrouted spawn planted there fails the audit.
  • (d) Hook subprocess env. _HOOK_BASE_ENV_KEYS stays a kiro_crew.hooks global. _hook_subprocess_env is rebound by compose, so it reads that global. test_script_hooks and test_packaged_docs_runtime_facts_b80 pass unmodified.

The only token edit in moved hook code is split('/')[-1] to rpartition('/')[2]. It is identical for every string and pinned by test_hooks_script_hooks.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision labels Oct 15, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s10-transcribe branch from 2b0c2f7 to 99f521e Compare October 15, 2026 04:43
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: base refresh (4-hour rule). 10e53cc -> 3d09514; git range-diff is identical, and main changed no split target or owner module in between (merge-tree clean, no conflicts, nothing to port). Re-gated on the new base under an isolated HOME: the facade, contract and posture tests, the re-pointed path guards, and the test files main added that import these modules (23 files, 1,266 passed, 5 xfailed); the flake-pattern ratchet (56 passed); docs_lint.py; check_file_line_cap.py (0 failures). The diff size, the move audit and the git-diff / --minimal counts are unchanged. CI re-running on 99f521e.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 15, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s10-transcribe branch from 99f521e to 1270d58 Compare October 15, 2026 06:04
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: the branch went DIRTY after main's 04:55Z merges. 3d09514 -> 83e97cd. The one conflict was the shared row table in test/test_campaign_facades_base_public_names.py, resolved as a union: main's kiro_crew.sandbox row is kept and the S10 rows follow it. Main changed no split target or owner module, so there was nothing to port.

One prose citation is folded in now that the sandbox split has landed: the provider_splits_oversized docstring cites the strict sandbox's run/voice-runtime mask at sandbox_tiers.py, where _STRICT_DIRS now lives.

Re-gated on the new base under an isolated HOME:

  • facade, contract and posture tests, the re-pointed path guards, test_transcribe and test_meetings_audio_import: 25 files, 1,605 passed, 2 skipped, 5 xfailed;
  • the flake-pattern ratchet: 56 passed;
  • docs_lint.py and check_file_line_cap.py: 0 failures.

The git-diff / --minimal difference is still the same one re-shown blank line in transcribe.py (now 111 vs 110). CI is re-running on 1270d58.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s10-transcribe branch from 987dfd6 to f5ebbf9 Compare October 15, 2026 16:53
@bolichen97

Copy link
Copy Markdown
Contributor Author

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 test/test_campaign_facades_base_public_names.py, resolved as a union: main's kiro_crew.providers.acp rows are kept and this PR's rows follow them. The comment edit in website/src/pages/settings/SttSettings.tsx is dropped, so this backend split no longer touches the frontend; the stale citation is listed under "References not edited (cost)". Re-gated under an isolated HOME: 25 files, 1,618 passed, 2 skipped, 5 xfailed; flake ratchet, docs lint and line-cap clean; mypy found no issues in 2,459 files. CI is re-running on f5ebbf9.

git range-diff against 987dfd6
1:  987dfd635c ! 1:  f5ebbf981b refactor: split transcribe.py, mcp_core.py and hooks.py into owners
    @@ test/metrics/test_business_counters.py: class TestAttributeValuesAreBounded:
     
      ## test/test_campaign_facades_base_public_names.py ##
     @@ test/test_campaign_facades_base_public_names.py: _BASE_PUBLIC_NAMES: dict[str, frozenset[str]] = {
    -         voice_runtime_workspace_conflict warm_backend wrap_argv wrap_argv_async
    -         wrapped_by_crew_sandbox
    +         resume_takes_tool_search_replay sandbox_init_failure_for_runtime sanitize_sink_text
    +         servers_exposing_no_tools telemetry_channel_of workspace_cli_settings_lock
              """.split()),
     +    "kiro_crew.mcp_core": frozenset("""
     +        ADVERTISE_CALLER_IDENTITY CORE_MCP_SERVER CallerContext ConversationLog
    @@ test/test_campaign_facades_base_public_names.py: _BASE_PUBLIC_NAMES: dict[str, f
      
      #: Facade -> ``{name: module holding it}`` for each base name the facade re-binds by import.
     @@ test/test_campaign_facades_base_public_names.py: _REBOUND: dict[str, dict[str, str]] = {
    -         "sandbox_plan": "kiro_crew",
    -         "sandbox_seatbelt": "kiro_crew",
    +         "telemetry_channel_of": "kiro_crew.messaging.link",
    +         "workspace_cli_settings_lock": "kiro_crew.workspace_cli_settings",
          },
     +    "kiro_crew.mcp_core": {
     +        "CORE_MCP_SERVER": "kiro_crew.session_directive",
    @@ test/test_transcribe_facade.py (new)
     +        and _home(getattr(transcribe, name)) not in family
     +    }
     +    assert served_from_outside == {}
    -
    - ## website/src/pages/settings/SttSettings.tsx ##
    -@@ website/src/pages/settings/SttSettings.tsx: interface SttVocabularies {
    - /** The only vocabulary state Amazon Transcribe opens a stream with. */
    - const VOCABULARY_READY = 'READY'
    - 
    --/** The listing's refusal code with an IAM fix of its own, from `transcribe.py`. */
    -+/** The listing's refusal code with an IAM fix of its own, from `transcribe_aws.py`
    -+ *  (served as `kiro_crew.transcribe.VOCABULARIES_ACCESS_DENIED`). */
    - const VOCABULARIES_ACCESS_DENIED = 'stt_vocabularies_access_denied'
    - 
    - /**

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention 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 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Punchline: the post-compose _atomic_mutation rebind stays pinned by a test that patches through kiro_crew.hooks

rebutted (verified at this head, no change needed): test_hooks_script_hooks::test_the_store_mutation_guard_reads_the_facade_globals sets kiro_crew.hooks.copy to a recording fake, then asserts that ScriptHookStore.create goes through it. Dropping the rebind makes the test fail (mutation-proven).
test_the_moved_classes_keep_the_module_compose_selects_them_by also pins that the owners' classes keep the module compose selects them by, and that their methods run on the facade's globals.
Both pass on this head's base (25-file gate, 1,618 passed).

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Punchline: a patch through kiro_crew.hooks still reaches ScriptHookStore._atomic_mutation

rebutted (verified, no change needed): hooks.py re-wraps contextmanager(_rebind(__wrapped__, globals())) right after compose, so the generator's __globals__ is the facade dict.
test_hooks_script_hooks::test_the_store_mutation_guard_reads_the_facade_globals patches kiro_crew.hooks.copy and asserts that the store's guard calls it. It is mutation-proven, and it passes on this head's base.
An AST scan finds this to be the only @contextmanager in hook_runtime/.

@bolichen97

Copy link
Copy Markdown
Contributor Author

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:

  • mcp_core_parts/governance.py (containment and the four vets): all 8 identical.
  • mcp_core_parts/identity.py (strict and lenient resolvers, require_strict_session_key, Slack identity): all 9 identical.
  • mcp_core_parts/gateway.py (refused-target replay and re-verification, internal secret, identity headers): 20 identical. _reverify_refused_target, _session_token_header and _http_error_body differ only in their docstrings, from present-tense rewording, the brand spelling and one pointer.
  • transcribe_ffmpeg.py (decoder resolution and the authenticated snapshot): 51 identical. _create_ffmpeg_subprocess differs only in its docstring. logger deliberately binds getLogger("kiro_crew.transcribe"), so logs keep the facade's name.
  • hook_runtime/script_hooks.py: _hook_subprocess_env, run_script_hook and ScriptHookResult are identical. ScriptHookStore differs by the one approved token, split('/')[-1] to rpartition('/')[2] in fire, which is identical for every string. The _atomic_mutation guard is rebound onto the facade's globals, and test_hooks_script_hooks pins that a patch of kiro_crew.hooks.copy reaches it, so a hook edit runs the same guard as at the base.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 15, 2026
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
@bolichen97
bolichen97 force-pushed the refactor/linecap-s10-transcribe branch from f5ebbf9 to e56a355 Compare October 15, 2026 20:47
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 15, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto c6d6106. This head supersedes f5ebbf9, which went DIRTY when main changed moved code. Three changes against the last reviewed head:

  • fix(identity): name recovery paths, reset refused flag, drop dead wrappers (#17612) #19939 (8b7d59f) edited _resolve_session_key_strict and deleted _host_pid_hosts_several_sessions in mcp_core.py. Both now live in mcp_core_parts/identity.py, so the change is ported there byte for byte by re-running the split recipe from the new base. The re-cut differs from the previous head only by that change.
  • test_campaign_facades_base_public_names.py now reads one JSON inventory per facade (test: keep each split facade's frozen inventory in its own file #20911). This PR's two rows moved into test/campaign_facade_inventories/kiro_crew.mcp_core.json and kiro_crew.transcribe.json, and the PR no longer edits that test.
  • The comment edit in website/src/pages/settings/SttSettings.tsx is dropped, so this backend split does not touch the frontend; the stale citation is listed under "References not edited (cost)".

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
1:  987dfd635c ! 1:  e56a355d9e refactor: split transcribe.py, mcp_core.py and hooks.py into owners
    @@ src/kiro_crew/mcp_core.py: def _get_knowledge_search(db_path: Path, cfg_path: Pa
     -       once per runtime and inherited by every MCP child of it, so on a shared
     -       runtime it names one tenant and cannot say which one is calling — the same
     -       ground on which source 3 refuses such a pid
    --       (:func:`_host_pid_hosts_several_sessions`).
    +-       (:func:`kiro_crew.mcp_caller.host_pid_is_shared`).
     -    3. The direct ``KIROCREW_HOST_PID`` -> ``session_pid_<pid>.txt``
     -       lookup, but ONLY when the HMAC sidecar written by the gateway
     -       verifies (:func:`kiro_crew.session_pid_sig.verify_session_pid`).
    @@ src/kiro_crew/mcp_core.py: def _get_knowledge_search(db_path: Path, cfg_path: Pa
     -    # which one is calling — the same reason source 3 below refuses such a pid.
     -    # Answering would attribute this caller to a co-tenant and a state-mutating
     -    # tool would write another session's state.
    --    if sk and not _host_pid_hosts_several_sessions(host_pid):
    +-    if sk and not host_pid_is_shared(host_pid):
     -        return sk
     -    try:
     -        if host_pid.isdigit():
    @@ src/kiro_crew/mcp_core.py: def _get_knowledge_search(db_path: Path, cfg_path: Pa
     -    return ""
     -
     -
    --def _host_pid_hosts_several_sessions(host_pid: str) -> bool:
    --    """True only when the mapping POSITIVELY records several sessions on *host_pid*.
    --
    --    Delegates to :func:`kiro_crew.mcp_caller.host_pid_is_shared`, the one answer
    --    both resolvers share, so the strict path and the client-side ladder cannot
    --    disagree about how many sessions a pid serves, nor about which mapping read
    --    decides it.
    --
    --    That shared answer takes the UNSIGNED read on purpose, because it only ever
    --    DENIES an identity. A same-uid agent that forges a tenant section costs its
    --    target a refusal that names the reason, while the MAC-verified read would
    --    make the guard silently inert wherever the SEL trust root is missing, which
    --    is exactly where identity is already weakest. Source 3 below still demands
    --    the MAC, because source 3 GRANTS a key.
    --
    --    Absence is NOT evidence: a missing or malformed mapping answers False and
    --    leaves the env var exactly as authoritative as it was, so the single-session
    --    topology the var was written for is unaffected and only a pid recorded as
    --    shared loses it. Never raises -- an identity source that can raise would turn
    --    a resolvable session into a crashed tool call.
    --    """
    --    return host_pid_is_shared(host_pid)
    --
    --
     -def strict_identity_diagnosis(server: str = "kirocrew-core") -> str:
     -    """Return the machine-specific reason strict identity is unavailable, or "".
     -
    @@ src/kiro_crew/mcp_core.py: def run_mcp_core_server() -> None:
     +        REFLEXIVE_TOOL_MODULES,
     +        _classify_slack_identity,
     +        _current_session_thread_ts,
    -+        _host_pid_hosts_several_sessions,
     +        _resolve_session_key_strict,
     +        _session_key_from_token,
     +        require_strict_session_key,
    @@ src/kiro_crew/mcp_core_parts/identity.py (new)
     +       once per runtime and inherited by every MCP child of it, so on a shared
     +       runtime it names one tenant and cannot say which one is calling — the same
     +       ground on which source 3 refuses such a pid
    -+       (:func:`_host_pid_hosts_several_sessions`).
    ++       (:func:`kiro_crew.mcp_caller.host_pid_is_shared`).
     +    3. The direct ``KIROCREW_HOST_PID`` -> ``session_pid_<pid>.txt``
     +       lookup, but ONLY when the HMAC sidecar written by the gateway
     +       verifies (:func:`kiro_crew.session_pid_sig.verify_session_pid`).
    @@ src/kiro_crew/mcp_core_parts/identity.py (new)
     +    # which one is calling — the same reason source 3 below refuses such a pid.
     +    # Answering would attribute this caller to a co-tenant and a state-mutating
     +    # tool would write another session's state.
    -+    if sk and not _host_pid_hosts_several_sessions(host_pid):
    ++    if sk and not host_pid_is_shared(host_pid):
     +        return sk
     +    try:
     +        if host_pid.isdigit():
    @@ src/kiro_crew/mcp_core_parts/identity.py (new)
     +    return ""
     +
     +
    -+def _host_pid_hosts_several_sessions(host_pid: str) -> bool:
    -+    """True only when the mapping POSITIVELY records several sessions on *host_pid*.
    -+
    -+    Delegates to :func:`kiro_crew.mcp_caller.host_pid_is_shared`, the one answer
    -+    both resolvers share, so the strict path and the client-side ladder cannot
    -+    disagree about how many sessions a pid serves, nor about which mapping read
    -+    decides it.
    -+
    -+    That shared answer takes the UNSIGNED read on purpose, because it only ever
    -+    DENIES an identity. A same-uid agent that forges a tenant section costs its
    -+    target a refusal that names the reason, while the MAC-verified read would
    -+    make the guard silently inert wherever the SEL trust root is missing, which
    -+    is exactly where identity is already weakest. Source 3 below still demands
    -+    the MAC, because source 3 GRANTS a key.
    -+
    -+    Absence is NOT evidence: a missing or malformed mapping answers False and
    -+    leaves the env var exactly as authoritative as it was, so the single-session
    -+    topology the var was written for is unaffected and only a pid recorded as
    -+    shared loses it. Never raises -- an identity source that can raise would turn
    -+    a resolvable session into a crashed tool call.
    -+    """
    -+    return host_pid_is_shared(host_pid)
    -+
    -+
     +def strict_identity_diagnosis(server: str = "kirocrew-core") -> str:
     +    """Return the machine-specific reason strict identity is unavailable, or "".
     +
    @@ src/kiro_crew/transcribe_local.py (new)
     +    )
     +    return text
     
    + ## test/campaign_facade_inventories/kiro_crew.mcp_core.json (new) ##
    +@@
    ++{
    ++ "base_public_names": [
    ++  "ADVERTISE_CALLER_IDENTITY",
    ++  "CORE_MCP_SERVER",
    ++  "CallerContext",
    ++  "ConversationLog",
    ++  "DIRECTIVE_TOOLS",
    ++  "DeferredTool",
    ++  "HybridRetriever",
    ++  "KiroCrewConfig",
    ++  "KnowledgeStore",
    ++  "MCP_CORE_SCHEMAS",
    ++  "REFLEXIVE_TOOL_MODULES",
    ++  "SEARCH_SCAN_WINDOW",
    ++  "SkillsLoader",
    ++  "UnknownMemoryStore",
    ++  "WAIT_PING_SECS",
    ++  "WAIT_STALENESS_PING_SECS",
    ++  "binding_key_for",
    ++  "build_tool_list",
    ++  "build_tool_names",
    ++  "call_tool_with_logging",
    ++  "capture_directive",
    ++  "clear_vouch",
    ++  "coerce_mcp_tool_args",
    ++  "config_dir",
    ++  "create_embedder_from_config",
    ++  "current_call_name",
    ++  "current_call_raw_args",
    ++  "current_caller",
    ++  "dashboard_socket_path",
    ++  "dedup_sweep",
    ++  "derive_directive",
    ++  "directive_capture_active",
    ++  "dispatch",
    ++  "drive_deferred",
    ++  "external_client_identity_note",
    ++  "host_pid_is_shared",
    ++  "internal_caller",
    ++  "is_incognito_transcript",
    ++  "is_legacy_slack_key",
    ++  "legacy_key",
    ++  "list_agents",
    ++  "loopback_urlopen",
    ++  "map_deferred",
    ++  "outbox_dir",
    ++  "port_is_gateway_owned",
    ++  "rank_triggered",
    ++  "read_config_text",
    ++  "read_local_secret",
    ++  "record_activity",
    ++  "redact",
    ++  "redact_credentials",
    ++  "redact_exfiltration_urls",
    ++  "redact_local_paths",
    ++  "refuse_if_markerless",
    ++  "require_strict_session_key",
    ++  "resolve_agent_bindings",
    ++  "resolve_client_port_src",
    ++  "resolve_own_identity",
    ++  "run_mcp_core_server",
    ++  "run_mcp_stdio_loop",
    ++  "sel",
    ++  "session_key_from_env_token",
    ++  "session_pid_mapping_path",
    ++  "set_current_caller",
    ++  "snippet_needles",
    ++  "spawned_without_gateway_identity",
    ++  "strict_identity_diagnosis",
    ++  "structured_monitor_binding_key_for",
    ++  "summarize_result",
    ++  "validate_tool_args",
    ++  "vector_leg",
    ++  "with_titles"
    ++ ],
    ++ "note": "S10: mcp_core.py became a mirror facade over mcp_core_parts/ (identity, gateway, governance, crew, history, radar_crew); these are the public names it bound before the split.",
    ++ "rebound": {
    ++  "CORE_MCP_SERVER": "kiro_crew.session_directive",
    ++  "CallerContext": "kiro_crew.mcp_caller",
    ++  "ConversationLog": "kiro_crew.history",
    ++  "DIRECTIVE_TOOLS": "kiro_crew.session_directive",
    ++  "DeferredTool": "kiro_crew.mcp_shared",
    ++  "HybridRetriever": "kiro_crew.knowledge.retrieval",
    ++  "KiroCrewConfig": "kiro_crew.config.loader",
    ++  "KnowledgeStore": "kiro_crew.knowledge.store",
    ++  "MCP_CORE_SCHEMAS": "kiro_crew.validation",
    ++  "SkillsLoader": "kiro_crew.skills",
    ++  "UnknownMemoryStore": "kiro_crew.memory_stores",
    ++  "binding_key_for": "kiro_crew.autonudge",
    ++  "build_tool_list": "kiro_crew.mcp_tools",
    ++  "build_tool_names": "kiro_crew.mcp_tools",
    ++  "call_tool_with_logging": "kiro_crew.mcp_shared",
    ++  "clear_vouch": "kiro_crew.session_directive",
    ++  "coerce_mcp_tool_args": "kiro_crew.validation",
    ++  "config_dir": "kiro_crew.config.loader",
    ++  "create_embedder_from_config": "kiro_crew.knowledge.embedder",
    ++  "current_caller": "kiro_crew.mcp_caller",
    ++  "dashboard_socket_path": "kiro_crew.dashboard.origin",
    ++  "dedup_sweep": "kiro_crew.knowledge.dedup",
    ++  "dispatch": "kiro_crew.mcp_tools",
    ++  "drive_deferred": "kiro_crew.mcp_shared",
    ++  "external_client_identity_note": "kiro_crew.mcp_shared",
    ++  "host_pid_is_shared": "kiro_crew.mcp_caller",
    ++  "internal_caller": "kiro_crew.mcp_shared",
    ++  "is_incognito_transcript": "kiro_crew.history",
    ++  "is_legacy_slack_key": "kiro_crew.messaging.link",
    ++  "legacy_key": "kiro_crew.messaging.link",
    ++  "list_agents": "kiro_crew.agent_discovery",
    ++  "loopback_urlopen": "kiro_crew.loopback_http",
    ++  "map_deferred": "kiro_crew.mcp_shared",
    ++  "outbox_dir": "kiro_crew.config.loader",
    ++  "port_is_gateway_owned": "kiro_crew.port_resolution",
    ++  "rank_triggered": "kiro_crew.trigger_match",
    ++  "read_config_text": "kiro_crew.config.loader",
    ++  "read_local_secret": "kiro_crew.config.loader",
    ++  "record_activity": "kiro_crew.members",
    ++  "redact_credentials": "kiro_crew.security",
    ++  "redact_exfiltration_urls": "kiro_crew.security",
    ++  "redact_local_paths": "kiro_crew.security",
    ++  "refuse_if_markerless": "kiro_crew.session_directive",
    ++  "resolve_agent_bindings": "kiro_crew.config.loader",
    ++  "resolve_client_port_src": "kiro_crew.port_resolution",
    ++  "resolve_own_identity": "kiro_crew.mcp_caller",
    ++  "run_mcp_stdio_loop": "kiro_crew.mcp_shared",
    ++  "sel": "kiro_crew.sel",
    ++  "session_key_from_env_token": "kiro_crew.session_token_sig",
    ++  "session_pid_mapping_path": "kiro_crew.session_pid_sig",
    ++  "set_current_caller": "kiro_crew.mcp_caller",
    ++  "snippet_needles": "kiro_crew.history",
    ++  "spawned_without_gateway_identity": "kiro_crew.mcp_shared",
    ++  "structured_monitor_binding_key_for": "kiro_crew.autonudge",
    ++  "summarize_result": "kiro_crew.context_management",
    ++  "validate_tool_args": "kiro_crew.validation",
    ++  "vector_leg": "kiro_crew.knowledge.retrieval",
    ++  "with_titles": "kiro_crew.mcp_tool_titles"
    ++ }
    ++}
    +
    + ## test/campaign_facade_inventories/kiro_crew.transcribe.json (new) ##
    +@@
    ++{
    ++ "base_public_names": [
    ++  "CODE_APPLE_NEEDS_TOOLCHAIN",
    ++  "CODE_APPLE_UNSUPPORTED",
    ++  "CODE_DISABLED",
    ++  "CODE_PROVIDER_OFF",
    ++  "CustomVocabulary",
    ++  "CustomVocabularyListing",
    ++  "DECODER_NOT_EXECUTABLE",
    ++  "DECODER_OK",
    ++  "DECODER_UNAUTHENTIC",
    ++  "FFMPEG_SOURCE_BUNDLED",
    ++  "FFMPEG_SOURCE_STORE",
    ++  "FFMPEG_SOURCE_SYSTEM",
    ++  "PackagedDecoderProbe",
    ++  "STT_PROVIDER_OFF",
    ++  "VOCABULARIES_ACCESS_DENIED",
    ++  "VOCABULARIES_LIST_FAILED",
    ++  "VOCABULARIES_LIST_PERMISSION",
    ++  "VocabularyListError",
    ++  "audio_exceeds_secs",
    ++  "availability_detail",
    ++  "aws_consent",
    ++  "batch_duration_cap_secs",
    ++  "decoder",
    ++  "ensure_ffmpeg_in_path",
    ++  "ffmpeg_source",
    ++  "filter_hallucinations",
    ++  "find_brew",
    ++  "install_hint",
    ++  "is_available",
    ++  "list_custom_vocabularies",
    ++  "load_stt_config",
    ++  "logger",
    ++  "pinned_fs",
    ++  "platform_compat",
    ++  "provider_splits_oversized",
    ++  "stt",
    ++  "transcribe_audio",
    ++  "transcribe_oversized_in_segments"
    ++ ],
    ++ "note": "S10: transcribe.py became a mirror facade over transcribe_ffmpeg, transcribe_aws and transcribe_local; these are the public names it bound before the split.",
    ++ "rebound": {
    ++  "aws_consent": "kiro_crew",
    ++  "decoder": "kiro_crew.stt",
    ++  "filter_hallucinations": "kiro_crew.stt.hallucinations",
    ++  "install_hint": "kiro_crew.extras",
    ++  "pinned_fs": "kiro_crew",
    ++  "platform_compat": "kiro_crew",
    ++  "stt": "kiro_crew"
    ++ }
    ++}
    +
      ## test/metrics/test_business_counters.py ##
     @@ test/metrics/test_business_counters.py: class TestCallSitesAreWired:
              "WORKFLOW_RUNS": "workflows/runner.py",
    @@ test/metrics/test_business_counters.py: class TestAttributeValuesAreBounded:
                  "dashboard/session_health.py",
                  "taskq/store.py",
     
    - ## test/test_campaign_facades_base_public_names.py ##
    -@@ test/test_campaign_facades_base_public_names.py: _BASE_PUBLIC_NAMES: dict[str, frozenset[str]] = {
    -         voice_runtime_workspace_conflict warm_backend wrap_argv wrap_argv_async
    -         wrapped_by_crew_sandbox
    -         """.split()),
    -+    "kiro_crew.mcp_core": frozenset("""
    -+        ADVERTISE_CALLER_IDENTITY CORE_MCP_SERVER CallerContext ConversationLog
    -+        DIRECTIVE_TOOLS DeferredTool HybridRetriever KiroCrewConfig KnowledgeStore
    -+        MCP_CORE_SCHEMAS REFLEXIVE_TOOL_MODULES SEARCH_SCAN_WINDOW SkillsLoader
    -+        UnknownMemoryStore WAIT_PING_SECS WAIT_STALENESS_PING_SECS binding_key_for
    -+        build_tool_list build_tool_names call_tool_with_logging capture_directive
    -+        clear_vouch coerce_mcp_tool_args config_dir create_embedder_from_config
    -+        current_call_name current_call_raw_args current_caller dashboard_socket_path
    -+        dedup_sweep derive_directive directive_capture_active dispatch drive_deferred
    -+        external_client_identity_note host_pid_is_shared internal_caller
    -+        is_incognito_transcript is_legacy_slack_key legacy_key list_agents
    -+        loopback_urlopen map_deferred outbox_dir port_is_gateway_owned rank_triggered
    -+        read_config_text read_local_secret record_activity redact redact_credentials
    -+        redact_exfiltration_urls redact_local_paths refuse_if_markerless
    -+        require_strict_session_key resolve_agent_bindings resolve_client_port_src
    -+        resolve_own_identity run_mcp_core_server run_mcp_stdio_loop sel
    -+        session_key_from_env_token session_pid_mapping_path set_current_caller
    -+        snippet_needles spawned_without_gateway_identity strict_identity_diagnosis
    -+        structured_monitor_binding_key_for summarize_result validate_tool_args
    -+        vector_leg with_titles
    -+        """.split()),
    -+    "kiro_crew.transcribe": frozenset("""
    -+        CODE_APPLE_NEEDS_TOOLCHAIN CODE_APPLE_UNSUPPORTED CODE_DISABLED
    -+        CODE_PROVIDER_OFF CustomVocabulary CustomVocabularyListing
    -+        DECODER_NOT_EXECUTABLE DECODER_OK DECODER_UNAUTHENTIC FFMPEG_SOURCE_BUNDLED
    -+        FFMPEG_SOURCE_STORE FFMPEG_SOURCE_SYSTEM PackagedDecoderProbe STT_PROVIDER_OFF
    -+        VOCABULARIES_ACCESS_DENIED VOCABULARIES_LIST_FAILED VOCABULARIES_LIST_PERMISSION
    -+        VocabularyListError audio_exceeds_secs availability_detail aws_consent
    -+        batch_duration_cap_secs decoder ensure_ffmpeg_in_path ffmpeg_source
    -+        filter_hallucinations find_brew install_hint is_available
    -+        list_custom_vocabularies load_stt_config logger pinned_fs platform_compat
    -+        provider_splits_oversized stt transcribe_audio transcribe_oversized_in_segments
    -+        """.split()),
    - }
    - 
    - #: Facade -> ``{name: module holding it}`` for each base name the facade re-binds by import.
    -@@ test/test_campaign_facades_base_public_names.py: _REBOUND: dict[str, dict[str, str]] = {
    -         "sandbox_plan": "kiro_crew",
    -         "sandbox_seatbelt": "kiro_crew",
    -     },
    -+    "kiro_crew.mcp_core": {
    -+        "CORE_MCP_SERVER": "kiro_crew.session_directive",
    -+        "CallerContext": "kiro_crew.mcp_caller",
    -+        "ConversationLog": "kiro_crew.history",
    -+        "DIRECTIVE_TOOLS": "kiro_crew.session_directive",
    -+        "DeferredTool": "kiro_crew.mcp_shared",
    -+        "HybridRetriever": "kiro_crew.knowledge.retrieval",
    -+        "KiroCrewConfig": "kiro_crew.config.loader",
    -+        "KnowledgeStore": "kiro_crew.knowledge.store",
    -+        "MCP_CORE_SCHEMAS": "kiro_crew.validation",
    -+        "SkillsLoader": "kiro_crew.skills",
    -+        "UnknownMemoryStore": "kiro_crew.memory_stores",
    -+        "binding_key_for": "kiro_crew.autonudge",
    -+        "build_tool_list": "kiro_crew.mcp_tools",
    -+        "build_tool_names": "kiro_crew.mcp_tools",
    -+        "call_tool_with_logging": "kiro_crew.mcp_shared",
    -+        "clear_vouch": "kiro_crew.session_directive",
    -+        "coerce_mcp_tool_args": "kiro_crew.validation",
    -+        "config_dir": "kiro_crew.config.loader",
    -+        "create_embedder_from_config": "kiro_crew.knowledge.embedder",
    -+        "current_caller": "kiro_crew.mcp_caller",
    -+        "dashboard_socket_path": "kiro_crew.dashboard.origin",
    -+        "dedup_sweep": "kiro_crew.knowledge.dedup",
    -+        "dispatch": "kiro_crew.mcp_tools",
    -+        "drive_deferred": "kiro_crew.mcp_shared",
    -+        "external_client_identity_note": "kiro_crew.mcp_shared",
    -+        "host_pid_is_shared": "kiro_crew.mcp_caller",
    -+        "internal_caller": "kiro_crew.mcp_shared",
    -+        "is_incognito_transcript": "kiro_crew.history",
    -+        "is_legacy_slack_key": "kiro_crew.messaging.link",
    -+        "legacy_key": "kiro_crew.messaging.link",
    -+        "list_agents": "kiro_crew.agent_discovery",
    -+        "loopback_urlopen": "kiro_crew.loopback_http",
    -+        "map_deferred": "kiro_crew.mcp_shared",
    -+        "outbox_dir": "kiro_crew.config.loader",
    -+        "port_is_gateway_owned": "kiro_crew.port_resolution",
    -+        "rank_triggered": "kiro_crew.trigger_match",
    -+        "read_config_text": "kiro_crew.config.loader",
    -+        "read_local_secret": "kiro_crew.config.loader",
    -+        "record_activity": "kiro_crew.members",
    -+        "redact_credentials": "kiro_crew.security",
    -+        "redact_exfiltration_urls": "kiro_crew.security",
    -+        "redact_local_paths": "kiro_crew.security",
    -+        "refuse_if_markerless": "kiro_crew.session_directive",
    -+        "resolve_agent_bindings": "kiro_crew.config.loader",
    -+        "resolve_client_port_src": "kiro_crew.port_resolution",
    -+        "resolve_own_identity": "kiro_crew.mcp_caller",
    -+        "run_mcp_stdio_loop": "kiro_crew.mcp_shared",
    -+        "sel": "kiro_crew.sel",
    -+        "session_key_from_env_token": "kiro_crew.session_token_sig",
    -+        "session_pid_mapping_path": "kiro_crew.session_pid_sig",
    -+        "set_current_caller": "kiro_crew.mcp_caller",
    -+        "snippet_needles": "kiro_crew.history",
    -+        "spawned_without_gateway_identity": "kiro_crew.mcp_shared",
    -+        "structured_monitor_binding_key_for": "kiro_crew.autonudge",
    -+        "summarize_result": "kiro_crew.context_management",
    -+        "validate_tool_args": "kiro_crew.validation",
    -+        "vector_leg": "kiro_crew.knowledge.retrieval",
    -+        "with_titles": "kiro_crew.mcp_tool_titles",
    -+    },
    -+    "kiro_crew.transcribe": {
    -+        "aws_consent": "kiro_crew",
    -+        "decoder": "kiro_crew.stt",
    -+        "filter_hallucinations": "kiro_crew.stt.hallucinations",
    -+        "install_hint": "kiro_crew.extras",
    -+        "pinned_fs": "kiro_crew",
    -+        "platform_compat": "kiro_crew",
    -+        "stt": "kiro_crew",
    -+    },
    - }
    - 
    - _PROBE = """
    -
      ## test/test_crew_members_doc.py ##
     @@ test/test_crew_members_doc.py: def test_the_bound_block_the_page_lists_is_what_select_crew_returns(doc_text: st
          ), "the page says the empty call returns the roster plus a top-level default_agent"
    @@ test/test_transcribe_facade.py (new)
     +        and _home(getattr(transcribe, name)) not in family
     +    }
     +    assert served_from_outside == {}
    -
    - ## website/src/pages/settings/SttSettings.tsx ##
    -@@ website/src/pages/settings/SttSettings.tsx: interface SttVocabularies {
    - /** The only vocabulary state Amazon Transcribe opens a stream with. */
    - const VOCABULARY_READY = 'READY'
    - 
    --/** The listing's refusal code with an IAM fix of its own, from `transcribe.py`. */
    -+/** The listing's refusal code with an IAM fix of its own, from `transcribe_aws.py`
    -+ *  (served as `kiro_crew.transcribe.VOCABULARIES_ACCESS_DENIED`). */
    - const VOCABULARIES_ACCESS_DENIED = 'stt_vocabularies_access_denied'
    - 
    - /**

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

Copy link
Copy Markdown
Contributor

HOLD at e56a355d9e4784ca51de4f3e5e02c341ae1a25a5: reserved for human review. This split moves sensitive code verbatim:

  • strict session identity, the internal-secret and session-token headers, and target re-verification (mcp_core_parts/identity.py, gateway.py);
  • the channel and memory-write vets (governance.py);
  • the authenticated ffmpeg snapshot (transcribe_ffmpeg.py);
  • the script-hook env allowlist and sandboxed run (hook_runtime/);
  • the security_posture.py redaction registry.

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:

  • Design's punchline for e56a355 is unanswered. _SOURCES in test_mcp_call_site_auth_coverage.py (and the inflight-report scan) does not glob mcp_core_parts/*.py, yet the spec now sends new MCP work there. Glob them in, or reply with why not. Your design disposition answers the older _atomic_mutation punchline at f5ebbf98.
  • Security Scope CONCERNS: your AST comparison and the scope override are scoped to f5ebbf98/987dfd63. This head re-cut identity.py for fix(identity): name recovery paths, reset refused flag, drop dead wrappers (#17612) #19939, so please re-post them for e56a355.
  • The SttSettings.tsx stale citation is 'queued for the batched docs follow-up'. Link the issue that tracks it.

CI is green on this head.

— crew-pr-reviewer (r105)

@chenmingwei23
chenmingwei23 merged commit 7f1a88b into main Oct 15, 2026
108 of 109 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/linecap-s10-transcribe branch October 15, 2026 22:53
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 15, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by a maintainer 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.

bolichen97 added a commit that referenced this pull request Oct 16, 2026
…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.
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