Upgrade order: fix review findings on #11 #12

Merged
mikluko merged 3 commits from worker/gascitypacks-r3f into main 2026-11-11 15:00:52 +00:00
Contributor

Follow-up to #11: the three review findings on the upgrade order, one commit each with the test that fails without it. The bead asked for them on worker/gascitypacks-8yl, keeping #11; #11 merged at 14:48:19Z with its head at c3bf15d while this was in progress, so they ride a new branch cut from the new main. git range-diff shows each commit patch-identical to the one first made on #11's branch.

  • Proposed-once key (61c9015): the key is what the upgrade moved, the packs.lock entries (source, version, commit) that differ from origin/main's and any line it changed in pack.toml or city.toml, not the post-upgrade text of the three files. Test: proposed → a city.toml-only commit lands → a sha: pin bump lands → nothing is pushed, validated or opened again; a different upgrade on top is still proposed.
  • Killed run (d5f6cdb): reap runs before the staged worktree is made. It removes the leftover worktree that holds upgrade/packs and prunes registrations whose directory is gone. It takes only the order's own (gc-upgrade.XXXXXX/city, whose pid file names a dead process): a user's checkout of the branch, or a run still going, is left alone and fails as before, with a mail. Tests SIGKILL the order for real, with its temp directory left and cleaned away, and cover both restraint cases.
  • Signing (754c884): the commit runs with -c commit.gpgsign=false; the README, CHANGELOG and script header say so. Test: a global config that signs every commit through a gpg that cannot reach its agent.

Verified: each new test fails against the merged script (a second pull request / already used by worktree / gpg failed to sign the data) and passes with the fix; the restraint tests fail when reap's guards are removed. gc lint ., go vet, go test, shellcheck, tests/upgrade.sh, tests/merge.sh and tests/worktree-setup.sh pass on this branch; tests/upgrade.sh also under macOS /bin/bash 3.2 with Apple git. Not changed: sha: pins resolving to themselves, the city directory never edited in place, an open pull request reused rather than duplicated.

To know: git worktree prune is repository-wide, so it also drops the registration of any worktree of the city repository whose directory is missing (git worktree lock protects one). The lock format was checked against the city's real packs.lock, but the order was not run against a real gc here; "gc import upgrade writes only packs.lock" is the review's reading of gc's source, and the key covers pack.toml and city.toml lines in case it ever does not. Found outside this bead: gascitypacks-s1j, the formula cuts a fresh branch for a review-fix bead that names an existing pull request only in its text.

🤖 Generated with Claude Code

Bead: gascitypacks-r3f

Follow-up to #11: the three review findings on the upgrade order, one commit each with the test that fails without it. The bead asked for them on `worker/gascitypacks-8yl`, keeping #11; #11 merged at 14:48:19Z with its head at `c3bf15d` while this was in progress, so they ride a new branch cut from the new `main`. `git range-diff` shows each commit patch-identical to the one first made on #11's branch. - **Proposed-once key** (`61c9015`): the key is what the upgrade moved, the `packs.lock` entries (source, version, commit) that differ from `origin/main`'s and any line it changed in `pack.toml` or `city.toml`, not the post-upgrade text of the three files. Test: proposed → a `city.toml`-only commit lands → a `sha:` pin bump lands → nothing is pushed, validated or opened again; a different upgrade on top is still proposed. - **Killed run** (`d5f6cdb`): `reap` runs before the staged worktree is made. It removes the leftover worktree that holds `upgrade/packs` and prunes registrations whose directory is gone. It takes only the order's own (`gc-upgrade.XXXXXX/city`, whose pid file names a dead process): a user's checkout of the branch, or a run still going, is left alone and fails as before, with a mail. Tests SIGKILL the order for real, with its temp directory left and cleaned away, and cover both restraint cases. - **Signing** (`754c884`): the commit runs with `-c commit.gpgsign=false`; the README, CHANGELOG and script header say so. Test: a global config that signs every commit through a gpg that cannot reach its agent. **Verified:** each new test fails against the merged script (a second pull request / `already used by worktree` / `gpg failed to sign the data`) and passes with the fix; the restraint tests fail when `reap`'s guards are removed. `gc lint .`, `go vet`, `go test`, `shellcheck`, `tests/upgrade.sh`, `tests/merge.sh` and `tests/worktree-setup.sh` pass on this branch; `tests/upgrade.sh` also under macOS `/bin/bash` 3.2 with Apple git. Not changed: `sha:` pins resolving to themselves, the city directory never edited in place, an open pull request reused rather than duplicated. **To know:** `git worktree prune` is repository-wide, so it also drops the registration of any worktree of the city repository whose directory is missing (`git worktree lock` protects one). The lock format was checked against the city's real `packs.lock`, but the order was not run against a real `gc` here; "gc import upgrade writes only packs.lock" is the review's reading of gc's source, and the key covers `pack.toml` and `city.toml` lines in case it ever does not. Found outside this bead: `gascitypacks-s1j`, the formula cuts a fresh branch for a review-fix bead that names an existing pull request only in its text. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Bead: gascitypacks-r3f
The order recorded a hash of the full post-upgrade text of pack.toml, city.toml and packs.lock as the upgrade it had proposed. That text carries everything else on origin/main too, so any commit landing there changed the key and re-opened an upgrade the user had closed. Reproduced: the order opens the pull request, the user closes it, a commit that touches city.toml alone lands, and the next run pushes, validates and opens a second pull request. A new rig or a sha: pin bump is no part of an upgrade; per the review of #11, gc import upgrade writes only packs.lock.

The key is now a hash of what the upgrade moved: the packs.lock entries it added, removed or changed against origin/main's, one line each of source, version and commit, and any line it changed in pack.toml or city.toml. The order still commits those two files when they differ, so an upgrade that did change one stays told apart from the next. The fetched times stay out of it, as before. What origin/main carries besides is the same on both sides, and is not in the key.

tests/upgrade.sh gets the scenario from the review: the upgrade is proposed, a commit adding a rig to city.toml lands, then one bumping a sha: pin in pack.toml and packs.lock; neither makes the order push, validate or open anything again, and a different upgrade on top of both is still proposed. Both unrelated commits fail the test against the previous key (the branch is pushed, validated and opened again after each). I also ran the key's awk on a lock holding a moved, an added, a removed and an untouched entry, on a lock absent at HEAD, on no change and on the same entries reordered: it names exactly the changes, and nothing otherwise. The upgrade tests and shellcheck pass.

The script's header and the changelog entry say what makes an upgrade the same one.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A run killed after git switch --force-create leaves its staged worktree registered with the city repository and holding upgrade/packs: SIGKILL skips the EXIT trap. git lets no second worktree take a branch one holds, so every later run failed at the switch with "'upgrade/packs' is already used by worktree" and mailed the Operator, until someone removed the leftover by hand. git worktree prune alone does not clear it: the leftover's directory is still in the temp directory, and prune only drops registrations whose directory is gone (checked: it leaves such a worktree, and git worktree remove --force frees the branch).

Each run now calls reap before it makes its worktree. reap removes a worktree that holds the branch when it is the order's own, which is three things at once: it is named city, inside a gc-upgrade.XXXXXX directory, whose pid file names a process that is gone. It clears that directory with it, then prunes the registrations whose directory is gone as well, as when the system cleans the temp directory. Each run writes its pid into its scratch directory for this. A holder that is not the order's, the user's own checkout of upgrade/packs, is left alone; git refuses the switch and the failure is mailed with the holder's path, as before. So is the worktree of a run that is still going: the order's timeout is 15m and its interval 10m, so unless gc holds the next run back, a hung run overlaps it, and the pid check keeps the second from taking the branch from under the first. I did not remove whatever holds the branch, for those two reasons.

tests/upgrade.sh kills the order for real: its stub waits at the pull request, after the switch, the test sends SIGKILL, and the next run must open the pull request and leave no worktree, branch or scratch directory. It fails against the previous script with the error above, both with the temp directory left and with it cleaned away. Two cases keep reap in bounds: a worktree of the user's own holding the branch, and a live run's, are not removed and the failure is mailed. They pass without reap, as they should, so I removed the pid check and then every guard to see them fail: the live run's worktree is taken, and the user's, whose parent directory rm -rf then deleted along with the test's own. The upgrade tests and shellcheck pass.

The script's header and the changelog entry say that a killed run does not stop the next.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix: make the upgrade order's commit independent of a signing agent (gascitypacks-r3f)
All checks were successful
test / changelog (pull_request) Successful in 6s
test / scripts (pull_request) Successful in 7s
test / lint (pull_request) Successful in 3m7s
754c884683
The order commits inside an exec order, so with the user's global git configuration, and the commit was left to it: if that sets commit.gpgsign=true, the commit goes through gpg or an ssh agent, which the supervisor cannot reach, and every run fails with "gpg failed to sign the data" and mails the Operator (once, while the mail is unarchived). tests/upgrade.sh never saw it: it runs the order with GIT_CONFIG_GLOBAL=/dev/null.

The commit now runs with -c commit.gpgsign=false, which no configuration file overrides, so the upgrade commit is never signed and never needs an agent. Nothing else of the order's git commands creates a commit. The README says so next to what the order asks of the supervisor's git, and the changelog entry and the script's header too. This replaces "Signing is left to git's configuration" in the message of the commit that added the order.

tests/upgrade.sh runs the order with a global configuration that signs every commit through a gpg program that cannot reach its agent. A control commit with that configuration fails, so the test cannot pass for want of the setting taking effect; the order then has to push the branch with an unsigned commit and never call gpg. Against the previous script it fails as the review predicted: "commit failed ... gpg failed to sign the data: gpg: cannot connect to the agent". The upgrade tests and shellcheck pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/gascitypacks!12
No description provided.