Skip to content

fix(ci): make the mirror-mode fold land and the promote reset safe - #1507

Merged
c-vigo merged 5 commits into
devfrom
bugfix/1502-mirror-fold-and-reset-guards
Aug 14, 2026
Merged

c-vigo merged 5 commits into
devfrom
bugfix/1502-mirror-fold-and-reset-guards

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the two mirror-mode release defects surfaced by vig-os/org-config v1.1.0
— together, a data-loss path. They ship as one PR deliberately: both live in
the same MANIFEST_SYNC_TARGET rendering block of assets/init-workspace.sh,
and #1503 must not land ahead of #1502 (a working reset over a broken fold is
what deletes the archive). One PR makes that ordering unrepresentable.

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests

Changes Made

#1502 — the fold committed nothing, silently. The path list reached
commit-action newline-separated; the action splits FILE_PATHS on commas, so
the whole blob was one nonexistent path, and it logged No files to commit and
returned success. The job printed "Folding 92 mirror archive path(s)" and the
release branch never moved.

  • The list is now comma-joined from git diff --cached --name-only -z. The tr
    runs inside the pipeline because command substitution drops NUL bytes.
  • That also fixes two latent mis-parses in the old
    git status --porcelain | awk '{print $2}': porcelain C-quotes paths
    containing spaces, and renders renames as R old -> new (awk took the old
    path).
  • A path containing a comma is unrepresentable in FILE_PATHS, so the step now
    fails loudly on one instead of mis-splitting it.
  • Re-pull release branch after fold is now
    Re-pull release branch and verify the fold landed: it asserts the
    post-condition (the release branch carries the mirror's archive) rather than
    trusting the action's exit code. Deletions still don't propagate — archives
    only grow — so a release-only path is tolerated.

#1503 — the reset 403'd, and would have deleted the archive if it hadn't.
The job embedded the Commit App token in the push URL, but actions/checkout
persists its own credentials as http.<host>.extraheader, which outranks URL
userinfo. The push ran under the default Actions identity against
contents: read → 403 on every mirror-mode consumer, after the release was
already published.

  • The App token is now generated before checkout and passed to it, so both
    the fetches and the push carry the App identity. contents: read stays
    deliberately — there's an inline comment saying so, since granting
    contents: write would "fix" a future 403 by silently moving mirror resets to
    the Actions identity.
  • Note persist-credentials: false alone (the issue's suggested one-liner)
    would have fixed the push but broken the job's git fetch on private
    consumers, which have no anonymous read. Checking out with the App token
    fixes both halves and matches how release-core.yml already does it.
  • New guard, per the issue: the force-push is gated on a new
    Verify main carries the mirror archive step that asserts main holds every
    docs/issues / docs/pull-requests path the mirror carries. Otherwise it
    skips with a ::warning:: — a stale mirror self-heals at the next nightly
    sync; deleted snapshots do not. The step's "a force reset loses nothing"
    comment is now true by construction.

Changelog Entry

### Fixed

- **Mirror-mode release: the archive fold committed nothing, silently**
  ([#1502](https://github.com/vig-os/devkit/issues/1502))
  ...
- **Mirror-mode promote: the mirror reset 403'd, and would have deleted the
  archive if it had succeeded**
  ([#1503](https://github.com/vig-os/devkit/issues/1503))
  ...

(Full entries in CHANGELOG.md under ## Unreleased → ### Fixed.)

Testing

  • Tests pass locally (just test, just test-bats, prek run --all-files)
  • Manual testing performed (describe below)

Both defects passed review and CI because the only tests over this code are
render pins — they assert the steps exist, never that they work. That is the
part worth fixing structurally, so this PR adds
tests/bats/release-mirror-fold.bats (11 tests), which extracts the rendered
run: blocks and executes them
against a throwaway repo whose origin is a
local bare clone: real git fetch/checkout/diff, real $GITHUB_OUTPUT, no
network. The fixture mirrors a consumer mid-release, including a spaced path and
a mirror-side rename.

Only the two steps that genuinely need GitHub are uncovered — commit-action
itself and the force-push — which is exactly why both are now gated on a
locally verifiable precondition instead of trusted.

RED-before-GREEN, against the unfixed renderer:

not ok 1 fold staging emits a single-line comma-joined path list (#1502)
not ok 6 fold staging fails loudly on a path commas cannot represent (#1502)
not ok 7 post-fold verification fails when the fold committed nothing (#1502)
not ok 9 mirror reset is refused when main lacks the archive (#1503)
not ok 10 mirror reset proceeds when main carries the archive (#1503)
not ok 11 mirror reset is refused when the mirror branch is absent (#1503)

All 11 green after the fix, as are the 6 mirror render pins (incl. the existing
actionlint pass over the rendered workflows) and the full 524-test bats suite.

Manual Testing Details

just test reports two failures on this host, both environmental and unrelated:
test_image.py::test_manifest_files compares CHANGELOG.md against the copy
baked into the locally-built image (stale by construction after any changelog
edit; the local mirror at assets/workspace/.devcontainer/CHANGELOG.md is
byte-identical), and test_integration.py::test_github_cli_authentication fails
on a missing dbus-launch in the container. 931 passed.

Checklist

Additional Notes

Rollout. These steps are rendered at scaffold time, so the fix reaches
vig-os/org-config only through a devkit-upgrade adoption PR after the next
release. That is safe to wait for: with the 403 still in place, nothing is
deleted — the 403 is currently the only reason org-config's 55 issue files still
exist.

Adjacent, deliberately not fixed here. The floating-tags job in the base
promote-release.yml (:669) has the identical shape — token in the push URL,
default checkout, contents: read — so its comment about pushing "as the Release
App EXPLICITLY" looks unenforceable in practice. It is a different job and a
different token, out of scope for these two issues; happy to file it separately.

Refs: #1502, #1503

c-vigo added 5 commits August 14, 2026 09:15
…ture

The render pins assert the steps EXIST; they cannot assert they work, which
is how a newline-joined FILE_PATHS (#1502) and a mis-authenticated force-push
(#1503) both shipped green. Extract the rendered run blocks and execute them
against a throwaway repo whose origin is a local bare clone.

Refs: #1502, #1503
commit-action parses FILE_PATHS as comma-separated and exits 0 with
"No files to commit" when nothing resolves, so the newline-joined list folded
nothing while every step stayed green. Build the list from the staged diff
with NUL framing (also correct for spaces and renames) and assert the release
branch actually carries the archive afterwards.

Refs: #1502
…rchive

Checkout's persisted extraheader outranked the token embedded in the push URL,
so the force-push ran under the default Actions identity and 403'd against
contents: read. Generate the App token first and check out with it.

The push is now also gated on main actually carrying every archive path the
mirror holds, so a broken or skipped fold degrades to a stale mirror instead
of deleted snapshots.

Refs: #1503
The base promote template builds a push URL the same way in other jobs, so an
unscoped assertion pinned more than #1503 owns.

Refs: #1503
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