Plugins as Deltas: Designing a Reversible Runtime Structure

    This article argues that plugins should be treated as deltas against a runtime's structure space rather than as arbitrary feature packages. It explains what a structural delta is, why reversibility means reversing structural changes rather than undoing side effects, and how declarative reconciliation keeps a long-lived runtime coherent during dynamic updates. It also defines the minimal algebra deltas should satisfy, covers the assembly-time half of reversibility, and lays out practical design boundaries. Readers will learn how to build plugin systems that stay explainable, rollback-friendly, and evolvable under continuous change.

    A runtime increasingly behaves like a continuously evolving structure rather than a program frozen after one compile. Agent loops, memory, tool calls, permissions, observability, and policy are often delivered by different teams at different cadences. If you weld all of them into the kernel, shipping, degrading, or replacing any single capability ripples across the whole system. Making these capabilities plugins looks like engineering decoupling on the surface; more precisely, a plugin should be a delta against the runtime’s structure space, not an arbitrarily mounted feature package.

    From “Functional Modules” to “Structural Deltas”

    The common formulation is:

    1. Application = Base + Plugin1 + Plugin2 + ...

    This line only means something when “add” is strictly defined. The base provides a minimal closure: a scheduling entry point, dependency resolution, lifecycle management, config merging, and failure isolation. Plugins do not rewrite the base source directly; instead they declare the structural fragments they intend to add, replace, or revoke, such as a processing stage, a memory backend, a set of tool contracts, or an observability tap.

    A delta must answer at least four questions. Where does it act, meaning which extension point it attaches to. What does it do, meaning add, override, or delete. How is it ordered, meaning whether it commutes with existing deltas. What remains when it is revoked, meaning full restoration, or only structural restoration without reclaiming facts that already happened in the external world.

    So “everything is a plugin” is not about forcing unrelated concepts under one name. Loops, memory, and tools do have different business semantics, but their impact on the runtime lands on the same structural operations: inserting a stage, registering an implementation, binding config, establishing a dependency. What is unified is the algebra of change, not the business itself. High configurability only means many parameters; delta-ization requires that changes be locatable, mergeable, replaceable, and reversible.

    Reversibility Is Not Running the Program Backwards

    Side effects are unavoidable: model calls, external tools, persistence writes, and message delivery cannot be erased by “reversing time.” Reversibility here means reversing the changes made to the runtime structure. Installing a plugin is a forward delta in structure space; uninstalling or replacing it applies the corresponding inverse delta so that the composite result returns to the declared target state.

    Two kinds of effects need to be distinguished.

    The first is structural effects: registries, processing chains, dependency graphs, config trees, and permission boundaries. These determine how multiple plugins work together, and they should be reversible; otherwise hot updates only accumulate into a mess.

    The second is business effects: requests already sent, memories already written, costs already incurred, and audit records already produced. The runtime should not pretend it can govern every side effect. The reasonable scope of reversible computing at this layer is the structural side effects that change how plugins compose. Business side effects should be managed through idempotency, compensation, the outbox pattern, or explicit confirmation, rather than being stuffed behind the same “undo” button.

    A practical criterion: if a change only affects “how the system is composed from here on,” it belongs in the reversible structural layer; if a change has already crossed the process boundary and become an external fact, only record the causality and do not promise a physical rollback.

    Dynamic Updates Solve Structural Coherence, Not Releases

    A version upgrade can replace artifacts, but it cannot automatically answer whether registrations left behind by old plugins are still present, how old and new configs merge, whether other plugins that depend on them still satisfy their invariants, and whether a failure can stop at the last consistent structure. The necessity of dynamic updates comes from the runtime being long-lived. Connections, sessions, caches, and in-progress tasks cannot always restart along with the process.

    Reliable dynamic updates usually follow a “declare the target state, then reconcile” path rather than patching live systems directly.

    1. The expected state is described declaratively: which plugins are enabled, version constraints, config, and extension-point bindings.
    2. The runtime computes the diff between the current structure and the expected structure.
    3. The diff is decomposed into ordered operations: stop dependents, revoke the old delta, apply the new delta, rebuild dependencies, and run health checks.
    4. If any step fails, apply the inverse of the completed steps, or enter an explicit degraded structure, rather than stopping in a half-installed state.

    This complements rolling upgrades in release systems. Releases deliver code to nodes; reconciliation makes the structure on each node converge to the same declaration. Without reconciliation, hot-plugging merely moves change risk from compile time to overnight on-call duty.

    The Minimal Algebra Deltas Must Satisfy

    To call plugins mathematical delta units, an implementation should at least approximate these properties, without piling up abstract terms in the documentation.

    Merges on the same extension point need a clear priority and conflict strategy: latter overrides, selection by priority, or rejection of coexistence. The empty delta must be the identity element, and repeatedly applying the same declaration must be idempotent; otherwise a restart would change behavior. Every forward delta should be able to construct an inverse delta, and applying that inverse once more should return to the original structure, at least at the structural level. If a delta composition is commutative, prove it explicitly; if it is not, fix the order and write it into the dependencies. Plugins must not bypass extension points to modify global mutable state, otherwise the inverse operation cannot enumerate what it touched.

    The sketch below expresses only control flow, not the interface of any particular framework:

    1. target = loadDeclaration(config)
    2. current = exportStructureSnapshot()
    3. delta = plan(current, target) # includes install, replace, uninstall
    4. for step in delta.orderedSteps:
    5. if not apply(step):
    6. reverse(completedSteps)
    7. exit with failure
    8. verifyInvariants(dependency closure, extension point uniqueness, health checks)

    The planning phase matters more than the application phase. Compute whether the inverse operations exist first, then decide whether the update can proceed. If a plugin starts an unregistrable background task during installation, planning should reject it from the reversible layer, or require it to provide a symmetric stop action.

    The Missing Half of Runtime Reversibility

    Runtime reconciliation alone is not a complete reversible structure. Compile time or assembly time needs a delta algebra too: baseline structure, patches, deletions, renames, and conflict detection should be completed before entering the process, producing a reviewable assembly result. The runtime only consumes closed deltas, rather than temporarily interpreting ambiguous config on the fly.

    Three common gaps show up in practice. A declaration describes “what is wanted” but not “relative to which baseline,” so the result of two merges depends on arrival order. Inverse operations rely on convention instead of being generated from the forward operation, so the uninstall path easily misses listeners and timers. When multiple plugins write the same logical field, there is no merge law, and the only defense is a “please do not enable both at once” note in the docs.

    The fix is to define a merge function and a conflict error for the value of each extension point; compile config into an immutable snapshot; have the runtime perform only snapshot switching and resource hookup; limit “reversible” to the structural diff between snapshots; and write the acquisition and release of external resources as paired lifecycle hooks. A paper-style mechanism description that stops at “you can install it and you can uninstall it” has not yet been formalized down to a delta algebra; in engineering, the same idea can be realized with snapshots, planning, idempotency, and invariant checking.

    Design Boundaries in Practice

    Keep extension points few and stable. Every additional extension point requires defining merge, priority, inverse operations, and observability metrics. The plugin manifest should be serializable, making it easy to compare differences across environments. Express dependencies with identifiers and version constraints, and avoid leaving startup order implicit in the code. Structural changes need an audit trail: who applied which delta to which snapshot. For observability, look separately at “whether the structure is converging” and “whether the business is succeeding,” and avoid substituting request success rate for assembly correctness.

    Do not mistake reversibility for a business rollback switch. Wrong memory writes and mistaken tool calls require a business compensation strategy; uninstalling a plugin only guarantees that execution no longer follows the old structure from that point on. For long-running tasks, define the ownership of in-flight work when switching snapshots: either continue on the old structure until completion, or migrate at a safe point.

    How to Understand and Use This

    To understand this approach, remember three sentences. Plugins are structural deltas, not arbitrary code packages. Reversibility reverses structural changes, not all side effects. Dynamic updates maintain coherence through declaration and reconciliation, rather than replacing version management.

    In practice, first delineate the base closure, then open extension points only for capabilities that genuinely need to evolve independently; write a clear install and a symmetric uninstall for every delta; drive the runtime with the expected state instead of piling imperative patches inside the process; and isolate external side effects outside the structural layer, designing compensation for them separately. Do these things, and a composite system can stay explainable, rollback-friendly, and evolvable through continuous change.