Domain libraries · entity catalog

shared library

Authored subsystem deep-dive for shared, layered on the code-linked entity catalog — what each system is, why it exists, and how it fits.

authored deep-dive
57entities6layers49deep-dives

On this page

The libs/shared/ area: ~47 cross-cutting Nx libraries (mostly @oshun/*) that every domain and app composes — the platform's substrate of auth, data access, observability, messaging, security, AI plumbing, and content-integrity primitives.

What this area is#

libs/shared/ is the bottom of the Oshun dependency graph for behaviour (where libs/contracts/ is the bottom for types). Each subdirectory is its own Nx project with its own project.json, package.json, and src/ barrel; almost all publish under the @oshun/* scope (two — shared-documentation and shared-release-management — keep an internal shared-* Nx name). Their Nx tags classify them mostly as layer:infra (e.g. @oshun/ai, @oshun/cache, @oshun/infrastructure), a few as layer:contracts (@oshun/types, @oshun/errors), and a handful as layer:domain (@oshun/audit-platform).

The area is not one coherent package but a catalogue of independently-versioned utilities. Reading the barrels, they cluster into a few sub-systems:

  • Foundations@oshun/types (zero-dependency type spine), @oshun/errors, @oshun/config, @oshun/crypto.
  • Data & messaging@oshun/database, @oshun/cache, @oshun/queue, @oshun/storage, @oshun/event-bus, @oshun/websocket, @oshun/migration, @oshun/deletion-fanout.
  • Service plumbing@oshun/http-client, @oshun/service-discovery, @oshun/traefik-config, @oshun/health, @oshun/rate-limit, @oshun/inbound-integrations.
  • Observability@oshun/logging, @oshun/metrics, @oshun/tracing, shared-documentation.
  • Identity & security@oshun/auth, @oshun/auth-primitives, @oshun/identity, @oshun/security, @oshun/data-residency, @oshun/region-rules.
  • AI / GPU / ML@oshun/ai, @oshun/ai-advanced, @oshun/ml, @oshun/gpu-dispatcher, @oshun/runpod-client, @oshun/vision-llm, @oshun/ocr, @oshun/layout-analyzer.
  • Content integrity & governance@oshun/content-eval, @oshun/content-quality-judge, @oshun/content-release-gates, @oshun/content-security, @oshun/content-signing, @oshun/encoding, @oshun/audit-platform, @oshun/review-persistence, shared-release-management.
  • Misc / specialised@oshun/infrastructure (Yemaya-origin), @oshun/tara-live-class-booking (a single-domain booking model that landed in shared), @oshun/testing.

How it fits the wider system#

These libraries are consumed by every app (apps/oshun/bff, admin, the web shells) and by the capability domains (Yemaya, Lilith, Isis, Sophia, Hathor, Bellona, …). The dependency direction is strictly downward: shared libs may depend on @oshun/contracts, @oshun/types, and third-party packages, but never on a domain's business logic — so a domain can swap implementations without the substrate changing. Several libraries are deliberately I/O-light and inject their side-effecting collaborators (e.g. @oshun/data-residency takes an audit publisher; @oshun/event-bus and @oshun/websocket take a Redis client), which keeps them testable and lets the same code run in the BFF, a worker, or a domain service. Walk the "used by" edges on any node below to see exactly who depends on it.

A note on honesty for the content/AI clusters: many of these libs follow the repo's "fail-loud seam" pattern — real deterministic logic plus typed boundaries that refuse to fabricate when a model/provider/credential is absent (e.g. @oshun/content-eval's model-metric seams, @oshun/ocr's "tiers do NOT silently fail over"). Where that is the case the blurb says so.

Entity catalog (57)#

The 57 tracked Nx projects in shared, each a code-linked entity node — package, type, source path, declared targets, and its internal dependency graph (depends-on / used-by, resolved from the package manifests, §6/§8), read from the project graph. Grouped by architectural layer; walk the dependency links to travel the system. 49 of these carry an authored deep-dive (what / why / how it fits); the rest are generated scaffolds awaiting one.

contracts (1)#

lib

@oshun/types

#

Shared TypeScript types and interfaces for the Oshun platform

The foundational, zero-external-dependency type spine (layer:contracts, ~6.4K lines). Base types (Result, BaseEntity, branded IDs), user, api, config, events, contracts, a large legacy module, and a rich creative/ namespace (agent/world/asset/storyboard/collaboration/generation/ script/character/schedule). Everything else can depend on it.

buildtestlint
layer: contractsscope: sharedowner: @GreyChimp

data (1)#

domain (3)#

lib

@oshun/audit-platform

#

Canonical audit event ingestion, immutable storage, retrieval, and investigation queries for the Oshun platform.

The canonical platform-wide audit ingestion and immutable-storage domain (layer:domain, ~25K lines). Every event validates against CanonicalPlatformAuditEventSchema from @oshun/contracts (ADR-0023); the store is append-only (amend by re-ingesting with metadata.amends). Rich modules: hash-chain, member-timeline, provenance-badges, synthetic-media-labeling, training-data-source-evidence, mandatory-human-approval, retention, plus investigation/evidence export.

buildtestlinttypecheck
layer: domainscope: sharedowner: @GreyChimp
lib

@oshun/review-persistence

#

Canonical persistence for Oshun review packages, stages, decisions, delegations, and audit events.

Canonical persistence for review packages (V1-GRC-001, ~4.2K lines): maps the @oshun/contracts Zod schemas and the isis ReviewPackage Prisma model into a typed, validated API. Guarantees schema validation on every row, deep-cloned returns, slug/id uniqueness, updatedAt refresh, and ADR-0029 stage/decision/ delegation invariants. Includes a stage-graph-repository, decision-lifecycle, delegation-policy, an in-memory store, and __fixtures__.

buildtestlinttypecheck
layer: domainscope: sharedowner: @GreyChimp

foundation (2)#

lib

@oshun/content-security

#

Cross-domain content security, watermarking, provenance, and DRM foundations for OSHUN

Content-protection plans and manifests (~2.7K lines): forensic watermarking (invisible image/audio/video/document plans + robustness evaluation + source identification), a large provenance module, and a drm module. These produce typed plans/manifests and capability descriptors rather than embedding pixels in-process.

buildtestlint
layer: foundationscope: sharedowner: @GreyChimp
lib

@oshun/encoding

#

Video encoding quality metrics and delivery analysis foundations for OSHUN

Video-encoding quality plumbing (~3K lines): real PSNR/SSIM/multi-scale-SSIM calculators, a Netflix-VMAF ffmpeg plan builder + JSON report parser (NETFLIX_VMAF_MODEL_REGISTRY), codec-support, imf-delivery, shot-optimization, a video-encoder, and quality-dashboard manifests.

buildtestlint
layer: foundationscope: sharedowner: @GreyChimp

infra (49)#

lib

@oshun/ai

#

AI integration layer - LLM clients, model routing, and inference

The platform AI integration layer (~18K lines). Real provider clients in src/providers/ (anthropic, openai, google, xai, ollama), a local-inference stack (local/model-manager, inference-engine, quantization), an agent-loop (loop + tool-registry + structured-output + reflexion + budget), prompt management (prompts/versioning, optimization), plus cache and a quality/ML router. Heavily implemented, not a facade.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/ai-advanced

#

Advanced AI Integration - Modular adapters, benchmarking, on-device AI, and research tools

Advanced/experimental AI tooling layered above @oshun/ai: src/ ships an AdapterManager (modular LLM adapter registry), a BenchmarkManager with standard tasks, an automatic model-selector, an edge-manager (on-device inference orchestration), and a research-manager — a substantial ~3.8K-line package with branded IDs in types.ts.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/auth

#

Unified authentication and authorization service for Oshun platform

The unified authentication/authorization service (~3.1K lines): an AuthService (login/registration/token management), RBAC + permission checks, account lockout protection, and framework-agnostic middleware (requireRole, requirePermissions). Sits above @oshun/auth-primitives.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/bff-kit

#

Shared BFF substrate: tracing, tenant context, authz, idempotency, abuse protection, device integrity, residency enforcement

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/config

#

Configuration management for the Oshun platform

Configuration management: env reading/parsing (env.ts), Zod validation schemas.ts, typed loader (loadServiceConfig, loadDatabaseConfig), a large features.ts feature-flag surface, experiment-guardrails, and a legacy compatibility module. Note: the directory also contains checked-in .d.ts/dist artifacts alongside the .ts sources.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/content-eval

#

Real, type-specific content-generation eval metrics (Phase 0.2): image PSNR/SSIM, mesh manifoldness/watertightness/UV, text citation precision, audio LUFS conformance, plus fail-loud seams for model metrics (CLIP/aesthetic/VMAF/PESQ/STOI/NLI faithfulness) and a golden-set runner.

Real, type-specific content-generation eval metrics (Phase 0.2). Deterministic metrics computed from first principles and golden-tested: image PSNR/SSIM, video temporal consistency, mesh topology (manifold/watertight/poly/UV), text citation P/R/F1, audio LUFS. Perceptual/model metrics (CLIP, aesthetic, VMAF, PESQ, NLI) are honest fail-loud seams via MetricModelNotConfiguredError — never fabricated.

testlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/content-quality-judge

#

Calibrated LLM-judge taste signal for creative content: versioned per-content-type rubrics, position-bias-mitigated pairwise/pointwise judging, judge panels, slop penalty, and human-gold calibration. The Q1 keystone for AGENTIC_CONTENT_QUALITY.

The calibrated "taste signal" keystone (~6.6K lines, ~32 modules): versioned anchored rubrics, a judge engine + judge-panel, slop penalty + slop-maintenance, calibration, quality-gate, best-of-n/self-refine, reward-model, drift, arc-coherence/continuity, corpus-diversity, and a benchmark harness. (The barrel re-exports several modules — e.g. judge-engine, quality-gate — that sit alongside the ~23 files read here.)

testlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/content-release-gates

#

Unified content release gates: one gate schema for validator/eval/manifest/human checks, eval-gated promotion, and champion-challenger ramping with statistical readiness

One unifying gate schema for the five disconnected quality systems the agentic-content audit found (Yemaya validators, Isis gates, V3/V6/V7 gates). A ReleaseGateService turns each check into a GateDefinition; content promotes only when every required gate passed plus (when demanded) a named human signoff. champion-challenger.ts ramps a new generator config only on a one-sided two-proportion z-test.

testlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/content-signing

#

One real Ed25519 + SHA-256 content signer (C2PA-aligned) shared by the isis 3D-asset provenance pipeline and the V3 concert-track signing path

A single ~148-line Ed25519 + SHA-256 content signer (ledger §D.1) that de-duplicates the isis C2PA provenance signer and the V3 concert-track signer. Real node:crypto Ed25519 over canonical bytes + SHA-256 binding; exposes both an async byte-oriented ClaimSigner/ClaimVerifier and sync ed25519SignBase64/ed25519VerifyBase64 helpers. Small but real, not a stub.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
util

@oshun/crypto

#

OshunCryptoSuite — unified crypto primitives backed by audited libraries (noble, bitcoinjs-lib, ethers, viem)

The unified crypto facade (~5K lines) — the only entrypoint internal code should use. src/index.ts wraps audited noble primitives (@noble/hashes/curves/ ciphers): keccak256/sha256/sha512/blake3, secp256k1, ed25519, AES-GCM, KDFs, ECDH (zero in-house crypto). Plus pluggable secrets/ managers (local/AWS/GCP/ Azure) and keystore/ backends (local/AWS-KMS/GCP-KMS/Azure-KV).

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/data-residency

#

V1-PRIV-018 region-aware data-residency enforcement service. Consumes the canonical residency rules and deployment policy from @oshun/contracts and produces enforced cross-zone transfer outcomes plus canonical audit events.

V1-PRIV-018 region/residency enforcement (~670 lines). The enforcer reads rule tables from @oshun/contracts and emits canonical audit events via an injected publisher — intentionally I/O-light; it only decides whether a proposed transfer is allowed. Also dsr-routing, traffic-shaping, and home-zone. Consumed by the BFF, admin, and @oshun/audit-platform.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/deletion-fanout

#

Shared account-deletion fan-out core (scope:shared): signed Ed25519 attestations, the per-service eraser port, event-driven domain consumers + the orchestrator — so any domain can run its own deletion consumer against the shared event bus.

The shared account-deletion fan-out core (scope:shared so any domain can run its own deletion consumer). Holds the per-service eraser port, signed Ed25519 attestation primitives, an event-driven orchestrator + transport port, a Redis bus transport, domain consumer registration, an env-resolved signer, and a runner composition root. These fan-out primitives moved out of @oshun/privacy; consumers import them from @oshun/deletion-fanout directly.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/errors

#

Standardized error handling for the Oshun platform

Standardized error handling (layer:contracts+layer:infra): base error classes with HTTP status codes (base.ts, http.ts), domain-specific errors (domain.ts), a codes.ts registry, and utilities (wrapError, etc.) with optional Sentry integration. Foundational and widely imported.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/gpu-dispatcher

#

GPU job dispatcher for RunPod Serverless with queuing, status tracking, and result handling

GPU job dispatcher for RunPod Serverless (~7K lines): a dispatcher with queuing and endpoint routing by job type, plus production-grade retry, timeout, fallback, circuit-breaker, cost-tracker, metrics, tracing, validation, and a job-store. Composes @oshun/runpod-client.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/identity

#

Shared identity and authentication library for Oshun platform

Shared identity library used by every capability domain (validate tokens, read canonical claims, enforce role/permission decisions; issuance stays with the auth service). Ships JwtService, authenticate/authenticateService middleware, mtls, node-http helpers, and V2 modules (v2-account-binding, v2-entitlement-claims). Documented in README.md against ADR-0003/0004.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/inbound-integrations

#

Inbound connector framework for tenant integrations

Large external-integration surface (~13K lines): LMS/LTI (lms, lti-verification), SCORM RTE (scorm-rte, scorm-2004-rte), oneroster, calendar (+ Google transport), payment, notification, byom/byom-model (bring-your-own-model), identity, health, and telemetry. Each is a sizable real module.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/infrastructure

#

Technical infrastructure - performance, security, monitoring, and observability

A Yemaya-origin infrastructure pack now under shared (~5.9K lines; its barrel docblock still reads @yemaya/infrastructure). Ships a performance-manager, security-manager, monitoring-manager, and calliope/calliope-operations (Calliope is a Yemaya sub-domain) over branded IDs in types.ts. Real and large, but domain-flavoured rather than fully platform-neutral.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/layout-analyzer

#

Canonical document-layout analyser (V1-P2-0064/0066). OshunLayoutAnalyzer decomposes a rendered page into the PubLayNet region taxonomy (DOCUMENT_REGION_CLASSES) via the canonical vision-LLM client; map.ts computes mAP@0.5 as the verification metric. ~985 lines.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/migration

#

Cross-domain data migration utilities for Oshun platform

Cross-domain data-migration utilities (~4.9K lines): a MigrationRunner + MigrationRegistry, checkpoint/id-mapping stores (file + memory), integrity/cross-domain-reference checks, and concrete scripts/ for real cutovers (yemaya-engine→bellona, yemaya-generation→isis, lilith-ingestion/rag→ sophia, lilith-sophia-cutover) plus the OSHUN-V1 shared-object plan generator.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
util

@oshun/ml

#

OshunMLRuntime — unified ONNX Runtime loader (browser + Node) for the Oshun ML stack

A compact (~890-line) ONNX inference runtime: loadModel/tensor over onnxruntime-node and onnxruntime-web adapters (plus a mock adapter for tests), SHA-256 model-integrity verification (expectedSha256), a provider preference list (webgpu/webnn/wasm), a model registry/loader, and a benchmark. Small but real, with an honest mock adapter at the dependency boundary.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/ocr

#

Canonical OCR client facade (V1-P2-0060, ~516 lines): OshunOCRClient over three tiers — tier1_tesseract (Tesseract.js WASM, default, real TesseractOCRBackend), tier2_vision_llm, and tier3_cloud_ocr (Google Document AI / Azure) — which explicitly do NOT silently fail over.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/prompt-trust

#

Typed trust-zone prompt rendering, delimiter hardening, and privacy-governed prompt provenance

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/rate-limit

#

Rate limiting and throttling service with Redis support

Rate limiting / throttling (~5.2K lines): sliding-window, fixed-window, token-bucket, adaptive, graceful, and throttle limiters; quota, abuse-controls, exemptions, bypass middleware, Hono middleware, and a monitoring/alerts surface. Redis-backed for distributed limiting.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/region-rules

#

Shared regional content-rule engine for V2 SKU cooks and future Oshun products.

A thin facade: src/index.ts is a one-line re-export of v2-regional-content-rules.ts (~405 lines), which holds the V2 regional content-rule tables. Effectively one real module behind a barrel.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/runpod-client

#

Type-safe client for RunPod Serverless API with status polling, error handling, and retry logic

Type-safe RunPod Serverless API client (~1.7K lines): a client with runAndWait, status polling, typed errors, and retry logic. The lower-level transport that @oshun/gpu-dispatcher composes.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/service-discovery

#

Service discovery for distributed microservices architecture

Redis-backed service discovery (~1.5K lines): createServiceDiscovery with register/lookup, a ServiceNames catalogue, pluggable backends, a hash-ring for consistent hashing, and a health-probe.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/testing

#

Comprehensive test-utility library (~4K lines): mock factories (createMockLogger/HttpClient/RedisClient/DatabaseClient/EventEmitter), fixture generators (createUser/createContent + a factory builder), assertion/ async helpers, Testcontainers wrappers (PostgresTestContainer/ RedisTestContainer), Vitest config builders, Playwright axe accessibility helpers, contract-testing (openapi-contract), and a fuzz/malicious-input corpora suite (§28.16). Mocks live at dependency boundaries by design.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/traefik-config

#

Unified API Gateway configuration for Oshun platform

Unified API-gateway configuration generator (~2K lines): typed builders (ServiceBuilder, RouteBuilder, GatewayConfigBuilder, plus service/route/ gateway helpers), a traefik.ts config emitter, per-domains configuration, and a small cli.ts. Generates gateway config; it is not itself the running proxy.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/vision-llm

#

Canonical vision wrapper (V1-P2-0064, ~1.7K lines): OshunVisionLLMClient is a convenience layer over the isis LLM client for vision-locate tasks — it owns prompt-shape, image normalisation, structured-output parsing, and the VisionLocateResult envelope, while provider routing/retries/cost/quotas stay in the gateway.

buildtestlint
layer: infrascope: sharedowner: @GreyChimp
lib

@oshun/websocket

#

WebSocket server for real-time features with Redis pub/sub scaling

Real-time WebSocket server (~5.4K lines): a server with channel-based subscribe/unsubscribe, a Redis redis-adapter for cross-server broadcasting, presence/state, rooms, JWT auth, per-connection ratelimit/limits, a delivery queue, and metrics.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

oshun-feature-store

@oshun/feature-store#

ML feature-store layer (libs/shared/feature-store/src): a FeatureCatalog + FeatureComputationEngine (windowed aggregations like averageOverWindow) over two online-store backends — RedisOnlineFeatureStore and a Feast-compatible pair (FeastFeatureServerClient, FeastOnlineFeatureStoreAdapter) — plus an offline store for point-in-time training reads.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

oshun-streaming

@oshun/streaming#

Kafka streaming backbone (libs/shared/streaming/src): BackpressuredTypedKafkaPublisher and ExactlyOnceKafkaConsumer over a ConfluentSchemaRegistry/SchemaRegistrySerde pair, with TemporalAlignmentBuffer and CrossDomainSignalJoinEngine for cross-domain signal joins, latency-tier budgets, and TrainingDataPipelineMetrics observability for the flywheel pipelines that ride on it.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

shared-documentation

@oshun/documentation#

Documentation infrastructure - architecture docs, API references, guides, tutorials, training materials, and certification system

A single architecture-documentation module (src/architecture/architecture.ts, ~454 lines): typed taxonomies for component diagrams and dependency graphs — ArchComponentType, DiagramFormat (mermaid/plantuml/d2/dot/ascii), ConnectionType. Narrow in scope (one file + its spec); models architecture documents, it does not render the docs site.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp
lib

shared-release-management

@oshun/release-management#

Release management - branching strategies, version numbering, release automation, beta programs, distribution channels, and platform-specific releases

Surface-scoped release safety (V1 §28.8, ~824 lines): RollbackPlan/RollbackStep schemas, a rehearsal engine, and canonical-plans for the six V1 surfaces (shell, admin, grounding, assistant, persona, generation). Internal Nx name is shared-release-management.

buildtestlinttypecheck
layer: infrascope: sharedowner: @GreyChimp

security (1)#

lib

@oshun/security

#

Security utilities including audit logging, content scanning, and secret management

Security utilities (~4.6K lines): a database-backed audit-logger (with actor helpers and batching), a content/file scanner, a secret-manager with rotation, and ip-minimization. Distinct from @oshun/audit-platform (which is the canonical compliance audit domain); this is the per-service security toolkit.

buildtestlint
layer: securityscope: sharedowner: @GreyChimp