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

@protocol-embedded-compliance/policy-cards

v0.1.0

Published

Policy Cards implementation for Protocol-Embedded Compliance - machine-readable runtime governance for AI agents

Readme

@protocol-embedded-compliance/policy-cards

Machine-readable runtime governance for AI agents, complementing Protocol-Embedded Compliance (PEC).

Based on the Policy Cards framework by Juraj Mavračić.

Overview

Policy Cards provide a deployment-layer specification for expressing operational, regulatory, and ethical constraints for AI agents. They complement PEC's protocol-layer compliance metadata by defining:

  • Rules: Allow/deny conditions referencing PEC metadata fields
  • Escalation: Human oversight triggers and fallback actions
  • Monitoring: Detectors and thresholds for runtime behavior
  • KPIs: Measurable assurance metrics and critical auto-fail conditions
  • Assurance Mapping: Crosswalk to NIST AI RMF, ISO/IEC 42001, and EU AI Act

Installation

pnpm add @protocol-embedded-compliance/policy-cards

Usage

Loading a Policy Card

import { loadPolicyCard } from '@protocol-embedded-compliance/policy-cards'

// From YAML file
const result = loadPolicyCard('./policy-cards/retail-banking.yaml')

// From string
const yamlContent = `
policy_card_version: "0.1"
name: "EU General Deployment"
scope:
  geography: ["EU", "EEA"]
rules:
  - id: geo-restriction
    effect: deny
    condition:
      field: pec.processing_locations
      operator: not_any_of
      values: ["EU", "EEA", "ADEQUACY"]
    reason: "Tool processes data outside approved jurisdictions"
`
const result = loadPolicyCard(yamlContent)

if (result.success) {
  console.log('Loaded:', result.policyCard.name)
}

Evaluating PEC Metadata Against a Policy Card

import { evaluatePolicyCard, loadPolicyCard } from '@protocol-embedded-compliance/policy-cards'
import type { PecComplianceMetadata } from '@protocol-embedded-compliance/mastra'

const { policyCard } = loadPolicyCard('./policy-cards/retail-banking.yaml')

const pecMetadata: PecComplianceMetadata = {
  pec_version: '1.0',
  processing_locations: ['DE', 'IE'],
  ai_act_status: {
    classification: 'limited',
    conformity_assessed: true
  },
  // ... other fields
}

const result = evaluatePolicyCard(policyCard!, pecMetadata, 'my-tool')

console.log('Compliant:', result.compliant)
console.log('Violations:', result.violations)
console.log('Assurance coverage:', result.assurance_coverage)

Filtering Tools by Policy Card

import { filterCompliantByPolicyCard, loadPolicyCard } from '@protocol-embedded-compliance/policy-cards'

const { policyCard } = loadPolicyCard('./policy-cards/retail-banking.yaml')

const tools = [
  { name: 'tool-a', compliance: pecMetadataA, tool: toolA },
  { name: 'tool-b', compliance: pecMetadataB, tool: toolB },
]

const { compliant, rejected } = filterCompliantByPolicyCard(policyCard!, tools)

console.log('Compliant tools:', compliant.map(t => t.name))
console.log('Rejected tools:', rejected.map(r => `${r.tool.name}: ${r.evaluation.violations[0]?.reason}`))

Auditing with Declare-Do-Audit Workflow

import { PolicyCardAuditor, loadPolicyCard } from '@protocol-embedded-compliance/policy-cards'

// DECLARE: Load and bind policy card
const { policyCard } = loadPolicyCard('./policy-cards/retail-banking.yaml')
const auditor = new PolicyCardAuditor(policyCard!)

// DO: Evaluate and record tool invocations
for (const tool of tools) {
  const { evaluation, evidence } = auditor.evaluateAndRecord(tool.name, tool.compliance)
  
  if (evaluation.compliant) {
    // Proceed with tool invocation
  } else {
    // Block or escalate
  }
}

// AUDIT: Generate report
const report = auditor.generateReport()
console.log(JSON.stringify(report, null, 2))

Policy Card Schema

See schemas/policy-card-schema-v0.1.json for the full JSON Schema.

Example Policy Card (YAML)

policy_card_version: "0.1"
name: "Retail Banking Payments Agent"
description: "Policy card for payment processing AI agent"

scope:
  ai_act_risk_level: high
  intended_uses:
    - payment_initiation
    - balance_inquiry
  geography:
    - EU
    - EEA

rules:
  - id: geo-restriction
    effect: deny
    condition:
      field: pec.processing_locations
      operator: not_any_of
      values: ["EU", "EEA", "ADEQUACY"]
    reason: "Tool processes data outside approved jurisdictions"
    
  - id: risk-ceiling
    effect: deny
    condition:
      field: pec.ai_act_status.classification
      operator: risk_exceeds
      threshold: limited
    reason: "Tool risk exceeds deployment threshold"

escalation:
  triggers:
    - condition: "transaction_value > 10000"
      action: human_approval_required

monitoring:
  detectors:
    - name: rejection_rate
      threshold: 0.3
      action: alert

kpis_thresholds:
  thresholds:
    - metric: compliance_rate
      target: 1.0
      critical_threshold: 0.95

assurance_mapping:
  nist: ["GOVERN-1", "MAP-1", "MEASURE-1"]
  iso_42001: ["ISO42001-4", "ISO42001-8"]
  eu_ai_act: ["EUAA-AnnexIV-3", "EUAA-Art72"]

Relationship to PEC

| Layer | Framework | Function | |-------|-----------|----------| | Protocol | PEC | MCP servers declare compliance metadata | | Deployment | Policy Cards | Defines what agents CAN/CANNOT do |

PEC provides standardised compliance information; Policy Cards provide constraint logic that consumes that information.

References

License

MIT