ion7-llm / kv.snapshot

module

kv.snapshot

Functions

M.save

Capture the KV state of `seq_id` into a Lua string.

M.save(ctx, seq_id)
ctxion7.core.Context
seq_idinteger
→ string?blob, or nil when the sequence is empty

M.restore

Restore the blob into `dst_seq_id`. The destination's previous contents (if any) are wiped — call `kv_seq_rm` first if you need to merge instead of replace.

M.restore(ctx, blob, dst_seq_id)
ctxion7.core.Context
blobstring
dst_seq_idinteger
→ integerbytes consumed (0 on failure)

M.size

Byte size the next snapshot of `seq_id` would produce. Useful for pre-allocating buffers in a producer / consumer pipeline.

M.size(ctx, seq_id)
ctxion7.core.Context
seq_idinteger
→ integer

M.save_file

File-backed save / load — drives `seq_save_state` / `seq_load_state` so a session's KV can persist across process restarts without going through a Lua-string blob. Each helper returns the underlying call's success boolean.

M.save_file(ctx, path, seq_id)
ctxion7.core.Context
pathstring
seq_idinteger
→ boolean

M.load_file

M.load_file(ctx, path, dst_seq_id)
ctxion7.core.Context
pathstring
dst_seq_idinteger
→ boolean