Skip to content

plx promote <name> and plx release [major|minor|patch]; the repo template's promote task is removed - #122

Merged
davidjalbers merged 20 commits into
stacks-3from
davidjalbers/plx-305-plx-promote-name-and-plx-release
Dec 6, 2026
Merged

davidjalbers merged 20 commits into
stacks-3from
davidjalbers/plx-305-plx-promote-name-and-plx-release

Conversation

@davidjalbers

@davidjalbers davidjalbers commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

plx promote <name> and plx release [major|minor|patch] are commands of plx, the same in every repo, and the promote task of the repo-turbo template is removed.
It implements § 6.8, § 7.9, § 7.10, § 8.4 and § 8.5 of the Decisions (PLX-305).

What each command does, in order

plx promote <name> (header of packages/lib/src/promote.ts):

  1. Finds the top of the repo the directory is in (refuses outside one), reads the declaration of its root marker through readDeclaredEnvironments; refuses an invalid or empty one with declarationRefusal, and an undeclared name (exit 2).
  2. Asks the remote (git ls-remote) which of the source and env/<name> it has; refuses where the source is not there, saying to promote <other> first.
  3. Fetches exactly those refs by explicit refspec into remote-tracking refs, whatever the clone's configured refspec is, also under --dry-run; a single-branch or shallow clone, as a forge's checkout makes it, gives the answers of a full one.
  4. Compares the heads; refuses where env/<name> is no ancestor of the source's head; in a shallow clone whose history cannot tell, says so and names git fetch --unshallow origin; stops, pushing nothing, where it is at the source already.
  5. Says what it will push, asks, and runs git push --no-verify origin <sha>:refs/heads/env/<name>, with no force.

plx release [step], minor by default (header of packages/lib/src/release.ts):

  1. Finds the top of the repo, checks that gh is logged in (preflightForge) and can reach the repository (gh repo view), before anything is fetched or pushed.
  2. Fetches origin's main and its tags by explicit refspec (not forced: a local tag that differs from the remote's is git's refusal, shown in git's words).
  3. Takes the head of origin/main and its version from commitVersion, counting only the tags the remote has (a new only argument of commitVersion, unset for the image step, whose meaning is unchanged; a shallow clone is refused there); refuses where origin/main has no commit since that tag.
  4. Computes the next version, 0.1.0 for a repo without tags, and refuses where its tag exists already.
  5. Prints the commit subjects, asks, and runs git push --no-verify origin <sha>:refs/tags/<version>.
  6. Runs gh release create <version> --verify-tag --title <version> --notes-file -, the notes on standard input whatever their length: a normal release, no immutability asked for; the notes list the subjects since the previous tag, each a code span (codeSpan moved from dev to lib for this), and the first release's notes say only that it is the first release. The narration lists twenty subjects and counts the rest. Where gh fails, the tag stays and the error says the tag is pushed and the release is not, and to run plx release again.
  7. A plx release run where the newest tag of the remote sits on the head of origin/main and GitHub has no release for it (gh release view) says that the tag has no release yet, that it exists on the remote and was not made by this run, and that the step is not used, and after the same question creates that release with the notes the first run wrote and tags nothing; its result line says "released", not "tagged", and its JSON has finished: true. Where the release exists it says "nothing to release".
    Only gh's answer "release not found" counts as no release: any other failure of gh release view stops the run with gh's words ("gh release view failed: ...") and creates nothing. What I relied on: gh's source returns the error release not found for a missing release (a 404), and any failure of a gh command exits 1, so the words, not the exit code, tell them apart; the string is in the installed gh 2.106.1 binary, which I read with strings, and no real repository was called.

Readings

The first three are the maintainer's opening readings.

  1. plx promote <name> refuses when its source is env/<other> and that branch is not on the remote yet, saying to promote <other> first.
  2. Nothing in tooling enforces fast-forward-only on env/<name> beyond plx promote itself; no forge ruleset is created or checked.
  3. A release tags main, starts no deploy and moves no branch: release, then promote.
  4. Neither command reads or changes the checkout's files, branches or checked-out branch, whatever branch it stands on and however dirty it is. The one thing read from it is the root marker as it is on disk, so a command run on a branch whose marker differs uses that marker's declaration, while the source is read from the remote (for the maintainer: reading the declaration from origin/main:PLEXUS.md would be consistent, and is not done). Both push a commit by hash (<sha>:refs/...), so no local branch is made; release makes no local tag, the tag exists on the remote only and arrives locally with the next fetch. promote fetches the two branches it compares, release main and the tags, into the checkout's remote-tracking refs (and their reflogs) and tags; both do so under --dry-run, which has to read the real remote. origin/HEAD is left alone.
  5. Both push with --no-verify: they push no commit of the repo's own, so a pre-push hook such as mise test has nothing to check.
  6. release refuses where origin/main has no commit since the last tag ("nothing to release"). The Decisions are silent; a release would list nothing and burn a version number, and a rerun after a failed gh would otherwise bump again.
  7. The first release is 0.1.0 whichever step is given, as § 7.9 says without a condition. major or patch on a repo without tags do not give 1.0.0 or 0.0.1.
  8. A tag that exists already for the computed version, on a commit origin/main does not hold, is refused rather than reused or moved.
  9. The tag is pushed first and the release created after, as § 7.9 orders them. Where gh fails the tag stays, and a run of plx release again finishes the release (step 7 above); no command is left for a person to assemble.
  10. Only tags the remote has count for the version, and the previous tag in the notes is one of them; a local-only tag is ignored (and one with the name of the next version is refused as existing).
  11. -C, --dir <dir> selects the checkout, as plx changeset and plx deploy do; the commands take no other argument or option. Where the directory is a subdirectory of a repo, the commands work from the repo's top (as plx apply does, through the same topOf) and read its root marker; outside a repo they refuse. The remote is origin, as for changeset.
  12. The yes, quiet and JSON switches are the CLI's own, through contextOf; the commands read no variable themselves. PLX-275 therefore still applies to them: PLX_YES=false plx promote staging answers yes (shown in the transcript), and it is fixed there, for all commands at once, not here.
  13. --json of release also has finished (true where the run only created the release of a tag an earlier run pushed). --json of promote prints environment, branch, source, from, to, commits, outcome (created, fast-forwarded, unchanged); of release, version, previous, commit, commits, url.
  14. Declining the question exits 1 with "aborted; nothing was pushed", as mise ship does.
  15. The first release's notes do not list its commits, since a first release of a repo with history would run to thousands of lines; they say that it is the first release (a reading: listing them is the alternative).
  16. Release tags are lightweight and unsigned, where ship makes annotated ones (for the maintainer).
  17. In a shallow clone whose history cannot show that env/<name> is behind its source, promote refuses and names the remedy instead of leaving git's "fetch first"; the commit count of a promotion is as far as the clone's history goes.
  18. exec of lib no longer crashes when a process exits without reading its input (an EPIPE on its input): it fails by the exit code; any other error on the input fails the call. No test for the latter: it needs a write error of another kind on a child's pipe, which cannot be provoked without replacing spawn. Needed so that a gh that exits early reports the pushed tag; one test in io.test.ts.

What plx update does to a repo that has the task

Rendered by plx-template from the old and the new template: an unedited promote task is removed by the merge, and one the repo edited is left in conflict (markers in mise.toml, which plx doctor reports).
No release task is rendered, now or before.

Known, and not fixed

  • Where an unreleased tag has commits after it, a new release is cut as normal and the earlier tag stays without a release; nothing says so.
  • How gh release view treats a draft release is not verified.

What no test covers

  • A real gh and a real forge: the tests and the proof use a stand-in that records its arguments.
    Whether the repo's setting makes releases immutable is the forge's.
  • The prompt on a real terminal in the test suite: the proof answers it on a pty, the tests answer through a Context with a prompt.
  • A remote that moves between the fetch and the push (the remote's own refusal stands behind the ancestor check; the review ran it).
  • A real actions/checkout (single-branch and shallow clones are made by hand).

Release notes

  • Removed: the promote task of the repo-turbo template (it fast-forwarded main from develop).
    Replaced by plx promote <name>, which fast-forwards env/<name> to its declared source, and plx release [major|minor|patch], which tags origin/main.
  • A repo that takes the version and has the task: the merge removes it unless edited, in which case the conflict is the repo's to resolve.
  • The removed promote task ran the pre-push hook (it pushed main); plx promote pushes with --no-verify and does not, as the update's own pushes do not.

For the workflows issue (auto-promotion after a green run)

  • plx promote <name> is the step to run after a green run on the branch promotes_from names. It fetches the refs it compares itself, by explicit refspec, so it works in a single-branch checkout, but a default depth-1 checkout (actions/checkout) refuses every promotion of a branch that exists behind main, because its history cannot show the move to be a fast-forward: a job that promotes needs the full history (fetch-depth: 0). It needs origin pointing at the repo, pushes with whatever credentials git push has there, the job supplies its own token and passes -y.
  • It takes no commit and cannot refuse where the head moved: a job promotes whatever the source's head is when it runs.
  • It must run with -y (no terminal in a job) and exits 0 when the branch is at its source already, 1 on a refusal, 2 on an undeclared name.
  • A job that promotes by the workflow token pushes a branch: whether that starts the pipeline on env/<name> is the forge's rule for the token, which the Decisions list as a fact to trial (a push with the default token is said to start no workflow).
  • plx release is not for a job: it needs gh and asks a person's decision of step.

Lines

+1432 −29 across 22 files; tests and their support: 950 added lines (66%).

Checks: TURBO_FORCE=true mise run test exit 0 (7 of 7 tasks); newborn tests repo-turbo.test.ts and update-released.test.ts pass.
The review's findings (long notes, narrow clones, local tags, gh reach, git's messages, subdirectories, finishing a release) are fixed in later commits, each test first, but the test of aeb4e9b (a release in a clone that fetches another branch than main) was added after the code it holds, found by a mutation; history is not rewritten.

🤖 Generated with Claude Code

davidjalbers and others added 9 commits December 6, 2026 05:50
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… declared source

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ease

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…release are commands

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…; a refused release names gh's own reason

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ves out the task promote, which plx promote replaced

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@davidjalbers davidjalbers self-assigned this Dec 6, 2026
davidjalbers and others added 11 commits December 6, 2026 06:31
… reaching the repo, narrow clones, subdirectories, git's own messages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…es on stdin, gh reaching the repo, the repo's top, git's own messages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…the rest

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t code, not by a broken pipe

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…th the notes of the first run

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…names no command to assemble; exec ignores a broken pipe on its input and no other error

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…s answer "release not found" counts as no release

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@davidjalbers
davidjalbers merged commit 1a99506 into stacks-3 Dec 6, 2026
2 of 4 checks passed
@davidjalbers
davidjalbers deleted the davidjalbers/plx-305-plx-promote-name-and-plx-release branch December 6, 2026 07:48
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