Skip to content

chore(statement-store): add console.info diagnostics for batch and submit lifecycle#155

Open
duewarn wants to merge 1 commit into
mainfrom
chore/statement-store-session-logs
Open

chore(statement-store): add console.info diagnostics for batch and submit lifecycle#155
duewarn wants to merge 1 commit into
mainfrom
chore/statement-store-session-logs

Conversation

@duewarn

@duewarn duewarn commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds structured logs at the four observable transitions of an outgoing batch and the response-arrival path.

Logs added

  • outgoing batch START — 1 message (no pending) — fresh batch created
  • outgoing batch APPEND — N messages now (previous batch had no response yet) — new message piggybacks on an unacknowledged batch
  • outgoing batch FULL — message queued, N in queue — message parked waiting for current batch to settle
  • response received — N pending message(s) in batch will be resolved — response statement matches the current outgoing batch

Topic-label hook

Adds an optional globalThis.__registerStatementStoreTopicLabel hook called from ensureStoreSubscription with peer-incoming and self-outgoing labels for the session's incoming and outgoing topics. A host app that wraps subscribeStatements for diagnostics can render readable subscription IDs (e.g. sub#1[peer-incoming]) from these labels. The hook is undefined by default; host apps that don't install it are unaffected.

Related

Test plan

  • vitest run packages/statement-store — 29 passed
  • Full project test suite — 388 passed

…bmit lifecycle

Adds structured logs at the four observable transitions of an outgoing
batch and the response-arrival path:

- `outgoing batch START — 1 message (no pending)` when a fresh batch is
  created.
- `outgoing batch APPEND — N messages now (previous batch had no
  response yet)` when a new message piggybacks on an unacknowledged
  batch (peer hasn't ACKed yet) and the whole thing is re-submitted
  under a new requestId.
- `outgoing batch FULL — message queued, N in queue` when the new
  message would push the batch past `maxRequestSize` and gets parked
  in the queue until the current batch settles.
- `response received — N pending message(s) in batch will be resolved`
  when a response statement matches the current outgoing batch and
  pending deliveries are about to fire.

Adds an optional `globalThis.__registerStatementStoreTopicLabel` hook
called from `ensureStoreSubscription` with `peer-incoming` and
`self-outgoing` labels for the session's incoming and outgoing topics.
A host app that wraps `subscribeStatements` for diagnostics can use
these labels to render readable subscription IDs instead of opaque hex.
The hook is undefined by default; host apps that don't install it are
unaffected.

No behaviour change. Useful when triaging slow/dropped peer responses
on a session.
@duewarn duewarn requested a review from johnthecat May 5, 2026 18:28
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.

1 participant