Files
deepseek-harness/docs/rfc/implemented/2026-06-11-microkernel-event-taxonomy.md
Tianyi Cui 7c400e9c02 docs: unify ADR/RFC trees into one lifecycle-organized RFC tree
Collapse docs/adr/ and docs/rfc/ into a single docs/rfc/ with proposed/,
implemented/, and rejected/ subfolders. Every file is renamed to
yyyy-mm-dd-topic-title.md, where the date is when the topic was first
proposed (from git history). ADRs and RFCs that covered exactly the same
topic are merged (property-based testing, session persistence); the
umbrella RFC 005 stays split across its three implemented decisions, and
RFC 006's deferred part-3 (API extractor reports) splits into its own
proposed RFC. All cross-references become machine-checkable relative
links instead of bare "ADR NNNN" / "RFC NNN" prose.

Add a verify-md-links doc-sync gate (scripts/verify-md-links.ts) that
checks every relative Markdown cross-link resolves, wired into doc-sync
alongside verify-md-wrap. This makes the reorganization self-verifying:
the same change that rewrote ~forty inter-doc links adds the check that
proves none dangle. Document the cross-link convention in a new
docs/AGENTS.md and record the gate as an implemented RFC.

doc-sync, typecheck, lint, and the full test suite (667) all pass.
2026-06-18 02:18:24 +08:00

1.9 KiB

RFC: Microkernel — extension via Cordis event taxonomy, one concrete loop

Status: implemented (accepted 2026-06-11)

Context

The product principle (see the 微内核Harness实现思路 design doc) is "everything is a plugin": hooks, /goal, /loop, dynamic workflows, compaction, sandboxing, permissions, UI, persistence, MCP, skills must all be writable as plugins without modifying the core. Candidate mechanisms considered: a purpose-built middleware stack (koa-compose style), an explicit phase state machine plugins can insert into, or Cordis's native event system.

Decision

Pure Cordis event taxonomy. The loop's extension seams are typed events with deliberate dispatch modes:

  • waterfall (around-middleware) where plugins mutate or veto: agent/request, agent/step-result, agent/turn-continuation, tools/execute, llm/stream, llm/generate, system-prompt/assemble.
  • emit (sync fire-and-forget) for notifications: turn/step boundaries, stream chunks, lifecycle, errors.
  • parallel (awaited) for the one durability checkpoint: session/flush.

The event vocabulary lives in interface packages (dsh-agent declares the agent/* events); @deepseek-ai/dsh-agent-loop is the only concrete plugin and is itself swappable — nothing outside it may depend on it.

Consequences

  • Every MVP feature maps to a listener (the "plugin sanity checklist" in docs/architecture.md is the proof obligation, kept current).
  • HMR and disposal come free: listeners and registrations are Cordis effects.
  • Waterfall semantics (call next() or short-circuit) are non-obvious and must be taught — documented in AGENTS.md and covered by composition tests.
  • The loop must be defensive: plugin exceptions are contained at turn level, steering from any seam is never stranded (regression-tested).