npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@shaevon/decision-ledger

v1.0.1

Published

A strict, deterministic decision engine for recordable, replayable logic.

Downloads

169

Readme

Decision Ledger

A strict, deterministic decision engine for recordable, replayable logic.

Decision Ledger allows you to define policies in a structured Intermediate Representation (IR) and evaluate them against input contexts. Every decision returned is a record of exactly why a result was reached, allowing for perfect auditability and replayability.

Features

  • Strict Validation: Policies and contexts are validated against schemas before evaluation.
  • Deterministic: Given the same policy and context, the engine always produces the same outcome and trace.
  • Auditable: Every decision returns a full trace of which rules were evaluated and why.
  • Replayable: Includes built-in support for verifying decisions after the fact.
  • TypeScript First: Full type safety for policies, contexts, and results.

Installation

npm i @shaevon/decision-ledger

Quick Start

import { 
  evaluateDecision, 
  InMemoryDecisionRecordStore, 
  PolicyIR,
  ComparisonOperator 
} from 'decision-ledger';

const store = new InMemoryDecisionRecordStore();

const policy: PolicyIR = {
  policy_id: "fraud-prevention-v1",
  namespace: "payments",
  decision_type: "fraud-check",
  input_schema: {
    transaction_amount: { kind: "int" },
    is_international: { kind: "int" } // 0 or 1
  },
  rules: [
    {
      id: "high-value-international",
      when: { 
        all: [
          { field: "transaction_amount", op: ComparisonOperator.GT, value: 10000 },
          { field: "is_international", op: ComparisonOperator.EQ, value: 1 }
        ]
      },
      then: { outcome: "FLAG_FOR_REVIEW", reason: "High-value international transaction" }
    },
    {
      id: "low-value-safe",
      when: { field: "transaction_amount", op: ComparisonOperator.LT, value: 50 },
      then: { outcome: "AUTO_ALLOW", reason: "Transaction value below threshold" }
    }
  ],
  default: { outcome: "ALLOW", reason: "Standard transaction" }
};

const result = evaluateDecision({
  decision_id: "tx-7890",
  namespace: "payments",
  decision_type: "fraud-check",
  policy_hash: "hash-v1",
  raw_context: { 
    transaction_amount: 15000, 
    is_international: 1 
  },
  created_at: new Date().toISOString(),
  store,
  policy
});

console.log(result.outcome); // "FLAG_FOR_REVIEW"

Advanced Usage

Replaying Decisions

Decision Ledger provides a verifyReplay utility to ensure that stored decisions are still valid against the policies that created them.

import { verifyReplay } from 'decision-ledger';

const result = verifyReplay(decision_id, recordStore, policyStore);
if (result.ok) {
  console.log("Decision is valid and consistent.");
}

License

ISC