Skip to content

feat: Phase 1C OSAL key-value storage abstraction#41

Merged
zevorn merged 1 commit intomainfrom
feat/phase1c-kv-abstraction
Mar 16, 2026
Merged

feat: Phase 1C OSAL key-value storage abstraction#41
zevorn merged 1 commit intomainfrom
feat/phase1c-kv-abstraction

Conversation

@zevorn
Copy link
Owner

@zevorn zevorn commented Mar 16, 2026

Summary

  • New OSAL KV API (claw_kv.h): set/get for strings, blobs, and u8 values with namespace isolation — replaces all direct NVS calls
  • ESP-IDF backend (claw_kv_freertos.c): thin wrapper over nvs_flash with auto nvs_flash_init() + erase-on-corrupt
  • RT-Thread backend (claw_kv_rtthread.c): RAM-only hash table (48 slots) — persistent filesystem backend planned later
  • Migrated callers: ai_memory.c (LTM), ai_skill.c, shell_commands.c — all #ifdef CLAW_PLATFORM_ESP_IDF + NVS code removed
  • Platform main.c (C3/S3): nvs_flash_init() replaced by claw_kv_init()
  • Zero #ifdef remaining in claw/ for storage — fully platform-independent

Test plan

  • meson compile passes on vexpress-a9 (zero warnings)
  • make build-esp32c3-qemu passes (zero warnings)
  • scripts/check-patch.sh --staged passes (only __cplusplus false positives)
  • QEMU boot test: verify LTM and skill NVS persistence still works
  • Verify RT-Thread KV RAM fallback functions correctly

🦞 Generated with Claude Code

New OSAL KV API (claw_kv.h): set/get for strings, blobs, and
u8 values with namespace isolation. Replaces all direct NVS
calls scattered across the codebase.

Implementations:
- ESP-IDF: thin wrapper over nvs_flash (claw_kv_freertos.c)
- RT-Thread: RAM-only hash table (claw_kv_rtthread.c), lost
  on reboot — persistent backend (filesystem) planned later

Migrated callers:
- ai_memory.c: LTM load/persist via claw_kv (no #ifdef)
- ai_skill.c: skill persist/load via claw_kv (no #ifdef)
- shell_commands.c: config save/load via claw_kv (no #ifdef)
- main.c (C3/S3): nvs_flash_init() replaced by claw_kv_init()

No migration needed. Direct replacement.

Signed-off-by: Chao Liu <chao.liu.zevorn@gmail.com>
@zevorn zevorn merged commit 26a1f6b into main Mar 16, 2026
9 checks passed
@zevorn zevorn deleted the feat/phase1c-kv-abstraction branch March 16, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant