Skip to content

replay: PluginRegistry has no reset hook, so plugin-held counters survive resetState #886

Closed

Description

@scttfrdmn

ReplayEngine.resetState (emulator/replay.go:656-664) resets the StateManager and nothing else. Plugins hold their own mutable counters, and PluginRegistry (emulator/types.go:334-365) is a sync.RWMutex plus a map[string]Plugin with no reset hook — so a second replay in one process starts from the first replay's counter values and produces different identifiers for the same recorded events.

The counters that survive a reset

  • S3Plugin.versionSeq — emulator/s3_plugin.go:927 and :1200 (version IDs)
  • SESV2Plugin.msgSeq — emulator/sesv2_plugin.go:20 (MessageId)

Both are atomic.Int64 fields on the plugin struct. resetState cannot reach them, and nothing else tries.

Why it matters beyond tidiness

resetState exists so a replay begins from the recorded run's starting point. It does that for state and not for the plugins, so:

A replay whose output depends on how many replays preceded it is the one property the event log exists to rule out.

This is a hard sub-task of #856

#856 proposes making the ~66 minters deterministic. Whichever option it takes, the two atomic counters come under it, and a counter is only reproducible if something resets it between runs. So a lifecycle hook is a prerequisite of #856's full seam, not an optional extra — and it is separable from the question of how the other minters derive their values, which is why it is filed on its own.

Acceptance criteria

  • PluginRegistry gains a way to signal "reset to a run's starting point" to every registered plugin — an optional interface a plugin may implement (so the 40-odd plugins that hold no state need no change) rather than a method on Plugin, unless there is a reason to force all of them.
  • resetState calls it, and its doc comment stops implying the StateManager is the whole of a plugin's mutable state.
  • S3Plugin and SESV2Plugin implement it, resetting versionSeq and msgSeq.
  • A test that replays one recorded stream twice in one process and asserts the two runs produce identical minted values. This is the assertion that fails today; assert on the values, not just that both runs succeeded.
  • An audit recorded on the issue of any other plugin-held mutable field, so the hook's implementers are a known set rather than the two found here. grep for atomic. and for non-config struct fields on plugin types.

Found while scoping #856 for the v0.116.0 cut; the CLI wiring in #855 made it reachable from the command line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: chore

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions