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

@evidifyresearch/event-schema

v0.1.0

Published

Open event schema for clinical AI decision provenance. Define, validate, and serialize human-AI interaction events for tamper-evident verification.

Downloads

84

Readme

@evidify/event-schema

Open event schema for clinical AI decision provenance.

Define, validate, and serialize human-AI interaction events for tamper-evident verification. Domain-agnostic. PHI-free by design. Zero dependencies.


The Problem

When a clinician interacts with an AI recommendation — accepts it, modifies it, overrides it — that decision sequence either isn't recorded at all, or it's recorded in a way that can't be independently verified later.

Every clinical AI system will eventually need to answer: "What did the AI suggest, and what did the clinician do with it?"

This package defines the event schema for capturing that interaction with integrity.

Design Principles

  1. PHI-free by structure — Events contain codes and hashes, never clinical text
  2. Append-only — Events are immutable once emitted
  3. Domain-agnostic — Same schema for radiology, cardiology, rehabilitation, pathology
  4. Verification-ready — Events are designed to be chained, hashed, and verified
  5. Standards-aligned — Maps to FHIR AuditEvent, CDS Hooks, EU AI Act Article 12

Install

npm install @evidify/event-schema

Quick Start

import { SessionBuilder, ClinicalEventEmitter } from '@evidify/event-schema';

// Define actors
const clinician = { role: 'clinician', sessionToken: 'dr-001' };
const aiSystem = { role: 'ai_system', sessionToken: 'model-001' };

// Create a session
const session = new SessionBuilder({
  domain: 'ct-cardiac',
  studyId: 'CARDIAC-STUDY-1',
  platform: { name: 'MyApp', version: '1.0.0' },
  enableChaining: true,
});

// Record the clinical encounter
session.start(clinician);
session.setCase('case-001');

// Clinician locks their independent assessment BEFORE seeing AI
session.emit('ASSESSMENT_LOCKED', clinician, {
  contentHash: 'sha256-of-assessment...',
  category: 'present',
  codeSystem: 'custom',
});

// AI recommendation revealed
session.emit('AI_RECOMMENDATION_REVEALED', aiSystem, {
  modelId: 'cleerly-v2.0',
  contentHash: 'sha256-of-ai-output...',
  outputType: 'recommendation',
  aiConfidence: 0.91,
  urgency: 'URGENT',
});

// Clinician responds to AI
session.emit('AI_OUTPUT_MODIFIED', clinician, {
  aiEventRef: 'event-id-of-ai-reveal',
  action: 'modified',
  resultContentHash: 'sha256-of-modified-assessment...',
  deliberationTimeMs: 4200,
  confidenceShift: -12,
});

// Session complete
session.end();

// Export verified envelope
const envelope = session.toEnvelope();
console.log(`Events: ${envelope.eventCount}`);
console.log(`Chain: ${envelope.chainIntegrity}`);
console.log(`Root hash: ${envelope.rootHash}`);

Real-Time Emitter

For live clinical encounters, use the ClinicalEventEmitter with automatic buffering and flush:

import { ClinicalEventEmitter } from '@evidify/event-schema';

const emitter = new ClinicalEventEmitter({
  domain: 'rehab-neuromod',
  platform: { name: 'PMP', version: '2.0' },
  flushIntervalMs: 5000,
  onFlush: async (events) => {
    // Persist to local SQLite, send to Evidify, etc.
    await db.insertBatch(events);
  },
  onEvent: (event) => {
    // Real-time subscriber (e.g., update UI, analytics)
    console.log(`[${event.type}] ${event.timestamp}`);
  },
});

emitter.startSession(clinician);

// Track ephemeral AI suggestions (shown but not saved)
emitter.ephemeralShown(aiSystem, 'sidebar_panel', 'diff-hash');
emitter.ephemeralDismissed(aiSystem, 'sidebar_panel', 'diff-hash', 3200);

// Track AI draft editing
emitter.emit('AI_DRAFT_EDITED', clinician, {
  originalHash: 'ai-draft-hash',
  modifiedHash: 'human-edited-hash',
  diffFormat: 'json-patch',
  diff: [{ op: 'replace', path: '/assessment', value: 'changed' }],
  attribution: {
    aiOriginatedPercent: 60,
    humanOriginatedPercent: 10,
    humanEditedPercent: 30,
  },
});

const envelope = emitter.endSession();
emitter.destroy();

Event Taxonomy

Categories

| Category | Description | Example Events | |----------|-------------|----------------| | session | Session lifecycle | SESSION_STARTED, SESSION_ENDED, CASE_STARTED | | assessment | Clinician assessments | ASSESSMENT_LOCKED, CONFIDENCE_RECORDED | | ai_output | AI recommendations | AI_RECOMMENDATION_REVEALED, AI_DRAFT_GENERATED | | ai_interaction | Clinician responses to AI | AI_OUTPUT_ACCEPTED, AI_OUTPUT_REJECTED | | comprehension | Error rate disclosure | ERROR_RATE_DISCLOSED, COMPREHENSION_GATE_PASSED | | documentation | Override documentation | OVERRIDE_DOCUMENTED, RATIONALE_RECORDED | | ephemeral | Shown-but-not-saved AI | EPHEMERAL_SUGGESTION_SHOWN, EPHEMERAL_PANEL_DISMISSED | | viewer | Image/document interactions | VIEWER_INTERACTION, VIEWER_MEASUREMENT_TAKEN | | quality | Automated quality flags | QUALITY_FLAG_RAISED, GAMING_PATTERN_DETECTED | | system | Platform events | SYSTEM_ATTESTATION, SYSTEM_EXPORT_GENERATED |

Key Event Sequence

The core provenance pattern captured by this schema:

ASSESSMENT_LOCKED          ← Clinician commits independent judgment
  ↓
AI_RECOMMENDATION_REVEALED ← AI output shown AFTER commitment
  ↓
AI_OUTPUT_ACCEPTED         ← Clinician accepts, modifies, or rejects
  | AI_OUTPUT_MODIFIED
  | AI_OUTPUT_REJECTED
  ↓
OVERRIDE_DOCUMENTED        ← Structured reasoning if changed
  ↓
CONFIDENCE_RECORDED        ← Post-AI confidence level

Validation

import { validateEvent, validateSession, detectPotentialPHI } from '@evidify/event-schema';

// Validate a single event
const result = validateEvent(event);
if (!result.valid) {
  console.error(result.errors);
}

// Validate a session envelope
const sessionResult = validateSession(envelope);

// Check for accidental PHI leakage
const phiCheck = detectPotentialPHI(event);
if (!phiCheck.valid) {
  console.warn('Potential PHI detected:', phiCheck.errors);
}

Chain Verification

import { verifySessionChain } from '@evidify/event-schema';

const result = verifySessionChain(envelope);
console.log(result.valid);   // true/false
console.log(result.details);  // "Chain verified: 15 events, root hash abc123..."

Supported Domains

The schema is domain-agnostic. It works for any clinical AI interaction:

| Domain | Example Use | Status | |--------|------------|--------| | Radiology (CT/MRI) | AI-assisted hemorrhage detection | Production | | Cardiac Imaging | Coronary stenosis AI evaluation | Production | | Mammography | AI-assisted breast screening | Production | | Rehabilitation | AI copilot treatment planning | Designed | | Ambient AI Scribes | Document attribution tracking | Designed | | Pathology | AI-assisted slide analysis | Planned | | Ophthalmology | Diabetic retinopathy AI | Planned |

Regulatory Alignment

| Regulation | How This Schema Helps | |-----------|----------------------| | EU AI Act Article 12 | Automatic event logging for high-risk AI (mandatory Aug 2026) | | HIPAA §164.312(b) | Audit controls for ePHI access | | 21 CFR Part 11 | Electronic records with tamper-evident audit trails | | ONC HTI-1 | Source attributes for predictive decision support | | FSMB Guidance | Document rationale for accepting/rejecting AI |

License

MIT — free for research and commercial use.

Citation

If you use this schema in research, please cite:

Henderson, J.M. (2026). @evidify/event-schema: An open event schema for
clinical AI decision provenance. Evidify LLC. https://github.com/evidifyai-svg/event-schema

About

Created by Joshua M. Henderson, Ph.D. | Evidify LLC

The flight recorder for AI-assisted clinical decisions.