Skip to content
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
937a75d
docs(reports): prefix cache hit-rate analysis and levers (2026-09-26)
Gajesh2007 Sep 27, 2026
4433c01
ops(cache-routing): plan-gate widening runbook and Nemotron/Bonsai tu…
Gajesh2007 Sep 27, 2026
831ae1b
feat(registry): prefer a proven cache holder inside the near-tie band
Gajesh2007 Sep 27, 2026
5b84a8a
fix(cache): bound the proof fence and narrow mismatch invalidation
Gajesh2007 Sep 27, 2026
9647118
feat(coordinator): forward observed repeat demand to providers and si…
Gajesh2007 Sep 27, 2026
6409a94
feat(provider): gate complete-checkpoint donations on observed repeat…
Gajesh2007 Sep 27, 2026
f89ad62
deploy: sync the sanitized prod env reference with live cache-routing…
Gajesh2007 Sep 27, 2026
8f0f7f1
test(e2e): observe cache_repeated_prefix_tokens in the provider wire …
Gajesh2007 Sep 27, 2026
75723ca
test(prompt-parity): reproduce sidecar/provider prompt-chain mismatches
Gajesh2007 Sep 27, 2026
08431f2
fix(registry): spread tied cache holders, clear cache selection on pl…
Gajesh2007 Sep 27, 2026
b8f0d90
feat(prefix-cache): stride-aligned historical checkpoints, K retentio…
Gajesh2007 Sep 27, 2026
72b07a6
fix(promptsidecar): mirror provider prompt preparation the planner sk…
Gajesh2007 Sep 27, 2026
98816d5
test(registry): discriminate the tied-holder burst by first-scan commits
Gajesh2007 Sep 27, 2026
f2acfd5
Merge pc/cache-credit: proven cache holders win inside the near-tie band
Gajesh2007 Sep 27, 2026
99c26ab
docs(reports): correct the mismatch-detail reading in the hit-rate an…
Gajesh2007 Sep 27, 2026
bb119e7
fix(registry): bound the demand-index TTL sweep per observe
Gajesh2007 Sep 27, 2026
c8e06d9
fix(cache): lift a replaced capability's fence at the heartbeat, not …
Gajesh2007 Sep 27, 2026
cd633fb
Merge pc/fence-bound: bounded proof fence and plan-scoped holder inva…
Gajesh2007 Sep 27, 2026
c60610b
Merge pc/demand-donation: demand-gated SSD donation with a coordinato…
Gajesh2007 Sep 27, 2026
d559921
fix(provider): stop rotating the SSD cache epoch on per-file removals
Gajesh2007 Sep 27, 2026
279224c
docs: cache routing credit band, bounded proof fence, demand-gated do…
Gajesh2007 Sep 27, 2026
950c2a7
Merge branch 'feat/prefix-cache-hit-rate' into pc/checkpoint-geometry
Gajesh2007 Sep 27, 2026
5a1b5a2
fix(promptsidecar): refuse inputs the provider renders differently; s…
Gajesh2007 Sep 27, 2026
eff5c61
docs: record the 30-minute SSD cache TTL sign-off and per-file evicti…
Gajesh2007 Sep 27, 2026
722347d
fix(provider): harden per-file SSD removals against rebuild, reader a…
Gajesh2007 Sep 27, 2026
089b78a
fix(cache): drop a provider's deeper holders when it hits at a shorte…
Gajesh2007 Sep 27, 2026
8c7ade6
feat(provider): raise the SSD prefix-cache TTL from 15 to 30 minutes
Gajesh2007 Sep 27, 2026
0a97f02
Merge pc/fence-bound: drop a provider's deeper holders on a shorter hit
Gajesh2007 Sep 27, 2026
e81dee1
Merge integration into pc/ttl-docs
Gajesh2007 Sep 27, 2026
06fee66
docs: shorter_hit holder removal
Gajesh2007 Sep 27, 2026
6057c68
Merge pc/epoch-rotation: per-file SSD removals keep the cache epoch
Gajesh2007 Sep 27, 2026
0c91025
Merge pc/ssd-ttl-raise: 30-minute SSD prefix-cache TTL (SEC-035 sign-…
Gajesh2007 Sep 27, 2026
42df951
Merge pc/ttl-docs: TTL sign-off record, per-file eviction and shorter…
Gajesh2007 Sep 27, 2026
01e39a6
Merge pc/mismatch-investigation: sidecar mirrors five provider prompt…
Gajesh2007 Sep 27, 2026
cf2ee42
fix(provider): expire files under a disowned store's root; drop the d…
Gajesh2007 Sep 27, 2026
d13ff3f
feat(prefix-cache): demand-targeted checkpoint retention and review f…
Gajesh2007 Sep 27, 2026
8f08f51
feat(registry): size the cache indexes for a 30-minute TTL and bound …
Gajesh2007 Sep 27, 2026
24093fe
fixup: read the tracker caps under its lock in stateCounts
Gajesh2007 Sep 27, 2026
26b2e53
Merge pc/epoch-cleanup: remove the dead maintenance gate, maintainer …
Gajesh2007 Sep 27, 2026
339757b
docs: maintainer ownership rule and retired donation outcomes
Gajesh2007 Sep 27, 2026
3e52833
perf(registry): index cache holders and attempts by provider
Gajesh2007 Sep 27, 2026
c3f6abf
feat(registry): observe cache demand on the 1,024-token checkpoint st…
Gajesh2007 Sep 27, 2026
c6fdd75
docs(registry): describe the 1,024-token demand stride in code comments
Gajesh2007 Sep 27, 2026
0dfde5d
test(registry): trim the race-time cost of the index sizing tests
Gajesh2007 Sep 27, 2026
00dd7b8
feat(prefix-cache): cap staged checkpoint windows across the slot
Gajesh2007 Sep 27, 2026
9904968
Merge pc/index-sizing: size cache indexes for a 30-minute window, exp…
Gajesh2007 Sep 27, 2026
f2c8a6e
fix(prefix-cache): align the donor byte budget with the slot-wide cap…
Gajesh2007 Sep 27, 2026
65a0013
feat(registry): sticky affinity, shallow demand ladder, demand index …
Gajesh2007 Sep 27, 2026
9f01887
test(promptsidecarloadproof): expect the 154-vector production corpus
Gajesh2007 Sep 27, 2026
329312f
Merge pc/index-sizing: sticky affinity rung, shallow ladder, demand i…
Gajesh2007 Sep 27, 2026
681ecd8
docs: index sizing, demand stride and observability
Gajesh2007 Sep 27, 2026
b62e01a
docs: demand index status fields and gauges
Gajesh2007 Sep 27, 2026
58f21b8
fix(prefix-cache): count checkpoints in publication against the slot cap
Gajesh2007 Sep 27, 2026
d20d399
Merge pc/checkpoint-geometry: 1,024-token historical checkpoints, dem…
Gajesh2007 Sep 27, 2026
32ae565
docs: historical checkpoint geometry, retention and staging cap; chan…
Gajesh2007 Sep 27, 2026
0233a79
registry: log the selection path on routing_decision
Gajesh2007 Sep 27, 2026
1a07849
Merge origin/master (preload selected models on every provider start,…
Gajesh2007 Sep 27, 2026
9156005
chore(libs): pin mlx-swift-lm to main c9bcdc3e (#168 squash of the ch…
Gajesh2007 Sep 27, 2026
2c140e7
fix(provider): keep the demand hint across an abandoned stage
Gajesh2007 Sep 27, 2026
680954f
chore(release): prepare v0.9.11 for the prefix-cache hit-rate set
Gajesh2007 Sep 27, 2026
6c8dda8
fix(provider): make checkpoint publish-to-index atomic against removals
Gajesh2007 Sep 27, 2026
3229885
docs(threat-model): reconcile the remaining 15-minute TTL statements …
Gajesh2007 Sep 27, 2026
31ea152
fix(registry): drop the retired tracker's demand index on reconfigure
Gajesh2007 Sep 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# Changelog

## Release candidate v0.9.11 — prefix cache hit rate (not shipped; 2026-09-27)

- Align `ProviderCore.version` and the coordinator display fallback at 0.9.11. The new inference-request field is optional in both directions, so the coordinator and providers can be upgraded in either order; upgrade the coordinator first to keep the 0.9.10 rollout order.

Production ran exact prefix-cache routing at 100% and measured a 1.4–5.2% hit rate per model. See the [analysis](docs/reports/2026-09-26-prefix-cache-hit-rate-analysis.md) and the [rollout procedure](docs/operations/cache-routing-rollout.md). Coordinator and provider changes are independent on the wire: an older provider ignores the new request field, and an older coordinator leaves providers on their previous donation behavior.

### Provider

- Keep the SSD cache epoch across budget eviction, TTL expiry and corrupt-file removal. Only a whole-root rebuild at load mints a new epoch, so the coordinator no longer forgets a provider's remaining checkpoints each time one file is removed.
- Raise the SSD prefix-cache TTL from 15 to 30 minutes (default equals maximum; the environment override can only shorten it). Recorded as the SEC-035 re-acceptance in the threat model.
- Write a complete checkpoint only on evidence of demand: the coordinator's `cache_repeated_prefix_tokens` at or above the 1,024-token floor, or a prior local sighting. Fleet-novel checkpoints report `skipped_novel` and touch neither disk nor the write budget. The first request for a prefix is served cold and not written, the second is written, the third can hit.
- Capture GPT-OSS 20B and Gemma QAT checkpoints at every 1,024-token boundary regardless of prefill chunk size, including inside a solo stripe, and retain at most three per donor: the first boundary, the boundary at the observed shared-prefix length, and the deepest. Qwen capture is unchanged.
- Report a file that disappeared under a reader as an absent miss rather than corruption; let expiry proceed when a root's only registered store has lost ownership.

### Coordinator

- Prefer a proven cache holder inside the existing 3-second near-tie band instead of collapsing the band whenever a cache credit exists. New selection path `cache_credit` and opportunity reason `selected_near_tie`.
- Bound the proof fence to 60 seconds, doubling per consecutive mismatch to a 10-minute maximum, and drop only the mismatched prompt's holders. Previously a mismatch fenced the capability until the provider's epoch changed and dropped every holder for the model.
- Drop a provider's deeper holders when it proves a hit at a shorter boundary (`shorter_hit`).
- Size the holder index (250,000) and observed-demand index (600,000) for a 30-minute window and expire holders from an expiry-ordered heap in bounded passes.
Comment thread
Gajesh2007 marked this conversation as resolved.
Resolved
- Forward observed repeat demand to providers as `cache_repeated_prefix_tokens`.

### Prompt sidecar

- Mirror five provider prompt transformations that caused proof mismatches: tool-call argument key order, integral doubles in arguments, extra keys in tool `function` objects, Harmony channel framing in assistant history, and `output_text` content parts. Prompt-contract IDs are unchanged. Decline to plan for decomposed Unicode object keys and for Harmony control tokens that share a grapheme with a neighbour.

### Operations

- Rollout procedure for sidecar capacity, plan QPS, holder TTL and the Nemotron Lightning and Bonsai 2 allowlist tuples. The sanitized production env reference now matches the live cache-routing values.

## Release candidate v0.9.10 — live switching and App Attest recovery (not shipped; 2026-09-27)

- Align `ProviderCore.version` and the coordinator display fallback at 0.9.10. Upgrade the coordinator before publishing the separately qualified signed provider; the source bump does not advance the registered latest release.
Expand Down
39 changes: 39 additions & 0 deletions coordinator/api/cache_proof_fence_wire_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package api

import (
"strings"
"testing"
"time"

"github.com/eigeninference/d-inference/coordinator/protocol"
)

// A proof mismatch received over the provider WebSocket fences the capability
// for a bounded window: receipts inside it are rejected as capability_fenced,
// /v1/cache/status counts the window, and a valid proof after it is accepted.
func TestProofFenceLiftsOverProviderWire(t *testing.T) {
w := newCacheReceiptWire(t, cacheEligibilityV2Capability("model"))

w.lookup("mismatch", w.attempt("mismatch"), func(m *protocol.PrefixCacheLookupV2Message) {
m.PromptAnchor.ChainHash = strings.Repeat("d", 64)
})
w.waitReceipt("lookup_v2", "rejected", "prompt_anchor_mismatch", 1)
w.waitStatus(func(s ExactCacheStatus) bool {
return s.Lifecycle.FencesApplied == 1 && s.Lifecycle.FencesExpired == 0 &&
s.Lifecycle.FencedCapabilities == 1
})

w.lookup("fenced", w.attempt("fenced"), nil)
w.waitReceipt("lookup_v2", "rejected", "capability_fenced", 1)

w.advance(61 * time.Second)
w.lookup("accepted", w.attempt("accepted"), nil)
w.waitReceipt("lookup_v2", "accepted", "accepted", 1)
status := w.waitStatus(func(s ExactCacheStatus) bool {
return s.Lifecycle.FencesApplied == 1 && s.Lifecycle.FencesExpired == 1 &&
s.Lifecycle.FencedCapabilities == 0
})
if status.Lifecycle.HolderRemoved["proof_mismatch"] != 0 {
t.Fatalf("mismatch with no holders reported removals: %+v", status.Lifecycle.HolderRemoved)
}
}
171 changes: 171 additions & 0 deletions coordinator/api/cache_receipt_wire_helpers_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package api

import (
"context"
"encoding/json"
"log/slog"
"net/http"
"net/http/httptest"
"strings"
"sync/atomic"
"testing"
"time"

"nhooyr.io/websocket"

"github.com/eigeninference/d-inference/coordinator/protocol"
"github.com/eigeninference/d-inference/coordinator/registry"
"github.com/eigeninference/d-inference/coordinator/store"
)

// cacheReceiptWire drives exact-cache receipts through a real provider
// WebSocket against an in-process coordinator. Plans come from the public
// planner with a synthetic local sidecar; only the clock is injected.
type cacheReceiptWire struct {
t *testing.T
ctx context.Context
reg *registry.Registry
srv *Server
url string
conn *websocket.Conn
capability protocol.PrefixCacheV2Capability
plan registry.CachePlan
provider *registry.Provider
offset atomic.Int64
seq uint64
}

func newCacheReceiptWire(t *testing.T, capability protocol.PrefixCacheV2Capability) *cacheReceiptWire {
t.Helper()
logger := slog.New(slog.DiscardHandler)
w := &cacheReceiptWire{t: t, reg: registry.New(logger), capability: capability}
w.srv = NewServer(w.reg, store.NewMemory(store.Config{}), ServerConfig{}, logger)
configureCachePreparationTest(t, w.reg)
base := time.Now()
w.reg.SetCacheRoutingClockForTest(func() time.Time { return base.Add(time.Duration(w.offset.Load())) })
httpServer := httptest.NewServer(w.srv.Handler())
t.Cleanup(httpServer.Close)
w.url = httpServer.URL
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
t.Cleanup(cancel)
w.ctx = ctx
conn, _, err := websocket.Dial(ctx, "ws"+strings.TrimPrefix(w.url, "http")+"/ws/provider", nil)
if err != nil {
t.Fatal(err)
}
t.Cleanup(func() { _ = conn.Close(websocket.StatusNormalClosure, "") })
w.conn = conn
writeProviderJSON(t, ctx, conn, protocol.RegisterMessage{
Type: protocol.TypeRegister, Backend: "mlx-swift",
Models: []protocol.ModelInfo{{ID: capability.ModelID, WeightHash: capability.ModelAggregateHash}},
PrefixCacheProtocol: 2, PrefixCacheV2Models: []protocol.PrefixCacheV2Capability{capability},
})
w.plan = cachePreparationPlanForTest(t, w.reg, capability)
waitCacheCondition(t, func() bool {
ids := w.reg.ProviderIDs()
if len(ids) != 1 {
return false
}
w.provider = w.reg.GetProvider(ids[0])
return w.provider != nil
})
return w
}

func (w *cacheReceiptWire) advance(d time.Duration) { w.offset.Add(int64(d)) }

// prompt is the plan's final boundary: the anchor every lookup must prove.
func (w *cacheReceiptWire) prompt() protocol.PrefixCacheAnchor {
return w.plan.Boundaries[len(w.plan.Boundaries)-1]
}

// boundary returns the plan's anchor at the given number of 256-token blocks.
func (w *cacheReceiptWire) boundary(blocks int) protocol.PrefixCacheAnchor {
w.t.Helper()
for _, anchor := range w.plan.Boundaries {
if anchor.TokenCount == blocks*int(w.capability.BlockSize) {
return anchor
}
}
w.t.Fatalf("plan has no boundary at %d blocks", blocks)
return protocol.PrefixCacheAnchor{}
}

// attempt prepares a coordinator attempt and returns the nonce the provider
// would have received in its inference request.
func (w *cacheReceiptWire) attempt(id string) string {
w.t.Helper()
pr := &registry.PendingRequest{RequestID: id, Model: w.capability.ModelID, CachePlan: w.plan}
if err := w.reg.PrepareCacheAttempt(pr, w.provider); err != nil {
w.t.Fatal(err)
}
nonce := providerInferenceWireMessage(id, "ephemeral", "ciphertext", pr).CacheReceiptNonce
if nonce == "" {
w.t.Fatalf("attempt %s did not prepare", id)
}
return nonce
}

func (w *cacheReceiptWire) lookup(id, nonce string, mutate func(*protocol.PrefixCacheLookupV2Message)) {
w.t.Helper()
w.seq++
msg := protocol.PrefixCacheLookupV2Message{
Type: protocol.TypePrefixCacheLookupV2, RequestID: id, CacheReceiptNonce: nonce,
ModelID: w.capability.ModelID, ModelAggregateHash: w.capability.ModelAggregateHash,
PromptContractID: w.capability.PromptContractID, CacheEpoch: w.capability.CacheEpoch,
CacheSeq: w.seq, PromptAnchor: w.prompt(), Outcome: "miss_absent", Tier: "ssd", StageMs: 1,
}
if mutate != nil {
mutate(&msg)
}
writeProviderJSON(w.t, w.ctx, w.conn, msg)
}

func (w *cacheReceiptWire) ready(id, nonce string, stageMs float64, anchors ...protocol.PrefixCacheAnchor) {
w.t.Helper()
w.seq++
writeProviderJSON(w.t, w.ctx, w.conn, protocol.PrefixCacheReadyV2Message{
Type: protocol.TypePrefixCacheReadyV2, RequestID: id, CacheReceiptNonce: nonce,
ModelID: w.capability.ModelID, ModelAggregateHash: w.capability.ModelAggregateHash,
PromptContractID: w.capability.PromptContractID, CacheEpoch: w.capability.CacheEpoch,
CacheSeq: w.seq, Outcome: "ready", Tier: "ssd", ReadyAnchors: anchors,
ExpectedPrefillTokensSaved: anchors[len(anchors)-1].TokenCount, StageMs: stageMs,
})
}

func (w *cacheReceiptWire) receipts(kind, outcome, reason string) int64 {
return w.srv.Metrics().Snapshot().Counters[metricKey("exact_cache_receipt_total", []MetricLabel{
{"type", kind}, {"outcome", outcome}, {"reason", reason},
})]
}

func (w *cacheReceiptWire) waitReceipt(kind, outcome, reason string, count int64) {
w.t.Helper()
waitCacheCondition(w.t, func() bool { return w.receipts(kind, outcome, reason) == count })
}

// waitStatus polls the public endpoint (cached for one second), so the
// projection itself is what a test asserts.
func (w *cacheReceiptWire) waitStatus(want func(ExactCacheStatus) bool) ExactCacheStatus {
w.t.Helper()
var status ExactCacheStatus
deadline := time.Now().Add(5 * time.Second)
for time.Now().Before(deadline) {
response, err := http.Get(w.url + "/v1/cache/status")
if err != nil {
w.t.Fatal(err)
}
status = ExactCacheStatus{}
err = json.NewDecoder(response.Body).Decode(&status)
_ = response.Body.Close()
if err != nil {
w.t.Fatal(err)
}
if want(status) {
return status
}
time.Sleep(20 * time.Millisecond)
}
w.t.Fatalf("cache status never reached the wanted state: holders=%d lifecycle=%+v", status.Holders, status.Lifecycle)
return status
}
58 changes: 58 additions & 0 deletions coordinator/api/cache_shorter_hit_wire_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package api

import (
"testing"

"github.com/eigeninference/d-inference/coordinator/protocol"
)

// A provider that stops rotating its epoch on per-file eviction reports a
// removed deeper checkpoint only as a valid hit at a shallower one. Over the
// real provider WebSocket, that hit drops the deeper holder under its own
// removal reason, keeps the shallower one, and applies no fence.
func TestShorterHitDropsDeeperHolderOverProviderWire(t *testing.T) {
capability := cacheEligibilityV2Capability("model")
capability.ReadyBoundaryMode = protocol.PrefixCacheReadyBoundaryCheckpoint
w := newCacheReceiptWire(t, capability)
short, long := w.boundary(8), w.boundary(16) // 2,048 and 4,096 tokens

donor := w.attempt("donor")
w.lookup("donor", donor, nil)
w.waitReceipt("lookup_v2", "accepted", "accepted", 1)
w.ready("donor", donor, 100, short, long)
w.waitReceipt("ready_v2", "accepted", "accepted", 1)
w.waitStatus(func(s ExactCacheStatus) bool { return s.Holders == 2 })

w.lookup("repeat", w.attempt("repeat"), func(m *protocol.PrefixCacheLookupV2Message) {
m.Outcome, m.MatchedAnchor = "hit", &short
m.ExpectedPrefillTokensSaved, m.StageMs = short.TokenCount, 50
})
w.waitReceipt("lookup_v2", "accepted", "accepted", 2)
status := w.waitStatus(func(s ExactCacheStatus) bool {
return s.Holders == 1 && s.Lifecycle.HolderRemoved["shorter_hit"] == 1
})
lifecycle := status.Lifecycle
if lifecycle.HolderRemoved["miss_invalidation"] != 0 || lifecycle.HolderRemoved["proof_mismatch"] != 0 {
t.Fatalf("shorter hit counted under another removal reason: %+v", lifecycle.HolderRemoved)
}
if lifecycle.FencesApplied != 0 || lifecycle.FencedCapabilities != 0 {
t.Fatalf("shorter hit fenced the capability: %+v", lifecycle)
}
if lifecycle.SSDHits != 1 {
t.Fatalf("ssd hits = %d, want the shorter hit counted once", lifecycle.SSDHits)
}

// The capability still proves receipts, and the deeper boundary is
// re-taught by the next durable publication.
again := w.attempt("again")
w.lookup("again", again, func(m *protocol.PrefixCacheLookupV2Message) {
m.Outcome, m.MatchedAnchor = "hit", &short
m.ExpectedPrefillTokensSaved, m.StageMs = short.TokenCount, 50
})
w.waitReceipt("lookup_v2", "accepted", "accepted", 3)
w.ready("again", again, 100, long)
w.waitReceipt("ready_v2", "accepted", "accepted", 2)
w.waitStatus(func(s ExactCacheStatus) bool {
return s.Holders == 2 && s.Lifecycle.HolderRemoved["shorter_hit"] == 1
})
}
26 changes: 26 additions & 0 deletions coordinator/api/exact_cache_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,27 @@ func (s *Server) registerExactCacheGauges() {
return float64(s.Lifecycle.DonationOutcomes[outcome])
}), MetricLabel{"outcome", outcome})
}
for _, fence := range []struct {
name string
value func(registry.CacheRoutingLifecycleStatus) uint64
}{
{name: "applied", value: func(s registry.CacheRoutingLifecycleStatus) uint64 { return s.FencesApplied }},
{name: "expired", value: func(s registry.CacheRoutingLifecycleStatus) uint64 { return s.FencesExpired }},
} {
fence := fence
s.metrics.RegisterGaugeLabels("exact_cache_fence", gauge(func(s ExactCacheStatus) float64 {
return float64(fence.value(s.Lifecycle))
}), MetricLabel{"event", fence.name})
}
s.metrics.RegisterGauge("exact_cache_fenced_capabilities", gauge(func(s ExactCacheStatus) float64 {
return float64(s.Lifecycle.FencedCapabilities)
}))
s.metrics.RegisterGauge("exact_cache_demand_entries", gauge(func(s ExactCacheStatus) float64 {
return float64(s.Lifecycle.DemandEntries)
}))
s.metrics.RegisterGauge("exact_cache_demand_cap_evictions", gauge(func(s ExactCacheStatus) float64 {
return float64(s.Lifecycle.DemandCapEvictions)
}))
}

func (s *Server) exactCacheGaugeSnapshot() ExactCacheStatus {
Expand Down Expand Up @@ -347,6 +368,11 @@ func (s *Server) emitExactCacheDDGauges() {
s.ddGauge("exact_cache.donation_outcome", float64(status.Lifecycle.DonationOutcomes[outcome]),
[]string{"outcome:" + outcome})
}
s.ddGauge("exact_cache.fence", float64(status.Lifecycle.FencesApplied), []string{"event:applied"})
s.ddGauge("exact_cache.fence", float64(status.Lifecycle.FencesExpired), []string{"event:expired"})
s.ddGauge("exact_cache.fenced_capabilities", float64(status.Lifecycle.FencedCapabilities), nil)
s.ddGauge("exact_cache.demand_entries", float64(status.Lifecycle.DemandEntries), nil)
s.ddGauge("exact_cache.demand_cap_evictions", float64(status.Lifecycle.DemandCapEvictions), nil)
}

func boolGauge(value bool) float64 {
Expand Down
7 changes: 6 additions & 1 deletion coordinator/api/exact_cache_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ func (s *Server) ExactCacheStatusSnapshot() ExactCacheStatus {
if routingMode != registry.CacheRoutingOn {
routingMode = registry.CacheRoutingOff
}
// Count first: counting settles expiry, and the lifecycle counters read
// afterwards then include those removals. The two reads take the tracker
// lock separately, so a receipt that lands between them can still leave
// holder_added minus the removals one or two off holders in a scrape.
holders, attempts := s.registry.CacheRoutingStateCounts()
status := ExactCacheStatus{
Holders: holders, Attempts: attempts,
ArtifactAllowlist: ExactCacheArtifactAllowlistStatus{
Configured: config.AllowedArtifacts != nil, Count: len(config.AllowedArtifacts),
},
Expand All @@ -86,7 +92,6 @@ func (s *Server) ExactCacheStatusSnapshot() ExactCacheStatus {
Providers: s.registry.PrefixCacheProtocolStatus(),
Lifecycle: s.registry.CacheRoutingLifecycleStatus(),
}
status.Holders, status.Attempts = s.registry.CacheRoutingStateCounts()
if s.promptSupervisor != nil {
supervisor := s.promptSupervisor.Status()
status.Sidecar.Enabled = supervisor.Enabled
Expand Down
Loading
Loading