Skip to content
CAI
Software that uses CAICheck a score

tompave/fun_with_flags

70.1

Strong · 23 September 2026

3.2k

lines of production code

Elixir

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

FunWithFlags is an Elixir library for managing application feature flags with support for boolean, actor-based, group-based, and percentage-based gating. It provides a flexible architecture that persists flag states to SQL databases (via Ecto) or Redis, and broadcasts changes via Phoenix.PubSub or Redis Pub/Sub. The system includes an in-memory cache for performance and exposes a public API to enable, disable, and query flags across different backends.

Features

Add Actor and Group protocols for targeted flagging

Introduced the \FunWithFlags.Actor\ and \FunWithFlags.Group\ protocols to enable more granular flagging. The \Actor\ protocol allows enabling or disabling flags for specific entities (like users or countries) by implementing an \id/1\ function. The \Group\ protocol allows enabling or disabling flags for categories of entities (like 'admin' or 'engineering') by implementing an \in?/2\ function. These protocols provide the foundation for actor-based and group-based feature flags, with the group protocol including a default 'Any' implementation that returns false, ensuring safe usage for all types.

_lib/fun\_with\flags/protocols · high confidence

Add Credo configuration and development environment setup

The repository now includes a \.credo.exs\ file to configure the Credo static analysis tool, enabling consistent code quality checks. Additionally, a \.iex.exs\ file has been added to streamline the local development experience by automatically starting the necessary services (Ecto repo, Redis, or Phoenix.PubSub) when launching an IEx session. A \.gitignore\ file has also been added to exclude build artifacts, database files, and other non-essential files from version control.

(repo-wide) · high confidence

Add Ecto and Redis persistence backends for feature flags

The library now supports persistent storage for feature flags via two new adapters: an Ecto-based backend (lib/fun\_with\_flags/store/persistent/ecto.ex) and a Redis-based backend (lib/fun\_with\_flags/store/persistent/redis.ex). The Ecto adapter implements the persistent store behavior, handling flag and gate CRUD operations using SQL transactions and database-specific locking strategies (PostgreSQL advisory locks, MySQL locks, SQLite). The Redis adapter similarly implements the persistent store behavior, using Redis hashes and sets to store flag data and manage subscriptions. Both adapters are conditionally compiled only if their respective dependencies (Ecto/Redix) are present.

_lib/fun\_with\flags/store/persistent · high confidence

Add Ecto persistence layer for feature flags

A new Ecto-based persistence store has been introduced for FunWithFlags, allowing feature flags to be persisted in a SQL database. The implementation includes a \Record\ schema that maps flag states to database rows, supporting both actor and time-based percentage gates. To handle cases where no database is configured, a \NullEctoRepo\ is provided to raise clear errors instead of failing silently or with cryptic exceptions.

_lib/fun\_with\flags/store/persistent/ecto · high confidence

Add Ecto serializer for flag persistence

The library now supports persisting feature flags via Ecto. A new \FunWithFlags.Store.Serializer.Ecto\ module handles serialization and deserialization of flags and gates, including support for \percentage\_of\_time\ and \percentage\_of\_actors\ gate types. The existing \FunWithFlags.Store.Serializer.Redis\ module was also updated to use \Enum.chunk\_every/2\ instead of the deprecated \Enum.chunk/2\.

_lib/fun\_with\flags/store/serializer · high confidence

Add Phoenix.PubSub and Redis Pub/Sub adapters for flag change notifications

The library now supports two new notification backends: a Phoenix.PubSub adapter (FunWithFlags.Notifications.PhoenixPubSub) and a Redis Pub/Sub adapter (FunWithFlags.Notifications.Redis). These allow applications to receive real-time flag change notifications via Phoenix's PubSub system or via Redis, respectively. The Phoenix adapter includes retry logic to handle cases where the PubSub process is not yet started during boot, while the Redis adapter handles connection disconnections and message validation to ensure only cross-node updates trigger cache reloads.

_lib/fun\_with\flags/notifications · high confidence

Add benchmark scripts for flag, cache, and persistence performance

Added new benchmark scripts in the benchmarks directory to measure performance for flag lookups, cache lookups, and persistence adapters. The flag benchmark (flag.exs) tests the performance of checking individual flags and actor/group conditions. The cache benchmark (cache.exs) measures cache lookup performance. The persistence benchmark (persistence.exs) evaluates the performance of the SimpleStore adapter. A README.md file was added to document how to run these benchmarks with different configurations, including support for Ecto and Redis.

benchmarks · high confidence

Add helper scripts for local development environments

Two new executable scripts, bin/console\_ecto and bin/console\_pubsub, have been added to simplify starting the iex console for local development. The Ecto script supports both PostgreSQL and MySQL databases, while the PubSub script configures the Phoenix PubSub broker. These scripts automate the process of clearing build artifacts and setting environment variables to launch the appropriate development environment.

bin · high confidence

Initial Ecto migration for feature flags

Added a new Ecto migration that creates the 'fun\_with\_flags\_toggles' table, defining columns for flag name, gate type, target, and enabled status, along with a unique index on the first three fields. The migration defaults to using a bigserial primary key but includes a commented-out alternative to use :binary\_id, allowing users to configure the primary key type.

priv · high confidence

Introduce in-memory cache and persistence adapter interface

Added a new in-memory cache module backed by an ETS table, providing functions to get, put, and flush cached flag data. Simultaneously, a new \Store.Persistent\ behaviour was introduced to define the interface for persistence adapters, standardizing how flags are stored and retrieved from external backends like Redis or Ecto.

_lib/fun\_with\flags/store · high confidence

Public API for feature flags and percentage-based gates

The main \FunWithFlags\ module now exposes a public API for enabling, disabling, and querying feature flags. This includes support for boolean gates, actor and group-based conditions, and new percentage-of-time or percentage-of-actors gates, allowing flags to be enabled for a specific percentage of time or users.

lib · high confidence

Architecture

Introduces a new internal architecture with a dedicated Supervisor, Config, and Telemetry modules

The library's internal structure has been refactored to use a module-based Supervisor for managing the application's processes, a centralized Config module for reading settings like Redis and cache options, and a Telemetry module for emitting persistence and cache events. This change also introduces new internal modules (FunWithFlags.Supervisor, Config, Telemetry, SimpleStore, Store, Flag, Gate) that replace the previous flat structure, enabling better configuration, error handling, and observability.

_lib/fun\_with\flags · high confidence

Behavioural changes

Centralized configuration for Ecto, Redis, and PubSub backends

The application now supports multiple persistence and notification backends, including Ecto (with MySQL, SQLite, and PostgreSQL), Redis, and Phoenix PubSub. The configuration is now centralized in \config/config.exs\ and \config/test.exs\, allowing users to switch between different database and caching strategies via environment variables (\PERSISTENCE\, \CACHE\_ENABLED\, \PUBSUB\_BROKER\). This change enables flexible local and CI environments, with specific configurations for testing (e.g., SQL sandbox, Redis database 5) and production (e.g., MySQL password handling for CI vs. local dev).

config · high confidence

Support for SQLite3 and MyXQL in Ecto dev repo

The Ecto repository configuration in dev\_support/ecto has been updated to support multiple database backends for local development. The new FunWithFlags.Dev.EctoRepo module dynamically selects the database adapter based on the RDBMS environment variable, allowing for SQLite3, MyXQL (preferred over the legacy Mariaex), or PostgreSQL. This change enables developers to run migrations and tests against different database systems, with MyXQL and SQLite3 support being the primary additions.

_dev\support/ecto · high confidence

Support for flag checks on strings and maps

The dev\_support module now includes protocol implementations for FunWithFlags.Actor and FunWithFlags.Group for the BitString and Map types, as well as a PlainUser struct. This allows the flag system to handle string identifiers and map-based actors/groups, enabling more flexible flag checking for these data types.

_dev\support · medium confidence

Test coverage

Added comprehensive tests for Ecto and Redis persistence adapters; Added integration tests for feature flag states and actor/group/percentage-based evaluations; Added test coverage for Actor and Group protocols; Added tests for Ecto and Redis flag serializers; Added tests for Phoenix PubSub and Redis notification adapters; Added tests for configuration, flag evaluation, gate logic, and store operations; Added tests for the Cache module; New test support modules for Ecto, Redis, and PubSub readiness.

Dependencies

Updated dependencies and test configuration for Elixir 1.16

The project now requires Elixir 1.16 and updates the lockfile with newer versions of key dependencies, including Ecto 3.13.3, Ecto SQL 3.13.2, Postgrex 0.21.1, MyXQL 0.8.0, Redix 1.5.2, and Phoenix PubSub 2.1.3. The test suite has been reconfigured to run all test configurations in sequence, with each test task retrying up to three times in CI environments to mitigate flakiness.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

This is the PUBLIC form of this artifact. Findings are listed in full, but the details of SECURITY findings — which rule fired, in which file, on which line, and how to fix it — are deliberately withheld, and any secret-scanner results are excluded entirely. Where detail is absent here it was REMOVED FOR PUBLICATION; it is not missing from the analysis. The complete artifact is available from the repository owner.

Score

  • CAI 65 → 70 (+5.3)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 100 → 100 (+0.0)
  • Architecture 95 → 92 (-2.4)
  • Maturity 52 → 49 (-2.4)
  • Readiness 68 → 82 (+14.3)
  • Security 75 → 98 (+22.4)

Resolved (14)

  • Coverage not included — suite not readable by the collector
  • Dependency hygiene not measured — no supported dependency manifest was read
  • High CVE: [GHSA redacted] (mix.lock)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • No exposed public API
  • Off-boarding risk: anonymized user #1
  • Test reliability not included

New (27)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • High CVE: [GHSA redacted] (mix.lock)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • High: security finding (details withheld)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • No dependency advisory monitoring
  • Outdated: benchee
  • Outdated: credo
  • Outdated: dialyxir
  • Outdated: ecto_sql
  • Outdated: ecto_sqlite3
  • …and 7 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

tompave/fun_with_flags was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 23 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 26c18e5fe6c0d7a125846b9c17e78f405087d4bc — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-955b9cee9818.