Skip to content

fix(sync): auto-resolve post-release main->dev sync conflicts - #1406

Merged
c-vigo merged 6 commits into
devfrom
bugfix/1403-sync-conflict-auto-resolve
Aug 10, 2026
Merged

c-vigo merged 6 commits into
devfrom
bugfix/1403-sync-conflict-auto-resolve

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the deterministic conflicts that make the post-release main → dev sync PR open red on every train (devkit#1395, smoke-test#351). Both root causes from #1403 are addressed; the merge-conflict manual path remains for genuine conflicts.

Cause B — issue/PR snapshot add/add conflicts (every gitflow repo)

sync-main-to-dev.yml (both the canonical copy and the workspace template, kept byte-identical and pinned by a new cross-copy test) gains three steps between branch push and PR creation:

  1. Auto-resolve — re-probes with git merge-tree --write-tree --name-only, parses the conflicted paths, and proceeds only when every conflicted path is a generated snapshot (docs/issues/, docs/pull-requests/) still present on dev (delete/modify stays manual). It materializes dev's side of exactly those paths in the working tree.
  2. Signed commit — vig-os/commit-action (COMMIT_APP token) commits them to the pushed sync branch.
  3. Re-verify — refetches and re-runs merge-tree against the updated branch; only a proven-clean result flips the effective conflict flag consumed by Create PR and Enable auto-merge (falsy-fallback expression keeps today's manual path bit-for-bit when auto-resolve is skipped or ineligible).

Why dev-side wins (deviation from the issue's "main side" suggestion): the Signed commits ruleset (~ALL refs, no bypass actors) means the runner can only produce single-parent GitHub-signed commits via GraphQL — a merge commit taking main's side is impossible. Aligning the sync branch to dev's content makes both merge sides identical, so the conflict vanishes; snapshots are derived artifacts of live GitHub state, and dev's next nightly sync-issues run re-captures anything main had (its updated-since cutoff predates the release-time sync), so nothing is lost beyond a ≤24 h staleness window. Only paths merge-tree reports as conflicted are touched — a snapshot changed only on main still merges cleanly.

Cause A — smoke deploy clobbered the consumer changelog (smoke-test only)

The smoke branch of init-workspace.sh rsynced with --delete and no preserve excludes, then copied devkit's entire changelog over the consumer's root CHANGELOG.md; the prepare-changelog unprepare safety valve no-ops since #590 (first heading is always ## Unreleased). Devkit's dated ## [X.Y.Z](…devkit…) heading replaced the consumer's frozen ## [X.Y.Z] - TBD, colliding with main's finalize rewrite whenever versions coincide — structural for devkit-smoke-test.

Now: root-anchored --exclude='/CHANGELOG.md' (consumer state preserved; .devcontainer/CHANGELOG.md still syncs), scaffold skeleton bootstrapped only when the file is absent, cp+unprepare block deleted. prepare-changelog unprepare loses its only production caller; the vig-utils CLI surface is deliberately untouched (removing a subcommand is out of scope here).

Also fixes the latent unbounded seeding awk in repository-dispatch.yml: the deploy bullet is now bounded at the next ## [ heading and a ### Changed subheading is synthesized when ## Unreleased lacks one.

Rollout timing (corrected)

An earlier draft of this PR claimed the fix only goes live one release late. That was wrong: push-triggered workflows execute the workflow file at the pushed commit, and devkit's own run history proves it — the 1.7.0 promote's sync run executed at headSha bcb0a257, the promote merge commit itself. Since this fix flows dev → release/1.7.1 → main, the 1.7.1 merge commit on main contains the new workflow, so the very sync run fired by the 1.7.1 promote is already the auto-resolving version — full live proof arrives with the next ordinary release, no extra train needed. Cause A proves even earlier, at the first 1.7.1-rc smoke deploy (the installer runs from the tagged tree). The smoke-test's already-copied changelog history is preserved as-is and converges over subsequent releases.

Zero-release proof: replay against the real 1.7.0 conflict

The pre-resolution state of devkit#1395 still exists in history (dc25bfbb's parents: bcb0a257 = main, 665a0901 = dev). Replaying the new auto-resolve pipeline against it:

  • git merge-tree --write-tree --name-only exits 1 and the output matches the parser's format assumption exactly (tree OID, conflicted paths, blank line, informational messages).
  • Parsed conflicted paths: docs/issues/issue-1386.md, docs/issues/issue-1391.md, docs/issues/issue-529.md, docs/pull-requests/pr-1385.md — all inside the allowlist, and issue-529.md is a content conflict (not add/add), confirming both classes are covered.
  • Eligibility loop passes (all paths present on dev).
  • The automated dev-side result is byte-identical on all four files to the actual manual resolution committed in dc25bfbb.

Verification

  • TDD: each fix landed as a failing-test commit followed by the implementation (see commit sequence).
  • tests/test_workflow_sync_autoresolve.py (new, parametrized over both workflow copies incl. cross-copy identity) — 9 passed.
  • Rewritten test_smoke_workspace_changelog_available_in_devcontainer_and_root passed against a freshly built dev image.
  • New bats: smoke deploy preserves a pre-seeded consumer changelog (sentinel + frozen ## [9.9.9] - TBD survive) and bootstraps the scaffold when absent; seeding-awk shape pinned in just.bats. The new awk was additionally exercised against three fixtures (skeleton present / missing ### Changed before a released section / Unreleased at EOF) — bullet lands inside Unreleased in all three.
  • Full local gates: pre-commit run --all-files green; fast pytest 510 passed; vig-utils 566 passed (untouched); just.bats 54/54; rendered-template + smoke actionlint (Adopt actionlint for authored and per-mode rendered workflow templates #995) green; full init-workspace.bats green.

Refs: #1403

c-vigo added 6 commits August 10, 2026 15:40
Smoke deploys must treat the consumer's root CHANGELOG.md as consumer
state: preserved across deploys, bootstrapped from the scaffold skeleton
only when absent, and never a copy of devkit's own changelog. The
rewritten integration test replaces assertions that encoded the buggy
copy-devkit-history behavior.

Refs: #1403
…loys

The smoke branch rsynced with --delete and no preserve excludes, then
copied devkit's entire changelog (.devcontainer/CHANGELOG.md mirror)
over the consumer's root CHANGELOG.md. The prepare-changelog unprepare
safety valve no-ops since #590 (the first heading is always
## Unreleased), so devkit's dated/linked ## [X.Y.Z] headings replaced
the consumer's frozen ## [X.Y.Z] - TBD heading — colliding with main's
finalize rewrite of the same line and guaranteeing a main<->dev sync
conflict whenever the versions coincide (structural for
devkit-smoke-test).

Root-anchor a /CHANGELOG.md exclude on the smoke rsync (consumer state,
shielded from copy and --delete; .devcontainer/CHANGELOG.md still
syncs), bootstrap the scaffold skeleton only when the file is absent,
and drop the cp + unprepare block. prepare-changelog unprepare loses
its only production caller; the vig-utils CLI surface is left untouched
deliberately (removing a subcommand is out of scope for this bugfix).

Refs: #1403
The deploy-entry seeding awk must be bounded at the next release
heading and able to seed an Unreleased section that lacks a
### Changed subheading.

Refs: #1403
The seeding awk never cleared in_unreleased at the next ## [X.Y.Z]
heading, so with an empty Unreleased section the deploy bullet landed
in the first ### Changed of a RELEASED section (the bounded verify awk
then failed the job). Bound the insert scope at the release-heading
boundary and synthesize a ### Changed subheading when Unreleased lacks
one (defensive: prepare-changelog always emits the full skeleton).

Refs: #1403
Pin the sync-main-to-dev auto-resolve pipeline shape in both decoupled
copies: conflicted-path enumeration and snapshot allowlist, dev-side
materialization, GitHub-signed commit via the pinned commit-action,
merge re-verification against the updated sync branch, and the
effective-conflict flag consumed by PR creation and auto-merge.

Refs: #1403
… commit

docs/issues and docs/pull-requests snapshots are generated
independently on dev (nightly sync-issues) and on the release branch
(release-time sync-issues), so every release produced add/add conflicts
on paths absent at the merge base and the post-release main->dev sync
PR opened conflicted every time.

The signed-commits ruleset (all refs, no bypass actors) forbids a plain
runner merge commit, so the resolution is a single-parent GitHub-signed
commit-action commit that aligns the sync branch's copy of each
conflicted snapshot with dev's content: with both merge sides identical
the conflict vanishes. Dev's possibly-staler snapshot self-heals at the
next nightly sync-issues run, whose updated-since cutoff predates
anything the release-time sync captured. Only paths merge-tree reports
as conflicted are aligned — a snapshot changed only on main still
merges cleanly and is not touched. Any conflicted path outside the
snapshot dirs (or a delete/modify conflict) keeps the existing manual
merge-conflict path, preserved bit-for-bit via the falsy fallback in
the effective-conflict expression.

Note the issue text proposed taking main's side; that would require a
merge commit the runner cannot sign, and snapshots are derived
artifacts of live GitHub state, so the dev-side alignment loses nothing
beyond a <=24h staleness window.

Applied identically to the canonical workflow and the workspace
template (intentionally decoupled copies, pinned by the new
cross-copy test).

Refs: #1403
@c-vigo
c-vigo enabled auto-merge August 10, 2026 14:04
@c-vigo
c-vigo disabled auto-merge August 10, 2026 14:05
@c-vigo
c-vigo merged commit d6e969e into dev Aug 10, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1403-sync-conflict-auto-resolve branch August 10, 2026 14:17
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.

1 participant