Skip to content

refactor(dashboard): build five files' slot 404s with slot_not_found - #21670

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/simplify-dashboard
Oct 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/simplify-dashboard

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make nine more dashboard branches that hand-build the uniform slot_not_found 404, in five files that do not call the helper today, call slot_not_found() instead, with no change in what the client receives.

slot_ownership.slot_not_found() is documented as "the one 404 an app gets for a slot it may not act on, or that does not exist". #21555 routed the hand-built copies in files that already called it; its Not a goal listed ten more copies in six files that did not, plus one spelled through a constant. This PR takes nine of those ten, in five of the six files.

#16523's in-scope list does not name this kind: it is code re-implementing an existing helper, so this PR keeps to the issue's behaviour-preserving, one-module-per-PR rule. The mechanical scan for the issue's two mechanically decidable kinds (shadowing in-function imports, chained ternaries) found no actionable site in dashboard/.

Why it matters

Nothing is broken today. These nine branches spell out the helper's body by hand, so a change to slot_not_found() would leave them answering the old body while every branch that calls the helper answers the new one. One of them hand-builds that body only so it matches the helper: the threads routes' feature-off answer, whose comment says it has "the same shape the app-isolation refusal answers with". Those routes refuse an app's foreign slot through deny_app_slot_access, which calls the helper, so after such a change an app could tell "threads are off" from "not your slot".

Not a goal

  • chat_fork.py's copy. Routing it means extending the file's slot_ownership import, and two open PRs (feat(chat): merge a fork back into its parent chat #15957, feat(chat): backend to merge a fork back into its parent chat #17165) insert an import directly above that line, so the edit would hand both a merge conflict.
  • handlers/prompts_caller_gates.py's copy, which spells the code through _CODE_SLOT_NOT_FOUND, a name handlers/prompts.py exports. Routing it would leave that published name unread; that is a separate call.
  • chat_pins.py's _authorize_app_slot, one expression that takes the code as a parameter: four of its five call sites get the helper's body and one (api_chat_pins_delete) gets pin_not_found, so routing it means splitting that expression.
  • Any 404 whose body differs from the helper's (for example "slot not found" in messaging_api/run_control.py and handlers/redaction.py, "no such slot" in handlers/appearances.py, the texts in ask_question.py and member_dashboard.py): routing it would change the response.
  • Changing slot_not_found(), any refusal decision or audit row, or what any branch returns.

What changed (motivation → approach → change)

Each branch below returned a hand-built copy of the helper's response; each now calls the helper, so these branches build that 404 from the same function as the branches that already call it; chat_fork.py, handlers/prompts_caller_gates.py and chat_pins.py's _authorize_app_slot still build theirs (see Not a goal).

File Branches How the name is reached
chat_todo.py lookup miss, app refusal, slot replaced during the body read new from kiro_crew.dashboard.slot_ownership import slot_not_found
chat_threads.py _feature_off, _resolve_slot lookup miss added to the existing slot_ownership import
chat_api/source_links.py GET lookup miss, unlink lookup miss facade globals; added to the TYPE_CHECKING list
routes/chat.py api_dashboard_card lookup miss new slot_ownership import
handlers/members.py fresh-start "not this member's DM" ch.slot_not_found() through the chat_handlers module the handler already imports

chat_api/source_links.py is an owner of the chat_handlers facade: its functions run with the facade's globals, which bind slot_not_found, the same way the file already reaches sel and deny_app_slot_access. routes/chat.py is on the boot path; its new import loads nothing new, because chat_threads, which the file imports at line 14, imports slot_ownership at module scope. In api_chat_slot_todo only the returned expressions change; the app refusal's audit row and the order of every check stay as they were.

The test file #21555 added gains one case for the dashboard-card read, the one changed branch no existing test reached.

Backwards compatibility

Compatible: every changed branch returns the same status, JSON body and content type as before.

Removes nothing: no handler, route, response field or name is removed; only the expression that builds an unchanged response changes.

Tests

  • New case. test_the_owner_card_read_gets_the_shared_not_found in test/test_missing_slot_uniform_404.py sends the owner's request for an unknown slot to api_dashboard_card and asserts status, body and content type equal slot_not_found()'s. It passes with main's routes/chat.py and fails when that branch returns a different body. D12: 20 runs at -n0, 10 at -n 4 beside test_chat_slot_muted.py and test_dynamic_dashboard_cards_activation.py, and a shuffled order (seed 21687), all green.
  • Name resolution. A probe confirmed each function the runtime calls (the facade's copy for source_links.py) has slot_not_found bound to the helper (ch.slot_not_found for members.py), and the helper's response equals the old literal's.
  • Related tests. Every test file that names a changed module, handler or route, or slot_not_found (133 files): 6907 passed, 42 skipped, 0 failed.
  • Mutation check. Giving each changed line its own status code in a scratch copy turned 12 existing tests red, covering 8 of the 9 lines; the new case covers the ninth.
  • Static gates (Python 3.12). All exit 0: flake8, isort, mypy, the black, subprocess-encoding, comment-history, brand, harness-parity, line-cap and feature-map checks (diff-scoped), the docs lint, eight --test self-tests (no coverage measured locally), the vendor manifest and the flake-pattern ratchet.
  • Pre-PR review. Seven read-only reviewers (repo rules, behaviour, imports, keystone and boot path, claims, local Opus and GPT lane mirrors, the GPT one on a Claude model) found no code defect; the five source files' base and head ASTs differ only in the nine swaps and the imports. Eight wording problems in drafts of this description and the commit message went to two adjudicators (five confirmed by both, three split); all eight were reworded. The existing _feature_off comment's "is not enumerable" overstates (a malformed request gets a 400 only with threads on); left, out of goal.
  • Not run locally. scripts/scrub-lint.sh is not in the checkout; that scan is CI's internal-content-scan job. semgrep is not installed here, so CI's SAST job is the only run of semgrep/. The frontend did not run: the diff touches nothing under website/, .github/ or scripts/.

Manual verification

N/A — unit coverage sufficient: each change swaps an expression for a call that returns an equal response, and the probe above checks each call resolves to the helper.

Screenshots / video

Why no screenshot: backend-only refactor; 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

Contribution License Agreement

Contributed under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 18:35
@bolichen97
bolichen97 requested a review from mbriones98 October 17, 2026 18:35
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 25f7f345b6e9196636830bb30512a16c4bb09721 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 17, 2026
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing to check.

[DESIGN-REVIEWED] 25f7f34

Description read

[DESCRIPTION-READ] 65e5bdfc731538dd9ecec587d4240b624f6ea0f5c0757dd6c0475277500c1ec8

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 25f7f345b6e9196636830bb30512a16c4bb09721 — 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 (3 items) — 3 justified

Intent: keep every dashboard "no such slot" 404 built by one function so that a change to the helper can't let an app tell one refusal from another. This is a FIX (behaviour-preserving dedup).

  1. Nine branches in five files (chat_todo, chat_threads, source_links, routes/chat, members) now return slot_not_found() instead of a hand-built copy of its body. Each client still gets the same status, body and content type — justified
  2. The threads feature-off 404 is now tied to the helper used for the app-isolation refusal, which it must match — justified
  3. A new test makes the owner's dashboard-card read of an unknown slot return the shared 404 — justified

[FIRST-PRINCIPLES-REVIEWED] 25f7f34

Description read

[DESCRIPTION-READ] 751dcf3f06e3aef9e662a49c3f775011694285a21968a4accff47acf5aec4077

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 25f7f34

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

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

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 25f7f34

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

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • First Principles PASS punchline: three hand-built copies left alone can drift from the helper

accepted-and-deferred: true; chat_fork.py:291, prompts_caller_gates.py:151 and chat_pins.py's _authorize_app_slot still build the body by hand.
Each is outside this PR's frozen goal for a stated reason: two open PRs insert an import beside chat_fork.py's slot_ownership line; _CODE_SLOT_NOT_FOUND is a name handlers/prompts.py exports; _authorize_app_slot takes the code as a parameter.
Tracked as #21678 (deferred-finding, assigned, Due 2026-10-31), with the per-site steps and the no-response-change bar.

@bolichen97
bolichen97 enabled auto-merge (squash) October 17, 2026 19:05
@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 17, 2026
Nine branches in five dashboard files hand-built the uniform per-slot
404 body that slot_ownership.slot_not_found() returns. Each now calls
the helper, so these branches answer with the same definition of the
indistinguishable 404 that deny_app_slot_access answers with, instead
of each carrying a copy of it.

The response bytes, status and every decision, audit row and their
order are unchanged. The owner's dashboard-card read was the one
changed branch no test reached; test_missing_slot_uniform_404.py now
pins its 404 to the helper's.
@bolichen97
bolichen97 force-pushed the refactor/simplify-dashboard branch from 762528c to 25f7f34 Compare October 17, 2026 19:29
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased onto ccb5d34645 to pick up #21640; CI re-running.

The previous head's only red, Backend Tests (3.12, 7) (with Coverage Gate, which fails closed on it), was test/test_session_allocation_bindings.py::test_every_name_patched_through_the_facade_reaches_every_owner_reading_it hitting its 120 s timeout (run; 1 failed, 24732 passed). That is main's red tracked in #21671 (reproduced on a clean origin/main, seen on five other unrelated PRs). This PR touches no session_allocation code. #21640 narrows that scan to the facade's own files and merged after this head's base; on the rebased tree the node passes locally in 15 s. The commit itself is unchanged (git range-diff: =).

@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 17, 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.

Tier 1 auto-approve: refactor (6 files). Criteria: no conflict, no requested changes, security path denylist clean, design-doc gate clean, security checklist all-NO, no reviewer-lane findings, readiness signal fresh for this head SHA, declared category matches the diff. Category: code-move only; six inline slot 404 responses are replaced by the shared slot_not_found() helper, which returns the same body and status, and a test pins the dashboard-card path to that shape.

@bolichen97
bolichen97 merged commit 52a302b into main Oct 17, 2026
104 checks passed
@bolichen97
bolichen97 deleted the refactor/simplify-dashboard branch October 17, 2026 21:04
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 17, 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