Skip to content

fix(roadmap): the job clone tracks the current release's branch while origin has it and the default branch otherwise, so close, refine and metrics run between a ship and the next release's start #1366

Closed

Description

@dan-petty

Problem

ensure_checkout (src/devops_cli/roadmap/run.py:184-251) prepares the per-repository clone for every row that sets needs_clone: close (:518), refine (:529), and metrics once #1358 lands. It runs git fetch origin (:207). If a current release exists, it then runs git checkout -B release/<v> origin/release/<v> and git reset --hard origin/release/<v> (:215-236). Any non-zero exit raises GitOperationError.

The rule trusts the remote-tracking ref origin/release/<v>. Between a ship and the next release's start, that ref is first stale and then missing.

How a ship moves the branch.

  • The current release is the lowest open milestone (current_release, src/devops_cli/roadmap/reprioritize.py:438-441). It is read once per round, before any row runs (run.py:828).
  • Only reprioritize creates release/<v>, when it starts a release. _branch_writes (reprioritize.py:1640-1647) creates it at the default branch head and is called from _plan_start (:1756). The first pull request into release/v0.2.28 was opened at 17:26Z on 2026-10-06, after the Service had started that release. No pull request targets release/v0.2.29 yet.
  • This repository deletes a head branch when its pull request merges (delete_branch_on_merge: true, checked 2026-10-08). So merging the release pull request deletes release/<shipped>. release.yml then publishes the GitHub Release and closes the milestone (.github/workflows/release.yml:126).
  • So each ship has two phases:
    1. Merge to milestone close: a stale ref. The shipped release is still current. git fetch origin does not prune (:207; the image sets no fetch.prune), so the clone keeps origin/release/<shipped> and the checkout succeeds on the deleted branch's last commit.
    2. Milestone close to the next start: no ref. The next release is current and has no branch. git checkout -B exits 128 with 'origin/release/v0.2.29' is not a commit and a branch 'release/v0.2.29' cannot be created from it (reproduced on 2026-10-08 against a bare remote in a temporary directory).
  • With no open milestone (current_rel is None), ensure_checkout fetches but never moves the working tree (run.py:215). refine then reads whatever commit the clone last had.
  • What a checkout failure does:

Phase 1 fired on 2026-10-06.

  • Release pull request feat(release): v0.2.27 #1257 merged at 15:55:58Z, and release/v0.2.27 was deleted at 15:56:01Z. The v0.2.27 milestone stayed open until 16:29:22Z, so v0.2.27 was still the current release.

  • The Service ran the v0.2.26 image; the close tracebacks match its release.py:1080 and :1387. Its close hold looked for a chore/cut-v0.2.27 pull request rather than the release pull request (release_cut_branch became release/vX in feat(release): v0.2.27 #1257). So close was already re-cutting v0.2.27 on every poll before the merge.

  • After the deletion it kept going. Between 15:56 and 16:29Z, Loki has:

    • 9 Created and checked out release branch chore/cut-v0.2.27 lines;
    • 9 (stale info) push rejections;
    • close failures at 15:58:11, 16:02:07, 16:06:04, 16:11:09, 16:14:32, 16:17:50, 16:22:31, 16:26:59 and 16:29:55Z.

    Each time, ensure_checkout and the cut's own existence check both passed on the stale origin/release/v0.2.27, and close re-cut a release that had already shipped.

  • The cut's check cannot catch this. _fetch_remote_release_tip (src/devops_cli/commands/release.py:1097-1119) runs git fetch origin release/v<version> with check=False and never reads the exit code. It then accepts git rev-parse --verify --quiet origin/release/v<version>, and a stale ref satisfies that (reproduced against a bare remote). So it fails closed for a missing branch only in a clone whose remote-tracking refs are pruned. That is weaker than fix(release): one fail-closed release path: cut branch from the remote release tip, uv.lock bump, draft flag, required label and milestone #982's "one fail-closed release path".

  • Today the re-cut itself is held. Since v0.2.27 the cut branch is release/vX (src/devops_cli/roadmap/store.py:196-198), so the merged release pull request matches the PR_MERGED hold (src/devops_cli/roadmap/close.py:340-352). The stale ref is still what refine reads in phase 1, and what the cut's check trusts in any unpruned clone.

Phase 2 has not fired yet, but the window is real.

  • 2026-10-07/08. feat(release): v0.2.28 #1283 merged at 23:43:26Z, release/v0.2.28 was deleted at 23:43:29Z, and the milestone closed at 23:44:21Z. release/v0.2.29 did not exist until a person ran devops roadmap reprioritize --confirm at about 00:37Z. Milestone v0.2.32 was created at 00:37:36Z, and release/v0.2.29 still points at the v0.2.28 merge commit. The window lasted about 53 minutes.
  • 2026-10-06. The Service started v0.2.28 itself, about 4 minutes after the v0.2.27 milestone closed: the machine account created milestones v0.2.30 and v0.2.31 at 16:33:28Z. No clone row failed in between.
  • Loki, 2026-10-04 to 2026-10-08.
    • Every round record that names close follows close's own Roadmap job close failed traceback.
    • Refine's round records outnumber its tracebacks by exactly one, at 2026-10-05 06:26:28Z. That failure was in the clone step, the only path that logs nothing (run.py:766-767), and its cause is not recorded.
    • The rounds at 06:22:43Z and 06:28:49Z reached refine's own code on the same current release, so that failure was not a missing branch.

Starting the release sooner (#1360) narrows phase 2 but cannot close it.

  1. close already runs before reprioritize (DEFAULT_DUE_TABLE, run.py:508-537), and fix(roadmap): a shipped release starts the next one without a person: the poll reports the ship, and close and reprioritize run before a capped intake batch #1360 keeps that order. close is due on the release pull request's pull_request closed webhook (CONST_ROADMAP_CLOSURE_BATCH_KEYS, src/devops_cli/config/constants.py:2459-2461) and every hour. So in a round where close is due and reprioritize starts the release:

    • close fails, because the branch does not exist yet;
    • refine and metrics fail on the reused error, even though the branch exists by the time they run.

    This is a defect of today's code, not something fix(roadmap): a shipped release starts the next one without a person: the poll reports the ship, and close and reprioritize run before a capped intake batch #1360 introduces.

  2. The start depends on reprioritize succeeding. Between 2026-10-05 and 2026-10-08, reprioritize failed 9 times for reasons unrelated to releases:

    • the GraphQL reserve (2026-10-06 17:20Z, 2026-10-07 22:44Z, 2026-10-08 01:08Z and 01:36Z);
    • REST timeouts (2026-10-07 03:58Z, 04:21Z, 04:33Z);
    • a board that changed while it was being read (2026-10-05 04:19Z);
    • a broken rate-limit state (2026-10-05 04:37Z).

    While reprioritize fails inside the window, close, refine and metrics fail with it on every poll.

  3. _plan_first_run (reprioritize.py:1773-1800) records a release that is already under way but does not create its branch. Suppose the Service starts managing a repository whose lowest open milestone has no release/ branch. close and refine then fail on every poll until that release ships. (Not checked against the managed repositories.)

The clone does not need the current release's branch.

  • close uses the clone only to cut (run.py:368-393), and the cut fetches release/v<version> and checks it out itself (release.py:1488-1491). In phase 2 close has nothing to close. It reads the pull requests merged into release/<current> (close.py:308-312), and nothing can merge into a branch that does not exist.
  • refine reads the code at the clone's HEAD and records the SHA and branch it read (src/devops_cli/roadmap/refine.py:171-196, :576). A detached HEAD is recorded as HEAD (:194-196).
  • metrics reads tags (fix(roadmap): the metrics job walks release tags in each repository's own clone, and a missing or type-less labels.yml stops intake as a configuration error before any model call #1358), and tags do not depend on the branch.
  • In phase 2 the release's code is the default branch head, because _branch_writes creates the branch at exactly that commit (reprioritize.py:1645). In phase 1 the default branch already holds the merged release.

Re-scope note.

Acceptance criteria

  • Checkout rule. ensure_checkout runs git fetch --prune origin and git remote set-head origin --auto, and reads the default branch name from git symbolic-ref --short refs/remotes/origin/HEAD. Then:

    • if the current release's release/<v> exists after that fetch (git rev-parse --verify --quiet refs/remotes/origin/release/<v>), it checks that branch out and hard-resets to it, as it does today;
    • otherwise, including when no release is open, it runs git checkout -B <default> origin/<default> and git reset --hard origin/<default>. HEAD is then the named default branch, never detached;
    • when a release is current but its branch is absent, it logs one INFO line naming that release and the default branch it checked out;
    • a failed fetch, set-head, symbolic-ref, checkout or reset still raises GitOperationError. Only a branch found absent after a successful pruning fetch selects the default branch.
  • The cut's branch check fails closed. _fetch_remote_release_tip (release.py:1097-1119) reads the exit code of git fetch origin release/v<version>. When it is non-zero, the cut stops with an error that carries git's message, before rev-parse or any checkout. A stale remote-tracking ref then cannot pass for a deleted branch in any checkout, pruned or not.

  • Checkout tests in tests/test_roadmap_run.py. They run real git against bare remotes in tmp_path, fake the gh api user login at the process edge, and patch no devops-cli name (test(cli): tests double only process edges and mirror the source tree #1307).

    • _make_bare_remote (:78) runs git init --bare --initial-branch=main and pushes main as well as the release branch. Today's helper pushes only the release branch, so the bare HEAD dangles, and git remote set-head origin --auto exits 1 with "Cannot determine remote HEAD" (reproduced 2026-10-08). The existing checkout tests depend on this change.
    • Each case asserts the clone's HEAD SHA and that git rev-parse --abbrev-ref HEAD prints the expected branch:
      • (a) The current release has no branch on the remote. HEAD is main's tip on main, nothing raises, and caplog holds one INFO line naming the release and main.
      • (b) The remote then gains release/<v>. The next call puts HEAD on release/<v> at that branch's tip.
      • (c) The remote deletes release/<v> while that release is still current. HEAD is main's tip on main, and git rev-parse --verify --quiet refs/remotes/origin/release/<v> fails in the clone.
      • (d) No release is open, and the remote's main moves. HEAD is the new tip on main.
      • (e) The remote path is removed. GitOperationError is still raised; this is the existing case in test_checkouts_git_management (:562).
  • Cut check test. In a clone that still holds origin/release/<v> after the bare remote deleted that branch, the cut's branch check exits 1 and creates no cut branch. It follows the same edge rules as the checkout tests.

  • Run-level test. Call run_due_jobs with:

    • build_stub_table(..., needs_clone=True) with close, reprioritize and refine stubs;
    • a store whose current release has no branch on the bare remote;
    • a ("webhook", "pull_request", "closed") batch. It makes close and reprioritize due, and refine follows because reprioritize ran (_refine_cross_job, run.py:303-310).

    The reprioritize stub pushes release/<v> to the bare remote at main's tip. close and refine both receive the same clone_path, whose HEAD is main's tip on main, and no RoadmapRunError is raised.

  • devops roadmap run --dry-run still runs no git command (run_due_jobs returns at run.py:835, before _execute_due_rows).

  • Gate.

    • No test reaches the network.
    • Each new test's call phase stays under 1 s (uv run pytest tests/test_roadmap_run.py --durations=10, plus the cut check test's file).
    • uv run devops ci passes within its 5-minute budget.
  • changelog.d/<n>.md exists. CHANGELOG.md and docs/ROADMAP.md are untouched (uv run devops pr check-readiness passes).

  • Pending a person, after merge. Run this once the Service runs a release image that contains the fix. Check the next ship, from the release pull request's merge until the next release starts; until then, gh api repos/dan-petty/devops-cli/branches/release%2Fv<next> returns 404.

Key questions

Strategic alignment

Update 2026-10-08: narrowed by #1124

#1124 delivers this item's "the cut's branch check fails closed" criterion. The release command's git fetch origin release/vX.Y.Z now goes through _run_remote_git_or_exit and stops the cut with git's reason on failure, and real-git tests cover a remote that deleted the release branch and a clone whose refspec fetches only main. This item keeps the Service clone's checkout rule (ensure_checkout in roadmap/run.py), its tests and live checks. When implementing, take the cut-check criterion as done and do not re-implement it.

Update 2026-10-08: delivered scope

Activity

  1. added
    type/bug
    scope/github
    priority/p2-medium
    scope/release
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P1-High. Recurring operational failure that blocks all clone-dependent roadmap jobs for the entire window between a ship and the next release start, with nine observed close failures on 2026-10-06.
    • Value: High. Close, refine, and metrics are core roadmap operations that are completely unavailable during every ship-to-next-start window.
    • Effort: Medium. The fix is localized to ensure_checkout (check whether origin/release/<v> exists before attempting checkout, fall back to default branch), but requires handling both the stale-ref and missing-ref phases plus testing.
  3. added
    source/agent
    and removed
    priority/p2-medium
    on Oct 8, 2026
  4. added this to the v0.2.29 milestone on Oct 8, 2026
  5. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Placed in v0.2.29 by the owner on 2026-10-08. The owner's instruction was to pull every issue that keeps the roadmap service from working into the current milestone and complete them. This is a person's placement and should stay in the release (#1349). Implementation started the same day, so the board Status is In Progress.

  6. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    What changed

    #1412, merged into release/v0.2.29 as 0efc4bb.

    Closes #1366

    The roadmap Service's job clone (ensure_checkout in src/devops_cli/roadmap/run.py) now:

    • fetches with --prune;
    • refreshes origin's HEAD with git remote set-head origin --auto and reads the default branch with git symbolic-ref;
    • checks out and hard-resets to the current release's release/<v> while origin has it, and to the default branch otherwise: between a ship and the next release's start, and while no release is open.

    HEAD is always a named branch. The checkout is forced, so a tracked change a failed job left in the clone is discarded instead of wedging every later round. Branches and origin's HEAD are read as full ref names (refs/remotes/origin/...), so no tag can shadow them. A current release without a branch logs one INFO line naming the release and the default branch.

    Fails closed: only git rev-parse --verify exit 1, after a successful pruning fetch, selects the default branch. Every other failed git command (clone, fetch, set-head, symbolic-ref, rev-parse, checkout, reset, identity write) raises GitOperationError with the command and git's reason, credentials masked. The docstring states the contract the clone rows rely on.

    The cut's branch check was delivered by #1124, as the issue's 2026-10-08 update records; commands/release.py is untouched.

    Tests (tests/test_roadmap_run.py) run real git against bare remotes in tmp_path whose HEAD names main. The session's gh api user login is answered at the `subprocess.run…

    4 file(s) changed.

    How it was verified

    Check runs at 0921053:

    • Prune PR DevContainer Images: pass
    • CodeQL: pass
    • Static Analysis: pass
    • Analyze (actions): pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1366-job-clone-tracks-default-branch.md:

    • Checkout rule. ensure_checkout fetches with --prune, runs remote set-head origin --auto and reads the default branch from symbolic-ref. It checks out and hard-resets to release/<v> while origin has it, and to the default branch otherwise, including when no release is open. A current release without a branch logs one INFO line naming that release and the default branch. A failed fetch, set-head, symbolic-ref, checkout or reset raises GitOperationError, and only rev-parse --verify exit 1 after the pruning fetch selects the default branch.
    • Checkout tests in tests/test_roadmap_run.py, real git, login faked at the process edge, no devops-cli name patched (test(cli): tests double only process edges and mirror the source tree #1307):
      • _make_bare_remote runs git init --bare --initial-branch=main and writes refs/heads/main, then a later commit on release/v0.2.26 unless with_release_branch=False. The remote's HEAD names main whatever the runner's init.defaultBranch.
      • (a)+(b) test_checkout_tracks_the_default_branch_until_the_release_branch_exists: with no release branch, HEAD is main's tip on main with exactly one INFO line naming the repository, v0.2.26 and main. Once the remote gains release/v0.2.26, HEAD is that branch's tip on that branch, and the clone's identity is the faked login.
      • (c) test_checkout_returns_to_the_default_branch_when_origin_deletes_the_release_branch: HEAD returns from the release tip to main's tip on main, and rev-parse --verify --quiet refs/remotes/origin/release/v0.2.26 exits 1 in the clone.
      • (d) test_checkout_follows_the_default_branch_while_no_release_is_open: HEAD follows main to its new tip, with no INFO line.
      • (e) test_checkouts_git_management still raises for a removed remote, failing close and refine. It now asserts the release tip by SHA and branch name.
      • Fail-closed cases that reach the new handler: test_checkout_raises_when_the_fetch_fails_and_keeps_the_branch_it_had (the remote is removed under an existing clone, so git fetch --prune origin failed carries git's reason and HEAD stays on the release branch), and test_checkout_raises_when_origin_head_names_no_branch (a remote HEAD naming a missing branch makes git remote set-head origin --auto fail with "Cannot determine remote HEAD").
    • Run-level test. test_a_round_after_a_ship_runs_its_clone_jobs_on_the_default_branch calls run_due_jobs with build_stub_table(..., needs_clone=True) and close, reprioritize and refine stubs, the seeded store (current release v0.2.26) and a remote without release/v0.2.26. Its batch is {("webhook","pull_request","closed"): 1, ("webhook","milestone","closed"): 1}. The reprioritize stub points release/v0.2.26 at main's tip. Close and refine both receive the same clone_path, whose HEAD is main's tip on main, the round runs intake, close, reprioritize and refine, and nothing raises.
    • devops roadmap run --dry-run runs no git: the same round with dry_run=True plans the same four jobs and starts no git child (the run-level test).
    • No test reaches the network, and each test's call phase is under 1 s. Run serially under a load average of about 30 on 16 cores, the slowest was test_checkout_follows_the_default_branch_while_no_release_is_open at 0.48 s (--durations). Each checkout starts seven to nine git children.
    • changelog.d/1366.md records the fix; CHANGELOG.md and docs/ROADMAP.md are untouched.
    • The cut's branch check fails closed: delivered by fix(release): release pushes run git with the person's environment, so the configured credential helper answers instead of "could not read Username", and a failed push stops release pr before it opens a PR #1124. _fetch_remote_release_tip fetches through _run_remote_git_or_exit, covered by test_release_cut_stops_when_the_release_branch_fetch_fails and test_release_cut_stops_when_the_fetch_writes_no_tracking_ref. This item does not touch commands/release.py.
    • Pending a person, after merge, once the Service runs a release image with this fix (v0.2.29 shipped and Argo CD deployed its service tag): watch the next ship, from the release pull request's merge until the next release starts. During that window, gh api repos/dan-petty/devops-cli/branches/release%2Fv<next> returns 404.
    • Pending a person: kubectl -n devops exec deploy/roadmap-service -- git -C /home/devops/.data/roadmap/dan-petty/devops-cli/clone rev-parse --abbrev-ref HEAD prints main during that window, and release/v<next> after the release starts.
    • Pending a person: kubectl -n devops exec deploy/roadmap-service -- git -C /home/devops/.data/roadmap/dan-petty/devops-cli/clone for-each-ref --format='%(refname:short)' refs/remotes/origin/release/ lists only release branches that exist on GitHub.
    • Pending a person: {namespace="devops", container="service"} |= "has no release/" in Loki shows the INFO line naming the release without a branch and the default branch. If fix(roadmap): the roadmap service logs each failed job's own error with its repository, and a configuration error without a traceback #1365 has landed, no failure record for this repository in that window carries is not a commit.
  7. added a commit that references this issue on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope/githubscope/releasesource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions