Added the snapshot/epoch type and getter in the public API, plus the store wrapper implementation:

This commit is contained in:
Carl Niklas Rydberg 2025-12-21 21:11:36 +01:00
parent 12e2a91ca7
commit 456e899b50
3 changed files with 29 additions and 0 deletions

View file

@ -18,6 +18,8 @@ typedef struct {
} amduat_tgk_store_mem_artifact_t;
typedef struct {
/* Monotonic snapshot/epoch; increments when ingest/remove mutates state. */
amduat_tgk_snapshot_id_t snapshot_id;
amduat_tgk_store_config_t config;
const amduat_tgk_store_mem_artifact_t *artifacts;
size_t artifacts_len;

View file

@ -122,6 +122,17 @@ static bool amduat_tgk_store_fs_get_config(void *ctx,
return mem_ops.get_config(&fs->mem, out_config);
}
static bool amduat_tgk_store_fs_snapshot_id(void *ctx,
amduat_tgk_snapshot_id_t *out_id) {
amduat_tgk_store_fs_t *fs = (amduat_tgk_store_fs_t *)ctx;
amduat_tgk_store_ops_t mem_ops = amduat_tgk_store_mem_ops();
if (fs == NULL || mem_ops.snapshot_id == NULL) {
return false;
}
return mem_ops.snapshot_id(&fs->mem, out_id);
}
static amduat_tgk_graph_error_t amduat_tgk_store_fs_resolve_edge(
void *ctx,
amduat_reference_t ref,
@ -349,6 +360,7 @@ amduat_tgk_store_ops_t amduat_tgk_store_fs_ops(void) {
memset(&ops, 0, sizeof(ops));
ops.get_config = amduat_tgk_store_fs_get_config;
ops.snapshot_id = amduat_tgk_store_fs_snapshot_id;
ops.resolve_edge = amduat_tgk_store_fs_resolve_edge;
ops.edges_from = amduat_tgk_store_fs_edges_from;
ops.edges_to = amduat_tgk_store_fs_edges_to;

View file

@ -555,6 +555,18 @@ static bool amduat_tgk_store_mem_get_config(void *ctx,
return true;
}
static bool amduat_tgk_store_mem_snapshot_id(
void *ctx,
amduat_tgk_snapshot_id_t *out_id) {
amduat_tgk_store_mem_t *mem = (amduat_tgk_store_mem_t *)ctx;
if (mem == NULL || out_id == NULL) {
return false;
}
*out_id = mem->snapshot_id;
return true;
}
static amduat_tgk_graph_error_t amduat_tgk_store_mem_resolve_edge(
void *ctx,
amduat_reference_t ref,
@ -829,6 +841,7 @@ bool amduat_tgk_store_mem_init(amduat_tgk_store_mem_t *mem,
if (mem == NULL) {
return false;
}
mem->snapshot_id = 0;
mem->config = config;
mem->artifacts = artifacts;
mem->artifacts_len = artifacts_len;
@ -926,6 +939,7 @@ void amduat_tgk_store_mem_free(amduat_tgk_store_mem_t *mem) {
mem->edges_len = 0;
mem->artifacts = NULL;
mem->artifacts_len = 0;
mem->snapshot_id = 0;
}
amduat_tgk_store_ops_t amduat_tgk_store_mem_ops(void) {
@ -933,6 +947,7 @@ amduat_tgk_store_ops_t amduat_tgk_store_mem_ops(void) {
memset(&ops, 0, sizeof(ops));
ops.get_config = amduat_tgk_store_mem_get_config;
ops.snapshot_id = amduat_tgk_store_mem_snapshot_id;
ops.resolve_edge = amduat_tgk_store_mem_resolve_edge;
ops.edges_from = amduat_tgk_store_mem_edges_from;
ops.edges_to = amduat_tgk_store_mem_edges_to;