feat(life): sdlc release, the normal path to a published image (a2357) #347
HIGH (Performance Check): behind_head makes a separate GitHub compare request for each tag until it finds one behind HEAD. When newer tags are not reachable from the clone's HEAD, deriving a version makes a linear number of API round trips, which can become slow or hit rate limits as the tag history grows.
Suggestion: Determine tag ancestry with a batched or local Git graph operation where possible, or use an API strategy that avoids one compare request per candidate tag.
Evidence:
for version in tags(api, repo):
compared = api.request("GET", f"/repos/{repo}/compare/v{version}...{head}")
if (compared or {}).get("status") in ("ahead", "identical"):
commits = compared.get("commits") or []
return version, [str((c.get("commit") or {}).get("message", "")) for c in commits]
<!-- gatehouse agent=performance confidence=90 votes=2/3 -->
Gatehouse found 1 issues (1 high)
Full review.
8 finding(s) dropped: their evidence is not in the diff.
<!-- gatehouse review complete -->
HIGH (Documentation): The documented --until values omit newly supported release steps. The release step list now includes identify, preflight, lease, and dispatch, and the tests confirm that --until lease is accepted, but the inputs section still lists only pr|merged|image.
Suggestion: Update the --until documentation to list all accepted step names, or clarify that the listed values are examples rather than an exhaustive set.
Evidence:
Inputs: run from a clone of the repo. `--version X.Y.Z` (default: derived),
`--item aN`, `--includes aX,aY`, `--until pr|merged|image`.
Steps (`identify`, `preflight`, `lease`, `dispatch`, `pr`, `merged`,
`image`)
<!-- gatehouse agent=docs confidence=98 votes=2/3 -->
Gatehouse found 1 issues (1 high)
Full review.
4 finding(s) dropped: their evidence is not in the diff.
<!-- gatehouse review complete -->
Fixed in 35ca946
The release section now says --until <step> takes any step listed below, most often pr, merged or image.
Not a bug: the loop is not linear in tag history in practice. It walks tags newest first and stops at the first one HEAD is ahead of. The only tag that can be newer than HEAD is the one this release made on its own merge commit, so derivation costs one compare call, or two once the release has landed. It never walks the history. A local git describe would depend on the clone having fetched its tags, and the API is the forge's own answer.
Gatehouse found no issues.
Reviewed 1 commit since 222c18a (incremental).
<!-- gatehouse review complete -->
Second-seat adversarial check of sdlc release at 35ca946 (read-only: sdlc_jobs/life/release.py, _runner.py, the spec in docs/lifecycle.md, compared against the Desk's cuts.refusal/_merge). Two real findings, a few low ones, and the rest held.
Findings
1. Re-running for a version that already shipped exits 0 as "landed" (high). preflight, lease and dispatch share done=started, and started is true once vX.Y.Z is tagged or its PR merged. So sdlc release --version 1.4.0 --item a99, where 1.4.0 is already the newest tag, skips preflight. That means the "not newer than the newest tag" refusal never runs. pr/merged skip on merged, and image re-verifies the old landing and prints the result JSON with exit 0. The commits on main since 1.4.0 (a99's change) were never released, and the command reports success. A derived version can hit the same path when a higher tag exists that HEAD isn't behind. test_preflight_version_not_newer_than_newest_tag calls the step directly, so it doesn't catch this. Suggested fix: without --resume, an existing vX.Y.Z tag or merged release PR is a 1. Resuming a landed release then requires --resume, which names the PR explicitly.
2. It merges whatever head the App's branch carries (medium). authored() checks only who opened the PR. Anyone who can push to ashigaru/release-X.Y.Z after the cut (any writer, any seat token) can add commits. Once checks pass on the new head, merged squashes them into main without review. Pinning sha only protects against a push during the step. Nothing checks that the head commit is the App's, or that the PR touches only what _bump.release_edits moves. The Desk's cut has the same gap because it pins to the observed head, so a fix probably belongs in both: one App-authored commit, and files ⊆ release_edits.
3. It skips refusals the Desk's cut applies (medium-low). cuts.refusal leaves a release PR for Prime when it's a draft, carries a flag label, or has changes requested. step_merged checks none of these, so a release PR someone deliberately held gets merged. The spec says "as the Desk's cut does".
4. A double merge produces a false failure (low). The Desk's cut loop also merges a green App PR under its lease. If it wins the race, GitHub answers 405 and step_merged reports "GitHub would not merge" (exit 1) on a release that did merge. A re-run recovers. Fix: on 405/409, check merged() again before refusing.
5. Dispatch run identification (low). the_run takes the first new run that appears. If a second ci.yml dispatch on the same sha (a hand dispatch, a different version) shows up first, it's adopted and its success is taken as ours. The damage is bounded: pr finds the PR by branch, so the worst case is a confusing refusal, not a wrong merge. Separately, if main moves between preflight and the POST, the run's head_sha ≠ rel.head, and the step waits 300s and exits 2. By then the cut has already happened, from a tree preflight never saw and with a version derived from the older commit set.
6. Required checks ignore the ruleset's source app (low). required() drops integration_id, and verdicts() counts a commit status with the required context as a pass. If the real check-run hasn't registered yet, a success status from any writer satisfies it. GitHub enforces the source at merge time, unless the merging credential bypasses the ruleset.
7. The TOCTOU on main (low). moved() runs before the PUT, and the merge pins only the PR head, not the base. A commit landing on main in that window gets released under a section about to be frozen. The window is narrow.
Held (no finding)
ashigaru-crunchtools-com[bot]. A user named ashigaru-crunchtools-com (no [bot], which users can't take) is refused.pulls() filters on head.repo.full_name and base.ref.sha, so GitHub answers 409 and the step refuses.error/failure status are refused (1). A mixed name takes the worst verdict.PASSED. Noted, not a bug./releases/tags), :latest ≠ X.Y.Z is a 1, and an unsigned digest is a 1. A repo with no images reports a null digest, by design.--resume with a stale PR: the branch pattern, App author and repo are checked, and only the version is taken from the PR. Later steps re-read via pulls(). A merged one re-verifies the old landing, which is finding 1's path.lease gets desk. Every step still receives the same write/merge github token, including the read-only identify, preflight and image. Per-step least privilege is nominal until a read-only github credential exists.Ashigaru-Item: a2363
Fixed in 63bf5fc
Answers to the second-seat review (https://github.com/crunchtools/sdlc/pull/347#issuecomment-7424974391), in its order:
--version for a shipped release exits 0. Fixed in 63bf5fc. Only --resume skips preflight, lease and dispatch now (done=resuming). Without it, preflight refuses (1) any release whose PR (open or merged) or tag already exists and names the --resume to use. A --resume of a PR closed unmerged is a 1. Tests: already-cut by tag, rerun with the PR open, the resume path skipping, closed-unmerged resume.pr waits and again before merged merges, the head commit's author and committer must both be the App. Its tree must also be exactly release_edits on its sole parent, checked by phase 0's own _prs.release_of (tree equality, file for file) through the step's GitHub client. Tests cover a non-App head and a refused tree, and run the real _prs.release_of over a small tree in two cases: the App's exact cut passes, and an extra file is refused.needs-human label, or a latest review per reviewer of CHANGES_REQUESTED is a 1, mirroring ashigaru desk/cuts.py refusal and automerge.FLAGS. A test asserts FLAGS == {"needs-human"}.head_sha and event match, its path ends in ci.yml, it is not among the runs listed before the dispatch, and it was created_at no earlier than the dispatch less a stated 120s clock skew. Two candidates is still a 2.integration_id and classic checks[].app_id are honoured. A check of the right name from another App leaves the requirement pending.moved() runs right before it. After the merge, or after a 405 adopted as merged, as_passed requires the merge commit's tree to equal the tree of the head that passed. Otherwise it is a 1 that says the base moved under the merge. image runs as_passed again, so a merge made elsewhere is judged too. GitHub's merge API takes no base-sha precondition, so checking before and after is the available guard.Suite: 99 tests in tests/test_life_release.py.
CRITICAL (Documentation): The new public now function has no docstring, so its purpose and UTC behavior are undocumented.
Suggestion: Add a brief docstring describing the value it returns, such as the current time in UTC.
Evidence:
def now() -> datetime:
return datetime.now(UTC)
<!-- gatehouse agent=docs confidence=94 votes=2/3 -->
CRITICAL (Documentation): The new public ForgeTools.http method has no docstring. Its interface and its handling of headers, payloads, and API errors are therefore undocumented.
Suggestion: Add a brief docstring describing how the method translates the HTTP request to the Api call and represents API errors in its Response.
Evidence:
def http(
self, method: str, url: str, headers: Mapping[str, str], payload: bytes | None = None
) -> Response:
del headers # the Api carries its own credential
path = url.removeprefix("https://api.github.com")
try:
got = self.api.request(method, path, None if payload is None else json.loads(payload))
except ApiError as err:
return Response(err.status, str(err).encode())
return Response(200, json.dumps(got).encode())
<!-- gatehouse agent=docs confidence=88 votes=2/3 -->
MEDIUM (General Review): the_apps_cut captures _prs.release_of's stdout and parses its human-readable text to construct a refusal reason. This couples control flow to diagnostic wording and uses process-wide stdout redirection, making the check harder to maintain and unsafe to compose with concurrent output.
Suggestion: Expose a structured result or error reason from _prs.release_of (or a dedicated validation function) and use that directly instead of redirecting and parsing stdout.
Evidence:
said = io.StringIO()
with contextlib.redirect_stdout(said):
parent = _prs.release_of(ForgeTools(rel.api), {}, rel.repo, head, rel.version)
if parent is None:
why = said.getvalue().strip().removeprefix("gates: ").removesuffix(": gating")
<!-- gatehouse agent=general confidence=92 votes=1/1 -->
Gatehouse found 3 issues (2 critical, 1 medium)
Reviewed 1 commit since 35ca946 (incremental).
5 finding(s) dropped: their evidence is not in the diff.
<!-- gatehouse review complete -->
Fixed in 1d38cca
now() has a docstring: this machine's time in UTC, used to match a dispatch to its run.
Fixed in 1d38cca
ForgeTools.http now has a docstring. It answers the URL's path through the Api as a 200 with JSON and turns an ApiError into its status. Headers are dropped because the Api carries its own credential.
Fixed in 1d38cca
the_apps_cut no longer redirects stdout or parses _prs.release_of's words. It refuses on the function's None alone, and the function's own diagnostic line prints unchanged as the reason. Phase 0's function is left as CI uses it.
Gatehouse found no issues.
Reviewed 1 commit since 63bf5fc (incremental).
1 finding(s) dropped: their evidence is not in the diff.
1 finding(s) not re-raised: already answered on this PR.
<!-- gatehouse review complete -->
fatherlinux
Phase 4 of docs/lifecycle.md:
sdlc release, replacing josui-land-release and every hand dispatch.Seven idempotent steps on the lifecycle runner, each in its own container with only the credentials it declares:
github.com/<owner>/<name>), confirmed byGET /repos; a name that does not resolve is a 2 at once. An agent (JOSUI_NAME, now passed into step containers by name) must give--item.--version, or derived from the Conventional Commits since the newestvX.Y.Ztag behind HEAD (breaking: MAJOR, MINOR before 1.0.0 per R1; feat: MINOR; else PATCH); newer than the newest tag;_bump.release_editsrun on the tree so its refusal (empty Unreleased included) is seen before anything is dispatched.POST /v1/releases; a 409 is ours only ifGET /v1/releasesshows this repo, version and item in flight, else a 1. No[desk]in the hosts file printsUNLEASED: the Desk will adopt this release.ci.ymlwith version, item, includes; the run is the one newworkflow_dispatchrun on this head that was not listed just before (no clock to skew). Two is a 2; a failed run is a 1 naming its jobs.ashigaru/release-X.Y.Z, this repo, into the default branch, authored by the Ashigaru App (never a title search); then the required checks (rulesets and classic protection), reading check runs and statuses. A failure is a 1 that printsresume: sdlc release --resume owner/repo#N.X.Y.Zandlatestare one digest that verifies against the fleet key. The last line is{"repo","version","commit","digest","release_pr"}.--resume owner/repo#Nreads the version from the release PR's branch, so a release started on one machine finishes on another; a closed-unmerged release PR counts as not cut.Tests:
tests/test_life_release.py(77, fake forge and fake Desk) covers each refusal, the ambiguous-run 2, the App-author check, a failed-check stop with its resume line, the resume path, version derivation and the landing checks.tests/test_host_contract.shpins thatJOSUI_NAMEreaches a step only when set.🤖 Generated with Claude Code
https://claude.ai/code/session_01R7Y1jgFUuEitySo4qtRTaQ
Ashigaru-Item: a2357