Skip to content

fix(name-grant): name the part a declined auto-approve could not model - #16082

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
eladrkatz:fix/name-grant-decline-reason
Oct 4, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
eladrkatz:fix/name-grant-decline-reason

Conversation

@eladrkatz

@eladrkatz eladrkatz commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: When an auto-approve grant is declined because the command "could not be reduced to a known set of program names", the notice says which part of the command caused it.

Today the notice reads:

🛡️ Auto-approve not applied — the command line could not be reduced to a known set of program names. Approve this command explicitly.

It never says which part. One user's audit log holds 1,517 of these declines in three weeks, and each one meant reading the command by hand to guess the cause.

Why it matters

Without the part named, the only way to learn the cause is to read name_grant.py. A user who wants fewer prompts cannot tell what to change in how they, or their agent, write commands. So the notice adds a chat row but no fact anyone can act on.

Not a goal

  • Changing which commands are declined. The same lines are refused, with the same code.
  • Moving the notice onto the approval card, or hiding it.
  • Reading inside $( ) or a wrapper's arguments.

What changed (motivation → approach → change)

The notice now ends with the part the check gave up on:

Command Notice now ends with
for f in a b; do grep x $f; done (the shell keyword 'for')
python3 - <<'EOF' with print(json.dumps({'a': 1})) on line 3 (line 3: the operator '))')
grep -n foo a.py \ continued on the next line (line 1: a trailing backslash; this check does not follow a line continuation)
PYTHONPATH=src python3 -m pytest x.py (the assignment 'PYTHONPATH=', which changes what runs)
echo 'unterminated (an unclosed quote; this check tokenizes one line at a time)

The program-name walk in src/kiro_crew/name_grant.py gave up in nine places by returning a bare None, so the refusal could only say that it gave up. Each place now raises a private _Unmodelled error naming its part, and name_grant_refusal adds that to the UNTOKENIZABLE detail, with the line number for a multi-line command. program_names still returns None, so its other callers do not change.

The part goes only into the display detail. Audit rows and log lines still use the constant log_text. Nothing after an = is shown, since an assignment's value can be a secret, and a part over 40 characters is cut.

Backwards compatibility

Compatible: the same commands are declined with the same refusal code and log text; only the human-readable detail gains a suffix. _program_names_line now raises instead of returning None; its one other caller is a test, updated to expect the raise.

Tests

  • test/test_name_grant.py::TestUntokenizableDetail locks in that each POSIX give-up names its part, that a multi-line command names the line, that nothing after an = is shown, that a part is kept at 40 characters and cut at 41, and that log_text stays the constant.
  • test/test_name_grant_windows.py::test_the_refusal_names_the_windows_part does the same for the five PowerShell-only give-ups, and test_a_scriptblock_assignment_value_is_never_shown checks that {$p="s3cret"} shows only {$p=.
  • test_the_ci_blocking_case_no_longer_auto_approves now expects the walk to raise.

Manual verification

Ran name_grant_refusal on the five commands in the table above, shaped like the most common declines in a real audit log; each detail is exactly the suffix shown. The chat runner already shows Refusal.detail as-is, so no surface code changes.

Related Issues

no linked issue: a small diagnostic change that no issue tracks.

Pattern harvest

Not generalizable: every other refusal code already carries a specific detail; this was the one give-up path that dropped its reason.

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

@eladrkatz
eladrkatz requested a review from a team as a code owner October 2, 2026 06:47
@eladrkatz
eladrkatz requested a review from buluoray October 2, 2026 06:47
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed 6140ee95a1a9de90f62911e28e27c6a52c6fcb29 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 6140ee9

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of 6140ee95a1a9de90f62911e28e27c6a52c6fcb29 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 6140ee9

Description read

[DESCRIPTION-READ] a803a340c44ad4b5e964abe0997e00bf0bd7097e4c13a70870442f6ffff19926

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

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of 6140ee95a1a9de90f62911e28e27c6a52c6fcb29 via the fork AI-review pipeline — 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

Verify _SHLEX_REASONS keys ("No closing quotation", "No escaped character") match shlex's messages on every supported CPython; a drift silently degrades to the generic reason.

What this change ships

Inventory (6 items) — 6 justified

Intent: FIX — the untokenizable auto-approve decline notice names the part of the command the check gave up on, instead of a bare constant. Verified on base: name_grant.py:2223 ships a constant detail while every sibling refusal's detail names its subject (grepped return Refusal( — 18 sites, all others carry {name}/{found}/{construct!r}); this was the one give-up path with no fact to act on.

  1. The decline notice ends with the shell part the walk could not model — justified
  2. A multi-line command's notice names the offending line number — justified
  3. Nothing after = is shown and a part is cut at 40 characters — justified
  4. PowerShell give-ups name their part too (same walk, same mechanism) — justified
  5. Two shlex failures get human reasons, with a generic fallback — justified
  6. Private _program_names_line raises instead of returning None; program_names keeps its contract for its one other consumer (pin_human_approval, name_grant.py:2180) — justified

Detail flows display-only through _redact_display_text (chat_runner.py:15628); audit and logs keep the constant log_text, pinned by the added tests.

[FIRST-PRINCIPLES-REVIEWED] 6140ee9

Description read

[DESCRIPTION-READ] b029518b530336cd09a7021ca82984e667630ee5fef7d5d7a36910b952c79c37

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

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed 6140ee95a1a9de90f62911e28e27c6a52c6fcb29 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6140ee9

The 'could not be reduced to a known set of program names' notice gave no clue which part of the command tripped it. The walk now raises with the part it gave up on (a shell keyword, an unclosed quote, a trailing backslash, an operator, an execution-affecting assignment, or a PowerShell expression form), plus the line number for a multi-line command, and the refusal detail carries it. The refusal code, log text and the set of refused commands are unchanged; assignment values are never shown.
@eladrkatz
eladrkatz force-pushed the fix/name-grant-decline-reason branch from 7903984 to 6140ee9 Compare October 2, 2026 07:17
@eladrkatz

Copy link
Copy Markdown
Contributor Author

Rebased: main moved since this head went red (cfb4284 -> 5a70ce7). CI re-running.

The four test failures on 7903984 touched no file in this PR:

  • test_context_composition_contract.py::TestSurface::test_builder_members_keep_their_kind_and_signature and test_app_script_cron_sibling_import.py::TestACommandCronRunningBundleCode::test_the_call_site_leaves_the_bundle_readable (Windows) were red on main and are fixed by test: fix two Windows-red tests and write down why #16083, now in the base.
  • test_issue_radar_crew_runtime.py::TestSweep::test_review_verdict_is_read_when_the_pr_moved (Windows) and test_subagent_reap_attribution.py::test_a_deadline_reap_names_the_deadline_not_the_death look flaky; the new head re-runs them.

@eladrkatz

Copy link
Copy Markdown
Contributor Author
  • fixed: the two shlex reason strings misstated shell grammar

fixed in 6140ee9: the reasons now name this check's limit, not a shell rule.
"an unclosed quote; this check tokenizes one line at a time"
"a trailing backslash; this check does not follow a line continuation"
Refusal code UNTOKENIZABLE and the constant log_text are unchanged; test/test_name_grant.py pins both new strings.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Oct 2, 2026
@eladrkatz

Copy link
Copy Markdown
Contributor Author

All review lanes pass on 6140ee9 (GPT, Opus, Design, First Principles, UX, Security Scope). The only reds are two Windows test shards, and neither touches this PR's files (src/kiro_crew/name_grant.py, test/test_name_grant*.py):

  • Backend Tests (Windows) (5): test/test_slot_close_recreation_race.py::test_delete_handover_of_a_restricted_tail_tightens_a_persistent_line[incognito] - "the persistent replacement was not summarizable before the drain"
  • Backend Tests (Windows) (7): test/test_messaging_privacy_mode.py::TestReservations::test_a_release_whose_clear_cannot_reach_disk_retains_the_mode - "a restart did not hydrate the retained mode"

Both shards passed these tests on the previous head (7903984) with the same name_grant change, so they look flaky. As a fork author I can't re-run jobs. Could a maintainer re-run just the failed jobs of run 36977830283? Thanks!

@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 2, 2026
@bolichen97
bolichen97 merged commit 23a040e into kirodotdev:main Oct 4, 2026
144 of 146 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants