def refresh_gated
import cswap-bend-cli@0.1.0.0/usage/gate.bend as Gateimport Base
177# consume_backup_grant: refresh the slot's credential under its consume lock.
178# `snapshot` is the caller's copy; the gate consumes the freshest copy it can
179# read from <root>/credentials/.creds-<slot>-<email>.enc, or adopts a fresher fresh one
180# without any POST. Busy past the timeout (10 s, or
181# CSWAP_CONSUME_TIMEOUT_MS) is `consume-busy`.
182def refresh_gated(+slot: String, +email: String, +snapshot: String, +root: String) -> IO(Gated):
183 IO.bind(Result<&1, &1, U32 & String, String>, Gated, IO.get_env("CLAUDE_SECURESTORAGE_CONFIG_DIR"),
184 r => gated.env(r, slot, email, snapshot, root))