English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

A Programming Paradigm for Spatiotemporal Composability: Making Plugins Truly Pluggable

Forum topic · QianXun · 2026-08-21

Summary

This post is a detailed Chinese-language deep-dive into the paper 'A Programming Paradigm for Spatiotemporal Composability' by Yifan Shi, Wei Zhang (Peking University), and Tianyi Cui (Peking University / DeepSeek-AI). The paper proposes promoting classical effect and coeffect systems from static type-system annotations to first-class runtime mechanisms, unified as a single 'context type.' This yields a programming paradigm where components can be freely installed and removed at runtime: unloading fully rolls back side effects (temporal composability), and dependencies are automatically reconnected as components appear or disappear (spatial composability). Key mechanisms include 'revertible effects,' where every environment transformation returns its own inverse as part of its value, and 'reactive coeffects,' which turn dependency declarations into contracts. The work includes metatheory (monoid homomorphism for tracking, soundness invariants, independence results) and a dynamic combinable calculus. It is implemented as the Cordis meta-framework, validated empirically on Koishi, an ecosystem with over 4,000 community plugins. The post motivates the work through the pain of unloading VS Code extensions and the demands of self-evolving AI agent harnesses, and contrasts the approach with coarse-grained alternatives like OS processes and container orchestration.

This is an edited Chinese-language deep-dive of the paper *A Programming Paradigm for Spatiotemporal Composability* (Yifan Shi, Wei Zhang — Peking University; Tianyi Cui — Peking University / DeepSeek-AI). The original article is long (88 pages, 8 sections, 124 references); below is a structured English summary.

Key points

  • Thesis: Classical *effects* and *coeffects* — normally static annotations in type systems — should be reified as first-class runtime mechanisms, unified into a single "context type." The result is a programming paradigm in which components can be freely plugged and unplugged at runtime: unloading fully rolls back side effects, and dependency lifecycles trigger automatic reconnection.
  • Motivation — why unloading is hard:
  • VS Code's extension host must restart after an extension is deactivated/uninstalled, because deactivate is only an optional cleanup callback, splitting creation from destruction (failure of *locality of concern*). Cross-extension dependencies are rare (only 7 of the top-100 extensions declare dependencies on non-builtin extensions) and untyped (any).
  • Self-evolving AI agent harnesses need even more: without temporal composability, every self-modification requires a full restart, losing in-process state; a bad self-modification can destroy the very process needed for recovery. Without spatial composability, modules must handle dependency churn with ad hoc code.
  • Coarse-grained alternatives (OS processes, containers) discard in-process state, need redundant replicas, and cannot express dependencies between components within the same address space.
  • Two orthogonal dimensions, mapped to classical theory:
  • *Temporal composability* — can an uninstalled component's environmental changes be fully and safely rolled back? (Corresponds to effects: how a computation modifies its environment.)
  • *Spatial composability* — can dependencies between components be declared, resolved, and adaptively maintained? (Corresponds to coeffects: how a computation depends on its environment.)
  • Revertible effects (temporal): An effect is modeled as Γ → Γ × (Γ → Γ) — applying a transformation yields the new context *plus its own inverse*. The effect context ∂Γ ≔ Γ × (Γ → Γ) pairs current state γ with an accumulator φ, the composition of all applied inverses (a recovery function). Theorem 5 shows trackΓ is a monoid homomorphism; Theorem 7 establishes the soundness invariant φ(γ) = γ₀, so recoverΓ(γ, φ) ≔ (φ(γ), idΓ) always restores the initial state. Corollary 21 shows that when effect transformation monoids commute (independence), inverses can be applied in any order — enabling concurrent plug/unplug of interleaved components.
  • Reactive coeffects (spatial): Dependency declarations become contracts (specifications); coeffects are treated as effects and hence also revertible, with isolation and interception semantics. When dependencies appear, disappear, or change owners, the runtime responsively re-wires the topology instead of leaving each module to poll and adapt on its own.
  • Unified context Γ∞: The two mechanisms merge into a layered context supporting hierarchical composition — the literal metaphor of plugging and unplugging — with observational equivalence (≃) characterizing when two configurations behave identically.
  • Metatheory: A dynamic combinable calculus is developed with formal theorems covering tracking, recovery, ordering, and dependency management.
  • Implementation — Cordis meta-framework: Three layers: a core library providing context/effect primitives, and a loader handling reconciliation and HMR (hot module replacement), so plugin code can be swapped in place.
  • Empirical validation — Koishi: An ecosystem of 4,000+ community plugins built on Cordis, demonstrating the paradigm at production scale.
  • Positioning: Classic static composition (function calls, imports, inheritance) is fixed at compile time; container orchestration buys rollback only at the cost of restarts and coarse granularity; OSGi-style systems can declare dependencies but cannot cleanly clean up in place. Only the combination of revertible effects and reactive coeffects achieves both dimensions at component granularity — turning correctness from an author-discipline problem into a structural property.

Conclusion

The paper's design goal is explicitly forward-looking: preparing for self-evolving systems. If an agent harness must modify its own tools, sandboxes, memory, and sub-agent orchestration while serving requests, it needs exactly these guarantees — safe in-place rollback of any self-modification, and automatic re-wiring of dependencies as components come and go.

Tags

#programming-paradigms#effects-systems#coeffects#runtime-composability#plugin-architecture#revertible-effects#cordis#koishi#ai-agents

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/178633769