docs(acm2-75): 按需求与架构收口契约和规范

补齐接口契约的入站、Redis 与出站边界,规范对齐已定语义并作废过期条款;Kafka 生产端约束编号改为 D2。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
windyboy
2026-09-16 08:49:19 +08:00
co-authored by Cursor
parent 7cd17409f5
commit fd65bb24fb
12 changed files with 327 additions and 266 deletions
@@ -5,7 +5,7 @@ import io.micronaut.context.annotation.Value
import jakarta.inject.Singleton
/**
* D3 启动自检:Kafka 生产者的 acks / enable-idempotence / max-in-flight 三项
* D2 启动自检:Kafka 生产者的 acks / enable-idempotence / max-in-flight 三项
* 必须联合满足幂等生产前提。不满足时拒绝启动——静默放行会让幂等保证在运行时失效。
*
* 独立于 `PipelineLifecycle`(受 autostart 开关控制),无条件执行。
@@ -23,13 +23,13 @@ class KafkaD3Check(
fun validate() {
require(acks == "all" || acks == "-1") {
"D3 violation: kafka.producers.default.acks must be 'all', got '$acks'"
"D2 violation: kafka.producers.default.acks must be 'all', got '$acks'"
}
require(idempotence) {
"D3 violation: kafka.producers.default.enable-idempotence must be true, got $idempotence"
"D2 violation: kafka.producers.default.enable-idempotence must be true, got $idempotence"
}
require(maxInFlight == 1) {
"D3 violation: kafka.producers.default.max-in-flight-requests-per-connection must be 1, got $maxInFlight"
"D2 violation: kafka.producers.default.max-in-flight-requests-per-connection must be 1, got $maxInFlight"
}
}
@@ -9,7 +9,7 @@ import org.apache.kafka.clients.producer.Producer
import org.apache.kafka.clients.producer.ProducerRecord
/**
* Kafka 真实投递端口:通过 [ProducerRegistry] 拿 default 生产者,D3 参数
* Kafka 真实投递端口:通过 [ProducerRegistry] 拿 default 生产者,D2 参数
* acks=all / enable-idempotence=true / max-in-flight=1)由 `KafkaD3Check` 启动自检。
*
* 发送同步等 broker 确认(`Future.get()`),语义是至少一次——满足 INV-10 / C-29。
+1 -1
View File
@@ -96,7 +96,7 @@ kafka:
servers: ${MSGX_KAFKA_SERVERS}
producers:
default: # U03/R09Micronaut Kafka 按具名 producer 解析,须有 default 层
# D3acks=all + 幂等 + max-in-flight=1 联合保证幂等生产;
# D2acks=all + 幂等 + max-in-flight=1 联合保证幂等生产;
# 若对接旧版 Broker(如现网 0.10.x/1.x,无 INIT_PRODUCER_ID 协议),
# 三项须同时降级为 MSGX_KAFKA_ACKS=1 / MSGX_KAFKA_IDEMPOTENCE=false / MSGX_KAFKA_MAX_IN_FLIGHT=1。
acks: ${MSGX_KAFKA_ACKS:all}
@@ -7,12 +7,12 @@ import org.junit.jupiter.api.Test
class KafkaD3CheckTest {
@Test
fun `default config satisfies D3`() {
fun `default config satisfies D2`() {
assertDoesNotThrow { KafkaD3Check(acks = "all", idempotence = "true", maxInFlight = "1") }
}
@Test
fun `acks=-1 also satisfies D3`() {
fun `acks=-1 also satisfies D2`() {
assertDoesNotThrow { KafkaD3Check(acks = "-1", idempotence = "true", maxInFlight = "1") }
}