Skip to content

test: align slot-approve internal-caller tests with the gate - #18944

Merged
buluoray merged 1 commit into
mainfrom
fix/approval-internal-caller-18810
Oct 10, 2026
Merged

buluoray merged 1 commit into
mainfrom
fix/approval-internal-caller-18810

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #18943
Refs #18810, #18867

Problem / Motivation

Goal: Turn test/test_approval_decide_owner_bound.py green on main without changing any auth behavior.

Three tests fail on main from 9086e9730 (#18810) to the current tip:

  • test_internal_caller_bare_id_slot_approve_is_refused -- assert 403 == 404
  • test_internal_caller_slot_approve_with_no_request_id_is_refused -- assert 403 == 404
  • test_internal_caller_owner_bound_slot_approve_resolves -- assert 403 == 200

They are red in "Backend Tests" on every PR whose merge ref includes #18810.

Why it matters

The red lands in "Backend Tests" on every PR whose merge ref includes #18810, so unrelated PRs cannot go green.

Not a goal

  • Changing any auth or approval behavior in src/.
  • Revisiting which internal callers the session-approval gate admits.

Root cause: the test is stale, the code is right

This is a semantic merge conflict between two PRs that each passed CI alone.

  1. fix(security): refuse bare internal-auth on session-approval routes #18867 (849803612, merged 18:51Z) made deny_session_approval_caller refuse every internal_auth caller on chat_slot_approve with 403 owner_only. Only a verified cron: key on chat_mode is admitted. Its PR body and docstring say so explicitly: "any key on chat_slot_approve ... even a verified dashboard: or subagent: key -- is refused".
  2. fix(approvals): bind decides to the request the card showed #18810 (9086e9730, opened 09:40Z on an older base, merged 19:58Z) added tests that assume an internal caller reaches the slot route's body: 404 approval_target_required for a bare id, 200 for an owner-bound target. Its last green CI ran on a merge ref without fix(security): refuse bare internal-auth on session-approval routes #18867.

api_chat_slot_approve calls deny_session_approval_caller on its first line, so on today's main an internal caller never reaches the owner-bound check. The 403 is the later, stricter security contract working as written. Making the tests pass by restoring 200 would reopen the bypass #18867 closed. So the tests change, not the code.

What changed (motivation → approach → change)

Test-only, one file:

  • The two "is refused" slot tests now expect 403 (and owner_only for the bare-id one). The future still stays unresolved.
  • test_internal_caller_owner_bound_slot_approve_resolves becomes ..._is_refused. It expects 403 and an unresolved future.
  • The module docstring states the slot route refuses internal callers outright.

No src/ change. The approvals-route tests (/api/approvals/{id}/{action}) and the dashboard-user tests are unchanged and still pass.

Auth gates

Nothing is loosened. Every changed assertion is at least as strict as before: each one asserts a refusal and an unresolved future. The one assertion that asserted a resolve (200) now asserts a refusal.

Backwards compatibility

No behavior change; test-only.

Tests

  • python3 -m pytest test/test_approval_decide_owner_bound.py test/test_chat_mode_internal_auth_gate.py test/test_dashboard_approval.py: 129 passed (8/8 in the target file).
  • black, isort, flake8 clean on the changed file. mypy reports the same 5 pre-existing errors on untouched lines (93-97) as on main.

Manual verification

N/A -- test-only change.

Screenshots / video

N/A -- no UI change.

Related Issues

Closes #18943. Refs #18810, #18867.

Pattern harvest

Rule candidate: review-prompt
Pattern: "Two auth PRs on the same route pass CI alone; a test written on the older base asserts a status the later gate now refuses."

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.

…ssion-approval gate

The slot approve route refuses every internal-auth caller with 403 in deny_session_approval_caller, before the owner-bound target is read. Three tests in test_approval_decide_owner_bound.py were written against a base without that gate and expected 404/200; they now assert 403 and that the pending future stays unresolved.
@iamwhatever
iamwhatever requested review from a team and KiroCrewCaptain as code owners October 10, 2026 20:55
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision dab098520981a2ac6bf1d8d84a3da5f384f71352 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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ⏭️ skipped

Revision dab098520981a2ac6bf1d8d84a3da5f384f71352 ships no reviewable capability (docs, tests or generated files only), so there is nothing to inventory. Advisory — does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

The spec still says an internal caller on the slot route gets 404 approval_target_required. The re-pinned tests now say it gets 403 owner_only, and this PR leaves the two disagreeing.

Watch

  • The spec contradicts the new pin. docs/system-specs/modules/learn-cron-dashboard.md:3663 says that POST /api/chat/slots/{slot}/approve "applies the same rule to a body without origin". That rule is a 404 for an internal caller and a resolve for an owner-bound target. The code now runs deny_session_approval_caller first and refuses every internal_auth caller. The PR's new docstring says the same: the slot route "is refused outright with 403". So a later author who reads the spec as the contract will meet the same semantic conflict again and may "fix" the code back to the looser behaviour. The tests were the only stale record; correcting them while the spec keeps the stale statement moves the drift instead of removing it.
    Clears when: the spec sentence states that the slot route refuses every internal caller with 403 owner_only, and that the owner-bound rule applies only to /api/approvals/{id}/{action}, updated in this PR.

Suggestions

  • The slot handler's owner-bound check for internal callers (the 404 approval_target_required branch) can no longer be reached by an internal caller. Remove it in a follow-up, or add a comment saying only dashboard-owner and app callers reach it, so it doesn't read as a live path.

[DESIGN-REVIEWED] dab0985

Description read

[DESCRIPTION-READ] dcd27eb06b875df0c7dbdd7688e53002a941b98541d2623d35be095bd374af2c

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] dab0985

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

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] dab0985

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

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

@buluoray
buluoray merged commit e6ac772 into main Oct 10, 2026
154 of 158 checks passed
@buluoray
buluoray deleted the fix/approval-internal-caller-18810 branch October 10, 2026 22:00
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 10, 2026

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

Approving at dab0985. Test-only change, no src/ behaviour touched.

Verified:

  • _internal_session_approval_refusal in src/kiro_crew/dashboard/chat_handlers.py admits only a verified cron: key on chat_mode; every other internal_auth caller on chat_slot_approve gets the owner-only 403. So 403 owner_only is the right expectation for all three slot-route tests, and the owner-bound target is never read for an internal caller there.
  • test/test_approval_decide_owner_bound.py fails 3/8 on current main (403 vs 404/200) and passes 8/8 at this head, run locally with -n 0.
  • The approvals-route tests that still prove an internal caller must send the owner-bound target are unchanged.

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.

main: test_approval_decide_owner_bound fails 3/8 since #18810 (403)

2 participants