Skip to content

kettle-release: name release checkout topologies; 3.1.22 lockfile revalidation breaks monorepo family publishes (detached worktree) #52

Closed

Description

@pboling

Summary

kettle-dev 3.1.22 added revalidate_publish_lockfile_changes!, which runs ensure_trunk_synced_before_push! + push! + monitor_workflows_after_push! whenever publish-time lockfile normalization detects drift. In a monorepo family member publish the release child runs in a detached-HEAD worktree (git worktree add --detach, kettle-family workflow.rb), so:

  1. push! runs git push origin HEAD — fails ("The <src> part of the refspec is a commit object"), warns, force-retries, fails again, and continues (the retry result is never checked).
  2. monitor_workflows_after_push! → ensure_ci_trigger_for_release_branch! sees branch "HEAD" ≠ trunk "main" → not a declared branch-stack target → falls into validation-PR creation: gh pr create --head HEAD --base main → GraphQL: Head sha can't be blank … Head ref must be a branch → wave aborts.

Observed 2026-10-22 releasing structuredmerge-ruby 7.1.16 (34-member monorepo wave, died at tree_haver release_publish). 7.1.15 predates 3.1.22; kettle-dev's own family is sibling-repos mode (members release on-branch), so this was the first monorepo wave to exercise the new path. It re-triggers deterministically whenever any registry gem publishes between family bup and the publish phase, because the child's bundle lock --update then changes the worktree locks.

Root cause: the topology split was never named

The release flow operates in distinct checkout topologies, but the code only knows two predicates — branch_stack_release_branch? and local_ci? — and collapses everything else into branch == trunk?. A family_worktree marker already exists in the environment (KETTLE_RELEASE_FAMILY_MEMBER_PUBLISH=true), yet new code has no named concept to consult.

Two orthogonal axes need naming:

  • Release target: trunk (release on main), feature (branch merged into trunk mid-flow), branch_stack (declared long-lived release branch, never merged)
  • Checkout form: primary (the repo's own checkout), family_detached_worktree (monorepo member publish; family orchestrator owns trunk state, tags, pushes, GitHub Release — see the architecture comment on run_family_member_finalize), plus local_ci as a remote-ops-off modifier

Branch-stack members (rubocop-lts) release from their own checkout switched to the release branch, so branch push works there; the monorepo detached worktree is the only form with no branch identity at all.

How family detached-worktree release is supposed to work

Commit/push and releasing are inseparable — and they all happen on the branchful primary checkout: the family orchestrator commits and pushes version bumps, changelog prep, and lockfiles from main before/between member publishes, owns the shared tag, and finalizes checksums serially in the primary checkout (run_family_member_finalize). The detached worktree child is intentionally reduced to build + gem push (run_family_member_publish): lockfile normalization must be verify-only there, because worktree commits are void (the tree is deleted after the run) and branch pushes are meaningless. 3.1.22's revalidate broke that contract by importing the standalone flow's commit-and-push-CI response into the publish boundary unconditionally.

Divergence points that don't account for topology (audit)

  1. revalidate_publish_lockfile_changes! — pushes/monitors from any checkout form (this bug).
  2. push! — swallows both normal and force push failures (warn only), so a detached push origin HEAD fails twice and the flow continues; the explosion surfaces later in gh pr create, far from the cause.
  3. ensure_ci_trigger_for_release_branch! — anything not-trunk-not-stack falls into validation-PR creation, including detached "HEAD" (family or manual).
  4. close_generated_branch_stack_pull_request! — gated on branch_stack_release_branch?, but create_github_pull_request! also fires for feature branches, so feature validation PRs are never closed by the tool; failure paths never close PRs either; and merge_feature_into_trunk_and_push! relies on "the PR (if any) should auto-close" and never deletes the merged branch (remote or local). Branches/PRs are left open three ways.
  5. commit_release_prep! / commit_bundle_update! — in a family worktree these commit into the void, so drift re-triggers on every rerun.
  6. Steps 8/11/12 gate only on local_ci? and branch-stack; in a family worktree, step 11's checkout!(trunk) would fail outright ("already checked out" in the primary worktree) if reached.

Proposal

Resolve a ReleaseTopology (target × checkout form × modifiers) once at flow start and make every topology-sensitive step consult it instead of ad-hoc branch == trunk checks:

  • family_detached_worktree: lockfile normalization is verify/build-only; never commit-to-persist, never push branches, never open PRs, never merge. On drift, either proceed with worktree-local locks (the built gem does not embed the dev lockfile) or fail fast naming the family-side normalization step — but never the standalone push+CI-revalidate dance.
  • feature: merge into trunk, close the validation PR (success and failure paths), delete the merged branch.
  • branch_stack: dispatch/dispatch-PR as today, plus close the validation PR on failure too.
  • Manual detached HEAD outside a family context: abort early with a clear message instead of wandering into the PR path.

Immediate unblock is the family_detached_worktree row, but implemented as the named profile — not an if detached hack — so the next topology divergence is visible at review time.

Related follow-up (separate issue)

A generic pre-release hook mechanism (e.g. release.preflight_hooks in family config: command + phase + commit/push policy) so families can declare their own maintenance commands — kettle-dev/kettle-family should ship only the mechanism and never know about any specific tool's preflight needs (e.g. a family that ships a templating tool wires its own floor/pin refresh commands there).

Activity

  1. pboling commented on Oct 23, 2026

    @pboling
    MemberAuthor

    Fixed in v3.1.23 (db4bbd6). The publish-boundary lockfile revalidation now skips branch operations (commit/push/CI-retrigger) in detached checkout topologies — family member worktrees and bare detached HEAD — keeping drift checkout-local as the contract requires. Verified by new specs covering both topologies, and the fix shipped inside the 3.1.23 release it was blocking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions