Map-rule cache is a design pattern where the reusable unit is an explicit mapping whose validity is maintained by admission, validation, or eviction rules.
It spans diverse settings such as inter-domain routing, retrieval-augmented generation, and long-context agents, ensuring efficient reuse of semantically valid data.
Analytical models and empirical validations demonstrate its ability to reduce lookup or generation costs while upholding evidence validity and predictable miss rates.
Searching arXiv for the cited work and closely related cache papers to ground the article.
In the literature, a map-rule cache can be understood as a cache whose reusable unit is either an explicit mapping or a compact map-like artifact, and whose correctness depends on explicit admission, validation, or eviction rules. In inter-domain routing, this takes the form of a cache of temporal locator↔identifier bindings used to preserve forwarding speed after semantic decoupling of identity and location. In retrieval-augmented generation, it takes the form of an answer cache whose entries are reused only when four safety gates hold. In long-context LLM agents, it appears as a bounded context map that stores reusable orientation knowledge about a recurring external context. Across these settings, the common problem is to reduce repeated lookup or generation cost without sacrificing miss-rate predictability, evidence validity, or prompt-budget discipline (Coras et al., 2013, Shah, 26 May 2026, Gu et al., 19 May 2026).
1. Conceptual scope
A useful way to organize the subject is to distinguish the cached object from the rule system that governs it. In the routing setting, the cached object is a binding between namespaces, such as an RLOC↔EID entry, and the governing mechanism is primarily an LRU replacement policy analyzed through working-set theory. In the RAG setting, the cached object is a tuple (qc,ec,ac,σc) containing a query, its embedding, an answer, and an evidence signature, and the governing mechanism is a four-gate admission rule requiring simultaneous agreement on query similarity, evidence overlap, source-version validity, and lexical or judge-based support. In the long-context agent setting, the cached object is an entry ri=(idi,sectioni,contenti,tokSizei,scorei,tsi) in a persistent context map, and the governing mechanism is a programmable policy composed of a Distiller, a Cartographer, and a priority-based Evictor (Coras et al., 2013, Shah, 26 May 2026, Gu et al., 19 May 2026).
Setting
Cached object
Governing rule structure
Inter-domain routing
locator ↔ identifier binding
LRU with working-set-based sizing
RAG answer reuse
(q,e,a,σ) entry
four admission gates G1–G4
Long-context agents
context-map entry ri
Distiller, Cartographer, Evictor
This organization suggests that “map-rule cache” is less a single protocol artifact than a recurring design pattern: a cache is only useful when the object being reused remains semantically valid under a compact rule system. The routing paper treats validity statistically through locality and stationarity; the RAG paper treats validity through evidence-grounded gating; the agent paper treats validity through orientation-value scoring and budgeted retention.
2. Working-set model for Loc/ID mapping caches
The analytical treatment of Loc/ID mapping caches begins from a discrete reference model. References are indexed as t=1,2,…, a window of length T denotes the last T references, and each cache entry stores a temporal binding between a locator and an identifier. Bindings are installed on a per-use basis: on a miss, the router fetches the mapping from the control-plane system and stores it. The model assumes an essentially unending reference string, stationarity, and asymptotic independence; under these conditions, classic working-set results apply and cache behavior under LRU is well modeled by the working-set size and miss-rate functions (Coras et al., 2013).
Let N be the universe of possible destinations and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)0 the reference string, with each ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)1. The working set at time ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)2 over window ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)3 is
Empirically, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)9 is observed to be piecewise linear in log-log scale, which motivates the fit
(q,e,a,σ)0
Here (q,e,a,σ)1 captures how strongly the working set grows with time, and (q,e,a,σ)2 sets the scale. For an LRU cache of fixed size (q,e,a,σ)3, the steady-state miss rate equals (q,e,a,σ)4 evaluated at the unique (q,e,a,σ)5 such that (q,e,a,σ)6. Inverting the power law yields
(q,e,a,σ)7
and therefore
(q,e,a,σ)8
The key parameters are the arrival rate (q,e,a,σ)9, the fitted coefficients G10 and G11, the cache size G12, and the expected miss probability G13. The model’s importance lies in separating shape from rate: G14 affects absolute rates but not the shape of G15, whereas G16 and G17 encode locality.
3. Applicability, validation, and router sizing
The theory is not presented as universally applicable; it is conditioned on the reference process satisfying the three working-set constraints. In practice, stationarity is tested by extracting multiple working-set curves G18 with different start times G19 and verifying that, for each fixed G40, G41 is approximately Gaussian and clusters, or by applying time-series stationarity tests such as augmented Dickey-Fuller to inter-reference distances. Because the sequence satisfies asymptotic independence, LRU is treated as approximating the optimal offline policy. For deployment, the prescribed workflow is to measure a day or more of packet-header traces, aggregate by destination prefix, compute G42 via a standard working-set algorithm such as Denning’s stack-distance method, fit G43, and then use equation (3) to size the cache for a target miss rate (Coras et al., 2013).
Validation is performed by emulation on four 24 h egress traces: upc 2009, upc 2011, and upc 2012 from a 2 Gbps campus link, and cesca 2013 from a 10 Gbps academic backbone. Each IP address is resolved to a BGP-table prefix from RouteViews, with stale-filtering of more specifics. The emulator uses pure LRU, infinite TTL, and varying cache sizes from a few hundred entries up to approximately G44, the daily-visited prefix set. The tested sizes range from a few hundred entries up to approximately G45 of the ISP’s routing table, normalized by G46. Over four orders of magnitude in G47, the analytical curve remains within a few G48 absolute miss error of the emulator. The reported mean absolute error is below G49 miss, and the worst-case deviation is below ri0 at the largest ri1, where cold-start bias and few data points in ri2 fitting reduce precision (Coras et al., 2013).
These results give the model direct operational significance. Under normal traffic, LRU is described as near-optimal, and a cache of approximately ri3 of the global BGP table yields miss rates ri4, i.e. below ri5 k miss/s at ri6 k pkt/s. The size-versus-miss trade-off follows the power law in equation (3), with pronounced knee points; small increases in ri7 yield large miss reductions until those knees are reached. A recurrent misconception is that map-cache provisioning is an ad hoc exercise. The analytical model argues the opposite: once locality is verified empirically, cache dimensioning becomes a parametric exercise in fitting ri8 and reading off ri9.
4. Cache-polluting scans and robustness limits
The same framework is extended to cache-polluting traffic by introducing an attacker-selected set t=1,2,…0 of prefixes to scan, a legitimate-to-attack rate ratio t=1,2,…1, and an overlap parameter t=1,2,…2, ranging from t=1,2,…3 for disjoint scans to t=1,2,…4 for full overlap. If t=1,2,…5 denotes the total number of packets seen, the combined working-set size becomes
t=1,2,…6
and differentiation gives the miss-rate expression
t=1,2,…7
The first term t=1,2,…8 is the contribution of legitimate traffic scaled to t=1,2,…9; the linear term corresponds to new attack prefixes minus overlaps (Coras et al., 2013).
Empirically, the attack model is tested on upc 2012 with T0 and T1. Overlapping scans, T2, are reported as the most damaging: the miss rate stays above T3 unless the cache is at least approximately T4. Even a T5 attack, T6, raises the miss rate by one order of magnitude compared to normal operation, from T7 to T8. The analytical attack model tracks emulation within below T9 absolute error (Coras et al., 2013).
The design consequences are explicit. Overlapping scans are described as worst-case because remedying them by raw capacity alone would require caches of size T0, i.e. essentially the full prefix space, which is impractical. Detection can therefore be based on comparing the instantaneous miss rate against the predicted T1 and raising an alert when it exceeds a threshold. The proposed mitigations are a two-level cache that protects top entries from eviction and evicts into a slower or shadow cache, per-user rate limiting for new prefixes, and more sophisticated eviction policies such as frequency-biased schemes at the cost of metadata complexity. This directly counters the common assumption that attack resilience is merely a question of more DRAM.
5. Four-gate answer caches in retrieval-augmented generation
In retrieval-augmented generation, a map-rule cache is instantiated as a grounded answer cache layered above a retriever, an LLM generator, and an embedding model. The architecture has a stage-2 retrieval cache and a stage-3 answer cache. After a query T2 is embedded as T3, the system performs retrieval, deduplicates and orders chunks, computes an evidence signature T4, and looks up the nearest cached answer entry T5. The cached answer T6 is reused only if all four admission gates hold simultaneously; otherwise the system compresses evidence, regenerates with the LLM, and inserts T7 into the answer cache. A hit in the retrieval cache does not by itself authorize answer reuse: only a stage-3 answer-cache hit with all gates satisfied bypasses generation (Shah, 26 May 2026).
The four gates are defined formally. The query-similarity gate requires
T8
with pre-normalized embeddings. The evidence-overlap gate requires the Jaccard overlap of chunk-hash sets,
T9
The source-version-validity gate requires matching version tags for every chunk hash in the intersection of N0 and N1. The lexical-support gate defines
N2
and the support score
N3
with admission if N4. The lexical gate can be replaced by a binary supported/not-supported LLM judge without altering the policy structure (Shah, 26 May 2026).
The operator-facing safety metric is the unsafe-served rate. For N5 total queries, with indicator N6 for whether query N7 was served from the answer cache and N8 for whether the served answer disagrees with gold, the answer-cache hit rate is N9, the unsafe-served rate is ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)00, and the conditional false-hit rate is ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)01. The paper identifies USR as the production quantity to watch because it directly measures the fraction of all queries that received a wrong cached answer (Shah, 26 May 2026).
The empirical results are framed as safety-first rather than hit-rate-first. Across ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)02 datasets and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)03 real-LLM generations using Qwen2.5-7B-Instruct on vLLM with Automatic Prefix Caching, GroundedCache drives USR to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)04 on every HotpotQA regime, compared with ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)05–ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)06 under naive caching, and to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)07 on mtRAG document drift, compared with ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)08. It yields a ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)09 reduction on the design-point adversarial regime and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)10–ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)11 reductions across the other mtRAG regimes, while end-to-end p50 latency stays within ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)12–ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)13 of a no-cache RAG baseline. In the summarized latency-versus-USR table, HotpotQA records ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)14 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)15 for no-cache RAG, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)16 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)17 for naive cache, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)18 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)19 for no-support, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)20 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)21 for GroundedCache; mtRAG records ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)22 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)23, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)24 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)25, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)26 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)27, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)28 s and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)29, respectively. A per-gate ablation identifies the lexical support gate as the load-bearing safety mechanism, with ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)30, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)31, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)32 providing defense in depth at near-zero cost (Shah, 26 May 2026).
6. Context maps as orientation caches for long-context agents
A different instantiation of the same general pattern appears in long-context LLM agents. Here the cache is not a binding table or an answer store, but a persistent context map capturing reusable orientation knowledge about a recurring external context. Formally, the context map at time ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)33 is
and the map enforces ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)38, where ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)39 is a fixed token budget, for example ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)40 tokens (Gu et al., 19 May 2026).
Maintenance is performed by three modules. The Distiller receives the execution trajectory ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)41 and current map ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)42, produces a diagnosis, tags existing entries as helpful, harmful, neutral, or stale, and extracts candidates ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)43 with scores ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)44. It examines REPL steps, code calls, sub-LLM calls, and self-analysis comments, and is instructed to assign high scores to transferable orientation facts and low scores to one-off task facts. The Cartographer computes a minimal set of edit operations ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)45 consisting of ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)46, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)47, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)48, then applies them to obtain ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)49. The Evictor enforces the budget by sorting entries by ascending priority ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)50, breaking ties by oldest timestamp, and removing the lowest-value entries until ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)51. If the total number of user questions is ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)52 and the map evolves only for the first ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)53 queries, the workflow initializes ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)54, prepends ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)55 to the system prompt at each iteration, runs the agent loop, and updates the map only while ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)56; after that, the map is frozen (Gu et al., 19 May 2026).
The reported performance gains are substantial. Using GPT-5-mini inside the RLM agent, PEEK improves long-context aggregation on OOLONG from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)57 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)58 on TREC-Q-coarse, from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)59 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)60 on AGNews, and from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)61 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)62 on Yahoo. On CL-bench, the solving rate rises from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)63 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)64, while rubric accuracy rises from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)65 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)66. Relative to ACE, iteration counts drop from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)67 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)68 on TREC-Q, from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)69 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)70 on AGNews, and from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)71 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)72 on Yahoo, corresponding to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)73, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)74, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)75 fewer iterations. Total cost is also lower: on OOLONG, ACE costs ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)76–ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)77 more than PEEK while scoring ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)78–ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)79 percentage points lower in accuracy; on CL-bench, ACE costs ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)80 more and still trails by ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)81 percentage points in solve rate and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)82 points in rubric accuracy. The method is stated to lie on the Pareto frontier of accuracy versus iterations and accuracy versus total dollar cost in all four benchmarks (Gu et al., 19 May 2026).
Generalization results indicate that the cache policy is model- and agent-agnostic. With GPT-5.5 as the base LM in the same RLM agent, TREC-Q improves from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)83 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)84, AGNews from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)85 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)86, Yahoo from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)87 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)88, and CL-bench solve/rubric from ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)89 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)90. With Qwen3-Coder in RLM, the corresponding changes are ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)91 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)92, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)93 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)94, ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)95 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)96, and ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)97 to ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)98. Replacing RLM with the OpenAI CodexCLI agent using GPT-5-mini yields ri=(idi,sectioni,contenti,tokSizei,scorei,tsi)99 to (q,e,a,σ)00 on TREC-Q, (q,e,a,σ)01 to (q,e,a,σ)02 on AGNews, (q,e,a,σ)03 to (q,e,a,σ)04 on Yahoo, and (q,e,a,σ)05 to (q,e,a,σ)06 on CL-bench solve/rubric (Gu et al., 19 May 2026).
7. Cross-domain interpretation
Taken together, these studies support a broader interpretation of map-rule caching. The routing model shows that reuse can be characterized analytically when locality assumptions hold and the replacement policy is simple. The grounded answer cache shows that high hit-rate alone is not an adequate objective when cached outputs can become semantically unsafe; safety requires explicit evidence-sensitive gates and an operator-facing error metric. The context-map cache shows that, in repeated long-context workloads, the object worth caching may be neither a full trajectory nor raw context, but a compact orientation artifact whose value is enforced through priority and token-budget rules (Coras et al., 2013, Shah, 26 May 2026, Gu et al., 19 May 2026).
This suggests three cross-cutting principles. First, cacheability is a semantic property, not merely a storage property: an RLOC↔EID binding, a cached answer, and a context-map entry are each reusable only under domain-specific invariants. Second, admission and eviction rules are central design objects rather than implementation detail. In the routing case, the governing rule is effectively LRU plus a traffic model; in GroundedCache, it is a conjunctive four-gate policy; in PEEK, it is a programmable maintenance stack culminating in priority eviction. Third, the right evaluation metric depends on failure mode. For mapping caches, miss probability and attack-induced miss inflation are decisive; for answer caches, USR is decisive; for context maps, solve rate, rubric accuracy, iteration count, and total cost matter jointly.
A final misconception common to all three areas is that caching is intrinsically a latency optimization. The networking results show that cache provisioning is also a control-plane scalability problem and an attack surface. The RAG results show that naive caching can be faster yet unsafe. The long-context results show that a small constant-sized prompt artifact can outperform larger or more passive context-preservation strategies. In that sense, a map-rule cache is best understood as a governed reuse mechanism: a cache whose utility depends on the quality of the rules that decide what is retained, when it is valid, and how it is consumed.