1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//! Where the durable event log lives, and how long it is kept.
//!
//! Why: the directory and retention window are the two facts every other
//! `log/` submodule needs and none of them should decide on its own — keeping
//! both here is what lets [`super::writer`], [`super::recovery`] and
//! [`super::replay`] agree without importing each other.
//! What: [`LogConfig`] is the console's private event-log directory
//! (`<data dir>/trusty-console/event_log/`, resolved through
//! [`trusty_common::resolve_data_dir`], never a raw `create_dir_all`) plus
//! `retain_days`. [`day_file_name`]/[`parse_day_file_name`] are the one
//! filename format every submodule reads and writes
//! (`YYYY-MM-DD.ndjson`), so a rename in one place can't drift from a parse
//! in another.
//! Test: `super::tests::day_file_name_round_trips`,
//! `super::tests::parse_day_file_name_rejects_a_non_matching_name`.
use PathBuf;
use NaiveDate;
use LogError;
/// Subdirectory of the console data directory the durable log lives under.
pub const LOG_SUBDIR: &str = "event_log";
/// Extension every day file carries.
pub const LOG_FILE_EXT: &str = "ndjson";
/// How many calendar days of day files are kept by default (DOC-73 §4.3's
/// "rotated and retained" requirement; no fixed number is specified there, so
/// a week is the simplest sane default — long enough that a viewer reattaching
/// after a weekend still gets replay, short enough that an idle console does
/// not accumulate files forever).
pub const DEFAULT_RETAIN_DAYS: u32 = 7;
/// Bounded capacity of the channel between [`super::EventBus::ingest`] and the
/// writer task. Sized well above any burst this workspace's harnesses are
/// expected to produce (DOC-73 §4.3's ring defaults to 8192 for the same
/// reason) while still being a real, enforced bound — see
/// `super::tests::backpressure_drops_are_counted_and_do_not_block_ingest` for
/// what happens once it fills.
pub const WRITE_CHANNEL_CAPACITY: usize = 4096;
/// Construction-time configuration for [`super::DurableLog`].
pub
/// The on-disk filename for `date`'s day file: `YYYY-MM-DD.ndjson`.
///
/// Test: `super::tests::day_file_name_round_trips`.
pub
/// Parse a day file's date back out of its filename, `None` for anything that
/// does not match [`day_file_name`]'s exact format — including another file a
/// human or another tool dropped in the same directory, which must be ignored
/// rather than crash the listing.
///
/// Test: `super::tests::day_file_name_round_trips`,
/// `super::tests::parse_day_file_name_rejects_a_non_matching_name`.
pub