Repository navigation
DO NOT MERGE · v0.2.0 CI vehicle (integrated milestone) - #59
Merged
Merged
Conversation
…rerequisite trace The evaluator becomes generic over a Trace observer. evaluate_variant runs it with NoTrace (empty methods, compiled away); explain() runs the very same function with a recorder. One evaluator, two views — no second copy of the targeting semantics for OpenFeature details, the Python SDK or the evaluation playground to drift from. Reasons follow the OpenFeature vocabulary (DISABLED, TARGETING_MATCH, SPLIT, DEFAULT, STATIC) plus PREREQUISITE_FAILED and ROLLOUT_EXCLUDED. Adds sdks/conformance/vectors/evaluation.json: 28 flags, 86 cases and 6 malformed configurations, with expectations blessed from the core (core/tests/vectors.rs) for every SDK to check itself against. A randomized test checks explain() == evaluate_variant() over 300 generated configurations.
getDetails() returns the engine's explanation (reason, matched rule, rollout bucket, weighted variant, prerequisite outcomes) from the same local evaluation as getVariant(). onStatusChange() reports connection-state transitions, and successful polls while in poll fallback. On a stream 'ready' the client now marks itself ready before switching to 'streaming', so a status listener sees isReady() on a first connection. test/vectors.test.js checks all 86 shared vectors through the public API with the real addon. CI gains sdk-node-native (Node 20/22/24): the real engine plus the OpenFeature provider; sdk-node keeps running the stand-in engine.
…eckgate/node One package, @checkgate/node-integrations, with subpath exports ./express, ./fastify and ./nestjs over a shared core: - RequestFlags: a per-request evaluator bound to one shared CheckgateClient. The context comes from a context(req) extractor, resolved once on first use; attributes are coerced (numbers, bigints, booleans to strings; other values dropped) so a non-string referenced attribute cannot throw inside a request. Evaluations never throw and make no network call. - startCheckgate / stopCheckgate: startup waits at most readyTimeoutMs, then continues (cached or default values, syncing in the background) or fails; a rejected SDK key always fails. Shutdown disconnects exactly once. - Express: checkgateMiddleware -> req.checkgate, listenWithCheckgate for ordered startup and close(). - Fastify: fastify-plugin plugin -> fastify.checkgate / request.checkgate, connect during plugin load, disconnect in onClose. - NestJS: CheckgateModule.forRoot / forRootAsync / forTesting, CheckgateService, @CheckGate() parameter, @RequireFlag() guard; no REQUEST-scoped providers. Plain CommonJS with hand-written .d.ts. Frameworks are optional peers.
An OpenFeature server-SDK provider over @checkgate/node. Every evaluation is
answered by the client's local engine (getDetails) — no network request per
evaluation, no second copy of the targeting rules.
- Boolean / string / number / object resolution with type checks: a value of
the wrong type resolves TYPE_MISMATCH; a flag that is off, or has no value,
and has no value of the requested type returns the caller's default.
- Reasons map to OpenFeature (ROLLOUT_EXCLUDED -> SPLIT, custom
PREREQUISITE_FAILED); flagMetadata carries checkgateReason, ruleIndex,
variantIndex, rolloutBucket.
- Context: targetingKey is the user key; numbers, booleans and dates become
string attributes, objects/arrays/null are dropped (the engine rejects
non-string attributes a rule reads).
- Lifecycle: READY after the first flag set, STALE while reconnecting, READY
again on recovery (polling counts only after a successful poll), FATAL on a
rejected key at startup, ERROR on a later rejection or an initTimeoutMs
expiry; ConfigurationChanged batches the keys of one snapshot.
- { client } shares an existing client, which the provider never disconnects.
Tests run the real OpenFeature SDK, the real native engine and a real SSE
stream (conformance FaultServer): all shared vectors, zero network requests
across 4,000 evaluations, lifecycle transitions, auth failure, init timeout,
close semantics. Docs: docs/sdks/openfeature.md.
…ake server Every adapter runs the same checks with the real @checkgate/node client and native addon, using sdks/conformance/fault-server.mjs as the Checkgate server: 400 concurrent requests with different users and attributes (no context leakage), startup with the server up / down (continue serves defaults or the offline cache and syncs later; fail rejects and stops retrying) / rejecting the key, a live flag change with no per-request network call (fake server counters and a global fetch counter), the server killed and restarted mid-run, and shutdown disconnecting exactly once with no stream left open. Plus adapter-specific tests (lazy context after auth middleware, Fastify encapsulation and clientOptions, NestJS RequireFlag 404/403, forTesting, overrideProvider, forRootAsync), core unit tests, a compile check of the .d.ts files (npm run typecheck), and the shared evaluation vectors when sdks/conformance/vectors/evaluation.json is present.
Minimal apps reading CHECKGATE_URL / CHECKGATE_SDK_KEY from the environment, with a stand-in auth step, a context extractor, flag reads, and SIGTERM shutdown. The NestJS one is TypeScript (compiled with tsc into the ignored examples/nestjs/dist/) and shows @CheckGate() and @RequireFlag(). test/examples.test.mjs runs each as its own process against the fake server and checks the answers and that SIGTERM closes the stream and exits.
…TimeoutMs The root entry re-exported members (core.RequestFlags, ...), which Node's CommonJS export detection does not follow: an ESM importer saw only one name. It now exports plain identifiers, and a test imports every entry point as ESM and checks each documented name. readyTimeoutMs above 2^31 - 1 (or Infinity) made setTimeout fire after 1 ms; it is now rejected.
… too The shared framework suite and the RequireFlag checks now also run with @nestjs/platform-fastify, where the request is a FastifyRequest.
Builds the @checkgate/node native addon (debug) and runs the integration package's type check and tests against it. The matrix is the Node.js lines in LTS in November 2026: 22 and 24 (maintenance) and 26 (active); 20 reached end of life on 2026-04-30.
New public page docs/sdks/node-frameworks.md (supported versions, the request context and attribute coercion, the startup timeout policy, each adapter, NestJS testing and why no provider is REQUEST-scoped, limitations), linked from the sidebar, the SDK chooser, the Node.js SDK page and the README. Package README for sdks/node-integrations.
POST /api/environments/{env}/flags/{key}/evaluate evaluates a flag for a
hypothetical user with checkgate_core::explain, over the flags read by the
SDK snapshot's own statement and expanded by the same segment code — so it
answers what an SDK holding that revision answers. The response carries the
value and type, reason, matched rule with its stored index and segment
origin, rollout bucket, weighted variant, prerequisite outcomes (with their
revisions), the attributes the rules read and which are missing, and the
configuration revision.
It changes nothing (no audit entry, no impression; the body is neither
logged nor stored), takes the environment's read access (project members,
read_only tokens; SDK keys refused by the route allowlist; non-members get
the same answer whether or not the flag exists), and bounds its input
(512-byte key, 100 attributes, 128/1024-byte names/values; non-scalar
values are refused, not dropped; 413 over the body limit).
The snapshot reader is split so both paths share decoding; the SDK path's
statement and work are unchanged. Segment expansion records rule origins
through a closure that is a no-op on the SDK path.
Dashboard: Playground page (side by side: context on the left, result and
explanation on the right; JSON attributes with validation; example context
from the flag's rules; reset). Tests: server/tests/playground.rs (all 86
shared vectors through the endpoint, segment tracing, validation, RBAC, no
side effects) and dashboard Playground.test.tsx.
A binding that evaluates from several threads needs to swap a whole new flag set in at once, so a concurrent evaluation never sees a flag from one version and its prerequisite from another. independent_copy() gives the copy-on-write base: a new map sharing the Arc'd flags, one pointer per flag.
…ngine) New workspace crate sdks/python (checkgate-python), PyO3 0.30.1 with abi3-py311. Evaluation only: upsert/validate/delete/clear, an atomic batch apply(), is_enabled, get_variant, explain (dict, core snake_case keys) and flag count/keys. Thread-safe: evaluations read the live FlagStore through an Arc and run with the GIL released; writers build the next set copy-on-write and swap it in whole. Attributes keep str values and skip the rest, as checkgate_core::attributes does for web/RN/Flutter. A flag that fails to parse is rejected and its old version removed (fail closed). The lib target has test = false: it is tested from Python, and a Rust test binary would have to link libpython under cargo test --workspace.
…fline cache Pure-Python sync (stdlib only), a port of sdks/nodejs/index.js: staged replay swapped in on ready, per-flag revision rules with mergeFullSet and the learn counter (R20), poll fallback (/flags/snapshot?v=2), exponential backoff with jitter, connect deadline, idle watchdog (3 x heartbeat_ms), terminal auth_failed on 401/403, pluggable storage with FileStorage. One daemon thread runs the state machine like the Node event loop; stream and poll I/O run on worker threads and are aborted by socket shutdown. Public API: connect / connect_async, is_enabled, get_value, get_variant, get_details (OpenFeature reasons), get_status, get_health (schema 1), on_change, close and context managers. A client used after os.fork() raises CheckgateForkError. No impression reporting in this release. Tests (pytest): shared evaluation vectors through the engine and the client, engine concurrency, the sync state machine against a local fake server, fork safety, and a latency harness (tool/bench.py).
… Python sdks/python/tool/conformance_adapter.py speaks the Dart adapter's JSON-lines protocol; pythonAdapter in adapters.mjs spawns it (PYTHON, else sdks/python/.venv), sdks/conformance/python.mjs runs the named scenarios and ci-seeds.json. live.mjs and scripts/sdk-live-e2e.sh include python.
docs/sdks/python.md (sidebar + SDK chooser), and examples for the FastAPI lifespan, a Flask app factory with a lazy per-process client, Django AppConfig.ready() with atexit, and gunicorn post_fork for --preload.
ci.yml sdk-python: build the release wheel, install it, run pytest and the SSE fault suite (CI seeds) on Python 3.11 and 3.13. release.yml build-python: maturin-action wheels for linux x86_64/aarch64 (manylinux), macOS x86_64/arm64 and windows x86_64, tested where the runner can run them, uploaded as artifacts. No publish job, and not yet a dependency of the publish jobs. check-tracked-artifacts also rejects .venv, wheels and built extension modules.
…e offline cache as STALE getHealth() reports, from local state only: state, ready, source (none / offline_cache / server), flag count, config age, highest received and applied revisions, stale events ignored (stream events and full-set entries older than held state), consecutive and total reconnects, poll fallback and its last success, the last sync error by kind (auth, network, http, parse, timeout) with its time, and the offline cache. Never the SDK key, user keys or attributes. The schema is shared with the Python SDK. The OpenFeature provider uses it: when initTimeoutMs expires but the client holds flags hydrated from its offline cache, the provider becomes READY and then STALE (instead of ERROR), and READY again once the server answers. FaultServer gains blockStreams (streams 503, snapshots work: a proxy that blocks long-lived connections). test/health.test.mjs checks the diagnostics against what the fault server actually did.
A third PAT scope, `propose`, that the server enforces on every request:
reads as read_only, plus exactly three writes, each narrowed by its handler:
- PATCH /api/environments/{env}/flags/{key} always queues a pending change
request (202), whether or not the environment requires approval;
- POST /api/environments/{env}/flags only creates a new, disabled flag
(409 over an existing key in every environment, 422 if the body enables
it or sets a disabled_value);
- DELETE /api/environments/{env}/change-requests/{id} only withdraws the
owner's own pending request (no admin override).
Every other write, approve and reject included, is 403, so an agent's
credential cannot apply, approve or reject a change even over raw HTTP.
require_admin never admits a propose token; require_editor admits it only
on the three route shapes (exact segment match). Project RBAC and the
self-approval block are unchanged.
Token minting is generalised: a token may only mint tokens at most as
capable as itself (read_only < propose < read_write); a scope this build
does not know ranks as read-only and is denied writes.
Migration 29 replaces the scope CHECK constraint (additive). An older binary
will not boot against a migrated database (the migrator reports the applied
migration as missing); one that did would treat propose as read-only.
Dashboard: "Propose (agents)" in the token form, with a one-line note.
Docs: token scopes in the API reference and governance guide.
Tests: server/tests/propose_scope.rs (6 integration tests, wired into the
server-integration CI job) and auth unit tests.
…se changes A Model Context Protocol server (stdio only) on the official SDK (@modelcontextprotocol/sdk 1.32.2, zod 4.6.7, both pinned). Read tools (always): access info, projects, environments (with require_approval), paginated flags, one flag, targeting explained in evaluation order (segments expanded), dependencies, audit events (changed fields only), a flag diffed across two environments, change requests, SDK connection counts per environment (no addresses). Proposal tools only with CHECKGATE_MCP_WRITE=1: create_draft_flag (always disabled, never overwrites), propose_flag_change, propose_rollout_change, cancel_change_request (own). No approve, reject, delete, promote, archive or raw-HTTP tool. CHECKGATE_MCP_REQUIRE_PROPOSE (default on) refuses to send a change unless the token is a propose token (scope read from /api/tokens by display prefix; ambiguous counts as not-propose) or the environment requires approval; a direct apply (HTTP 200) is reported with a leading WARNING. API content is returned as data: structuredContent plus a delimited <checkgate-data> block whose JSON escapes <, > and & so user text cannot close it. Strict, bounded zod schemas for every input; 10 s request timeout, streamed 2 MiB response cap, redirects refused, errors built from the status code only; the token never appears in results, errors or stderr, and a URL with credentials is refused. Exits 0 when stdin closes (after answering requests already received) and on SIGTERM. Tests: node --test unit/schema/error/redaction/prompt-injection tests against a fake API, stdio lifecycle tests, and an e2e suite against a real server with a propose token (also measures stdio overhead). CI: new mcp-server job; the e2e runs in server-integration. Docs: ecosystem/mcp page (setup and security model), package README.
…G_DONTWAIT on Windows)
…convergence summary, poll-fallback metrics
- Each SSE connection records the highest flag revision written to it (the
replay, then each change event) in an AtomicI64: no per-event map write.
/api/health/connections reports it as last_delivered_revision.
- GET /api/health/environments: per environment with open streams on this
instance — connections, latest committed revision, streams not yet sent
it, oldest connection. Counts only, same project visibility rules.
- Metrics: checkgate_snapshot_requests_total{outcome,format} (poll-fallback
activity) and checkgate_playground_evaluations_total{outcome}. Bounded
labels only; never keys, user ids, environments or attributes.
Dashboard SDK Health shows the per-environment convergence and the delivered
revision per stream, and says plainly that this is what the server observes —
not proof an SDK applied it, and blind to SDKs that poll or serve their
offline cache (getHealth() in the application is the SDK's own view).
Tests: server/tests/sdk_diagnostics.rs (delivered revision follows replay and
changes, summary convergence, counters, no forbidden label values, RBAC) and
SdkHealth.test.tsx.
# Conflicts: # docs/.vitepress/config.ts
…ions v0.2.0 · Phase 3: Express, Fastify, NestJS integrations
…he workspace The image build copies each workspace member's Cargo.toml before the sources (dependency layer caching). sdks/python joined the workspace without one, so every cargo command in the image failed to load the workspace. (cherry picked from commit d01dfe1)
v0.2.0 · Phase 7: propose-scoped tokens + MCP server
…-branch merge)
v0.2.0 · Phase 4: five-minute quickstart (stacked on all)
…ifest v0.2.0 · fix: Docker build copies the Python SDK manifest (stranded from #53)
Resolving the ci.yml and README conflicts between the phase PRs kept one side of each hunk: - the whole node-integrations CI job (Express/Fastify/NestJS on the real addon) was gone, so #56's tests no longer ran anywhere; - sdk-node-native was back on Node 20/22/24 (20 is end of life since 2026-04-30) instead of 22/24/26; - the README documentation table lost its OpenFeature and Python rows. Restored from the integrated tree that CI vehicle #59 tested.
v0.2.0 · fix: restore the node-integrations CI job, Node 22–26 matrix and README rows lost in merge resolution
…s Python SDK - integrations/.gitignore ignores bin/ (Go build output), which silently kept integrations/mcp-server/bin/checkgate-mcp.js — the package's executable, package.json "bin" — out of the repository. The MCP server could not start from a clone (CI: 'Cannot find module …/bin/checkgate-mcp.js', 4 stdio tests failed) and npm pack would have shipped no executable. Negated for mcp-server/bin/ and the file added (mode 755). - scripts/sdk-live-e2e.sh all includes Python since #53 and exits when the package is not installed in sdks/python/.venv; the SDK e2e job never set it up, so the whole live suite (every SDK) stopped before running. The job now builds and installs the wheel.
Linux x86_64 and aarch64, macOS x86_64 and arm64, Windows x86_64: build the wheel on the platform, install it into a clean environment and run the test suite against the installed package. The release workflow's wheel jobs run only on a version tag and cross-build some targets without testing them; this is the per-platform evidence before a release. Runs on PRs that touch the engine or the Python SDK, and by hand.
v0.2.0 · fix: MCP bin entry was git-ignored; live e2e job lacked the Python SDK
v0.2.0 · ci: native-platform Python wheel tests (Linux arm64, macOS, Windows)
On windows-latest the job failed before compiling anything: dtolnay installed stable, then cargo fetched the rust-toolchain.toml pin and rustup refused to add clippy (detected conflict: bin\cargo-clippy.exe). release.yml's native builds already use `rustup show`, which installs exactly the pin.
Path.read_text() decodes with the locale encoding, cp1252 on Windows, which turned the unicode-user-key case's 'ユーザー-ü' into 'ユーザー-ü' — a different user, a different rollout bucket, and 2 failures on windows-x86_64. The SDK itself already reads and writes UTF-8 explicitly (offline cache, SSE, snapshots); only the test fixture was wrong. The conformance adapter's stdin gets the same treatment.
…lchain v0.2.0 · ci: python-wheels on Windows — install the pinned toolchain with rustup show
A propose token could create a new, disabled flag, and creating a flag is not a change request. A created flag is served to SDKs at once: code that already reads that key — getValue(key, default), get_value, OpenFeature getBooleanValue(key, true) — starts getting false (or another value of the flag) instead of its own default, with no approval, even in environments that require approval. That broke the scope's promise that an agent never changes what production serves on its own. - auth: POST …/flags is no longer a propose route (403 from require_editor); create_flag also refuses a propose token (defence in depth). The propose-only create rules (disabled-only, never overwrite, audit marker) are gone with it. - MCP server: create_draft_flag removed; no tool creates flags. - Tests: propose_scope.rs asserts 403 for every create shape in both kinds of environment, nothing stored, no CREATE audited, the owner's session still creates. Mutation check: re-allowing the route without the handler guard fails it. MCP unit 29 pass; e2e against a real server 2/2. - Docs: MCP guide, API reference, governance, README, CHANGELOG.
…eate v0.2.0 · fix(security): propose tokens cannot create flags (review F-01, high)
…blocks connect (review F-03, F-04, F-16) - F-03: stream_idle_timeout_ms=inf passed validation and then ended the sync thread for good: Condition.wait raises OverflowError past threading.TIMEOUT_MAX. Every millisecond option is now finite and at most 2^31-1 ms (Node's timer ceiling), and the loop's wait is clamped to TIMEOUT_MAX as a backstop. - F-04: hydration caught only ValueError, so a cache whose parse raised anything else (deep nesting -> RecursionError, a custom storage's TypeError) skipped opening the stream and connect() never settled. Any error is now logged and ignored, and the stream opens in a finally. - F-16: stream and poll parsing also catch RecursionError (and TypeError for snapshot shapes). Tests: hostile caches (deep JSON, raising storage) still connect; delay options bounded; a 1e12 s timer no longer ends the loop. Both new tests fail on the previous code (checked). pytest 160/160, mypy --strict clean.
- F-05: the provider stayed READY while every poll failed — 'polling' is the state whether polls succeed or not. The client now notifies status listeners after every poll in fallback (success or failure), and the provider treats polling as current only while a poll succeeded within two poll intervals (getHealth().lastPollAt). Stream retries failing alongside successful polls do not flap it. - F-10: onStatusChange delivered 'auth_failed' with error: null (state set before the error). - F-11: a status listener calling disconnect() on 'connecting' left connect() pending forever: the promise is now created before the state change, and connect() opens no stream after such a disconnect. - F-13: an initTimeoutMs expiry followed by a rejected key never reached FATAL; it now emits PROVIDER_ERROR with PROVIDER_FATAL. - F-09: test/bench.mjs ran under npm test (node --test runs every .mjs in test/): minutes per CI run. Moved to bench/overhead.mjs (npm run bench). Regression tests for F-05/F-13 (provider) and F-10/F-11 (client) fail on the previous code (checked). Node SDK 76/76 incl. the fault suite; provider 16/16 in 6 s; typecheck clean.
v0.2.0 · fix(sdk-python): bounded timers, a bad cache never blocks connect (review F-03, F-04, F-16)
…review v0.2.0 · fix(node, openfeature): STALE on failing polls, status/connect edge cases, bench out of npm test (review F-05/09/10/11/13)
… new npm packages; Python marked unpublished (review F-02, F-06, F-07, F-08, F-23) - F-02: docs/operations/upgrading-to-0-2-0.md and the CHANGELOG, from a run of bench/ab/upgrade-rollback.sh with release builds of 0.1.31 and a 0.2.0 candidate: upgrade keeps the SDK snapshot byte-identical; a 0.1.31 instance refuses to start once migration 29 is applied (no rolling mixed-version upgrade); create no propose tokens while a 0.1.31 instance serves (0.1.31 lets them mint read_write tokens); rollback = stop 0.2.0, delete propose tokens, delete the migration row, start 0.1.31 (tested: 0.1.31 became ready with no errors). - F-06: release.yml verifies the MCP server's tests and that the three new npm packages pack the files their manifests point at, and publishes @checkgate/openfeature-provider, @checkgate/node-integrations and @checkgate/mcp-server like @checkgate/cli (tag-only, after every verify job). - F-07: the docs, README, quickstart, seed output and dashboard snippet say the Python package is not on PyPI yet and show the build-from-checkout path; nothing tells users to pip install an unclaimed name. - F-08: bump-version.sh covers the OpenFeature provider, the MCP server and the Python package (pyproject + __version__); the MCP server reads its version from package.json. Checked on a scratch copy: all 15 files bump. - F-23: getHealth() is in the Node.js and Python SDKs, not every SDK; the MCP job runs Node 22 only.
v0.2.0 · release, docs: propose-token upgrade/rollback rules, publish jobs for new npm packages, Python marked unpublished (review F-02/06/07/08/23)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE. CI vehicle for the v0.2.0 milestone:
ci.ymlonly runs on PRs into main/dev, and the phase PRs targetfeat/v0.2.0-developer-adoption. This branch is the integrated milestone (all phase PRs merged, plus the quickstart). Close it once the phase PRs are merged and an integration → dev PR exists.Phase PRs: #50, #51, #52, #53, #54, #55, #56, #57, #58.