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

@run-iq/core

v0.2.5

Published

PPE — Parametric Policy Engine core

Readme

@run-iq/core

Parametric Policy Engine (PPE) — a deterministic, plugin-driven rules engine for financial and regulatory computation.

Install

npm install @run-iq/core

Quick start

import { PPEEngine } from '@run-iq/core';

const engine = new PPEEngine({
  plugins: [fiscalPlugin],
  dsls: [jsonLogicEvaluator],
  snapshot: snapshotAdapter,
  strict: true,
  timeout: { dsl: 100, hook: 500, pipeline: 5000 },
});

const result = await engine.evaluate(rules, {
  requestId: 'req-001',
  data: { grossSalary: 2_500_000 },
  meta: { tenantId: 'tenant-1' },
});

console.log(result.value);       // aggregated value
console.log(result.breakdown);   // per-rule contributions
console.log(result.trace);       // full audit trail

Pipeline

The engine executes a 10-step pipeline on every call to evaluate():

  1. Input validation — sanitize and validate the input
  2. Idempotence check — skip if requestId already processed
  3. beforeEvaluate hooks — plugins enrich input and can modify rules via BeforeEvaluateResult
  4. Rule filtering — date range, tags, DSL conditions
  5. Rule validation — checksum + params verification
  6. Dominance resolution — priority sort + conflict handling
  7. Execution — models compute contributions (decimal-safe)
  8. afterEvaluate hooks — plugins enrich result
  9. Snapshot — persist immutable audit record
  10. Return — final EvaluationResult

Key concepts

| Concept | Description | |---|---| | Rule | Declarative policy unit with model, params, condition, priority, and date range | | CalculationModel | Pure function (input, rule, params) → number — registered by plugins | | DSLEvaluator | Evaluates rule conditions (e.g. JSONLogic, CEL) — pluggable | | PPEPlugin | Lifecycle hooks (beforeEvaluate, afterEvaluate) + model registration | | BeforeEvaluateResult | Return type from beforeEvaluate containing both input and rules to evaluate | | Snapshot | Immutable audit record with full rule copies and DSL versions |

Retroactive calculation

Pass effectiveDate to evaluate rules as of a specific date:

const result = await engine.evaluate(rules, {
  requestId: 'req-002',
  data: { grossSalary: 2_500_000 },
  meta: {
    tenantId: 'tenant-1',
    effectiveDate: new Date('2023-12-01'),
  },
});

Hydrating rules from JSON

When rules come from an API or database as JSON, date fields are strings. Use hydrateRule to convert them:

import { hydrateRule, hydrateRules } from '@run-iq/core';

const rule = hydrateRule(jsonFromApi);
const rules = hydrateRules(jsonArrayFromDb);

Exported errors

| Error | Code | When | |---|---|---| | RuleConflictError | RULE_CONFLICT | Same-priority rules in strict mode | | ModelNotFoundError | MODEL_NOT_FOUND | Rule references unregistered model | | DSLNotFoundError | DSL_NOT_FOUND | Rule condition uses unregistered DSL | | DSLTimeoutError | DSL_TIMEOUT | DSL evaluation exceeds timeout | | DSLEvaluationError | DSL_EVALUATION_ERROR | DSL syntax or runtime error | | SnapshotFailureError | SNAPSHOT_FAILURE | Snapshot save fails in strict mode | | ValidationError | VALIDATION_ERROR | Input validation fails |

Requirements

  • Node.js >= 20
  • TypeScript >= 5.4

License

MIT