From a1c548dbf262f54513e192d401aeed0e40d06013 Mon Sep 17 00:00:00 2001 From: "torlando-agent[bot]" <281092095+torlando-agent[bot]@users.noreply.github.com> Date: Fri, 19 Jun 2026 10:39:15 -0400 Subject: [PATCH] fix: make PYXIS_FILESTORE_DIAG self-contained (define bin_str) The diagnostic patch injected printf("...%s...", bin_str(key, key_len)) into FileStore.h but never defined bin_str, so a PYXIS_FILESTORE_DIAG=1 build failed with an undeclared-identifier error (normal DIAG=0 builds were unaffected). Inject a standard-C hex-encode helper as a static member alongside the prints so the diagnostic build is self-contained. Verified: the helper compiles clean under gnu++11 -Wall -Wextra -Werror and round-trips keys correctly. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5 --- patch_filestore.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/patch_filestore.py b/patch_filestore.py index fe709533..4a02598c 100644 --- a/patch_filestore.py +++ b/patch_filestore.py @@ -40,7 +40,19 @@ OLD = """\tbool exists(const uint8_t* key, uint8_t key_len) \t\treturn true; \t}""" -NEW = """\tbool exists(const uint8_t* key, uint8_t key_len) +NEW = """\t// pyxis-local diagnostic helper, only compiled under PYXIS_FILESTORE_DIAG +\t// and only used by the printfs below. Hex-encodes a binary key using just +\t// standard C so the diagnostic build is self-contained (no external bin_str). +\t// Static buffer is fine here: each printf evaluates it exactly once. +\tstatic const char* bin_str(const uint8_t* d, uint8_t n) { +\t\tstatic char b[2 * USTORE_MAX_KEY_LEN + 1]; +\t\tstatic const char hex[] = "0123456789abcdef"; +\t\tif (n > USTORE_MAX_KEY_LEN) n = USTORE_MAX_KEY_LEN; +\t\tfor (uint8_t i = 0; i < n; i++) { b[2 * i] = hex[(d[i] >> 4) & 0xF]; b[2 * i + 1] = hex[d[i] & 0xF]; } +\t\tb[2 * n] = '\\0'; +\t\treturn b; +\t} +\tbool exists(const uint8_t* key, uint8_t key_len) \t{ \t\tif (!isValid()) { printf("[ustore] exists: !isValid len=%u idx_size=%zu store=%p\\n", (unsigned)key_len, _index.size(), (void*)this); return false; } \t\tif(key_len > USTORE_MAX_KEY_LEN) { printf("[ustore] exists: key too long\\n"); return false; }