Skip to content

refactor(apps): unchain the no-manifest approved-grants ternary - #18391

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

iamwhatever merged 1 commit into
mainfrom
refactor/simplify-apps

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the approved-grants choice for a manifest-less app self-registration read as three plain cases, with no change to which grants an app gets.

When an app registers itself without sending a manifest, register_external_app in src/kiro_crew/apps/manager.py picks its approved api/events set with a conditional expression nested inside another one, and the inner one also binds on_disk with a walrus. Three cases are packed into one expression, and the reader has to unwind it to see which one runs.

Why it matters

Nothing is broken today. This block feeds the approved-grants file that token_auth and ws_event_scope enforce. A reader checking that gate should see its cases at a glance, not have to work out how a nested expression evaluates.

Not a goal

  • Changing which grants are approved, held back, written or rolled back on any path.
  • Reusing prior_grants for the second _read_approved_grants(name) call. That would save one disk read, but it changes how many times the file is read, so it is not a pure rewrite.
  • Any other site in apps/, or any other module.

What changed (motivation → approach → change)

No app gains or loses a grant. In register_external_app (src/kiro_crew/apps/manager.py), the nested conditional expression that picks the approved api/events set for a self-registration without a manifest becomes an if / elif / else, with the same three cases in the same order:

Case Approved set
the app has an install record its stored set, read from disk and left untouched
no install record, and a readable manifest is on disk what that manifest declares
no install record and no readable manifest none, so no approved-grants file is written

Each case makes the same calls and returns the same value as before. on_disk is still bound only when there is no install record, and nothing else reads it. The approved_grants annotation still comes before every assignment, so mypy's inference does not change.

Backwards compatibility

Compatible: every case gives the same value, from the same calls, in the same order, so every caller sees exactly what it did before.

Removes nothing: the change only restructures one expression. No name, path, key or record goes away, and take_away_check.py reports no take-away shape.

Tests

No new tests: behaviour does not change, so there is nothing new to pin.

  • Equivalence check. I ran both forms against stub callables for every combination of existing (None, falsy, truthy, a plain object) and get_app_manifest (returns None, returns a falsy manifest, returns a truthy manifest, raises). The result, any exception, the full call order and whether on_disk was bound matched in every case.
  • Static gates (Python 3.12, on base d4c3a7334d). All exit 0: flake8, isort, mypy, check_black_formatting.py, check_subprocess_encoding.py, check_comment_history.py, check_brand_name.py, check_harness_parity.py, check_feature_map.py, docs_lint.py --test, docs-lint.sh, check_per_file_coverage.py --test, verify_vendor_manifest.py and the rest of the profile's backend gate floor. semgrep is not installed on this host, so CI's SAST job is the only run of semgrep/.
  • Tests. On base d4c3a7334d, the 11 test files that call register_external_app and the four test files whose host-memory pin main added beside the test/conftest.py change (test_chat_send_agent_model_default.py, test_crew_log_previous_latch.py, test_cron_reaper.py, test_cron_resilience.py) pass: 1548 passed, 7 skipped. No commit on main since 0c20641d03 touches apps/. The related-test runner selected 482 files, on the 0c20641d03 base: 40621 passed, 118 skipped, 5 failed. None of the 5 imports apps/, and each one fails the same way on pristine origin/main on this host:
    • test_cli.py::TestDoctorStt (the boto3-missing and amazon-transcribe-missing tests): pip_install_channel_available() is not stubbed, and this host's venv has no pip module, so the Install: line never prints.
    • test_service.py::TestAppArmorNeverFailsTheInstall (two tests): the linger probe is not stubbed, and linger is off for this account, so a ⚠️ warning prints.
    • test_cli_doctor.py::TestDoctorAgentAuth::test_a_stored_but_unusable_vault_identity_is_still_reported: this passes alone. It fails when test_cli.py::TestDoctorStt::test_doctor_stt_transcribe_provider runs first on the same worker, which rebinds kiro_crew.auth. That two-test sequence fails the same way on 0c20641d03.
  • Not run locally. scripts/scrub-lint.sh is not in the checkout; that scan runs as CI's internal-content-scan job. The diff touches nothing under website/, .github/ or scripts/, so CI reports only_backend=true.

Pre-PR review: seven read-only reviewers looked at this before it opened. Their lenses were AUTOSDE blocking rules plus the code-review.yml greps, behaviour preservation, import and binding semantics, the security keystone and boot path, comment accuracy, and local mirrors of the GPT and Claude CI lane contracts. None found a code defect.

  • The behaviour reviewer compared the base and head ASTs: the only statement that differs is this block.
  • The security reviewer traced every consumer of approved_grants. On the no-manifest path, only the first-registration write reads it, so the fail-closed None-versus-{} meaning is unchanged.
  • The comment reviewer found that my commit message overclaimed in two places, and an independent verifier confirmed both. "There is no set" became "no set is written", because an absent approved-grants file is not "nothing approved". "Keeps the stored set" became "leaves its stored set untouched", because that case only reads the set. The verifier also pointed out that "first registration" in this code means no readable install record, and that "no manifest" includes an unreadable one, so the message and the table use those terms.
  • Not acted on: the security reviewer suggested holding the grant helpers in this file to the keystone rule. That changes the campaign's keystone scope, which is outside this goal. This diff already meets that rule's bar, because the rewrite is provably equivalent and still explicit.

Manual verification

N/A — unit coverage sufficient: the rewrite gives the same value from the same calls for every input, and the tests that register apps pass.

Screenshots / video

Why no screenshot: backend-only rewrite of one Python expression; 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 October 9, 2026 08:15
@bolichen97
bolichen97 requested a review from CrysisDeu October 9, 2026 08:16
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 4ec2901c63cb0fc51823376947aba03c66088d3b 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 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 4ec2901c63cb0fc51823376947aba03c66088d3b — 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 (1 items) — 1 justified

Intent: make the approved-grants choice for a manifest-less app self-registration readable as three plain cases, without changing any grant outcome. This is neither a FIX nor an ADDITION: it is a pure refactor.

  1. In register_external_app, the nested conditional expression that picks the approved grants for a registration without a manifest becomes if/elif/else. The cases, calls and order are unchanged. — justified

[FIRST-PRINCIPLES-REVIEWED] 4ec2901

Description read

[DESCRIPTION-READ] 4bcd5fd6858c7e5a491adfcaa81f19d7ee010695a9643995343cdbf6c545ee6a

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 4ec2901

Description read

[DESCRIPTION-READ] 4891eecdb47a0c83e94979602bc1de45cb750550f2cdab4b274704501cf9736b

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 4ec2901

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

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

@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4ec2901

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 4ec2901c63cb0fc51823376947aba03c66088d3b: <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 9, 2026
@bolichen97
bolichen97 force-pushed the refactor/simplify-apps branch from cf0ad2a to e7bd934 Compare October 9, 2026 12:35
@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 labels Oct 9, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/agent.py since this head went green (7044e75 -> 33b67ac); CI re-running.

The overlap is import-graph only: agent.py imports kiro_crew.apps.manager, and main's change to it is prompt text. git range-diff shows the patch byte-identical (cf0ad2a122 = e7bd9345f3). On the new base the static gate floor and the 13 targeted test files (the 11 that call register_external_app plus the two agent.py test files main changed) pass: 1388 passed, 7 skipped.

@bolichen97

Copy link
Copy Markdown
Contributor Author

The red E2E (stub ACP backend, offline) on e7bd934 is main's, not this diff's: it is the known flake #17941 (session-tags-e2e.spec.ts:783, spec 17b passes only on a retry, so the MAX_FLAKY_SPECS=0 ceiling fails the job).

No further rerun and no override: the PR waits for the #17941 fix, then rebases onto it.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Answering the First Principles check note on e7bd934 ("the elif walrus still binds on_disk only when there is no install record"): it does.

  • Before: on_disk := get_app_manifest(name) sat in the else arm of ... if existing else (...), so it ran only when existing was falsy.
  • After: it sits in the elif of if existing:, so it runs under exactly the same falsy test, and get_app_manifest is still called at most once.
  • on_disk appears only on manager.py:3011-3012 in the whole file, so no later line in register_external_app reads it either way.

@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 9, 2026
register_external_app picked the approved api/events set for a
registration that supplies no manifest with a conditional expression
nested inside another, the inner one binding on_disk with a walrus.
Spell the same three cases as an if/elif/else: an app with an install
record leaves its stored set untouched, one without approves what its
on-disk manifest declares, and with no readable manifest either no set
is written. Same branch order, same calls, same on_disk binding.
@bolichen97
bolichen97 force-pushed the refactor/simplify-apps branch from e7bd934 to 4ec2901 Compare October 9, 2026 17:34
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/conftest.py since this head went green (33b67ac -> d4c3a73); CI re-running.

The overlap is import-graph only: main's change pins host free memory in test/conftest.py and four test files, plus a CHANGELOG.md date; none of it touches apps/. git range-diff shows the patch byte-identical (e7bd9345f3 = 4ec2901c63). On the new base the static gate floor passes, and the 11 test files that call register_external_app plus the four test files main changed pass: 1548 passed, 7 skipped.

The E2E red on the previous head stays attributed to #17941; its fix (#18529) has not merged yet.

@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: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 9, 2026

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

This rewrites one nested conditional expression in register_external_app (src/kiro_crew/apps/manager.py ~L3008) as if/elif/else, and it is a pure refactor with nothing to fix at a root cause. I read the 6/-9 diff and checked equivalence by hand: the install-record case still reads the stored set, the walrus that binds on_disk still runs only when there is no install record, and the no-manifest case still yields None, so no approved-grants file is written. Every check is green, all AI lanes PASS with no findings, base is main and there are no reviews or change requests. It is a behaviour-identical refactor of one expression, so it changes no permission outcome, and I am approving it. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 9, 2026 18:22
@iamwhatever
iamwhatever merged commit 398f28d into main Oct 9, 2026
102 checks passed
@iamwhatever
iamwhatever deleted the refactor/simplify-apps branch October 9, 2026 18:23
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 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