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)#
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.
UserID27ProjectID27OrganizationID27TeamID27SessionID27AssetID27ContentID27AgentID27RequestID27CorrelationID27ISODateTime27ISODate27Failure27Result27 +128 moredata (1)#
Database utilities for PostgreSQL, Redis, and connection pooling
Unified DB utilities (~6.2K lines): postgres-client, redis-client, a
connection-pool (legacy-pool), transaction helpers, a query-builder,
migration + legacy-migrations, connection-string parsing, health, and
metrics. Checked-in .d.ts artifacts accompany the sources.
DatabaseError49DatabaseErrorCodes49DEFAULT_POSTGRES_CONFIG49DEFAULT_REDIS_CONFIG49DEFAULT_RETRY_CONFIG49DEFAULT_HEALTH_CHECK_CONFIG49PostgresClient62createPostgresClient62createPostgresClientFromEnv62createPostgresClientFromUrl62RedisClient73RedisClusterClient73createRedisClient73createRedisClientFromEnv73 +53 moredomain (3)#
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.
AuditEventNotFoundError24AuditImmutabilityViolationError24AuditPlatformError24CanonicalAuditValidationError24DuplicateAuditEventError24createInMemoryCanonicalAuditEventStore33InMemoryCanonicalAuditEventStore33AuditEventIngestService35createAuditEventIngestService35AuditEventIngestServiceOptions35OSHUN_AUDIT_PLATFORM_PACKAGE_NAME41V2_AUDIT_PLATFORM_ACTIONS41V2_AUDIT_PLATFORM_RETENTION_TAGS41V2_AUDIT_PUBLICATION_KINDS41 +642 moreCanonical 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__.
assembleReviewPackage24arseOrThrow24validateReviewPackage24deepClone26DuplicateReviewPackageError28InvalidReviewPackageError28ReviewPackageChildNotFoundError28ReviewPackageNotFoundError28ReviewPersistenceError28createInMemoryReviewPackageRepository38InMemoryReviewPackageRepository38InMemoryReviewPackageRepositoryOptions38PRIORITY_WEIGHTS53assembleStageGraph60 +48 moreTenant-safe live-media contracts, authorization, and deterministic stream lifecycle
foundation (2)#
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.
FORENSIC_WATERMARKING_CAPABILITIES1createDocumentWatermarkPlan1createForensicWatermarkingManifest1createInvisibleAudioWatermarkPlan1createInvisibleImageWatermarkPlan1createInvisibleVideoWatermarkPlan1createWatermarkRobustnessTestSuite1valuateWatermarkRobustness1identifyWatermarkSource1DocumentWatermarkPlan1DocumentWatermarkRequest1ForensicWatermarkingCapability1ForensicWatermarkingManifest1InvisibleAudioWatermarkPlan1 +97 moreVideo 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.
ENCODING_QUALITY_CAPABILITIES1ENCODING_QUALITY_DOMAINS1NETFLIX_VMAF_MODEL_REGISTRY1calculateMultiScaleSsim1calculatePsnr1calculateSsim1createEncodingQualityManifest1createNetflixVmafFfmpegPlan1createQualityComparisonDashboard1arseNetflixVmafJsonReport1EncodingComparisonAsset1EncodingQualityCapability1EncodingQualityDashboard1EncodingQualityDashboardPanel1 +163 moreinfra (49)#
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.
VERSION6AI_VERSION7LLMProvider13ModelId13MessageRole13ContentBlockType13TextContent13ImageContent13ToolUseContent13ToolResultContent13ContentBlock13ChatMessage13JsonSchema13ToolDefinition13 +251 moreAdvanced 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.
AdapterManager5InMemoryAdapterStorage5createBuiltInAdapters5AdapterStorageProvider5AdapterInterface5BenchmarkManager14InMemoryBenchmarkStorage14getStandardBenchmarkTasks14BenchmarkStorageProvider14DatasetEntry14ModelSelector23InMemoryModelProfileStorage23ModelProfileStorageProvider23EdgeManager30 +18 moreUnified 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.
hasMinimumRole105getRolesAtOrBelow105ROLE_PERMISSIONS105hasPermission105getPermissions105hasAllPermissions105hasAnyPermission105DEFAULT_RATE_LIMITS105DEFAULT_AUTH_SERVICE_CONFIG105AccountLockoutManager129createAccountLockoutManager129DistributedLockoutManager129createDistributedLockoutManager129ILockoutStore129 +59 moreAuthentication primitives and JWT utilities
Low-level auth building blocks (~4.6K lines): jwt, session, password
(hashing), totp, api-key, oauth-client/oauth-revoke, token-refresh,
token-audit, platform-roles, and tenant-isolation. These are the
composable primitives the higher-level @oshun/auth and @oshun/identity build
on.
DEFAULT_JWT_CONFIG41DEFAULT_SESSION_CONFIG41JwtService49createJwtService49createHmacJwtService49createRsaJwtService49generateJwtId49arseAuthorizationHeader49createAuthorizationHeader49SessionManager63InMemorySessionStore63createSessionManager63createInMemorySessionStore63generateSessionId63 +52 moreShared BFF substrate: tracing, tenant context, authz, idempotency, abuse protection, device integrity, residency enforcement
Caching library (~3.9K lines): redis-client, memory-cache, a with-cache
wrapper, distributed-lock, circuit-breaker, pubsub, invalidation, a
key-builder, and metrics. Real Redis and in-memory implementations behind a
common CacheClient type.
TTL53DOMAIN_TTL53PUBSUB_CHANNELS53refixedKey59hashKey59userKey59sessionKey59authKey59jwtKey59accessTokenKey59remiumKey59nftKey59contentKey59rateLimitKey59 +51 moreCollection utilities (chunk, deepClone, deepMerge)
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.
isProduction37isDevelopment37isTest37getEnvRequired37getEnvNumber37getEnvNumberRequired37getEnvBool37getEnvArray37getEnvJson37getEnvUrlRequired37logLevelSchema68logFormatSchema68ortSchema68hostSchema68 +76 moreReal, 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.
MetricModelNotConfiguredError16InvalidMetricInputError16computePsnr18meanSquaredError18RasterImage18computeSsim19oLuminance19analyzeMeshTopology21checkPolyBudget21computeUvCoverage21MeshGeometry21MeshTopologyReport21UvCoverageReport21mporalConsistency30 +19 moreCalibrated 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.)
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.
ReleaseGateService14ReleaseGateError14gateFromValidator14gateFromEvalScore14gateFromManifestCheck14gateFromProof14humanSignoffGate14formatValidityProof14observedOutcomeProof14consentProof14gateEvidenceRef14GateContext14GateDefinition14GateEvidence14 +18 moreOne 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.
ED25519_ALGORITHM24sha256Hex31generateEd25519SigningKeyPair41ed25519Sign53ed25519Verify59ed25519SignBase6477ed25519VerifyBase6482ClaimSigner94ClaimVerifier102Ed25519ClaimSigner112Ed25519ClaimVerifier134OshunCryptoSuite — 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).
sha25652sha51259keccak25668blake376Secp256k1Signature85secp256k1Sign98secp256k1Verify132secp256k1Recover147secp256k1RecoverAddress167secp256k1GetEthereumAddress189secp256k1GetPublicKey197ed25519Sign211ed25519Verify220ed25519GetPublicKey229 +16 moreV1-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.
DSR_RESIDENCY_REQUEST_KINDS18OSHUN_DATA_RESIDENCY_PACKAGE_NAME18OSHUN_DSR_QUEUE_PREFIX18createDsrResidencyRoutingDecision18DsrResidencyRequestKind18DsrResidencyRoutingDecision18DsrResidencyRoutingDecisionInput18ResidencyEnforcementError28ResidencyEnforcementService28createResidencyEnforcementService28ResidencyEnforcementContext28ResidencyEnforcementOutcome28ResidencyEnforcementRequest28ResidencyEnforcementServiceOptions28 +21 moreShared 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.
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.
VALIDATION_ERRORS35AUTH_ERRORS35AUTHZ_ERRORS35RESOURCE_ERRORS35EXTERNAL_ERRORS35BUSINESS_ERRORS35CONTENT_ERRORS35ErrorCode35HttpStatusCode35AppError59SerializedError59ErrorOptions59ErrorOptionsWithMetadata59ErrorOptionsWithoutStatus59 +34 moreCross-domain event bus for distributed event-driven architecture
Cross-domain event bus over Redis pub/sub (~4.1K lines): type-safe publish/
subscribe with wildcard patterns, retry with backoff, a dead-letter queue, event
persistence/replay, and correlation/causation tracking. A large
topic-registry.ts enumerates topics; outbound-delivery.ts and a
webhook-simulator handle external delivery.
EventBus38createEventBus38DEFAULT_EVENT_TOPIC_DEFINITIONS40DEFAULT_EVENT_TOPIC_REGISTRY40EventTopicRegistry40OshunV1EventTopics40createEventTopicRegistry40MemoryOutboundDeliveryStore48OutboundEventDispatcher48OutboundSigningKeyRing48calculateOutboundBackoffMs48createOutboundEventDispatcher48createOutboundSigningKeyRing48serializeOutboundEvent48 +7 moreTyped in-process event emitter and minimal console logger
LogLevel19Logger21createLogger31EventListener47Unsubscribe50EventEmitterOptions53TypedEventEmitter66createEventEmitter267GPU 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.
GpuDispatcher50createGpuDispatcher50InMemoryJobStore56createJobStore56DEFAULT_DISPATCHER_CONFIG96DispatcherError102JobNotFoundError102EndpointNotFoundError102DispatchFailedError102PollFailedError102StorageFailedError102WebhookFailedError102QueueFullError102BudgetExceededError102 +88 moreHealth-check utilities for microservices (~1.4K lines): a health-manager
registry, liveness/readiness probes, and dependencies checks, with typed
HealthStatus/HealthReport/ProbeType surfaces.
DEFAULT_HEALTH_TIMEOUT31DEFAULT_CACHE_DURATION31DEFAULT_FAILURE_THRESHOLD31DEFAULT_RECOVERY_THRESHOLD31DEFAULT_CHECK_INTERVAL31HealthManager45createHealthManager45healthy45degraded45unhealthy45ProbeManager51createProbeManager51createProbeHandlers51DependencyAggregator57 +6 moreHTTP client utilities with circuit breaker, retry, and tracing
Resilient HTTP client (~6K lines incl. .d.ts): http-client core plus
retry, timeout, circuit-breaker, interceptors, idempotency keys,
tenant-context propagation, distributed tracing, and an ssrf-guard.
Substantial, production-oriented outbound HTTP.
DEFAULT_RETRY_CONFIG39DEFAULT_CIRCUIT_BREAKER_CONFIG39DEFAULT_TIMEOUT_CONFIG39DEFAULT_CONNECTION_POOL_CONFIG39HttpClient50createHttpClient50createSimpleHttpClient50createResilientHttpClient50createHttpError50CircuitBreaker62CircuitBreakerRegistry62CircuitOpenError62createCircuitBreaker62createCircuitBreakerRegistry62 +77 moreShared 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.
JwtService14createJwtService14authenticate17createAuthChecker17authenticateService17xtractBearerToken17xtractApiKey17hasRole17hasPermissions17hasAnyPermission17getPermissionsForRole17arsePeerCertificate32verifyPeerIdentity32verifyForwardedClientCert32 +2 moreCanonical identifier generation (UUID, ULID, prefixed ids)
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.
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.
createPerformanceManager88AssetStorageProvider88LODProvider88MemoryMonitorProvider88TaskExecutorProvider88TaskStorageProvider88GPUComputeProvider88PerformanceManagerConfig88InMemoryTaskStorage88NodeMemoryMonitor88WorkerThreadTaskExecutor88SystemGPUProvider88MockLODProvider88MockMemoryMonitor88 +82 moreCanonical 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.
OshunLayoutAnalyzer11DOCUMENT_REGION_CLASSES14BoundingBox14DocumentRegion14DocumentRegionClass14LayoutAnalysisOptions14LayoutAnalysisResult14LayoutCoordinateSystem14LayoutImageInput14LayoutImageMimeType14LayoutQuality14computeMeanAveragePrecision27iou27MAPEvalOptions27 +4 moreStructured logging with Pino for the Oshun platform
Structured logging (~3K lines) on Pino: createLogger/log, multiple
transports (console, file, http, elasticsearch, tcp), sampling
strategies, a request-logger middleware (Express/Fastify/Koa), OpenTelemetry
hooks, and PII redaction.
OshunLogger93createLogger93getLogger93setLogger93initializeLogger93log93serializeError93LOG_LEVEL_NAMES107createEventEmitter163Scalar math primitives (clamp, lerp, remap, smoothstep)
clamp15clamp0128clampRound42clampFinite59lerp76lerpClamped83inverseLerp92remap103smoothstep119nearlyEqual130wrap140Metrics collection library for Oshun platform with Prometheus and OpenTelemetry support
Prometheus-compatible metrics (~1.7K lines): a registry, typed
Counter/Gauge/Histogram/Summary configs and interfaces, helpers, and a metrics
server.
DB_METRICS36CACHE_METRICS36AI_METRICS36QUEUE_METRICS36OshunMetricsRegistry53createRegistry53getRegistry53setRegistry53initializeRegistry53gauge53histogram53summary53OshunMetricsServer70createMetricsServer70 +9 moreCross-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.
MigrationRegistry12MigrationRunner12createMigrationRunner12FileCheckpointStore15FileIdMappingStore15MemoryCheckpointStore15MemoryIdMappingStore15OSHUN_V1_SHARED_OBJECT_FRAMEWORK_TASKS23OSHUN_V1_SHARED_OBJECT_GLOBAL_VERIFICATION_GATES23OSHUN_V1_SHARED_OBJECT_MIGRATION_STEPS23buildOshunV1SharedObjectMigrationPlan23createOshunV1SharedObjectMigrationRegistry23registerOshunV1SharedObjectMigrations23serializeOshunV1SharedObjectMigrationPlan23 +1 moreOshunMLRuntime — 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.
loadModel14fetchModelBytes14nsor14setAdapter14getAdapter14sha256Hex15benchmark29speedup29BenchmarkOptions29BenchmarkResult29Canonical 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.
OshunOCRClient11createOshunOCRClient11OshunOCRClientOptions11TesseractOCRBackend13TesseractBackendOptions13Typed trust-zone prompt rendering, delimiter hardening, and privacy-governed prompt provenance
BullMQ-based job queue (~4.5K lines): a queue + worker, priorities, retries,
a dead-letter-queue, a durable-queue, an sla-monitor, and a full
memory-queue implementation for testing behind the same types.
PRIORITY_VALUES46getPriorityValue46QUEUE_NAMES46DEFAULT_RETRY_CONFIG46DEFAULT_JOB_OPTIONS46DEFAULT_DLQ_CONFIG46DURABLE_JOB_CLASSES55DURABLE_JOB_CLASS_CONFIG55DurableQueueSubstrate55createDurableJobSubmitters55createDurableQueueSubstrate55deriveDurableJobId55DEFAULT_DURABLE_QUEUE_SLA_POLICIES79DurableQueueSlaMonitor79 +15 moreRate 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.
SlidingWindowRateLimiter43createSlidingWindowRateLimiter43FixedWindowRateLimiter43createFixedWindowRateLimiter43TokenBucketRateLimiter43createTokenBucketRateLimiter43TokenBucketConfig43RequestThrottler43createRequestThrottler43GracefulRateLimiter43createGracefulRateLimiter43InMemoryRateLimiter43createInMemoryRateLimiter43CircuitState43 +80 moreShared 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.
Retry, backoff, sleep, and circuit-breaker primitives
sleep13AbortError13backoffDelay14BackoffOptions14JitterMode14retry15withRetry15RetryExhaustedError15RetryOptions15CircuitBreaker16CircuitOpenError16CircuitBreakerOptions16CircuitBreakerStats16CircuitState16 +39 moreType-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.
RunPodClient39createRunPodClient39isRunningStatus84DEFAULT_POLLING_CONFIG84EndpointNotFoundError98JobNotFoundError98RateLimitError98ServerError98TimeoutError98NetworkError98ValidationError98JobFailedError98PollingTimeoutError98wrapError98 +12 moreService 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.
ServiceDiscovery36createServiceDiscovery36ServiceNames59RedisRegistryBackend62DnsRegistryBackend62ConsulRegistryBackend62robeInstance67HashRing71Object-storage utilities (~2.7K lines): an s3-client (S3/MinIO), a
local-client (filesystem), presigned-URL generation, file-manifest types,
and utils, behind a common StorageProvider/StorageConfig surface.
DEFAULT_SIGNED_URL_EXPIRATION40DEFAULT_PART_SIZE40MIN_PART_SIZE40MAX_PART_SIZE40MAX_PARTS40S3StorageClient52createS3Client52createMinioClient52LocalStorageClient58createLocalStorageClient58sanitizeFilename66getFilenameFromKey66getDirectoryFromKey66joinKey66 +20 moreComprehensive 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.
createMockLogger50createMockHttpClient50createMockRedisClient50createMockDatabaseClient50createMockEventEmitter50createMockTimers50MockTimers50randomEmail64randomInt64randomPick64randomUUID64randomDate64randomBoolean64createUsers64 +51 moreDistributed tracing library for Oshun platform with OpenTelemetry and AWS X-Ray integration
OpenTelemetry distributed tracing (~3.8K lines): a tracer, context
propagation, AWS xray exporter, span decorators, and middleware (generic +
hono), over branded TraceId/SpanId/CorrelationId types.
SpanStatus58SpanKind58SamplingResult58TRACE_CONTEXT_HEADERS58OshunTracer64LightweightTracer64createTracer64createLightweightTracer64getTracer64setTracer64initializeTracer64createTracerConfigFromEnv64createTracerFromEnv64OtlpConfigurationError64 +63 moreUnified 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.
createDefaultGatewayConfig12ServiceBuilder12RouteBuilder12GatewayConfigBuilder12service12route12gateway12YEMAYA_SERVICES23YEMAYA_ROUTES23ISIS_SERVICES23ISIS_ROUTES23SOPHIA_SERVICES23SOPHIA_ROUTES23HATHOR_SERVICES23 +12 moreCanonical 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.
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.
YemayaWSServer71createWSServer71RoomManager74createRoomManager74COMMON_CHANNEL_CONFIGS74ChannelType74ChannelConfig74RoomConfig74PresenceMember74SubscribeResult74RoomStats74MessageQueue87createMessageQueue87QueuedMessage87 +68 moreML 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.
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.
security (1)#
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.
DEFAULT_EVENT_SEVERITY139DEFAULT_SCAN_OPTIONS139DEFAULT_SECRET_MANAGER_CONFIG139DatabaseAuditStore149createMemoryAuditStore149createDatabaseAuditStore149createAuditLogger149userActor149serviceActor149systemActor149auditTarget149ClamAVScanner175createSecurityScanner175createBuiltinScanner175 +12 more