wiki / concepts / cordis-framework
Cordis Framework
Machine ingest — raw context
loading…
~… tokensappend .md to any wiki URL for this view
Cordis Framework
Cordis is a microkernel plugin and dependency-injection framework used as the underlying infrastructure kernel in DeepSeek Harness. It provides modular lifecycle management, service containers, typed event buses, and reversible side-effects for agent runtimes.
The 5 Core Concepts
Cordis structures agent harnesses around 5 foundational mechanics:
- Plugins as Service Providers: A plugin is either an object implementing
apply(ctx)with optionalinjectdeclarations, or aServicesubclass whose lifecycle is bound to the current context. - Context as Service Container: Services occupy stable keys on the context object (e.g.,
ctx.tools,ctx.llm,ctx.sessions,ctx.agents). Consumer plugins access capabilities via context keys rather than importing concrete module implementations. - Declarative Inversion of Control via
inject: Plugins declare required services viainject. Cordis delays plugin activation until all dependent services are mounted and ready, eliminating manual startup sequencing. - Typed Event Dispatch: Services communicate through typed event buses with 4 distinct dispatch modes:
emit: Asynchronous observation in registration order (no return value, no await).waterfall: Middleware pipeline in registration order; listeners can modify data, delegate vianext(), or short-circuit return values.parallel: Parallel asynchronous execution across all listeners (await, no return value).serial: Sequential execution in registration order (await, returns value).
- Reversible Side Effects & Teardowns: Registrations (prompt fragments, tool schemas, middleware, event listeners) are mounted via
ctx.effect()orctx.on(). Reloads and teardowns automatically invoke associated disposers to cleanly undo side-effects.
Waterfall Middleware Semantics
The waterfall pattern functions as an onion-style interceptor:
- Listeners accept
(...args, next). - Calling
next()delegates to downstream handlers and yields their return value back up the stack. - Returning directly without calling
next()short-circuits execution, allowing policy plugins to preemptively veto or handle actions. - Collaborative listeners modify shared request/decision payloads before delegating.
Loader & Configuration Engine
Dynamic configuration uses @deepseek-ai/cordis-plugin-include:
- Parses expressions like
!!jsinto dynamic AST nodes. - Evaluates
configanddisabledpredicates reactively against service context (ctx.serviceName). - Environment-specific overrides and overlays allow dynamic feature flags without modifying harness code.
Related Concepts
Evidence — verified primary sources
| deepseek-harness-cordis-primer-2026 | https://deepseek-harness.github.io/deepseek-harness/reference/cordis-primer | ingested 2026-08-24 sha256:e76a43328989… |
Graph context
References (4)
DeepSeek Harness. It provides modular lifecycle management, service containers, typed event buses, and reversible side-effects for agent runtimes.Agent Harness EngineeringAgent-Native InfrastructureDeepSeek Referenced by (4)
Agent Harness EngineeringClean ArchitectureDeepSeek Harness, delegating all functional capabilities into plugins that register typed services:DeepSeekas an in-process microkernel where every agent subsystem (models, tools, skills, sessions, sandboxes, storage, loops, scheduling, and UI) is