Skip to content

tools/publish-kernel: stop instead of rewriting published history when the tip can't be read - #286

Closed
only21mil wants to merge 2 commits into
derekross:mainfrom
only21mil:build/c024-kernel-publish-guard
Closed

only21mil wants to merge 2 commits into
derekross:mainfrom
only21mil:build/c024-kernel-publish-guard

Conversation

@only21mil

@only21mil only21mil commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

What and why

tools/publish-kernel read the published branch with git fetch ... 2>/dev/null && pub=... and took any failure for "the branch doesn't exist yet". So a dropped SSH connection or a GitHub hiccup during that one fetch made the tool rebuild the branch from scratch and git push --force it. The push itself could still succeed, and then every published commit id that open kernel pull requests are based on would change.

Now:

  • The tool reads the tip with git ls-remote --exit-code. Only exit 2, where the remote answered and has no such branch, counts as a first publication. Any other failure, or a fetch of the tip that fails, stops the run before anything changes.
  • A published tip that matches no commit on the local branch (local history was rewritten) stops with a message, and replacing it takes an explicit tools/publish-kernel --rebuild.
  • The push sends the replay the tool checked, by commit id, with --force-with-lease on the tip the run fetched ("must not exist" for a first publication). A published branch that moved during the run (a second publisher, or a hidden ref) is never overwritten. Neither is it replaced by whatever another run left in the local publish/<branch>, which now moves only after a successful push.

The fast-forward path, the normal case, behaves as before.

device/cheetah/KERNEL-PUBLISH.md (status, §5.4 and its rollback, which is now leased too) and docs/RELEASES.md §8 (a rebuilt omamobile-int snapshot now needs --rebuild) describe the new behaviour.

Device and build

  • Phone: none: a laptop tool. It never runs on a phone, so no tools/phone-smoke report (CONTRIBUTING §6.5).
  • Kernel release (uname -r): n/a
  • Packages changed, with versions: none

Checks (no phone needed)

  • tools/pr-check origin/main passes
  • tests/all passes, including the new tests/publish-kernel
  • tests/packages: no package changed. On the build host, omamobile-audio, omamobile-shell and omamobile-speaker-tuning fail. Their files are identical to main, and none of them uses a file this change touches. Every other suite passes.
  • No package changed, so no version bump
  • Area prefix and a why-body; AI help is a Co-Authored-By: trailer

tests/publish-kernel runs the real tool against a bare repository in a scratch folder. The tool accepts PUBLISH_REMOTE, defaulting to its current GitHub destination. The fixture sets it directly to the local repository, clears inherited Git protocol/config overrides, and refuses every Git protocol but file. It checks the destination and protocol restrictions before creating a repository. A small git shim fails the fetch, or moves the branch just before the push. It covers nine cases: a first publication, a fast-forward, a failed fetch, an unreadable remote, a rewritten history with and without --rebuild, a published branch that moves before the push (fast-forward and rebuild), a local publish/<branch> that moves before the push, and a branch that looks missing but exists at push time. The tool as it was on main fails seven of the nine. In the failed-fetch case it force-pushes over the published branch.

On the phone

  • Not applicable: nothing runs on the phone.
  • What I did not test: a real publication to GitHub. Every run used the local scratch remote.
  • Nothing in this change writes outside slot B and userdata, weakens the storage guard, or reads registers from userspace (AGENTS.md §1)

Found by Opus 5.5 High, Terra 6.1 Max / Priority and Sol 6.1 xhigh / Priority (OPUS-S14-016; TERRA-BUILD_INSTALL-008; TERRA-DEVICE_CHEETAH-021; SOL-XHIGH-R2:release_build:SOL61XH-R2-RB-023). The observed-tip lease also covers the concurrency improvement SOL-XHIGH-R2:release_build:SOL61XH-R2-RB-024 (C649).

Generated with Claude Opus 5.5 in T3 Code Nightly

The publisher fetched the published branch in an AND list and took any
failure for a missing branch: a network error left pub empty, which
picked a full rebuild and an unleased `git push --force`, so one failed
read could replace every published commit id that pull requests are
based on.

Read the tip with `git ls-remote --exit-code` instead: exit 2 means the
remote answered without the branch, and any other failure, or a fetch
that fails, stops the run. A published tip that matches no local commit
(rewritten history) now stops unless `--rebuild` is given. Every push
sends the checked replay by commit id with `--force-with-lease` on the
tip the run fetched (no tip: the branch must not exist), so neither a
published branch that moved during the run nor a local publish/<branch>
moved by another run is ever pushed over it. publish/<branch> moves
only after a successful push, so it keeps naming the published head.

tests/publish-kernel runs the tool against a bare repository in a
scratch folder (the remote URL rewritten to it, every Git protocol but
file refused): a first publication, a fast-forward, a failed fetch, an
unreadable remote, a rewritten history with and without --rebuild, a
published branch that moves before the push on both paths, a local
publish/<branch> that moves before the push, and a hidden tip. The old
tool fails seven of the nine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Hi, and welcome. Thank you for these twelve. I've read every diff and run each PR's own new test in a container with no network, and most of them fix real problems I hadn't seen. The descriptions are unusually honest about what wasn't tested, and that made reviewing them much easier. I've left a note on each. In short, #291, #292, #295 and #296 are ready, and the rest need a small change or a decision on my side. I've approved the CI runs. (#299 and #300 arrived while I was reviewing these; I'll get to them next.)

A few things that apply to the whole set:

  • Pace. Twelve PRs opened within a minute is a lot for one maintainer to review, and your branch names suggest there are many more. Please keep three or four open at a time, and group related fixes to one tool in one PR (tools/kernel-pr-check: a --build one level above the kernel tree no longer deletes it #287 and tools/kernel-pr-check: a checkpatch that can't run fails the check instead of passing it #288 both change the kernel-pr-check header and its --help range, and together they break the range again).
  • tests/all. Six of these PRs add a test on the same line of tests/all, so they conflict with each other and with other contributors' open PRs. I'll resolve those at merge, so there's no need to rebase for it.
  • Commit bodies. We squash with the commit message, so whatever is in the body lands on main. Please leave out internal audit record ids (KIMI-S01-009 and the like). One sentence on how it was found is plenty. If more than one assistant co-wrote a commit, a Co-Authored-By: line for each is fine.
  • Tools only I run (publish-kernel, repo-publish). Thank you for the careful fixtures. Changes there change how I publish, so I'll decide the behaviour changes (such as tools/publish-kernel: stop instead of rewriting published history when the tip can't be read #286's --rebuild) and do one real dry run myself after merging.
  • Could you confirm that you've read each change yourself and stand behind it? I ask anyone whose PRs are mostly written by an assistant, and it helps me know who to ask when something comes up later.

Thanks again: this was a useful batch.

@derekross

Copy link
Copy Markdown
Owner

Thank you for this. You've found a real hole: a failed git fetch was read as "no published branch yet", and the tool then rebuilt and force-pushed. I re-read the old and new code paths, and I ran tests/publish-kernel in a container with no network: all nine cases pass. The --force-with-lease on the tip the run read, and moving publish/<branch> only after a successful push, are both right.

Two things before I merge:

  1. --rebuild is a change to how I publish, not only a fix. Until now a rewritten local history meant a rebuild and a force-push without asking. With this change it stops, and the omamobile-int snapshot (RELEASES §8) needs --rebuild whenever int has been rebuilt, which happens often. I think stopping is the right default, but it's my workflow, so I'll decide it at merge. Nothing needed from you unless you'd rather split it out. If I keep it, I'll put "stop on a rewritten history unless --rebuild" in the squash subject, because the title only covers the unreadable tip.
  2. The test runs the real publisher, and the remote hard-coded in it is our GitHub repository, so it runs on the machine that can push there. The guards hold as written: the global config is replaced, every protocol but file is refused, GIT_SSH_COMMAND=false, and the URL is checked before anything runs. Environment config still wins over all of that, though. Could you also unset GIT_ALLOW_PROTOCOL GIT_CONFIG_PARAMETERS GIT_CONFIG_COUNT at the top of the test? Better still, let the tool take its remote from a variable (PUBLISH_REMOTE, defaulting to today's URL), so the test never names the real one at all.

Small things: KERNEL-PUBLISH's status line is still dated 2026-10-19 while it describes 2026-11-01 behaviour, so please add "(since 2026-11-01)" there. Also, tests/all will conflict with several other open PRs that each add a test on the same line. I'll resolve that at merge, so please don't rebase just for it.

Select a local remote directly in the publisher test and clear inherited
Git config overrides before its protocol guards run. The default publish
destination is unchanged. Date the new behavior in the status summary.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>
@only21mil

Copy link
Copy Markdown
Contributor Author

Note

🤖 GPT-6.1 Sol responding on behalf of only21mil

Victor confirms that he personally read each submitted change and stands behind them.

We’ll keep future batches to three or four open PRs and group related fixes by tool. Further openings are on hold. New commit bodies will omit internal audit IDs.

We’ll leave the shared help-range correction for #287/#288, the tests/all merge conflicts and #293’s squash-message trim to you, as offered.

derekross added a commit that referenced this pull request Nov 2, 2026
…push; RELEASES records the 11-01 decisions (#310)

* publish-kernel: fast-forward omamobile and tag releases, never force-push

Since 2026-10-30 the phone runs the published omamobile branch plus a
curated local branch, and community pull requests merge into omamobile
on GitHub. RELEASES §8 still said releases come from omamobile-int
snapshots published with tools/publish-kernel, and run that way the
tool found no local commit matching the published tree and fell back to
a rebuild and a force push: from the stale local omamobile that drops
every community commit, from omamobile-int it replaces the snapshot
history with hundreds of unsigned commits.

The model is now: omamobile on GitHub is the one source of the release
kernel; community work lands by rebase merges, the maintainer's curated
work as a fast-forward of a local release branch built on the current
published tip; releases are annotated tags on it (kernel-YYYY.MM.DD,
proposed); omamobile-int is a local test branch only.

tools/publish-kernel is rewritten to match. It reads and fetches the
published tip first (a failed read is never taken for a missing
branch), pushes only when the branch contains it, and otherwise prints
the rebase to run. It runs kernel-pr-check's commit and policy checks
(new --no-checkpatch) on what it would publish and refuses merge
commits. --tag creates an annotated tag naming the release uname and
pushes it with the branch atomically, or alone on the published tip;
--dry-run prints the exact push. The squash replay, --rebuild and every
force push are gone; with no force flag, git refuses a non-fast-forward
even when the remote moves during the run. The remote comes from
PUBLISH_KERNEL_REMOTE for the test.

kernel-pr-check now fails a Co-Authored-By trailer: CONTRIBUTING §6.2
and coding-assistants.rst credit an AI with Assisted-by in kernel
commits.

This takes over #286's safe read of the published tip (ls-remote exit
2 only means missing) and its test sandbox idea; its --rebuild and
--force-with-lease paths have no place in a branch that only moves
forward, so the two conflict in tools/publish-kernel and RELEASES §8.

tests/publish-kernel runs the tool against a scratch bare repository
with only the file protocol allowed, ssh disabled, replaced global and
system configs and the GitHub URL rewritten into the scratch folder,
and logs every push to prove none forces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

* RELEASES: record the first-release decisions of 2026-11-01

The maintainer decided all twelve items of the release decisions brief,
with the kernel source changed to a tag on the published omamobile
branch after the curated commits land there by fast-forward. §12 turns
from open questions into that record, and the sections the decisions
change say so: the kernel package is packed on the build machine with
the pinned AOSP clang (§4, §9); one root image per device, a signed
JSON manifest with per-file sizes and hashes and the install checks as
data for a future web flasher and desktop installer, and hosting next
to [omamobile] with the GitHub Release carrying notes and links, never
any Google firmware (§6); the first release's version and label (§7);
signing with the release key and users on stable (§10); the attended
test install gating the release, and the upload and promotion (§11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

* kernel-pr-check: a Co-Authored-By trailer warns on pull requests, fails with --strict-trailers

linux-omarchy-mobile's CI runs this tool from omarchy-mobile's main, so
failing every Co-Authored-By trailer would have turned open community
kernel PRs red the moment this branch merged. Pull requests now get a
warning that names the commits; tools/publish-kernel passes
--strict-trailers, so nothing published carries one. The help range
follows the longer header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@derekross

Copy link
Copy Markdown
Owner

Thank you for this one, @only21mil. #310 replaced tools/publish-kernel with a version that only ever fast-forwards omamobile and tags releases, since that's how the kernel is now published (RELEASES §8). It took two of your ideas, with credit: the ls-remote rule that only exit 2 means a missing branch, and the scratch-remote sandbox for the test. The --rebuild and force-with-lease paths don't fit a branch that only moves forward, so I'm closing this as superseded by #310.

@derekross derekross closed this Nov 2, 2026
robertzas pushed a commit to robertzas/omarchy-mobile that referenced this pull request Nov 14, 2026
…push; RELEASES records the 11-01 decisions (derekross#310)

* publish-kernel: fast-forward omamobile and tag releases, never force-push

Since 2026-10-30 the phone runs the published omamobile branch plus a
curated local branch, and community pull requests merge into omamobile
on GitHub. RELEASES §8 still said releases come from omamobile-int
snapshots published with tools/publish-kernel, and run that way the
tool found no local commit matching the published tree and fell back to
a rebuild and a force push: from the stale local omamobile that drops
every community commit, from omamobile-int it replaces the snapshot
history with hundreds of unsigned commits.

The model is now: omamobile on GitHub is the one source of the release
kernel; community work lands by rebase merges, the maintainer's curated
work as a fast-forward of a local release branch built on the current
published tip; releases are annotated tags on it (kernel-YYYY.MM.DD,
proposed); omamobile-int is a local test branch only.

tools/publish-kernel is rewritten to match. It reads and fetches the
published tip first (a failed read is never taken for a missing
branch), pushes only when the branch contains it, and otherwise prints
the rebase to run. It runs kernel-pr-check's commit and policy checks
(new --no-checkpatch) on what it would publish and refuses merge
commits. --tag creates an annotated tag naming the release uname and
pushes it with the branch atomically, or alone on the published tip;
--dry-run prints the exact push. The squash replay, --rebuild and every
force push are gone; with no force flag, git refuses a non-fast-forward
even when the remote moves during the run. The remote comes from
PUBLISH_KERNEL_REMOTE for the test.

kernel-pr-check now fails a Co-Authored-By trailer: CONTRIBUTING §6.2
and coding-assistants.rst credit an AI with Assisted-by in kernel
commits.

This takes over derekross#286's safe read of the published tip (ls-remote exit
2 only means missing) and its test sandbox idea; its --rebuild and
--force-with-lease paths have no place in a branch that only moves
forward, so the two conflict in tools/publish-kernel and RELEASES §8.

tests/publish-kernel runs the tool against a scratch bare repository
with only the file protocol allowed, ssh disabled, replaced global and
system configs and the GitHub URL rewritten into the scratch folder,
and logs every push to prove none forces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

* RELEASES: record the first-release decisions of 2026-11-01

The maintainer decided all twelve items of the release decisions brief,
with the kernel source changed to a tag on the published omamobile
branch after the curated commits land there by fast-forward. §12 turns
from open questions into that record, and the sections the decisions
change say so: the kernel package is packed on the build machine with
the pinned AOSP clang (§4, §9); one root image per device, a signed
JSON manifest with per-file sizes and hashes and the install checks as
data for a future web flasher and desktop installer, and hosting next
to [omamobile] with the GitHub Release carrying notes and links, never
any Google firmware (§6); the first release's version and label (§7);
signing with the release key and users on stable (§10); the attended
test install gating the release, and the upload and promotion (§11).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

* kernel-pr-check: a Co-Authored-By trailer warns on pull requests, fails with --strict-trailers

linux-omarchy-mobile's CI runs this tool from omarchy-mobile's main, so
failing every Co-Authored-By trailer would have turned open community
kernel PRs red the moment this branch merged. Pull requests now get a
warning that names the commits; tools/publish-kernel passes
--strict-trailers, so nothing published carries one. The help range
follows the longer header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BeEcdVeSfyLCbijF8XQF1d

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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