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

governance-sdk-platform

v0.1.3

Published

Platform storage layer for governance-sdk — auto-migrating schema, typed queries for org settings and policy tiers

Downloads

802

Readme

governance-sdk-platform

PostgreSQL storage layer for governance-sdk -- auto-migrating schema, typed queries for org settings and policy tiers.

License: MIT

What it does

Provides persistent storage for governance state that the core SDK evaluates in-memory:

  • Auto-migrating schema -- tables created and upgraded automatically on first connection
  • Org settings -- plan, preferences, kill switch state, scoring/detection config
  • Policy tiers -- org-default rules, level-scoped rules, and agent-specific overrides
  • Saved policies -- versioned policy definitions with level and agent assignments
  • Typed throughout -- full TypeScript types for all stored structures

Install

npm install governance-sdk-platform

Requires a PostgreSQL client as a peer dependency (pg >= 8.0.0).

Quick Start

import { createPlatformStorage } from 'governance-sdk-platform';
import pg from 'pg';

const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });

// Create storage -- auto-migrates schema on first call
const platform = await createPlatformStorage({ pool });
console.log(`Applied ${platform.migrationsApplied} migrations`);

// Load org settings (returns defaults if no row exists)
const settings = await platform.loadOrgSettings('org_123');
// => { clerkOrgId, plan, settings: { autoRegisterAgents, killSwitch, ... }, ... }

// Save org preferences
await platform.saveOrgSettings('org_123', {
  settings: {
    killSwitch: { reason: 'Security incident', killedAt: new Date().toISOString(), scope: 'fleet' },
  },
});

// Load policy tiers for enforcement
const tiers = await platform.loadPolicyTiers('org_123');
// => { plan, policyRules, levelPolicies, agentOverrides, settings }

// List all saved policies
const policies = await platform.listSavedPolicies('org_123');

API

createPlatformStorage(config)

Creates a platform storage instance. Auto-migrates the schema on first call (idempotent).

interface PlatformStorageConfig {
  pool: PgPoolLike;       // Any pg.Pool-compatible client
  autoMigrate?: boolean;  // Default: true
}

Returns a PlatformStorage object with:

| Method | Description | |--------|-------------| | loadOrgSettings(orgId) | Load org settings (returns defaults if no row) | | saveOrgSettings(orgId, update) | Upsert org preferences | | loadPolicyTiers(orgId) | Load resolved policy tiers for enforcement | | listSavedPolicies(orgId) | List all saved policies for an org | | migrationsApplied | Number of migrations applied on init |

runMigrations(pool)

Run migrations manually (useful if autoMigrate: false).

import { runMigrations } from 'governance-sdk-platform';

const applied = await runMigrations(pool);

Schema

The migrator creates and maintains these tables:

| Table | Purpose | |-------|---------| | org_settings | Per-org plan, preferences, scoring/detection config | | saved_policies | Versioned policy definitions with rules, level/agent assignments | | _platform_migrations | Migration tracking (internal) |

Works with any pg-compatible client

PgPoolLike accepts anything with a .query() method -- pg.Pool, @neondatabase/serverless, connection poolers, etc.

import { Pool } from '@neondatabase/serverless';

const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const platform = await createPlatformStorage({ pool });

Part of the Governance SDK

| Package | Purpose | |---------|---------| | governance-sdk | Core SDK -- policy engine, scoring, injection detection, 20 framework adapters | | governance-sdk-platform | This package -- PostgreSQL storage layer |

License

MIT