ADR
ARTIFACT STATUS // AT_RISKpackages/llm-gateway/src/semantic-cache.ts:L1-L30ADR-014: Custom Semantic Caching Microservice
LOAD-BEARING BLAST RADIUS (IF INVALIDATED)Evaluated: 9:30:00 AM
4,200 LOC Redis vector cache + $600/mo Redis cluster can be deleted if upstream models become cheap and fast enough.
Assertion Dependency DAG & Multi-Hop Cascade Gate
OR Kill-Switch (ANY): Decision invalidates immediately when ANY single premise breaks.
upstream_llm_input_cost_usd
3.00 > 2.00 USD / 1M tokens
upstream_ttft_p95_ms
695 > 650 ms
KILL-SWITCH GATE
OR_BREAK (ANY)
0 of 2 Broken
LOCUS STATEAT_RISK
packages/llm-gateway/src/semantic-cache.ts:L1-L30
DECAY WARNING → MONITOR
Cross-Artifact Multi-Hop Cascade Topology (Blast Radius Chain)
UPSTREAM PREREQUISITES (0)DEPENDS ON
Root Decision (No upstream artifact dependencies)
THIS NODE
ADR
AT_RISK
DOWNSTREAM CASCADE (1)AUTO-KILL
Compiled Load-Bearing Premises (2)
PREMISE #1
upstream_llm_input_cost_usd“Upstream LLM input cost > $2.00 / 1M tokens”
VALID
LIVE TELEMETRY VALUE
3.00 USD / 1M tokens
vs
REQUIRED ASSERTION
> 2.00 USD / 1M tokens
TELEMETRY TRAJECTORY (8 PTS)
Δ -0.211 USD / 1M tokens/sample
--- Red dashed line = threshold (2.00 USD / 1M tokens)
DRIFT FORECAST (TTI)TTI ~20h at current drift
DRIFT PROXIMITY TO BREAKING THRESHOLD: 5%Warning Margin: 15% (at 2.3 USD / 1M tokens)
SIMULATE REALITY DRIFT (LIVE SLIDER):Breaks when <= 2.00 USD / 1M tokens
0.45.55
HTTP_JSON_PATH/api/telemetry/live?source=llm-pricing-index
18ms
SELECTOR: $.metrics.upstream_llm_input_cost_usdINTERVAL: 300s
{
"source": "llm-pricing-index",
"provider": "anthropic-claude-sonnet",
"metrics": {
"upstream_llm_input_cost_usd": 3,
"currency": "USD",
"unit": "1M_input_tokens"
},
"timestamp": "2026-10-19T09:30:00.000Z"
}PREMISE #2
upstream_ttft_p95_ms“P95 upstream time-to-first-token > 650ms”
DECAYING
LIVE TELEMETRY VALUE
695 ms
vs
REQUIRED ASSERTION
> 650 ms
TELEMETRY TRAJECTORY (8 PTS)
Δ -28.214 ms/sample
--- Red dashed line = threshold (650 ms)
DRIFT FORECAST (TTI)TTI ~8h at current drift
DRIFT PROXIMITY TO BREAKING THRESHOLD: 80%Warning Margin: 10% (at 715 ms)
SIMULATE REALITY DRIFT (LIVE SLIDER):Breaks when <= 650 ms
1301285.75
HTTP_JSON_PATH/api/telemetry/live?source=datadog-llm-synthetics
24ms
SELECTOR: $.metrics.upstream_ttft_p95_msINTERVAL: 60s
{
"source": "datadog-llm-synthetics",
"window": "rolling_1h",
"metrics": {
"upstream_ttft_p95_ms": 695,
"upstream_ttft_p50_ms": 380
},
"timestamp": "2026-10-19T09:30:00.000Z"
}Real Codebase Locus Inspector & Patch ApplierSYNTHETIC LOCUS
Target:
packages/llm-gateway/src/semantic-cache.ts:L1-L30Target locus
packages/llm-gateway/src/semantic-cache.ts:L1-L30 points to an external path not mounted in the local repository. Switch to git apply Diff to inspect the generated remediation patch.Source Decision Document (Inline Premise Highlighting)
Extracted claims bound to live telemetryADR-014: Custom Semantic Caching Microservice
**Status:** Accepted | **Owner:** Core AI Platform | **Locus:** `packages/llm-gateway/src/semantic-cache.ts:L1-L30`
Context & Problem Statement
Our inference gateway processes 84M daily prompt tokens across customer support and code-analysis workflows. Direct passthrough to frontier upstream models introduces prohibitive unit economics and tail latency.
Load-Bearing Premises
We justify maintaining our custom HNSW Redis semantic vector cache only while the following quantitative assumptions hold true:
1. **Token Unit Economics:** Upstream LLM input cost > $2.00 / 1M tokens across our primary tier-1 reasoning endpoints.[VALID: 3.00 > 2.00 USD / 1M tokens]
2. **Tail Latency Envelope:** P95 upstream time-to-first-token > 650ms during peak North America traffic windows.[DECAYING: 695 > 650 ms]
Decision & Architecture
We deploy a dedicated 3-node Redis Stack cluster (`redis-semantic-prod-01`) running cosine-similarity embedding lookup (`threshold >= 0.94`) in `packages/llm-gateway/src/semantic-cache.ts:L1-L30`.
Blast Radius & Sunset Criteria
4,200 LOC Redis vector cache + $600/mo Redis cluster can be deleted if upstream models become cheap and fast enough. Once either load-bearing premise is invalidated by upstream provider price cuts or inference speedups, decommission the Redis vector cluster and cascade-terminate downstream `VENDOR-04: Redis Enterprise Annual FinOps Commit`.