![]() |
Signet Forge 0.1.0
C++20 Parquet library with AI-native extensions
|
DEMO |
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< HashChainEntry > | log (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. | |
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.
|
inline |
Create an inference log writer.
| output_dir | Directory to write Parquet files to |
| chain_id | Unique chain identifier (auto-generated if empty) |
| max_records | Max records per file before rotating (default 100,000) |
Definition at line 492 of file inference_log.hpp.
|
inline |
Close the writer (flushes remaining records).
Definition at line 650 of file inference_log.hpp.
|
inline |
Get the file path of the current (or last written) output file.
Definition at line 695 of file inference_log.hpp.
|
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.
|
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.
|
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.
|
inline |
Get the number of records in the current (unflushed) batch.
Definition at line 685 of file inference_log.hpp.
|
inline |
Get the total number of records written across all files.
Definition at line 690 of file inference_log.hpp.