Skip to content

refactor(slack): split the cron callback into composed owners - #20761

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/linecap-g02-gateway-p3
Oct 15, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/linecap-g02-gateway-p3

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Bring slack/gateway.py down from 7,272 lines by splitting the cron callback, the gateway's largest remaining method, into composed owner modules, with no behaviour change.

slack/gateway.py is 7,272 lines after the second PR of this series (#20601). The repository is adopting a 2,000-line cap on hand-written files (#20192). GatewayOrchestrator._init_cron alone is 3,255 lines: one closure, _cron_callback, runs every cron job kind, so moving whole definitions cannot shrink it. This PR decomposes that closure into methods with explicit inputs and moves them out. It is the third PR of four.

Why it matters

The cron callback is the gateway's most-edited code path. Every later feature or fix to cron delivery, retries or failure alerts gets a file the size of one responsibility instead of a 3,000-line closure whose locals cross a dozen regions.

Not a goal

What changed (motivation → approach → change)

_init_cron held the whole cron run in one closure, so its regions shared locals instead of parameters and could only move together. This PR first turns each region into a method or a function whose closure inputs become explicit parameters, still in gateway.py, and then moves those methods into five owners with the binding shape of #20443 and #20601:

Owner Responsibility
cron_fire.py _init_cron and the _cron_callback it registers (goal reminder, overlap-guard check, the message job's fire-time gate and first-run tab, dispatch), the per-fire capture, resolving the agent and acquiring its session
cron_exec.py the command and script arms, which hold the overlap guard for their run, and the script result delivery
cron_turn.py the agent sequence, and the single-agent turn with its retries and cleanup in one method, so the flags its handler and finally read stay plain locals
cron_delivery.py delivering a single-agent result: duplicate and silent paths, the dashboard, the job's own channel, Slack
cron_failure.py the failure alerts: the four one-spelling helpers and their two callers

gateway.py goes from 7,272 to 4,035 lines; the largest new file is 909. The callback keeps its name, so stall attribution still finds a _cron_callback frame mid-turn. The runtime-death attribution and charge (_cron_failure_attribution, _charge_failure) and _apply_gate_verdict stay in the facade beside the sub-agent death arms, because the runtime-death audit requires the ownership predicate, the shared-death streak and its success clear in one file; they move together in the fourth PR.

Region bodies move verbatim apart from the dedent and these re-plumbing edits: a closure input becomes a parameter (job, cron_execution, the capture), a call to a former closure gains self. or the argument it closed over, the two recursive retries call the retry parameter, the single-agent failure path returns and its caller re-raises, an annotation-only import and a dead store on the sequence path are dropped, seven moved comments are reworded for the comment-history and brand gates, and _cron_quarantine is declared on the class for mypy. One facade import loses its per-line # noqa: F401, which the file-wide F401 setting already covers.

Backwards compatibility

Compatible: every name kiro_crew.slack.gateway bound before this PR stays bound, pinned by test_campaign_facades_base_public_names.py; _init_cron and the four failure-alert helpers keep their name, kind, signature, __module__ and __qualname__, and every new member is pinned the same way by _BASE_SURFACE. Tests and the cron service still reach the callback through CronService.create(on_job=...).

Removes nothing: no public module-level function moves, and every moved name stays reachable on the facade or the class.

Log lines keep the kiro_crew.slack.gateway logger: the owners read the facade's logger through the composed globals.

Tests

  • New test/test_gateway_cron_turn.py and test/test_gateway_cron_exec.py (56 tests) characterise what the decomposition must keep, driven through on_job and passing unchanged before and after the move: the single-agent finally order and the flags each exit hands it, the deferred reset, the compaction box per fire, one charge per run, a cancellation mid-alert, the re-raised exception's identity, the ACP-death and transient retries re-entering the whole callback, the shared-death exemption and its hand-over, the _cron_callback frame mid-stream, the message arm's order, the sequence's per-step cleanup and pre-loop deferral, and, for every command and script disposition, the claim hand-off abandoned before the overlap guard is released.
  • test_runtime_death_is_a_process_event.py gains four self-tests of the one-unit subject rule on in-memory sources (a caller that captures the provider passes; a capture gone, a caller passing None, and an asker nothing calls each fail; a self. call and an explicit-self call are read from the right argument; a getattr or an alias that reaches the asker fails closed).
  • Re-pointed guards: listed below; each turned red when its construct was altered in its new home (16 mutations, all red).
  • Local runs: the 193 test files that import, patch or read the gateway: 11,423 passed, 36 skipped; per-file coverage of the new owners: cron_fire 96%, cron_exec 96%, cron_turn 95%, cron_delivery 98%, cron_failure 94%; cold mypy clean (2,435 source files); black, isort, flake8, comment-history, brand, harness, subprocess-encoding, agent-sdk boundary, docs-lint and line-cap gates clean; semgrep on the changed files: 0 findings, 0 parse errors; the flake ratchet passes; the new test files pass 5 runs at -n0, one at -n 3 and one in reversed order; the five owners ship in the wheel and import from it.

Re-pointed guards

Guard Re-point
test_cron_failure_alert_one_spelling the one-spelling counts read the facade and every owner, without the class-body binding lines (which name a method, not a site); the counts are unchanged
test_sandbox_interpreter_enoent_retry the skipped-status readers read the facade and every owner
test_update_check_install_aware the cron registration contract reads the facade and every owner
test_slack_gateway_cron_exec_coverage the gate and pool counts read the facade and every owner, with the message path last for the after-the-gate check
test_runtime_death_is_a_process_event the cron streak subjects are collected from the facade and every owner; the guard-subject check reads the facade and its owners as one unit, where a parameter subject is filled only by what every caller passes (see below)
test_chat_turn_timeout_consistency _DISPATCH_FILES covers every gateway owner
test_turn_duration_recorded EXPECTED_SITES: cron_turn.py 2, and a slack/gateway.py 0 row so the facade gains no persist site unnoticed
test_transcript_derivation_seam the cron history read row -> cron_delivery.py
test_no_config_dir_in_async five owner rows
test_cron_reaper_ephemeral the negative pin reads the facade and every owner at any indentation
test_security_posture census slack/gateway.py 2 -> 1, cron_exec.py 1; security_posture.py lists the four redacting owners as non-egress
composition contract 17 _BASE_SURFACE rows; _GUARDED_TOKEN_HOMES re-keyed for 11 tokens

The guard-subject check reads the gateway as one unit

test_the_guards_subject_is_a_provider_the_turn_actually_obtained requires every caused_by_this_session(<name>) subject to be given a real value, and exempts a function parameter as filled by its caller. The cron attribution now asks about _run_provider as a parameter of the facade's _cron_failure_attribution, while cron_turn.py fills it, so the per-file exemption would pass even with the capture gone. The check therefore reads slack/gateway.py and every gateway_runtime owner as one unit: there a parameter subject is filled only when every call of its function passes a name the caller assigns a real value or itself receives as a filled parameter, and a function no call reaches fills nothing. The assertion and its message are unchanged; four self-tests pin the rule on in-memory sources, and deleting the capture or passing an unassigned name in the real tree turns it red. The fourth PR's runtime_charge.py is read under the same unit rule.

Citations (L29)

File Construct Old → new
docs/system-specs/modules/slack-gateway.md the facade row, Composition table, what stays five owner rows; the facade keeps the runtime-death charge and the subagent path
docs/system-specs/modules/learn-cron-dashboard.md _acquire_with_model_fallback, the failure DM, the message arm's failure path, the thread claim slack/gateway.py → cron_fire.py, cron_failure.py, cron_delivery.py
docs/system-specs/modules/session.md _acquire_with_model_fallback; the ACP-death retry row → cron_fire.py; _cron_run_single in cron_turn.py
docs/system-specs/modules/governance.md where vet_job_at_fire_time is reached slack.gateway._cron_callback → _cron_callback (cron_fire.py) and the arms (cron_exec.py)
docs/system-specs/modules/messaging.md, common/model-selection.md, turn-stats-footer.md, session-summary.md cron delivery, acquire, usage row, wake slack/gateway.py → the owner
gateway_runtime/cron_dispatch.py, cron_verdict.py, delivery.py, slack/gateway.py module docstrings name the new homes
cron_history.py, cron_service/execution.py, security_posture.py, mcp_gateway/daemon/cli.py, mcp_tools/spawn.py comments name the owner that holds the cited code
test/test_cron_ephemeral_session.py, test_slack_cron_remove_audit.py, test_chat_turn_timeout_consistency.py, test_background_loops_compaction_reinjection.py docstrings and comments slack/gateway.py → cron_fire.py (_cron_capture), cron_exec.py (_deliver_script_result), cron_turn.py
gateway_runtime/__init__.py package docstring owners hold functions moved verbatim or, for the cron callback, cut from its closure with only re-plumbing edits

Relayed, not edited: the slack/gateway.py citation above _UPDATE_TIMEOUT_SECS in kiro_prerequisite.py belongs to a file another campaign scope is splitting, so its owner re-points it (slack/gateway_runtime/update_apply.py).

Manual verification

N/A — a structural move: the related suite and the characterisation tests exercise every moved region through the unchanged on_job entry, and test/integration/test_boot_smoke.py boots the gateway in-process.

Move audit

src/kiro_crew/slack/gateway.py: 7272 -> 4035 lines; moved 46.12% (python-ast)

move_audit.py compares whole definitions, and the cron callback's regions were not definitions before this PR, so the audit lists _init_cron and the class as changed. The region audit (cron_region_audit.py) re-derives every region from the base and compares its tokens with the def that now holds it: 10,492 of 10,524 base tokens unchanged; every difference is one of the re-plumbing edits listed above, a reworded comment, or a pair of parentheses black drops when a dedented call fits on fewer lines.

Diff alignment (L36)

git diff --numstat and git diff --minimal --numstat agree on every changed file.

Files over 2,000 lines this PR grows

All three are report-only under the line-cap guard, and their baseline rows are left as they are:

  • src/kiro_crew/security_posture.py, +5: the non-egress rows for four redacting owners and the reworded comment above them;
  • test/test_slack_gateway_cron_exec_coverage.py, +15: the gate and pool readers join the facade with its owners;
  • test/test_update_check_install_aware.py, +3: the cron contract reads the facade and every owner.

.github/file-line-cap-baseline.txt lowers the slack/gateway.py row by hand to 4035 (that row only).

CI path references

None changed. AUTOSDE.yaml already covers src/kiro_crew/slack/gateway_runtime/**/*.py, and no workflow filter or file list names slack/gateway.py.

Related Issues

Part of #20192

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

Contributed under the project's Apache-2.0 license.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 15, 2026 09:25
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: e579a1b
  • What rule changed: no rule changes. src/kiro_crew/security_posture.py gains four rows in NON_EGRESS_REDACTION_MODULES naming the new cron owners (cron_delivery, cron_exec, cron_failure, cron_fire) that hold redactor calls moved verbatim out of slack/gateway.py, the class comment above the rows names what they redact, and one comment elsewhere in the file now says the alert paths are composed into slack/gateway.py.
  • Before -> after (what was allowed/blocked, now): before, those redactor calls sat in slack/gateway.py, the registered "Slack cron / notification posts" sink; after, the same calls live in owners composed into that facade and run on its globals, listed as non-egress modules because slack/gateway.py stays the registered sink for all of them, as it already is for the earlier owners. Nothing is newly allowed or blocked.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel would count one Slack egress path under the facade rather than under the owner; no redaction is removed or weakened, because every moved call keeps its arguments and order and runs on the facade's globals through gateway_runtime.compose.
  • Evidence checked (which sandbox result proves it): no sandbox path changes, so no sandbox result applies; test/test_security_posture.py (omission detection and the gate-side log census, re-keyed to slack/gateway.py 1 and gateway_runtime/cron_exec.py 1) passes on this head, as do the 193 gateway test files (11,423 passed) and cold mypy.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, gate, policy or sandbox path changes; the composition contract test pins that every owner function runs on the facade namespace, and it passes.
    • Backward compatible (old config / old data / old callers still work, how checked): every redactor call site keeps its arguments and order, and no registry row is removed or narrowed; checked by the census and omission tests above.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py and the gateway suite pass with their assertions unchanged; only rows are re-pointed.
  • How to undo: revert this commit; the four rows are additive and the moved code returns to slack/gateway.py.

@github-actions

github-actions Bot commented Oct 15, 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 884a8d7.

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 884a8d79fb27e54f22e2fc16fac2f7fbc8c7841f 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 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the 56 characterisation tests in test_gateway_cron_turn.py/test_gateway_cron_exec.py passed on the base commit before the decomposition, as the description claims.

[DESIGN-REVIEWED] 884a8d7

Description read

[DESCRIPTION-READ] bd42d5a24e9b0e22bd8ce64a0c9ba7495835e37dda30fdacce227cd879bc32ad

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) — 🟡 CONCERNS

Premise-level review of 884a8d79fb27e54f22e2fc16fac2f7fbc8c7841f — 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: CONCERNS

The new 160-line "one-unit" subject follower in test_runtime_death_is_a_process_event.py is built for six hops, aliases and receivers, but checks exactly one parameter subject one hop away.

Not justified as shipped

  • Item 6 — one consumer, generalized: grepping caused_by_this_session\( across src/kiro_crew/slack finds 4 sites. Only one has a parameter subject: _cron_failure_attribution(job, _run_provider) in gateway.py. It has one caller, cron_turn.py:872, one hop away. Yet _unit_dead_subjects ships _FILL_DEPTH = 6, getattr/alias detection, self/cls binding and explicit-self argument offsets, with 8 self-tests for them.
    Subtraction: replace _unit_dead_subjects, _FILL_DEPTH, _scope_real_names and the route/receiver self-tests with a direct pin: every call of _cron_failure_attribution passes a name that the calling function gives a real value.
    Clears when: a second parameter-subject asker in the gateway unit exists, or the follower is cut down to the single-hop check.

What this change ships

Inventory (8 items) — 7 justified

Intent: a maintainer wants the cron callback split out of a 7,272-line gateway.py to get under the 2,000-line cap, with no behaviour change. REFACTOR (an addition of structure, not a fix).

  1. The cron callback and its arms move into five owner modules (cron_fire/exec/turn/delivery/failure) — justified
  2. gateway.py baseline drops from 7269 to 4035 lines — justified
  3. The four cron owners join NON_EGRESS_REDACTION_MODULES, and the log-site census moves one site to cron_exec.py — justified
  4. Comments and docstrings elsewhere point to the new homes — justified
  5. Existing guards are re-pointed to read the facade plus every owner — justified
  6. A cross-file parameter-subject follower is added to the runtime-death guard — one consumer, generalized
  7. 56 characterisation tests for cron turn and exec are added — justified
  8. _cron_quarantine is declared on the class, and one # noqa: F401 is dropped — justified

[FIRST-PRINCIPLES-REVIEWED] 884a8d7

Description read

[DESCRIPTION-READ] be03145bd97249521384e3ea68673d6df3ebe7459b845d603c1e31cb4d745b0e

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 884a8d7

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

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 15, 2026 09:35
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: no state that crosses fires moved into a per-fire object or onto self — answered, checked

At BASE no _cron_callback local outlived its call. What a job carries across fires lives on the job (_acp_retried, _transient_attempts, its run fields) or on the orchestrator (_running_script_ids, cron_svc, _cron_quarantine), and both are untouched. The split adds no instance attribute. _cron_quarantine is only declared on the class for mypy, and _init_cron still assigns it once at service creation.
The compaction box _turn_compaction and the stop box stay locals of _cron_run_single, created on each call as they were on each callback call. The sequence boxes stay per step. test_two_fires_do_not_share_the_compaction_box pins it.
The deferred reset is the session manager's and _cron_injecting's state, read in the same finally order. test_pending_sub_agent_work_defers_the_reset_and_keeps_the_registration pins that it keeps the registration.
_CronCapture holds only what one fire captured (session key, prompt, agent sequence, execution, store, agent, substitution flag). It is rebuilt every fire, so a retry re-captures exactly as the closure did.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles punchline: the failure path's re-raise covers every exit the old raise did — answered, checked

The region had two exits, both a bare raise of the handled exception: one after the duplicate-suppression branch, one at the end of the alert path. In _cron_single_failure the first becomes return and the second is the function's end. Its only caller is the except Exception as exc: block of _cron_run_single, which runs the bare raise right after the awaited call, so both exits re-raise the same object.
Anything the helper itself raises propagates unchanged, as it did inline. A cancellation during _deliver_failure_alert leaves the run uncounted.
Pinned through on_job before and after the move. test_a_duplicate_failure_reraises_the_same_exception_and_counts asserts the identity of the raised object and the logger.exception record. test_a_raise_after_the_reinjection_is_consumed_hands_it_back covers the alert path. test_a_cancellation_during_the_failure_alert_leaves_the_counters covers the cancellation.
The region audit's only non-re-plumbing difference in that region is this raise → return and two reworded comments.

@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 884a8d79fb27e54f22e2fc16fac2f7fbc8c7841f and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 884a8d7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 884a8d79fb27e54f22e2fc16fac2f7fbc8c7841f: <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 15, 2026
chenmingwei23
chenmingwei23 previously approved these changes Oct 15, 2026

@chenmingwei23 chenmingwei23 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving: readiness gate passed, no conflicts, checks green.

@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 after reading the review lanes: every lane is clean on this head, and the automated triage held it only on a size, path, category or doc rule.

@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
The third step of splitting GatewayOrchestrator. _init_cron held every
cron job kind in one 3,000-line closure whose regions shared locals,
so it could not move by whole definitions. Each region becomes a
method or function with its closure inputs as explicit parameters,
and those move into five gateway_runtime owners: the callback spine
and the per-fire capture (cron_fire), the command and script arms
(cron_exec), the agent turns (cron_turn), the result delivery
(cron_delivery) and the failure alerts (cron_failure). The class body
binds each under its own name and compose() runs the owners on the
facade's globals, so every patch of kiro_crew.slack.gateway.<name>
still reaches the moved code.

Bodies move verbatim apart from the dedent and the listed re-plumbing.
The runtime-death attribution and charge stay in the facade beside the
sub-agent death arms until those move. New characterization tests pin
the callback's ordering, retries, cleanup and charging through on_job;
guards that read the moved code by path now read the owners.

Part of #20192
@bolichen97
bolichen97 force-pushed the refactor/linecap-g02-gateway-p3 branch from e579a1b to 884a8d7 Compare October 15, 2026 21:46
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 884a8d7
  • What rule changed: no rule changes. src/kiro_crew/security_posture.py gains four rows in NON_EGRESS_REDACTION_MODULES naming the new cron owners (cron_delivery, cron_exec, cron_failure, cron_fire) that hold redactor calls moved verbatim out of slack/gateway.py, the class comment above the rows names what they redact, and one comment elsewhere in the file now says the alert paths are composed into slack/gateway.py.
  • Before -> after (what was allowed/blocked, now): before, those redactor calls sat in slack/gateway.py, the registered "Slack cron / notification posts" sink; after, the same calls live in owners composed into that facade and run on its globals, listed as non-egress modules because slack/gateway.py stays the registered sink for all of them, as it already is for the earlier owners. Nothing is newly allowed or blocked.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel would count one Slack egress path under the facade rather than under the owner; no redaction is removed or weakened, because every moved call keeps its arguments and order and runs on the facade's globals through gateway_runtime.compose.
  • Evidence checked (which sandbox result proves it): no sandbox path changes, so no sandbox result applies; test/test_security_posture.py (omission detection and the gate-side log census, re-keyed to slack/gateway.py 1 and gateway_runtime/cron_exec.py 1) passes on this head (re-run on the rebased tree with the touched surface: 654 passed); the code is unchanged from the head where the 193 gateway test files (11,423 passed) and cold mypy passed.
  • No regression:
    • Tools still work (which tools/commands were run, result): no tool, gate, policy or sandbox path changes; the composition contract test pins that every owner function runs on the facade namespace, and it passes.
    • Backward compatible (old config / old data / old callers still work, how checked): every redactor call site keeps its arguments and order, and no registry row is removed or narrowed; checked by the census and omission tests above.
    • Existing tests (which suites passed on this head): test_security_posture.py, test_core_path_redact_before_bound.py and the gateway suite pass with their assertions unchanged; only rows are re-pointed.
  • How to undo: revert this commit; the four rows are additive and the moved code returns to slack/gateway.py.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main c6d6106: the branch had gone DIRTY because two doc lines this PR re-points were also edited on main. No code changed. The range-diff shows exactly those two lines, and each one keeps main's edit together with this PR's new path:

$ git range-diff e579a1bbde~1..e579a1bbde 884a8d79fb~1..884a8d79fb
1:  e579a1bbde ! 1:  884a8d79fb refactor(slack): split the cron callback into composed owners
    (the two doc lines above; nothing else)

Main touched no slack/gateway.py or slack/gateway_runtime/ code. Re-gated locally on the rebased tree: the line-cap check (0 failures), docs lint, and the touched surface (654 tests, with a probe proving kiro_crew was imported from the rebased tree). The default and --minimal diffs agree on every file. CI re-running.

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

Copy link
Copy Markdown
Contributor Author
  • span=5de73d137796 the unit follower checks one parameter subject one hop away — rebutted

At this head the unit has three parameter-subject askers, not one: _cron_failure_attribution(job, _run_provider) in gateway.py, filled by its caller in cron_turn.py, and both death arms of _inject_with_retry(client, msg, parent_key, label) (gateway.py caused_by_this_session(client) twice), filled by the two injection calls in _subagent_done. The clears-when ("a second parameter-subject asker exists") already holds.
The receiver and alias arms are not speculative. The next PR of this series moves _inject_with_retry into a gateway_runtime owner as a method, which callers in another owner reach as self._inject_with_retry(info, client, ...); that is the bound-receiver arm. The facade binds moved functions under their own names (name = _owner.name), which is what the alias exemption reads. Any other alias or a getattr fails closed.
_FILL_DEPTH = 6 is a bound that stops a recursive caller chain, not a hop count the code needs. The rule's six self-tests pin each arm (capture found, capture gone, a caller passing None, no caller, self. receiver, explicit first argument).

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • Design punchline: the 56 characterisation tests passed on the base before the decomposition — answered, checked

Re-run just now against this PR's base commit c6d6106. That tree holds the undecomposed _cron_callback in slack/gateway.py, and test/test_gateway_cron_turn.py and test/test_gateway_cron_exec.py were taken unchanged from this head. Result: 56 passed, plus a probe asserting kiro_crew was imported from that base tree.
They pass unchanged at this head too. Each was also proven by mutation of the code before the move: every mutation turned its test red.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at 884a8d7.

The split reads as a faithful move. I compared the lines removed from gateway.py with the lines added to the five owners. The leftovers are black re-wraps and the re-plumbing edits the description lists. Every AI lane is clean or answered: the First Principles rebuttal holds, because _inject_with_retry asks caused_by_this_session(client) on a parameter (gateway.py L1628), so there are three parameter-subject askers, not one. CI and the Sensitive Change Review are green.

What holds it: the user's rules reserve this for human review. It changes the security-posture redaction registry (security_posture.py L2455-L2466) and rewrites the runtime-death guard's subject rule (test_runtime_death_is_a_process_event.py), and cron_exec.py now holds the command and script execution arms. Auto-merge is armed but waits on a human approval.

This clears when a maintainer reviews those three areas. I did not run the tests or read the new characterisation tests line by line.

— crew-pr-reviewer (r105)

@chenmingwei23
chenmingwei23 merged commit 820be44 into main Oct 15, 2026
104 of 106 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/linecap-g02-gateway-p3 branch October 15, 2026 22:51
@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.

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