Skip to content
CAI
Software that uses CAICheck a score

pedroassumpcao/incident

76.8

Strong · 21 September 2026

2.3k

lines of production code

Elixir

primary language

8

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Incident is an Elixir library that provides a foundational framework for building event-sourced and CQRS-based applications. It offers configurable event and projection stores with support for both in-memory and PostgreSQL backends, along with aggregate state management and command handling. The system includes a complete example demonstrating bank account and transfer domain logic, supported by comprehensive integration and unit tests.

Features

Add bank account and transfer domain logic with event sourcing

The bank example application now includes full domain logic for managing bank accounts and money transfers using an event-sourced architecture. This adds the \Bank.BankAccount\ aggregate to handle account operations like deposits, withdrawals, and money transfers, alongside a \Bank.Transfer\ aggregate that manages the lifecycle of a transfer (request, initiate, complete, revert, cancel). The implementation includes corresponding command handlers, event handlers for projecting state, and Ecto repositories for both the event store and projection store backed by Postgres.

examples/bank/lib/bank · high confidence

Add in-memory event store and lock manager

Introduces an in-memory implementation of the event store adapter, including data structures for events and aggregate locks, along with a GenServer-based lock manager that supports retry logic and automatic lock expiration.

_lib/incident/event\_store/in\memory · medium confidence

Add mix task to generate Postgres schema migrations

A new \mix incident.postgres.init\ task has been added to the \lib/mix\ directory. This tool generates Ecto migrations to create the \events\ and \aggregate\_locks\ tables required by the Postgres adapter, including the necessary indexes and constraints for the event store.

lib/mix · high confidence

Added bank example application with CQRS and event sourcing

The examples/bank directory now contains a complete example application demonstrating the use of the Incident library for event sourcing and CQRS. This includes the implementation of commands, events, aggregates, and projections, along with configuration for Postgres-based event and projection stores. The example also provides a diagram illustrating the state transitions for a money transfer operation.

examples/bank · high confidence

Adds command handlers for bank operations

The example bank application now includes command handlers for opening accounts, depositing and withdrawing money, sending and receiving money, initiating, completing, and canceling transfers, as well as reverting money sent and transfers. These commands use Ecto.Schema and Ecto.Changeset for validation, with each command defining required fields and validation rules (e.g., amount \> 0).

examples/bank/lib/bank/commands · medium confidence

Introduce Projection Store adapter interface and in-memory implementation

Added a new Projection Store adapter interface (Incident.ProjectionStore.Adapter) that defines the API for storing and retrieving projections. Implemented an in-memory adapter (Incident.ProjectionStore.InMemory.Adapter) using Agents, providing project, all, and get operations. This establishes the foundation for pluggable projection storage backends.

_lib/incident/projection\store · high confidence

Introduces Event Store adapter interface

A new module, Incident.EventStore.Adapter, has been added to define the API for Event Store adapters. This module specifies the types for persisted events (supporting both InMemory and Postgres implementations) and defines callbacks for retrieving and appending events, establishing a consistent interface for event storage.

_lib/incident/event\store · high confidence

Introduces core event-sourcing infrastructure: aggregates, commands, and stores

The Incident library now includes the foundational components for an event-sourced architecture. This adds an Aggregate behavior for handling commands and applying events, a CommandHandler macro that validates commands, executes them via an aggregate, persists the resulting event, and broadcasts it to an event handler. It also introduces an EventStore with lock management for concurrency control, a ProjectionStore for maintaining read models, and supervisors to manage the event and projection stores. These changes provide the core mechanics for processing commands and propagating state changes.

lib/incident · high confidence

Postgres event store adapter and lock manager implementation

The Postgres adapter for the event store is now implemented, introducing the \Incident.EventStore.Postgres.Adapter\ module to handle event persistence via Ecto. This includes new Ecto schemas for \Event\ and \AggregateLock\ to manage state and locking. A dedicated \LockManager\ GenServer has been added to coordinate aggregate locking with configurable retries, timeouts, and automatic lock release, ensuring safe concurrent access to the Postgres-backed event store.

_lib/incident/event\store/postgres · medium confidence

Behavioural changes

Add Credo configuration and update Elixir/Erlang versions

The project now includes a \.credo.exs\ file to configure the Credo static analysis tool, enabling a comprehensive set of consistency, design, readability, and refactoring checks for the codebase. Additionally, the minimum supported Elixir version has been updated to 1.12 (with Erlang 23), and the \.tool-versions\ file specifies Elixir 1.12.3-otp-23, ensuring developers use the correct runtime versions.

(repo-wide) · high confidence

Add Ecto schemas for bank account and transfer projections

The example application now uses Ecto schemas to define the structure of the bank account and transfer projections. These schemas map to 'bank\_accounts' and 'transfers' database tables, each including fields for aggregate IDs, account numbers, balances, versions, and event metadata, enabling structured persistence and validation for these read models.

examples/bank/lib/bank/projections · medium confidence

Add database migrations for the bank example app

The bank example app now includes database schema migrations for its event store, aggregate locks, and projection stores. Specifically, it adds a new 'events' table for the event store, an 'aggregate\_locks' table to manage aggregate locking, and projection tables for 'bank\_accounts' and 'transfers' to support the example's domain logic.

examples/bank/priv · medium confidence

Add event definitions for bank transfer lifecycle

The bank example application now includes a comprehensive set of event structures to track the full lifecycle of a money transfer. New event types have been added to capture each stage: TransferInitiated, TransferRequested, TransferCompleted, TransferCancelled, and TransferReverted. Additionally, supporting events for the source and destination accounts (MoneySent, MoneyReceived, MoneySentReverted) are now defined using Ecto.Schema, allowing the system to record and process these domain events.

examples/bank/lib/bank/events · high confidence

Configure PostgreSQL database connections for the bank example app

The bank example application is now configured to use PostgreSQL for both the event store and projection store repositories. Environment-specific settings (dev, test, prod) define the database credentials and connection details, with the test environment also configuring the Ecto SQL sandbox and setting the logger level to error.

examples/bank/config · medium confidence

Environment-specific configuration files for Ecto repositories

The application now uses separate configuration files for each environment (dev, test, and prod). The main config file now imports environment-specific settings, allowing the Ecto repositories for the event store and projection store to be configured differently per environment, with the test environment explicitly setting the logger level to error.

config · high confidence

Incident module refactored into a configurable supervisor

The Incident module has been transformed from a simple utility into a GenServer-based supervisor that manages the application's supervision tree. It now dynamically configures and starts the Event Store and Projection Store components based on provided configuration, supporting both Postgres and In-Memory adapters for each.

lib · high confidence

Test coverage

Add tests for Incident supervision tree and test helpers; Added integration tests for the bank example application; Added test coverage for the projection store; Added test support infrastructure for Postgres event and projection stores; Added tests for the Incident aggregate, state, and command handler; Added tests for the in-memory event store adapter and lock manager; Added tests for the incident event store.

Dependencies

Update project configuration and dependencies for the Incident library and example app

The Incident library's \mix.exs\ has been updated to require Elixir 1.12, bump the version to 0.6.2, and add comprehensive metadata (maintainers, licenses, links) for Hex packaging. The dependency list now explicitly includes \credo\, \dialyxir\, \ex\_doc\, and \excoveralls\ as dev/test tools, alongside \ecto\, \ecto\_sql\, \jason\, and \postgrex\ for database and data parsing. Additionally, a new \examples/bank/mix.exs\ and its corresponding \mix.lock\ files were added to configure the bank example application, which depends on \incident\ and \dialyxir\. The root \mix.lock\ was refreshed to lock the new dependency versions.

(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 74 → 77 (+2.6)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 100 → 99 (-0.4)
  • Architecture 100 → 94 (-6.3)
  • Maturity 62 → 62 (+0.0)
  • Readiness 85 → 85 (+0.4)
  • Security 75 → 89 (+13.7)
  • Event Sourcing 100 → 100 (+0.0)

Resolved (15)

  • Coverage not included — suite not readable by the collector
  • Dependency hygiene not measured — no supported dependency manifest was read
  • Duplicated block (6 lines × 2) (lib/incident/event_store/in_memory/adapter.ex)
  • High CVE: [GHSA redacted] (mix.lock)
  • 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)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • No exposed public API
  • Test reliability not included
  • The 'Setup' section describes adding Incident to supervision trees but does not explain how to run the application or what output one expects. (examples/bank/README.md)
  • dormant codebase — no living knowledge left to concentrate

New (27)

  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • Duplicated block (6 lines × 4) (examples/bank/lib/bank/commands/cancel_transfer.ex)
  • Duplicated block (7 lines × 2) (lib/incident/event_store/in_memory/adapter.ex)
  • Duplicated block (7 lines × 6) (examples/bank/lib/bank/commands/deposit_money.ex)
  • High CVE: [GHSA redacted] (mix.lock)
  • 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)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • Medium CVE: EEF-[CVE redacted] (mix.lock)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Medium: security finding (details withheld)
  • Outdated: credo
  • Outdated: dialyxir
  • Outdated: ecto
  • Outdated: ecto_sql
  • …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

pedroassumpcao/incident 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 21 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 b879cb757464cbe6b0996d09c1102cb9867d1421 — 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-b84573e22831.