Skip to content

fix(log): preserve metadata from lifecycle hooks - #1296

Draft
janmarsino98 wants to merge 1 commit into
boardgameio:mainfrom
janmarsino98:codex/fix-hook-log-metadata
Draft

fix(log): preserve metadata from lifecycle hooks#1296
janmarsino98 wants to merge 1 commit into
boardgameio:mainfrom
janmarsino98:codex/fix-hook-log-metadata

Conversation

@janmarsino98

Copy link
Copy Markdown
Contributor

Summary

  • attach log metadata from lifecycle hooks to the move or event that triggered them
  • handle hooks reached through queued and automatic events, including turn, phase, and game endings
  • preserve synthetic event arguments and player IDs while stripping credentials
  • document hook metadata behaviour and add regression coverage

Fixes #1228.
Builds on the direct-event support added in #1267.

Testing

  • corepack pnpm exec jest src/core/flow.test.ts src/plugins/plugin-log.test.ts --runInBand (150 tests)
  • corepack pnpm exec eslint src/core/flow.ts src/core/reducer.ts src/plugins/plugin-log.ts src/plugins/plugin-log.test.ts
  • corepack pnpm run ts
  • corepack pnpm run build

Checklist

  • Use a separate branch in your local repo (not main).
  • Regression coverage was added for all changed paths. The full pre-push coverage command could not start locally because the Windows environment exposes pnpm through Corepack while the hook invokes pnpm directly; CI will run the full coverage suite.

@devill devill left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes #1228 — metadata from a phase onBegin now lands on the triggering entry. Three things
first:

  • Coverage is red (−0.2%, 99.821%), so the "coverage added for all changed paths" box isn't
    true. Every gap is new dead code: flow.ts:544,864,885,891 and reducer.ts:183-186
    (clearLogMetadata is unreachable now). Delete rather than test.
  • Undeclared change: an event dispatched inside a move now gets its own log entry.
    events.endGame({ winner: '0' }) in a move gives ["MOVE:win"] on main and
    ["MOVE:win","EVENT:endGame"] here. Not in the description; all 906 tests pass either way.
  • This replaces #1267 rather than building on it — the ~86 lines dropped from reducer.ts
    are your 107604e. Worth saying so, it's a second pass over the same ground.

Moving it to draft, please reopen once comments are addressed.

@devill
devill marked this pull request as draft August 1, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Log plugin does not work on hooks, only on moves

2 participants