Files
codebase-memory-mcp/internal/cbm/zstd_store.c
T
test 8babe67bea feat: add persistent artifact storage for team sharing
Add .codebase-memory/graph.db.zst — a zstd-compressed knowledge graph
artifact that can be committed to the repo. Teammates bootstrap from
the artifact instead of running a full reindex from scratch.

- Vendor zstd 1.5.7 (amalgamated build) for 8-13:1 compression
- Two-tier export: zstd -9 + index stripping for explicit index,
  zstd -3 for watcher/incremental auto-updates
- Import: decompress → integrity check → auto-recreate indexes
- Bootstrap in handle_index_repository: when no local DB exists but
  artifact is present, import first then run incremental
- Auto-create .gitattributes with merge=ours to prevent conflicts
- Fix: add missing idx_edges_url_path to create_user_indexes and
  url_path_gen generated column to init_schema
- 13 new tests (5 zstd wrapper + 8 artifact round-trip/edge cases)
2026-04-15 23:56:03 +02:00

28 lines
704 B
C

// zstd_store.c — Thin C wrappers around Zstandard.
#include "vendored/zstd/zstd.h"
#include "zstd_store.h"
#include <stddef.h>
int cbm_zstd_compress(const char *src, int srcLen, char *dst, int dstCap, int level) {
size_t rc = ZSTD_compress(dst, (size_t)dstCap, src, (size_t)srcLen, level);
if (ZSTD_isError(rc)) {
return 0;
}
return (int)rc;
}
int cbm_zstd_decompress(const char *src, int srcLen, char *dst, int dstCap) {
size_t rc = ZSTD_decompress(dst, (size_t)dstCap, src, (size_t)srcLen);
if (ZSTD_isError(rc)) {
return 0;
}
return (int)rc;
}
size_t cbm_zstd_compress_bound(int inputSize) {
return ZSTD_compressBound((size_t)inputSize);
}