diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fad93c10..81b9eb4d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,12 @@ jobs: - name: No generated or machine-specific files are tracked run: scripts/check-tracked-artifacts.sh + # Every discovered package (Cargo, npm, PyPI, pub.dev) carries the + # workspace version, internal ranges accept it, lockfiles agree, and + # release.yml publishes each publishable package. Node built-ins only. + - name: Release versions are consistent + run: node scripts/check-versions.mjs + # --------------------------------------------------------------------------- # Published benchmarks — schema, deterministic graphic, links, documented # commands. Runs no benchmark (those are manual: public-benchmarks.yml). diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bd3d9da5..000ca82a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,10 @@ name: Release on: push: tags: ["v*.*.*"] + # Release dry run on a branch (run it on main before tagging): the whole + # verify phase on that commit, plus the credentials preflight below. Every + # publish job runs only for a version tag, so a dispatch publishes nothing. + workflow_dispatch: # Never let two releases run against each other. concurrency: @@ -46,6 +50,20 @@ jobs: with: node-version: 22 + # The tag must name the version the manifests already carry. The npm + # jobs set their version from the tag, but the wheels, the pub.dev + # package and the server binary are built from the manifests, so a tag + # that disagrees would publish mixed versions. + - name: Tag matches every release manifest + run: | + set -euo pipefail + node scripts/check-versions.mjs + WS="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml)" + if [ "${{ github.ref_type }}" = tag ] && [ "v$WS" != "${{ github.ref_name }}" ]; then + echo "Error: tag ${{ github.ref_name }} but the manifests are at $WS (scripts/bump-version.sh)." + exit 1 + fi + - name: CLI — tests working-directory: cli run: node --test @@ -295,11 +313,9 @@ jobs: run: dart pub publish --dry-run # Python wheels (sdks/python): abi3, one per platform for CPython 3.11+. - # VERIFY ONLY: the wheels are built (and, where the runner can run them, - # tested) and uploaded as workflow artifacts. There is no PyPI publish job - # yet, and this job is deliberately not in the publish jobs' `needs` until - # the Python SDK is released: a wheel failure must not block the npm, - # pub.dev and image releases before then. + # Built (and, where the runner can run them, tested) here; checked together + # in verify-python; published to PyPI by publish-pypi. Every publish job + # needs verify-python, so a broken wheel stops the whole release. build-python: name: Verify — Python wheel ${{ matrix.platform }} runs-on: ${{ matrix.os }} @@ -359,6 +375,38 @@ jobs: path: sdks/python/dist/*.whl if-no-files-found: error + # All five wheels together: one per platform, the tag's version, and each + # passing the package check (tags, metadata, contents, RECORD hashes, + # version consistency) and `twine check`. + verify-python: + name: Verify — Python distribution + needs: [build-python] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - uses: actions/setup-python@v6 + with: + python-version: "3.11" + + - uses: actions/download-artifact@v7 + with: + pattern: python-wheel-* + merge-multiple: true + path: dist + + - name: Check the wheels + run: | + set -euo pipefail + # verify-js checked that a tag equals this version. + VERSION="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml)" + ls -l dist + COUNT=$(ls dist/checkgate-"$VERSION"-*.whl | wc -l) + if [ "$COUNT" -ne 5 ]; then echo "Error: expected 5 wheels for $VERSION, found $COUNT."; exit 1; fi + python scripts/check-python-package.py dist --version "$VERSION" + python -m pip install "twine>=6.1,<7" + python -m twine check --strict dist/*.whl + # Build the image without pushing, so a broken or vulnerable image blocks the # release instead of being discovered after the npm packages are already live. build-docker: @@ -402,13 +450,101 @@ jobs: vuln-type: 'os,library' severity: 'CRITICAL' + # Credentials preflight (workflow_dispatch only). Proves, without + # publishing, what the tag run will need: an npm identity that can publish + # in the @checkgate scope, parseable pub.dev credentials, and a PyPI trusted + # publisher matching this workflow and environment. Prints no secret. + # + # The PyPI check exchanges this job's OIDC token for a short-lived upload + # token (discarded unused), exactly as publish-pypi will. If the publisher + # is still *pending* (project not yet on PyPI), that exchange creates the + # empty project `checkgate` under the account that registered it. + preflight-credentials: + name: Preflight — publishing credentials + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/checkgate/ + permissions: + contents: read + id-token: write + steps: + - uses: actions/setup-node@v5 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + + - name: npm — identity and @checkgate scope access + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + run: | + set -euo pipefail + [ -n "$NODE_AUTH_TOKEN" ] || { echo "Error: NPM_TOKEN is not set."; exit 1; } + WHO="$(npm whoami)" + echo "npm identity: $WHO" + npm access list packages --json > access.json + node -e ' + const a = require("./access.json"); + const need = ["node","web","cli","edge","ssr","react-native"].map((p) => "@checkgate/" + p); + const bad = need.filter((p) => a[p] !== "read-write"); + for (const p of need) console.log(` ${p}: ${a[p] ?? "no access"}`); + if (bad.length) { console.error("Error: no read-write access to " + bad.join(", ")); process.exit(1); } + ' + # The new packages (openfeature-provider, node-integrations, + # mcp-server) are created by their first publish. Org members of + # any role may create packages in the org scope; a granular token + # must also cover the @checkgate scope, not only listed packages. + if npm org ls checkgate "$WHO" --json > role.json 2>/dev/null; then + echo "role in the checkgate org: $(node -p 'Object.values(require("./role.json"))[0] ?? "none"')" + else + echo "::warning::Could not read the checkgate org role (the token may lack organization read permission). Confirm on npmjs.com that this token's package scope includes @checkgate." + fi + for p in openfeature-provider node-integrations mcp-server; do + if npm view "@checkgate/$p" version >/dev/null 2>&1; then + echo " @checkgate/$p already exists: $(npm view @checkgate/$p versions --json | tr -d '\n ')" + else + echo " @checkgate/$p does not exist yet (its first publish creates it)" + fi + done + + - name: pub.dev — credentials present and well-formed + env: + PUB_CREDENTIALS: ${{ secrets.PUB_CREDENTIALS }} + run: | + set -euo pipefail + [ -n "$PUB_CREDENTIALS" ] || { echo "Error: PUB_CREDENTIALS is not set."; exit 1; } + printf '%s' "$PUB_CREDENTIALS" | node -e ' + let b = ""; process.stdin.on("data", (d) => b += d).on("end", () => { + const c = JSON.parse(b); + if (!c.refreshToken) { console.error("Error: PUB_CREDENTIALS has no refreshToken"); process.exit(1); } + console.log("pub.dev credentials: refresh token present"); + });' + + - name: PyPI — trusted publisher accepts this workflow + run: | + set -euo pipefail + AUD="$(curl -fsS https://pypi.org/_/oidc/audience | node -p 'JSON.parse(require("fs").readFileSync(0)).audience')" + OIDC="$(curl -fsS -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=$AUD" | node -p 'JSON.parse(require("fs").readFileSync(0)).value')" + echo "::add-mask::$OIDC" + RESP="$(curl -sS -X POST https://pypi.org/_/oidc/mint-token -H 'Content-Type: application/json' -d "{\"token\":\"$OIDC\"}")" + printf '%s' "$RESP" | node -e ' + const r = JSON.parse(require("fs").readFileSync(0)); + if (r.success && r.token) { console.log("PyPI trusted publishing: accepted (upload token minted and discarded)"); process.exit(0); } + console.error("Error: PyPI refused the trusted-publishing exchange:"); + console.error(JSON.stringify({ message: r.message, errors: (r.errors || []).map((e) => e.code + ": " + e.description) }, null, 2)); + process.exit(1); + ' + echo "PyPI project page: $(curl -s -o /dev/null -w '%{http_code}' https://pypi.org/pypi/checkgate/json)" + # =========================================================================== # PHASE 2 — PUBLISH. Every job below waits for *all* of phase 1. # =========================================================================== publish-node: name: Publish — @checkgate/node - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -477,7 +613,8 @@ jobs: publish-web: name: Publish — @checkgate/web - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -523,7 +660,8 @@ jobs: publish-cli: name: Publish — @checkgate/cli - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -550,7 +688,8 @@ jobs: publish-edge: name: Publish — @checkgate/edge - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -577,7 +716,8 @@ jobs: publish-ssr: name: Publish — @checkgate/ssr - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -604,7 +744,8 @@ jobs: publish-openfeature: name: Publish — @checkgate/openfeature-provider - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -631,7 +772,8 @@ jobs: publish-node-integrations: name: Publish — @checkgate/node-integrations - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -658,7 +800,8 @@ jobs: publish-mcp-server: name: Publish — @checkgate/mcp-server - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -685,7 +828,8 @@ jobs: publish-react-native: name: Publish — @checkgate/react-native - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -716,7 +860,8 @@ jobs: publish-flutter: name: Publish — checkgate_flutter (pub.dev) - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: id-token: write @@ -756,7 +901,8 @@ jobs: publish-docker: name: Publish — Docker image - needs: [verify-js, build-native, build-web, verify-flutter, build-docker] + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] runs-on: ubuntu-latest permissions: contents: read @@ -808,11 +954,39 @@ jobs: run: | cosign sign --yes ${{ env.IMAGE_NAME }}@${{ steps.build-push.outputs.digest }} + # PyPI trusted publishing (OIDC): no stored token. Needs, once, on PyPI: a + # publisher for project `checkgate`, owner checkgate-sh, repository + # checkgate, workflow release.yml, environment `pypi`. The action attaches + # PEP 740 attestations to each file. + publish-pypi: + name: Publish — checkgate (PyPI) + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + needs: [verify-js, build-native, build-web, verify-flutter, verify-python, build-docker] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/checkgate/ + permissions: + contents: read + id-token: write # OIDC token for PyPI trusted publishing and attestations + steps: + - uses: actions/download-artifact@v7 + with: + pattern: python-wheel-* + merge-multiple: true + path: dist + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + packages-dir: dist + # =========================================================================== # Final status — one green check that means "the whole release succeeded". # =========================================================================== release-complete: name: Release complete + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') needs: - publish-node - publish-web @@ -825,11 +999,13 @@ jobs: - publish-react-native - publish-flutter - publish-docker + - publish-pypi runs-on: ubuntu-latest steps: - name: Summary run: | echo "All packages published for ${{ github.ref_name }}:" >> $GITHUB_STEP_SUMMARY - echo "- npm: @checkgate/{node,web,cli,edge,ssr,react-native}" >> $GITHUB_STEP_SUMMARY + echo "- npm: @checkgate/{node,web,cli,edge,ssr,react-native,openfeature-provider,node-integrations,mcp-server}" >> $GITHUB_STEP_SUMMARY echo "- pub.dev: checkgate_flutter" >> $GITHUB_STEP_SUMMARY + echo "- PyPI: checkgate" >> $GITHUB_STEP_SUMMARY echo "- ghcr.io: ${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY diff --git a/CHANGELOG.md b/CHANGELOG.md index 913e5b6c..f6247989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to Checkgate are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/). -## [0.2.0] - Unreleased +## [0.2.0] - 2026-11-22 Developer adoption: OpenFeature, Python, framework integrations, a local quickstart, an evaluation playground, SDK diagnostics and an MCP server for AI @@ -43,6 +43,13 @@ adds a network request per evaluation. 0.2.0 SDKs with a 0.1.31 server; the new server endpoints are additive. - Building the Rust workspace now needs Python 3.11+ for the PyO3 crate (`PYO3_PYTHON` selects the interpreter). +- **Supported runtimes:** server with PostgreSQL 15 (bundled in the image) + or 16 (CI) and Redis, unchanged; Node.js SDK, OpenFeature provider and + framework integrations tested on Node.js 22, 24 and 26 (the integrations + require 22.12+); MCP server tested on Node.js 22; Python SDK on CPython 3.11+ + (abi3 wheels for Linux x86_64/aarch64, macOS x86_64/arm64, Windows x86_64). +- No breaking change to SDK or REST APIs beyond the `202` on governed flag + creation above. ### Added @@ -77,6 +84,23 @@ adds a network request per evaluation. Node.js and Python examples; first-run snippets in the setup wizard and an empty-environment checklist on the dashboard. +### Improved + +- **Onboarding:** a five-minute local quickstart, first-run snippets in the + setup wizard, and SDK pages organised by stack. +- **SDK integration:** one engine and one set of evaluation vectors behind + every SDK, now including OpenFeature, Python and the framework integrations; + `getDetails()` / `get_details()` explain each answer. +- **Diagnostics:** per-stream delivered revision, environment convergence and + SDK health reports, shared between the Node.js and Python SDKs. +- **Package validation:** npm tarballs and Python wheels are checked + (contents, metadata, entry points, types, clean installs) in CI and before + every publish. +- **Release and benchmark infrastructure:** a dedicated-host A/B benchmark + harness with confidence intervals and explicit invalid-run rules + (`scripts/release-benchmarks/`), and a version-consistency check over every + package (`scripts/check-versions.mjs`, run in CI and by the release). + ### Security - **Approval-required environments: flag creation is governed** (inherited @@ -106,6 +130,10 @@ adds a network request per evaluation. 4-vCPU runners produced no Rust core results while reporting success. CI now runs every benchmark once, and the workflow fails when a run fails. - Server tests: a port race in the test harness (`reliability::g2`). +- Python SDK: quadratic buffering of event-stream lines (see Security). +- Release tooling: `scripts/bump-version.sh` left the workspace crates' + `checkgate-core` requirements at `0.1.0`, which no longer resolve at 0.2.0; + it now discovers packages instead of using a fixed list. ### Changed @@ -120,10 +148,45 @@ adds a network request per evaluation. - CI tests the Node.js SDK's native build, the OpenFeature provider and the framework integrations on Node.js 22, 24 and 26 (Node.js 20 reached end of life on 2026-04-30); the MCP server on 22. -- Packages not yet on a registry: the Python package (`checkgate` on PyPI) has - no publish job yet; `@checkgate/openfeature-provider`, - `@checkgate/node-integrations` and `@checkgate/mcp-server` publish with the - release (packaging checked in the release workflow). +- Release workflow: the tag must match every manifest's version; the Python + wheels are checked together and published to PyPI with trusted publishing + (no stored token, with attestations), and every publish job waits for them. + `@checkgate/openfeature-provider`, `@checkgate/node-integrations`, + `@checkgate/mcp-server` and the Python package `checkgate` are first + published with 0.2.0. + +### Performance + +Measured with the dedicated-host A/B harness on a 6-CPU Linux workstation +(v0.1.31 against the 0.2.0 candidate, repeated runs, ratio of medians with a +95 % bootstrap interval; harness and method in `scripts/release-benchmarks/`): + +- No measured regression exceeds the 10 % release threshold. +- Rust core: rule matching is 2.7 % (1 rule) to 4.6 % (10 rules) slower and + weighted multivariate evaluation 3.0 % slower, about 2–10 ns per + evaluation; boolean, rollout, prerequisite and lookup cases are unchanged. + Tracked in #72 and #73. +- Node.js SDK evaluation, snapshot throughput and CPU per request, SSE + propagation (p50/p95/p99 up to 1,000 clients) and memory are unchanged + within measurement noise. + +These are measurements on one host class under the documented workloads, +not a comparison with other products. + +### Known limitations + +- Python SDK: the event queue between the stream and the client is not + bounded by count (#74); snapshot persistence re-encodes the whole cache per + batch (#77). No source distribution, so platforms without a wheel (for + example musl/Alpine) cannot install it yet. +- Evaluation playground: no dedicated concurrency limit (#75). +- `/health/ready` runs a database probe per call (#76). +- Kubernetes operator: retries of an approval-gated update can create + duplicate pending change requests (#78). +- Inert flags (disabled, no `disabled_value`) are still created directly in + approval-required environments, by design; any other creation needs + approval. +- React Native: iOS is not certified. Flutter: no bundled compiled engine. ## [0.1.31] - 2026-11-21 diff --git a/Cargo.lock b/Cargo.lock index a6298e79..cde84526 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -285,7 +285,7 @@ dependencies = [ [[package]] name = "browser" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "console_error_panic_hook", @@ -355,7 +355,7 @@ dependencies = [ [[package]] name = "checkgate-bench" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "criterion", @@ -364,7 +364,7 @@ dependencies = [ [[package]] name = "checkgate-core" -version = "0.1.31" +version = "0.2.0" dependencies = [ "dashmap", "murmur3", @@ -374,7 +374,7 @@ dependencies = [ [[package]] name = "checkgate-python" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "pyo3", @@ -842,7 +842,7 @@ dependencies = [ [[package]] name = "flutter" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "serde_json", @@ -1646,7 +1646,7 @@ dependencies = [ [[package]] name = "nodejs" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "napi", @@ -2224,7 +2224,7 @@ dependencies = [ [[package]] name = "react-native" -version = "0.1.31" +version = "0.2.0" dependencies = [ "checkgate-core", "serde_json", @@ -2535,7 +2535,7 @@ dependencies = [ [[package]] name = "server" -version = "0.1.31" +version = "0.2.0" dependencies = [ "argon2", "async-stream", diff --git a/Cargo.toml b/Cargo.toml index 8181a9dc..86caeb9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ resolver = "2" [workspace.package] -version = "0.1.31" +version = "0.2.0" license = "Apache-2.0" # --------------------------------------------------------------------------- diff --git a/README.md b/README.md index a7eda4d4..bb4d4c43 100644 --- a/README.md +++ b/README.md @@ -136,8 +136,10 @@ Measured on a v0.1.31 release candidate (commit `66cbfec`) on a 4-core Intel lap with the server in Docker limited to 1 vCPU / 512 MiB; v0.1.30 was measured in the same session with runs alternated. 3 runs per measurement, 6 for propagation. The pooled p99 of 198 ms includes two runs made while the host was still loaded; the methodology explains why. These figures describe -that machine and workload, not a guarantee for yours. v0.2.0 has not been re-benchmarked on -dedicated hardware. +that machine and workload, not a guarantee for yours. v0.2.0 was compared with v0.1.31 in a +controlled A/B on a 6-CPU Linux workstation: no measured regression above 10 %; Rust-core rule +matching and weighted variants are 2.7–4.6 % slower (2–10 ns per evaluation), everything else +unchanged ([CHANGELOG](CHANGELOG.md#performance)). Methodology, every run and the raw data: [Public benchmarks](docs/performance/benchmarks.md). ## Infrastructure cost diff --git a/bench/Cargo.toml b/bench/Cargo.toml index a7a17cca..785bfc42 100644 --- a/bench/Cargo.toml +++ b/bench/Cargo.toml @@ -11,7 +11,7 @@ description = "Benchmarks of checkgate-core. Not published." # benchmark-only dependency. [dev-dependencies] -checkgate-core = { version = "0.1.0", path = "../core" } +checkgate-core = { version = "0.2.0", path = "../core" } criterion = { version = "0.8.2", default-features = false, features = ["cargo_bench_support", "rayon"] } serde_json = "1.0.149" diff --git a/bench/public/scripts/validate.py b/bench/public/scripts/validate.py index 38ff3976..823fb000 100755 --- a/bench/public/scripts/validate.py +++ b/bench/public/scripts/validate.py @@ -32,9 +32,19 @@ ROOT = subprocess.run(["git", "rev-parse", "--show-toplevel"], capture_output=True, text=True, check=True).stdout.strip() HERE = os.path.join(ROOT, "bench", "public") -with open(os.path.join(ROOT, "Cargo.toml"), encoding="utf-8") as _f: - VERSION = re.search(r'^version = "([^"]+)"', _f.read(), re.M).group(1) -RESULTS = os.path.join(ROOT, "docs", "performance", "results", f"v{VERSION}") +# The published result set is the newest docs/performance/results/v/ +# with a summary.json, not the workspace version: a release that is not +# re-benchmarked (0.2.0) keeps publishing the previous set, and says so. +_RESULTS_ROOT = os.path.join(ROOT, "docs", "performance", "results") +_SETS = sorted( + (tuple(int(x) for x in d[1:].split(".")), d) + for d in os.listdir(_RESULTS_ROOT) + if re.fullmatch(r"v\d+\.\d+\.\d+", d) and os.path.isfile(os.path.join(_RESULTS_ROOT, d, "summary.json")) +) +if not _SETS: + sys.exit("error: no docs/performance/results/v*/summary.json") +VERSION = _SETS[-1][1][1:] +RESULTS = os.path.join(_RESULTS_ROOT, f"v{VERSION}") SECTIONS = ("Performance", "Infrastructure cost") ASSETS = os.path.join(ROOT, "assets", "benchmarks") DOCS = [os.path.join(ROOT, "docs", "performance", "benchmarks.md"), @@ -271,11 +281,14 @@ def main(): check_readme_numbers(summary) check_links() check_commands() + data_ts = os.path.join(ROOT, "docs", ".vitepress", "data", "benchmarks.data.ts") + if os.path.isfile(data_ts) and f"/results/v{VERSION}/summary.json" not in open(data_ts, encoding="utf-8").read(): + fail(f"docs/.vitepress/data/benchmarks.data.ts does not read the published set v{VERSION}") if errors: for e in errors: print(f"error: {e}", file=sys.stderr) sys.exit(1) - print("ok: benchmark results, graphic, links and documented commands are consistent") + print(f"ok: benchmark results (v{VERSION}), graphic, links and documented commands are consistent") if __name__ == "__main__": diff --git a/cli/README.md b/cli/README.md index 5ec8ef68..0f266b22 100644 --- a/cli/README.md +++ b/cli/README.md @@ -1,5 +1,5 @@
- Checkgate + Checkgate

@checkgate/cli

Generate type-safe flag accessors for TypeScript, Dart, and Rust from your Checkgate flag definitions.

@@ -9,20 +9,26 @@ definitions — straight from a running server or a local JSON export — and em typed module so a wrong key or a mis-typed value is a **compile error**, not a production surprise. +**Current version: 0.2.0.** The commands, options, exit codes and `--json` report are the same +as in 0.1.31; only the version changed. What changed across Checkgate: +[CHANGELOG](https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md). + ## Installation ```bash -npm install -g @checkgate/cli +npm install -g @checkgate/cli@0.2.0 +# or as a dev dependency of your project: +npm install -D @checkgate/cli@0.2.0 # or run without installing: -npx @checkgate/cli typegen --help +npx @checkgate/cli@0.2.0 typegen --help ``` -Requires Node 18+ (uses the built-in `fetch`). Zero runtime dependencies. +The package installs one command, `checkgate`, and has zero runtime dependencies. ## Usage ```bash -checkgate typegen --lang [source] [output] +checkgate typegen --lang [source options] [output options] ``` ### Pick a source @@ -37,14 +43,19 @@ checkgate typegen --lang ts \ --out src/flags.ts ``` -Or from a local JSON file (e.g. a `/flags` API export), which needs no network — ideal for CI: +Or from a local JSON file (e.g. a `/flags` API export), which needs no network and suits CI: ```bash checkgate typegen --lang ts,dart,rust --input flags.json --out-dir ./generated ``` Server connection details can also come from the environment: -`CHECKGATE_URL`, `CHECKGATE_ENV`, `CHECKGATE_TOKEN`. +`CHECKGATE_URL`, `CHECKGATE_ENV`, `CHECKGATE_TOKEN` (and `CHECKGATE_TIMEOUT`). A command-line +option wins over its environment variable. The CLI reads `GET /api/environments/{id}/flags`, +500 flags per page, until it has them all. + +`typegen` is the only command. `checkgate` with no command prints the help to stderr and exits +`2`; `--help` prints it to stdout and exits `0`. ### Options @@ -61,7 +72,7 @@ Server connection details can also come from the environment: | `--check` | | Write nothing; exit `3` if an output file is missing or stale. Needs `--out`/`--out-dir`. | | `--json` | | Print one JSON result object on stdout. Needs `--out`/`--out-dir`. | | `--help` | `-h` | Show help. | -| `--version` | | Show version. | +| `--version` | | Print the installed version (read from the package's `package.json`) and exit `0`. | ## Use in CI: fail the build when generated files are stale @@ -117,7 +128,7 @@ jobs: CHECKGATE_ENV: ${{ vars.CHECKGATE_ENV }} CHECKGATE_TOKEN: ${{ secrets.CHECKGATE_TOKEN }} run: > - npx --yes @checkgate/cli@0.1.31 typegen --lang ts -o src/flags.ts + npx --yes @checkgate/cli@0.2.0 typegen --lang ts -o src/flags.ts --check --json > checkgate-typegen.json - name: Keep the report if: always() @@ -134,7 +145,7 @@ jobs: ("Missing access token"). If you take fork PRs, commit a flags export and check against it with `--input flags.json` instead of `--url`. - The step's log names the stale files (stderr); the JSON report is the artifact. -- Pin the CLI version (`@0.1.31` above) so generated output only changes when you bump it. +- Pin the CLI version (`@0.2.0` above) so generated output only changes when you bump it. ## JSON result (`--json`) @@ -145,7 +156,7 @@ cannot share stdout. ```json { "schema_version": 1, - "tool": { "name": "@checkgate/cli", "version": "0.1.31" }, + "tool": { "name": "@checkgate/cli", "version": "0.2.0" }, "command": "typegen", "mode": "check", "status": "out_of_date", @@ -232,7 +243,7 @@ import { typedFlags } from './flags' const flags = typedFlags(new CheckgateClient({ /* … */ })) const color = flags.getValue('checkout-color', userId) // typed as string -flags.getValue('chekout-color', userId) // ❌ compile error — typo caught +flags.getValue('chekout-color', userId) // compile error: typo caught ``` ### Dart @@ -272,6 +283,33 @@ let fallback = defaults::CHECKOUT_COLOR; // "blue" - Keys that aren't valid identifiers (hyphens, leading digits) are converted safely and de-duplicated per language. ---- +## Runtime compatibility + +- Node.js 18 or later (`engines: >=18`; it uses the built-in `fetch`). CI tests it on Node.js 22. + Node.js 18 and 20 are past end of life, so prefer 22 or later. +- Runs anywhere Node.js does; it needs network access only when it reads from a server. +- Generated files import no SDK. The TypeScript wrapper takes any client with `getValue()` and + `isEnabled()`, such as `@checkgate/node` or `@checkgate/web`; the Dart wrapper takes the client + as `dynamic`; the Rust module is dependency-free. + +## Security + +- Use a token that can only read the environment. A personal access token with scope + `read_only` works for any environment its owner can see; an SDK key works only for its own + environment. +- The token is sent only as an `Authorization: Bearer` header. It never appears in the + `--json` report, in error messages or in generated files. +- A `--url` with `user:password@` is refused (exit `2`) without printing the password. URLs shown + in messages, reports and the generated `// Source:` line have credentials and query strings + removed. + +## Documentation + +- [Typed flags (CLI) guide](https://checkgate-sh.github.io/checkgate/ecosystem/cli) +- [Personal access tokens](https://checkgate-sh.github.io/checkgate/api-reference#personal-access-tokens) +- [Changelog](https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md) + +## License -Part of [Checkgate](https://github.com/checkgate-sh/checkgate) — the self-hosted feature-flag platform. +Apache-2.0. Part of [Checkgate](https://github.com/checkgate-sh/checkgate), the self-hosted +feature-flag platform. diff --git a/cli/package.json b/cli/package.json index 295da44d..9bd9db0d 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/cli", - "version": "0.1.31", + "version": "0.2.0", "description": "Checkgate command-line tools — generate type-safe flag accessors for TypeScript, Dart, and Rust from your flag definitions.", "type": "module", "bin": { diff --git a/dashboard/package.json b/dashboard/package.json index d038fe4c..816ce244 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -1,6 +1,6 @@ { "name": "checkgate-dashboard", - "version": "0.1.31", + "version": "0.2.0", "private": true, "type": "module", "packageManager": "bun@1.4.2", diff --git a/docs/ecosystem/cli.md b/docs/ecosystem/cli.md index a6db3441..e6a142c9 100644 --- a/docs/ecosystem/cli.md +++ b/docs/ecosystem/cli.md @@ -20,7 +20,7 @@ Requires Node 18+ (it uses the built-in `fetch`) and has zero runtime dependenci ## Usage ```bash -checkgate typegen --lang [source] [output] +checkgate typegen --lang [source options] [output options] ``` ### Read from a running server @@ -39,7 +39,7 @@ Connection details can also come from the environment: `CHECKGATE_URL`, `CHECKGA ### Read from a local JSON file -A local `/flags` API export needs no network — ideal for CI: +A local `/flags` API export needs no network, which suits CI: ```bash checkgate typegen --lang ts,dart,rust --input flags.json --out-dir ./generated @@ -116,7 +116,7 @@ jobs: CHECKGATE_ENV: ${{ vars.CHECKGATE_ENV }} CHECKGATE_TOKEN: ${{ secrets.CHECKGATE_TOKEN }} run: > - npx --yes @checkgate/cli@0.1.31 typegen --lang ts -o src/flags.ts + npx --yes @checkgate/cli@0.2.0 typegen --lang ts -o src/flags.ts --check --json > checkgate-typegen.json - name: Keep the report if: always() @@ -133,7 +133,7 @@ jobs: ("Missing access token"). If you take fork PRs, commit a flags export and check against it with `--input flags.json` instead of `--url`. - The step's log names the stale files (stderr); the JSON report is the artifact. -- Pin the CLI version (`@0.1.31` above) so generated output only changes when you bump it. +- Pin the CLI version (`@0.2.0` above) so generated output only changes when you bump it. ## JSON result (`--json`) @@ -144,7 +144,7 @@ cannot share stdout. ```json { "schema_version": 1, - "tool": { "name": "@checkgate/cli", "version": "0.1.31" }, + "tool": { "name": "@checkgate/cli", "version": "0.2.0" }, "command": "typegen", "mode": "check", "status": "out_of_date", @@ -230,7 +230,7 @@ import { typedFlags } from './flags' const flags = typedFlags(new CheckgateClient({ /* … */ })) const color = flags.getValue('checkout-color', userId) // typed as string -flags.getValue('chekout-color', userId) // ❌ compile error — typo caught +flags.getValue('chekout-color', userId) // compile error: typo caught ``` ### Dart diff --git a/docs/performance/benchmarks.md b/docs/performance/benchmarks.md index da7113d2..7f9138bd 100644 --- a/docs/performance/benchmarks.md +++ b/docs/performance/benchmarks.md @@ -59,6 +59,33 @@ propagation ran 6 times per version (why 6: [below](#3-flag-update-propagation)) How results are combined was fixed before the runs ([below](#how-results-are-combined)). +## v0.2.0 regression check + +Before release, 0.2.0 (candidate `ca3dcc7`) was compared with v0.1.31 (`33b9d5f`) using +the dedicated-host A/B harness in +[`scripts/release-benchmarks/`](https://github.com/checkgate-sh/checkgate/tree/main/scripts/release-benchmarks). +The run used a 6-CPU Linux workstation with an idle-host check before every run. A metric +passes only if its 95 % bootstrap interval excludes a regression of more than 10 %. This is a +release check against the previous version, not a new set of public figures; the figures on +this page are still the v0.1.31 measurements. + +| Metric (median of runs) | v0.1.31 | 0.2.0 | Ratio [95 % CI] | +|---|---|---|---| +| Core boolean | 52.9 ns | 52.1 ns | 0.986 [0.984, 1.003] | +| Core targeting, 1 rule | 79.9 ns | 82.1 ns | 1.027 [1.014, 1.041] | +| Core targeting, 10 rules | 228.4 ns | 238.8 ns | 1.046 [1.031, 1.055] | +| Core weighted multivariate | 119.7 ns | 123.3 ns | 1.030 [1.026, 1.037] | +| Node.js `isEnabled` boolean | 331 ns | 330 ns | 0.996 [0.948, 1.029] | +| Snapshot throughput, 100 concurrent | 2,076 req/s | 2,077 req/s | 1.001 [0.985, 1.012] | +| SSE p99 propagation, 1,000 clients | 26.36 ms | 25.94 ms | 0.984 [0.961, 1.013] | +| SSE-suite peak RSS | 43.8 MiB | 43.8 MiB | 1.001 [0.989, 1.016] | + +Every metric passed. Rule matching and weighted-variant selection in the Rust core are +measurably slower, by 2.7–4.6 % (2–10 ns per evaluation). The slowdown is not visible through +the Node.js SDK or in any server metric. It is tracked in +[#72](https://github.com/checkgate-sh/checkgate/issues/72) and +[#73](https://github.com/checkgate-sh/checkgate/issues/73). + ## Environment | | | diff --git a/edge/package.json b/edge/package.json index 3b8e92b8..f6f9f2cf 100644 --- a/edge/package.json +++ b/edge/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/edge", - "version": "0.1.31", + "version": "0.2.0", "description": "Runtime-agnostic edge evaluator for Checkgate — fetch a flag snapshot, cache it with TTL + stale-while-revalidate, and evaluate at the edge (Cloudflare Workers, Deno Deploy, Fastly, Vercel Edge, Fly.io).", "type": "module", "main": "src/index.js", diff --git a/integrations/mcp-server/README.md b/integrations/mcp-server/README.md index 9e7ffa9c..4f9e82e0 100644 --- a/integrations/mcp-server/README.md +++ b/integrations/mcp-server/README.md @@ -3,91 +3,189 @@ A [Model Context Protocol](https://modelcontextprotocol.io) server (stdio) that lets AI agents read Checkgate feature flags and **propose** changes that a person approves. -- **Read tools** (always on): projects, environments (with `require_approval`), flags - (paginated), one flag's configuration, targeting explained in plain language, flag dependencies, - recent audit events, a flag compared across two environments, change requests, SDK connection - counts per environment. -- **Proposal tools** (only with `CHECKGATE_MCP_WRITE=1`): `propose_flag_change`, - `propose_rollout_change`, `cancel_change_request` (own pending requests). -- **No** create, approve, reject, delete, promote, archive or raw-HTTP tool, in any - configuration. (A new flag is served to SDKs at once, so people create flags.) +**Current version: 0.2.0.** This is the package's first release; it publishes to npm together with +Checkgate 0.2.0. It needs a **Checkgate 0.2.0 server**: the `propose` token scope it relies on does +not exist on 0.1.x. What changed: [CHANGELOG](https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md). -Full guide and security model: [docs/ecosystem/mcp.md](../../docs/ecosystem/mcp.md). +## What it does -## Use a `propose` token +- **Read tools** (always registered): the token's access, projects, environments (with + `require_approval`), flags (paginated), one flag's configuration, targeting explained in plain + language, flag dependencies, recent audit events, a flag compared across two environments, + change requests, SDK connection counts. +- **Proposal tools** (only with `CHECKGATE_MCP_WRITE=1`): propose a flag change, propose a rollout + percentage, withdraw the token owner's own pending change request. +- **No** create, approve, reject, delete, promote, archive or raw-HTTP tool, in any configuration. + A new flag is served to SDKs at once, so people create flags; agents propose changes to them. -Create the agent's personal access token with scope **`propose`** (Settings → Access Tokens, or -`POST /api/tokens` with `"scope": "propose"`). The Checkgate server then enforces, for every request -with that token — through this server or raw HTTP: +It runs next to the MCP client as a child process and speaks MCP over stdin/stdout. It opens no +network listener; it only makes HTTPS (or HTTP) requests to your Checkgate server. -- a flag `PATCH` always becomes a pending change request (`202`), in every environment; -- `DELETE` of a change request works only on the owner's own pending ones; -- everything else that writes is `403`, creating flags, approve and reject included. +## Installation -A different person must approve each change request (self-approval is blocked server-side). - -With any other token, the **propose guard** (`CHECKGATE_MCP_REQUIRE_PROPOSE`, default on) refuses to -send a change unless the target environment requires approval. If a change is ever applied -directly (HTTP 200), the tool result begins with a loud `WARNING`. - -## Configuration - -| Variable | Default | | -|---|---|---| -| `CHECKGATE_URL` | required | Server base URL (`http(s)://`, no `user:pass@`, query or fragment). | -| `CHECKGATE_TOKEN` | required | Personal access token (`propose` recommended). | -| `CHECKGATE_MCP_WRITE` | `0` | `1` registers the proposal tools. | -| `CHECKGATE_MCP_REQUIRE_PROPOSE` | `1` | `0` turns the propose guard off. | -| `CHECKGATE_TIMEOUT_MS` | `10000` | Whole-request timeout, 100–120000. | -| `CHECKGATE_MCP_MAX_RESPONSE_BYTES` | `2097152` | Largest API response accepted. | - -Claude Code: +The MCP client starts the server, so there is usually nothing to install: point the client at +`npx -y @checkgate/mcp-server@0.2.0` (see below). To install it instead: ```bash -claude mcp add --transport stdio checkgate \ - --env CHECKGATE_URL=https://flags.example.com \ - --env CHECKGATE_TOKEN=pat_your_propose_token \ - --env CHECKGATE_MCP_WRITE=1 \ - -- node /path/to/checkgate/integrations/mcp-server/bin/checkgate-mcp.js +npm install -g @checkgate/mcp-server@0.2.0 # provides the checkgate-mcp command ``` -Claude Desktop (`claude_desktop_config.json`): - -```json -{ - "mcpServers": { - "checkgate": { - "command": "node", - "args": ["/path/to/checkgate/integrations/mcp-server/bin/checkgate-mcp.js"], - "env": { - "CHECKGATE_URL": "https://flags.example.com", - "CHECKGATE_TOKEN": "pat_your_propose_token", - "CHECKGATE_MCP_WRITE": "1" - } - } - } -} -``` +From a source checkout: `cd integrations/mcp-server && npm ci`, then run +`node /path/to/checkgate/integrations/mcp-server/bin/checkgate-mcp.js`. + +## Minimal example + +1. Create a personal access token with scope **`propose`**: in the dashboard under + **Settings → Access Tokens**, or with `POST /api/tokens` and `{"name": "agent", "scope": "propose", "expires_in_days": 30}`. +2. Add the server to your MCP client. Claude Code: + + ```bash + claude mcp add --transport stdio checkgate \ + --env CHECKGATE_URL=https://flags.example.com \ + --env CHECKGATE_TOKEN=pat_xxxxxxxxxxxx \ + -- npx -y @checkgate/mcp-server@0.2.0 + ``` + + Claude Desktop (`claude_desktop_config.json`), Cursor (`.cursor/mcp.json`) and other clients + that read an `mcpServers` object: + + ```json + { + "mcpServers": { + "checkgate": { + "command": "npx", + "args": ["-y", "@checkgate/mcp-server@0.2.0"], + "env": { + "CHECKGATE_URL": "https://flags.example.com", + "CHECKGATE_TOKEN": "pat_xxxxxxxxxxxx" + } + } + } + } + ``` + + `pat_xxxxxxxxxxxx` is a placeholder; Checkgate tokens start with `pat_`. Keep the real token + out of files you commit. +3. This configuration is read-only. To let the agent propose changes, add + `"CHECKGATE_MCP_WRITE": "1"` to `env` (or `--env CHECKGATE_MCP_WRITE=1`). + +On start the server logs one line to stderr, for example +`checkgate-mcp: ready (11 tools, read-only; propose guard on)`. + +## Configuration + +All configuration is through environment variables. -## Untrusted content +| Variable | Default | Meaning | +|---|---|---| +| `CHECKGATE_URL` | required | Server base URL. `http://` or `https://`, no `user:pass@`, query string or fragment. | +| `CHECKGATE_TOKEN` | required | Personal access token (scope `propose` recommended). Printable ASCII, at most 512 characters. | +| `CHECKGATE_MCP_WRITE` | `0` | `1` registers the three proposal tools. | +| `CHECKGATE_MCP_REQUIRE_PROPOSE` | `1` | `0` turns the propose guard off (not recommended). | +| `CHECKGATE_TIMEOUT_MS` | `10000` | Timeout for each API request, body included. 100 to 120000. | +| `CHECKGATE_MCP_MAX_RESPONSE_BYTES` | `2097152` | Largest API response body accepted. 1024 to 33554432. | -Flag descriptions, rule values, audit entries, names and change-request reasons are user-written. -Results return them as data: in `structuredContent.data`, and in the text content only inside a -`` block whose JSON escapes `<`, `>` and `&`, so content cannot close the block. A -fixed note before the block says it is data, not instructions. +The two switches accept `1`/`true`/`yes` and `0`/`false`/`no`; any other value is a configuration +error. -## Behaviour details +## Tools -- The token is sent only as `Authorization: Bearer`; it never appears in a URL, a result, an error - or on stderr. Redirects are refused (they could carry the token elsewhere). -- Error results carry a stable `kind`: `auth` (401), `forbidden` (403), `not_found` (404), - `conflict` (409), `invalid` (400/422), `rate_limited` (429, with `retry_after_seconds`), `server` - (5xx), `http`, `timeout`, `network`, `too_large`, `bad_response`, `refused` (a local guard), and - `internal`. Messages are built from the status code only, never from the response body. -- The process exits 0 when stdin closes (after answering requests already received, at most 2 s) - and on SIGTERM/SIGINT. A configuration error exits 2. -- The token's scope is read from `GET /api/tokens` by matching this token's display prefix; if - that is ambiguous or fails, the scope counts as unknown (not `propose`). +| Tool | Kind | What it does | +|---|---|---| +| `get_access_info` | read | The token's scope (`read_only`, `propose`, `read_write` or `unknown`), whether write tools are on, whether the propose guard is on. | +| `list_projects` | read | Projects the token can see. | +| `list_environments` | read | A project's environments, with `require_approval`. | +| `list_flags` | read | Flags in an environment, compact, paginated (up to 200 per page, default 50; filter by tag, optionally archived). | +| `get_flag` | read | One flag's full configuration. | +| `explain_flag` | read | Who gets which value, step by step in evaluation order (segments expanded). | +| `flag_dependencies` | read | Prerequisites (whether each exists and is enabled) and flags that depend on this one. Scans up to 5000 flags. | +| `flag_audit_events` | read | Recent audit events for an environment or one flag, only the fields that changed (up to 100, default 20). | +| `compare_flag_across_environments` | read | Evaluation-relevant differences separately from metadata differences between two environments. | +| `list_change_requests` | read | Change requests, newest first, optionally by status `pending`, `approved` or `rejected`. | +| `sdk_connection_summary` | read | Live SDK streaming connections per environment, counts only. | +| `propose_flag_change` | write | Propose changes to an existing flag: `is_enabled`, `rollout_percentage`, `description`, `default_value`, `disabled_value`, `rules`, `variants`, `prerequisites`, `tags`, `owner_email`. | +| `propose_rollout_change` | write | Propose a rollout percentage (0 to 100); same path as `propose_flag_change`. | +| `cancel_change_request` | write | Withdraw one of the token owner's own pending change requests. | + +Every input is validated with bounded lengths and ranges, and unknown arguments are rejected, +before anything is sent. Read tools carry the MCP `readOnlyHint` annotation. + +## Authentication and approval + +The server authenticates with a Checkgate personal access token, sent only as +`Authorization: Bearer`. Tokens have one of three scopes: `read_only`, `propose` or `read_write`. +A token acts as the user who created it: it sees that user's projects, and project roles still +apply (a viewer's token cannot propose). + +**Use a `propose` token.** For every request made with it, through this server or raw HTTP, the +Checkgate server enforces: + +- a flag `PATCH` always becomes a pending change request (`202`), in every environment, whether or + not that environment requires approval; +- `DELETE` of a change request works only on the token owner's own pending ones; +- every other write is `403`: creating flags, approve and reject included. + +A different person must approve each change request; the server blocks self-approval. So proposals +from this server become pending change requests, and no tool creates, approves or applies one. A +`propose_*` result says `pending_review` and names the change request; follow it with +`list_change_requests` and `get_flag`. + +**The propose guard** (`CHECKGATE_MCP_REQUIRE_PROPOSE`, on by default) covers tokens with another +scope. The server looks up the token's scope with `GET /api/tokens`, matching the token's display +prefix (its first 12 characters); if that fails or is ambiguous, the scope counts as `unknown`, not +`propose`. Unless the scope is `propose`, the guard: + +- refuses to send a flag change unless the target environment requires approval; +- refuses `cancel_change_request` (a workspace admin's `read_write` token could withdraw anyone's + request). + +A refusal is an error result of kind `refused`; nothing is sent. If a change is applied directly +anyway (HTTP 200, possible only with a non-`propose` token), the result begins +with `WARNING` and reports `applied_immediately`. + +## Runtime compatibility + +- Node.js 20 or later (`engines: >=20`). CI tests the package on Node.js 22. Node.js 20 is past + end of life, so prefer 22 or later. +- Transport: stdio only. +- Checkgate server 0.2.0 or later. The `propose` scope does not exist on a 0.1.31 server; do not + create `propose` tokens while any 0.1.31 instance still serves the API. +- Dependencies: `@modelcontextprotocol/sdk` 1.32.2 and `zod` 4.6.7, pinned exactly. + +## Errors and lifecycle + +- A failed tool call is an MCP error result (`isError: true`) with + `structuredContent.error.kind`: `auth` (401), `forbidden` (403), `not_found` (404), `conflict` + (409), `invalid` (400/422), `rate_limited` (429, with `retry_after_seconds` when the server sends + `Retry-After`), `server` (5xx), `http` (other status), `timeout`, `network`, `too_large`, + `bad_response`, `refused` (a local guard) or `internal`. Messages are built from the status code, + never from the response body. +- `too_large`: an API response over `CHECKGATE_MCP_MAX_RESPONSE_BYTES`, or a tool result over + 200,000 characters. Narrow the request (smaller `limit`, an `offset`, one flag). +- The process exits `0` when stdin closes, after answering requests already received (waiting at + most 2 seconds), and on SIGTERM or SIGINT. A configuration error exits `2` with a message on + stderr; an unexpected startup failure exits `1`. +- stdout carries only the MCP protocol. Diagnostics go to stderr, prefixed `checkgate-mcp:`. + +## Security + +- The token never appears in a URL, a tool result, an error or on stderr (stderr lines are + scrubbed). A `CHECKGATE_URL` with `user:pass@` is refused at startup without repeating it. +- Redirects are refused: following one could send the token to another host. +- **Cleartext HTTP.** With a plain `http://` URL to a host other than `localhost`, `127.0.0.1` or + `[::1]`, the server starts but warns on stderr: the token travels unencrypted. Use `https://`. +- **Untrusted content.** Flag descriptions, rule values, audit entries, names and change-request + reasons are user-written. Results return them as data: in `structuredContent.data`, and in the + text content only inside a `` block whose JSON escapes `<`, `>` and `&`, so + content cannot close the block. A fixed note before the block says it is data, not + instructions. This reduces prompt injection through flag content; it cannot prevent a model + from following such text. With a `propose` token, a misled agent still cannot apply, approve or + reject anything. +- With a non-`propose` token, the guard's "environment requires approval" check is a separate + request from the change, so an admin turning approval off in between could let one change + through. With a `propose` token the Checkgate server enforces the queueing itself. +- `sdk_connection_summary` reports the connections of the server instance that answered; behind a + load balancer each instance reports only its own. ## Development @@ -103,3 +201,15 @@ CHECKGATE_E2E_REDIS_URL=redis://127.0.0.1:6379 \ The e2e suite also prints the measured overhead of an MCP stdio tool call versus a direct HTTP read of the same flag. + +## Documentation + +- [AI agents (MCP) guide and security model](https://checkgate-sh.github.io/checkgate/ecosystem/mcp) +- [Governance and approvals](https://checkgate-sh.github.io/checkgate/guide/governance) +- [Personal access tokens](https://checkgate-sh.github.io/checkgate/api-reference#personal-access-tokens) +- [Upgrading to 0.2.0](https://checkgate-sh.github.io/checkgate/operations/upgrading-to-0-2-0) +- [Changelog](https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md) + +## License + +Apache-2.0. Part of [Checkgate](https://github.com/checkgate-sh/checkgate). diff --git a/integrations/mcp-server/test/tools.test.js b/integrations/mcp-server/test/tools.test.js index da633e84..3400906f 100644 --- a/integrations/mcp-server/test/tools.test.js +++ b/integrations/mcp-server/test/tools.test.js @@ -30,7 +30,7 @@ test('read-only by default: write tools are not registered at all', async () => } finally { await s.close() } }) -test('CHECKGATE_MCP_WRITE=1 adds exactly the four proposal tools — no approve/reject/delete/raw HTTP', async () => { +test('CHECKGATE_MCP_WRITE=1 adds exactly the three proposal tools — no approve/reject/delete/raw HTTP', async () => { const s = await connect({ write: true }) try { const names = (await s.client.listTools()).tools.map((t) => t.name) diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index bf465ab6..9049f3d2 100755 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -31,68 +31,86 @@ else fi # --- Rust workspace (source of truth) --- +# The [workspace.package] version is the only line-initial `version = "..."` in +# Cargo.toml (members inherit it with version.workspace). SED_INPLACE "s/^version = \".*\"$/version = \"$VERSION\"/" "$ROOT/Cargo.toml" echo " updated Cargo.toml [workspace.package]" -# --- JS SDKs --- -for pkg in nodejs node-integrations openfeature-provider web react-native; do - FILE="$ROOT/sdks/$pkg/package.json" - SED_INPLACE "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$FILE" - echo " updated sdks/$pkg/package.json" +# Path dependencies on a workspace crate pin the release version exactly: a +# `^0.1.0` requirement stops matching the path crate at 0.2.0 and the +# workspace no longer resolves. +for member in $(sed -n '/^members = \[/,/^\]/p' "$ROOT/Cargo.toml" | grep -o '"[^"]*"' | tr -d '"'); do + FILE="$ROOT/$member/Cargo.toml" + SED_INPLACE -E "s/^(checkgate-core = \{ version = \")[^\"]*(\")/\1$VERSION\2/" "$FILE" done +echo " updated workspace path-dependency requirements on checkgate-core" -# --- Standalone published JS packages (each has its own release workflow) --- -for pkg in cli edge ssr; do - FILE="$ROOT/$pkg/package.json" - SED_INPLACE "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$FILE" - echo " updated $pkg/package.json" -done +# Cargo.lock: only the workspace crates' own entries. +if command -v cargo >/dev/null 2>&1; then + (cd "$ROOT" && cargo update --workspace --offline >/dev/null 2>&1 || cargo update --workspace >/dev/null) + echo " updated Cargo.lock (workspace crates)" +else + echo " WARNING: cargo not found; run \`cargo update --workspace\` before committing" >&2 +fi -# --- MCP server (its code reads the version from package.json) --- -SED_INPLACE "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$ROOT/integrations/mcp-server/package.json" -echo " updated integrations/mcp-server/package.json" +# --- npm packages --- +# Every publishable package plus the lockstep private ones, discovered by +# scripts/check-versions.mjs (a package added later is bumped too). Only the +# package's own version changes, in package.json and in its lockfile (top level +# and packages[""]): a sed over a lockfile would rewrite every dependency. +for dir in $(node "$ROOT/scripts/check-versions.mjs" --list npm); do + node -e ' + const fs = require("fs"); + const [dir, version] = process.argv.slice(1); + const edit = (file, fn) => { + if (!fs.existsSync(file)) return false; + const json = JSON.parse(fs.readFileSync(file, "utf8")); + fn(json); + fs.writeFileSync(file, JSON.stringify(json, null, 2) + "\n"); + return true; + }; + // package.json: replace the version string in place, keeping the + // existing formatting (escapes, inline arrays). + const pj = dir + "/package.json"; + const text = fs.readFileSync(pj, "utf8"); + const next = text.replace(/^( "version":\s*")[^"]*(")/m, `$1${version}$2`); + if (JSON.parse(next).version !== version) throw new Error(pj + ": no top-level version to bump"); + fs.writeFileSync(pj, next); + edit(dir + "/package-lock.json", (l) => { + l.version = version; + if (l.packages && l.packages[""]) l.packages[""].version = version; + }); + ' "$ROOT/$dir" "$VERSION" + echo " updated $dir/package.json (and package-lock.json if present)" +done # --- Python SDK (the wheel's version, and the client's __version__) --- SED_INPLACE "s/^version = \".*\"$/version = \"$VERSION\"/" "$ROOT/sdks/python/pyproject.toml" SED_INPLACE "s/^__version__ = \".*\"$/__version__ = \"$VERSION\"/" "$ROOT/sdks/python/python/checkgate/_client.py" echo " updated sdks/python/pyproject.toml and checkgate/_client.py __version__" -# --- Dashboard --- -SED_INPLACE "s/\"version\": \".*\"/\"version\": \"$VERSION\"/" "$ROOT/dashboard/package.json" -echo " updated dashboard/package.json" - -# --- npm lockfiles: only the package's own version (top level and -# packages[""]); a sed over a lockfile would rewrite every dependency's -# version too. Lockfiles left at the old version made `npm ci` trees report a -# version the package no longer has. -for dir in sdks/nodejs sdks/web sdks/react-native sdks/openfeature-provider \ - sdks/node-integrations integrations/mcp-server cli edge ssr dashboard; do - LOCK="$ROOT/$dir/package-lock.json" - [ -f "$LOCK" ] || continue - node -e ' - const fs = require("fs"); - const [file, version] = process.argv.slice(1); - const lock = JSON.parse(fs.readFileSync(file, "utf8")); - lock.version = version; - if (lock.packages && lock.packages[""]) lock.packages[""].version = version; - fs.writeFileSync(file, JSON.stringify(lock, null, 2) + "\n"); - ' "$LOCK" "$VERSION" - echo " updated $dir/package-lock.json" -done - # --- Flutter / Dart --- SED_INPLACE "s/^version: .*/version: $VERSION/" "$ROOT/sdks/flutter/dart/pubspec.yaml" echo " updated sdks/flutter/dart/pubspec.yaml" -# --- Flutter CHANGELOG (prepend new entry) --- +# --- Flutter CHANGELOG (pub.dev shows it): prepend a placeholder entry unless +# the version already has one. Replace the placeholder with real notes. CHANGELOG="$ROOT/sdks/flutter/dart/CHANGELOG.md" TODAY="$(date +%Y-%m-%d)" -ENTRY="## $VERSION ($TODAY)\n\n- Release $VERSION.\n" -# Only prepend if the version heading isn't already present. if ! grep -q "^## $VERSION" "$CHANGELOG" 2>/dev/null; then - printf "%b\n" "$ENTRY" | cat - "$CHANGELOG" > /tmp/_cg_changelog && mv /tmp/_cg_changelog "$CHANGELOG" + TMP="$(mktemp "$CHANGELOG.XXXXXX")" + { printf '## %s (%s)\n\n- Release %s. See https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md\n\n' "$VERSION" "$TODAY" "$VERSION"; cat "$CHANGELOG"; } > "$TMP" + mv "$TMP" "$CHANGELOG" + echo " prepended a placeholder $VERSION entry to sdks/flutter/dart/CHANGELOG.md (replace it with real notes)" fi -echo " prepended $VERSION entry to sdks/flutter/dart/CHANGELOG.md (edit manually to add details)" + +# --- Verify --- +echo "" +node "$ROOT/scripts/check-versions.mjs" || { + echo "" >&2 + echo "Version check failed after the bump (above). Fix the listed files." >&2 + exit 1 +} echo "" echo "Done. All packages are now at $VERSION" @@ -100,4 +118,4 @@ echo "" echo "Next steps:" echo " 1. Review changes: git diff" echo " 2. Commit: git commit -am \"chore: bump version to $VERSION\"" -echo " 3. Tag: git tag v$VERSION" +echo " 3. Tag only after the release PR is merged into main: git tag -a v$VERSION" diff --git a/scripts/check-versions.mjs b/scripts/check-versions.mjs new file mode 100644 index 00000000..c0400fc1 --- /dev/null +++ b/scripts/check-versions.mjs @@ -0,0 +1,248 @@ +#!/usr/bin/env node +// Release version consistency check. +// +// node scripts/check-versions.mjs check; exit 1 on any mismatch +// node scripts/check-versions.mjs --json the same, as a JSON report +// node scripts/check-versions.mjs --list npm print the lockstep npm package +// directories (used by bump-version.sh) +// +// The release version is Cargo.toml [workspace.package].version. Packages are +// DISCOVERED, not listed, so a package added later is checked (and bumped by +// scripts/bump-version.sh) without editing either script: +// +// Rust every workspace member inherits `version.workspace = true`; every +// path dependency on a workspace crate requires exactly the release +// version (a `^0.1.0` requirement stops resolving at 0.2.0); the +// workspace crates in Cargo.lock carry the release version. +// npm every package.json outside node_modules/build output that is not +// `"private": true` is publishable: its version, its package-lock.json +// (top level and packages[""]) and every @checkgate/* dependency or +// peer range must agree with the release version, and release.yml +// must have a job that runs `npm publish` in its directory. +// Private packages are internal and only listed, except LOCKSTEP +// ones, which are versioned with the release. +// Python every pyproject.toml: version, the `__version__` constant, and a +// PyPI publish step in release.yml. +// Dart every pubspec.yaml without `publish_to: none`: version, a CHANGELOG +// heading for it, and a pub.dev publish step in release.yml. +// +// Packages that are deliberately versioned on their own are EXCEPTIONS below, +// with the reason; anything else that disagrees fails the check. + +import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..') +const rel = (p) => path.relative(root, p).split(path.sep).join('/') +const read = (p) => readFileSync(path.join(root, p), 'utf8') + +const SKIP_DIRS = new Set([ + 'node_modules', 'target', '.git', 'dist', 'build', '.dart_tool', 'internal_docs', + '.venv', 'venv', '.vitepress', 'rust-core', 'pkg', '.next', +]) + +// Private packages that are still versioned with the release. +const LOCKSTEP_PRIVATE = new Set(['dashboard']) + +// Deliberate exceptions: directory -> reason. They are reported, not checked. +const EXCEPTIONS = { + 'docs': 'documentation site (private, not released)', + 'quickstart/node': 'quickstart example (private); depends on the published @checkgate/node', + 'edge/examples/cloudflare-worker': 'example project (private)', + 'integrations/checkgate-go': 'Go module, source only: no registry, no version field (Go versions modules by tag)', + 'integrations/terraform-provider-checkgate': 'Go module, source only: not on the Terraform Registry', + 'integrations/kubernetes-operator': 'Go module, source only: no published image or chart', +} + +function walk(dir, names, out = []) { + for (const entry of readdirSync(dir)) { + if (SKIP_DIRS.has(entry)) continue + const full = path.join(dir, entry) + let st + try { st = statSync(full) } catch { continue } + if (st.isDirectory()) walk(full, names, out) + else if (names.includes(entry)) out.push(full) + } + return out +} + +const errors = [] +const packages = [] +const err = (where, msg) => errors.push(`${where}: ${msg}`) + +// --- Release version ------------------------------------------------------- +const cargoToml = read('Cargo.toml') +const wsPkg = cargoToml.split(/^\[workspace\.package\]$/m)[1]?.split(/^\[/m)[0] ?? '' +const VERSION = wsPkg.match(/^version\s*=\s*"([^"]+)"/m)?.[1] +if (!VERSION) { + console.error('Cargo.toml: no [workspace.package] version') + process.exit(2) +} + +// --- Minimal semver range check (the forms this repository uses) ------------ +const parse = (v) => v.replace(/^[v=]/, '').split('-')[0].split('.').map(Number) +const cmp = (a, b) => { + const x = parse(a); const y = parse(b) + for (let i = 0; i < 3; i++) if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) < (y[i] ?? 0) ? -1 : 1 + return 0 +} +function satisfies(version, range) { + return range.split('||').some((alt) => alt.trim().split(/\s+/).every((c) => { + if (c === '*' || c === '') return true + let m + if ((m = c.match(/^\^(.+)$/))) { + const [maj, min] = parse(m[1]) + const upper = maj > 0 ? `${maj + 1}.0.0` : `0.${min + 1}.0` + return cmp(version, m[1]) >= 0 && cmp(version, upper) < 0 + } + if ((m = c.match(/^~(.+)$/))) { + const [maj, min] = parse(m[1]) + return cmp(version, m[1]) >= 0 && cmp(version, `${maj}.${min + 1}.0`) < 0 + } + if ((m = c.match(/^(>=|<=|>|<)(.+)$/))) { + const r = cmp(version, m[2]) + return { '>=': r >= 0, '<=': r <= 0, '>': r > 0, '<': r < 0 }[m[1]] + } + return cmp(version, c) === 0 + })) +} + +const releaseYml = existsSync(path.join(root, '.github/workflows/release.yml')) + ? read('.github/workflows/release.yml') : '' +// Jobs of release.yml, split on two-space-indented job keys. +const releaseJobs = releaseYml.split(/^ {2}(?=[a-z0-9-]+:\s*$)/m).slice(1) +const jobPublishes = (dir, cmd) => releaseJobs.some((j) => + new RegExp(`working-directory:\\s*${dir.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')}\\s*$`, 'm').test(j) && j.includes(cmd)) + +// --- Rust -------------------------------------------------------------------- +const members = [...(cargoToml.match(/members\s*=\s*\[([^\]]*)\]/)?.[1] ?? '').matchAll(/"([^"]+)"/g)].map((m) => m[1]) +const crateNames = new Map() +for (const m of members) { + const file = `${m}/Cargo.toml` + const t = read(file) + const name = t.match(/^\[package\][^[]*?^name\s*=\s*"([^"]+)"/ms)?.[1] + crateNames.set(name, m) + const publish = !/^publish\s*=\s*false/m.test(t) + if (!/^version\.workspace\s*=\s*true/m.test(t)) err(file, `does not inherit version.workspace (release ${VERSION})`) + packages.push({ ecosystem: 'cargo', name, dir: m, version: VERSION, registry: 'none (workspace crate, not published to crates.io)', publish: false, crateFlagPublish: publish }) +} +for (const m of members) { + const file = `${m}/Cargo.toml` + for (const [, dep, ver] of read(file).matchAll(/^([A-Za-z0-9_-]+)\s*=\s*\{[^}]*?version\s*=\s*"([^"]+)"[^}]*?path\s*=/gm)) { + if (crateNames.has(dep) && ver !== VERSION) err(file, `${dep} requires "${ver}", expected "${VERSION}"`) + } +} +if (existsSync(path.join(root, 'Cargo.lock'))) { + const lock = read('Cargo.lock') + for (const name of crateNames.keys()) { + const v = lock.match(new RegExp(`\\[\\[package\\]\\]\\nname = "${name}"\\nversion = "([^"]+)"\\n(?!source)`))?.[1] + if (v !== VERSION) err('Cargo.lock', `${name} is ${v ?? 'missing'}, expected ${VERSION} (run \`cargo update --workspace\`)`) + } +} + +// --- npm --------------------------------------------------------------------- +const npmLockstep = [] +for (const file of walk(root, ['package.json'])) { + const dir = rel(path.dirname(file)) + const pkg = JSON.parse(readFileSync(file, 'utf8')) + if (EXCEPTIONS[dir]) { + packages.push({ ecosystem: 'npm', name: pkg.name, dir, version: pkg.version ?? null, registry: 'internal', publish: false, exception: EXCEPTIONS[dir] }) + continue + } + const isPrivate = pkg.private === true + if (isPrivate && !LOCKSTEP_PRIVATE.has(dir)) { + err(`${dir}/package.json`, `private package not classified: add it to LOCKSTEP_PRIVATE or EXCEPTIONS in scripts/check-versions.mjs`) + continue + } + npmLockstep.push(dir) + packages.push({ ecosystem: 'npm', name: pkg.name, dir, version: pkg.version, registry: isPrivate ? 'internal (lockstep)' : 'npm', publish: !isPrivate }) + if (pkg.version !== VERSION) err(`${dir}/package.json`, `version ${pkg.version}, expected ${VERSION}`) + const lockFile = path.join(path.dirname(file), 'package-lock.json') + if (existsSync(lockFile)) { + const lock = JSON.parse(readFileSync(lockFile, 'utf8')) + if (lock.version !== VERSION || (lock.packages?.[''] && lock.packages[''].version !== VERSION)) { + err(`${dir}/package-lock.json`, `version ${lock.version}/${lock.packages?.['']?.version}, expected ${VERSION}`) + } + } + for (const field of ['dependencies', 'peerDependencies', 'optionalDependencies']) { + for (const [dep, range] of Object.entries(pkg[field] ?? {})) { + if (!dep.startsWith('@checkgate/') || range.startsWith('file:') || range.startsWith('workspace:')) continue + if (!satisfies(VERSION, range)) err(`${dir}/package.json`, `${field}.${dep} "${range}" does not accept ${VERSION}`) + } + } + if (!isPrivate) { + if (!pkg.name?.startsWith('@checkgate/')) err(`${dir}/package.json`, `publishable package outside the @checkgate scope: ${pkg.name}`) + if (!jobPublishes(dir, 'npm publish')) err('.github/workflows/release.yml', `no job runs \`npm publish\` in ${dir} (${pkg.name})`) + if (!existsSync(path.join(path.dirname(file), 'README.md'))) err(dir, 'publishable package has no README.md') + } +} + +// --- Python ------------------------------------------------------------------ +for (const file of walk(root, ['pyproject.toml'])) { + const dir = rel(path.dirname(file)) + const t = readFileSync(file, 'utf8') + const name = t.match(/^\[project\][^[]*?^name\s*=\s*"([^"]+)"/ms)?.[1] + const v = t.match(/^\[project\][^[]*?^version\s*=\s*"([^"]+)"/ms)?.[1] + packages.push({ ecosystem: 'pypi', name, dir, version: v, registry: 'PyPI', publish: true }) + if (v !== VERSION) err(`${dir}/pyproject.toml`, `version ${v}, expected ${VERSION}`) + for (const py of walk(path.dirname(file), ['__init__.py', '_client.py', '_version.py'])) { + const m = readFileSync(py, 'utf8').match(/^__version__\s*=\s*"([^"]+)"/m) + if (m && m[1] !== VERSION) err(rel(py), `__version__ ${m[1]}, expected ${VERSION}`) + } + const publishes = releaseJobs.some((j) => j.includes('pypa/gh-action-pypi-publish')) + if (!publishes) err('.github/workflows/release.yml', `no PyPI publish step for ${name} (${dir})`) +} + +// --- Dart -------------------------------------------------------------------- +for (const file of walk(root, ['pubspec.yaml'])) { + const dir = rel(path.dirname(file)) + const t = readFileSync(file, 'utf8') + if (/^publish_to:\s*["']?none/m.test(t)) continue + const name = t.match(/^name:\s*(\S+)/m)?.[1] + const v = t.match(/^version:\s*(\S+)/m)?.[1] + packages.push({ ecosystem: 'pub', name, dir, version: v, registry: 'pub.dev', publish: true }) + if (v !== VERSION) err(`${dir}/pubspec.yaml`, `version ${v}, expected ${VERSION}`) + const changelog = path.join(path.dirname(file), 'CHANGELOG.md') + if (!existsSync(changelog) || !new RegExp(`^## ${VERSION.replace(/\./g, '\\.')}\\b`, 'm').test(readFileSync(changelog, 'utf8'))) { + err(`${dir}/CHANGELOG.md`, `no "## ${VERSION}" entry (pub.dev shows this file)`) + } + if (!jobPublishes(dir, 'dart pub publish --force')) err('.github/workflows/release.yml', `no pub.dev publish job for ${dir}`) +} + +// --- Root changelog ---------------------------------------------------------- +if (!new RegExp(`^## \\[${VERSION.replace(/\./g, '\\.')}\\]`, 'm').test(read('CHANGELOG.md'))) { + err('CHANGELOG.md', `no "## [${VERSION}]" entry`) +} + +// --- Go modules (exceptions, listed for the inventory) ----------------------- +for (const file of walk(root, ['go.mod'])) { + const dir = rel(path.dirname(file)) + const mod = readFileSync(file, 'utf8').match(/^module\s+(\S+)/m)?.[1] + packages.push({ ecosystem: 'go', name: mod, dir, version: null, registry: 'source only', publish: false, exception: EXCEPTIONS[dir] ?? null }) + if (!EXCEPTIONS[dir]) err(dir, 'Go module not classified: add it to EXCEPTIONS (or give it a release job)') +} + +// --- Output ------------------------------------------------------------------ +const argv = process.argv.slice(2) +if (argv[0] === '--list') { + if (argv[1] === 'npm') console.log(npmLockstep.sort().join('\n')) + else { console.error('usage: --list npm'); process.exit(2) } + process.exit(0) +} +if (argv.includes('--json')) { + console.log(JSON.stringify({ version: VERSION, ok: errors.length === 0, errors, packages }, null, 2)) +} else { + console.log(`Release version (Cargo.toml [workspace.package]): ${VERSION}\n`) + const rows = packages.map((p) => [p.ecosystem, p.name ?? '?', p.dir, p.version ?? '-', p.exception ? `exception: ${p.exception}` : p.registry]) + const w = [0, 1, 2, 3].map((i) => Math.max(...rows.map((r) => r[i].length))) + for (const r of rows) console.log(` ${r.slice(0, 4).map((c, i) => c.padEnd(w[i])).join(' ')} ${r[4]}`) + console.log('') + if (errors.length) { + console.log(`${errors.length} problem(s):`) + for (const e of errors) console.log(` - ${e}`) + } else { + console.log('All release versions are consistent.') + } +} +process.exit(errors.length ? 1 : 0) diff --git a/sdks/flutter/dart/CHANGELOG.md b/sdks/flutter/dart/CHANGELOG.md index 675b8281..d90c63d7 100644 --- a/sdks/flutter/dart/CHANGELOG.md +++ b/sdks/flutter/dart/CHANGELOG.md @@ -1,3 +1,17 @@ +## 0.2.0 (2026-11-22) + +- Released in lockstep with Checkgate 0.2.0. The Dart API is unchanged from + 0.1.31, and the package works with 0.1.31 and 0.2.0 servers (the SDK + protocol did not change). +- The bundled Rust engine source is the 0.2.0 core (its evaluator was + refactored to support `explain()`, which this package does not expose). + Evaluation results are unchanged: the core passes the shared evaluation + vectors. +- Still no bundled compiled engine: you build and link it yourself (see the + README). + +Full release notes: https://github.com/checkgate-sh/checkgate/blob/main/CHANGELOG.md + ## 0.1.31 (2026-11-21) - The library is in `lib/`, so `import 'package:checkgate_flutter/checkgate_flutter.dart'` diff --git a/sdks/flutter/dart/pubspec.yaml b/sdks/flutter/dart/pubspec.yaml index e67e69f8..6e5eea1e 100644 --- a/sdks/flutter/dart/pubspec.yaml +++ b/sdks/flutter/dart/pubspec.yaml @@ -1,6 +1,6 @@ name: checkgate_flutter description: Checkgate feature-flag SDK for Flutter — local evaluation via Rust FFI. -version: 0.1.31 +version: 0.2.0 homepage: https://github.com/checkgate-sh/checkgate environment: diff --git a/sdks/flutter/dart/rust/Cargo.toml b/sdks/flutter/dart/rust/Cargo.toml index ba36e63e..d18fa6e9 100644 --- a/sdks/flutter/dart/rust/Cargo.toml +++ b/sdks/flutter/dart/rust/Cargo.toml @@ -8,7 +8,7 @@ edition = "2024" crate-type = ["staticlib", "cdylib"] [dependencies] -checkgate-core = { version = "0.1.0", path = "../../../../core" } +checkgate-core = { version = "0.2.0", path = "../../../../core" } serde_json = "1.0.149" [lints] diff --git a/sdks/nodejs/Cargo.toml b/sdks/nodejs/Cargo.toml index 9c93c61c..82ec55e1 100644 --- a/sdks/nodejs/Cargo.toml +++ b/sdks/nodejs/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["cdylib"] napi = { version = "3.8.3", features = ["napi2", "napi3"] } napi-derive = "3.5.2" serde_json = "1.0" -checkgate-core = { version = "0.1.0", path = "../../core" } +checkgate-core = { version = "0.2.0", path = "../../core" } [lints] workspace = true diff --git a/sdks/nodejs/package-lock.json b/sdks/nodejs/package-lock.json index 726c5306..3c9846d9 100644 --- a/sdks/nodejs/package-lock.json +++ b/sdks/nodejs/package-lock.json @@ -1,12 +1,12 @@ { "name": "@checkgate/node", - "version": "0.1.31", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@checkgate/node", - "version": "0.1.31", + "version": "0.2.0", "license": "Apache-2.0", "dependencies": { "eventsource": "^4.1.0" diff --git a/sdks/nodejs/package.json b/sdks/nodejs/package.json index 5ff0332f..d5fe05d1 100644 --- a/sdks/nodejs/package.json +++ b/sdks/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/node", - "version": "0.1.31", + "version": "0.2.0", "description": "Checkgate feature-flag SDK for Node.js — local evaluation via Rust NAPI.", "main": "index.js", "types": "index.d.ts", diff --git a/sdks/python/Cargo.toml b/sdks/python/Cargo.toml index c3d51440..8a33abbc 100644 --- a/sdks/python/Cargo.toml +++ b/sdks/python/Cargo.toml @@ -20,7 +20,7 @@ doctest = false pyo3 = { version = "0.30.1", features = ["abi3-py311"] } serde = "1.0" serde_json = "1.0" -checkgate-core = { version = "0.1.0", path = "../../core" } +checkgate-core = { version = "0.2.0", path = "../../core" } [lints] workspace = true diff --git a/sdks/python/pyproject.toml b/sdks/python/pyproject.toml index 12f71f6e..9f066c97 100644 --- a/sdks/python/pyproject.toml +++ b/sdks/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "checkgate" -version = "0.1.31" +version = "0.2.0" description = "Checkgate feature flags for Python: local evaluation with the Rust engine, kept in sync over SSE" readme = "README.md" requires-python = ">=3.11" diff --git a/sdks/python/python/checkgate/_client.py b/sdks/python/python/checkgate/_client.py index 8bf104f4..5602b0b8 100644 --- a/sdks/python/python/checkgate/_client.py +++ b/sdks/python/python/checkgate/_client.py @@ -51,7 +51,7 @@ from ._storage import Storage, cache_namespace from ._transport import Endpoint, PollRequest, Request, StreamRequest -__version__ = "0.1.31" +__version__ = "0.2.0" log = logging.getLogger("checkgate") diff --git a/sdks/react-native/Cargo.toml b/sdks/react-native/Cargo.toml index 0b8ab8d2..b952280c 100644 --- a/sdks/react-native/Cargo.toml +++ b/sdks/react-native/Cargo.toml @@ -11,7 +11,7 @@ name = "checkgate_rn" crate-type = ["cdylib", "staticlib"] [dependencies] -checkgate-core = { version = "0.1.0", path = "../../core" } +checkgate-core = { version = "0.2.0", path = "../../core" } serde_json = "1.0.149" [lints] diff --git a/sdks/react-native/package-lock.json b/sdks/react-native/package-lock.json index 107c3d3f..91afc576 100644 --- a/sdks/react-native/package-lock.json +++ b/sdks/react-native/package-lock.json @@ -1,12 +1,12 @@ { "name": "@checkgate/react-native", - "version": "0.1.31", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@checkgate/react-native", - "version": "0.1.31", + "version": "0.2.0", "license": "Apache-2.0", "devDependencies": { "react-native-sse": "^1.2.1", diff --git a/sdks/react-native/package.json b/sdks/react-native/package.json index 4a26ccd6..49e42f81 100644 --- a/sdks/react-native/package.json +++ b/sdks/react-native/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/react-native", - "version": "0.1.31", + "version": "0.2.0", "description": "Checkgate feature-flag SDK for React Native — local evaluation via Rust JSI.", "main": "index.js", "repository": { diff --git a/sdks/web/Cargo.toml b/sdks/web/Cargo.toml index 6d987a4f..bf3cced0 100644 --- a/sdks/web/Cargo.toml +++ b/sdks/web/Cargo.toml @@ -12,7 +12,7 @@ console_error_panic_hook = "0.1.7" js-sys = "0.3.90" serde = { version = "1.0.228", features = ["derive"] } serde-wasm-bindgen = "0.6.5" -checkgate-core = { version = "0.1.0", path = "../../core" } +checkgate-core = { version = "0.2.0", path = "../../core" } serde_json = "1.0.149" wasm-bindgen = "0.2.113" diff --git a/sdks/web/package-lock.json b/sdks/web/package-lock.json index 6513ee73..71d6b557 100644 --- a/sdks/web/package-lock.json +++ b/sdks/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "@checkgate/web", - "version": "0.1.31", + "version": "0.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@checkgate/web", - "version": "0.1.31", + "version": "0.2.0", "license": "Apache-2.0", "devDependencies": { "eventsource": "^4.1.1", diff --git a/sdks/web/package.json b/sdks/web/package.json index a206af48..55d592ea 100644 --- a/sdks/web/package.json +++ b/sdks/web/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/web", - "version": "0.1.31", + "version": "0.2.0", "description": "Checkgate feature-flag SDK for the web — local evaluation via WebAssembly.", "type": "module", "main": "index.js", diff --git a/server/Cargo.toml b/server/Cargo.toml index 7f617f17..68729e00 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -21,7 +21,7 @@ ipnet = "2.12" redis = { version = "1.0.4", features = ["tokio-comp", "connection-manager"] } serde = { version = "1.0.228", features = ["derive"] } serde_json = "1.0.149" -checkgate-core = { version = "0.1.0", path = "../core" } +checkgate-core = { version = "0.2.0", path = "../core" } rand = "0.10.1" sqlx = { version = "0.8.6", features = ["postgres", "runtime-tokio-rustls", "time"] } time = { version = "0.3", features = ["serde-human-readable"] } diff --git a/ssr/package.json b/ssr/package.json index 84f9897b..72ebb42a 100644 --- a/ssr/package.json +++ b/ssr/package.json @@ -1,6 +1,6 @@ { "name": "@checkgate/ssr", - "version": "0.1.31", + "version": "0.2.0", "description": "Server-side rendering & bootstrap helpers for Checkgate — evaluate flags on the server, embed the result in the HTML, and hydrate the client with zero flag flicker (Next.js, Remix, SvelteKit, any SSR framework).", "type": "module", "main": "src/index.js",