Skip to content

refactor(toplevel): unchain the scope-reap audit outcome ternary - #15345

Merged
iamwhatever merged 1 commit into
mainfrom
refactor/simplify-toplevel
Oct 1, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
refactor/simplify-toplevel

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the agent-scope reap audit label readable at a glance, with no behaviour change.

reap_scopes in src/kiro_crew/session_scope_reap.py chose the SEL outcome label for each reclaimable scope with a chained conditional expression nested inside the _sel_scope_reap(...) call. It was the smallest actionable site the module-simplification detector found on main.

Why it matters

This label is an audit field that separates a refused reap (a tenant still holds the scope) from a failed one (the stop ran and left members behind). A reader checking which case gets which label had to untangle a if x else (b if y else c) inside a call's arguments.

Not a goal

  • Changing any audit label, or which inputs produce it.
  • Touching the chained ternary in subagent_manager/monitoring.py. It is another module and five open PRs touch that file.
  • Reshaping the three keystone-excluded ternaries in safety_override.py.
  • Changing the other lease-driven skip inside the signal loop, which records failed rather than refused.

What changed (motivation → approach → change)

The outcome is now picked by a guard-first if/elif/else just above the call, and the call passes outcome as its fourth positional argument, as before.

cleared refused list label (before and after)
True any completed
False non-empty refused
False empty failed

The _sel_scope_reap docstring said it fires "per reclaimed (or failed) scope". It is also called for refused, which this module deliberately keeps apart from failed. The docstring now names all three outcomes.

Backwards compatibility

Compatible: the same three labels come out for every input, in the same order relative to the summary counters and warnings. Both forms were run over every cleared × refused combination and matched.

Tests

No test changes. The suites that drive this function pass locally on the Python 3.12 CI-parity venv: test_session_scope_reap.py, test_runtime_reconcile.py and test_spawn_audit.py (201 passed); test/e2e/test_process_chaos.py skips on this host by design.

Gates, all exit 0: flake8, isort, mypy, check_black_formatting.py, check_subprocess_encoding.py, check_brand_name.py, check_harness_parity.py, docs_lint.py --test, docs-lint.sh, check_per_file_coverage.py --test and verify_vendor_manifest.py. scripts/scrub-lint.sh is not in the tree; that scan runs in CI only.

A five-lens review fleet checked the diff: AUTOSDE blocking rules, behaviour preservation, import semantics, security keystone and boot path, and comment accuracy. Four found nothing. The comment-accuracy lens found the stale docstring above; an independent refuter confirmed it predates this diff, so it was fixed here. Nothing was dropped.

Backend-only diff: nothing under website/, .github/ or scripts/ changes, so CI's changes job reports only_backend=true and the frontend suites were not run locally.

Manual verification

N/A: unit coverage is sufficient. This refactors one expression and one docstring, and the expression was checked over every input combination.

Screenshots / video

Why no screenshot: backend-only refactor of one audit-label expression; nothing renders differently.

Related Issues

no linked issue: a readability sweep from the module-simplification campaign, not tracked by an issue.

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

@bolichen97
bolichen97 requested a review from a team as a code owner September 30, 2026 07:52
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 30, 2026
@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 1cd0ff150dba1df54ec9ebc858c9112bc744d57e and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1cd0ff1

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

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 1cd0ff1

Description read

[DESCRIPTION-READ] 5b87071521e07568a1782cb44615e10024deaccd87503092869d6c02fd13f5ab

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 1cd0ff150dba1df54ec9ebc858c9112bc744d57e — 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

Nothing to check.

What this change ships

Inventory (2 items) — 2 justified

Intent: make the scope-reap audit label choice readable, with no behaviour change — a FIX (readability refactor).

  1. The audit outcome label is now chosen by an if/elif/else above the call instead of a nested ternary inside its arguments; same three labels for the same inputs — justified
  2. _sel_scope_reap's docstring now names all three outcomes instead of omitting refused — justified

[FIRST-PRINCIPLES-REVIEWED] 1cd0ff1

Description read

[DESCRIPTION-READ] d593615e9b0558ad9fd1f35934ed44c17e56fa8cceabfebeb4a0a039af973c1b

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 Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 1cd0ff1

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

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

@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution: Backend Tests (Windows) (2) is red on main, not on this diff.

The four failures on this head are all in test/test_session_control_revive.py (SessionControlError: this session changed while resuming, resume_conflict). That file was added to main by #13110 (2138c2c3fc, 07:31 UTC today), 40 minutes before this branch's base.

The same shard fails on unrelated PR heads on the same base, each with a different subset of that file's tests. One example is fix/dynamic-dashboard-review-followups, run 36686305413: test_a_case_variant_of_a_live_key_is_reported_live_not_revived_twice and test_a_concurrent_resume_during_the_hook_gets_a_coded_conflict_not_a_500. The same shard is also red on fix/slack-reconnect-route-10306, feat/cron-in-mates-sidebar, fix/owner-gate-round13-issueradar and fix/crew18720-panel-default-tab.

This PR changes one expression and one docstring in src/kiro_crew/session_scope_reap.py. Nothing there reaches dashboard/session_control. Every other check on this head is green, and the four AI lanes PASS with no findings.

I am not rerunning the job, because the red reproduces across PRs. This needs a fix on main to the revive tests' Windows behaviour.

@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 Sep 30, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-toplevel branch from 82ad121 to b799a34 Compare September 30, 2026 12:29
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/context.py, src/kiro_crew/dashboard/chat_runner.py, test/test_member_essential_context.py, test/test_member_prompt.py since this head went green (64b0a33 -> f10a74d); CI re-running. Diff unchanged; static gates and 338 related tests pass locally on the rebased tree.

@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 Sep 30, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

CI attribution (head b799a342b3): Backend Tests (Windows) (2) is red on main, not on this diff.

The one failure is test/test_session_control_revive.py::test_revive_accepts_every_key_spelling_a_caller_holds[<lambda>2] (SessionControlError: this session changed while resuming), the same Windows race that fails a different subset of that file on each run since it landed. On the previous head (82ad121046) this shard failed four tests in the same file. This diff touches only src/kiro_crew/session_scope_reap.py, which the test does not import. 22253 other tests in the shard passed. Not re-running, since it fails again. Rebasing once a fix lands on main.

@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 Sep 30, 2026
reap_scopes picked the SEL outcome label for each reclaimable agent
scope with a nested conditional inside the _sel_scope_reap call. It is
now a guard-first if/elif/else that yields the same three labels
(completed, refused, failed) for every input, in the same order.

The _sel_scope_reap docstring listed only reclaimed and failed scopes;
it now names all three outcomes it is called with.
@bolichen97
bolichen97 force-pushed the refactor/simplify-toplevel branch from b799a34 to 1cd0ff1 Compare September 30, 2026 17:30
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/test_session_control_revive.py since this head was built (f10a74d -> 867d7a4). The rebase picks up #15396, which settles each metadata rewrite before the read in the revive tests on Windows. That race is the Backend Tests (Windows) (2) red attributed above. CI is re-running. The diff is unchanged. Static gates pass locally on the rebased tree, and so do 299 related tests (test_session_scope_reap, test_spawn_audit, test_runtime_reconcile, test_session_control_revive).

@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 Sep 30, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Green age (head 1cd0ff150d): verified against fresh main, not re-pushed.

green_age.py reports main +15 commits (867d7a46d4 -> c1a02ce976). The overlap it lists is shared directories and imports only. None of the 15 commits touch src/kiro_crew/session_scope_reap.py, its importers (diag/, runtime_reconcile.py, session.py, session_cleanup.py), or its tests.

This diff was cherry-picked onto c1a02ce976 in a scratch worktree. mypy and flake8 are clean there, and all 201 tests in test_session_scope_reap, test_spawn_audit and test_runtime_reconcile pass. I have not pushed another rebase, which would re-run the full ~60-minute matrix and every review lane for a tree that is provably identical in this file. This would also be the third green-age re-sync on this PR, where the loop hands off to a human. A maintainer can rebase at merge time if they want the CI stamp on the newer base.

@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 Sep 30, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Green age (head 1cd0ff150d): verified against fresh main again, not re-pushed.

green_age.py reports main +24 commits (867d7a46d4 -> 909e0fc193). None of them touch src/kiro_crew/session_scope_reap.py, the files that import it (diag/, runtime_reconcile.py, session.py, session_cleanup.py) or its tests. The only dependency that changed is sandbox.py, and that change only adds crew-home leaf-list entries. The cgroup-slice helpers this module calls (_agents_slice_cgroup_dir, _agents_slice_name, _CGROUP_AGENTS_SLICE, _probe_cgroup_scope) are unchanged.

I cherry-picked this diff onto 909e0fc193 in a scratch worktree. flake8 and mypy are clean there, and all 201 tests in test_session_scope_reap, test_spawn_audit and test_runtime_reconcile pass. This would be the third green-age re-sync on this PR, so I am handing it to a maintainer instead of re-running the full matrix on a tree that is identical in this file.

@iamwhatever
iamwhatever merged commit 6697253 into main Oct 1, 2026
100 of 101 checks passed
@iamwhatever
iamwhatever deleted the refactor/simplify-toplevel branch October 1, 2026 00:45
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 1, 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.

2 participants