Files
correx/apps/server/build.gradle
T
kami a7d5211f3f feat(server,logging): correlation-structured MDC logging at seams
Implement T1 of observability epic: every server log line carries sessionId
(and stageId where known) via SLF4J MDC, propagated across coroutine
suspension points.

Changes:
- Create com.correx.apps.server.logging.Correlation: withSessionContext()
  helper that sets MDC (sessionId, stageId), wraps block in MDCContext(),
  and restores prior values on exit; supports safe nesting
- Wrap launchSessionRun() orchestrator loop in withSessionContext(sessionId)
  so all session logs carry the sessionId
- Wrap GlobalStreamHandler ChatInput and StartChatSession onUserInput call
  sites in withSessionContext(sessionId)
- Wrap SessionStreamHandler ChatInput onUserInput in withSessionContext(sessionId)
- Update log4j2.properties patterns: append
  %notEmpty{ [%X{sessionId}]}%notEmpty{ [%X{stageId}]} before %msg
  on both console and file appenders
- Add kotlinx-coroutines-slf4j:1.9.0 dependency for MDCContext

Test (6 tests):
- withSessionContext sets/restores sessionId ✓
- withSessionContext sets/restores stageId ✓
- Nested contexts stack and restore correctly ✓
- MDC cleared when stageId not provided ✓
- Propagation across coroutine boundaries via MDCContext ✓
- Cleanup after block exit ✓

Acceptance:
- Zero behavior change; no core module touched ✓
- All imports verified as used ✓
- No bare try-catch; try/finally used correctly ✓
- Detekt-compliant ✓
- Full test suite passes (120 tests, 119 passed, 1 skipped) ✓
2026-06-12 14:17:54 +04:00

69 lines
2.8 KiB
Groovy

plugins {
id 'org.jetbrains.kotlin.jvm'
id 'org.jetbrains.kotlin.plugin.serialization'
id 'application'
}
application {
mainClass = 'com.correx.apps.server.MainKt'
}
tasks.named('distTar') {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.named('distZip') {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
dependencies {
implementation project(':core:config')
implementation project(':core:events')
implementation project(':core:approvals')
implementation project(':core:sessions')
implementation project(':core:kernel')
implementation project(':core:journal')
implementation project(':core:inference')
implementation project(':core:transitions')
implementation project(':core:context')
implementation project(':core:validation')
implementation project(':core:risk')
implementation project(':core:artifacts')
implementation project(':core:artifacts-store')
implementation project(':infrastructure')
implementation project(':infrastructure:artifacts-cas')
implementation project(':infrastructure:workflow')
implementation project(':infrastructure:persistence')
implementation project(':infrastructure:inference')
implementation project(':infrastructure:inference:llama_cpp')
implementation project(':infrastructure:inference:commons')
implementation project(':core:router')
implementation project(':core:tools')
implementation project(':core:toolintent')
implementation project(':infrastructure:tools')
implementation project(':infrastructure:tools:filesystem')
implementation "com.github.ajalt.clikt:clikt:5.0.1"
implementation "io.ktor:ktor-client-cio:$ktor_version"
implementation "io.ktor:ktor-client-logging:$ktor_version"
implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "io.ktor:ktor-server-websockets:$ktor_version"
implementation "io.ktor:ktor-server-content-negotiation:$ktor_version"
implementation "io.ktor:ktor-serialization-kotlinx-json:$ktor_version"
implementation "io.ktor:ktor-server-status-pages:$ktor_version"
implementation "io.ktor:ktor-server-call-logging:$ktor_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinx_coroutines_version"
testImplementation "io.ktor:ktor-server-test-host:$ktor_version"
testImplementation "io.ktor:ktor-client-websockets:$ktor_version"
testImplementation "io.ktor:ktor-client-mock:$ktor_version"
implementation "org.apache.logging.log4j:log4j-core:2.24.1"
implementation "org.apache.logging.log4j:log4j-slf4j2-impl:2.24.1"
implementation "org.slf4j:slf4j-api:2.0.16"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.9.0"
}
tasks.named("koverVerify").configure { enabled = false }