Skip to content

refactor(dashboard): split security, memory and messaging handlers - #21619

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s14-security
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/linecap-s14-security

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: dashboard/handlers/security.py, memory.py and messaging.py each fit under the 2,000-line cap, with every route, import path and test patch working exactly as before.

security.py had grown to 2,807 lines, messaging.py to 2,789 and memory.py to 2,694, all over the repository's 2,000-line rule for hand-written files (all three were listed in .github/file-line-cap-baseline.txt). messaging.py changed 14 times in the last week, so it is where the next feature would land.

Why it matters

A file this size is hard to review and easy to merge-conflict, and the line cap only shrinks: until these files are split, every change to the Security settings API, the memory API or the messaging routes adds to three of the largest files the dashboard has. Splitting them by responsibility gives each new piece of work an obvious home.

Not a goal

  • No behaviour change: every moved definition is byte-identical apart from the edits listed under "Move audit".
  • No change to any route, status code, response body or SEL audit row.
  • No new public API, and no rename of anything callers import.
  • Not splitting the tests of these modules (they belong to the test-split scopes).

What changed (motivation → approach → change)

security.py and memory.py become mirror facades (kiro_crew/_facade_mirror.py, the campaign's shared mechanism): the original path stays the only import path, the moved code lives in sibling owner modules, and a patch through the facade still reaches every module that reads the name. messaging.py was already a compose facade over dashboard/messaging_api/; five more owners join its _facade_compose tuple, so their functions still run on the facade's globals.

Facade (lines) Keeps Owners (lines)
handlers/security.py 2,807 → 895 the denied-commands surface (keystone reads/writes, snapshot, six CRUD routes) security_audit 65 (SEL audit, ConfigCorruptError, off-loop runner), security_trusted_apps 1,119, security_governance_policy 391, security_trusted_registries 579
handlers/memory.py 2,694 → 1,555 documents, settings, semantic and episodic routes, migration, consolidation, the graph route, the write gate memory_services 100 (SEL accessor, the gateway's vector store), memory_embeddings 1,030 (model choice, status, enable), memory_graph 192 (graph builder)
handlers/messaging.py 2,787 → 1,144 api_send_message, the Teams activity route, the iMessage save entry, the module state, _write_env_off_loop messaging_api/: browser_routes 726, channel_config_writes 427 (the rest of the shared channel-config transaction and .env writes), slack_workspace 381 (pins, reactions, profile, manifest), channel_folder_backfill 122, agent_push 178

What stays in each facade is what repository checks read in that file: the denied-commands parsing a code-review.yml tripwire greps by path, the memory routes that path-keyed inventories name, and the send route with its census sites and turn dispatch. _write_env_off_loop stays in messaging.py because main's open code-scanning alert #1091 (py/stack-trace-exposure) sits on it, so the alert stays at the path where main tracks it. Three owners are under 150 lines on purpose: security_audit and memory_services are the lowest layer the other owners import (owners never import their facade), and channel_folder_backfill is one route with no existing owner it belongs to. Specs gain owner maps; definition-site citations name the owners; path-keyed guards are re-keyed (see "Guard changes").

Backwards compatibility

Compatible: every name each facade bound at the merge-base still resolves on it as the same object (test_campaign_facades_base_public_names, test_handlers_messaging_composition_contract); the mirror facades serve owner-bound names and route writes to every holder.

Logger (L25): every security and memory family member binds logging.getLogger("kiro_crew.dashboard.handlers.security") / ("...memory") by literal name, so record.name and the caplog filters keyed on it are unchanged, and the mirror installs under python -m. Messaging owners log through the facade's logger, as before.

Class __module__: ConfigCorruptError and TrustSettingOverlayOwned keep the facade's __module__ (pinned by test_the_moved_exceptions_keep_the_facade_module). _LockedSectionWrite takes its owner's module, as compose owners' classes do (_ChannelSendFailed precedent); nothing in src or tests reads its __module__, __qualname__ or pickles it.

Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_apps_list -- crew page -- still bound on the facade, served from security_trusted_apps.py by the mirror (test_trusted_apps_api)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_app_grant -- crew page -- still bound on the facade, served from security_trusted_apps.py by the mirror (test_trusted_apps_api)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_app_revoke -- crew page -- still bound on the facade, served from security_trusted_apps.py by the mirror (test_trusted_apps_api)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_apps_allow_all -- crew page -- still bound on the facade, served from security_trusted_apps.py by the mirror (test_trusted_apps_api)
Reader: src/kiro_crew/dashboard/handlers/security.py:build_trusted_apps_snapshot -- chat -- still bound on the facade, served from security_trusted_apps.py by the mirror (change_cards.py imports it lazily from the facade; test_trusted_apps_api)
Reader: src/kiro_crew/dashboard/handlers/security.py:build_trusted_apps_snapshot_async -- crew page -- still bound on the facade, served from security_trusted_apps.py by the mirror (test_security_handlers_facade)
Reader: src/kiro_crew/dashboard/handlers/security.py:build_governance_policy_snapshot -- crew page -- still bound on the facade, served from security_governance_policy.py by the mirror (test_governance_policy_viewer)
Reader: src/kiro_crew/dashboard/handlers/security.py:build_governance_policy_snapshot_async -- crew page -- still bound on the facade, served from security_governance_policy.py by the mirror (test_governance_policy_viewer)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_governance_policy -- crew page -- still bound on the facade, served from security_governance_policy.py by the mirror (test_governance_policy_viewer)
Reader: src/kiro_crew/dashboard/handlers/security.py:build_trusted_registries_snapshot -- crew page -- still bound on the facade, served from security_trusted_registries.py by the mirror (test_registry_trust_grant)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_registries_list -- crew page -- still bound on the facade, served from security_trusted_registries.py by the mirror (test_registry_trust_grant)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_registry_grant -- crew page -- still bound on the facade, served from security_trusted_registries.py by the mirror (test_registry_trust_grant)
Reader: src/kiro_crew/dashboard/handlers/security.py:api_trusted_registry_revoke -- crew page -- still bound on the facade, served from security_trusted_registries.py by the mirror (test_registry_trust_grant)
Reader: src/kiro_crew/dashboard/handlers/memory.py:api_memory_embedding_model -- crew page -- still bound on the facade, served from memory_embeddings.py by the mirror (test_embedding_model_apply)
Reader: src/kiro_crew/dashboard/handlers/memory.py:api_memory_embedding_status -- crew page -- still bound on the facade, served from memory_embeddings.py by the mirror (test_enable_embeddings_faiss)
Reader: src/kiro_crew/dashboard/handlers/memory.py:api_memory_enable_embeddings -- crew page -- still bound on the facade, served from memory_embeddings.py by the mirror (test_enable_embeddings_faiss)
Reader: src/kiro_crew/dashboard/handlers/memory.py:api_memory_disable_embeddings -- crew page -- still bound on the facade, served from memory_embeddings.py by the mirror (test_handlers_memory_coverage)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_notification_agent_push -- chat -- re-imported by the facade from messaging_api/agent_push.py and composed onto its globals (test_handlers_messaging_composition_contract)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_slack_pins -- chat -- re-imported by the facade from messaging_api/slack_workspace.py and composed onto its globals (test_handlers_messaging_composition_contract)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_slack_reactions -- chat -- re-imported by the facade from messaging_api/slack_workspace.py and composed onto its globals (test_handlers_messaging_composition_contract)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_slack_profile -- chat -- re-imported by the facade from messaging_api/slack_workspace.py and composed onto its globals (test_handlers_messaging_composition_contract)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_slack_manifest -- crew page -- re-imported by the facade from messaging_api/slack_workspace.py and composed onto its globals (test_handlers_messaging_composition_contract)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_token_put -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_command -- chat -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_command_drain -- chat -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_command_result -- chat -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:stop_browser_install -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_install_get -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_install_start -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_engine_install -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_view_get -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_view_start -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_browser_open -- crew page -- re-imported by the facade from messaging_api/browser_routes.py and composed onto its globals (test_messaging_browser_routes, test_browser_cli_journeys)
Reader: src/kiro_crew/dashboard/handlers/messaging.py:api_channel_folder_backfill -- crew page -- re-imported by the facade from messaging_api/channel_folder_backfill.py and composed onto its globals (test_handlers_messaging_composition_contract)

Move audit

src/kiro_crew/dashboard/handlers/security.py: 2807 -> 895 lines; moved 92.01% (python-ast)
   changed: _stop_apps_running_on_blanket_trust [AsyncFunctionDef] 96 lines
   changed: _mutate_agent_config [AsyncFunctionDef] 69 lines
   changed: Expr [Expr] 37 lines
src/kiro_crew/dashboard/handlers/memory.py: 2694 -> 1555 lines; moved 99.27% (python-ast)
   changed: _redact_pip_stderr [FunctionDef] 18 lines
src/kiro_crew/dashboard/handlers/messaging.py: 2787 -> 1144 lines; moved 90.91% (python-ast)
   changed: _LockedSectionWrite [ClassDef] 185 lines
   changed: Expr [Expr] 19 lines
  • security.py _stop_apps_running_on_blanket_trust: docstring "can no longer be" → "cannot be" (comment-history gate on moved lines).
  • security.py Expr: the facade's module docstring names the three owner surfaces.
  • memory.py _redact_pip_stderr: docstring "no longer matches" → "does not match" (comment-history gate).
  • messaging.py Expr: the _facade_compose(...) call lists the five new owners (glue).
  • Comment-only edits (no AST change): security_trusted_apps.py two "no longer" comments (comment-history), "the denied-commands opt-out above" → "in the facade", "this module's own error type" → "the handlers' own"; memory_embeddings.py "is no longer authoritative" → "is not", "previously-working" → "working" (comment-history); memory_graph.py the example project header "KiroCrew (Public)" → "Acme (Public)" twice (brand gate); memory_services.py the comment about the one-module file's top-level KiroCrewConfig binding; agent_push.py "no longer says" → "does not say" (comment-history, Master ruling).
  • Formatting: security.py was black-baselined; the 12 statements black re-wraps in security_trusted_apps.py are AST-identical, and security.py leaves .github/black-baseline.txt.
  • Glue: the literal logger lines; ConfigCorruptError.__module__ / TrustSettingOverlayOwned.__module__ restores; the TYPE_CHECKING manifests (owner-defined names, and names served from outside the family, L42).

L36 (default vs --minimal added lines): identical for every changed file (memory.py +108/-1247; messaging.py +75/-1718; security.py +147/-2059 under both; the owners are new files).

Guard changes

Master ruling (messaging Option A): each re-keyed pin is at least as strong, with a mutation proof that turns it red.

Pin Before After
_FACADE_DEFS (messaging contract) 25 defs pinned to the facade the 10 that stay (_write_env_off_loop among them); rows of the 15 moved defs deleted, rationale names their homes
census test (messaging contract) test_the_census_sites_stay_in_the_facade: facade == 12, owners grow none test_the_census_sites_stay_in_their_census_homes: facade 2, slack_workspace 10, total 12, every other owner forbidden, both equal their census rows
_STAYS_IN_THE_FACADE (messaging contract) 4 patterns, facade only (pattern, owners) rows; await read_bounded_json\( = facade + agent_push exactly; the other three unchanged
_OWNER_MODULES / _BASE_OWNERS / _BASE_SHAPE_DIGEST 14 owners, 86 names 19 owners, 120 names; digest computed on the merge-base facade in an isolated interpreter and identical at HEAD
test_security_posture._BASELINE_LOG_SITE_CENSUS dashboard/handlers/messaging.py: 12 messaging.py: 2 + messaging_api/slack_workspace.py: 10
security_posture.NON_EGRESS_REDACTION_MODULES — + handlers/memory_embeddings.py, handlers/memory_graph.py (classified as their facade handlers/memory.py is), messaging_api/slack_workspace.py (the facade stays the registered sink, as for the spawn owners)
test_json_object_body_guard._CAP_REGISTER handlers/messaging.py::api_notification_agent_push, handlers/memory.py::api_memory_embedding_model messaging_api/agent_push.py::..., handlers/memory_embeddings.py::...
test_no_config_dir_in_async._ASYNC_CHECKED_FILES — + the 5 new messaging_api owners
test_internal_python_isolation dashboard/handlers/memory.py × 2 dashboard/handlers/memory_embeddings.py × 2
test_vector_memory._PLUMBED_SITES dashboard/handlers/memory.py dashboard/handlers/memory_services.py
test_r6_owner_gate_regression._GATED_MODULES ...handlers.security + the 4 security_* owner modules (L40(8))
test_handlers_memory_coverage::test_no_async_handler_calls_sync_get_vector_store getsource(mem_mod) the facade plus every _OWNERS file (L40(8) join)
test_sync_io_in_async_gate::TestExemplarStaysClean handlers/memory.py alone the facade plus every file its _OWNERS names (L40(8) join; assertions unchanged)
code-review.yml bool() opt-out tripwire handlers/security.py + handlers/security_*.py (see CI path references)

Mutation proofs (26, all red, then restored): r6-gated-modules, msg-base-owners-dropped-name, msg-unlisted-owner, msg-facade-def-in-owner, msg-census-13th-site-in-other-owner, msg-census-site-moved-between-homes, msg-stays-planted-in-other-owner, msg-stays-removed-from-agent-push, cap-register-agent-push, cap-register-embedding-model, async-row-dropped, async-guard-reaches-owner, isolation-row-reaches-owner, plumbed-site-reaches-owner, tripwire-reaches-owner, non-egress-row, non-egress-row-slack, security-facade-owner-dropped, security-kept-code-moved, memory-facade-owner-dropped, memory-setup-status-on-facade, msg-census-13th-site-in-facade, syncio-exemplar-reaches-owner, codereview-tripwire-reaches-owner, msg-off-loop-drain-in-owner, msg-digest-moved-signature.

Tests

  • New test/test_security_handlers_facade.py and test/test_memory_handlers_facade.py: every name the test trees patch through each facade (scanned with test/facade_mirror_scan.py, with a known-seams non-vacuity floor) reaches every module holding it and the undo restores them; the owners load lowest layer first; no forwarding table; names served from outside the family are visible to type checkers (L42); one logger under the facade name; the kept code stays bound on the facade; the moved exceptions keep the facade module; _embedding_setup_status lives in one owner (its global rebinding stays the binding every read sees); python -m still runs; corpus-gate self-test.
  • New test/test_messaging_browser_routes.py: the native panel's command-bus routes (/api/browser/command, /command-drain, /command-result) for every body shape and bus outcome, with a recording stand-in bus. They were 15/83 covered in CI's report; the owner file now reaches the 80% per-file floor on its own (93% locally).
  • test/campaign_facade_inventories/kiro_crew.dashboard.handlers.security.json (62 names, 37 re-bound) and ...memory.json (88, 62), generated from the merge-base text.
  • Floor: 486 test files at -n 3 -- every test file that imports, patches or names a moved symbol of these modules, every whole-tree scanner (rglob / source_corpus), and the guards above: 33,445 tests, 33,444 passed (95 skipped, 5 xfailed) plus test_platformdirs_pytest_plugin_block, which reads the addopts my -o addopts= override dropped and passes under the default options. Touched sets after the later edits, default options: 1,605 passed, then 443 passed (test_sync_io_in_async_gate, test_ai_review_workflows_code_review_greps, the facade, contract, mirror-guard and flake/wait-discipline ratchet tests). scripts/local-gate.py --dry-run selects 2,277 backend + 599 frontend related files, over the campaign's 600-file local cap, so the floor above ran instead; CI owns the full matrix. After the rebase onto main with the config/loader.py split (refactor: split config/loader.py into loader_* owners behind a facade #20550): the importer floor again (187 files, default options), 13,562 passed, and mypy over the package is clean. After the rebase onto main at 75bead2892 with _write_env_off_loop kept in the facade: every test file that imports, patches or names the messaging facade or its owners, plus the error-code, sync-io, config-dir, posture, JSON-body, flake-ratchet, line-cap, facade-inventory and mirror guards (100 files, -n 3), 5,174 passed (1 skipped), and mypy over the package is clean. After the rebase onto main at 8335fa0164 (fix(dashboard): take a cron's queued card down when its turn starts #21340 edits api_send_message, which stays in the facade): every test file that names any of the three facades, their owners or security_posture, plus the guards and the test files main changed that mention these modules (309 files, -n 3): 22,570 passed, 31 skipped, 1 failed, and mypy over the package is clean. The one failure is test_facade_mirror_guards.py::test_no_test_writes_a_mirrored_facade_namespace_directly hitting the 120 s pytest timeout under host load (load average 45-67 on 32 CPUs). It reproduces on main: run alone in git-archive exports of main and of this head, it takes 141.5 s / 122.6 s of CPU on main and 138.3 s / 121.4 s on this head (two runs each). It passed alone in this worktree (115.6 s) and on CI at the previous head.
  • Determinism (new and rewritten tests): 20 runs at -n0, each in a shuffled order (seeds printed: 1000 + 7919·i), plus one -n 3 run: 83 passed every time.

Manual verification

N/A: a pure move; the facade, mirror and composition guards, the importer floor and an installed-wheel import of every new module cover it.

Docs, citations and source-text pins

  • Specs: owner maps in docs/system-specs/modules/learn-cron-dashboard.md (security, memory) and messaging.md (the messaging_api table and what the facade keeps); definition-site citations re-pointed in app-kit-platform.md, governance.md, security.md, config.md, memory-skills-hooks.md; docs/feature-map/README.md facade note names the two new facades and their owners.
  • L29 citation edits (path or name only), file:line old -> new:
    • src/kiro_crew/apps/registry_trust.py:10 dashboard/handlers/security.py -> dashboard/handlers/security_trusted_registries.py
    • src/kiro_crew/apps/registry_trust.py:14 security.py / it / imports -> The security handlers / they / import
    • src/kiro_crew/security_posture.py:33 handlers/security.py's / snapshot), -> the / snapshot in handlers/security_governance_policy.py),
    • src/kiro_crew/browser/command_bus.py:7 wired / dashboard/handlers/messaging.py. -> dashboard/messaging_api/browser_routes.py.
    • src/kiro_crew/dashboard/handlers/mcp.py:2386 security.py's -> security_trusted_apps.py's
    • src/kiro_crew/dashboard/handlers/computer_use.py:141 handlers/security.py::ConfigCorruptError, -> handlers/security_audit.py::ConfigCorruptError,
    • src/kiro_crew/dashboard/handlers/computer_use.py:191 handlers/security.py::_run_off_loop: -> handlers/security_audit.py::_run_off_loop:
    • src/kiro_crew/dashboard/handlers/computer_use.py:560 handlers/messaging.py's -> messaging_api/agent_push.py's
    • src/kiro_crew/vector_memory_lifecycle.py:352 dashboard/handlers/memory.py's -> dashboard/handlers/memory_services.py's
    • src/kiro_crew/dashboard/messaging_api/__init__.py:30 _LockedSectionWrite transaction, -> _ABSENT sentinel,
    • test/test_trusted_apps_api.py:3 dashboard/handlers/security.py -> dashboard/handlers/security_trusted_apps.py
    • test/test_governance_policy_viewer.py:439 security.py -> security_governance_policy.py
    • test/test_chat_regenerate_refusal_codes.py:50 handlers/security.py:1535 / # -> handlers/security_trusted_apps.py (allow-all) / #
    • test/test_chat_regenerate_refusal_codes.py:71 handlers/security.py -> handlers/security_trusted_apps.py
    • test/test_r8_s33_subprocess_env.py:197 memory.py -> memory_embeddings.py
    • docs/system-specs/modules/computer-use.md:591 messaging.py's -> messaging_api/agent_push.py's
    • docs/system-specs/modules/app-kit-platform.md:2370 dashboard/handlers/security.py -> dashboard/handlers/security_trusted_apps.py
    • docs/system-specs/modules/app-kit-platform.md:2686 dashboard/handlers/security.py). -> dashboard/handlers/security_trusted_registries.py).
    • docs/system-specs/modules/app-kit-platform.md:2701 dashboard/handlers/security.py / (security.py / imports -> dashboard/handlers/security_trusted_registries.py / (the security handlers / import
    • docs/system-specs/modules/governance.md:2417 (handlers/security.build_governance_policy_snapshot, -> (handlers/security_governance_policy.build_governance_policy_snapshot,
    • docs/system-specs/modules/governance.md:3718 dashboard/handlers/security.py / serialization). -> dashboard/handlers/security_governance_policy.py / serialization), served through dashboard/handlers/security.py.
    • docs/system-specs/modules/security.md:1406 (handlers/messaging.py) -> (dashboard/messaging_api/slack_workspace.py)
    • docs/system-specs/modules/security.md:3045 dashboard/handlers/security.py)** -> dashboard/handlers/security_trusted_registries.py)**
    • docs/system-specs/modules/config.md:2854 handlers/messaging.py, -> messaging_api/channel_config_writes.py,
    • docs/system-specs/modules/memory-skills-hooks.md:1183 dashboard/handlers/memory.py, -> dashboard/handlers/memory_services.py,
  • Rows: .github/file-line-cap-baseline.txt rows for all three targets deleted; .github/black-baseline.txt row for security.py deleted; error-code-baseline.json redistributed (--update, own rows only): totals unchanged (1046 / 18 / 38).
  • Baselined growth (L56 addendum 1): test/test_handlers_memory_coverage.py main row 3,102 → 3,105 (the L40(8) tripwire join). Baselined growth (L56 addendum 1b): src/kiro_crew/security_posture.py +3 (three exact-path NON_EGRESS rows the drift guard requires; the shared comment re-worded in place).
  • References not edited (cost): none in website/** names a moved definition's file.

CI path references

  • .github/workflows/code-review.yml:186 (Check backend security rules, the bool() opt-out tripwire): the git diff path list gains 'src/kiro_crew/dashboard/handlers/security_*.py', so the four security owners stay in scope (path list only, no logic; Master grant under L14). Proof: a synthetic two-commit repo adding bool(denied.get('disable_all')) to security_trusted_apps.py is caught with the new path list and missed with the old one.
  • No other workflow path filter, explicit file list, AUTOSDE.yaml glob or SENSITIVE_GLOBS entry needs a new path. The edit to src/kiro_crew/security_posture.py (a SENSITIVE_GLOBS path) brings in Sensitive Change Review; its template is posted as a PR comment for the head.

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

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97

bolichen97 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: f3087da
  • What rule changed: none. src/kiro_crew/security_posture.py gains three exact-path NON_EGRESS_REDACTION_MODULES rows (dashboard/handlers/memory_embeddings.py, dashboard/handlers/memory_graph.py, dashboard/messaging_api/slack_workspace.py) for redactor calls that moved verbatim out of handlers/memory.py and handlers/messaging.py, a shared comment reworded to name the Slack owner, and a docstring cite re-pointed to handlers/security_governance_policy.py.
  • Before -> after (what was allowed/blocked, now): unchanged; the same redactor calls run on the same responses, now classified under the owner paths they live in, exactly as their facades and the spawn owners already are; no sink row, label or count changes.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the posture panel's omission guard would fail CI on an unclassified module; no runtime behaviour depends on these rows, so nothing is leaked, blocked or broken for a user.
  • Evidence checked (which sandbox result proves it): test_security_posture TestOmissionDetection passes on this head, and removing either new row turns test_every_redactor_call_site_is_a_registered_sink_or_allowlisted red (mutation proofs non-egress-row and non-egress-row-slack).
  • No regression:
    • Tools still work (which tools/commands were run, result): test_security_posture, test_handlers_messaging_composition_contract and the 100-file messaging importer set (5,174 passed) passed on this patch one rebase earlier, the 13-file facade and guard set (984 passed) on this head, and the 486-file importer floor on the same split before its rebase; no tool or command path changed.
    • Backward compatible (old config / old data / old callers still work, how checked): yes; no config, data or caller reads these rows except the posture tests, which pass unchanged in logic.
    • Existing tests (which suites passed on this head): test_security_posture, test_handlers_messaging_composition_contract, test_security_handlers_facade, test_memory_handlers_facade and test_facade_mirror_guards (984 passed with the guard set); the 100-file messaging importer set (5,174 passed) on this patch one rebase earlier; the 486-file floor (33,444 passed) ran on the same split before its rebase.
  • How to undo: revert the commit; the three rows and the comment go with the moved code.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 14:29
@bolichen97
bolichen97 requested a review from mbriones98 October 17, 2026 14:29
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for f3087da.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision f3087da5be20cd37d5c5984958fd467b2bd6d95a 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 added the readiness: checking Automated validation is still running label Oct 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] f3087da

Description read

[DESCRIPTION-READ] 5d3fcc29164825c34a8a4a50e3550748d3f472843e7c8edb47f56c9ee9ed0bd6

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f3087da5be20cd37d5c5984958fd467b2bd6d95a — 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 deliberately small owners (security_audit 65 lines, memory_services 100) are the only import-cycle breakers, not extra layers.

What this change ships

Inventory (8 items) — 8 justified

Intent: bring three dashboard handler files under the 2,000-line cap with no behaviour change. This is a refactor (ADDITION of files only, no new capability).

  1. handlers/security.py split into a mirror facade plus four owner modules; routes and import path unchanged — justified
  2. handlers/memory.py split into a mirror facade plus three owners — justified
  3. handlers/messaging.py gains five messaging_api/ compose owners — justified
  4. Three rows removed from .github/file-line-cap-baseline.txt (the cap only shrinks) — justified
  5. Path-keyed guards (the code-review.yml bool tripwire, the R6 owner gate, async/IO gates, the log-site census, NON_EGRESS_REDACTION_MODULES, the error-code baseline) re-keyed to the owner files — justified
  6. Definition-site citations in comments and specs point at the owners — justified
  7. Tripwire tests now walk the facade's _OWNERS so moved handlers stay covered — justified
  8. New test_messaging_browser_routes.py covers the moved browser command-bus routes — justified

[FIRST-PRINCIPLES-REVIEWED] f3087da

Description read

[DESCRIPTION-READ] d49b707e3ed0e04f02a147e2ddc3da8a2c1d192b1ca9f1aaaeb643f5a7d11bc5

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f3087da

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 17, 2026 14:35
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f3087da

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

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 17, 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 on behalf of the maintainer: code-move refactor held by the cron on a README touch or the file cap alone. Every review lane on the current head is clean (only PR Scope size notes).

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Oct 17, 2026
@bolichen97
bolichen97 force-pushed the refactor/linecap-s14-security branch from 45e58d9 to 984008a Compare October 17, 2026 18:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Oct 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted facade patches reach the moved owner functions, including tests outside the inventories

Verified, not a defect: each mirror facade's setattr writes every module that binds the name. Patching memory._get_vector_store_async lands in memory, memory_services and memory_embeddings; security._sel lands in security_audit; and each undo restores them all (checked on this head).
The reach is not limited to the inventories: test_security_handlers_facade and test_memory_handlers_facade scan every test file for names patched through the facade (facade_mirror_scan, with a known-seams non-vacuity floor that includes _sel). They then patch each one and require every holder to see it.
Messaging is a compose facade: its owner functions run on the facade's globals, and test_no_owner_captures_a_name_tests_rebind_on_the_facade covers the test corpus.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted the facade-only pins are re-keyed to named homes, not loosened

Census: test_the_census_sites_stay_in_their_census_homes requires exactly {messaging.py: 2, messaging_api/slack_workspace.py: 10}. It also requires each to equal its _BASELINE_LOG_SITE_CENSUS row, a total of 12, and no site in any other owner. Mutations red: msg-census-13th-site-in-other-owner, -site-moved-between-homes, -13th-site-in-facade.
STAYS_IN_THE_FACADE: each pattern must match the facade, and the set of owners holding it must equal its row exactly (agent_push for read_bounded_json, none for the other three). Mutations red: msg-stays-planted-in-other-owner, msg-stays-removed-from-agent-push.
Tripwire: code-review.yml adds handlers/security
*.py to the bool() path list and drops nothing. A synthetic two-commit repo shows the plant in security_trusted_apps.py caught with the new list and missed with the old one.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 17, 2026
handlers/security.py (2,807 lines), messaging.py (2,789) and memory.py
(2,694) were over the 2,000-line cap for hand-written files. Each keeps
its path as the only import path and patch surface; the moved code
lives in owners by responsibility.

security.py (895) and memory.py (1,555) become mirror facades
(kiro_crew._facade_mirror): security keeps the denied-commands surface,
with owners security_{audit,trusted_apps,governance_policy,
trusted_registries}; memory keeps the document, settings, vector-tier,
migration, consolidation and graph routes, with owners
memory_{services,embeddings,graph}. messaging.py (1,102) composes five
more messaging_api owners: browser_routes, channel_config_writes,
slack_workspace, channel_folder_backfill and agent_push.

Moved bodies are unchanged apart from listed comment and docstring
rewordings for the comment-history and brand gates, and phrases that
named the one-module layout. Path-keyed guards follow the moved code
(census, stays-in-facade and facade-defs pins re-keyed per ruling);
specs gain owner maps; new facade tests pin patch reach and the kept
code, and new route tests cover the browser command bus.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-s14-security branch from 984008a to f3087da Compare October 18, 2026 08:12
@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 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted the two small owners only break import cycles; they add no extra layer

Owners never import their facade, so a helper that the facade and at least two owners call needs one low owner they can all import. security_audit holds exactly that: _audit and ConfigCorruptError (used by security.py, security_trusted_apps and security_trusted_registries) and _run_off_loop (security.py and security_trusted_apps). It also holds _sel, which _audit calls and tests patch as security._sel.
memory_services holds _get_vector_store_async (memory.py and memory_embeddings), plus the two things it calls, _get_vector_store and _sel (_sel is also read by memory_embeddings).
Neither module wraps, re-exports or forwards anything. Each is imported directly by its readers, and the facade serves their names through the same mirror as every other owner.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 18, 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.

Every review lane on the head is clean (only runner notices and PR Scope size warnings); held by the triage cron on size or path rules alone. Approved on the watch holder's request.

@bolichen97
bolichen97 merged commit a281642 into main Oct 18, 2026
105 checks passed
@bolichen97
bolichen97 deleted the refactor/linecap-s14-security branch October 18, 2026 09:28
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants