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

@consensus-tools/policies

v0.7.0

Published

Built-in consensus policy implementations for consensus-tools

Readme

@consensus-tools/policies

Pluggable consensus policy registry with all 9 built-in resolution strategies. Use this package when you need to swap policies at runtime or register custom ones.

Install

pnpm add @consensus-tools/policies

Quick Start

import { createPolicyRegistry, createRegistryResolver } from "@consensus-tools/policies";

const registry = createPolicyRegistry(); // pre-loaded with all 9 policies
const resolver = createRegistryResolver(registry);

// resolver dispatches based on job.consensusPolicy.type
const result = resolver({ job, submissions, votes, reputation: (agent) => 1 });
console.log(result.winners, result.consensusTrace);

Register a Custom Policy

import { createPolicyRegistry, createRegistryResolver } from "@consensus-tools/policies";

const registry = createPolicyRegistry();
registry.set("MY_CUSTOM_POLICY", (input) => {
  // Your logic here -- return { winners, winningSubmissionIds, consensusTrace, finalArtifact }
  const best = input.submissions.sort((a, b) => b.confidence - a.confidence)[0];
  return {
    winners: best ? [best.agentId] : [],
    winningSubmissionIds: best ? [best.id] : [],
    consensusTrace: { policy: "MY_CUSTOM_POLICY" },
    finalArtifact: best?.artifacts ?? null,
  };
});

const resolver = createRegistryResolver(registry);

Use Individual Policies Directly

Each policy is also exported as a standalone function:

import { approvalVote, majorityVote, topKSplit } from "@consensus-tools/policies";

const result = approvalVote({ job, submissions, votes, reputation });

Built-in Policies

| Policy | Type Key | How It Resolves | |---|---|---| | firstSubmissionWins | FIRST_SUBMISSION_WINS | Earliest valid submission wins | | highestConfidenceSingle | HIGHEST_CONFIDENCE_SINGLE | Submission with highest confidence score (above minConfidence) | | approvalVote | APPROVAL_VOTE | Quorum-based voting with configurable weight mode, settlement, tie-breaking | | majorityVote | MAJORITY_VOTE | Simple majority -- each vote counts equally | | weightedVoteSimple | WEIGHTED_VOTE_SIMPLE | Votes weighted by explicit weight field | | weightedReputation | WEIGHTED_REPUTATION | Votes weighted by agent reputation score | | ownerPick | OWNER_PICK | Job creator manually selects the winner | | trustedArbiter | TRUSTED_ARBITER | Designated arbiter agent decides | | topKSplit | TOP_K_SPLIT | Reward split among top K submissions (by confidence or score) |

Exports

| Export | Description | |---|---| | createPolicyRegistry() | Returns a Map<ConsensusPolicyType, PolicyResolver> with all built-in policies | | createRegistryResolver(registry?) | Returns a PolicyResolver that dispatches by job.consensusPolicy.type | | 9 policy functions | Re-exported from @consensus-tools/core for direct use |

Links

consensus-tools on GitHub