Skip to content

PR-18 feat(worker): define worker protocol #37

Description

@HsienW

Objective

Define explicit, versioned messages between main thread and worker before writing worker runtime logic.

Main → Worker

{ type: 'COMMAND_BATCH', seq: 42, commands: [...] }
{ type: 'RUNTIME_CONTROL', action: 'PAUSE' }

Worker → Main

{ type: 'SNAPSHOT', tick: 123, state: {...}, metrics: {...} }
{ type: 'GAME_EVENT', event: {...} }

Ownership rule

  • Worker owns: tick, snake positions, collision, food, score, seeded RNG, replay log.
  • Main thread owns: keyboard/browser input collection, buttons, accessibility UI, current renderer, main-thread performance panel.
  • No shared mutable state in the first Worker version.

Exit criteria

  • Worker protocol is versioned

Activity

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

Metadata

Metadata

Assignees

Labels

improvementImprove existing functionality or performance.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions