Skip to content

feat(apps): declare code-review-sage's pull-request read and writes - #36343

Merged
bolichen97 merged 1 commit into
mainfrom
feat/w5-perm-parity-sage
Nov 13, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
feat/w5-perm-parity-sage

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Code Review Sage can move to its own repository without losing the pull-request view and the publish bar its built-in page has, because the grant those need is already approved for every existing user.

Code Review Sage's built-in page reads a pull request and acts on it through the dashboard's /api/source/pull-request family: the SDK PullRequestPanel's read, checks, status, ready, auto-merge, reply, comment, resolve and unresolve, and the publish bar's pending-review and submit-review (website/src/apps/code-review-sage/components/PrSourcePanel.tsx, DraftReviewActions.tsx, PrReviewDetail.tsx). The compiled built-in reaches them as dashboard code. The app repository's bundle could reach them only through the scoped client, which refuses an undeclared path, and declaring the path there was a widening adoption refuses (E9), so that copy dropped the pull-request tab and the publish bar (its PORTING.md gaps 2 and 3).

Owner ruling on #26967, comment 6841699202 (2026-11-13): decide directly, users' normal use must not be affected, grant what is needed. Its decision 1 names code-review-sage /api/source/pull-request (the read and write calls it already makes), declared in the wheel copy first so adoption is not a widening.

Why it matters

Without this the repository copy either keeps a reduced page (no pull-request view, publishing moved to GitHub) or adds the grant later as a widening every user would be asked to approve again; the built-in's users would see a regression either way.

Not a goal

  • Porting the pull-request tab and the publish bar into the repository copy's page (app repository work, now unblocked).
  • The follow-up chat slot (/api/chat/slots, the repository copy's gap 1), which the ruling routes to a generic chat-slot seam.
  • Adding the adoption pin for Code Review Sage.
  • Design Tweak's and Dev Fleet's declarations, which get their own PRs.

What changed (motivation → approach → change)

  • apps/builtins/code_review_sage/app.json adds /api/source/pull-request. One bare entry is the narrowest the matcher allows for the family: every endpoint the panel and the publish bar call is a child of the read, which is also what the SDK panel checks before it builds a client. It also covers status/refresh, a read of the same cached statuses, and nothing else is registered below it. The handlers refuse an app token (source_providers._authorize_owner_request), so the app's backend token gains no reach; the page's requests carry the owner's session, as every scoped request does.
  • A built-in approves what its wheel copy ships at every start (register_builtin_apps), so the release carrying this grants the entry to every existing record before any pin, and the repository copy's identical list adopts with permission_refusal(...) == None.
  • Spec: app-kit-platform.md § 18g records the declaration and why it is the one entry.

The trust prompt lists this entry once #36342 (the generic host-path box) lands; no merge order is required.

App repo: KiroCrewCaptain/kirocrew-app-code-review-sage@12e0f75 (declares the same list in app.json, records it in the built-in fixture its parity test compares, and rewrites gaps 2 and 3 in PORTING.md as page work that the grant now allows).

Backwards compatibility

Compatible: the wheel manifest only adds a grant; the compiled built-in page keeps the dashboard client and never read its own permissions.api.

Removes nothing: the change adds one declaration.

Tests

  • test/test_code_review_sage_permission_parity.py: the wheel copy declares exactly its own paths plus the family; every path the built-in page calls matches; the SDK panel's endpoint table (read from PullRequestPanel.tsx) is inside that list; a registered built-in's approved set is the wheel's; permission_refusal is None for the repository's list and permission_widening with one more path (/api/source/issues); the app token matches the family and is refused at /api/source/pull-requestx, /api/source/issue, /api/source/issues, /api/chat, /api/apps. Five of the seven fail with the manifest change reverted (checked locally).
  • Run: the new file, the code_review_sage package tests, test_builtin_discovery, test_builtin_app_optional_enable, and every test/*.py naming the app (2,337 passed).

Proof: not provable -- other: a feat PR; the manifest hunk was reverted by hand and 5 of the 7 new tests went red

Determinism: the new tests read files and in-memory state only.

Real repository manifest, against this branch with the built-in registered in a scratch data home:

code-review-sage wheel api: ['/api/apps/code-review-sage', '/api/apps/code-review-sage/*', '/api/source/pull-request']
code-review-sage repo  api: ['/api/apps/code-review-sage', '/api/apps/code-review-sage/*', '/api/source/pull-request']
code-review-sage permission_refusal -> None
code-review-sage with /api/sessions added -> permission_widening

Manual verification

N/A: a manifest declaration with no rendered change; the parity tests register the real wheel copy.

Related Issues

Part of #26967

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 November 13, 2026 03:03
@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 03:05
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-code-review-sage that referenced this pull request Nov 13, 2026
kirodotdev/KiroCrew#36343 declares /api/source/pull-request in the
built-in's manifest, so this copy declares the same list and adoption is
no widening. The fixture records the built-in's new list, and PORTING.md
turns gaps 2 and 3 into the page work the grant now allows.

Co-authored-by: Bolin Chen <bolichen@amazon.com>
@KiroCrewCaptain

KiroCrewCaptain commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

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

This PR adds one bare /api/source/pull-request entry to the permissions.api list in Code Review Sage's wheel manifest. I checked the PR's claims against the code and they hold:

  • Matcher scope. _api_pattern_matches treats a bare entry as "this path or anything below it, split on /". So the entry covers the 12 POST routes registered in routes/chat.py (the read plus 11 children, including status/refresh). It does not match /api/source/pull-requestx or the other /api/source/* paths.
  • Owner gate. Every handler calls _authorize_owner_request or _owner_mutation_response. This includes pending-review, whose docstring doesn't say "Owner-only" but which is gated anyway. Both branches of the gate refuse an app token (request["app"] != ""), so the app's own backend token gains no reach.
  • Precedent. auto_improvement/app.json already declares the same entry.
  • AGENTS.md rules. The no-new-built-ins rule explicitly allows fixing a shipping built-in in place until it moves out, and this app has no adoption pin yet.

The new parity test pins:

  • the declared list;
  • that the page's calls are covered, including a parse of the SDK PULL_REQUEST_PANEL_PATHS

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 31a1b60130 · 147 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 13, 2026
@bolichen97
bolichen97 force-pushed the feat/w5-perm-parity-sage branch from 1b624dd to 6b6f35e Compare November 13, 2026 04:40
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto 510ba1b6b8 to pick up the red-main fix #36290: the previous head 1b624dd0e4 failed Backend Tests (3.12, 8) / (Windows) (8) on test/test_reply_format_once.py::TestEveryMessageWhereTheBlockCannotBeTakenOut::test_the_table_names_every_selectable_harness (the mimocode row missing from COMPACTION_SEEN), which that fix adds; Coverage Gate was its downstream red. The design / first-principles / UX / GPT / Opus / license / CodeQL-actions reds on the old head were the shared installation token rate limit, not verdicts. PR diff is byte-identical to the previous head; CI re-running on 6b6f35ebd6.

@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 Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 31a1b60130c00fffed7e36d80196551631d47bb1 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 13, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: this adds one manifest grant for calls the built-in page already makes. It takes nothing away, and the owner gate on the handlers still refuses the app's own backend token.

Notes

  • The grant gives the adopted bundle's page code, not the app token, the right to write to pull requests (reply, resolve, submit-review) on the owner's session. That reach comes from the owner ruling, not from _authorize_owner_request. The spec's "gains no reach" wording covers only the app token, so § 18g should state the page-side reach plainly.

[DESIGN-REVIEWED] 31a1b60

Description read

[DESCRIPTION-READ] ec9689a2c3e5c5348ea6d8eef6074b47807ce25a8c8da9c1a82bf4e9552eb42f

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 31a1b60130c00fffed7e36d80196551631d47bb1 — 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. The one manifest entry follows the recorded owner ruling on #26967 and uses the existing declaration form (auto_improvement/app.json:58 declares the same path). The spec paragraph and the tests go with it.

What this change ships

Inventory (4 items) — 4 justified

Intent: let Code Review Sage move to its own repository and keep its pull-request view and publish bar, without existing users having to re-approve a wider grant. This is an ADDITION.

  1. Code Review Sage's shipped manifest now declares the /api/source/pull-request family, and every existing install approves it at start. — justified
  2. The same entry also reaches status/refresh, a read of the same cached statuses. — justified
  3. Spec § 18g records the declaration and why one entry is enough. — justified
  4. A new parity test pins the declared list, the paths the page calls, and adoption without widening. — justified

[FIRST-PRINCIPLES-REVIEWED] 31a1b60

Description read

[DESCRIPTION-READ] e89c1ec017ced620d5a167aebbc295340dcd31e48b526594b621619e72f74376

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 31a1b60130c00fffed7e36d80196551631d47bb1 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 31a1b60

Verdict parsed from the review's SHA-scoped output markers for commit 31a1b60130c00fffed7e36d80196551631d47bb1.

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 31a1b60130c00fffed7e36d80196551631d47bb1 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 31a1b60

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

@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 13, 2026
@bolichen97
bolichen97 force-pushed the feat/w5-perm-parity-sage branch from 6b6f35e to 460980f Compare November 13, 2026 05:50
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/cli.md since this head went green (510ba1b -> ff344c7); 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 readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97
bolichen97 force-pushed the feat/w5-perm-parity-sage branch from 460980f to 4a8844a Compare November 13, 2026 07:32
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/app-kit-platform.md, src/kiro_crew/apps/manifest.py and 13 sibling spec files since this head went green (ff344c7 -> 72b62cf); CI re-running.

@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 Nov 13, 2026
Owner ruling on #26967 (comment 6841699202): an app gets what its
built-in already uses, declared in the wheel copy first so adoption is
not a widening.

Code Review Sage's built-in page reads a pull request and acts on it
through the /api/source/pull-request family: the SDK PullRequestPanel's
read, checks, status, ready, auto-merge, reply, comment, resolve and
unresolve, and the publish bar's pending-review and submit-review. An
adopted bundle reaches them only through the scoped client, which
refuses an undeclared path. The wheel copy now declares the one bare
entry that covers them, which a built-in approves at every start, so
the repository copy's identical list adopts with permission_refusal
None. The handlers refuse an app token, so the backend gains no reach.
@bolichen97
bolichen97 force-pushed the feat/w5-perm-parity-sage branch from 4a8844a to 31a1b60 Compare November 13, 2026 07:54
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto 48dee00442 to pick up the red-main fix #36457: Backend Lint & Type Check (3.12) on 4a8844a123 failed mypy at src/kiro_crew/cli_commands_memory.py:335, a file this PR does not touch, so the test shards never started and Coverage Gate failed closed. PR diff is byte-identical; CI re-running on 31a1b60130.

@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 Nov 13, 2026
@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 Nov 13, 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 approved this PR on head 31a1b60. The diff adds one entry, /api/source/pull-request, to the permissions.api list in Code Review Sage's app.json. It also adds a § 18g spec paragraph and a new 7-test parity file. I checked that dashboard/routes/chat.py:88-99 registers exactly 12 routes under that prefix and nothing else. The matcher stops at a slash boundary, so /api/source/pull-requestx is not admitted. Every one of those handlers goes through _authorize_owner_request or _owner_mutation_response. PR Readiness is green on this head.

Security: the scope layer now lets this app's token reach the pull-request family, but every handler in that family still refuses a request that carries an app claim (app_token_not_allowed). So the app's backend token gains no reach. The real new reach is the adopted page's calls on the owner's own session. That follows the owner ruling recorded on #26967, and the spec paragraph states it.

Done well: the parity test reads PULL_REQUEST_PANEL_PATHS from the SDK source instead of copying it. It runs the real register_builtin_apps and permission_refusal, and it pins both sides: the identical list adopts, and one extra host path is still refused as a widening.

Optional:

  • test/test_code_review_sage_permission_parity.py:40 says PAGE_CALLS is every host path the page calls. ReviewChat.tsx:155 also posts to /api/chat/slots, which the body scopes out. You could narrow the comment to the pull-request family, or note that /api/chat/slots is left undeclared on purpose so the /api/chat deny reads as intended.
  • App-token refusal is pinned for read, checks, resolve, reply, comment, unresolve and auto-merge. It is not pinned for submit-review, pending-review, ready, status or status/refresh. One parametrized 403 test over PAGE_CALLS would tie the "no reach" claim to every endpoint this grant opens.
  • The _shipped, registered and _repository_manifest helpers are also copied in #36342 and #36344. A shared helper, or deleting each copy when its app leaves core, would keep that in one place.

@bolichen97
bolichen97 merged commit 65dd048 into main Nov 13, 2026
189 of 198 checks passed
@bolichen97
bolichen97 deleted the feat/w5-perm-parity-sage branch November 13, 2026 11:04
KiroCrewCaptain added a commit to KiroCrewCaptain/kirocrew-app-code-review-sage that referenced this pull request Nov 15, 2026
…9.4 (#4)

* feat: bring back the pull-request tab and the publish bar

The built-in's detail pane has a "Pull request" tab (the dashboard's
PullRequestPanel: description, checks, review threads, the file diff,
commits), header chips drawn from the same payload, and a publish bar
that releases the draft review as Submit as comment, Request changes or
Approve. This copy had dropped all three because the endpoints were
outside its grant. kirodotdev/KiroCrew#36343 declares
/api/source/pull-request in the built-in's own manifest under the owner
ruling on kirodotdev/KiroCrew#26967, and this app.json declares the same
list, so they come back unchanged:

- the tab renders the App SDK's PullRequestPanel
  (kirodotdev/KiroCrew#32665, seam level 2), feature-detected in
  hostSdk.ts; on a host without it the pane shows the review alone, as
  before;
- the payload, the pending review and the submit go through the host's
  scoped client (sourceApi in api.ts) with the dashboard client's
  bodies; every path is the declared entry or a child of it;
- the publish bar is the built-in's, with every guard it had (delivery
  evidence, superseded draft, redacted content, stale head, Approve
  withheld under auto-merge or kept stale approvals) and the two-click
  confirm bound to the content digest.

The built-in's tests for the bar, the payload and the tab are ported
over sourceApi; a stand-in for the SDK panel pins that it gets the one
pull request and shares the payload's query entry. PORTING.md marks gaps
2 and 3 closed; gap 1 (opening a new follow-up chat) remains.

Part of kirodotdev/KiroCrew#26967.

* chore: release 0.9.4

Bump the version once for the release that carries the wheel fixes
(#3) and the pull-request tab and publish bar, so Kiro Crew can pin
this commit: a first-adoption pin's version equals the wheel
built-in's, which the pin release moves to 0.9.4. The built-in
manifest fixture is the current wheel manifest at that version.

The README shows the new Pull request tab, captured with capture.py on
an isolated Kiro Crew main gateway running this repository's copy. The
capture's gh stand-in now answers the dashboard's own pull-request read
(the pr view fields and the two GraphQL reads), and KIROCREW_GH_BIN
points that read at it.

Part of kirodotdev/KiroCrew#26967.

* fix: ship .kiro so adoption can replace a reviewed install's folder

A built-in Code Review Sage that ran a review has .kiro/settings/cli.json
in its record's folder: the review worker's Kiro CLI workspace settings,
which the review pool writes into the worker's working directory, the
app's folder. Kiro Crew's adoption refuses to swap a record whose folder
holds an entry beside app.json that nothing rebuilds and the pinned tree
does not ship, so every user who had ever run a review would have
stayed on the built-in ("Adoption of code-review-sage skipped: the swap
would delete .kiro beside app.json"), as the adoption smoke showed.

The tree now ships .kiro/ (a README saying what is written there), so
the swap replaces the folder as an update does, and the next review
writes the settings again. .kiro/settings/ is ignored so a dev clone
never commits them. tests/test_adoptable_root.py runs Kiro Crew's own
check against a record a review left behind: it passes with this tree
and fails without the folder.

Part of kirodotdev/KiroCrew#26967.

---------

Co-authored-by: Bolin Chen <bolichen@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants