Skip to content

fix(unload): preserve runtime ownership across repeated plugin loads #113

Description

@ss-o

Problem

Zi identifies runtime ownership by plugin ID rather than by load instance. A
second load of the same plugin can therefore overwrite or collapse the state
needed to clean up the first load.

Current examples:

  • widget restoration scans later plugin loads but explicitly skips repeated
    loads of the same plugin;
  • function diff state is reset on overwrite-load, so a function created by the
    first load appears pre-existing to the second and can survive the eventual
    unload; and
  • bindkey and widget ownership chains cannot distinguish two instances with
    the same plugin ID.

The hook-registration cleanup added by #108 preserves its first snapshot
across overwrite-loads, which fixes that hook-specific contract without
claiming to solve the shared per-load identity model.

Impact

Repeated loads can leave functions behind or restore the wrong prior widget or
binding state. Multi-plugin replacement chains can likewise lose the
immediately preceding live owner.

Acceptance criteria

  • Represent function, widget, and bindkey ownership per load instance rather
    than only by plugin ID.
  • Restore or remove state belonging to the correct instance when unloading.
  • Restore the immediately preceding live owner in multi-plugin chains.
  • Preserve correct behavior when the same plugin is loaded more than once.
  • Add focused tests for repeated same-plugin function definitions, two-plugin
    widget and bindkey chains, repeated same-plugin loads, and out-of-order
    unload.
  • Keep existing single-load behavior and the hook-specific ownership contract
    from fix(unload): track and remove plugin-owned hook callbacks #108 compatible.

Next action

Define the minimal per-load identity and ownership-chain representation before
implementation, then apply it consistently to function, widget, and bindkey
records.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ziZi core behavior, APIs, or documentation.type:bugSomething is broken or behaving incorrectly.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions