Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions enterprise-webhook-replay-ledger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Enterprise Webhook Replay Ledger

This module adds a focused enterprise integration slice for SCIBASE Enterprise
Tooling. It models signed webhook envelopes, institutional destinations, retry
windows, dead-letter queues, replay approvals, and delivery health metrics for
systems such as institutional repositories, learning management systems,
electronic lab notebooks, and funder reporting portals.

The goal is narrow: help institutional admins prove that project publication,
review, compliance, and export events were delivered or are safely queued for
reviewable replay.

## What It Covers

- Creates deterministic event envelopes with idempotency keys and audit digests.
- Applies destination-specific retry, signing, retention, and replay policies.
- Classifies deliveries into delivered, retryable, dead-letter, replay-approved,
or manual-review states.
- Builds replay plans for failed institutional integrations.
- Produces admin dashboard metrics for webhook health and export readiness.
- Includes synthetic enterprise data, tests, a CLI demo, a requirement map, and
a short demo video.

## Quick Start

```bash
npm run check
npm test
npm run demo
```

Expected demo summary:

```text
Enterprise delivery health: degraded
Dead-letter events: 2
Replay-ready events: 1
Manual review events: 1
```

## Repository Layout

```text
enterprise-webhook-replay-ledger/
data/sample-enterprise-events.json
docs/demo.svg
docs/demo.mp4
docs/requirement-map.md
scripts/demo.js
src/webhook-ledger.js
test/webhook-ledger.test.js
```

## Design Notes

This is not a broad enterprise dashboard or another export package generator.
It is the reliability layer that sits behind those tools:

1. SCIBASE emits a project, publication, review, compliance, or export event.
2. The ledger builds a signed, idempotent envelope for each configured
institutional destination.
3. Delivery attempts are evaluated against retry and replay policies.
4. Failed deliveries become dead-letter records with replay prerequisites.
5. Admin metrics expose whether enterprise integrations are healthy enough for
institutional reporting.

The functions are pure and dependency-free, so they can back a REST endpoint,
webhook worker, nightly integration report, or pull request verification step.
188 changes: 188 additions & 0 deletions enterprise-webhook-replay-ledger/data/sample-enterprise-events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{
"schemaVersion": "enterprise-webhook-ledger.v1",
"organization": {
"id": "northbridge-university",
"name": "Northbridge University Research Office",
"timezone": "UTC",
"dashboardWindowHours": 24
},
"destinations": [
{
"id": "dspace-archive",
"name": "DSpace institutional repository",
"type": "institutional_repository",
"endpoint": "https://repo.example.edu/webhooks/scibase",
"signingKeyId": "northbridge-dspace-2026-05",
"maxAttempts": 4,
"retryBackoffMinutes": [5, 30, 120],
"replayRequiresApproval": false,
"retentionDays": 30,
"acceptedEventTypes": ["project.published", "dataset.exported", "doi.registered"]
},
{
"id": "canvas-lms",
"name": "Canvas LMS research course sync",
"type": "learning_management_system",
"endpoint": "https://canvas.example.edu/scibase/events",
"signingKeyId": "northbridge-canvas-2026-05",
"maxAttempts": 3,
"retryBackoffMinutes": [10, 60],
"replayRequiresApproval": true,
"retentionDays": 14,
"acceptedEventTypes": ["project.created", "review.completed", "publication.submitted"]
},
{
"id": "labnote-eln",
"name": "LabNote ELN enrichment",
"type": "electronic_lab_notebook",
"endpoint": "https://eln.example.edu/integrations/scibase",
"signingKeyId": "northbridge-eln-2026-05",
"maxAttempts": 5,
"retryBackoffMinutes": [5, 20, 60, 240],
"replayRequiresApproval": false,
"retentionDays": 45,
"acceptedEventTypes": ["reproducibility.score.updated", "dataset.exported"]
},
{
"id": "grant-portal",
"name": "Funder mandate reporting portal",
"type": "funder_portal",
"endpoint": "https://funder.example.gov/reporting/scibase",
"signingKeyId": "northbridge-grant-2026-05",
"maxAttempts": 2,
"retryBackoffMinutes": [30],
"replayRequiresApproval": true,
"retentionDays": 60,
"acceptedEventTypes": ["compliance.mandate.failed", "compliance.mandate.passed"]
}
],
"events": [
{
"id": "evt-project-published-001",
"type": "project.published",
"occurredAt": "2026-05-15T08:05:00Z",
"projectId": "proj-neuro-organoid-atlas",
"actorId": "orcid:0000-0002-1825-0097",
"payload": {
"repositoryVersion": "preprint-v2.2",
"doi": "10.5555/scibase.neuro-organoid-atlas.v2",
"visibility": "public"
},
"deliveries": [
{
"destinationId": "dspace-archive",
"attempts": [
{
"attemptedAt": "2026-05-15T08:05:30Z",
"statusCode": 202,
"durationMs": 184,
"responseDigest": "sha256:dspace-accepted-001"
}
]
}
]
},
{
"id": "evt-review-completed-017",
"type": "review.completed",
"occurredAt": "2026-05-15T08:12:00Z",
"projectId": "proj-organic-sensor-array",
"actorId": "reviewer:pseudonym-r42",
"payload": {
"reviewTemplate": "engineering-design-check",
"decision": "changes_requested",
"visibility": "course-private"
},
"deliveries": [
{
"destinationId": "canvas-lms",
"attempts": [
{
"attemptedAt": "2026-05-15T08:12:30Z",
"statusCode": 503,
"durationMs": 408,
"responseDigest": "sha256:canvas-503-a"
},
{
"attemptedAt": "2026-05-15T08:22:40Z",
"statusCode": 503,
"durationMs": 390,
"responseDigest": "sha256:canvas-503-b"
},
{
"attemptedAt": "2026-05-15T09:23:20Z",
"statusCode": 503,
"durationMs": 412,
"responseDigest": "sha256:canvas-503-c"
}
],
"approvedForReplayBy": "enterprise-admin:northbridge-research-office",
"approvedForReplayAt": "2026-05-15T09:40:00Z"
}
]
},
{
"id": "evt-dataset-exported-022",
"type": "dataset.exported",
"occurredAt": "2026-05-15T09:00:00Z",
"projectId": "proj-neuro-organoid-atlas",
"actorId": "orcid:0000-0002-1825-0097",
"payload": {
"exportTarget": "Zenodo",
"datasetHash": "sha256:dataset-archive-v4",
"license": "CC-BY-4.0"
},
"deliveries": [
{
"destinationId": "labnote-eln",
"attempts": [
{
"attemptedAt": "2026-05-15T09:00:20Z",
"statusCode": 429,
"durationMs": 122,
"responseDigest": "sha256:eln-rate-limit"
},
{
"attemptedAt": "2026-05-15T09:05:50Z",
"statusCode": 200,
"durationMs": 240,
"responseDigest": "sha256:eln-delivered"
}
]
}
]
},
{
"id": "evt-compliance-failed-006",
"type": "compliance.mandate.failed",
"occurredAt": "2026-05-15T09:30:00Z",
"projectId": "proj-climate-sensor-network",
"actorId": "system:compliance-engine",
"payload": {
"funder": "Horizon EU",
"mandate": "open-data-within-30-days",
"missingEvidence": ["data-availability-statement", "repository-link"]
},
"deliveries": [
{
"destinationId": "grant-portal",
"attempts": [
{
"attemptedAt": "2026-05-15T09:30:20Z",
"statusCode": 401,
"durationMs": 155,
"responseDigest": "sha256:grant-auth-expired"
},
{
"attemptedAt": "2026-05-15T10:01:00Z",
"statusCode": 401,
"durationMs": 142,
"responseDigest": "sha256:grant-auth-expired-repeat"
}
]
}
]
}
],
"evaluationTime": "2026-05-15T10:10:00Z"
}
Binary file added enterprise-webhook-replay-ledger/docs/demo.mp4
Binary file not shown.
55 changes: 55 additions & 0 deletions enterprise-webhook-replay-ledger/docs/demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions enterprise-webhook-replay-ledger/docs/requirement-map.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Requirement Map

Issue: SCIBASE-AI/SCIBASE.AI#19, Enterprise Tooling.

## Admin Dashboards

The ledger emits delivery health, dead-letter counts, replay-ready counts,
manual-review counts, retry state, and per-destination delivery evidence. These
values can populate an institutional admin dashboard for integration and export
reliability.

## API & Webhooks

Each event is wrapped in a deterministic envelope with a destination id,
idempotency key, signing key id, body digest, and signature preview. The sample
destinations cover institutional repositories, learning management systems,
electronic lab notebooks, and funder portals.

## Webhook Reliability

Destination policies define accepted event types, retry windows, max attempts,
replay approval requirements, and retention. Failed attempts are classified into
retryable, dead-letter, replay-approved, or manual-review states.

## Export Pipelines

Dataset export, project publication, DOI registration, review completion, and
compliance mandate events can be delivered to downstream systems. Replay plans
preserve the same idempotency key so external systems do not duplicate exports.

## Compliance And Reporting

The funder portal sample demonstrates compliance mandate reporting with a
manual-review hold when replay needs enterprise approval. Audit digests make the
delivery state reproducible for research-office reporting.

## Scope Boundary

This is not another broad enterprise dashboard, export package generator,
trust-center module, or compliance evidence packet. It is a reliability and
replay layer for enterprise webhook delivery.
15 changes: 15 additions & 0 deletions enterprise-webhook-replay-ledger/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "enterprise-webhook-replay-ledger",
"version": "0.1.0",
"description": "Dependency-free delivery ledger for SCIBASE enterprise webhooks and export events.",
"private": true,
"scripts": {
"check": "node scripts/demo.js --json > /dev/null",
"demo": "node scripts/demo.js",
"test": "node --test test/*.test.js"
},
"engines": {
"node": ">=18"
},
"license": "MIT"
}
17 changes: 17 additions & 0 deletions enterprise-webhook-replay-ledger/scripts/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require("node:fs");
const path = require("node:path");
const { createWebhookLedger, formatLedgerReport } = require("../src/webhook-ledger");

const manifestPath = path.join(__dirname, "..", "data", "sample-enterprise-events.json");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
const ledger = createWebhookLedger(manifest);

if (process.argv.includes("--json")) {
process.stdout.write(`${JSON.stringify(ledger, null, 2)}\n`);
} else {
process.stdout.write(`${formatLedgerReport(ledger)}\n`);
}

if (ledger.health === "invalid-manifest") {
process.exitCode = 1;
}
Loading