Repository navigation
refactor(apps): unchain the dev-fleet fallback-remote ternary - #15767
Conversation
The fallback remote pick in the dev-fleet base resolver chained two conditional expressions on one line. Spell it as if/elif/else with the same branch order, so origin still wins over a sole remote and an empty name still falls through the _plausible_remote_name gate.
be8c666 to
ce5d016
Compare
|
Rebased: main moved in 21 files this PR overlaps by import since this head ran (6b033ab -> 8ae5dff). The old base carried the |
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] ce5d016 Description read[DESCRIPTION-READ] 56b3cf05790624c22c7a6008ea8e36243240a41870d35605748cd04fe548764f 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 |
Opus 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 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (1 item) — 1 justifiedIntent: make the dev-fleet fallback-remote pick readable without changing which remote is picked — a FIX (readability), no behaviour change.
Verified against the checkout: the three branches are value-for-value identical to the replaced expression ( [FIRST-PRINCIPLES-REVIEWED] ce5d016 Description read[DESCRIPTION-READ] de53ae05403d267e62885f720e2f52e7f8ca89b7bc12ed86a7fceb95328c53ad That sha256 names the PR description this verdict read. Recompute it with |
buluoray
left a comment
There was a problem hiding this comment.
Review at ce5d0160c96e83ae8953cca917786208bf4b8961: approve
This is a pure readability refactor. I checked that it behaves identically to the old code.
Branch-by-branch equivalence (src/kiro_crew/apps/builtins/dev_fleet/repository.py:699-704)
a if c1 else (b if c2 else d) and if c1: a / elif c2: b / else: d evaluate the same conditions in the same order, and each branch's value is evaluated only when that branch is taken. names is always a list[str] from remotes.split() (line 666).
"origin" in names |
len(names) == 1 |
before | after |
|---|---|---|---|
| T | T (["origin"]) |
"origin" |
"origin" |
| T | F (origin among several) | "origin" |
"origin" |
| F | T (sole other remote) | names[0] |
names[0] |
| F | F (none, or several without origin) | "" |
"" |
names[0] is still only read when len(names) == 1, so it cannot raise. The _plausible_remote_name gate after the pick (line 705) is untouched.
I also ran a mechanical truth-table comparison of the old and new expressions. It covered 312 inputs: lists and tuples of length 0 to 3 over origin, upstream, "", --upload-pack=x and Origin. Return values and exceptions were identical for every input.
Existing tests pin every branch. I mutated each branch in turn in test/test_dev_fleet_repo_accessor.py, and each mutation reddened one test:
- Disable the
originbranch:test_base_branch_ignores_a_remote_sorted_before_originfails. - Disable the sole-remote branch:
test_base_branch_reads_a_sole_remote_under_another_namefails. - Change
len(names) == 1to>= 1:test_base_branch_falls_back_locally_when_no_remote_is_unambiguousfails. - Swapping the order of the first two branches is an equivalent mutant: they overlap only on
["origin"], where both yield"origin". So the order the commit message says it keeps does not change the result.
All 17 remote, origin and sole tests pass at head. flake8 is clean on the file.
PR body and commit message: both are accurate. The table in the body matches the code, and nothing false would land in main's history.
Bots: Opus, GPT, Design and First Principles all PASS with no findings. Each verdict is consistent with what I verified above.
CI at this head: 82 checks succeeded and 12 were skipped (frontend lanes, because the diff is backend-only). None failed.
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed. Same truth table as the chained ternary: origin wins, a single name is used, otherwise empty. No behaviour change.
Problem / Motivation
Goal: Make the dev-fleet fallback-remote pick readable at a glance, with no behaviour change.
_resolve_base_snapshotinsrc/kiro_crew/apps/builtins/dev_fleet/repository.pypicked the fallback remote with a chained conditional expression on one line. It was the smallest actionable site the module-simplification detector found onmain.Why it matters
This pick decides which remote the Dev Fleet
/rebaseflow verifies and rebases onto when the checkout has no usable tracking remote. A reader checking which remote wins had to untanglea if x else (b if y else c).Not a goal
_plausible_remote_namegate the pick passes through.subagent_manager/monitoring.py. It is another module, and four open PRs touch that file._row_stem_tokens_for_scanname error onmaininvector_memory_runtime/lessons.py. It is tracked by flake8 F821 on main: lessons.py:1206 calls _row_stem_tokens_for_scan as a bare global #15762, with fixes open in fix(memory): read turn_lessons' row-token helper through text_scoring #15737 and fix(memory): read the row-stem helper through its owner module #15759.What changed (motivation → approach → change)
The fallback is now picked by an
if/elif/elsewith the same branch order. The result still goes through_plausible_remote_namebefore it becomesremote.originoriginoriginorigin""(rejected by the gate)Backwards compatibility
Compatible: the same remote comes out for every list of names.
names[0]is still read only when there is exactly one name, so it cannot raise.Tests
No test changes. On the Python 3.12 CI-parity venv, rebased onto
8ae5dff6ee, the suites that drive this resolver and the rest of Dev Fleet pass: everytest_dev_fleet*.pyandtest_devfleet*.py, plustest_config_app_owned_sections.py,test_spawn_audit.pyandtest_sandbox_dev_fleet_live_target.py(1274 passed, 1 skipped).Gates exit 0: flake8, isort, mypy,
check_black_formatting.py,check_subprocess_encoding.py,check_brand_name.py,check_harness_parity.py,docs_lint.py --test,docs-lint.sh,check_per_file_coverage.py --testandverify_vendor_manifest.py.scripts/scrub-lint.shis not in the tree; that scan runs in CI only.A five-lens review fleet checked the diff before this PR opened: AUTOSDE blocking rules, behaviour preservation, import semantics, security keystone and boot path, and comment accuracy. None found anything, so nothing went to the refuters and nothing was dropped.
Backend-only diff: nothing under
website/,.github/orscripts/changes. CI'schangesjob reportsonly_backend=true, so the frontend suites were not run locally.Manual verification
N/A: unit coverage is sufficient. This refactors one expression, and its three branches are listed above.
Screenshots / video
Why no screenshot: backend-only refactor of one remote-selection expression; nothing renders differently.
Related Issues
no linked issue: a readability sweep from the module-simplification campaign, not tracked by an issue.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)