Repository navigation
refactor(dashboard): unchain the warm brief list-field ternary - #23377
Conversation
`_clean_items` picked the raw items of a brief's `needs_you` / `next` field with a chained conditional expression: one string becomes a one-item list, a list is used as is, anything else gives no items. It reads as if/elif/else now, with the same three branches in the same order. The `list[object]` annotation says what the items can be: a model's JSON list may hold numbers or null, which `_clean` turns into empty strings that `_clean_items` then drops. No existing test sends a list field as one string or as an object, so emptying the string branch, or letting the last branch read an object's keys or values, fails no existing test. One new test sends both.
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: it rewrites one ternary into [DESIGN-REVIEWED] b48caf6 Description read[DESCRIPTION-READ] 0e284d19225ff0a6f867740d465bae3b57f5cbf9389118597325913229d4e871 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This refactor doesn't change what a brief shows, and the added test pins two inputs that had no test before. What this change shipsInventory (2 items) — 2 justifiedIntent: make the code that picks a brief's
[FIRST-PRINCIPLES-REVIEWED] b48caf6 Description read[DESCRIPTION-READ] 84add4f21821dd38829d74b1b6bae8373fbf39a284958aa7059becd244c5a3fa That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
|
Instead of a push that restarts CI on a base that keeps moving, I proved the tree a merge would produce: this commit cherry-picked cleanly onto |
|
Disposition: rebutted (no change needed): the PASS punchline raises no ask, so nothing follows from it.
|
|
Disposition: rebutted (no change needed): "This refactor doesn't change what a brief shows" and both inventory items judged justified raise no ask, so nothing follows from it.
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Tier 1 auto-approve: refactor (2 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: a nested conditional expression becomes an if/elif chain with the same three outcomes, plus a test that pins them.
Problem / Motivation
Goal: Make the warm-welcome brief's list-field reader in
src/kiro_crew/dashboard/warm_task_brief.pyread as plainif/elif/else, and pin the two inputs no test sends it (a field sent as one string, and a field sent as an object), with no change in what a brief shows.On
origin/mainthe sweep's detector reports one actionable chained conditional expression indashboard/(it excludes two others: one in a keystone file, one a test pins as text). It is_clean_items, which picks a brief's rawneeds_you/nextitems witha if c1 else b if c2 else d, so the reader has to unpack precedence to see which branch wins.Why it matters
Nothing is broken today.
_clean_itemsdecides which of a model'sneeds_you/nextitems reach_clean, the redaction and capping step for the warm-welcome card, so a reader checking that path should see its three cases at a glance. Two of those inputs are unguarded: no existing test sends a list field as one string or as an object, so a later edit could silently drop a model's single-stringneeds_you, or start turning an object's keys or values into items, and no test would fail.Not a goal
warm_task_brief.pyor elsewhere indashboard/.test/test_warm_task_brief.py, which is already over the 1,600-line working target; the one test added here pins an existing function and is not a new responsibility.What changed (motivation → approach → change)
A warm-welcome brief comes out exactly as before.
_clean_itemsnow spells its three cases as statements, in the same order: a string becomes a one-item list, a list is used as is, anything else gives no items. Thelist[object]annotation on the first branch says what the items can be (a model's JSON list may hold numbers or null;_cleanturns those into empty strings, which_clean_itemsthen drops), so mypy does not inferlist[str]from that branch alone.One test sends the two inputs no test sent: a field as one string, and a field as an object.
Backwards compatibility
Compatible: same branches, same order, same results for every input; no signature or return type changes.
Removes nothing: the rewrite keeps every branch and every result, and the test file only gains a test.
Tests
test_a_list_field_sent_as_one_string_is_one_item_and_an_object_gives_no_itemsintest/test_warm_task_brief.py: aneeds_yousent as one string becomes one item, and anextsent as an object with a string value gives no items (neither its key nor its value becomes one). It passes onorigin/main's_clean_items.-n0, 10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest/test_slot_running_readers.py, and one shuffled order of both files' 198 ids (seed 14078): all green.scripts/run_scoped_tests.pyselectstest/test_warm_task_brief.pyandtest/test_slot_running_readers.py: 198 passed (Python 3.12).scripts/docs_lint.py --test,scripts/docs-lint.sh), the per-file coverage self-test, the--testself-tests, the flake-pattern ratchet and the vendor manifest.scripts/scrub-lint.shis absent from the checkout (CI'sinternal-content-scancovers it), semgrep is not installed on this host (CI's SAST job runssemgrep/), and the frontend did not run, as nothing underwebsite/,.github/orscripts/changed._clean_items. The behaviour reviewer ran base and head_clean_itemsover 50,000 fuzzed and 48 chosen inputs with identical results, and the same calls in the same order on the 48; the security reviewer found_clean_itemsis not a control (anything it does not pick is dropped, never shown) and the file not keystone. Their other findings were the test's object needing a string value so a values mutant fails, and overclaims in this description and the commit message; two independent adjudicators upheld every one, and the diff and this text carry each fix, so none was dropped.Manual verification
N/A — unit coverage sufficient: a pure function whose three branches are each pinned by a test.
Screenshots / video
Why no screenshot: backend-only refactor; the card renders the same fields from the same values.
Related Issues
Part of #16523
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.