Skip to content

feat(api): centralize session event log bridge#26

Merged
naory merged 3 commits intomainfrom
feat/session-event-log
Mar 8, 2026
Merged

feat(api): centralize session event log bridge#26
naory merged 3 commits intomainfrom
feat/session-event-log

Conversation

@naory
Copy link
Copy Markdown
Owner

@naory naory commented Mar 8, 2026

Summary

  • add a single emitSessionEvent() helper in the DB layer and route session timeline writes through it instead of scattered insert SQL
  • enforce minimal timeline scope for now by ingesting only five core lifecycle milestones: SESSION_CREATED, POLICY_GRANT_ISSUED, PAYMENT_DECISION_CREATED, SETTLEMENT_VERIFIED, SESSION_CLOSED
  • add a session timeline index migration for ordered /api/sessions/:id/timeline queries (session_id, created_at)

Test plan

  • pnpm --filter api test -- test/routes/sessions.test.ts test/routes/gate.test.ts test/stripeWebhook.test.ts

Made with Cursor

NAOR YUVAL added 2 commits March 8, 2026 14:45
Add a shared emitSessionEvent helper and route timeline writes through a single DB bridge while limiting session timeline ingestion to the five core lifecycle milestones.

Made-with: Cursor
Add central metadata enrichment for mirrored session lifecycle events so timeline records carry decision, policy, settlement, and location correlation identifiers for easier debugging. Include focused DB-level tests and keep timeline response shape minimal and stable.

Made-with: Cursor
@naory
Copy link
Copy Markdown
Owner Author

naory commented Mar 8, 2026

Updated this PR with correlation-id enrichment for mirrored session_events metadata.

Included identifiers (when available):

  • decisionId
  • policyHash
  • txHash
  • rail
  • asset
  • vehicleId
  • lotId

Also added focused tests in apps/api/test/db/queries.session-events.test.ts to lock in:

  • enrichment from inferred settlement/payload fields
  • precedence of payload-provided values over inferred values

Validation:

  • pnpm --filter api test -- test/db/queries.session-events.test.ts test/routes/sessions.test.ts
  • pnpm --filter api test -- test/routes/sessions.test.ts test/routes/gate.test.ts test/stripeWebhook.test.ts

Clarify that gate exit fails closed on any XRPL pending-intent persistence error, and add migration/normalizer notes so SQL trigger message changes stay synchronized with app-level error normalization.

Made-with: Cursor
@naory naory merged commit 5df00d2 into main Mar 8, 2026
1 check failed
@naory naory deleted the feat/session-event-log branch March 8, 2026 13:07
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