Skip to content

Commit 805bdf8

Browse files
authored
Merge branch 'v2/main' into v2/feat/4872-knowledge-skills
2 parents 153f6e6 + ac7a0d3 commit 805bdf8

28 files changed

Lines changed: 4607 additions & 167 deletions

‎.claude/skills/pr-flow/SKILL.md‎

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,23 @@ _someone else's_ certification never is.
111111

112112
## 4. Run the gate
113113

114-
Run what CI runs for everything the change touches, and fix what fails before
115-
pushing:
114+
Format, then run the pre-push gate, and fix what fails before pushing:
116115

117-
| Change touches | Command |
116+
```sh
117+
npm run format # TypeScript; in a Python server: uv run --frozen ruff format .
118+
npm run local:gate; echo "EXIT=$?"
119+
```
120+
121+
`local:gate` runs every check CI runs, for both languages, whatever the change
122+
touched. Verify by the exit code, not by grepping the output. What each stage
123+
checks and how to fix a red one is `/pre-push-gate`; the stage list is
124+
[`docs/quality-gate.md`](../../../docs/quality-gate.md).
125+
126+
One thing the gate deliberately leaves out:
127+
128+
| Change touches | Also run |
118129
| --- | --- |
119-
| Anything (always) | `npm run validate:guards` (CI's "Root guards" job: root format and lint, the coverage guards, `verify:skills`, the script tests) |
120-
| A TypeScript server | `npm run validate -w src/<server>` (format check, lint, typecheck, build, test) |
121-
| A Python server | `npm run validate:py -- <server>` (locked sync, ruff, ruff format, pyright, pytest, build) |
122-
| Anything under `.claude/skills/` | `npm run verify:skills:cli` (the pinned `claude plugin validate` that CI's "Root guards" job also runs; `validate:guards` only runs the in-repo `verify:skills`) |
123-
| A skill's description, or a new skill | `npm run skills:eval` for the **whole** suite (spends model calls; not in CI). See `AGENTS.md` **Maintaining the skills** |
124-
125-
Verify by exit code, not by grepping the output. Formatting failures are fixed
126-
with `npm run format` at the root (TypeScript), or `uv run --frozen ruff format .`
127-
in the server's directory (Python).
130+
| A skill's description, or a new skill | `npm run skills:eval` for the **whole** suite (spends model calls; not in the gate or CI). See `AGENTS.md` **Maintaining the skills** |
128131

129132
## 5. Client evidence
130133

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
name: pre-push-gate
3+
description: "Run this repo's pre-push gate and fix it when it goes red. Use when npm run local:gate fails or a stage of it does (verify:install-fresh, a root guard, lint, typecheck, ruff, pyright, pytest, verify:skills:cli, the boot smoke); when the gate says it is waiting on the gate lease; or when checking whether a gate run really passed."
4+
disable-model-invocation: false
5+
---
6+
7+
# The pre-push gate
8+
9+
**The rule** (stated in [`AGENTS.md`](../../../AGENTS.md#before-pushing)): run
10+
**`npm run local:gate`** before every push, and push only when it exits 0.
11+
`npm run validate` is the inner-loop check and is **not** a substitute.
12+
13+
What each stage covers, and how the gate relates to CI, is
14+
[`docs/quality-gate.md`](../../../docs/quality-gate.md). The stage list is
15+
written out there and nowhere else, on purpose. This skill is how to run the
16+
gate and what to do when it goes red.
17+
18+
## Run it
19+
20+
```sh
21+
cd <repo root>
22+
npm run format # TypeScript. It rewrites files; the gate only checks.
23+
npm run local:gate; echo "EXIT=$?"
24+
```
25+
26+
In a Python server you changed, format with `uv run --frozen ruff format .`
27+
from that server's directory.
28+
29+
**Verify by exit code, not by grepping the output.** A Prettier failure is a
30+
few `[warn]` lines that match no obvious failure pattern, and `validate:py`
31+
prints `PASS` for two servers above the `FAIL` for the third.
32+
33+
⚠️ If you run it as a background task, the harness's "exit code 0"
34+
notification describes the _wrapper_ (the trailing `echo`), not the gate. Read
35+
the `EXIT=` line.
36+
37+
**Background it and wait for the notification.** Do not spend turns tailing
38+
the log; see `AGENTS.md` **Waiting on long-running work**.
39+
40+
The gate stops at the first failing stage, so the last stage header in the
41+
output is the one that failed. Fix it, then **re-run the whole gate**, not just
42+
that stage: the stages after it have not run yet.
43+
44+
## Diagnosing a failing stage
45+
46+
Each heading is a stage or guard name as it appears in the output.
47+
48+
### `verify:install-fresh`
49+
50+
An installed package's version disagrees with `package-lock.json`
51+
(`node_modules` is older than the tree you pulled), or a `package.json`
52+
declares a dependency the lockfile does not record. **Run `npm install` at the
53+
repo root**, commit the lockfile if it changed, and re-run. It is the first stage because a stale install otherwise
54+
passes every static check and fails later as a test reporting the _old_
55+
dependency's behavior. Do not "fix" that test.
56+
57+
### `format:check` / `format:check:root`
58+
59+
Run `npm run format` at the **root**. It covers `scripts/`, the root configs
60+
and every workspace; a single workspace's `format` does not.
61+
62+
### `verify:format-coverage`
63+
64+
A tracked source file is matched by no `format:check` glob, so nothing checks
65+
its formatting. Put it where a glob reaches it, or extend the glob. Do not add
66+
it to `.prettierignore` to make the guard pass.
67+
68+
### `verify:skills` / `verify:skills:cli`
69+
70+
A `.claude/skills` manifest does not parse, declares no
71+
`disable-model-invocation`, a model-invoked skill lacks its eval cases, or the
72+
listing is over budget. The message names the skill. The usual cause is an
73+
unquoted `#` or `:` in a `description`.
74+
75+
`verify:skills:cli` is the authoritative validator. It fetches the pinned
76+
Claude Code CLI with `npx` when the installed one is a different version, so it
77+
**fails offline**. (`validate:py`'s `sync` step is the other stage that can:
78+
`uv sync --locked` downloads when a server's environment is missing or stale.)
79+
80+
### `verify:typecheck-coverage`
81+
82+
A tracked `.ts` file lands in no `tsc` program. Usually a new test or config
83+
file outside the server's `tsconfig.test.json` `include`. Add it there.
84+
85+
### `verify:dep-lockstep`
86+
87+
Two workspaces declare different ranges of a shared toolchain package
88+
(`typescript`, `vitest`, `@vitest/coverage-v8`, `prettier`, `@types/node`).
89+
Bump it in **every** workspace that declares it, then `npm install`.
90+
91+
### `verify:no-test-retries`
92+
93+
A test declares a retry: Vitest's `retry:` option or `--retry` flag, a pytest
94+
rerun plugin, or a `flaky` marker. Remove it and fix why the test fails. A race
95+
is fixed with fake timers or an awaited condition; a port collision with a port
96+
the OS hands out.
97+
98+
The guard matches spellings, not semantics, so an unrelated `retry:` property
99+
in server source trips it too. Rename the property, or restructure so the key
100+
is not written as `retry:` at the start of an expression.
101+
102+
### `test:scripts`
103+
104+
A guard's own unit test failed. Two of these are about the gate itself and
105+
mean a change broke one of its invariants
106+
(`scripts/lib/workflow-gate.test.mjs`):
107+
108+
- **"GitHub CI must not run a local-only script"**: a workflow invokes a
109+
`local:*` script. Call the underlying checks as their own steps instead.
110+
- **"every CI job needs a timeout"**: a job was added without
111+
`timeout-minutes`.
112+
- **"local:gate must run …"**: a stage was dropped from `local:gate:stages`,
113+
or `local:gate` is no longer exactly the lease wrapper.
114+
115+
Do not edit the guard to make these pass; the split they enforce is the design.
116+
117+
### `lint`
118+
119+
**There is no warning tier.** Every `lint` script runs `--max-warnings 0`, so
120+
a warning fails exactly as an error does. Fix the finding. If a rule genuinely
121+
must be waived on one line, use its inline disable comment **with a one-line
122+
justification**; never widen an ignore list or turn the rule off.
123+
124+
### `typecheck` / `build`
125+
126+
`typecheck` runs `tsc -p tsconfig.test.json` (source and tests); `build` runs
127+
the server's own `tsc`. An error in a test file only shows in `typecheck`.
128+
129+
### `test` (a TypeScript workspace)
130+
131+
Re-run just that suite to iterate: `npm test -w src/<server>`. Read the failure
132+
before changing a timeout: an assertion that races is a bug in the test.
133+
134+
### `validate:py`
135+
136+
The summary at the end names the failing server, and the step that failed is
137+
the last `[validate:py] <server>: <step>` line above it. Re-run one server with
138+
`npm run validate:py -- <server>`.
139+
140+
| Step | Fix |
141+
| --- | --- |
142+
| `sync` | `uv.lock` no longer matches `pyproject.toml`. Run `uv lock` in that server and commit the lockfile |
143+
| `ruff check` | Fix the finding; `uv run --frozen ruff check --fix .` handles the mechanical ones |
144+
| `ruff format --check` | `uv run --frozen ruff format .` |
145+
| `pyright` | A type error. Add the missing hint rather than an ignore |
146+
| `pytest` | `uv run --frozen pytest -k <name>` in that server to iterate |
147+
| `build` | A packaging error in `pyproject.toml` |
148+
149+
`uv: command not found` means `uv` is not installed. Never substitute `pip`.
150+
151+
### `smoke`
152+
153+
`smoke — FAIL <server> over <transport>` followed by the reason and the tail
154+
of the server's stderr. Re-run a subset with
155+
`node scripts/smoke-servers.mjs <server> [<server> …]`.
156+
157+
- **"dist/index.js does not exist — build first"**: you ran the smoke on its
158+
own before building. `npm run build -w src/<server>`. Inside the gate this
159+
cannot happen, since `validate` builds first.
160+
- **".venv does not exist — sync first"**: the same for a Python server. The
161+
smoke never creates an environment; `npm run validate:py -- <server>` does.
162+
- **The server exited before answering**: the stderr tail shows why. This is
163+
what the smoke is for: the unit tests import the source, so a wrong `bin`
164+
path, a file missing from `dist/`, or an import that only resolves under the
165+
test runner passes them and fails here.
166+
- **"tools/list does not include …"**: a tool was renamed or removed. A
167+
published tool is never renamed (`AGENTS.md` **MCP protocol**); if the change
168+
is intended, update that server's entry in `SERVERS`.
169+
- **A new server fails `test:scripts`** with "every server directory in the
170+
repo has a smoke entry": add it to `SERVERS` in `scripts/smoke-servers.mjs`.
171+
172+
## Waiting on the lease
173+
174+
A gate that starts with
175+
176+
```
177+
gate-lease: pid 12345 in /path/to/other-worktree, running for 40s holds the gate lease; waiting for its turn so the gates do not contend. SERVERS_SKIP_GATE_LEASE=1 runs anyway.
178+
```
179+
180+
is queued behind another worktree's gate. That is normal: it starts once the
181+
holder (and any gate that arrived before it) finishes. The line names the
182+
holder's pid and worktree, so you can tell whether to wait or to stop that
183+
gate.
184+
185+
- A holder that was **killed** stops refreshing its lock and is taken over
186+
after 30 seconds. Nothing needs cleaning up.
187+
- A waiter that prints `gave up after 45m` names a lock path. Check whether
188+
the holder it names is alive and hung (stop it), or dead with a lock
189+
directory that could not be removed (remove that directory).
190+
- Do **not** set `SERVERS_SKIP_GATE_LEASE=1` to get a result sooner. Two
191+
overlapping gates each take longer than one queued behind the other.
192+
- Do **not** write your own "wait until no gate is running" loop. Two of them
193+
deadlock on each other, and a `pgrep` for the gate's command line matches the
194+
loop itself.
195+
196+
The details of the lease are in
197+
[`docs/quality-gate.md`](../../../docs/quality-gate.md#the-gate-lease).
198+
199+
## Not part of the gate
200+
201+
`npm run skills:eval` (real model calls) and `npm run coverage` (a report; no
202+
threshold is enforced yet) are separate commands. Run the eval suite when you
203+
add a skill or change a description.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[
2+
{
3+
"prompt": "npm run local:gate just failed at the verify:install-fresh stage. What do I do?",
4+
"expect": "pre-push-gate"
5+
},
6+
{
7+
"prompt": "The gate printed 'gate-lease: pid 4412 holds the gate lease; waiting for its turn'. Is something stuck? Should I skip the lease?",
8+
"expect": "pre-push-gate"
9+
},
10+
{
11+
"prompt": "The boot smoke stage went red for the git server over stdio. How do I work out what is wrong?",
12+
"expect": "pre-push-gate"
13+
},
14+
{
15+
"prompt": "I ran the pre-push gate in the background and the task says exit code 0. How do I confirm it really passed?",
16+
"expect": "pre-push-gate"
17+
},
18+
{
19+
"prompt": "validate:py reports FAIL for fetch at the sync step during the gate. How do I fix it?",
20+
"expect": "pre-push-gate"
21+
},
22+
{
23+
"prompt": "verify:no-test-retries is failing in my gate run but I never added a test retry. What is it matching?",
24+
"expect": "pre-push-gate"
25+
},
26+
{
27+
"prompt": "What is 17 multiplied by 23?",
28+
"expect": null
29+
},
30+
{
31+
"prompt": "Write a limerick about a cat.",
32+
"expect": null
33+
}
34+
]

‎.claude/skills/security-advisory/SKILL.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ undone; it takes a re-scoped token or an admin in the UI. That asymmetry is the
244244
reason for the read-first rule.
245245

246246
Fix and review inside the fork. The fix follows the rules in `AGENTS.md` like
247-
any other change: a regression test that fails before the fix, and the checks
248-
under **Before pushing** for the server it touches. Name the branch
247+
any other change: a regression test that fails before the fix, and the gate
248+
under **Before pushing**. Name the branch
249249
`v2/fix/<ghsa-id>` (lowercase, **no descriptive slug**, since a branch name
250250
outlives the fork once merged), and keep commit messages equally opaque until
251251
publication. **The fork's PR targets `v2/main`**, never `main`: check its base

‎.github/workflows/claude.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
jobs:
1414
claude:
15+
timeout-minutes: 30
1516
if: |
1617
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
1718
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||

‎.github/workflows/python.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ concurrency:
1212

1313
jobs:
1414
detect-packages:
15+
timeout-minutes: 5
1516
runs-on: ubuntu-latest
1617
outputs:
1718
packages: ${{ steps.find-packages.outputs.packages }}
@@ -26,6 +27,7 @@ jobs:
2627
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
2728
2829
script-tests:
30+
timeout-minutes: 5
2931
name: Test the Python gate script
3032
runs-on: ubuntu-latest
3133
steps:
@@ -39,6 +41,7 @@ jobs:
3941
run: node --test scripts/validate-py.test.mjs
4042

4143
test:
44+
timeout-minutes: 15
4245
needs: [detect-packages]
4346
strategy:
4447
matrix:
@@ -66,6 +69,7 @@ jobs:
6669
run: node scripts/validate-py.mjs ${{ matrix.package }}
6770

6871
build:
72+
timeout-minutes: 10
6973
needs: [detect-packages, test]
7074
strategy:
7175
matrix:

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55

66
jobs:
77
create-metadata:
8+
timeout-minutes: 10
89
runs-on: ubuntu-latest
910
if: github.repository_owner == 'modelcontextprotocol'
1011
outputs:
@@ -63,6 +64,7 @@ jobs:
6364
echo "npm_packages=$NPM" >> $GITHUB_OUTPUT
6465
6566
update-packages:
67+
timeout-minutes: 10
6668
needs: [create-metadata]
6769
if: ${{ needs.create-metadata.outputs.npm_packages != '[]' || needs.create-metadata.outputs.pypi_packages != '[]' }}
6870
runs-on: ubuntu-latest
@@ -104,6 +106,7 @@ jobs:
104106
fi
105107
106108
publish-pypi:
109+
timeout-minutes: 15
107110
needs: [update-packages, create-metadata]
108111
if: ${{ needs.create-metadata.outputs.pypi_packages != '[]' && needs.create-metadata.outputs.pypi_packages != '' }}
109112
strategy:
@@ -156,6 +159,7 @@ jobs:
156159
skip-existing: true # re-runs tolerate already-uploaded files
157160

158161
publish-npm:
162+
timeout-minutes: 15
159163
needs: [update-packages, create-metadata]
160164
if: ${{ needs.create-metadata.outputs.npm_packages != '[]' && needs.create-metadata.outputs.npm_packages != '' }}
161165
strategy:
@@ -215,6 +219,7 @@ jobs:
215219
NPM_CONFIG_PROVENANCE: "true"
216220

217221
create-release:
222+
timeout-minutes: 10
218223
needs: [update-packages, create-metadata, publish-pypi, publish-npm]
219224
if: |
220225
always() &&

0 commit comments

Comments
 (0)