Skip to content

Gate: scope per-server stages to touched servers, run each suite once, lighter draft gate - #5761

Merged
cliffhall merged 4 commits into
v2/mainfrom
v2/chore/5759-gate-scope-and-coverage
Dec 5, 2026
Merged

cliffhall merged 4 commits into
v2/mainfrom
v2/chore/5759-gate-scope-and-coverage

Conversation

@cliffhall

Copy link
Copy Markdown
Member

Closes #5759

Description

The pre-push gate now runs each test suite once, under coverage, and only for the servers a change touches. A lighter gate covers pushes to a draft PR.

  • Scope. scripts/gate-servers.mjs replaces the per-server part of the local:gate:stages chain.
    • scripts/lib/gate-scope.mjs decides which servers to run from the files changed since the merge base with origin/v2/main.
    • A change confined to src/<server>/ directories gates those servers only. A pending changeset does not widen the scope.
    • Any other path gates every server: a root manifest or lockfile, scripts/, a workflow, root configuration, a doc, or a skill. The rule is "anything outside a server directory", not a list of repository-wide files, because a list goes stale silently.
    • An empty change gates every server, so a gate can never pass by running nothing.
    • The log prints the decision and its reason before anything runs, for example [gate] servers: memory — every changed file is under `src/memory/` .
    • GATE_BASE=<ref> scopes against another base, such as a stacked branch's parent. resolveBase reads it, so the interface diff and the image smoke compare against the same base.
  • Each suite runs once. The gate used to run every TypeScript suite twice: once in validate, then again under coverage. Python's pytest ran twice the same way, in validate:py and coverage:py.
    • Each TypeScript workspace gains check (format, lint, typecheck, build), and validate becomes check && test, unchanged in effect.
    • The gate runs check then coverage.
    • validate-py.mjs gains --no-pytest, so Python runs validate:py --no-pytest then coverage:py.
    • The per-file thresholds still fail the gate.
  • Draft PRs. npm run local:gate:draft runs under the same lease: verify:dco plus the touched servers' full validate and validate:py, with no coverage and no smoke.
    • In CI, a push whose only open PRs are drafts skips coverage, the boot smoke, the interface diff and the image smoke. A new draft job decides this.
    • ready_for_review runs the full set again: it is a new trigger on typescript.yml and python.yml, and a new pull_request type on mcp-interface-diff.yml and image-smoke.yml.
    • The CI suites also run once. Coverage is the test run; plain npm test runs only on the Node 26 leg or for a draft.
  • CI parity. workflow-gate.test.mjs reads gatePlan when it checks that every npm script CI runs is reached by local:gate. So "the gate runs every check CI runs" in AGENTS.md is still enforced and still true.
  • Docs and skills. Updated: docs/quality-gate.md (the stage table, and new sections on scope, on running each suite once, and on draft PRs), AGENTS.md Before pushing, CONTRIBUTING.md, and the pre-push-gate and pr-flow skills.

Server Details

None (repository-wide): gate tooling, CI workflows, docs and skills. Each TypeScript server's package.json gains a check script, and its validate now runs check && test. Nothing a server publishes changes, so there is no changeset.

Motivation and Context

See #5759. A fix confined to one server waited on all seven servers' suites, each run twice. On a saturated gate lease, that time multiplies across every queued gate.

How Has This Been Tested?

This change has no client-facing surface, so the evidence is targeted probes.

Gate timings for a one-server change. Each probe added one line to src/memory/index.ts in a fresh worktree. The times below are how long each gate held the lease. Time spent waiting for the lease is excluded: it ran 5 to 30 minutes, because the lease was saturated.

Before (origin/v2/main 002bcce) After (this branch)
Servers gated all 7 memory
Root guards and script tests 9s 9s
TypeScript validate / check 25s (4 servers, with tests) 4s (memory, no tests)
TypeScript coverage 8s 3s
validate:py 2m23s (with pytest) not run
coverage:py 2m07s not run
Boot smoke 4s (15 pairs) 0s (2 pairs)
Interface diff and image smoke 5s (memory) 5s (memory)
Total 5m22s 21s

The after probe ran with GATE_BASE set to the branch tip, so that only the probe's own change counted.

This branch's own gate. The branch changes repository-wide files, so this gate ran every server, and the interface diff and image smoke covered all seven. npm run local:gate exited 0 on 1ad5861 in 3m30s. The full gate before this change took 5m22s even with the interface diff and image smoke covering memory only. The gain is the Python suites, which no longer run twice: 4m30s before, 2m13s after.

[gate] servers: every server — `.claude/skills/pr-flow/SKILL.md`, `.claude/skills/pre-push-gate/SKILL.md`, `.github/workflows/image-smoke.yml` and 17 more are outside every server directory
[gate] check passed (14s)
[gate] coverage passed (9s)
[gate] validate:py passed (6s)
[gate] coverage:py passed (127s)
[gate] smoke passed (4s)

A defect the probes caught, fixed in 1ad5861. The first after probe failed. GATE_BASE narrowed the per-server stages, but the interface diff still compared against origin/v2/main. It therefore selected the Python servers, whose .venvs the narrowed gate had never synced. resolveBase now reads GATE_BASE, and the re-run passed.

Unit tests. All of these run in test:scripts.

  • gate-scope.test.mjs: a one-server change; several servers across both languages; a changeset; every kind of repository-wide path; a sibling directory such as src/memory-next/; an empty change.
  • gate-servers.test.mjs: the plan for each scope, with no plain test pass in the full gate; the draft plan; the printed reason; fail-fast; GATE_BASE; bad arguments.
  • validate-py.test.mjs: --no-pytest.
  • interface-diff.test.mjs: the precedence --base, then GATE_BASE.
  • workflow-gate.test.mjs: the CI parity check, which now reads gatePlan.

verify:skills and verify:skills:cli pass.

The draft-PR path in CI (the draft job, and the ready_for_review trigger) is exercised for the first time by this PR's own runs.

Breaking Changes

None for users. For contributors:

  • local:gate gates only the servers a change touches. Set GATE_BASE on a stacked branch.
  • local:gate:draft is new.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Also a chore: gate tooling and CI.

Checklist

  • I have read the MCP Protocol Documentation (not applicable: no protocol surface changes)
  • My changes follow MCP security best practices (not applicable: no server code changes; the new draft jobs hold pull-requests: read only)
  • I have updated the server's README accordingly (not applicable: no server-facing change)
  • I have added a changeset (npm run changeset) if this changes what a TypeScript server publishes (not applicable: only package.json scripts change; nothing published changes)
  • I have tested this with an LLM client (not applicable: gate tooling, with no client-facing surface; see the targeted probes above)
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options (GATE_BASE, --draft, --no-pytest)

Additional context

🤖 Generated with Claude Code

cliffhall and others added 2 commits December 4, 2026 16:44
The pre-push gate ran every test suite twice (the plain pass in each
workspace's `validate` and in `validate:py`, then the same suites under
coverage) and ran every server whatever a change touched.

- `scripts/gate-servers.mjs` runs the per-server stages once, for the
  servers the change touches: each TypeScript workspace's new `check`
  (its `validate` without the tests) then `coverage`, `validate:py
  --no-pytest` then `coverage:py`, then the smoke. It prints the servers
  it chose and why. `scripts/lib/gate-scope.mjs` holds the rule: a change
  confined to `src/<server>/` gates those servers; any other file gates
  every server.
- `npm run local:gate:draft` (under the same lease) is the gate for a push
  to a draft PR: `verify:dco` and the touched servers' `validate`.
- CI: `typescript.yml` and `python.yml` run each suite once (the Node 24
  validate leg and the Python test leg leave the suite to coverage), and a
  new `draft` job skips coverage and the smoke on a draft PR's pushes;
  the interface diff and the image smoke skip drafts too.
  `ready_for_review` runs what a draft skipped.
- The workflow guard's tests read the per-server plan, so "the gate runs
  every check CI runs" stays enforced.
- AGENTS.md, docs/quality-gate.md, CONTRIBUTING.md and the pre-push-gate
  and pr-flow skills describe the new rules.

Closes #5759

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
GATE_BASE scoped only the per-server stages; interface-diff and
image-smoke still compared against origin/v2/main, so on a stacked
branch they could select a server the per-server stages never set up
(a Python server with no .venv). resolveBase now falls back to
GATE_BASE when no --base is given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall cliffhall added the v2 label Dec 4, 2026
@changeset-bot

changeset-bot Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5d7b27e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

sequentialthinking: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 1 0 0 0
Head 1 0 0 0

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

filesystem: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 16 0 0 1
Head 16 0 0 1

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

memory: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 9 0 1 0
Head 9 0 1 0

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

fetch: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 1 1 0 0
Head 1 1 0 0

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

time: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 3 0 0 0
Head 3 0 0 0

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

everything: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 23 4 8 5
Head 23 4 8 5

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

git: MCP interface diff

Base: 597a263e419e (Merge pull request #5758 from modelcontextprotocol/v2/chore/5757-gate-lease-slots)
Head: the build in this checkout, at cbcbc81ab329 (Merge 5d7b27e into 597a263)

Diffed because it was named (--server).

✅ No interface changes detected.

Tools Prompts Resources Resource templates
Base 14 2 0 0
Head 14 2 0 0

Updated by this run for 5d7b27e8cce8198d6bdedb944693a48b01bc5995.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test fails on CI’s shallow checkout because HEAD~1 is unavailable, while draft-PR detection incorrectly skips coverage and Boot smoke checks for development-branch pushes.

2 open issues
What changed in this PR

Reduces pre-push gate time for the reference servers by limiting work to affected packages and removing duplicate test runs, addressing #5759.

Changes:

  • Scope per-server checks to changed directories, with a shared GATE_BASE override.
  • Run full-gate tests once under coverage.
  • Add lighter draft gates and restore skipped CI checks when PRs become ready.
File Description
src/​sequentialthinking/​package.json Separate checks from tests.
src/​memory/​package.json Separate checks from tests.
src/​filesystem/​package.json Separate checks from tests.
src/​everything/​package.json Separate checks from tests.
scripts/​validate-py.test.mjs Test pytest-skip argument handling.
scripts/​validate-py.mjs Add --no-pytest.
scripts/​lib/​workflow-gate.test.mjs Check scoped-stage CI parity.
scripts/​lib/​gate-scope.test.mjs Test server selection rules.
scripts/​lib/​gate-scope.mjs Determine affected servers.
scripts/​interface-diff.test.mjs Test base override precedence.
scripts/​interface-diff.mjs Honor GATE_BASE.
scripts/​image-smoke.mjs Document GATE_BASE usage.
scripts/​gate-servers.test.mjs Test plans and failure handling.
scripts/​gate-servers.mjs Execute scoped full or draft stages.
package.json Wire scoped and draft gates.
docs/​quality-gate.md Explain revised gate behavior.
CONTRIBUTING.md Update contributor gate guidance.
AGENTS.md Update gate and testing rules.
.github/​workflows/​typescript.yml Avoid duplicate tests; handle drafts.
.github/​workflows/​python.yml Avoid duplicate tests; handle drafts.
.github/​workflows/​mcp-interface-diff.yml Defer draft checks until ready.
.github/​workflows/​image-smoke.yml Defer draft checks until ready.
.claude/​skills/​pre-push-gate/​SKILL.md Update gate troubleshooting.
.claude/​skills/​pr-flow/​SKILL.md Document draft-to-ready procedure.

Review effort: Balanced

Comment thread scripts/interface-diff.test.mjs Resolved
Comment thread .github/workflows/typescript.yml Resolved
Copilot round 1 on #5761:
- The draft lookup classified pushes to v2/main as a draft's when the
  release merge PR (head v2/main) is a draft, skipping coverage and the
  smoke there. Both workflows now skip the lookup for v2/main and main,
  and workflow-gate.test.mjs pins it.
- The resolveBase test used HEAD~1, which CI's one-commit checkout does
  not hold. It now tests precedence with HEAD and a bad GATE_BASE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1: two findings, both defects in what this PR added, both fixed in e1aaff4. The gate exited 0 on that commit.

  • P1, interface-diff.test.mjs: the resolveBase test used HEAD~1, which CI's one-commit checkout does not hold. It now tests precedence with HEAD and an unresolvable GATE_BASE.
  • P2, the draft job in typescript.yml and python.yml: a draft release merge PR has v2/main as its head, so a push to v2/main could read as a draft's and skip coverage and the smoke. The lookup now skips v2/main and main, and workflow-gate.test.mjs pins that in both workflows.

Requesting round 2.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the scoped pre-push gate and draft CI changes.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2: clean, with no open findings. Both round-1 findings show as resolved. The review loop ends on this first clean round.

…ope-and-coverage

docs/quality-gate.md: keeps "The lease covers `local:gate` and
`local:gate:draft` only." followed by #5758's "### Lease slots"
subsection, as agreed with #5758's author. docs/ai-software-factory.md's
gate summary now says the per-server stages are scoped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: cliffhall <cliff@futurescale.com>
@cliffhall
cliffhall merged commit 93f0355 into v2/main Dec 5, 2026
67 checks passed
@cliffhall
cliffhall deleted the v2/chore/5759-gate-scope-and-coverage branch December 5, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gate: run each suite once under coverage, scope stages to touched servers, and gate fully only when a draft PR is marked ready

2 participants