AxiomCore
Acore Language

Policies and runtime behavior

Declare cache and retry intent globally or for an individual endpoint.

Service contracts can declare cache and retry policy. The runtime applies only the behavior implemented for the selected client target; inspect the generated contract and validate the target before relying on it.

Global policy

policies {
  cache = CachePolicy {
    strategy = "stale_while_revalidate"
    ttlSeconds = 3600
  }
  retry = RetryPolicy {
    maxAttempts = 3
    retryOnCodes = Listing { 502 503 504 }
    retryOnTimeout = true
    backoff = ExponentialBackoff {
      initialDelay = "500ms"
      maxDelay = "10s"
      multiplier = 2.0
      useJitter = true
    }
  }
}

Endpoint override

endpoints {
  ["get_profile"] = EndpointDef {
    name = "get_profile"
    path = "/profile"
    method = "GET"
    cache = CachePolicy { strategy = "cache_first" ttlSeconds = 300 }
    retry = RetryPolicy { maxAttempts = 2 }
  }
}

An endpoint-level value is the narrow override for that endpoint. Do not infer an override from the HTTP method.

Cache strategies

StrategyContract intent
network_onlyDo not satisfy the request from the contract cache.
cache_firstUse a valid cached value before network.
network_firstPrefer network and use the target's implemented fallback behavior.
stale_while_revalidatePermit an existing value while a refresh is attempted.

ttlSeconds is required by CachePolicy. Storage, eviction, privacy, and background-refresh behavior remain target/runtime concerns.

Retry and backoff

RetryPolicy defaults to three attempts, retry codes 502, 503, and 504, and timeout retries. Backoff implementations are fixed, linear, and exponential. Review retries for non-idempotent operations and declare security or idempotency requirements where appropriate.

Policy declarations are not server enforcement and do not replace rate limits, timeouts, circuit breakers, or observability in the backend.

On this page