Skip to content

feat(errors,tracing,audit,auth): structured error taxonomy, distributed tracing, encrypted audit logging, token rotation#684

Merged
temma02 merged 1 commit into
StellerCraft:mainfrom
ambermartin681:feat/issues-589-590-591-592-error-tracing-audit-rotation
May 28, 2026
Merged

feat(errors,tracing,audit,auth): structured error taxonomy, distributed tracing, encrypted audit logging, token rotation#684
temma02 merged 1 commit into
StellerCraft:mainfrom
ambermartin681:feat/issues-589-590-591-592-error-tracing-audit-rotation

Conversation

@ambermartin681
Copy link
Copy Markdown
Contributor

@ambermartin681 ambermartin681 commented May 28, 2026

closes #589
closes #590
closes #591
closes #592

Summary

Test plan

  • handleApiError returns the correct HTTP status and code for each AppError variant
  • No route returns an unclassified 500 — all errors flow through handleApiError
  • startTrace() produces a valid W3C traceparent; newSpan() preserves the traceId
  • Each deployment pipeline stage log entry includes traceId and durationMs
  • AuditLogService.log() writes an encrypted row; decrypting recovers the original payload
  • rotateIfExpiringSoon() skips rotation when expiry is far away; triggers when within 1 h
  • _revokeGitHubToken() is called with the old plaintext token after a successful rotation

🤖 Generated with Claude Code

… distributed tracing, encrypted audit logging, and token rotation

Closes StellerCraft#589 StellerCraft#590 StellerCraft#591 StellerCraft#592

- Extend packages/types/src/errors.ts with ErrorCode, ErrorCategory, ApiErrorResponse, and ERROR_CODE_META lookup table across validation/auth/external/internal categories
- Add apps/backend/src/lib/api/error-handler.ts with AppError class and handleApiError() centralised handler mapping all thrown errors to typed NextResponse payloads
- Document full error taxonomy with stable code enum in apps/backend/openapi.yaml Error schema
- Add apps/backend/src/lib/tracing.ts with W3C traceparent utilities (startTrace, newSpan, withSpan, parseTraceparent)
- Instrument GitHub-to-Vercel deployment pipeline with per-stage spans and traceId propagation through all log entries and result objects
- Add docs/tracing-architecture.md documenting the tracing design
- Add apps/backend/src/services/audit-log.service.ts with AES-256-GCM encrypted audit log payloads for sensitive config mutations (tokens, billing, domains)
- Extend github-credential.service.ts with rotateIfExpiringSoon() (proactive rotation 1h before expiry with exponential-backoff retry), revokeToken() (GitHub OAuth token revocation), and rotation metadata storage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@ambermartin681 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@temma02 temma02 merged commit ae4f0dd into StellerCraft:main May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants