anonpenguin23 dc7abbcc51 fix(serverless,rqlite): reliable WASM cold-fetch + bounded-staleness none-reads
Three anchat-priority fixes for delivery-critical paths.

#137 — rarely-invoked function WASM cold-fetch timed out (15s) → INVOKE_FAILED
with no retryable flag:
- uploadWASM now pins WASM on EVERY cluster peer (replication=-1) so no gateway
  node is ever cold, and HARD-FAILS the deploy on a pin error (no silent
  "deployed but unfetchable").
- GetWASMBytes fetches with an independent 4s×3 budget decoupled from the
  function's timeout, returning the typed ErrWASMFetchTimeout.
- New FUNCTION_UNAVAILABLE rpc code (retryable) emitted on BOTH the HTTP and WS
  invoke error frames; the invoker no longer re-runs (re-fetches) on it.

#139 — a gateway's local rqlite follower can lag minutes; none-reads silently
served stale rows and recipients missed messages:
- New in-process freshness gate (LocalFollowerFresh via raft /status
  last_contact + commit/applied gap, TTL-cached). A stale local follower's
  none-reads AUTO-DEGRADE to the leader-routed weak conn — transparent, no
  caller change, never stale.

#138 — expose rqlite native level=none&freshness=<dur> in db_query_batch:
- New queryNoneFresh custom HTTP path (gorqlite can't express freshness) +
  typed ErrFreshnessViolation; freshness field on the db_query_batch envelope,
  validated/clamped at the boundary; a violation returns a structured
  stale_rejected envelope so WASM can fall back to a leader read.

Reads-only; additive + backward compatible (empty freshness = prior behavior).
Verified live on devnet: rqlite v8.43.0 signals a violation as HTTP 200 +
{"error":"stale read"}; /status is reachable unauthenticated for the gate.
2026-06-24 08:51:13 +03:00
..