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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rule-of-law

v0.0.10

Published

[![Build Status](https://github.com/nvie/rule-of-law/workflows/test/badge.svg)](https://github.com/nvie/rule-of-law/actions)

Downloads

64

Readme

Build Status

Rule of Law

Rule of Law is a logical predicate language and a tool that allows you to verify assumptions about data and relationships in your database that are otherwise hard to check or enforce.

Think of Rule of Law as a last line of defense, to provide a safety-net for cases that normal database constaints cannot cover.

Example

Here's an example:

rule "All completed orders must have a completion date"
forall orders o:
  o.status = "COMPLETE" => o.date_completed != NULL

Read the above as "for every order in the DB it should hold that if its status is COMPLETE, then it must also have a completion date". Note that this expression says nothing about non-COMPLETE orders.

One could also state the opposite: "for every order in the DB it should hold that if it has a completion date, then it must also be in COMPLETE status":

rule "All orders with a completion date must be complete"
forall orders o:
  o.date_completed != NULL => o.status = "COMPLETE"

Since this arrow holds both ways, these two rules can be combined into a single rule with an equivalence relation:

rule "All completed orders have a completion date, and all others do not"
forall orders o:
  o.date_completed != NULL <=> o.status = "COMPLETE"

Rationale

Codifying these rules as logical statements serves multiple purposes:

  1. Share common system knowledge. By making the rules explicit, they become an expression of intent.
  2. Explicit documentation.
  3. One place to look. Since all rules can be stored in the same place, it's easy to find.
  4. Proactive monitoring. Since these rules are self-validating, we can periodically run them as checks against real production data and alert as soon as a counter example is found.
  5. Test cases. By running the rules as part of the CI / testing phase, you can catch broken assumptions as they happen.
  6. Guide code reviews. Because the rules are explicitly stored and versioned alongside code, they allow us to link to a rule when reviewing code.
  7. Part of the developer workflow. While working on new code, formulate a one-off rule and verify it quickly against real data.