Skip to content

chore(host-papp): add console.info diagnostics for SSO request flow#156

Open
duewarn wants to merge 1 commit into
mainfrom
chore/host-papp-sso-flow-logs
Open

chore(host-papp): add console.info diagnostics for SSO request flow#156
duewarn wants to merge 1 commit into
mainfrom
chore/host-papp-sso-flow-logs

Conversation

@duewarn

@duewarn duewarn commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds structured logs across the lifecycle of a remote-signer request issued by userSession.

Logs added in userSession.ts

For each of signPayload / signRaw / getRingVrfAlias:

  • queueing in requestQueue on call entry (before pool admission)
  • task RUNNING — messageId=... when the inner queue task actually starts (queue admitted)
  • request submitted — waiting for response messageId=... after the request statement reaches chain
  • response RECEIVED — messageId=... when the matching response arrives
  • <method> filter] MATCH expected=... respondingTo=... from the per-call responseFilter on the exact statement that resolves the wait

withQueueTimeout logs the freed-queue event so a stuck signer doesn't fail silently.

Stale-message classification

subscribe(callback) now classifies each batch of incoming statements into:

  • relevantrespondingTo matches a messageId we are still waiting on (tracked in a module-level Set<string>)
  • stale — typically a response from a previous session that's still on bulletin paseo (statements retained ~7 days)

The header line reports both counts; details are only printed for the relevant subset. A freshly opened session that sees dozens of historical responses no longer produces a wall of text.

Handshake topic label

auth/impl.ts calls the optional globalThis.__registerStatementStoreTopicLabel hook with a handshake label, complementing the peer-incoming/self-outgoing labels registered by statement-store. A host-side wrapper around subscribeStatements can render readable subscription IDs from these labels (e.g. sub#1[handshake]).

Notes on shared state

pendingExpectedMessageIds is module-level (a single Set<string> shared by all sessions of the package). messageId values come from nanoid() and are unique across sessions, so the shared set has no risk of false positives even with several SSO sessions running.

Related

Test plan

  • vitest run packages/host-papp — 22 passed
  • Full project test suite — 388 passed
  • TypeScript build (nx run @novasamatech/host-papp:build) — clean

Adds structured logs across the lifecycle of a remote-signer request
issued by `userSession`:

- `signPayload` / `signRaw` / `getRingVrfAlias` each log on entry
  (`queueing in requestQueue`), when the inner queue task starts
  (`task RUNNING — messageId=...`), when the request statement has
  been submitted to chain (`request submitted — waiting for
  response`), and when a matching response arrives (`response
  RECEIVED`).

- The per-call `responseFilter` logs a single `MATCH` line on the
  exact statement that resolves the wait, instead of being silent.

- `subscribe(callback)` classifies each batch of incoming statements
  into "relevant" (responding to a messageId we are still waiting on)
  and "stale" (typically a response from a previous session, since
  bulletin paseo retains statements for ~7 days). The header line
  reports both counts; details are printed only for the relevant
  subset, so a freshly opened session that sees dozens of historical
  responses no longer produces a wall of text.

- `withQueueTimeout` logs the freed-queue event so a stuck signer
  doesn't fail silently.

- `auth/impl.ts` calls the optional
  `globalThis.__registerStatementStoreTopicLabel` hook with a
  `handshake` label for the handshake topic, complementing the
  `peer-incoming` / `self-outgoing` labels registered by
  statement-store (any host-side wrapper around `subscribeStatements`
  can render readable subscription IDs from these labels).

Tracking of pending message ids is module-level (single `Set<string>`
shared by all sessions of the package). `messageId` values come from
`nanoid()` and are unique across sessions, so the shared set has no
risk of false positives even with several SSO sessions running.

No behaviour change.
@duewarn duewarn requested a review from johnthecat May 5, 2026 18:29
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