Description
Several routes import getCorrelationContext from app/lib/logger.ts but never use it (e.g. start, pause, settle import it yet log nothing structured), so logs lack the correlation_id/stream_id propagation the project's logging story promises. Wire structured, correlated logging through every lifecycle route. This is a backend observability task.
Requirements and Context
- Emit structured
logger.info/warn/error entries on each lifecycle action with correlation_id, stream_id, action, and resulting status.
- Remove the unused
getCorrelationContext imports or actually consume them; ensure correlation-middleware.ts context is in scope.
- Redact secrets/PII per
app/lib/privacy.ts and the README secret-redaction policy.
- Must be secure, tested, and documented
- Should be efficient and easy to review
Suggested Execution
- Fork the repo and create a branch
git checkout -b task/correlated-lifecycle-logging
- Implement changes
app/api/streams/[id]/{start,pause,stop,settle,withdraw}/route.ts
- Reuse
app/lib/logger.ts and app/lib/correlation-middleware.ts
- Test and commit
npm test -- app/lib/logger.test.ts app/lib/correlation-middleware.test.ts
- Cover edge cases: correlation_id present in logs, redaction of recipient PII
- Include test output and notes in the PR
Example commit message
task: propagate correlation and stream ids in lifecycle logs
Acceptance Criteria
Guidelines
- Minimum 90% test coverage including redaction
- Clear documentation and inline comments
- Timeframe: 96 hours
Description
Several routes import
getCorrelationContextfromapp/lib/logger.tsbut never use it (e.g.start,pause,settleimport it yet log nothing structured), so logs lack thecorrelation_id/stream_idpropagation the project's logging story promises. Wire structured, correlated logging through every lifecycle route. This is a backend observability task.Requirements and Context
logger.info/warn/errorentries on each lifecycle action withcorrelation_id,stream_id, action, and resulting status.getCorrelationContextimports or actually consume them; ensurecorrelation-middleware.tscontext is in scope.app/lib/privacy.tsand the README secret-redaction policy.Suggested Execution
app/api/streams/[id]/{start,pause,stop,settle,withdraw}/route.tsapp/lib/logger.tsandapp/lib/correlation-middleware.tsnpm test -- app/lib/logger.test.ts app/lib/correlation-middleware.test.tsExample commit message
Acceptance Criteria
correlation_id+stream_idGuidelines