Skip to content

refactor(dashboard): route the last two slot 404s through slot_not_found - #21711

Merged
bolichen97 merged 1 commit into
mainfrom
refactor/slot-not-found-last-two-21576
Oct 17, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
refactor/slot-not-found-last-two-21576

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the last two dashboard branches that hand-build the uniform slot_not_found 404 call slot_ownership.slot_not_found(), with no change in what the client receives, so every branch that answers it reads one definition.

#21555 and #21670 routed the other copies. Two are left: the fork handler's unknown-slot branch in chat_fork.py, and _deny_foreign_app_skill_slot in handlers/prompts_caller_gates.py, which spells the code through a private _CODE_SLOT_NOT_FOUND.

Why it matters

Nothing is broken today. slot_not_found() is the one 404 an app gets for a slot it may not act on or that does not exist. A hand-built copy keeps answering the old body if the helper ever changes. The skill gate's refusal must stay indistinguishable from "no such slot", so it should build that 404 from the same function the other isolation refusals use.

Not a goal

  • Any 404 whose body differs from the helper's (for example "slot not found" in handlers/redaction.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)

Both remaining copies now call the helper, so no dashboard module builds this 404 by hand.

File Change
chat_fork.py unknown-slot branch calls slot_not_found(); name added to its existing slot_ownership import
handlers/prompts_caller_gates.py refusal calls slot_not_found(); private _CODE_SLOT_NOT_FOUND deleted
handlers/prompts.py its TYPE_CHECKING list drops the deleted constant and names slot_not_found, which its facade now serves from that owner

No import adds boot work: slot_ownership is already loaded at module level through chat_threads and the chat_handlers facade. test_chat_fork_error_codes.py's per-file count drops from 27 to 26: the unknown-slot 404 is now counted in slot_ownership.

Merge cost: #15957 and #17165 each add an import line right above chat_fork.py's slot_ownership import, so whichever lands second takes a one-line rebase (keep both imports).

Backwards compatibility

Compatible: both branches return the same status, JSON body and content type as before.

Removes nothing: _CODE_SLOT_NOT_FOUND was a private name with no reader outside prompts_caller_gates.py and the TYPE_CHECKING list in handlers/prompts.py (grep of src/ and test/ on origin/main; it is not in the frozen facade inventory); no handler, route or response field is removed.

Tests

  • test/test_missing_slot_uniform_404.py adds the fork handler's unknown-slot 404 and the skill gate's refusal of an app naming no slot, each pinned to the helper's status, body and content type.
  • A new source scan in the same file fails on any dashboard module except slot_ownership.py that calls json_response with {"error": "not found", "code": "slot_not_found"} (or a *SLOT_NOT_FOUND name). Red on origin/main, naming chat_fork.py:291 and handlers/prompts_caller_gates.py:151; green here.
  • test_chat_fork_error_codes.py::test_the_ratchet_can_actually_fail count updated to 26.
  • Local: scripts/local-gate.py related set, black, isort, flake8, mypy, semgrep (semgrep/, diff-scoped), the flake-pattern ratchet, and local GPT and Opus review mirrors. All green on this head. A wider local run of the same refactor on the earlier base hit test_pid_lifecycle_teardown.py::TestResetStateUntracksParentPid::test_reset_state_untracks_parent_pid, which fails on clean origin/main on that host too, so it is not caused by this diff.

Manual verification

N/A — unit coverage sufficient: each branch swaps a literal for a call returning an equal response, and the tests call both changed branches.

Related Issues

Closes #21576

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

The fork handler's unknown-slot branch and the skill gate's app refusal
still built the slot_not_found 404 by hand. Both now call
slot_ownership.slot_not_found(), so every dashboard branch that answers
this 404 reads one definition. prompts_caller_gates drops its private
_CODE_SLOT_NOT_FOUND spelling, which nothing else read.

Both branches return the same status, body and content type. A source
scan now fails on any dashboard module that hand-builds this 404.
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners October 17, 2026 21:52
@bolichen97
bolichen97 requested a review from CrysisDeu October 17, 2026 21:52
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that the ResumeRefusal/SlotContinueRefusal("not found", "slot_not_found", 404) copies in chat_api/ are meant to stay outside the claim that "no dashboard module builds this 404 by hand".

[DESIGN-REVIEWED] abdc857

Description read

[DESCRIPTION-READ] 6a401f0253b28eba927ecede720cd55a41cad45944ee46e1ca54a621bea8ae00

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

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

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

One thing to check: ResumeRefusal("not found", "slot_not_found", 404) (chat_handlers.py:1109, resume.py:872, continue_turn.py:175,212) still holds the body as data, and the new scan can't see it.

What this change ships

Inventory (5 items) — 5 justified

Intent: Make every dashboard branch that answers the uniform no-such-slot 404 read one definition, without changing what clients receive. This is a FIX (a refactor removing two duplicate copies).

  1. The fork handler's unknown-slot 404 now comes from slot_not_found(), with the same response as before — justified
  2. The skill gate's foreign-app refusal now comes from slot_not_found(); private _CODE_SLOT_NOT_FOUND deleted — justified
  3. The prompts.py TYPE_CHECKING list swaps the deleted constant for slot_not_found — justified
  4. A new source scan fails any dashboard module that hand-builds json_response({"error":"not found","code":"slot_not_found"}) — justified
  5. The fork error-code ratchet count drops from 27 to 26 because the site is now counted in slot_ownership — justified

[FIRST-PRINCIPLES-REVIEWED] abdc857

Description read

[DESCRIPTION-READ] 5d19f4f0186404509ba0da6d9446d1ff573646d4efc6b54b2bd3e64156cb08ef

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] abdc857

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

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

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] abdc857

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

@bolichen97
bolichen97 enabled auto-merge (squash) October 17, 2026 22:05
@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 Oct 17, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Punchline answered: rebutted (in scope as written).

ResumeRefusal / SlotContinueRefusal("not found", "slot_not_found", 404) are refusal values, not responses; their wire wrappers build the response, and ## Not a goal names them as kept.
The claim and the scan cover hand-built json_response calls only; the docstring and body say so, so nothing outside that shape is promised.

@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] Punchline answered: rebutted (in scope as written).

ResumeRefusal / SlotContinueRefusal("not found", "slot_not_found", 404) are refusal values, not responses; their wire wrappers build the response, and ## Not a goal names them as kept.
The claim and the scan cover hand-built json_response calls only; the docstring and body say so, so nothing outside that shape is promised.

@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 (5 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: the two remaining hand-built slot 404s now return the shared slot_not_found() response, with a source scan test that keeps new copies out.

@bolichen97
bolichen97 merged commit a22ed2a into main Oct 17, 2026
103 checks passed
@bolichen97
bolichen97 deleted the refactor/slot-not-found-last-two-21576 branch October 17, 2026 23:09
@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.

refactor(dashboard): route the remaining hand-built slot_not_found 404s through the helper

2 participants