Skip to content

ci: the merge-queue reuse decision is built and run from the base commit - #866

Merged
Blind-Striker merged 2 commits into
masterfrom
ci/826-reuse-judge-from-base
Nov 14, 2026
Merged

Blind-Striker merged 2 commits into
masterfrom
ci/826-reuse-judge-from-base

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?
The merge-queue reuse decision is now built and run from the merge group's base commit instead of from the group's own tree, so a pull request can no longer change the judge that decides whether its green PR run can be reused. With that, the self-vouching guard shrinks from eight paths to .github/ only. SDK pin moves and dependency refreshes (global.json, Directory.Packages.props, tools/, Directory.Build.*, nuget.config) can now skip the second full CI run when the queue tests the exact tree their PR run already tested.

  • ci.yml, reuse job only:
    • after the facts are gathered, git worktree add --detach "$RUNNER_TEMP/judge" "$QUEUE_BASE"; a failed add refuses with unavailable judge;
    • the SDK comes from the judge's global.json, and "Decide reuse" runs with working-directory: ${{ runner.temp }}/judge;
    • the shell's eight-path guard list is gone.
  • The judge lives under $RUNNER_TEMP, a sibling of the workspace, on purpose: MSBuild, NuGet and the SDK resolver search parent folders for Directory.Build.*, Directory.Packages.props, nuget.config and global.json, so a judge inside the group's checkout would import the group's files.
  • MergeGroupReuseDecision.IsGuarded (rule 5) now matches .github/ only, case-insensitively. Permissions are unchanged: contents, actions and pull-requests read. No secret is added.
  • quality-gates.md and workflow.md describe the base-commit judge.

Design check: #826 (comment)

Related Issue(s):

🔄 Type of Change

  • 🔧 Build, CI, or tooling
  • 🧪 Test improvements

🎯 Protocol & API Surface

  • No change to the public API surface
  • The pinned snapshot (spec/) is untouched
  • Nothing under external/ was hand-edited

🧪 Testing

  • Unit / contract tests added or updated
  • Decision rows (MergeGroupReuseCommandTests):
    • the formerly guarded non-.github/ rows now expect all rules hold, and a root Directory.Packages.props row is added;
    • tools/example.cs+different-tree and Directory.Packages.props+different-base-tree show that rule 4 still demands the exact tested tree;
    • the .github/ rows stay rule 5.
  • New repository gate (CiMergeGroupReuseTests), against the real ci.yml, asserts:
    • QUEUE_BASE comes from merge_group.base_sha;
    • the worktree add is the fail-closed if ! git worktree add …; then form;
    • the SDK comes from the judge's global.json;
    • only "Decide reuse" runs dotnet, with exactly the base tool's command, from the judge;
    • the job never names the workspace;
    • the permissions are exactly the three reads.
  • Mutants, each failing at its own assertion:
    • the worktree from HEAD;
    • QUEUE_BASE from github.sha;
    • || true after the add;
    • the decision run from the workspace;
    • the group's global.json;
    • a dotnet tool restore in the workspace, both one-line and as a block;
    • a commented copy of the command plus another file;
    • a relative path out of the judge;
    • IsGuarded back to the old eight-path list (fails 12 decision rows).
  • The ci.yml read helpers moved out of CiBenchmarkGuardTests into a sealed CiWorkflow(IFileSystem); its assertions are unchanged.

Test Environment: Windows (UNDERDARK), SDK 11.0.100; the Tools project on net10.0.

✅ Completion Gate

  • The local check in quality-gates.md passes: slopwatch, the Release build (0 warnings), both format passes, verify-clones (0 new clones), and OpenCode.Sdk.Tools.Tests except NativeAot (2791/2791), on the rebased head. OpenCode.Sdk.Tests is untouched.

📚 Documentation

  • Canon updated: docs/engineering/quality-gates.md (the reuse paragraph) and docs/engineering/workflow.md (its relay)
  • No CHANGELOG.md entry: CI only, nothing a consumer sees

✅ Code Quality Checklist

  • No new analyzer warnings or suppressions
  • No tests skipped, weakened, or deleted; the changed expected results are the rule-5 rows this design re-rules
  • All tests pass locally
  • Branch is up to date with master

🔍 Additional Notes

What to check on this PR's own merge group: this PR touches .github/, so the queue judges it with the current base's tool and must answer rule 5: guarded path and run in full. The reuse job should end success with that reason, not failure. That is the first live proof that the judge builds in the worktree. The first later pin or dependency PR should report all rules hold.

Review: the change had an independent Grok 4.7 review and an independent Opus review. Neither found a way for the group's tree outside .github/ to reach the judge, and both walked every failure path to the full run. Their test findings are folded into the second commit.

🎯 Reviewer Focus Areas

  • Security implications (who builds and runs the reuse judge)
  • Test coverage, including the refusal paths

Addresses #826. Build and run the reuse judge in a separate base-commit worktree outside the workspace, using the base's global.json. Rule 5 now guards .github/ only.
…and its one executed command

Review fix-ups for #826. The gate now asserts that QUEUE_BASE comes from
merge_group.base_sha, that the judge worktree is added in the fail-closed
"if ! git worktree add ...; then" form, that only the "Decide reuse" step
runs a dotnet command, that this command is exactly the base's tool run
(a commented copy or a relative path out of the judge fails), and that
the job never names github.workspace. The redundant checkout path check
is gone: the working-directory assertion already catches a judge placed
anywhere else.

quality-gates.md says a PR is judged by the base's tool and rules, and
that the workflow calling the judge comes from the group's tree, so a
workflow change is covered by review.
@Blind-Striker Blind-Striker added this to the Next milestone Nov 14, 2026
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 14, 2026
Merged via the queue into master with commit 2958e2c Nov 14, 2026
17 checks passed
@Blind-Striker
Blind-Striker deleted the ci/826-reuse-judge-from-base branch November 14, 2026 21:18
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.

CI: run the merge-queue reuse decision from the base commit, so pin and dependency changes can skip the second full run

1 participant