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

Writes AI trading decision records to Parquet files with cryptographic hash chaining for tamper-evident audit trails. More...

#include <decision_log.hpp>

Public Member Functions

 DecisionLogWriter (const std::string &output_dir, const std::string &chain_id="", size_t max_records=100000)
 Create a decision log writer.
 
void set_instrument_validator (std::function< bool(const std::string &)> validator)
 Set an optional symbol/instrument validator callback (MiFID II RTS 24).
 
expected< HashChainEntrylog (const DecisionRecord &record)
 Log a trading decision.
 
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 AI trading decision records to Parquet files with cryptographic hash chaining for tamper-evident audit trails.

Usage: DecisionLogWriter writer("/audit/decisions"); DecisionRecord rec; rec.timestamp_ns = now_ns(); rec.strategy_id = 1; rec.symbol = "BTC-USD"; // ... fill other fields ... auto entry = writer.log(rec); writer.close();

Files are named: decision_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 553 of file decision_log.hpp.

Constructor & Destructor Documentation

◆ DecisionLogWriter()

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

Create a decision 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 559 of file decision_log.hpp.

Member Function Documentation

◆ close()

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

Close the writer (flushes remaining records).

Definition at line 734 of file decision_log.hpp.

◆ current_file_path()

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

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

Definition at line 780 of file decision_log.hpp.

◆ current_metadata()

AuditMetadata signet::forge::DecisionLogWriter::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 745 of file decision_log.hpp.

◆ flush()

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

Flush current records to a Parquet file.

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

Definition at line 652 of file decision_log.hpp.

◆ log()

expected< HashChainEntry > signet::forge::DecisionLogWriter::log ( const DecisionRecord record)
inline

Log a trading decision.

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 610 of file decision_log.hpp.

◆ pending_records()

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

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

Definition at line 770 of file decision_log.hpp.

◆ set_instrument_validator()

void signet::forge::DecisionLogWriter::set_instrument_validator ( std::function< bool(const std::string &)>  validator)
inline

Set an optional symbol/instrument validator callback (MiFID II RTS 24).

If set, each record's symbol is validated before logging. Invalid symbols cause log() to return INVALID_ARGUMENT.

Definition at line 601 of file decision_log.hpp.

◆ total_records()

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

Get the total number of records written across all files.

Definition at line 775 of file decision_log.hpp.


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