Skip to content

ci(cora): skip the review on a release sync identical to develop (#1022) - #1279

Merged
ajianaz merged 7 commits into
developfrom
ci/cora-skip-release-sync
Nov 26, 2026
Merged

ajianaz merged 7 commits into
developfrom
ci/cora-skip-release-sync

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What

The Cora Review job skips its review step on a release sync PR whose git tree is identical to a commit on develop, and says so in the job summary ("skipped, tree identical to develop at "). Every other PR, and every doubt, runs the normal review.

Refs #1022. This PR does not say Closes: see "Open point: the trigger" below.

Why

A release sync (chore/release-* into main, one squash commit with the tree of develop) is hundreds of files and tens of thousands of lines, all already reviewed in the PRs that put them on develop. Cora cannot cover that range in the job limit, and "Review could not complete" is a merge blocker (v0.9.0 precedent, AGENTS.md infra facts). A tree equal to develop's adds no content to review, and any change makes the trees differ and turns the review back on.

Changes

  • scripts/cora-release-sync.sh (new): the decision. Six positional arguments (event, base ref, head ref, head repo, base repo, head sha), exit 0 = skip (stdout <develop-sha> <tree>), exit 1 = run the review, with a reason on stderr. It compares real objects only (GIT_NO_REPLACE_OBJECTS=1). Skips only when ALL hold:
    1. event is pull_request, base is main, head branch matches ^chore/release-[0-9A-Za-z._-]+$ (a filter only);
    2. head repository equals base repository, both non-empty (no fork);
    3. the history is complete (not shallow) and the PR head is exactly one commit on top of main: its only parent is the current tip of refs/remotes/origin/main and main..head is 1 commit (so the tree that lands on main is the head tree for any merge method);
    4. git rev-parse <head>^{tree} equals the tree of a commit in the first-parent history (newest 200) of refs/remotes/origin/develop, the ref the checkout fetched from the base repository; and the checked-out tree equals the head tree.
  • .github/workflows/cora-review.yml: new step Is this a release sync with the tree of develop? after the checkout. It reads the script from refs/remotes/origin/develop (git show), runs it with the event data passed through env: (no ${{ }} inside run:) and without the Cora token (env -u ACCESS_TOKEN), validates the output with a regex, then writes the summary and a ::notice::. The ci: a docs-only PR makes the Cora review answer "could not complete" because docs/** is excluded #914 scope step and the review step are gated on steps.release_sync.outputs.skip != 'true'. Permissions (contents: read, pull-requests: write, security-events: write, id-token: write), the job name Cora Review and the pull_request trigger are unchanged. No pull_request_target.
  • scripts/test-cora-release-sync.sh (new, wired into the Format job of ci.yml next to the ci: a docs-only PR makes the Cora review answer "could not complete" because docs/** is excluded #914 self-test).
  • CONTRIBUTING.md (new "Release sync PRs (ci(cora): skip Cora Review on a release sync PR whose tree is identical to develop #1022)" under the merge gate with its residual risks, a paragraph under Release validation), AGENTS.md (release flow and the large-release-range note, minimal), CHANGELOG.md: what is skipped, when, and how to check it by hand.

Security properties

  • The proof is two tree hashes computed from git objects. The title, body, commit message and branch name are never proof; the branch name and repository names only narrow the cases down.
  • develop comes from the base repository: the job's origin is the base repository and the script reads only the fully qualified refs/remotes/origin/develop. A local branch develop, a branch named origin/develop, a tag develop or another remote's develop cannot stand in (tested).
  • The decision script is read from develop, never from the PR checkout. A PR cannot edit the check. Where the script is missing or unreadable, the review runs.
  • Only git plumbing runs in the deciding step (rev-parse, rev-list, log --format=%H %T): no diff driver, textconv, hook or filter, and nothing from the PR checkout is executed.
  • Fail closed: wrong argument count, empty value, abbreviated or non-existing sha, shallow clone, missing ref, odd git output, or a non-matching regex on the script output all mean skip=false.
  • Fork PRs never skip. No new permission, secret or trigger.
  • A skipped PR's tree equals develop's, so its workflow files equal develop's too.

Negative cases (all run the normal review; all in the self-test)

Second commit with the same tree; one differing file; one extra file; a merge commit with develop's tree; a root commit; main moved after the sync was cut; a sync cut from an older main; a commit message claiming identity; head branch develop, chore/release, chore/release-, feat/x, evil/chore/release-v1, with a space, with a newline, empty; base develop / main2 / empty; events pull_request_target, push, merge_group, empty; fork, look-alike repo name, deleted fork (empty head repo), empty base repo; empty, abbreviated, uppercase, non-existing, ref-name and tree-object head shas; 5, 0 and 7 arguments; checkout not at the head tree; no develop ref, only a local develop branch, a local origin/develop branch plus a tag, another remote's develop; develop lacking the tree; tree only on another branch; tree only in a merged side branch (off the first-parent line); the matching develop commit more than 200 commits back; a shallow clone; a refs/replace entry that makes an evil head look like a develop commit. Positive: identical tree on the tip of main (also with develop moved on after the cut, 150 commits back, and on a branch checkout).

Residual risks

  • The PR can edit the workflow file itself (a pull_request run uses the merge ref's workflow), as it could before this change; the usual guard is branch protection and CODEOWNERS on .github/workflows/. When the skip legitimately applies the workflow files equal develop's.
  • Time of check vs. time of merge (also a PR retargeted to main): if main moves after the check ran, GitHub does not re-run the job and the merge result is a three-way merge. A merge queue (merge_group is skipped by this job) or "up to date" strict checks close it; otherwise re-push the release branch. Documented in CONTRIBUTING.
  • The 200-commit window accepts an older develop tree (a release cut some merges back); all content in it was on develop and reviewed there, but the release is then older than develop's tip. Documented in CONTRIBUTING.
  • A trust anchor moved: the script is read from develop rather than main, because main does not have the script until the first release containing it (reading it from main would defeat the first use). develop is the ref the proof itself is anchored to and is protected the same way. The independent review judged this acceptable; scripts/ is not in review.exclude, so a change to the script is itself reviewed.
  • GITHUB_STEP_SUMMARY and the notice are the visible record; no PR comment is posted.

Open point: the trigger

cora-review.yml lists branches: [develop] since #1021 (owner decision of 2026-11-20): PRs into main get no Cora Review run at all today, so this step has no effect until main is listed again. I did not widen the trigger: it reverses an owner decision and would also put a full (failing) review back on develop-headed PRs to main. To activate: branches: [develop, main] in .github/workflows/cora-review.yml, an owner call. The workflow file of a pull_request run comes from the merge ref, so this change, and that one, only take effect for a release branch built after they land on develop; the v0.12.0 sync (#1021) cannot use it.

Testing

  • bash scripts/test-cora-release-sync.sh: all cases passed on the final head (throwaway bare origin and clone; 1 skipping case plus its variants, the rest negative). The new replace-ref case fails when the GIT_NO_REPLACE_OBJECTS line is removed (checked).
  • bash scripts/test-cora-all-excluded.sh: all cases passed (unchanged).
  • The new workflow step's run: block, extracted from the YAML and run locally in a clone with a GitHub-style merge commit as HEAD: skip case wrote skip=true, the summary and the notice; fork case and a missing script on develop wrote skip=false (run before the env -u ACCESS_TOKEN change, which adds no other behaviour).
  • python3 -c 'import yaml; yaml.safe_load(...)' on .github/workflows/cora-review.yml and ci.yml: both parse. actionlint, shellcheck and yamllint are not installed here and were not run.
  • scripts/arch-check.sh all: ok.
  • Not run: the real workflow on GitHub; scripts/review-local.sh / cora review (no cora binary here); cargo fmt/clippy/test (no Rust changed). The Cora gate on this PR is the CI job.
  • Independent security review (CI path): a fresh read-only reviewer that did not write the change reviewed the diff and ran both self-tests, with its own bypass attempts (extra-file head, refs/replace, hex-named branch and tag on the head sha, trailing newline in the head ref, an info/grafts entry, a merge commit with develop's tree). Verdict: SECURE WITH NITS. Quoting, the develop trust anchor, origin being the base repository, the parent and window rules, the output regex, fail-closed paths and the step gating were checked OK. Findings and handling: (1) a refs/replace entry made a script skip an evil head: fixed with GIT_NO_REPLACE_OBJECTS=1 and a self-test case (a PR cannot plant that ref, defence in depth); (2) the script ran with ACCESS_TOKEN in its environment: fixed with env -u ACCESS_TOKEN; (3) time of check vs. time of merge and (4) the 200-commit window: documented as residual risks in CONTRIBUTING and above; (5) the by-hand check is simpler than the job: accepted, it is a human check. Not verifiable by the reviewer: the real GitHub runtime (the merge ref and actions/checkout layout; if they differ the script never skips, fail-closed), and whether branch protection on main requires up-to-date branches.

…self-test

scripts/cora-release-sync.sh decides, from git objects only, whether a PR is
a release sync (chore/release-* into main, same repository, one commit on the
tip of main) whose tree equals the tree of a develop commit. It fails closed.
scripts/test-cora-release-sync.sh is its self-test (one positive case, many
negative ones) and runs in the Format job (#1022).
A step after the checkout runs the script from develop and, only on a proven
tree identity, skips the review and writes 'skipped, tree identical to develop
at <sha>' to the job summary. The check name, permissions and trigger are
unchanged; any doubt runs the review (#1022).
CONTRIBUTING (merge gate, release), AGENTS.md (release flow, large release
ranges) and the changelog say when the release sync is skipped and how to
check it by hand.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit f431fed into develop Nov 26, 2026
34 checks passed
ajianaz added a commit that referenced this pull request Nov 28, 2026
… skipped by proof (#1022) (#1333)

`Cora Review` triggers on pull requests into `main` again (`branches: [develop, main]`). The skip by tree identity for a release sync (`scripts/cora-release-sync.sh`, merged in #1279) now has an effect: a PR from `chore/release-*` into `main` that is one commit on the tip of `main` with the tree of a `develop` commit ends green with "skipped, tree identical to develop at <sha>"; any other PR into `main` gets the normal review.
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