Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/INTEGRATION-TEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ the documentation versions; do not infer named-client compatibility.
returned `next_start_index`. Check no gaps/duplicate anchors and bounded
response bodies. Retrieve individual sections via
`get_docs(slug="whatsnew/3.15", version="3.15", anchor=...)`.
7. Preserve the original 3.11–3.13 frozen regression index and run
`uv run --locked python -m benchmarks.regression --index <retained-index> --output regression-results.json`.
The new separate 3.15 fixtures do not replace that gate.
7. Preserve the original 3.11–3.13 frozen regression index and follow the
[local benchmark workflow](../CONTRIBUTING.md#local-benchmark-workflow),
selecting that retained index with `--index`. The separate 3.15 fixtures
do not replace the local baseline comparison.

## Evidence log

Expand Down
58 changes: 51 additions & 7 deletions .github/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ or disable checks.

1. Merge the version/changelog PR after independent current-head verification
and all required CI. `pyproject.toml`, `uv.lock`, `server.json` and its package
entry must agree. CI covers Python 3.12–3.14 on Ubuntu and macOS, the real
benchmark corpus, offline full-index regression, and installed-wheel stdio.
entry must agree. CI covers ordinary product tests on Python 3.12–3.14 on
Ubuntu and macOS, static analysis, security checks and installed-wheel stdio.
Full-index installation E2E remains required. Benchmarks run locally and do
not gate releases. See the [local benchmark workflow](../CONTRIBUTING.md#local-benchmark-workflow).
If an update from `main` changed the head, carry verification forward only
under the amendment's rule: a conflict-free update, green required checks,
a new record for the new head, and either (a) a rebase whose
Expand Down Expand Up @@ -56,11 +58,16 @@ That file pins `hatchling` and every dependency with SHA-256 hashes, and the bui
runs `uv build --build-constraint .github/build-constraints.txt --require-hashes`.
Every project build in the build job uses that file. The job syncs dependencies with
`uv sync --locked --dev --no-install-project --no-build`, which builds neither the
project nor any source distribution. It installs the built wheel with
`uv pip install --no-deps dist/*.whl` and runs every later command with
`uv run --no-sync`, so nothing re-syncs and rebuilds the project. The tests run
against that installed wheel, and the test suite's own wheel build gets the same
constraints through `UV_BUILD_CONSTRAINT` and `UV_REQUIRE_HASHES`.
project nor any source distribution, in a fresh `UV_PROJECT_ENVIRONMENT` under
`RUNNER_TEMP`. It installs the built wheel with
`uv pip install --python "$UV_PROJECT_ENVIRONMENT/bin/python" --no-deps dist/*.whl`
and runs later commands with `uv run --no-sync`. Product tests also inherit
`UV_NO_SYNC=1`, protecting the installation from nested `uv run` calls. Before
tests, the job requires imports from that environment's site-packages, compares
installed `schema.sql` and `synonyms.yaml` bytes with the wheel, and bootstraps an
in-memory database including FTS5. No source-tree resource fallback is used.
The test suite's own wheel build gets the same constraints through
`UV_BUILD_CONSTRAINT` and `UV_REQUIRE_HASHES`. Benchmark tests remain excluded.
To update it, run
`echo hatchling | uv pip compile --generate-hashes --universal --python-version 3.12 --upgrade - -o .github/build-constraints.txt`,
then
Expand All @@ -76,3 +83,40 @@ unchanged, with no bypass actors.
No routine human reviewer is required. If publication partially fails, record
which registries succeeded and diagnose the failure; never overwrite a published
version, move a tag, or claim a release complete from a partial result.

## One-time v0.5.0 recovery

The failed v0.5.0 release spent its tag. It must continue to peel to
`3a48f832404a11fb18de7d56c27c8e84ba57c2cc`. The original wheel contains
`storage/schema.sql`: a local reproduction of the benchmark sandbox's nested
`uv run --locked` replaced the installed wheel with an editable install while
the parent test process retained its old site-packages imports. The next database
bootstrap then failed to read the removed schema. Running the same nested command
with the inherited no-sync guard preserved the wheel and allowed the bootstrap to
succeed. The sandbox test itself filters its subprocess environment, so excluding
benchmark tests remains necessary. This repairs the test environment; it does
not change the v0.5.0 package source.

After independent review, merge of this repair, and green required checks on its
exact main commit, the owner may create **only** `v0.5.0-recovery.1` on that commit.
The existing `v*` creation restrictions, immutable-tag rules (no update/delete or
bypass actors), and `pypi` tag environment must cover this control tag as well as
`v0.5.0`. Keep those protections; do not move either tag. This implementation does
not create tags or change repository settings.

Only the exact protected `refs/tags/v0.5.0-recovery.1` push selects recovery. The
eligibility job checks that its tag still names the event commit and applies the
normal main ancestry, merged-PR, CodeQL, owner-record and main-check gates. It
also peels the original tag to the pinned SHA and rechecks that commit's evidence
under its original frozen gate, including the historical `Product regression`
success. A missing, changed or failing record/check aborts recovery. Other tag
pushes retain the ordinary release path; no arbitrary ref or manual artifact
input is accepted.

The repaired workflow builds and validates the manifest from the **original**
pinned source commit. Its verified target tag is `v0.5.0`, including the explicit
GitHub Release `tag_name` and package/manifest version checks. The existing
full-index E2E, artifact-ID/checksum checks, attestations, Trusted Publishing job,
`pypi` environment, MCP Registry publication and GitHub Release job remain in the
path. Provenance identifies the recovery workflow run; the gate identifies the
original source commit. Confirm all publication results using step 5 above.
52 changes: 48 additions & 4 deletions .github/scripts/release_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import os
import re
import urllib.request
from pathlib import Path

RECOVERY_TAG = "v0.5.0-recovery.1"
RECOVERY_TARGET = "v0.5.0"
RECOVERY_SHA = "3a48f832404a11fb18de7d56c27c8e84ba57c2cc"

REQUIRED = {
"Test (Python 3.12, ubuntu-latest)",
Expand All @@ -19,7 +24,6 @@
"Dependency audit",
"Analyze",
"Installed package smoke",
"Product regression",
}
# First line of the owner's PR comment that records an independent verification.
RECORD = re.compile(r"Independent verification: (PASS|FAIL)")
Expand All @@ -42,7 +46,7 @@ def verdict(comment, owner: str, head: str, merged_at: str) -> str | None:
return match[1] if match else None


def require_eligible(api, sha: str, owner: str) -> None:
def require_eligible(api, sha: str, owner: str, *, required=None) -> None:
if not re.fullmatch(r"[0-9a-f]{40}", sha) or not owner:
raise ValueError("Exact commit and repository owner are required")
if api(f"compare/{sha}...main")["status"] not in {"ahead", "identical"}:
Expand Down Expand Up @@ -80,12 +84,50 @@ def require_eligible(api, sha: str, owner: str) -> None:
if check["app"]["id"] == 15368:
latest[check["name"]] = check
failed = sorted(
name for name in REQUIRED if latest.get(name, {}).get("conclusion") != "success"
name for name in (REQUIRED if required is None else required)
if latest.get(name, {}).get("conclusion") != "success"
)
if failed:
raise ValueError(f"Missing or failing main checks: {', '.join(failed)}")


def tag_commit(api, tag: str) -> str:
"""Peel lightweight or annotated tags, failing closed on malformed chains."""
obj = api(f"git/ref/tags/{tag}")["object"]
for _ in range(10):
if not re.fullmatch(r"[0-9a-f]{40}", obj["sha"]):
break
if obj["type"] == "commit":
return obj["sha"]
if obj["type"] != "tag":
break
obj = api(f"git/tags/{obj['sha']}")["object"]
raise ValueError("Tag does not peel to an exact commit")


def release_target(api, env) -> tuple[str, str]:
"""Only the named immutable recovery event may build a different commit."""
sha, tag = env["GITHUB_SHA"], env["GITHUB_REF_NAME"]
owner = env.get("GITHUB_REPOSITORY_OWNER", "")
require_eligible(api, sha, owner)
if tag == RECOVERY_TAG:
if (
env.get("GITHUB_EVENT_NAME") != "push"
or env.get("GITHUB_REF") != f"refs/tags/{RECOVERY_TAG}"
or env.get("GITHUB_REF_PROTECTED") != "true"
):
raise ValueError("Recovery requires the exact protected tag push")
if tag_commit(api, RECOVERY_TAG) != sha:
raise ValueError("Recovery tag no longer names the event commit")
if tag_commit(api, RECOVERY_TARGET) != RECOVERY_SHA:
raise ValueError("Original v0.5.0 tag moved")
# Recheck the original frozen gate, including its then-required benchmark
# status. This does not restore a benchmark gate for new releases.
require_eligible(api, RECOVERY_SHA, owner, required=REQUIRED | {"Product regression"})
return RECOVERY_SHA, RECOVERY_TARGET
return sha, tag


def main() -> None:
repo = os.environ["GITHUB_REPOSITORY"]
token = os.environ["GH_TOKEN"]
Expand All @@ -102,7 +144,9 @@ def api(path):
with urllib.request.urlopen(request, timeout=30) as response:
return json.load(response)

require_eligible(api, os.environ["GITHUB_SHA"], os.environ.get("GITHUB_REPOSITORY_OWNER", ""))
sha, tag = release_target(api, os.environ)
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as output:
output.write(f"build-sha={sha}\ntarget-tag={tag}\n")
print("Verified main commit, owner verification record and required main checks.")


Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ jobs:
- name: Run type checker
run: uv run --locked pyright src/ benchmarks/

- name: Validate frozen benchmark corpus
run: uv run --locked python -m benchmarks validate-corpus --corpus docs/benchmarks/corpus.yml --schema docs/benchmarks/corpus.schema.json

- name: Run tests
run: uv run --locked pytest --tb=short -q
run: uv run --locked pytest --ignore=tests/benchmarks --tb=short -q

- name: Verify wheel contents
run: |
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/product-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,3 @@ jobs:
cp tests/test_stdio_smoke.py "${RUNNER_TEMP}/test_stdio_smoke.py"
cd "${RUNNER_TEMP}"
installed/bin/python -m pytest --import-mode=importlib test_stdio_smoke.py -q

regression:
name: Product regression
runs-on: ubuntu-latest
timeout-minutes: 60
env:
UV_PYTHON: '3.13'
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
- run: echo "XDG_CACHE_HOME=${RUNNER_TEMP}/docs-cache" >> "$GITHUB_ENV"
- run: uv sync --locked --dev
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
id: index
with:
path: ${{ runner.temp }}/docs-cache/mcp-python-docs/index.db
key: docs-regression-v1-${{ runner.os }}-${{ hashFiles('src/mcp_server_python_docs/ingestion/**', 'src/mcp_server_python_docs/storage/**', 'src/mcp_server_python_docs/__main__.py', 'uv.lock') }}
- name: Build full reference index
if: steps.index.outputs.cache-hit != 'true'
run: uv run --locked python-docs-mcp-server build-index --versions 3.11,3.12,3.13
- name: Enforce offline retrieval baseline
run: uv run --locked python -m benchmarks.regression --output regression-results.json
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
if: always()
with:
name: product-regression-results
path: regression-results.json
if-no-files-found: error
72 changes: 45 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
name: Release eligibility
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
build-sha: ${{ steps.gate.outputs.build-sha }}
target-tag: ${{ steps.gate.outputs.target-tag }}
permissions:
contents: read
checks: read
Expand All @@ -27,6 +30,7 @@ jobs:
with:
persist-credentials: false
- name: Require verified main commit
id: gate
env:
GH_TOKEN: ${{ github.token }}
run: python .github/scripts/release_gate.py
Expand All @@ -36,6 +40,8 @@ jobs:
runs-on: ubuntu-latest
name: Build & Test
timeout-minutes: 180
env:
RELEASE_TAG: ${{ needs.eligibility.outputs.target-tag }}
outputs:
dist-id: ${{ steps.upload-dist.outputs.artifact-id }}
dist-sha256: ${{ steps.dist-sha256.outputs.dist-sha256 }}
Expand All @@ -44,32 +50,35 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
ref: ${{ needs.eligibility.outputs.build-sha }}

- name: Install uv
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0

- name: Set up Python 3.13
run: uv python install 3.13
run: |
uv python install 3.13
echo "UV_PROJECT_ENVIRONMENT=$RUNNER_TEMP/release-product-venv" >> "$GITHUB_ENV"

- name: Install dependencies
run: uv sync --locked --dev --no-install-project --no-build

- name: Verify tag matches package version
run: |
TAG_VERSION="${GITHUB_REF_NAME#v}"
TAG_VERSION="${RELEASE_TAG#v}"
PKG_VERSION=$(uv run --no-sync python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match pyproject.toml version ${PKG_VERSION}"
echo "::error::Tag ${RELEASE_TAG} does not match pyproject.toml version ${PKG_VERSION}"
exit 1
fi
SERVER_VERSION=$(uv run --no-sync python -c "import json; print(json.load(open('server.json'))['version'])")
PACKAGE_VERSION=$(uv run --no-sync python -c "import json; print(json.load(open('server.json'))['packages'][0]['version'])")
if [ "$TAG_VERSION" != "$SERVER_VERSION" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match server.json version ${SERVER_VERSION}"
echo "::error::Tag ${RELEASE_TAG} does not match server.json version ${SERVER_VERSION}"
exit 1
fi
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
echo "::error::Tag ${GITHUB_REF_NAME} does not match server.json package version ${PACKAGE_VERSION}"
echo "::error::Tag ${RELEASE_TAG} does not match server.json package version ${PACKAGE_VERSION}"
exit 1
fi
echo "Version check passed: ${PKG_VERSION}"
Expand All @@ -78,7 +87,30 @@ jobs:
run: uv build --build-constraint .github/build-constraints.txt --require-hashes

- name: Install the built wheel
run: uv pip install --no-deps dist/*.whl
run: uv pip install --python "$UV_PROJECT_ENVIRONMENT/bin/python" --no-deps dist/*.whl

- name: Verify wheel contents and installed database bootstrap
run: |
uv run --no-sync python - <<'PY'
import sqlite3
import sysconfig
import zipfile
from pathlib import Path
from mcp_server_python_docs.storage import db

wheel, = Path("dist").glob("*.whl")
installed = Path(db.__file__).resolve().parents[1]
assert installed.is_relative_to(Path(sysconfig.get_path("purelib")).resolve()), installed
with zipfile.ZipFile(wheel) as archive:
for resource in ("storage/schema.sql", "data/synonyms.yaml"):
expected = archive.read(f"mcp_server_python_docs/{resource}")
assert expected and (installed / resource).read_bytes() == expected, resource
with sqlite3.connect(":memory:") as conn:
db.bootstrap_schema(conn)
assert conn.execute("PRAGMA user_version").fetchone()[0] == db.INDEX_FORMAT_VERSION
conn.execute("SELECT * FROM sections_fts LIMIT 0")
print(f"Verified wheel resources and installed database bootstrap: {installed}")
PY

- name: Run linter
run: uv run --no-sync ruff check src/ tests/ benchmarks/ ops/ .github/scripts/
Expand All @@ -90,32 +122,15 @@ jobs:
env:
UV_BUILD_CONSTRAINT: .github/build-constraints.txt
UV_REQUIRE_HASHES: "1"
run: uv run --no-sync pytest --tb=short -q

- name: Validate frozen benchmark corpus
run: uv run --no-sync python -m benchmarks validate-corpus --corpus docs/benchmarks/corpus.yml --schema docs/benchmarks/corpus.schema.json
# Inherit into nested uv run calls; the CLI flag alone is not inherited.
UV_NO_SYNC: "1"
run: uv run --no-sync pytest --ignore=tests/benchmarks --tb=short -q

- name: Validate MCP manifest before publication
run: |
bash .github/scripts/install_publisher.sh
"${RUNNER_TEMP}/mcp-publisher" validate server.json

- name: Verify wheel contents
run: |
uv run --no-sync python -c "
import zipfile, glob, sys
wheels = glob.glob('dist/*.whl')
if not wheels:
print('No wheel found')
sys.exit(1)
with zipfile.ZipFile(wheels[0]) as zf:
names = zf.namelist()
if not any('synonyms.yaml' in n for n in names):
print('synonyms.yaml not found in wheel')
sys.exit(1)
print('Wheel contents OK')
"

- name: Record dist checksums
id: dist-sha256
run: |
Expand Down Expand Up @@ -180,7 +195,7 @@ jobs:
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1

publish-mcp-registry:
needs: publish
needs: [eligibility, publish]
runs-on: ubuntu-latest
name: Publish to MCP Registry
timeout-minutes: 10
Expand All @@ -192,6 +207,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
ref: ${{ needs.eligibility.outputs.build-sha }}

- name: Install verified MCP publisher
run: bash .github/scripts/install_publisher.sh
Expand All @@ -204,6 +220,7 @@ jobs:

github-release:
needs:
- eligibility
- build
- publish
- publish-mcp-registry
Expand Down Expand Up @@ -236,5 +253,6 @@ jobs:
- name: Create GitHub Release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3
with:
tag_name: ${{ needs.eligibility.outputs.target-tag }}
files: dist/*
generate_release_notes: true
Loading
Loading