Repository navigation
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
716d7d5 to
b824cff
Compare
|
🤖 Kiro Crew [operator: bolichen97#66809557]: This PR has been inactive with a blocked CI state. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: The branch is behind If you'd prefer I don't touch this PR, add the |
b824cff to
6adfb57
Compare
|
🤖 Kiro Crew [operator: bolichen97#66809557] Rebased this PR onto current main (was CONFLICTING) and pushed Conflict resolution — main's structure + this PR's consolidation, guard semantics untouched:
Rebase-integration fixes:
Local gates: isort / flake8 / black-baseline clean; mypy clean on the touched files; 1090 targeted tests pass (all 24 test files this PR touches + the stale-signal and error-code contract suites). Single commit preserved (original authorship kept, Kiro Crew co-author trailer added). |
6adfb57 to
608d606
Compare
|
I re-read the complete current 26-file diff after the head changed from Already merged coverage:
Keep the distinct residual: owner gates for the remaining MCP/custom/discovery/gateway/config mutations (including probe/measure/quarantine/sync/toggle/remove/apply, custom add/update, discovery install, gateway enable/stub/resolve refresh, and config/theme writes), plus the route-walk and route-specific authorization tests. Dropping the already-merged helper and agent-spec portions will make the security delta reviewable without losing those uncovered routes. |
Audit note — part of this has already landed; the rest has notThis PR is not a duplicate and is not finished by anything on Already landedOnly ONE claimed reference really landed and touches this work: #6245 -- the issue/PR reference check row Which parts
|
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
|
Rebased onto main Conflict resolutions:
Rebase follow-ups: Gates run locally on changed files: black (8 files remain in Please review the resolutions. A maintainer push makes the maintainer the last pusher, so a second approver is needed under the repo's last-push rule. Reply if anything looks wrong. Note, not changed here: main's |
|
Rebased onto current Conflict resolvedOne conflict, in snapshot = _not_ready_snapshot(
bool(service.initial_setup_complete),
probe_error=f"{type(exc).__name__}: {exc}"[:400],
)
if is_owner_dashboard_request(request):That is,
Verification run before the push
One thing for a follow-up, not fixed hereAfter the rebase
|
The 10 red backend shards are this PR, and four of them need an owner-gate decisionShards 1, 3, 4, 5, 7 fail on both 3.12 and Windows — the same five file-shards on each platform, which is what a stable path-hash shard assignment ( Four distinct causes. 1. The
|
Shard reds cleared, one left for a product rulingHead Fixed — the 10 red backend shards came from three consequences of one change, not ten defects:
Verified locally: 4475 passed across the 61 test files that reference the owner predicate. Still red, deliberately: a product decision
Its docstring pins "stopping spend is never gated". This PR's blanket owner gate on
|
The shard-4 red is not from this PR
Failing test What differs. The test AST-scans The four handlers still exist and still refuse a switch mid-turn. Only the attribution moved: their inline Introducing commit. The enumeration test itself is newer than that refactor ( Reproduced on pristine main, no PR merge ref, at Tracking / fix. Already filed and already being fixed — nothing is needed from this PR:
I applied 12718 and 12715 to a pristine main worktree in turn; each takes the file to Please ignore the shard-4 / Coverage Gate red here. It clears on this PR once a fix lands on main and the branch is rebased. No push to this PR is required. |
Ruling: the spend-off carve-out stays
Why. What changed. A bodyless or unparseable request names no direction, so it is not the carve-out and No new helper, flag, or config knob: the gated half calls this PR's own shared Scope note for a reviewer. The carve-out is drawn at the billed field only. The Verification. 1286 passed across the 21 test files this PR touches plus A maintainer can reverse this ruling — it defaults to the documented design, it is not |
|
Your shard-1 red is not from this PR. It landed in #12731 asserting the three diag routes answer Fix is up at #12865 (test-only, +47/-6). No action needed here — once it merges, |
|
Rebased onto No code change. Shape is identical: 28 files, +522/-97, 2 commits, no deletions, both authors preserved. The one conflict was |
On the fenced GPT finding at
|
The lane is right and the claim was stale. Checked each site on
So "remain outside this boundary" was true when it was written and is not true now. Description-only; no code change on this head. |
Accurate finding. The parse has to come first there, and only there: Description now scopes the ordering claim to exclude Description-only; no code change on this head. |
Confirmed, with the file list. Deferred rather than done on this head, for the reason the earlier rounds deferred the Added to #6224 alongside the other test-side consolidations. The duplication is inert — all |
Agreed with the lane's own reading — harm-free, and kept deliberately. Base answered the kiro-prerequisite denials as a plain 403 with no machine-readable code. This The user-visible text is unchanged, which is load-bearing: No change made; recorded as an accepted consequence of the consolidation. |
Rebased onto
|
| File | Resolution |
|---|---|
handlers/mcp.py |
kept main — it now gates all 13 mutating routes (mcp_probe, measure, quarantine_clear, sync, toggle, toggle_tool, toggle_all, remove, server_detail, apply, mcp_gateway.enable/set_stub/resolve_refresh). Byte-identical to main. |
handlers/mcp_custom.py |
kept main — custom_add / custom_update already gated. Byte-identical to main. |
test_gateway_appkit_endpoints.py |
kept main — its own owner-claims fixture for the registration transport. |
test_handlers_mcp_coverage.py |
kept main — owner_claims(req) helper replaces this PR's inline claims dict. |
test_mcp_apply.py |
kept main — same helper. |
test_mcp_custom_api.py |
kept main — same helper. |
test_mcp_gateway_control_plane.py |
kept main — same helper. |
test_mcp_mutation_identifiers.py |
kept main — NoConfiguredOwner() state stand-in. |
test_mcp_quarantine.py |
kept main — as_owner(app) wrapper. |
Newly gated routes: none. test_mcp_config_endpoints_owner_auth.py walks the real agent_config registrar and asserts the found set equals its 20-entry expectation; it passes unchanged, so main registered no new mutating route in core.py / mcp.py / mcp_custom.py / mcp_discover.py since this branch was cut. What remains genuinely ungated on main, and is what this PR now carries: POST /api/mcp/discover/install, PUT/PATCH /api/config/kirocrew, PUT /api/config/theme, plus issue #5014's task 2 (converging _dashboard_owner_only onto the shared helper).
Retrospective on the usage_text_scrape_enabled carve-out
The asymmetry is deliberate and load-bearing: 10a8953f8a introduced it with the reasoning "the enable goes through the shared owner gate while the disable stays open to anyone: someone who can see spend must always be able to stop it", docs/feature-map/README.md records the field as "owner-only to enable", and test_a_non_owner_may_still_switch_the_billing_off pins the open disable. The carve-out stays, and the route gate keeps its early position: moving it below the per-field branch would be ~4 lines smaller but would run allowlist validation and the shutil.which PATH probe for dashboard.terminal.shell on a non-owner's input before the 403.
Two review findings from this revision, both applied
- First Principles —
require_owner_dashboard_requestgainederror=/resources=kwargs that onlykiro_prerequisite.pypassed, all three sites identically, to reproduce its own pre-convergence wording. Both kwargs are gone;_shared.pyis now byte-identical tomain, the three call sites are plain, andKiroPrerequisiteGate.test.tsxmodels the message the backend actually sends. - Design Review — the per-field enable gate sat behind the route gate and could no longer fire, while its comment still documented the pre-gate "any authenticated caller" bar. That branch is removed and the rationale now lives on the gate that enforces it, so there is one authorization record for this field instead of two that can drift.
Verification
--diff-filter=D empty · exactly one def is_owner_dashboard_request under src/ (source_providers.py:6600) · merge-base symbol diff loses only _dashboard_owner_only and _audit · test_usage_scrape_editable.py byte-identical to main · error-code ratchet regenerated and moves DOWN (missing_code 1115 → 1114, kiro_prerequisite.py drops out) · isort / flake8 / mypy / black-baseline / comment-history clean · 1257 backend tests and the 57 KiroPrerequisiteGate frontend tests pass.
The remaining red lanes on this head are GitHub App installation rate-limit casualties, not verdicts — each failing check-run says "could not run", and the underlying jobs die on API rate limit exceeded for installation while resolving the PR. They need a re-roll once the installation window resets.
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS Non-owner dashboard sessions now lose theme/language/onboarding writes silently — picks appear to work, revert on reload, and first-run replays every session. Watch
Suggestions
[UX-REVIEWED] 269ebd1 |
Rebase-integration fixes by Kiro Crew (original change by PISIT KOOLPLUKPOL): - keep main's stale_owner_session_response relabel on the shared guard's deny path (lazy import; relabel-only, never grants) - re-export is_owner_dashboard_request from source_providers for its existing importers; keep _LOCAL_DASHBOARD_OWNER_SUBJECTS from _shared - give rebase-added TestFallbackModelPatch the owner-identity app pattern - migrate the agents stale-label test to the shared guard - regenerate error-code-baseline.json (missing_code 1285 -> 1284) Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
The gate moved to _shared with its app-claim test re-spelled as a membership check. That is equivalent on a real request and not on the request stubs the suite already had, so three separate reds fell out of one change: - test_agent_sdk_backend_install (16 tests, 403 instead of 400/200): its _request() stub overrides only .get, as the predicate it was written against required, so "app" not in request answered False and every owner call was denied. The predicate reads the claim with .get again -- an absent claim answers None, which already is not "" and so already denies, without asking every caller to stub __contains__. - test_decisions_config_api and test_config_live (25 tests, 500 from KeyError: 'state'): both register the now-gated config routes on a bare web.Application, which carries no state and no owner claim. Both fixtures go through dashboard_owner_helpers.as_owner, which is what the repo already uses for this exact case. - error-code-baseline.json: dropping the codeless 403 from kiro_prerequisite took its missing_code to 0, so the ratchet was looser than the code. Regenerated with --update. Fourth red, and the only behavioural one: the blanket config.patch gate removed an asymmetry main deliberately drew at that route. test_usage_scrape_editable.py::test_a_non_owner_may_still_switch_the_ billing_off pins "stopping spend is never gated" -- main gates only `dashboard.usage_text_scrape_enabled = True`, because refusing the disable would leave someone able to SEE billed spend they cannot stop. Gating the route as a whole silently reversed that. api_kirocrew_config_patch now reads the requested direction before authorizing, and skips the route-level gate for exactly that one spend-off write. Everything else the route accepts stays owner-only, including the matching ENABLE, which main's own per-field gate further down already refuses with the same shared helper. A bodyless or unparseable request names no direction, so it is not the carve-out and is still refused before any field is validated -- which is what test_every_targeted_mutation_rejects_non_owner_before_body_parse asks for. Verified: 1286 passed across the 21 files this PR touches plus test_usage_scrape_editable.py and test_agent_sdk_backend_install.py; mypy, flake8, black and isort clean on core.py; the error-code ratchet regenerates byte-identical, so the gate change moves no count. Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
bolichen97
left a comment
There was a problem hiding this comment.
Request changes: merging this head into current main breaks 3 backend tests, and the PATCH carve-out now targets a key main deleted
Every comment in this thread was written before PR #12918 (merged 2026-09-24 07:35Z) and PR #12927 (merged 16:57Z). Both changed tests that call the routes this PR gates. The head merges into origin/main c66f95b without a textual conflict. On the merged tree, though, these tests fail, and they pass on pristine main:
test/test_usage_scrape_editable.py:77test_the_config_patch_refuses_the_keywas rewritten by PR #12918. It sends a PATCH through a bareweb.Application()withvalue: True, so the route gate atcore.py:2745-2746runs:if not (path_key == "dashboard.usage_text_scrape_enabled" and value is False): denied = await require_owner_dashboard_request(request, "config.patch")
is_owner_dashboard_requestthen readsrequest.app["state"]and raisesKeyError. The test gets a 500 instead of the 400 it expects.test/test_api_theme_config.py:205and:225were added by PR #12927. They callapi_theme_configwith a bareMagicMock(spec=web.Request). The new gate atcore.py:633answers 403 before the handler runs. One test expects 200 and the other expectsHTTPBadRequest.
This PR's CI ran against a merge ref from before those merges, and a job rerun replays that recorded SHA. If this merges on the current green, those backend shards and Coverage Gate will fail on main and on every open PR. The damage stops at CI: production always sets app["state"], so users get the intended owner-only gate.
- PR #12918 also removed
dashboard.usage_text_scrape_enabledfrom main, so the carve-out is dead code. The key is gone from_EDITABLE_CONFIGon main, and main's test checks that it stays gone. The comment atcore.py:2725-2744citestest_a_non_owner_may_still_switch_the_billing_off, which no longer exists. This is not a security hole: a non-owner PATCH of that key tofalseskips the gate but then gets 400 "field not editable", so nothing is written. It is, however, the only reason the PATCH gate still runs afterrequest.json().
Smallest fix:
- Rebase onto current main.
- Give the three tests an owner identity. Use
dashboard_owner_helpers.as_owner(app)for the TestClient test. Useowner_claims(req), or this file's_owner_request(), for the two MagicMock tests. - Delete the carve-out and its comment, and move the PATCH owner gate ahead of the body parse.
From a full open-PR audit against origin/main c66f95b (2026-09-25); findings were checked by independent reviewers reading the code. Reply here if this is wrong.
|
Thanks for this, @atomsbaza — the owner-gate fix is valuable. Since your branch is on a fork, I've opened an in-repo replacement, #14300, rebased onto current main and driven to green (all review lanes + PR Readiness pass), crediting you as co-author. It also drops the config.patch carve-out that had gone dead on main (the |
Problem / Motivation
The dashboard still exposes MCP and configuration mutation routes that can write machine-global state, restart sessions, install or remove capabilities, or change gateway behavior. The routes this PR targets did not share one owner authorization boundary, so the protection could drift between handlers. Several owner-denial helpers also duplicated the same identity rule in different modules.
Why it matters
MCP and dashboard configuration writes affect the host and future sessions, not only the requesting tab. An app-scoped token or an authenticated non-owner must not be able to trigger those side effects. Authorization must happen before JSON parsing, locks, resolver work, process spawning, or any other mutation side effect. One route is deliberately outside that ordering:
PATCH /api/config/kirocrewreads the requested direction first, becausemainlets any authenticated dashboard user turn the billed usage scrape OFF (test_a_non_owner_may_still_switch_the_billing_off), and a gate placed before the parse could not tell that disable from an enable. The parse is the only thing that precedes the gate there; no lock, resolver, spawn or write does.What changed
403with machine-readable codeowner_only.main(connections.py:190,341,572,files.py:6182,onboarding_import.py:595,618); what they lack is a place in the registrar-walk invariant this PR adds, so a future ungated sibling there would not be caught. That test-coverage gap is what migrate the 7 remaining inline owner-denial sequences to require_owner_dashboard_request #6224 tracks.X-Internal-Secretremains an explicit opt-in exception only for MCP server registration (PUT/DELETE /api/mcp/servers/{name}); it does not bypass the other mutation routes.403 owner_onlybefore a handler can return a body-parse error or perform a side effect.Tests
py_compilepassed for all changed Python files.git diff --checkpassed.The final targeted run deselected 6 environment-only test nodes. The broader relevant run had 3 environment-only failures: two pip-channel checks because the uv-created environment has no
pipmodule, and one optional STT capability check because voice/Transcribe dependencies were not installed. Formatting/lint executables (black,isort,flake8, andruff) were unavailable in the isolated worktree environment.Review and CI status
The local diff was reviewed and the available targeted validation passed. No separate model-pinned review is claimed here. Upstream automated checks for this fork PR are currently held by GitHub
action_requiredapproval for the fork workflows; this is an execution-permission blocker, not a source-test failure. After an upstream maintainer approves and runs the workflows, CI and review results should be evaluated for the current head revision.Scope
Backend-only authorization and regression coverage. No frontend behavior changes and no screenshot evidence is applicable.
Closes #5014
Pattern harvest
Rule candidate: semgrep / review-prompt — when an authorization predicate is re-stated per handler it drifts, so a registrar's mutating routes should share one owner boundary that runs before body parsing, lock acquisition, or any other side effect, and the invariant should be pinned by a test that walks the real route table rather than by a hand-kept list of route names.
Section appended by a maintainer to satisfy the
PR Hygienegate, which began requiring a Pattern harvest section onfix:PRs after this PR was opened. No other part of this description, and nothing on the branch, was touched.