REQ-STOR-008: Append-only JSONL audit log with rotation and untruncated payloads¶
What it requires
- Given an enabled logger, When initialize() is called, Then audit.jsonl exists at log_path(); When record() is called, Then exactly one parseable JSON line is appended carrying tool_name, caller_id, sequence, session_id and timestamp.
- Given multiple records, Then sequence numbers are monotonic and entry_count() equals the number of record() calls.
- Given many threads recording concurrently, Then every line is complete valid JSON and no sequence number is duplicated.
- Given an existing audit.jsonl, When a new logger initializes, Then prior lines are preserved and new ones appended.
- Given max_file_size exceeded, Then the file rotates and the number of retained rotated files respects max_files.
- Given oversized params/result strings, When serialized and read back, Then they are byte-identical to the input.
- Given enabled=false, When record() is called, Then no file is created.
- tier
- NOT_RUN
How it is met
Implemented by
audit_entry_from_jsonsrc/storage/audit_entry.cpp:80audit_entry_to_jsonsrc/storage/audit_entry.cpp:53entropic_audit_countsrc/facade/entropic_audit.cpp:49entropic_audit_flushsrc/facade/entropic_audit.cpp:33entropic_audit_readsrc/facade/entropic_audit.cpp:72entry_countsrc/storage/audit_logger.cpp:128extract_parent_idsrc/storage/audit_entry.cpp:24flushsrc/storage/audit_logger.cpp:114hook_callbacksrc/storage/audit_logger.cpp:211initializesrc/storage/audit_logger.cpp:48log_pathsrc/storage/audit_logger.cpp:138parse_result_fieldssrc/storage/audit_entry.cpp:39populate_from_hook_contextsrc/storage/audit_logger.cpp:246recordsrc/storage/audit_logger.cpp:72write_linesrc/storage/audit_logger.cpp:95
Tests (41)
Reached through calls
41 tests: 41 absent
| test | result | linked by | implementers exercised | calls away |
|---|---|---|---|---|
Audit entry is recorded when a tool call executes | absent | inferred | 7 of 15 | 1 |
AuditLogger entry_count matches record calls | absent | inferred | 5 of 15 | 1 |
AuditLogger flush forces write to disk | absent | inferred | 5 of 15 | 1 |
Disabled AuditLogger creates no file | absent | inferred | 5 of 15 | 1 |
AuditEntry from_json ignores extra fields | absent | inferred | 4 of 15: audit_entry_from_json, audit_entry_to_json, extract_parent_id, parse_result_fields | 1 |
AuditEntry preserves large params without truncation | absent | inferred | 4 of 15: audit_entry_from_json, audit_entry_to_json, extract_parent_id, parse_result_fields | 1 |
AuditEntry preserves large result content | absent | inferred | 4 of 15: audit_entry_from_json, audit_entry_to_json, extract_parent_id, parse_result_fields | 1 |
AuditEntry round-trips through JSON | absent | inferred | 4 of 15: audit_entry_from_json, audit_entry_to_json, extract_parent_id, parse_result_fields | 1 |
AuditLogger appends to existing file | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger concurrent writes produce no duplicates | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger flush_interval batches writes | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger records a single JSONL line | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger records multiple entries | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger rotates at max_file_size | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger rotation respects max_files | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditLogger sequence numbers are monotonic | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
Concurrent writes produce complete JSON lines | absent | inferred | 4 of 15: audit_entry_to_json, initialize, record, write_line | 1 |
AuditEntry from_json fails on missing required field | absent | inferred | 3 of 15: audit_entry_from_json, extract_parent_id, parse_result_fields | 1 |
Audit count on engine with no logger | absent | inferred | 2 of 15: entropic_audit_count, entry_count | 1 |
entropic_audit_count on NULL handle returns INVALID_HANDLE | absent | inferred | 2 of 15: entropic_audit_count, entry_count | 1 |
entropic_audit_count with NULL out pointer returns INVALID_ARGUMENT | absent | inferred | 2 of 15: entropic_audit_count, entry_count | 1 |
entropic_audit_flush on NULL handle returns INVALID_HANDLE | absent | inferred | 2 of 15: entropic_audit_flush, flush | 1 |
entropic_audit_flush on a handle with no audit_logger is a no-op | absent | inferred | 2 of 15: entropic_audit_flush, flush | 1 |
entropic_audit_flush rejects NULL handle | absent | inferred | 2 of 15: entropic_audit_flush, flush | 1 |
AuditEntry serializes all fields to JSON | absent | inferred | 1 of 15: audit_entry_to_json | 1 |
AuditEntry serializes directive array correctly | absent | inferred | 1 of 15: audit_entry_to_json | 1 |
AuditEntry serializes empty directives as empty array | absent | inferred | 1 of 15: audit_entry_to_json | 1 |
AuditEntry serializes null parent_conversation_id | absent | inferred | 1 of 15: audit_entry_to_json | 1 |
AuditLogger creates file on initialize | absent | inferred | 1 of 15: initialize | 1 |
AuditLogger log_path returns correct path | absent | inferred | 1 of 15: log_path | 1 |
Per-handle log scope routes session.log writes per handle | absent | inferred | 1 of 15: flush | 1 |
entropic_audit_count on configured handle returns 0 | absent | inferred | 1 of 15: entropic_audit_count | 1 |
entropic_audit_count on fresh handle returns 0 (no logger) | absent | inferred | 1 of 15: entropic_audit_count | 1 |
entropic_audit_count rejects NULL handle | absent | inferred | 1 of 15: entropic_audit_count | 1 |
entropic_audit_count rejects NULL out-pointer | absent | inferred | 1 of 15: entropic_audit_count | 1 |
entropic_audit_read of a populated JSONL file returns each line | absent | inferred | 1 of 15: entropic_audit_read | 1 |
entropic_audit_read of an empty JSONL file returns an empty array | absent | inferred | 1 of 15: entropic_audit_read | 1 |
entropic_audit_read on NULL handle returns INVALID_HANDLE | absent | inferred | 1 of 15: entropic_audit_read | 1 |
entropic_audit_read with NULL args returns INVALID_ARGUMENT | absent | inferred | 1 of 15: entropic_audit_read | 1 |
entropic_audit_read with a missing file returns IO | absent | inferred | 1 of 15: entropic_audit_read | 1 |
setup_session + register_handle_log don't double-write | absent | inferred | 1 of 15: flush | 1 |