Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:1ay1 Agentty Keystore First File Fallback

From Leeroopedia
Knowledge Sources
Domains Security, Authentication
Last Updated 2026-10-28 14:00 GMT

Overview

Try the OS-native keystore first; fall back to encrypted file storage only when the keystore is unavailable, so that the strongest available protection is always used without breaking on platforms that lack a keystore.

Description

The Keystore_First_File_Fallback heuristic implements a tiered credential storage strategy: the OS-native keystore (macOS Keychain, Windows Credential Manager, Linux secret service) is the primary store, tried first. If the OS keystore is unavailable (headless server, platform without a secret service, permission denied), the system falls back to an encrypted file store. The fallback is transparent to the caller — the same API works regardless of which backend is active — but the file fallback is clearly marked as degraded security so the user can install a keystore if available.

In agentty this appears in: the provider key vault (`keys.hpp`) which tries the OS keystore first and falls back to file storage; and the OS-native keystore abstraction (`keystore.hpp`) which probes for keystore availability.

Usage

Apply this heuristic when storing secrets on platforms with varying capabilities. Probe for the strongest available backend first (OS keystore), fall back to a weaker but universal backend (encrypted file), and make the degradation visible. The caller API must be identical regardless of backend — the choice is an implementation detail, not a caller-visible distinction.

The Insight (Rule of Thumb)

  • Action: Try OS keystore first; fall back to encrypted file only when unavailable.
  • Value: Strongest available protection always used; universal fallback for headless/minimal platforms.
  • Trade-off: File fallback is weaker security (key derivation vs OS keychain); but the system never fails due to missing keystore.
  • Compatibility: Pairs with Heuristic:1ay1_Agentty_Defense_In_Depth — the file fallback itself is encrypted, not plaintext.

Reasoning

The OS-native keystore is the strongest credential storage available on a given platform — it uses hardware-backed keys, OS-level access control, and isolated memory. But not every platform has one (headless Linux without `secret-service`, minimal containers). If the system requires a keystore, it breaks on these platforms. If it only uses file storage, it forgoes the stronger protection on platforms that have a keystore. The tiered approach gets the best of both: strongest protection when available, universal fallback when not. The key design decision is making the fallback transparent to the caller and visible to the user — the API doesn't change, but the security level is reported.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment