Skip to content

refactor(dashboard): answer the pin routes' slot denial with slot_not_found - #21730

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/pins-slot-not-found-21678
Oct 18, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/pins-slot-not-found-21678

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The chat pin routes answer an app's denied slot with the shared slot_not_found() 404, so every dashboard slot denial comes from one helper.

chat_pins._authorize_app_slot still builds the slot 404 by hand: web.json_response({"error": "not found", "code": missing_code}, status=404). Four of its five callers get the slot_not_found body that way. The other two hand-built copies the issue names (chat_fork.py and handlers/prompts_caller_gates.py) already call the helper on main since #21711, so this is the last one.

Why it matters

If the helper's body ever changes, the pin routes would keep the old body. An app could then tell a pin-route denial from every other slot denial, which is the difference the uniform 404 exists to hide.

Not a goal

  • Changing any response body, status, SEL row or the order of checks.
  • The pin_not_found 404s (they name a pin, not a slot).
  • Other 404s with a different body, such as "slot not found" in handlers/redaction.py and messaging_api/run_control.py.

What changed (motivation → approach → change)

The pin routes' slot denial was a copy of the helper's bytes, not a call to it, and the source scan in test/test_missing_slot_uniform_404.py misses it because the code is a variable.

_authorize_app_slot in src/kiro_crew/dashboard/chat_pins.py now returns slot_not_found() when no missing_code is given. api_chat_pins_delete still passes missing_code="pin_not_found" and keeps its literal body. Both responses stay byte-identical to main.

Resume carries its refusal as data (ResumeRefusal) until one wrapper builds the response, so it cannot call the helper directly. src/kiro_crew/dashboard/chat_api/resume.py built a second copy of the app refusal by hand; it now returns the shared _RESUME_APP_NOT_FOUND like the six other resume branches, and a test pins that refusal's wire bytes to slot_not_found().

Backwards compatibility

Compatible: every response keeps the same status, body bytes and content type; only the private pin helper's default changed (all five callers are in the same file), and resume returns an equal refusal value.

Removes nothing: no route, key, record or check is taken away.

Tests

test/test_missing_slot_uniform_404.py gains four tests:

Test Locks in
test_the_pin_slot_gate_answers_with_the_helper_itself the default denial IS chat_pins.slot_not_found() (a sentinel swap); red on main, green here
test_the_pin_slot_gate_keeps_both_404_bodies the slot denial matches the helper's bytes, and the pin_not_found denial keeps its exact body
test_the_resume_app_refusal_answers_with_the_helpers_bytes resume's app refusal goes out as the helper's exact bytes
test_resume_spells_its_app_404_only_through_the_shared_refusal resume.py builds no ResumeRefusal(..., "slot_not_found", ...) of its own; red on main, green here

Determinism: the four new tests passed 20/20 repeats, and the whole file passed in reversed order. The existing pin suites (test_dashboard_chat_pins.py, test_dashboard_chat_pins_ownership.py, test_chat_slot_pin_ownership.py) pass unchanged.

Manual verification

N/A — unit coverage sufficient: the change is one return path inside a private helper, and the tests compare full response bytes.

Related Issues

Closes #21678

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

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision e5a99e2976aaee0fe65957674a8f603873bd3dbb 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 added the readiness: checking Automated validation is still running label Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] e5a99e2

Description read

[DESCRIPTION-READ] d6c61fa0e5219ab48986d52c95d5d72e95d48e8f5ac7adf16ab3fe621f6ca020

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of e5a99e2976aaee0fe65957674a8f603873bd3dbb — 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

Check before merge: chat_api/continue_turn.py:175 and :212 still write the same "not found"/"slot_not_found"/404 by hand, for a slot replaced mid-request, not an app denial.

What this change ships

Inventory (4 items) — 4 justified

Intent: a FIX that makes an app's denied pin-route slot get the shared slot 404 from the one helper, so the denial can't drift into a body that sets it apart from other slot denials.

  1. Pin routes (list/create/delete) answer an app's denied slot via slot_not_found(); the bytes don't change — justified
  2. Resume's history-key app refusal reuses _RESUME_APP_NOT_FOUND instead of an inline copy — justified
  3. The private _authorize_app_slot default missing_code becomes None (all callers are in the same file; only one passes a value) — justified
  4. Four tests: a sentinel swap, both pin bodies, resume's wire bytes, and an AST scan with no inline ResumeRefusal slot 404 — justified

[FIRST-PRINCIPLES-REVIEWED] e5a99e2

Description read

[DESCRIPTION-READ] e3b4020b63e24b7efc8c15618d462902016901891b9c5d19b149696789387237

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e5a99e2

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

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

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e5a99e2

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 18, 2026 03:05
@bolichen97
bolichen97 force-pushed the refactor/pins-slot-not-found-21678 branch from 0223d66 to e5a99e2 Compare October 18, 2026 03:26
@bolichen97

bolichen97 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: resume's inline app-refusal copy replaced by the shared constant

  • fixed span=fe4c65eacd1f

Fixed in e5a99e2. chat_api/resume.py built ResumeRefusal("not found", "slot_not_found", 404) inline; it now returns _RESUME_APP_NOT_FOUND like its six other app-refusal branches, so resume has one spelling.
The other copy the lane counted is that constant's own definition (chat_handlers.py). Resume carries refusals as data until _resume_refusal_response builds the wire body, so it cannot call slot_not_found() directly.
test_the_resume_app_refusal_answers_with_the_helpers_bytes pins the constant's wire bytes to slot_not_found(); test_resume_spells_its_app_404_only_through_the_shared_refusal (red on main) keeps resume from growing a new inline copy.

[operator: bolichen97]

@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 18, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • rebutted: continue_turn.py replaced-slot refusals

Kept as-is: out of this PR's frozen goal. #21678 names three hand-built json_response copies of the app-denial 404; the two continue_turn.py lines raise SlotContinueRefusal(...) for a slot replaced while the request waited, which the lane itself notes is not an app denial.
They are exception values, not responses, so slot_not_found() cannot be called there; sharing them would need a new shared SlotContinueRefusal constant on a different path, which this refactor does not need.
No response changes either way, so leaving them changes no wire bytes.

[operator: bolichen97]

@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 18, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD at e5a99e2, for the policy reason only.

The change reads as correct. _authorize_app_slot now returns slot_not_found() by default (chat_pins.py L70-L72), and its body matches the removed literal. The pin-delete route keeps pin_not_found. Resume returns the shared _RESUME_APP_NOT_FOUND, an equal value that nothing compares by identity. Admission is unchanged. All AI lanes pass, the First Principles check on continue_turn.py has a reasoned rebuttal, and checks are green.

The hold: it edits the app-isolation denial path of the pin and resume gates, which our policy reserves for a human unless the change is a pure move. The bytes are identical, so this should be a quick maintainer approval.

— crew-pr-reviewer (r110)

@bolichen97
bolichen97 merged commit bdc5329 into main Oct 18, 2026
104 checks passed
@bolichen97
bolichen97 deleted the refactor/pins-slot-not-found-21678 branch October 18, 2026 06:23
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 18, 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.

Route the last three hand-built slot_not_found 404s through slot_not_found()

2 participants