03 / 12Prism Systems · Cloud-Native & Developer Infrastructure
Feature flags evaluated at the edge, in microseconds
A LaunchDarkly-style feature flag engine: targeting rules, segments, prerequisites, sticky murmur3 percentage rollouts, multi-region replication that survives partitions, and a tamper-evident audit chain.
Roll out to four regions at once
The same 96 users are evaluated in four regions. Drag the rollout slider and watch versions replicate, partition Mumbai to see it serve stale config, hit the kill switch, then heal it and watch it converge in order.
What's inside the engine
Real algorithms, not mock-ups. The simulator above runs the exact same code you import.
Targeting rules
15 operators (in, endsWith, matches, semverGte, before, gt…), negation, array attributes and per-user targets.
Segments
Reusable audiences with include/exclude lists and their own rules, referenced via segmentMatch.
Sticky rollouts
murmur3(flag.salt.key) % 100000 buckets users the same way in every region. Raising the percentage never flips users out.
Prerequisites
A flag can require another flag's variation, with cycle protection, which is how experiments depend on launches.
Multi-region replication
A versioned control plane pushes changes to regions. Delivery is idempotent, out-of-order changes are buffered and applied in sequence.
Partition tolerant
A partitioned region keeps serving its last known config and catches up in order when it heals.
Audit hash chain
Every change records actor, comment and a field diff, chained with SHA-256 so tampering is detectable.
Fast evaluation
Pure functions with a regex cache: roughly 3µs per evaluation on Node 20, millions per second for simple flags.
From request to result
Define
A flag has variations, targets, ordered rules, a fallthrough and an off variation. Rules contain clauses on context attributes.
Evaluate
Order: off → prerequisites → individual targets → first matching rule → fallthrough. Each result carries a reason such as RULE_MATCH or PREREQUISITE_FAILED.
Bucket
Rollouts hash flag key, salt and user key into 100,000 buckets and walk the cumulative weights. No state is stored per user.
Publish
The control plane assigns a global version, appends to the change log, writes an audit entry and fans the change out to every region.
Converge
Regions apply version N only after N−1. Gaps are buffered. After a partition, a region drains its buffer or resync()s from the log.
System design
Every box is a module in src/. Data flows left to right.
Ship it in your own stack
Zero dependencies. Works in Node.js 18+ and modern browsers.
import { evaluate, percent, Region, ControlPlane } from "prism-flags";
const flag = {
key: "new-checkout", on: true, variations: [false, true],
rules: [{ id: "india-v5", clauses: [
{ attribute: "country", op: "in", values: ["IN"] },
{ attribute: "appVersion", op: "semverGte", values: ["5.2.0"] },
], variation: 1 }],
fallthrough: percent(10), // 10% of everyone else
};
evaluate(flag, { key: "u-1", country: "IN", appVersion: "5.3.0" });
// → { value: true, variation: 1, reason: { kind: "RULE_MATCH", ruleId: "india-v5" } }
// multi-region
const regions = ["us-east-1", "ap-south-1"].map((n) => new Region(n));
const cp = new ControlPlane(regions);
cp.setFlag(flag, { actor: "alice", comment: "launch" });
cp.tick(1); // deliver
regions[1].evaluate("new-checkout", { key: "u-1" });
console.log(cp.verifyAudit()); // true$ npx github:krishyaa06/prism-flags eval examples/flags.json --flag new-checkout --ctx '{"key":"u1","country":"IN","appVersion":"5.4.0"}'
$ npx github:krishyaa06/prism-flags rollout examples/flags.json --flag pricing-experiment
$ npx github:krishyaa06/prism-flags bench examples/flags.json
$ npx github:krishyaa06/prism-flags regions# use the CLI without installing
$ npx github:krishyaa06/prism-flags --help
# or add the engine to your project
$ npm install github:krishyaa06/prism-flags
# run the simulator locally
$ git clone https://github.com/krishyaa06/prism-flags.git && cd prism-flags
$ npx serve . # then open http://localhost:3000