feat(events): record the client's stated reason on request events

SJ
6d ago
+535-20

Summary

  • Expo’s simulator session page wants to show the agent’s note for each action: what it is doing and why, or what it sees. Today, a note in meta is accepted but dropped. This adds an optional note string to DaemonRequestMeta and records it as details.note on request.started and request.finished, including error outcomes. action.recorded is unchanged.
  • This is a deliberate, opt-in exception to #1379’s rule that events omit client text. Notes are trimmed and bounded to 300 code points, with the same ellipsis behavior as the event label helper and their own limit; other labels keep 120. Absent, blank, and non-string values are omitted. The docs warn clients not to include secrets or personal data; Expo’s MCP server will send a note only when the agent provides one. Please say if you’d prefer a different shape.
  • The wire change is additive: released daemons ignore the unknown metadata key. The compatibility ledger and acknowledgment are updated.

Validation

Automated

Run locally on macOS with Node 26:

  • pnpm check:affected --base origin/main --run on the final commit: format, lint, typecheck, layering, fallow, build, and vitest-related checks passed. The unit lane passed 21,091 tests with one failure, a provider-revyl timing test that also fails on clean origin/main on this machine. Earlier wire-compatibility failures were fixed by the ledger update.
  • After the ledger fix, pnpm exec vitest run --project unit-core test/wire-compat passed all 51 tests.
  • Session-event-request and request-router-events tests passed, covering notes on started, finished, and error events; omitted invalid values; a 300-code-point note kept whole; and truncation at a code-point boundary with an emoji. A request-path test through createRequestHandler confirms the note reaches the session event log and fails against origin/main’s event builder.
  • pnpm typecheck, oxfmt --check and oxlint were clean on changed files.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.