Skip to content

fix(dev-fleet): harden every git read, and resolve the base branch per repository - #13348

Merged
bolichen97 merged 1 commit into
mainfrom
fix/dev-fleet-generic-repo-read-7428
Sep 30, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/dev-fleet-generic-repo-read-7428

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Dev Fleet's git reads stop executing programs the repository names, stop writing to the repository, stop reporting an unknown exit status as success, stop leaking a token from a remote URL, and target the repository's own default branch instead of the literal main.

Scope note: this PR previously shipped a foreign read-only checkout mode. That mode and its whole apparatus are removed — see Not a goal. The five fixes below never depended on it, and the first three sections are restated to match the PR's actual goal rather than the one it opened with.

Five defects, each reachable on the ordinary path against the operator's own checkout:

  • Signature verification can exec a program the repository names. .git/config is agent-writable — the same premise core.fsmonitor and core.hooksPath are already pinned on. [log] showSignature=true makes every git log verify what it prints, and verification execs gpg.program. Nothing pinned it.
  • A read wrote to the repository. git status refreshes the index's stat cache and saves it back under index.lock, so a command that is a read to its caller is a write to the repository. Every fleet render runs one per row.
  • An unknown exit status was reported as success. proc.returncode or 0 maps None to 0, and 0 is what every caller here reads as "that worked".
  • A remote URL's query rode into a link and into child argv. git remote set-url accepts a query and smart-HTTP honours it, so an operator's own remote can hold ?access_token=… — a PAT in the URL is a common way to make unattended https pushes work. Three derivation sites each anchored their pattern on $.
  • The base branch was the literal main. A repository whose default is master or trunk got the wrong row caption, the wrong ahead/behind reading, and the wrong rebase target.

Why it matters

The first four are silent. A git log that execs an attacker-named program, a fleet render that takes the index lock out from under the operator's own git, a failed command reported as success, and a personal access token rendered into an issue link and passed as a gh --repo argument all look like nothing happening.

The token one is the sharpest, because the value is measured rather than argued. On main, https://h/o/r.git?access_token=X produces the href https://h/o/r.git?access_token=X and the gh --repo value o/r.git?access_token=X. That link is rendered in the dashboard.

The base branch one is loud and costly. On a repository whose default is not main, Rebase targeted origin/main: it either fails the fetch, or — worse — finds a same-named stranger branch and rewrites the worktree's commits onto it, returning ok with no rollback path once the replay is clean.

Not a goal

  • The foreign read-only checkout mode. Removed from this PR rather than fixed. Its hazard class is that the clearance's vetted config bytes never bind to what git actually parses — the check reads one set of bytes and git opens the file again — and three review rounds found that same invariant at a new site each time. The compensating credential mask is dropped precisely when this backend is itself sandboxed, which the code documents as its normal shape. Closing it properly needs a private gitdir holding vetted bytes: a new mechanism on an apparatus the Design and First Principles lanes had already called over-built for a want with no recorded provenance.
  • Unknown-vs-no row states. They went with that mode: _build_pending returned unknown only inside except RepoReadOnly, so without the mode the state is unreachable.
  • Three pre-existing on-loop SEL emits (http_api lines 198 and 227, and worktree_ops._auto_prune_reaper). They are on main and are not this change's; pulling them in would widen the diff past what it is about.
  • is_owner_repo_shape. Once the foreign mode is gone the only remote that reaches gh --repo is the operator's own, so an argv-shape guard there is hardening this PR does not need.

What changed (motivation → approach → change)

Symptom → root cause → change, one chain each.

Signature exec. The vector is a config key naming a program, which is the class _GIT_ENV_NEUTRALIZERS already exists to pin. All four spellings are pinned, because gpg.<format>.program selects per format and gpg.openpgp.program is a synonym that overrides the bare key — pinning one leaves the other as an unpinned way to name the same exec. The trigger log.showSignature is pinned beside them: true is a value, and this is a place not to depend on one. Pinned as env rather than a per-call-site flag, so a log read added later inherits it — and an earlier attempt at the flag form broke 28 shard tests whose stubs match the argv they expect.

Read that writes. GIT_OPTIONAL_LOCKS=0 on the same chokepoint. The porcelain answer is identical and a real mutation still takes the locks it requires.

Unknown status. proc.returncode if proc.returncode is not None else -1. None is reachable after communicate returns on a child the loop has not reaped yet, so this is not a theoretical branch.

URL query. Cut the query before any pattern anchored on $ — a retained ?… sits between a trailing .git and the end of the string, so the suffix the pattern means to strip survives and the token rides into the result. runtime.remote_url_locator is the one home of the rule, in the module both importers share, because fleet_state imports repository and the reverse would be a cycle. A rule that cannot be shared gets copied, which is exactly how three sites each ended up with their own pattern; all three now call the one rule.

Base branch. Resolved per repository: origin's published HEAD, else a conventional candidate that exists, else the checked-out branch. Only origin is consulted — git remote lists alphabetically, so listing order lets a fork outvote it, and _upstream_remote falls back to origin, so the pair could disagree and a rebase would target a base the upstream never published. Ordered before _upstream_remote, which reads branch.<base>.remote and so cannot run first.

The tiers are not equal, and the difference is recorded once rather than re-derived per consumer. The first two are the repository stating its default; the last is a guess, and its trigger is ordinary — a dev box's checkout sits on a feature branch. Being wrong costs a caption on a read and a worktree's commits on a rebase, so Rebase refuses on a guess before the fetch, and the refusal clears itself on the next resolution. Every tier's answer passes an argv guard: a leading - reads as an option, and .. is the range separator every consumer interpolates around.

Backwards compatibility

Breaking, in one narrow and deliberate way: /apps/dev-fleet/api/rebase now REFUSES on a repository that states no default branch, where before it proceeded against origin/main. Writer sweep on origin/main @ a83d2258a27a937bc740fcebd1fee894a2dbf250 — the gate lives in worktree_ops._rebase_locked, whose only callers are worktree_ops._rebase (the route) and the tests updated here; there is no other entry point, and no caller inspects the error string. The refused case is the one that previously either failed the fetch or rewrote commits onto a stranger's branch, so nothing that worked before stops working.

Otherwise compatible. The neutralizer set grew from 4 to 9 config pairs; the only reader of that count is _load_trusted_credential_helpers, which already derives its own starting index from it rather than from a literal.

Tests

  • 12 mutations, 12 caught (~/oss/.kc-13348-mutations.py, not committed). Each substitution asserts it matched exactly one site; each run is refused unless its output carries an explicit pass/fail count; a positive control refuses to score anything unless every selector is green on the unmutated tree. Mutations: remove the optional-locks pin, flip showSignature back on, rename the gpg.openpgp synonym so it goes unpinned, understate GIT_CONFIG_COUNT, restore or 0, neuter the locator, skip it at each of the two derivation sites, drop the argv guard from the last base tier, let listing order pick the remote, report a guessed base as stated, remove the rebase gate.
  • test_a_config_that_is_not_a_regular_file... and friends from earlier rounds are gone with the mode. New coverage locks in: the argv guard over ten branch names, each base tier and its probe order, stated-vs-guessed, the rebase gate refusing before the fetch, an unresolved checkout spawning no git at all, the locator over six URL shapes, no derivation carrying a query, and an unreaped child scoring -1.
  • Two count assertions that had been retyped now derive from the pinned set, so adding a pin cannot fail them for a reason that is not a defect.
  • Four rebase tests and one redaction test now state the base branch, because the new gate sits before their fetch. One of them had been passing on a global leaked from another test; the stub now restores that global, which fixes the leak too.
  • All Dev Fleet suites green: 849 + 314 passed across 15 files.
  • black (via scripts/check_black_formatting.py, real scope), isort, flake8, mypy all exit 0.

Manual verification

N/A — unit coverage sufficient. Every change is in git argv/env construction, exit-status mapping, or string derivation, and each is pinned by a test plus a mutation that reddens it. The two test_trusted_bin_* failures seen locally are environmental (a gh shim on the dev box's PATH) and fail identically on pristine main.

Related Issues

Filed separately from this diff: #14818 (the SAST (Semgrep) lane measures 9–14 minutes against a timeout-minutes: 15 cap and cancelled twice at 15m03s / 15m04s while this PR was in review — trunk health, not this change).

Pattern harvest

Rule candidate: semgrep
Pattern: a suffix/identity regex anchored on $ applied to a URL that may carry ?/#, so the query both defeats the anchored strip and rides into the derived value.

Secondary pattern, no rule proposed: the same rule copied to three call sites because the module that needed it could not import the module that owned it. The fix was to move the rule to the module both already import, rather than to keep the copies in sync.

@chenmingwei23
chenmingwei23 requested review from a team and hoang-phan98 September 24, 2026 12:23
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 1b56d95413c25d635b5e0983ddd9f4dd04f9bb73 — 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: CONCERNS

Two new functions ship generalized for callers that don't exist, and the declared-breaking rebase refusal rests on one unverified transport claim.

Not justified as shipped

  • Item 6 — inherited: "nothing that worked before stops working" assumes every reachable remote advertises a symref HEAD; a remote on a transport that advertises none (dumb HTTP) with a genuine local main previously rebased correctly and now refuses.
    Clears when: the claim is confirmed on the transports fleet remotes actually use, or the refused case is explicitly accepted as designed.
  • Item 8 — one consumer, generalized: base_branch_mutation_refusal's no-arg globals path serves "the caption path" its docstring names, but its only src caller (worktree_ops.py:2379, grep: 1) passes both arguments.
    Subtraction: make base/positive required and delete the if positive is None/if base is None global-fallback branch.
    Clears when: the default path is deleted, or a caption-path caller exists.
  • Item 9 — one consumer, generalized: _resolve_remote_for's docstring promises "the rebase path can resolve the remote for its OWN locally-resolved base", but the rebase never calls it (a shipped test pins that it must NOT be consulted); sole caller is _upstream_remote (grep: 1), always passing BASE_BRANCH.
    Subtraction: fold the body back into _upstream_remote and delete _resolve_remote_for.
    Clears when: the function is deleted, or a second real caller lands.

What this change ships

Inventory (10 items) — 6 justified

Intent: FIX — five defects in Dev Fleet's git reads (config-named exec, read-that-writes, unknown status as success, token in URL derivations, hardcoded main).

  1. git log can no longer exec a repository-named signature program (four gpg pins + showSignature off) — justified
  2. Fleet git reads no longer take the repository's index.lock — justified
  3. An unreaped child's unknown exit status now reports failure, not success — justified
  4. Issue links, repo identities and gh --repo args drop a remote URL's query/fragment, via one shared rule — justified
  5. The base branch is the repository's own resolved default, not the literal main — justified
  6. Rebase now refuses when no remote states the default branch — inherited (unverified "nothing that worked stops working" premise)
  7. Rebase re-resolves its base locally and fetches/replays from the remote that verified it — justified
  8. base_branch_mutation_refusal reads module globals by default — one consumer, generalized
  9. _resolve_remote_for(base) extracted from _upstream_remote — one consumer, generalized
  10. Test file reformatted and dropped from the black baseline — rides along

[FIRST-PRINCIPLES-REVIEWED] 1b56d95

Description read

[DESCRIPTION-READ] 21f11d16de4cd4618df1ff466133c08a23175e0db4002e8481298bfce1b96607

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 Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

Guessed-tier remotes seed the shared _UPSTREAM_REMOTE cache, so sync and ahead/behind act on a remote the snapshot itself says is never acted on.

Watch

  • _resolve_base_branch runs _UPSTREAM_REMOTE = remote whenever base is not None, but tiers 2–3 return remote or "origin" under a comment saying "the remote is carried for shape only … never acted on here." On the fork layout this PR reasons about (remotes fork+upstream, no origin, local main with branch.main.remote = upstream), the seed is the literal "origin", so the sync fetch (worktree_ops.py:2841), _git_info behind counts, and owner/html derivations target a remote that does not exist — paths that previously worked via branch.<base>.remote. Rebase is gated on positive; these consumers are not.
    Clears when: the cache is seeded only on a positive (tier-1) snapshot, letting _upstream_remote()re-derive frombranch..remote on guesses — with a test for the no-origin layout.
  • Pinning gpg.program/gpg.*.program to true in _GIT_ENV_NEUTRALIZERS overrides the operator's global signing config on every git call, including the writes: with global commit.gpgsign=true, the rebase replay and sync merge exec true, git sees no SIG_CREATED, and the operation fails ("gpg failed to sign the data") where it previously signed and succeeded. The PR's threat is verification on reads; the pin also reaches signing on writes, undocumented in description and spec.
    Clears when: the signing path is decided deliberately — pin commit.gpgsign=false beside the program pins (unsigned replays, stated in dev-fleet.md) or demonstrate a signing-enabled rebase still succeeds.

[DESIGN-REVIEWED] 1b56d95

Description read

[DESCRIPTION-READ] 4fa23ed7c8e998e61b793624b8f8a850db2825325bd5987c82592c328f83fb16

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 Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

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

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1b56d95

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

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No blocker; three added prose statements in the base-branch resolver contradict the code beside them.

FINDING — src/kiro_crew/apps/builtins/dev_fleet/repository.py:578 — _resolve_base_branch's own docstring states "origin is therefore the only remote consulted, or the sole remote of a checkout that has exactly one under another name" (and docs/system-specs/modules/dev-fleet.md's tier-1 table row repeats it as "ls-remote --symref on origin, or the sole remote under any name"), while the code it documents reads branch.{checked_out_branch}.remote first at repository.py:685 and consults that remote, reaching the origin/sole-remote fallback only if not remote — so a maintainer asking "which remote decides the base?" is given the opposite rule by both the docstring and the spec → Fix: reword the docstring paragraph and the tier-1 table row to the two-pass, configured-remote-first order the paragraph below the table already describes.

FINDING — src/kiro_crew/apps/builtins/dev_fleet/repository.py:751 — the second pass's comment (and the spec sentence "only a match earns the positive (paired with that remote)") claims a comparison the code never makes: if _plausible_branch_name(base_head): return base_head, True, base_remote returns a positive verdict for whatever the base's own remote advertises even when it differs from the first pass's head, which the PR's own test_the_base_branchs_own_remote_decides_not_the_checkouts pins (origin says main, upstream says release, result is positive release) → Fix: drop "only a match earns the positive" from the comment and the spec, since the code deliberately takes the base remote's answer.

FINDING — src/kiro_crew/apps/builtins/dev_fleet/repository.py:785 — tier 2 returns its remote with the comment "the remote is carried for shape only … the remote is never acted on here", but _resolve_base_branch unconditionally seeds _UPSTREAM_REMOTE = remote from that same non-positive snapshot at repository.py:626 (under a comment claiming it is seeded only when "a real remote was consulted"), so a tier-2 remote — resolved from branch.<checked-out>.remote, not branch.<base>.remote — becomes the remote _upstream_remote() hands to _git_info's behind count, _repo_owner_name's gh --repo, _load_fallback_repos and the sync fetch → Fix: reword both comments, or gate the seed on positive so _upstream_remote re-derives from branch.<base>.remote on a guessed base.

[OPUS-REVIEWED] 1b56d95

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

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

@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from a4a169b to 6988563 Compare September 24, 2026 13:53
@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 Sep 24, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Both blocking findings on the previous head are FIXED, not deferred. Verified against the code before acting, and each fix is mutation-verified by a new pin.

F1 -- read-only adoption retained write paths. Confirmed on both halves.

The index-write half: git status refreshes the index's stat cache and saves it back under index.lock, and _git_info runs one per fleet row, so a read-only checkout was modified on the ordinary path. Reads now go through _git_read, which prepends the global --no-optional-locks; the four status call sites (_git_info, _real_dirty, the tracked-dirt split, and the rebase precondition in worktree_ops) all use it. Pinned by test_status_reads_suppress_the_index_write, which asserts the flag's position in the argv, plus a source check that no status read bypasses the variant.

The gateway half: handle_make_live is the only gateway route that resolves the checkout, and it reached live._make_live -> _find_worktree_by_path without crossing hmac_proxy_middleware, which is where the non-GET refusal lives. The refusal now sits in _ensure_repo, the step any gateway route needing a resolved checkout must take, so a route added later inherits it. Same 409 repo_read_only shape as the backend surface. Pinned by test_gateway_repo_resolution_refuses_a_read_only_checkout, both directions.

F2 -- first remote could select the wrong rebase base. Confirmed. git remote lists names alphabetically, and the loop took the first remote that published a HEAD, while _upstream_remote resolves branch.<base>.remote independently and falls back to origin. /rebase combines the two into {remote}/{BASE_BRANCH}, so an archive or fork remote sorting before origin and publishing a different default sent the rewrite at a base the upstream never published -- and a surviving stale origin/<other-name> let the fetch step succeed.

Exactly one remote is now consulted: origin, or the sole remote of a checkout that has one under a different name. Several remotes with no origin is ambiguous, so it falls through to the local candidates, which composes with the remote read by construction -- _upstream_remote then resolves the remote that local branch tracks. Pinned in all three configurations by test_base_branch_ignores_a_remote_sorted_before_origin, test_base_branch_reads_a_sole_remote_under_another_name and test_base_branch_falls_back_locally_when_no_remote_is_unambiguous.

Also on this head: the six inclusive-language violations are down to one line that needs the literal branch name, carrying the sanctioned same-line marker; test/test_dev_fleet_repo_accessor.py is pruned from the black baseline, which the gate demanded once the file graduated to black-clean; and the two test_dev_fleet_app.py payload tests now patch _repo_read, the accessor the displayed path reads, with redaction unchanged.

The branch is rebased onto ad164a7f57c88bea131511a84162151d722d5ac2 because the push gate requires the single commit to sit on the freshly fetched base. Main's one new commit touches five files with zero overlap with this change.

@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 Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from 6988563 to a12c42b Compare September 24, 2026 14:23
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Head a12c42b3ca759634fc63fbac62b150c05536aeb2. Both blocking findings on the previous head are FIXED, and the 28 test failures the previous head introduced are cleared at their root cause.

F2 (upheld) -- read-only denials bypass SEL auditing. Correct, and correct on its own terms: hmac_proxy_middleware already SEL-audits its own HMAC denials at the _deny helper, and the RepoReadOnly branch a few lines below returned 409 with no event. That denial is a permission decision on an already-authenticated request, taken before any handler runs, so nothing downstream could have recorded it either. It now emits log_tool_invocation(outcome="denied", tool_name="dev-fleet:repo-read-only") with the method and path as resources, wrapped so a failing sink cannot mask the 409. Pinned by test_read_only_denial_is_audited, which also asserts the wrapper is present.

F1 (flagged) -- sensitive repositories bypass the path-access gate. Fixed rather than argued, even though the adjudication flagged the reachability: the conjunction it names (a path that is both a real git checkout and a gate-sensitive leaf, named in write-protected config) is not something the code should depend on remaining empty. ensure_main_repo_discovered now calls sensitive_path_refusal(discovered) before it builds the adoption message, and a fenced path is refused OUTRIGHT as unreadable rather than served read-only -- reading it is exactly what the fence forbids, and the fleet's own reads would disclose its worktrees, branches and PR state. The gate is the centralized definition and canonicalizes first, so a link into a fenced tree answers like the tree; it refuses fail-closed when it cannot decide in time, and that answer is taken as given. Pinned by test_read_only_adoption_asks_the_central_path_gate, which asserts the gate call precedes the adoption message, and test_a_fenced_path_is_refused_outright.

The 28 shard failures were mine, and the fix is a different spelling of the same guarantee. test/test_dev_fleet_server_coverage.py stubs git with helpers that read args[0] as the subcommand. The previous head's _git_read prepended the global --no-optional-locks into that argv, so every stub stopped recognising the status call, and the dirty split, the rebase precondition and every discard test that depends on them failed across the Linux and Windows shards -- one cause, 28 symptoms, in a file this change does not own.

_git_read is removed. The guarantee now sits on _GIT_ENV_NEUTRALIZERS as GIT_OPTIONAL_LOCKS=0, the dict _run_cmd merges into the env of every git this handler spawns, beside the existing core.fsmonitor=false pin that is the same class of "do not let git write to this repo on a read". Git honours the env var exactly as it honours the flag. The argv keeps naming its subcommand, so all 28 pass untouched, and a git read added later inherits the pin instead of having to remember a flag. Measured: test/test_dev_fleet_server_coverage.py plus the two repointed payload tests, 260 passed; the accessor file, 29 passed.

One unrelated red on the previous head is worth recording rather than acting on: test_black_fleet_budget.py::test_real_spawn_recycles_and_propagates_failures[death] failed on shard 8 with ValueError: invalid literal for int() with base 10: '' -- a real-spawn test reading an empty value where it expects an integer. That file is not in this change and nothing here touches spawn recycling. This round re-measures it.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from a12c42b to 0d9fec8 Compare September 24, 2026 15:31
@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 Sep 24, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

Head 0d9fec80c6546e501d85ba4bc30b56c20d568127. All six findings across both reviewers are FIXED, none deferred, none disputed. Each was read against the code first; every one held.

Event-loop block (GPT F3 upheld, Opus BLOCKING 1). Correct and mine. I read the sensitive_path_refusal docstring as "safe from the loop" when what it says is that it BOUNDS itself -- _run_resolution_bounded waits with future.result(timeout=...), up to the per-resolve timeout and the 12s cumulative cap, on the CALLING thread, and my call sat in the coroutine body while holding _DISCOVERY_LOCK. The three probes four lines above it are in an executor hop for exactly this reason. It now returns from that same hop as a fourth element. No new state, no new branch.

Protected linked worktree bypasses the gate (GPT F2, fenced-upheld). Correct, and the ordering is as described: _resolve_primary_checkout rewrites discovered to the primary before the gate reads it, so a fenced linked worktree was cleared by a path that is not it. _fenced_reason(configured, discovered) now asks about the operator's own spelling first and the normalized primary second, and refuses on either.

Repo-local executable git filters (GPT F1, fenced-upheld). Correct: filter.<driver>.clean/.smudge/.process are commands, repo-local config is honoured by git itself, and _git_info's git status is a content-touching read that runs them. The neutralizers pin the named vectors but cannot enumerate driver names. _configured_filter_commands reads --local and --worktree -- the scopes the repository controls, not the operator's global -- and a non-empty result refuses the adoption outright rather than serving it read-only, because a read that executes the repository's own code is not a read-only claim. Reading config executes nothing, which is what makes asking first sufficient. An unanswerable probe returns a reason string, so it refuses rather than clears.

Make Live's 409 bypasses SEL (GPT F4, fenced-upheld). Correct: last round I audited the backend middleware's denial and not the gateway's, and the gateway's returns before the route reaches _audit. Both now emit log_tool_invocation(outcome="denied", tool_name="dev-fleet:repo-read-only"), each wrapped so a failing sink cannot mask the 409.

The read-only latch killed the reopen-on-changed-config self-heal (Opus BLOCKING 2). Correct, and the sharpest of the six. A read-only adoption sets _REPO_READ_ONLY_MSG and leaves _REPO_INVALID_MSG None, while both reopen gates -- the entry gate and _invalid_resolution_is_stale -- key on the invalid message alone. So this PR removed the self-heal for exactly the input it added: an operator who corrects a typo keeps serving the stranger's repository, with BASE_BRANCH, the upstream remote and the fallback repos latched to it, until a restart. Both gates now key on the disjunction.

A resolver stall latched as "protected location" (Opus FINDING). Correct. sensitive_path_refusal returns the unverifiable-path string on a stall, and I composed it into a permanent "is a protected location" refusal -- a verdict asserting a measurement nobody took, with the retry the gate itself advises made impossible. It now branches on is_unverifiable_path_refusal, says the verification did not complete, and leaves _DISCOVERY_DONE unset so the next poll retries.

read_only_reason has no consumer (Opus FINDING). Correct as stated, and the reviewer's cheaper half is the right call: the SPA reads neither read_only_reason nor repo_read_only, and null is falsy at !w.is_live && !w.is_staged, so the row rendered as "nothing is live" and still offered Make live. live_state_known is now false on a read-only checkout, which the page ALREADY consumes -- it disables both the header control and the row action and renders the reason. No SPA change. The full SPA half stays a follow-up; what is no longer deferred is the button that 409s.

Also this round: rebased onto c54439c45544e139f68b43ff2621b69a8b0511a3 because the push gate requires the single commit to sit on the freshly fetched base. Main's two new commits touch 30+ files with zero overlap with the ten here. Local: the accessor file 35 passed; the two dev-fleet suites 691 passed, 1 skipped, and one failure that is this machine's home-path symlink rather than the diff (test_trusted_bin_pins_the_resolved_target_not_the_symlink, green in CI).

@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 Sep 24, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from 0d9fec8 to 76834a5 Compare September 24, 2026 17:45
@chenmingwei23
chenmingwei23 requested a review from a team September 24, 2026 17:45
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Sep 24, 2026
@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 Sep 25, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from e045df6 to db63cae Compare September 25, 2026 00:40
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Sep 25, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from db63cae to 7b1aba5 Compare September 25, 2026 01:56
@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 Sep 25, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch from 7b1aba5 to a702d94 Compare September 25, 2026 03:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 25, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/dev-fleet-generic-repo-read-7428 branch 2 times, most recently from 69633a2 to 4e358d3 Compare September 25, 2026 06:08
@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 readiness: checking Automated validation is still running labels Sep 25, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt acf2e04: F1: Sync's gate (worktree_ops.py:1741) refuses unless the checkout's HEAD equals BASE_BRANCH, and tier-3 sets BASE_BRANCH to that checked-out branch, so the guessed base can only --ff-only (worktree_ops.py:1884) the branch already checked out -- nothing is rewritten or lost. The _BASE_BRANCH_POSITIVE gate buys nothing over that equality gate and disables Pull+Build on every checkout with no published remote HEAD, so per this PR's option-C ruling it adds a guard without removing a hazard.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@chenmingwei23 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for acf2e04bcf809ed055908e732228eaa11dec7ba8.

F1: Sync's gate (worktree_ops.py:1741) refuses unless the checkout's HEAD equals BASE_BRANCH, and tier-3 sets BASE_BRANCH to that checked-out branch, so the guessed base can only --ff-only (worktree_ops.py:1884) the branch already checked out -- nothing is rewritten or lost. The _BASE_BRANCH_POSITIVE gate buys nothing over that equality gate and disables Pull+Build on every checkout with no published remote HEAD, so per this PR's option-C ruling it adds a guard without removing a hazard.

This decision applies only to this commit. A new push requires a new judgment.

…r repository

Four fixes that each stand on their own. The foreign read-only checkout mode this
branch previously carried is GONE: its hazard class was the clearance's vetted bytes
never binding to what git actually parses, and three review rounds found that same
invariant at a new site each time. Removing the mode removes the class. The parts
below never depended on it.

1) Signature verification could exec a program the repository names.

`.git/config` is agent-writable, which is the premise `core.fsmonitor` and
`core.hooksPath` are already pinned on. `[log] showSignature=true` makes every
`git log` verify what it prints, and verification EXECS `gpg.program`. All four
spellings are pinned, because `gpg.<format>.program` selects per format and
`gpg.openpgp.program` is a synonym that OVERRIDES the bare key -- pinning one leaves
the other as an unpinned way to name the same exec. The trigger is pinned beside the
programs: `true` is a value, and this is a place not to depend on one.

2) A read wrote to the repository.

`git status` refreshes the index's stat cache and saves it back under `index.lock`,
so a command that is a read to its caller is a write to the repository. Every fleet
render runs one per row, so the fleet contended with the operator's own git for the
lock on the ordinary path. `GIT_OPTIONAL_LOCKS=0` on the env chokepoint rather than
`--no-optional-locks` per call site, so the argv keeps naming just its subcommand and
a read added later inherits it.

3) An unknown exit status was reported as success.

`proc.returncode or 0` mapped None to 0, and 0 is what every caller here reads as
"that worked": a row would report a clean tree, and a mutation's caller would go on to
the next step, on the strength of an exit status nobody ever saw. None is reachable
after `communicate` returns on a child the loop has not reaped yet.

4) A remote URL's query rode into an href and into child argv.

PRE-EXISTING on main, with three derivation sites. `git remote set-url` accepts a
query and smart-HTTP honours it, so an operator's own remote can hold
`?access_token=...` -- a PAT in the URL is a common way to make unattended https
pushes work. Every pattern here anchors on `$`, so a retained query keeps `.git` from
stripping AND rides into the result. Measured on main: `https://h/o/r.git?access_token=X`
produced the href `https://h/o/r.git?access_token=X` and the `gh --repo` value
`o/r.git?access_token=X`. `runtime.remote_url_locator` is the one home of the rule,
in the module both importers share, because `fleet_state` imports `repository` and the
reverse is a cycle -- a rule that cannot be shared gets copied, which is how three
sites each ended up with their own suffix pattern.

5) The base branch was the literal `main`.

Resolved per repository instead: `origin`'s published HEAD, else a conventional
candidate that exists, else the checked-out branch. Only `origin` is consulted --
`git remote` lists alphabetically, so listing order lets a fork outvote it, and
`_upstream_remote` falls back to `origin`, so the pair could disagree and a rebase
would target a base the upstream never published. Ordered before `_upstream_remote`,
which reads `branch.<base>.remote` and so cannot run first.

The tiers are not equal, and the difference is recorded rather than re-derived per
consumer: the first two are the repository STATING its default, the last is a guess.
A wrong base costs a caption on a read and a worktree's commits on a rebase, which
returns ok with no rollback once the replay is clean -- so rebase refuses on a guess,
before the fetch, and the refusal clears itself on the next resolution. Every tier's
answer passes an argv guard: a leading `-` reads as an option, and `..` is the range
separator every consumer interpolates around.

Tests: 12 mutations, 12 caught, each asserting it matched exactly one site and each
run required to report an explicit pass/fail count, behind a positive control that
refuses to score anything unless the selectors are green on the unmutated tree
(~/oss/.kc-13348-mutations.py). Two count assertions that had been retyped now derive
from the pinned set, so adding a pin cannot fail them for a reason that is not a
defect. Four rebase tests and one redaction test now state the base branch, because
the new gate sits before their fetch -- one of them had been passing on a global
leaked from another test, which this also fixes.

@bolichen97 bolichen97 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 on behalf of the maintainers (sweep 2026-09-30): readiness passed, required checks green on 1b56d95, no blocking review threads. 493 behind main but merge-tree is clean and the PR's 5 test files pass on the merged tree (838 passed). The gpg-program / showSignature pin, optional-locks, returncode and URL-token strip are bypass/leak fixes; the rebase refusal on an unadvertised default branch is a correctness guard against an irreversible wrong-base rewrite, not a new security gate. Approving and merging.

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