Skip to content

feat(js): add read-only mode to local server provider - #486

Closed
fabriziodemaria wants to merge 2 commits into
mainfrom
feat/js-read-only-mode
Closed

fabriziodemaria wants to merge 2 commits into
mainfrom
feat/js-read-only-mode

Conversation

@fabriziodemaria

Copy link
Copy Markdown
Member

Summary

Adds a readOnly option to the JS OpenFeature local server provider (@spotify-confidence/openfeature-server-provider-local) that lets you resolve flag values without sending any data back to Confidence.

Previously there was no unified way to turn off apply/telemetry/logs together — only a per-evaluation _confidence_skip_apply context key that just suppressed apply for a single evaluation.

When readOnly: true, all three outbound side-effects are suppressed:

  • Apply — resolve requests are forced to apply=false, and applyFlag() becomes a no-op.
  • Telemetry — registerResolve() calls are skipped.
  • Resolve/assignment logs — flush() / flushAssigned() still drain the WASM log buffers (to bound memory) but never POST to /v1/clientFlagLogs:write.

Flag values still resolve normally, so this is a true "read-only" preview mode that leaves experiment metrics unaffected.

const provider = createConfidenceServerProvider({
  flagClientSecret: process.env.CONFIDENCE_FLAG_CLIENT_SECRET!,
  readOnly: true, // resolve values only; no apply, logs, or telemetry
});

Changes

  • ConfidenceServerProviderLocal.ts: new readOnly?: boolean option; gates apply, telemetry, and log sending.
  • ConfidenceServerProviderLocal.read-only.test.ts: new tests asserting zero egress in read-only mode, applyFlag no-op, and a sanity check that logs still send when disabled.
  • README.md / CLAUDE.md (AGENTS.md): documented the option.

Test plan

  • make test (WASM build + install + proto:gen + format:check + typecheck + vitest): 164/164 non-e2e tests pass.
  • New read-only suite passes (3/3).
  • Note: flaglogs.test.ts requires a live CONFIDENCE_CLIENT_SECRET + network and is unaffected by this change.

Made with Cursor

fabriziodemaria and others added 2 commits July 23, 2026 10:26
Add a `readOnly` provider option that resolves flag values without sending
any data back to Confidence: resolves are forced to apply=false, applyFlag()
is a no-op, telemetry (registerResolve) is skipped, and flush()/flushAssigned()
still drain the WASM log buffers to bound memory but never POST to
clientFlagLogs:write.

This enables previewing flag values without recording exposures or generating
traffic, leaving experiment metrics unaffected.

Co-authored-by: Cursor <cursoragent@cursor.com>
Guards against reintroducing unbounded buffer growth: verifies that flush()
still drains the in-WASM resolve-log buffer in read-only mode even though it
sends nothing, so events don't accumulate across the process lifetime.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant