Nativa PHP Core

Article

DeepSeek Harness and Cordis ... the plugin framework for tomorrow

Article cover illustration: Vision, security-series, deepseek, cordis

What is DeepSeek Harness

DeepSeek Harness (dsh) isn't another LLM API wrapper. It's an agent framework ... an environment where agents run, and every agent is a plugin.

The core is built on Cordis ... a plugin framework where:

  • Nothing is fixed ... all components are replaceable
  • Agent changes the environment ... can load/uninstall plugins at runtime
  • Effects are tracked ... when a plugin is uninstalled, resources are released

DeepSeek owns the framework layer

DeepSeek didn't just use Cordis ... they vendored the entire framework layer into their own @deepseek-ai/* scope:

PackageUpstreamWhat it does
@deepseek-ai/cordiscordiverse/cordis 4.0.0-rc.7Core plugin framework
@deepseek-ai/cosmokitdeepseek-harness forkUtility library
@deepseek-ai/schemasterydeepseek-harness forkSchema validation
@deepseek-ai/cordis-plugin-loader@cordisjs/plugin-loaderRuntime plugin loading
@deepseek-ai/cordis-plugin-hmr@cordisjs/plugin-hmrHot module replacement
@deepseek-ai/cordis-plugin-timer@cordisjs/plugin-timerDisposal-aware timers
@deepseek-ai/cordis-plugin-include@cordisjs/plugin-includeYAML/JSON config

Why? Because they publish Cordis as part of Harness, not as a dependency. Every harness package declares cordis as a peer dependency ... and when you publish the harness, you publish the framework layer too.

Local patches

DeepSeek didn't take Cordis as-is from upstream. They added:

  • Fiber lifecycle hardening ... closes reentrant disposal gaps, cleanup-time registration is rejected, teardown-notification failures are isolated per observer
  • Transactional Loader ... imports a new entry name BEFORE disposal, restores the previous plugin if application fails
  • JSDoc enrichment ... @param/@returns tags for the API reference generator

This isn't just "we use Cordis" ... this is we own the framework layer.

Cordis: No hard core

Traditional frameworks have a hard core and plugins are added around it:

Traditional: [Hard Core] + [Plugin 1] + [Plugin 2] + [Plugin 3]
Cordis:      [Plugin 1] ↔ [Plugin 2] ↔ [Plugin 3]
             No core. Everything is a plugin.

In Cordis, even the agent-loop is a plugin. You can replace, modify, or uninstall it without breaking the rest of the system.

# cordis.yml ... plugin configuration
plugins:
  - dsh-agent-loop       # Basic agent loop
  - dsh-llm-adapter      # LLM provider adapter
  - dsh-tool-registry    # Tool registration
  - dsh-p2p-sync         # P2P communication
  - dsh-energy-monitor   # Resource tracking
  - dsh-outbox           # Async processing

Every line is a plugin. None is "the important one." All can be replaced.

Hot-swap: Change at runtime

Imagine your P2P node (fridge) is running and you want to change the communication method. Traditional approach: restart. With Cordis:

// Agent changes plugin at runtime
$ctx->uninstall('dsh-http-transport');
$ctx->install('dsh-websocket-transport');

// No restart. No downtime. Network keeps running.

The plugin is properly uninstalled:

  1. Its lifecycle is tracked
  2. Resources are released (DB connections, file handles)
  3. The new plugin takes over its duties

Scoped services: Resources with lifecycle

Every plugin has scoped services ... resources that live only during the plugin's lifetime:

// Plugin registers scoped service
$ctx->effect(function () use ($pdo) {
    // This runs when plugin is installed
    $repository = new SqliteOutboxRepository($pdo);

    // Returns service that will be released on uninstall
    return $repository;
});

// When plugin is uninstalled, $repository is automatically released

No memory leak. No orphan connections. Cordis takes care of it.

Event-driven: Small-talk between plugins

Plugins communicate through typed events ... exactly like small-talk:

// Plugin A: emits event
$ctx->emit('p2p/chunk-received', [
    'chunk_id' => $chunk->id(),
    'hash' => $chunk->hash(),
]);

// Plugin B: listens and reacts
$ctx->on('p2p/chunk-received', function (array $data) {
    $this->chunkIndexer->index($data);
});

// Plugin C: also listens, but differently
$ctx->on('p2p/chunk-received', function (array $data) {
    $this->energyMonitor->trackTransfer($data);
});

Plugin A doesn't know Plugin B or C. It just "says" something and whoever wants to, listens. Decoupled, testable, extensible.

How it fits P2P

In the previous article we described the fridge as a P2P server. Cordis is the operating system for such a node:

NeedCordis solution
P2P communicationdsh-p2p-sync plugin
Energy trackingdsh-energy-monitor plugin
Local storagedsh-chunk-store plugin
Async processingdsh-outbox plugin
UpdatesHot-swap without restart
AuditTrajectory (append-only log)

Trajectory: Audit trail

Harness automatically records all events in an append-only log:

// Every action is recorded
$trajectory->record('p2p/chunk-shared', [
    'chunk_id' => $chunk->id(),
    'peers' => ['192.168.1.10', '192.168.1.11'],
    'timestamp' => time(),
]);

// Full audit trail ... who, what, when, why

For P2P networks this is crucial: you know exactly which chunks were shared, when, and through which nodes.

Cordis and Outbox

Cordis plugins can use the Outbox pattern for async processing:

// dsh-outbox plugin
$ctx->effect(function () use ($processor) {
    // Registers handlers for P2P events
    $processor->registerHandler('ChunkShared', function (OutboxMessage $msg) {
        $this->p2pNetwork->broadcast($msg->payload());
    });

    // Background process processes outbox
    $processor->process(100);

    return $processor; // Released on uninstall
});

Outbox ensures P2P broadcasts survive plugin crashes. Cordis ensures plugins can be fixed without restarting the entire node.

OpenSpec and Cordis

OpenSpec defines what should happen. Cordis ensures how:

# OpenSpec: behavior definition
distribution:
  strategy: gossip
  chunk_size: 4KB
  retry: 3

# Cordis: implementation as plugin
plugins:
  - dsh-p2p-gossip       # Gossip protocol
  - dsh-chunk-splitter   # Split into 4KB chunks
  - dsh-retry-queue      # Retry mechanism

OpenSpec can generate Cordis configuration. Cordis can report back to OpenSpec. A bidirectional bridge.

The lesson

Cordis is a TypeScript plugin framework ... not an abstract idea, but a concrete tool.

A framework that follows these principles:

  • No hard core ... everything can be replaced
  • No restart ... hot-swap at runtime
  • No memory leak ... scoped services
  • No silent failure ... trajectory logging

For P2P freeNet, it's exactly what you need: a node that can update, fix, and extend itself without someone physically coming to restart the fridge.

And when you combine it with OpenSpec (orchestrator), Outbox (async distribution), and ACID (consistency), you have the complete stack for a decentralized cognitive network.

→ The fridge as a P2P server: hardware for P2P nodes → Outbox pattern ... when cache isn't enough: async distribution → OpenSpec vs tickets ... agility in the AI era: orchestrator for Cordis

Sources

Comments (0)

No comments yet — be the first to react.

Reader questions (0)

No questions yet — be the first to ask.

Stuck on something in this article? Ask below. Your name is shown publicly; your email is never stored. A question appears here once a moderator approves it.