Files
document-haness/docs/clean-architecture-backend-template/final/evidence/rendered/a05-f021-complete-replayttl-postgres.svg
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

125 lines
11 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1382" viewBox="0 0 1200 1382" role="img">
<title>terminal evidence</title>
<desc>Terminal-style rendering generated from retained command output. Sensitive-looking values are redacted in the visual asset.</desc>
<rect x="1" y="1" width="1198" height="1380" rx="14" fill="#0d1117" stroke="#30363d"/>
<rect x="1" y="1" width="1198" height="44" rx="14" fill="#161b22"/>
<rect x="1" y="30" width="1198" height="14" fill="#161b22"/>
<circle cx="24" cy="22" r="6" fill="#ff5f57"/>
<circle cx="44" cy="22" r="6" fill="#febc2e"/>
<circle cx="64" cy="22" r="6" fill="#28c840"/>
<text x="92" y="27" fill="#8b949e" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace">terminal evidence</text>
<text x="24" y="68" fill="#c9d1d9" font-size="15" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">$ set -e
mkdir -p /tmp/probe
CT=complete-ttl-probe
docker rm -f &quot;$CT&quot; &gt;/dev/null 2&gt;&amp;1 || true
docker run -d --name &quot;$CT&quot;</tspan><tspan x="24" dy="22"> --network &quot;container:workmachine&quot; \
-e POSTGRES_PASSWORD=probe -e POSTGRES_USER=probe -e POSTGRES_DB=probe \
postgr</tspan><tspan x="24" dy="22">es:16-alpine -p 55432 &gt;/dev/null
for i in $(seq 1 40); do docker exec &quot;$CT&quot; pg_isready -U probe -p 55432 &gt;/dev/null 2&gt;&amp;1</tspan><tspan x="24" dy="22"> &amp;&amp; break; sleep 1; done
docker exec &quot;$CT&quot; psql -U probe -p 55432 -d probe -tAc &#x27;select version()&#x27; | cut -c1-24
M=adapte</tspan><tspan x="24" dy="22">r/outbound/persistence-jpa/src/main/resources/db/migration
for d in postgresql jpa/core jpa/idempotency; do
for f in &quot;</tspan><tspan x="24" dy="22">$M/$d&quot;/V*.sql; do
docker exec -i &quot;$CT&quot; psql -U probe -p 55432 -d probe -q &lt; &quot;$f&quot; &gt;/dev/null 2&gt;&amp;1 || true
done
done</tspan><tspan x="24" dy="22">
echo
echo &#x27;# 같은 연산·같은 응답에 재생 창만 바꿔 완료를 두 번 부른다&#x27;
cat &gt; /tmp/probe/cp.sh &lt;&lt;&#x27;CPSH&#x27;
# 락파일의 한 </tspan><tspan x="24" dy="22">구성에 실린 좌표 전부를 캐시 경로로 바꾼다. Gradle 실행 없이 재현된다.
LOCK=${1:-adapter/outbound/persistence-jpa/gradle</tspan><tspan x="24" dy="22">.lockfile}
CONF=${2:-postgresqlIntegrationTestRuntimeClasspath}
CACHE=/root/.gradle/caches/modules-2/files-2.1
cp=&quot;&quot;
whi</tspan><tspan x="24" dy="22">le IFS= read -r line; do
coord=${line%%=*}; confs=${line#*=}
case &quot;,$confs,&quot; in *&quot;,$CONF,&quot;*) ;; *) continue ;; esac
</tspan><tspan x="24" dy="22"> group=${coord%%:*}; rest=${coord#*:}; name=${rest%%:*}; ver=${rest##*:}
jar=$(find &quot;$CACHE/$group/$name/$ver&quot; -name </tspan><tspan x="24" dy="22">&#x27;*.jar&#x27; ! -name &#x27;*sources*&#x27; ! -name &#x27;*javadoc*&#x27; 2&gt;/dev/null | head -1)
[ -n &quot;$jar&quot; ] &amp;&amp; cp=&quot;$cp:$jar&quot;
done &lt; &lt;(grep -E</tspan><tspan x="24" dy="22"> &#x27;^[a-zA-Z0-9._-]+:[^=]+=&#x27; &quot;$LOCK&quot;)
echo &quot;${cp#:}&quot;
CPSH
cat &gt; /tmp/probe/CompleteTtlProbe.java &lt;&lt;&#x27;JAVA&#x27;
import dev.caske</tspan><tspan x="24" dy="22">leton.application.idempotency.RequestFingerprint;
import dev.caskeleton.application.idempotency.StoredResponse;
import d</tspan><tspan x="24" dy="22">ev.caskeleton.application.idempotency.v2.*;
import dev.caskeleton.application.transaction.OperationId;
import dev.caskel</tspan><tspan x="24" dy="22">eton.adapter.outbound.persistence.postgresql.idempotency.PostgreSqlOwnerSafeIdempotencyStore;
import java.time.Duration;</tspan><tspan x="24" dy="22">
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionMana</tspan><tspan x="24" dy="22">ger;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.transaction.support.T</tspan><tspan x="24" dy="22">ransactionTemplate;
/** 같은 연산·같은 응답에 재생 창만 바꿔 완료를 두 번 부른다. */
public class CompleteTtlProbe {
</tspan><tspan x="24" dy="22"> public static void main(String[] args) throws Exception {
var dataSource = new SimpleDriverDataSource(
(ja</tspan><tspan x="24" dy="22">va.sql.Driver) Class.forName(&quot;org.postgresql.Driver&quot;).getDeclaredConstructor().newInstance(),
&quot;jdbc:postgresql:/</tspan><tspan x="24" dy="22">/127.0.0.1:55432/probe&quot;, &quot;probe&quot;, &quot;probe&quot;);
var jdbc = new JdbcTemplate(dataSource);
var transactions = new Tran</tspan><tspan x="24" dy="22">sactionTemplate(new DataSourceTransactionManager(dataSource));
var store = new PostgreSqlOwnerSafeIdempotencyStore(j</tspan><tspan x="24" dy="22">dbc);
jdbc.update(&quot;update capability_schema_registry set lifecycle_state = &#x27;ACTIVE&#x27; &quot;
+ &quot;where capability_i</tspan><tspan x="24" dy="22">d = &#x27;jpa-idempotency-owner-safe-v2&#x27;&quot;);
jdbc.update(&quot;delete from idempotency_record&quot;);
var scope = new Idempoten</tspan><tspan x="24" dy="22">cyScopeDigest(&quot;b&quot;.repeat(64), 1, &quot;PROBE&quot;);
var fingerprint = RequestFingerprint.ofSha256(&quot;probe-request&quot;.getBytes())</tspan><tspan x="24" dy="22">;
var attempt = new IdempotencyClaimAttempt(&quot;1&quot;.repeat(64), new OperationId(&quot;op-1&quot;));
var request = new Idempote</tspan><tspan x="24" dy="22">ncyClaimRequest(
scope, fingerprint, attempt, Duration.ofMinutes(5), Duration.ofHours(1), &quot;json.v1&quot;, 2);
var</tspan><tspan x="24" dy="22"> response = new StoredResponse(&quot;{\&quot;v\&quot;:\&quot;SAME\&quot;}&quot;);
transactions.executeWithoutResult(status -&gt; {
var owner =</tspan><tspan x="24" dy="22"> ((IdempotencyClaimOutcome.Acquired) store.claim(request)).owner();
var started = store.markExecutionStarted(owner</tspan><tspan x="24" dy="22">, new OperationId(&quot;op-1&quot;)).owner().orElseThrow();
System.out.println(&quot;첫 완료 (재생 창 1시간) : &quot;
+ st</tspan><tspan x="24" dy="22">ore.complete(started, response, Duration.ofHours(1), new OperationId(&quot;op-1&quot;)));
});
String first = jdbc.queryFor</tspan><tspan x="24" dy="22">Object(
&quot;select extract(epoch from (replay_until - updated_at))::int::text from idempotency_record&quot;,
Str</tspan><tspan x="24" dy="22">ing.class);
String digestFirst = jdbc.queryForObject(
&quot;select last_transition_result_digest from idempotency</tspan><tspan x="24" dy="22">_record&quot;, String.class);
System.out.println(&quot;저장된 재생 창(초) : &quot; + first);
var owner2 = new Idempoten</tspan><tspan x="24" dy="22">cyOwner(scope, &quot;1&quot;.repeat(64),
jdbc.queryForObject(&quot;select attempt from idempotency_record&quot;, Long.class),
</tspan><tspan x="24" dy="22"> jdbc.queryForObject(&quot;select state_revision from idempotency_record&quot;, Long.class),
new OperationId(&quot;op-1&quot;));
</tspan><tspan x="24" dy="22"> transactions.executeWithoutResult(status -&gt;
System.out.println(&quot;둘째 완료 (재생 창 9시간) : &quot;
+ st</tspan><tspan x="24" dy="22">ore.complete(owner2, response, Duration.ofHours(9), new OperationId(&quot;op-1&quot;))));
String second = jdbc.queryForObject(</tspan><tspan x="24" dy="22">
&quot;select extract(epoch from (replay_until - updated_at))::int::text from idempotency_record&quot;,
String.cla</tspan><tspan x="24" dy="22">ss);
String digestSecond = jdbc.queryForObject(
&quot;select last_transition_result_digest from idempotency_recor</tspan><tspan x="24" dy="22">d&quot;, String.class);
System.out.println(&quot;저장된 재생 창(초) : &quot; + second);
System.out.println(&quot;전이 다이제</tspan><tspan x="24" dy="22">스트 그대로인가 : &quot; + digestFirst.equals(digestSecond));
}
}
JAVA
CP=&quot;adapter/outbound/persistence-jpa/build/classes/j</tspan><tspan x="24" dy="22">ava/main:application-core/build/classes/java/main:$(bash /tmp/probe/cp.sh adapter/outbound/persistence-jpa/gradle.lockfi</tspan><tspan x="24" dy="22">le postgresqlIntegrationTestRuntimeClasspath)&quot;
javac -encoding UTF-8 -nowarn -cp &quot;$CP&quot; -d /tmp/probe /tmp/probe/Complete</tspan><tspan x="24" dy="22">TtlProbe.java
java -Dstdout.encoding=UTF-8 -cp &quot;$CP:/tmp/probe&quot; CompleteTtlProbe 2&gt;&amp;1 | grep -v SLF4J
docker rm -f &quot;$CT</tspan><tspan x="24" dy="22">&quot; &gt;/dev/null 2&gt;&amp;1 || true</tspan></text>
<text x="24" y="1102" fill="#8b949e" font-size="13" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">cwd: /shared/codebase/clean-architecture-backend-template/src</tspan></text>
<text x="24" y="1124" fill="#8b949e" font-size="13" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">time: 2026-09-02T04:43:45+00:00 · exit 0</tspan></text>
<line x1="24" y1="1138" x2="1176" y2="1138" stroke="#30363d"/>
<text x="24" y="1178" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">PostgreSQL 16.15 on x86_</tspan></text>
<text x="24" y="1200" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"></tspan></text>
<text x="24" y="1222" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"># 같은 연산·같은 응답에 재생 창만 바꿔 완료를 두 번 부른다</tspan></text>
<text x="24" y="1244" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">첫 완료 (재생 창 1시간) : COMPLETED</tspan></text>
<text x="24" y="1266" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">저장된 재생 창(초) : 3600</tspan></text>
<text x="24" y="1288" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">둘째 완료 (재생 창 9시간) : ALREADY_COMPLETED_SAME_RESULT</tspan></text>
<text x="24" y="1310" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">저장된 재생 창(초) : 3600</tspan></text>
<text x="24" y="1332" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">전이 다이제스트 그대로인가 : true</tspan></text>
</svg>