Skip to content

refactor(apps): unchain the dev-fleet fallback-remote ternary - #15767

Merged
iamwhatever merged 1 commit into
mainfrom
refactor/simplify-apps
Oct 1, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
refactor/simplify-apps

Conversation

@bolichen97

@bolichen97 bolichen97 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Make the dev-fleet fallback-remote pick readable at a glance, with no behaviour change.

_resolve_base_snapshot in src/kiro_crew/apps/builtins/dev_fleet/repository.py picked the fallback remote with a chained conditional expression on one line. It was the smallest actionable site the module-simplification detector found on main.

Why it matters

This pick decides which remote the Dev Fleet /rebase flow verifies and rebases onto when the checkout has no usable tracking remote. A reader checking which remote wins had to untangle a if x else (b if y else c).

Not a goal

What changed (motivation → approach → change)

The fallback is now picked by an if/elif/else with the same branch order. The result still goes through _plausible_remote_name before it becomes remote.

remotes git lists fallback (before and after)
includes origin origin
exactly one, not origin that one
none, or several without origin "" (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: every test_dev_fleet*.py and test_devfleet*.py, plus test_config_app_owned_sections.py, test_spawn_audit.py and test_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 --test and verify_vendor_manifest.py. scripts/scrub-lint.sh is 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/ or scripts/ changes. CI's changes job reports only_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

  • 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

@bolichen97
bolichen97 requested a review from a team as a code owner October 1, 2026 07:37
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Oct 1, 2026
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.
@bolichen97
bolichen97 force-pushed the refactor/simplify-apps branch from be8c666 to ce5d016 Compare October 1, 2026 12:35
@bolichen97

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in 21 files this PR overlaps by import since this head ran (6b033ab -> 8ae5dff). The old base carried the _row_stem_tokens_for_scan F821 in vector_memory_runtime/lessons.py, which redded flake8 and backend shards 4-6 on Linux and Windows. That is fixed on main, and none of it was in this diff. The review lanes and readiness on the previous head failed on API rate limit exceeded for installation, not on a verdict. CI is re-running on ce5d016.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

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

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 .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 1, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ce5d016

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

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

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of ce5d0160c96e83ae8953cca917786208bf4b8961 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ce5d016

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

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of ce5d0160c96e83ae8953cca917786208bf4b8961 — 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 (1 item) — 1 justified

Intent: make the dev-fleet fallback-remote pick readable without changing which remote is picked — a FIX (readability), no behaviour change.

  1. The fallback-remote pick for Dev Fleet /rebase is now an if/elif/else block instead of a one-line chained ternary; same branches, same order, same _plausible_remote_name gate — justified

Verified against the checkout: the three branches are value-for-value identical to the replaced expression (repository.py:699-704), no surface, config, default, test or pin changes anywhere in the diff. Sibling chained ternaries counted with if .* else \(.* if .* else: 3 in src/kiro_crew (one in a test), plus the subagent_manager/monitoring.py one the description defers with a named reason — a readability sweep landing one site at a time is the deferral lens 6 accepts, not a point patch hiding a general fix.

[FIRST-PRINCIPLES-REVIEWED] ce5d016

Description read

[DESCRIPTION-READ] de53ae05403d267e62885f720e2f52e7f8ca89b7bc12ed86a7fceb95328c53ad

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 added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 1, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 origin branch: test_base_branch_ignores_a_remote_sorted_before_origin fails.
  • Disable the sole-remote branch: test_base_branch_reads_a_sole_remote_under_another_name fails.
  • Change len(names) == 1 to >= 1: test_base_branch_falls_back_locally_when_no_remote_is_unambiguous fails.
  • 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 iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. Same truth table as the chained ternary: origin wins, a single name is used, otherwise empty. No behaviour change.

@iamwhatever
iamwhatever merged commit dd87314 into main Oct 1, 2026
97 checks passed
@iamwhatever
iamwhatever deleted the refactor/simplify-apps branch October 1, 2026 15:44
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 1, 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.

3 participants