How cordiverse/cordis works
Purpose and Package Topology
Cordis is a TypeScript monorepo implementing a meta-framework for spatiotemporal composability: scoped service contexts, plugin lifecycles, eventing, dependency association, and runtime reconfiguration. The primary public runtime is @cordisjs/core at packages/core/src/index.ts; surrounding packages add configuration loading, HMR, scoped grouping, timers, logging, and project creation.
Core Context and Service Runtime
The central execution model is the context/service graph:
• packages/core/src/context.ts defines scoped contexts and their composition/isolation boundaries.
• packages/core/src/service.ts manages service provisioning, lookup, lifecycle, and dependency-facing behavior.
• packages/core/src/registry.ts maintains registrations and associations.
• packages/core/src/index.ts exports the public framework API.
Plugins and services are attached to contexts rather than a global container, enabling localized capabilities and disposal.
Plugin Lifecycle, Fibers, and Disposal
Plugin invocation and teardown are coordinated through:
• packages/core/src/fiber.ts for lifecycle/disposable execution units.
• packages/core/src/context.ts for context-owned plugin application and cleanup.
• packages/core/src/reflect.ts for metadata/reflection used in association and injection-like behavior.
This establishes ownership boundaries: disposing a context or fiber should clean up work and services created beneath it without requiring application-wide shutdown.
Event and Logging Boundary
Core provides runtime observability and communication:
• packages/core/src/events.ts implements context/event dispatch semantics.
• packages/core/src/logger.ts defines framework logging facilities.
• packages/logger-console/src/index.ts provides a console-backed logger integration, with browser-specific support in packages/logger-console/src/browser.ts.
Events decouple producers from scoped consumers; logging is an adapter boundary so core does not depend on a specific output target.
Declarative Loading and Configuration Graphs
@cordisjs/loader turns configuration into a context/plugin topology:
• packages/loader/src/index.ts is the loader entry point.
• packages/loader/src/config/tree.ts models hierarchical configuration.
• packages/loader/src/config/group.ts and packages/loader/src/config/isolate.ts represent group and isolation boundaries.
• packages/loader/src/internal.ts contains loader-runtime integration.
The loader is the principal bridge from declarative configuration to imperative core context/plugin creation.
Runtime Reconfiguration Extensions
Several packages modify or extend active compositions:
• packages/hmr/src/index.ts supplies hot-module/plugin reload behavior; packages/hmr/src/error.ts handles reload failures.
• packages/include/src/index.ts supports inclusion/patching of configuration or plugin sources.
• packages/group/src/index.ts provides grouping semantics compatible with the scoped composition model.
• packages/timer/src/index.ts adds time-based execution primitives.
HMR is an important control-flow boundary: replacement must coordinate with core lifecycle disposal and error reporting rather than simply re-import code.
Entrypoints and Execution Environment
The repository targets Node.js/TypeScript package consumers, with browser support specifically represented by the console logger adapter. CLI entrypoints are:
• packages/core/bin.js for the core package executable.
• packages/create/src/bin.ts for project scaffolding.
• packages/create/src/index.ts for the create-package implementation.
Build/test automation is GitHub Actions-based (.github/workflows/build.yml), while package orchestration is defined at the monorepo root (package.json, yakumo.yml). No application server, database, or external hosted service is present in the repository.
Main entry points: context.ts Scoped Contexts · index.ts Hot Reload · service.ts Service Runtime · internal.ts Loader Runtime Bridge
Components 21
Core Runtime
Scoped composition and lifecycle primitives.
- Core Public API
packages/core/src/index.ts - Scoped Contexts · Owns localized capabilities, plugins, and cleanup.
packages/core/src/context.ts - Service Runtime · Provides lookup and lifecycle behavior for scoped services.
packages/core/src/service.ts - Service Registry
packages/core/src/registry.ts - Lifecycle Fibers · Coordinates plugin execution and teardown.
packages/core/src/fiber.ts - Reflection Metadata · Supports service association and injection-like behavior.
packages/core/src/reflect.ts - Scoped Events
packages/core/src/events.ts - Logger Interface · Keeps core independent of output targets.
packages/core/src/logger.ts
Declarative Loading
Configuration-to-runtime composition.
- Loader Entrypoint
packages/loader/src/index.ts - Configuration Tree · Models hierarchical declarative composition.
packages/loader/src/config/tree.ts - Group & Isolate Config · Represents grouping and isolation declarations.
packages/loader/src/config/group.ts - Loader Runtime Bridge · Materializes configuration as contexts and plugins.
packages/loader/src/internal.ts
Runtime Extensions
Packages that augment active compositions.
- Hot Reload · Replaces active plugins while coordinating disposal.
packages/hmr/src/index.ts - Reload Errors
packages/hmr/src/error.ts - Include & Patch · Includes or patches configuration and plugin sources.
packages/include/src/index.ts - Scoped Grouping
packages/group/src/index.ts - Timers · Adds time-based execution primitives.
packages/timer/src/index.ts - Console Logger · Console-backed logger with browser support.
packages/logger-console/src/index.ts
Tooling
CLI and project scaffolding.
- Core CLI
packages/core/bin.js - Create CLI
packages/create/src/bin.ts - Project Creator
packages/create/src/index.ts
Connections 21
- Core Public API → Scoped Contexts: exports
- Scoped Contexts → Service Runtime: owns scoped services
- Service Runtime → Service Registry: registers and associates
- Service Runtime → Reflection Metadata: uses metadata
- Scoped Contexts → Lifecycle Fibers: applies and disposes plugins
- Scoped Contexts → Scoped Events: dispatches scoped events
- Scoped Contexts → Logger Interface: uses logging boundary
- Loader Entrypoint → Configuration Tree: loads
- Configuration Tree → Group & Isolate Config: contains
- Loader Entrypoint → Loader Runtime Bridge: delegates to
- Loader Runtime Bridge → Scoped Contexts: creates compositions
- Loader Runtime Bridge → Lifecycle Fibers: applies plugins
- Hot Reload → Scoped Contexts: replaces compositions
- Hot Reload → Lifecycle Fibers: coordinates disposal
- Hot Reload → Reload Errors: reports failures
- Include & Patch → Loader Entrypoint: extends sources
- Scoped Grouping → Scoped Contexts: adds grouping semantics
- Timers → Scoped Contexts: adds scheduled work
- Console Logger → Logger Interface: implements
- Core CLI → Core Public API: invokes
- Create CLI → Project Creator: invokes