/* Bio-Digital persistent state table (.bdst). */
#ifndef BIO_STATE_H_
#define BIO_STATE_H_

#include <stdint.h>

#include "bio/bio.h"
#include "bio/bio_gguf.h"

#define BIO_BDST_MAGIC 0x54534442u
#define BIO_BDST_PATH_BYTES 512u

typedef struct bio_state_table {
    uint32_t magic;
    uint32_t version;
    char gguf_path[BIO_BDST_PATH_BYTES];
    char delta_path[BIO_BDST_PATH_BYTES];
    char architecture[BIO_GGUF_MAX_ARCH_BYTES];
    uint32_t context_length;
    uint32_t embedding_length;
    uint32_t block_count;
    uint32_t feed_forward_length;
    uint32_t attention_head_count;
    uint32_t attention_head_count_kv;
    uint32_t vocab_size;
    uint32_t tensor_count;
    uint32_t tokenizer_token_count;
    uint64_t gguf_size;
    uint64_t checksum;
} bio_state_table;

bio_v1_status bio_state_create(const char *gguf_path, const char *state_path,
                               const char *delta_path);
bio_v1_status bio_state_load(const char *state_path, bio_state_table *state);
bio_v1_status bio_state_save(const char *state_path, const bio_state_table *state);
uint64_t bio_state_checksum(const bio_state_table *state);

#endif /* BIO_STATE_H_ */
