Skip to content

refactor(acp): unchain the deny-notice suffix ternary - #37557

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
refactor/simplify-acp
Nov 15, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
refactor/simplify-acp

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the session-start notice's deny-entry formatter read top to bottom, without changing any notice text it produces.

acp/kas_spec_denies.py carries the module-simplification detector's one acp site: denied_command_notice picks the suffix of a deniedCommands notice line with a chained conditional expression (A if p else B if c else ""), so a reader has to work out which else binds to which if to see the three cases.

Why it matters

Nothing is broken today. The function decides which of three labels an operator sees next to an authored deny — past the record bound, refused by Kiro Crew's gate, or neither — and a chained ternary makes a reader work out which else belongs to which if before they can see which label an entry gets.

Not a goal

  • Changing any notice wording, GATE_JUDGED_MARK, the _MAX_DENIES bound, or how denied_command_items classifies an entry.
  • Any other file in acp/. Its other detector site, in kas_permissions.py (_shell_glob_pattern), turns an allowedCommands glob into a regex for the security matcher, so this sweep leaves it as it is.
  • Other packages' detector sites (apps, toplevel, security, dashboard, and the test-pinned decisions shadow import).

What changed (motivation → approach → change)

Every notice line reads exactly as before. In src/kiro_crew/acp/kas_spec_denies.py, denied_command_notice sets suffix with an if/elif/else in place of the chained ternary: the past-the-bound note first, then GATE_JUDGED_MARK for a conditional entry, else nothing. The order, the truthiness tests and the short-circuit (conditional is read only when past_bound is falsy) are the same.

Backwards compatibility

Compatible: the function returns the same string for every input, so both of its callers, unread_denied_commands in the same module and split_deny_notices in agent_sdk/kas_tool_view.py, see no difference.

Removes nothing: no name, key, string or path goes away.

Tests

No test change: the diff changes no behaviour. An equivalence probe called origin/main's and this head's denied_command_notice over 729 combinations (nine truthy and falsy values each for past_bound and conditional, three for whole, three for entry) and got identical strings, including an item with no conditional key at all when past_bound is set (neither version reads it).

On this head (one commit on origin/main), on the Python 3.12 CI-parity venv: the 19 test files that name kas_spec_denies, kas_tool_view, unread_denied_commands, denied_command_notice or spec_keys_without_carrier pass (983 passed). Static gates green: flake8, isort, mypy, the black baseline gate, subprocess encoding, comment history, brand name, harness parity, docs_lint.py --test, docs-lint.sh, check_per_file_coverage.py --test, file line cap and the vendor manifest. The repository's semgrep rules were not run locally (no semgrep binary on this host); CI's SAST job runs them. Backend-only: nothing under website/, .github/ or scripts/ changes.

Pre-push review fleet of seven, all read-only: the Opus and GPT CI review contracts extracted from claude-review.yml and codex-review.yml (both served by Claude Opus 5.5, so the GPT one ran at reduced fidelity) and five lenses (AUTOSDE blocking rules, behaviour preservation, import semantics, security controls and boot path, comment and claim accuracy). None found a code defect; three reviewers ran their own old-versus-new probes and got identical strings and the same subscript reads. The comment lens raised three points about this description; an independent verifier upheld two (the caller count, and a term for the kas_permissions.py site that only a local tool uses), which the wording here reflects, and refuted the third (the 729 count is 9 × 9 × 3 × 3).

Manual verification

N/A — unit coverage sufficient: one conditional expression respelled as statements; no new path.

Screenshots / video

Why no screenshot: backend-only refactor in src/kiro_crew/acp/; nothing renders differently.

Related Issues

Part of #16523

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 review from a team and KiroCrewCaptain as code owners November 15, 2026 07:48
@bolichen97
bolichen97 requested a review from buluoray November 15, 2026 07:48
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 72afbf45bc43be58e250b30fc4c96e6944f11fd4 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 72afbf45bc43be58e250b30fc4c96e6944f11fd4 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing to check. This is a behaviour-preserving restatement of a single expression, and it stays within the stated goal.

[DESIGN-REVIEWED] 72afbf4

Description read

[DESCRIPTION-READ] c3e92379746cf87e8ca455277b918e7f7bc698a9cc6cf46301e7c7eca2deb051

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 72afbf45bc43be58e250b30fc4c96e6944f11fd4 — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks: this rewrites one expression with the same output for every input, so no default, surface or behaviour moves.

Inventory (1 items) — 1 justified

Intent: make the deny-notice suffix choice in denied_command_notice easy to read top to bottom; an ADDITION in the sense of a pure refactor, not a FIX.

  1. denied_command_notice picks its suffix with if/elif/else instead of a chained ternary. The tests run in the same order, and every notice line reads exactly as before. — justified

[FIRST-PRINCIPLES-REVIEWED] 72afbf4

Description read

[DESCRIPTION-READ] 8c166f12ff52c019a31005efac1203fc06286b976d134475efac3709af945984

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

Pure refactor with identical semantics (Python's chained ternary is right-associative, so the original equals the new if/elif/else).

No findings.

[OPUS-REVIEWED] 72afbf4

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 72afbf45bc43be58e250b30fc4c96e6944f11fd4 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 72afbf4

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 72afbf45bc43be58e250b30fc4c96e6944f11fd4 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 2% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

Pure refactor in denied_command_notice: a chained ternary becomes an if/elif/else with the same order, truthiness tests and short-circuit (conditional is only read when past_bound is false). Output strings and the suffix type are identical, no state or contract changes, and no test is required for a refactor that changes no behaviour. Approve.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit ad23e2e26a · 11 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

denied_command_notice picked its suffix with a chained conditional
expression: a past-the-bound note, else the gate-judged mark for a
conditional entry, else nothing. Spell the three cases as an
if/elif/else so the precedence reads top to bottom.

Same order, same short-circuit (`conditional` is read only when
`past_bound` is falsy) and the same truthiness tests, so every notice
string is byte-identical.
@bolichen97
bolichen97 force-pushed the refactor/simplify-acp branch from ad23e2e to 72afbf4 Compare November 15, 2026 08:38
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto main (ad23e2e26a -> 72afbf45bc) to pick up #37545, the fix for the main red tracked in #37564; diff unchanged.

Backend Tests (3.12, 6) and Coverage Gate were red on ad23e2e26a with the three test/metrics/test_kiro_export_destination.py::TestOffOffer cases (assert False is True). Not this diff: the same three failed serially on an untouched origin/main worktree at 55b2e4a5e0. Cause: #37460 removed the home fixture's is_default_home -> True patch, and #37463, merged 26 minutes later, added TestOffOffer, whose off_offer_due keeps its own beacon.is_default_home() check, so under the fixture's tmp KIROCREW_HOME it returned False. On this head the file passes locally (77 tests), along with the 19 files this PR names and the static gates. CI re-running.

@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 Nov 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.

I reviewed head 72afbf4 and confirmed it rewrites one chained conditional expression in denied_command_notice as an if/elif/else. Python's conditional expression is right-associative, so the new branches run in the same order with the same truthiness tests and the same short-circuit, and conditional is still read only when past_bound is falsy. A quick old-versus-new probe over mixed truthy and falsy inputs produced identical suffixes. The function's output does not change and no caller is affected, so nothing blocks.

@KiroCrewCaptain
KiroCrewCaptain merged commit 216a5eb into main Nov 15, 2026
97 of 98 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the refactor/simplify-acp branch November 15, 2026 09:57
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 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.

Reviewed the full diff. A if p else B if c else "" groups as A if p else (B if c else ""), so the new if/elif/else returns the same suffix for every input and keeps the short-circuit (conditional is read only when past_bound is falsy). Display-only; no behaviour change. PR Readiness green on this head.

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