Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
DEMO
Loading...
Searching...
No Matches
signet::forge::InferenceLogWriter Class Reference

Writes ML inference records to Parquet files with cryptographic hash chaining for tamper-evident audit trails. More...

#include <inference_log.hpp>

Public Member Functions

 InferenceLogWriter (const std::string &output_dir, const std::string &chain_id="", size_t max_records=100000)
 Create an inference log writer.
 
expected< HashChainEntrylog (const InferenceRecord &record)
 Log an inference event.
 
expected< void > flush ()
 Flush current records to a Parquet file.
 
expected< void > close ()
 Close the writer (flushes remaining records).
 
AuditMetadata current_metadata () const
 Get the chain metadata for the current batch.
 
size_t pending_records () const
 Get the number of records in the current (unflushed) batch.
 
int64_t total_records () const
 Get the total number of records written across all files.
 
std::string current_file_path () const
 Get the file path of the current (or last written) output file.
 

Detailed Description

Writes ML inference records to Parquet files with cryptographic hash chaining for tamper-evident audit trails.

Usage: InferenceLogWriter writer("/audit/inference"); InferenceRecord rec; rec.timestamp_ns = now_ns(); rec.model_id = "bert-base-v2"; rec.model_version = "a1b2c3d4"; rec.inference_type = InferenceType::CLASSIFICATION; rec.latency_ns = 12500000; // 12.5ms // ... fill other fields ... auto entry = writer.log(rec); writer.close();

Files are named: inference_log_{chain_id}_{start_seq}_{end_seq}.parquet Each file embeds AuditMetadata in the Parquet key-value metadata for chain continuity verification across file rotations.

Definition at line 486 of file inference_log.hpp.

Constructor & Destructor Documentation

◆ InferenceLogWriter()

signet::forge::InferenceLogWriter::InferenceLogWriter ( const std::string &  output_dir,
const std::string &  chain_id = "",
size_t  max_records = 100000 
)
inline

Create an inference log writer.

Parameters
output_dirDirectory to write Parquet files to
chain_idUnique chain identifier (auto-generated if empty)
max_recordsMax records per file before rotating (default 100,000)

Definition at line 492 of file inference_log.hpp.

Member Function Documentation

◆ close()

expected< void > signet::forge::InferenceLogWriter::close ( )
inline

Close the writer (flushes remaining records).

Definition at line 650 of file inference_log.hpp.

◆ current_file_path()

std::string signet::forge::InferenceLogWriter::current_file_path ( ) const
inline

Get the file path of the current (or last written) output file.

Definition at line 695 of file inference_log.hpp.

◆ current_metadata()

AuditMetadata signet::forge::InferenceLogWriter::current_metadata ( ) const
inline

Get the chain metadata for the current batch.

Returns metadata describing the hash chain state, including the chain ID, first/last sequence numbers, and boundary hashes.

Definition at line 661 of file inference_log.hpp.

◆ flush()

expected< void > signet::forge::InferenceLogWriter::flush ( )
inline

Flush current records to a Parquet file.

Writes all pending records to a new Parquet file with the schema defined by inference_log_schema(). The hash chain metadata is embedded in the file's key-value metadata section.

Definition at line 567 of file inference_log.hpp.

◆ log()

expected< HashChainEntry > signet::forge::InferenceLogWriter::log ( const InferenceRecord record)
inline

Log an inference event.

Returns the hash chain entry.

The record is serialized, hashed, and appended to the hash chain. If the pending buffer reaches max_records, the file is automatically flushed and rotated.

Definition at line 531 of file inference_log.hpp.

◆ pending_records()

size_t signet::forge::InferenceLogWriter::pending_records ( ) const
inline

Get the number of records in the current (unflushed) batch.

Definition at line 685 of file inference_log.hpp.

◆ total_records()

int64_t signet::forge::InferenceLogWriter::total_records ( ) const
inline

Get the total number of records written across all files.

Definition at line 690 of file inference_log.hpp.


The documentation for this class was generated from the following file: