Repository navigation
ci: CI, PR-Agent review, the auto-merge gate and an SDK version check - #51
Conversation
package.json on main asks for exponential-sdk ^1.32.0, but package-lock.json still pinned 1.31.0, so `npm ci` refused to install. Regenerated with `npm install --package-lock-only`; only the exponential-sdk entry and the root version fields change.
Copies the app repo's setup (exponential-im/exponential): - ci.yml: npm ci, build, typecheck and test on every PR into main and on every push to main. One job, "Build, typecheck & test". - pr_agent.yml + .pr_agent.toml: review-only PR-Agent on GLM 5.3 through OpenRouter, one call per push, findings tagged [blocker] or [minor]. The house rules are rewritten for a CLI. - pr-agent-automerge.yml: squash-merges a PR into main once PR-Agent left nothing blocking on the latest commit and CI passed on it. Honours no-automerge and pr-agent-ack exactly as the app's gate does. Differences from the app's gate: no database-schema rule; the CI check is verified by name in the gate as well as by branch protection; and without the App's credentials the gate does nothing, so this can merge before the repo is set up. New here, because this package depends on exponential-sdk: - .github/scripts/check-sdk-pin.mjs runs in CI before npm ci and fails, saying what to do, when package.json's exponential-sdk range has no published version, when package-lock.json pins a version that is not on npm (or a local link or tarball), or when the two files disagree. - sdk-bump.yml asks npm hourly for a newer exponential-sdk and opens a "chore: bump exponential-sdk to <version>" PR as the auto-merge App. A person merges it: the gate skips bot-opened PRs. CLAUDE.md gains a "Who merges" section.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd848358d5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const findings = [...body.matchAll(/<details><summary><a href='([^']*)'><strong>([\s\S]*?)<\/strong><\/a>/g)] | ||
| .map(m => finding(m[2].trim(), m[1], null)); | ||
| if (!findings.length && !/No major issues detected/i.test(body)) return null; |
There was a problem hiding this comment.
Parse standalone findings without requiring a details wrapper
When a standalone review contains a [minor] finding with a code snippet and a [blocker] finding without one, this regex captures only the minor finding. PR-Agent's renderer emits a plain <a><strong>…</strong></a> when relevant lines are unavailable, rather than wrapping it in <details><summary>. Running readReview against that mixed output returns zero blockers; with green CI and no security concern, the gate therefore merges despite the explicit blocker. Parse both supported finding formats, or reject the review when findings cannot be fully accounted for.
Useful? React with 👍 / 👎.
…ding form Two holes in the gate, both found by Codex's review and both inherited from the app repo's copy: - pr-agent-ack was only cleared by the `synchronize` run. Runs share one concurrency slot per branch and a queued run is replaced by the next one queued, so that run can be dropped and an old acknowledgement would then cover a newer commit. The label's timestamp is now checked against PR-Agent's review of the latest commit; an older one is ignored and removed. - A standalone review (no state block) was parsed for findings in the `<details>` form only. PR-Agent also writes `<a><strong>` and bare `<strong>` findings when it can't quote the lines, so a [blocker] in that form was missed. Every finding in the focus-areas row now counts, and a row that can't be read holds the PR. Also: CI runs on PRs into any branch, so a stacked PR already has its check when it is retargeted to main; and the SDK bump never lowers a range in package.json that is already ahead of npm.
Adds CI, PR-Agent review and the auto-merge gate, copied from the app repo (
exponential-im/exponential), plus a check that theexponential-sdkversion this repo asks for is published. This repo had no.githubfolder.What's added
.github/workflows/ci.yml(workflowCI, one jobBuild, typecheck & test): the SDK check below, thennpm ci,npm run build,npm run typecheck,npm test, on every PR and every push tomain. Node 22. Only scripts that are already inpackage.json..github/workflows/pr_agent.ymland.pr_agent.toml: review-only PR-Agent on GLM 5.3 through OpenRouter (Z.AI's endpoint only), one call per push, every finding tagged[blocker]or[minor]. The[config]and[openrouter]sections are the app's, unchanged. The house rules are rewritten for a CLI: JSON output, flags and exit codes are a contract (breaking changes need a major bump), nothing but the JSON document on stdout in JSON mode, errors go throughhandleError, API calls go through the SDK, the token is printed only byauth show --token,.json relative imports, mocked-client tests..github/workflows/pr-agent-automerge.yml: squash-merges a PR intomainonce PR-Agent left nothing blocking on the latest commit and CI passed on it.[minor]findings don't block; untagged or[blocker]findings and security concerns do. Honoursno-automerge, andpr-agent-ackonly whenpositonicapplied it.CLAUDE.md, and a note on the SDK check.The exponential-sdk check
maincurrently can't runnpm ci:package.jsonasks forexponential-sdk ^1.32.0andpackage-lock.jsonstill pins 1.31.0. The first commit here syncs the lockfile (only theexponential-sdkentry and the root version fields change), so CI has something that installs.To stop that merging again:
.github/scripts/check-sdk-pin.mjsruns in CI beforenpm ciand fails with the cause and the fix whenpackage.json'sexponential-sdkrange has no published version on npm,package-lock.jsonpins a version that isn't on npm, or takes the SDK from a local link, folder or tarball,package.json's range, orIt is a step in the required job, so the PR can't merge.
.github/workflows/sdk-bump.yml(optional extra): asks npm once an hour for a newerexponential-sdkand openschore: bump exponential-sdk to <version>, setting the range to^<version>and updating the lockfile. It opens the PR as the exponential-automerge App, so CI runs on it; it uses the samepr-agent-automergeenvironment and does nothing until that is set up. PR-Agent and the gate both skip bot-opened PRs, so you merge the bump once CI is green. Closing a bump declines that version. Turn it off withgh workflow disable sdk-bump.yml.Where the gate differs from the app's
REQUIRED_CHECKS = ['Build, typecheck & test']). The app's gate leaves "did the required checks pass?" to branch protection, which this repo doesn't have yet; without this, the gate would merge on a red or still-running build. Branch protection should still require the same check.pr-agent-ackis checked against the review it answers. The app's gate relies on thesynchronizerun to remove the label on a new push, and that run can be dropped (runs share one concurrency slot per branch, and a queued run is replaced by the next one queued), so an old acknowledgement could cover a newer commit. Here a label older than PR-Agent's review of the latest commit is ignored and removed.<details>form, so a[blocker]PR-Agent couldn't quote lines for is missed and the PR merges.Setup for James (I can't do these)
Nothing merges on its own until all of these exist. Names are exactly as the workflows read them.
OPENROUTER_API_KEYmainpr-agent-automergeexponential-im/exponential)AUTOMERGE_APP_CLIENT_ID.pemAUTOMERGE_APP_PRIVATE_KEYmain: require this status checkBuild, typecheck & testno-automerge; this one is yours)pr-agent-ackno-automergegh pr list --state open --json number -q '.[].number' | xargs -I{} gh pr edit {} --add-label no-automergeallow_auto_mergestays off. The gate calls the merge API itself, pinned to the reviewed commit; it never queues GitHub auto-merge.A workflow that names an environment creates it if it is missing, with no branch limit. So after this merges,
pr-agent-automergemay already exist when you get to it: add themainlimit before you store the key.What happens before setup
.pr_agent.tomlfrommain, which has none until this merges, so it falls back to its default OpenAI model and stops for want of a key. After the merge it needsOPENROUTER_API_KEY, and is red on every PR without it. It is not meant to be a required check.AUTOMERGE_APP_CLIENT_IDis missing: no comment, no merge, a notice in the run saying why.Checked
ci.ymlon Node 22 from a cleannpm ci: the SDK check, build, typecheck and 395 tests pass.check-sdk-pin.mjsagainst 14 fixture lockfiles (unpublished range, unpublished pin,file:and git ranges, a linked SDK, a local tarball, a wrong integrity hash, a missing entry, a stale lockfile) and againstmainas it is today, where it fails with "package-lock.json doesn't match package.json".actionlintis clean on all four workflows.Build, typecheck & teston the same commit, and holds on a blocker, an untagged finding, a security concern, a partial or stale review, red, running or missing CI, a bot or fork PR, a draft, andno-automerge.pr-agent-ackfrom anyone butpositonicis ignored, as is one older than the review, and it never overrides red CI. The 11 scenarios for the two fixes fail on the gate as first pushed and pass now.mainwithghandgit pushstubbed: it produces the same lockfile change as the first commit here, updates an open bump, leaves a closed one alone, and never lowers a range that is ahead of npm.Not merged by me, and no
pr-agent-acklabel.