Skip to main content

Module cache

Module cache 

Source
Expand description

Cache - account-scoped, atomic cache paths and versioned catalog cache for the Workers AI catalog.

Layout: $HERMES_HOME/cache/auth-cloudflare/<slug>/ (feedback 03 rename contract). Each account’s catalog is stored as two files written atomically:

  • catalog.json - the raw payload (serde_json::Value);
  • catalog.meta.json - CatalogCacheMeta (schema version, fetch time, provenance, model count, account fingerprint).

Reads return Ok(None) when the cache is absent, and Err when a present file is truncated or corrupt - callers fall back to a live fetch or the bundled fallback catalog (never panic).

Structs§

CatalogCacheMeta
Metadata recorded alongside every cached catalog payload (feedback 02/06: the cache records timestamps, provenance, and model count).

Constants§

HERMES_HOME_ENV
Env var overriding the Hermes home (matches hermes’s own resolution).

Functions§

atomic_write
Atomic write helper - write to a sibling temp file, then rename over the destination. Never leave a half-written catalog behind.
cache_dir_for_account
Return the account-scoped cache directory for one provider.
cache_is_stale
True when the cache metadata is older than max_age.
read_catalog_cache
Read the versioned catalog cache for an account-scoped directory.
write_catalog_cache
Write the versioned catalog cache for an account-scoped directory.