# data-api: cache /.well-known/entire-api.json like entire-cluster.json

`f1f92f9`→[main](/content/gh/entireio/cli/commits/main/index.html)·

toothbrush·1mo ago·7 files·+382 added/-25 removed

Discovery was re-fetched on every activity/search/trail/dispatch/recap invocation. Cache it the same way the git path caches entire-cluster.json: reuse the generic cache primitives (modifyCacheFile/loadCacheFile/...) for a new api_discovery.json sibling, 24h TTL, with stale-fallback when a re-fetch fails. The entry carries `audience` alongside issuer/trusted_issuers — the one field that distinguishes a resource API from a git cluster.

- discovery: APIDiscoveryCache / APIDiscoveryEntry (mirrors ClusterCoresCache)
- clusterdiscovery: resolveAPIDoc (mirrors resolveClusterCores); ResolveContextForAPI gains a cacheDir param and goes cache-then-/.well-known
- auth: ResolveDataAPIToken passes discovery.DefaultCacheDir(); test seam + DiscoveryUnavailableForTest grow the cacheDir param

Behavioural upside: a transient discovery outage now reuses last-known-good trust roots instead of dropping to the static fallback — aligning with COR-393's mandatory-discovery direction. Cold failure (no cache entry) still falls back.

## Sessions

99ecee35ca11View transcript

## Changes

7

- cmd/entire/cli

- auth

- Mdata_api.go+10/-4

- Mdata_api_test.go+4/-4

- Mauth_context_test.go+6/-6

- internal/entireclient

- clusterdiscovery

- Mapi_discovery.go+58/-6

- Mapi_discovery_test.go+100/-5

- discovery

- Aapi_discovery.go+86

- Aapi_discovery_test.go+118
