Skip to content

feat(audit): HTTP correlation-id ingress directive + tapir input (Sto…#10

Merged
fupelaqu merged 5 commits into
mainfrom
feature/audit
Jun 14, 2026
Merged

feat(audit): HTTP correlation-id ingress directive + tapir input (Sto…#10
fupelaqu merged 5 commits into
mainfrom
feature/audit

Conversation

@fupelaqu

Copy link
Copy Markdown
Contributor

…ry 13.7 Phase B gate #1)

HttpCorrelation.withCorrelation — an akka-http directive (mirrors HttpMetrics.withMetrics, applied at the same ApiRoutes.mainRoutes attach point) that extracts-or-generates X-Correlation-Id, MDC-stamps the synchronous request thread (operational stdout), re-injects the canonical id onto the request so downstream tapir reads the same value, and echoes it on the response.

HttpCorrelation.correlationInput — a reusable tapir EndpointInput[Option[String]] (extractFromRequest) so serverLogic receives the id as DATA and threads it onto the command (AuditableCommand.withCorrelationId) on the request thread, never an MDC read across the Future (C14). Builds on the Auditable/AuditableCommand/AuditableEvent carriers plus withCid already promoted in b4d0ee1.

Bumps tapir 1.7.0->1.8.5, tapirHttpSession 0.2.0->0.3.0, logback 1.2.3->1.4.14, slf4j. HttpCorrelationSpec (7 tests, incl. end-to-end tapir serverLogic delivery) and HttpMetricsSpec green; +server/compile (2.12+2.13) and scalafmtAll clean.

…ry 13.7 Phase B gate #1)

HttpCorrelation.withCorrelation — an akka-http directive (mirrors HttpMetrics.withMetrics,
applied at the same ApiRoutes.mainRoutes attach point) that extracts-or-generates
X-Correlation-Id, MDC-stamps the synchronous request thread (operational stdout),
re-injects the canonical id onto the request so downstream tapir reads the same value,
and echoes it on the response.

HttpCorrelation.correlationInput — a reusable tapir EndpointInput[Option[String]]
(extractFromRequest) so serverLogic receives the id as DATA and threads it onto the
command (AuditableCommand.withCorrelationId) on the request thread, never an MDC read
across the Future (C14). Builds on the Auditable/AuditableCommand/AuditableEvent carriers
plus withCid already promoted in b4d0ee1.

Bumps tapir 1.7.0->1.8.5, tapirHttpSession 0.2.0->0.3.0, logback 1.2.3->1.4.14, slf4j.
HttpCorrelationSpec (7 tests, incl. end-to-end tapir serverLogic delivery) and HttpMetricsSpec
green; +server/compile (2.12+2.13) and scalafmtAll clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Jun 14, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 6 complexity · 0 duplication

Metric Results
Complexity 6
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.22%. Comparing base (b4d0ee1) to head (839ef3c).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...a/app/softnetwork/persistence/audit/AuditLog.scala 84.61% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #10      +/-   ##
==========================================
+ Coverage   60.94%   61.22%   +0.27%     
==========================================
  Files          94       95       +1     
  Lines        1836     1849      +13     
==========================================
+ Hits         1119     1132      +13     
  Misses        717      717              
Flag Coverage Δ
unittests 61.22% <84.61%> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

fupelaqu and others added 4 commits June 14, 2026 07:33
…#1)

Generic structured audit logger in core (co-located with the Auditable/AuditableEvent carriers) so every pod (licensing/notification/payment/scheduler) reuses one helper instead of an in-repo copy.

One FIXED shared logger name app.softnetwork.audit -> a single additivity=false route in the shared logback.xml template; each pod still writes its own pod-local audit.log; the service field (per-eventType resolver, or a fixed value) distinguishes domains at query time. correlationId stays explicit data (never MDC across the async path, C2).

Adds logstash-logback-encoder 8.1 to core (StructuredArguments.kv). AuditLogSpec (3 tests via logback ListAppender) green; +core/compile (2.12+2.13) + scalafmtAll clean. Also folds the ApiRoutes unused-import cleanup from gate #1.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…cho at the endpoint layer)

correlationInput now yields String, generating a default cid when the header is absent, so serverLogic always receives a non-empty id (no None handling downstream).

Endpoint.endpointsToRoute wraps the interpreted tapir route with withCorrelation, so every endpoint set generates-or-extracts the id, feeds correlationInput and echoes it on the response even when mounted outside mainRoutes. withCorrelation is now re-entrant (does not clobber an outer MDC scope; echoes only if the response has no header) so nesting under mainRoutes stays a single header + one MDC scope.

HttpCorrelationSpec: +self-sufficiency test (no outer directive: default generated, delivered to serverLogic, echoed) and +re-entrancy test (single echoed header). 13 server tests green; +server/compile (2.12+2.13) + scalafmtAll clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@fupelaqu fupelaqu merged commit 1885a22 into main Jun 14, 2026
5 checks passed
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