Files
document-haness/docs/clean-architecture-backend-template/final/evidence/meta/a06-f003-change-streams-true-probe.json
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

15 lines
9.3 KiB
JSON

{
"assetKey": "a06-f003-change-streams-true-probe",
"kind": "terminal",
"command": "set -e\nD=$(mktemp -d)\ntrap 'docker rm -f cs-standalone >/dev/null 2>&1; rm -rf \"$D\"' EXIT\n\ndocker rm -f cs-standalone >/dev/null 2>&1 || true\ndocker run -d --name cs-standalone --network container:workmachine \\\n mongo:8.0.16 --port 57017 --bind_ip 127.0.0.1 >/dev/null\nfor i in $(seq 1 60); do\n docker exec cs-standalone mongosh --port 57017 --quiet \\\n --eval 'db.runCommand({ping:1}).ok' 2>/dev/null | grep -q 1 && break\n sleep 1\ndone\n\ncat > \"$D/ChangeStreamProbe.java\" <<'JAVA'\nimport com.mongodb.MongoException;\nimport com.mongodb.reactivestreams.client.MongoClients;\nimport dev.caskeleton.adapter.outbound.mongo.api.capability.MongoCapability;\nimport dev.caskeleton.adapter.outbound.mongo.api.capability.MongoCapabilitySet;\nimport dev.caskeleton.adapter.outbound.mongo.api.profile.MongoTopology;\nimport dev.caskeleton.adapter.outbound.mongo.api.schema.MongoSchemaVersionRange;\nimport dev.caskeleton.adapter.outbound.mongo.autoconfigure.MongoPlatformSettings;\nimport dev.caskeleton.adapter.outbound.mongo.autoconfigure.MongoStartupValidator;\nimport dev.caskeleton.adapter.outbound.mongo.autoconfigure.MongoTopologyProbe;\nimport dev.caskeleton.adapter.outbound.mongo.changestream.MongoChangeStreamSubscription;\nimport dev.caskeleton.adapter.outbound.mongo.changestream.consumer.SpringReactiveChangeStreamSource;\nimport dev.caskeleton.adapter.outbound.mongo.changestream.recovery.MongoChangeStreamRecoveryPolicy;\nimport dev.caskeleton.adapter.outbound.mongo.failure.MongoDriverFailureView;\nimport dev.caskeleton.adapter.outbound.mongo.imperative.MongoCollectionProfileRegistry;\nimport dev.caskeleton.adapter.outbound.mongo.security.MongoCredentialReference;\nimport dev.caskeleton.adapter.outbound.mongo.security.MongoPrincipalRole;\nimport dev.caskeleton.adapter.outbound.mongo.security.MongoSecurityProfile;\nimport java.time.Duration;\nimport java.util.Map;\nimport java.util.Optional;\nimport java.util.Set;\nimport org.bson.Document;\nimport org.springframework.boot.context.properties.bind.Binder;\nimport org.springframework.boot.context.properties.source.MapConfigurationPropertySource;\nimport org.springframework.data.mongodb.core.ReactiveMongoTemplate;\nimport org.springframework.data.mongodb.core.SimpleReactiveMongoDatabaseFactory;\n\npublic final class ChangeStreamProbe {\n\n private static final String PREFIX = \"ca-skeleton.persistence-mongo.platform\";\n\n private static final MongoCredentialReference RUNTIME =\n new MongoCredentialReference(\"secret://mongodb/app-write\", MongoPrincipalRole.APP_WRITE);\n\n private static final MongoCredentialReference ADMIN =\n new MongoCredentialReference(\"secret://mongodb/admin\", MongoPrincipalRole.DBA);\n\n public static void main(String[] args) {\n System.out.println(\"[바인딩] 같은 컴팩트 생성자에 들어가는 세 입력\");\n show(\"transactions\", \"true\");\n show(\"change-streams\", \"true\");\n show(\"required-secondaries\", \"-1\");\n System.out.println();\n\n ReactiveMongoTemplate template =\n new ReactiveMongoTemplate(\n new SimpleReactiveMongoDatabaseFactory(MongoClients.create(args[0]), \"probe\"));\n\n Document hello = template.executeCommand(new Document(\"hello\", 1)).block();\n MongoTopology observed =\n hello.containsKey(\"setName\")\n ? MongoTopology.REPLICA_SET\n : \"isdbgrid\".equals(hello.getString(\"msg\"))\n ? MongoTopology.SHARDED\n : MongoTopology.STANDALONE;\n String version =\n template.executeCommand(new Document(\"buildInfo\", 1)).block().getString(\"version\");\n\n MongoTopologyProbe probe = new MongoTopologyProbe(observed, version, 0);\n MongoCapabilitySet capabilities = probe.capabilities();\n System.out.println(\"서버 : mongod \" + version + \", 관측 토폴로지 \" + observed);\n System.out.println(\n \"CHANGE_STREAM : isStable=\" + capabilities.isStable(MongoCapability.CHANGE_STREAM));\n System.out.println(\n \" 사유 : \" + capabilities.require(MongoCapability.CHANGE_STREAM).constraints());\n\n MongoPlatformSettings bound =\n new Binder(new MapConfigurationPropertySource(Map.of(PREFIX + \".change-streams\", \"true\")))\n .bind(PREFIX, MongoPlatformSettings.class)\n .get();\n\n System.out.println();\n System.out.println(\"[출하 배선] MongoStartupValidator(..., properties.changeStreams())\");\n System.out.println(\" validate() -> \" + outcome(validator(bound, probe, bound.changeStreams())));\n System.out.println(\"[시험 배선] MongoStartupValidator(..., true)\");\n System.out.println(\" validate() -> \" + outcome(validator(bound, probe, true)));\n\n template.getCollection(\"events\").flatMap(c -> reactor.core.publisher.Mono.from(\n c.insertOne(new Document(\"seed\", 1)))).block();\n MongoCollectionProfileRegistry collections =\n MongoCollectionProfileRegistry.builder().register(\"events\", \"events\").build();\n System.out.println();\n System.out.println(\"[source 직접 생성] SpringReactiveChangeStreamSource.open()\");\n try {\n new SpringReactiveChangeStreamSource(template, collections)\n .open(MongoChangeStreamSubscription.of(\"probe\", \"events\"), Optional.empty())\n .blockFirst(Duration.ofSeconds(15));\n System.out.println(\" -> 커서 열림\");\n } catch (RuntimeException failure) {\n Throwable root = failure;\n while (root.getCause() != null) {\n root = root.getCause();\n }\n System.out.println(\" -> \" + root.getClass().getSimpleName());\n System.out.println(\" \" + root.getMessage().split(\"\\n\")[0]);\n if (root instanceof MongoException driverFailure) {\n System.out.println();\n System.out.println(\"[복구 정책] MongoChangeStreamRecoveryPolicy.onFailure(...)\");\n System.out.println(\n \" -> \"\n + new MongoChangeStreamRecoveryPolicy()\n .onFailure(MongoDriverFailureView.from(driverFailure)));\n }\n }\n System.exit(0);\n }\n\n private static void show(String key, String value) {\n try {\n MongoPlatformSettings bound =\n new Binder(new MapConfigurationPropertySource(Map.of(PREFIX + \".\" + key, value)))\n .bind(PREFIX, MongoPlatformSettings.class)\n .get();\n System.out.println(\n \" \"\n + (key + \"=\" + value + \" \").substring(0, 28)\n + \"바인딩 성공, transactions=\"\n + bound.transactions()\n + \" changeStreams=\"\n + bound.changeStreams()\n + \" requiredSecondaries=\"\n + bound.requiredSecondaries());\n } catch (RuntimeException failure) {\n Throwable root = failure;\n while (root.getCause() != null) {\n root = root.getCause();\n }\n System.out.println(\n \" \"\n + (key + \"=\" + value + \" \").substring(0, 28)\n + \"바인딩 실패, \"\n + root.getClass().getSimpleName()\n + \": \"\n + root.getMessage().split(\" \\\\[\")[0]);\n }\n }\n\n private static MongoStartupValidator validator(\n MongoPlatformSettings settings, MongoTopologyProbe probe, boolean changeStreamsEnabled) {\n return new MongoStartupValidator(\n settings,\n probe,\n MongoSecurityProfile.production(RUNTIME, Set.of()),\n ADMIN,\n settings.transactions(),\n changeStreamsEnabled,\n MongoSchemaVersionRange.of(1, 3));\n }\n\n private static String outcome(MongoStartupValidator validator) {\n try {\n validator.validate();\n return \"통과\";\n } catch (RuntimeException rejected) {\n return rejected.getClass().getSimpleName() + \": \" + rejected.getMessage().split(\" \\\\[\")[0];\n }\n }\n}\nJAVA\n\nCACHE=/root/.gradle/caches/modules-2/files-2.1\nLOCK=src/adapter/outbound/persistence-mongo/gradle.lockfile\nCP=src/adapter/outbound/persistence-mongo/build/classes/java/main\nwhile IFS= read -r line; do\n coord=${line%%=*}; confs=${line#*=}\n case \",$confs,\" in *\",testRuntimeClasspath,\"*) ;; *) continue ;; esac\n g=${coord%%:*}; r=${coord#*:}; n=${r%%:*}; v=${r##*:}\n jar=$(find \"$CACHE/$g/$n/$v\" -name '*.jar' ! -name '*sources*' ! -name '*javadoc*' 2>/dev/null | head -1)\n [ -n \"$jar\" ] && CP=\"$CP:$jar\"\ndone < <(grep -E '^[a-zA-Z0-9._-]+:[^=]+=' \"$LOCK\")\n\njavac -encoding UTF-8 -cp \"$CP\" -d \"$D\" \"$D/ChangeStreamProbe.java\"\njava -Dstdout.encoding=UTF-8 -cp \"$D:$CP\" ChangeStreamProbe mongodb://127.0.0.1:57017/probe 2>&1 \\\n | grep -vE '^[0-9]{2}:[0-9]{2}:[0-9]{2}[.][0-9]{3} ' ",
"cwd": "/shared/codebase/clean-architecture-backend-template",
"exitCode": 0,
"executedAt": "2026-09-02T06:56:08+00:00",
"sourceRevision": "21234e38cdb9a926cbc92bb97a2aee2e4a7d2916",
"raw": "evidence/raw/a06-f003-change-streams-true-probe.txt",
"svg": "evidence/rendered/a06-f003-change-streams-true-probe.svg",
"rawSha256": "4582c01754321fa9a80a59f27a6bef198c56e4d4cdb584496bbead8c591fe775",
"lines": 20,
"redaction": "SVG 렌더러가 secret: 로 시작하는 자격증명 참조 문자열을 가렸다 — 탐침 소스의 리터럴이고 실제 비밀값이 아니다"
}