Skip to main content

Module shell_init

Module shell_init 

Source
Expand description

Shell-init profile reader, aggregator, and rotation.

Profile files are written by the timing wrapper that crate::shell::generate_init_script embeds in dodot-init.sh. Each shell startup emits one TSV under <data_dir>/probes/shell-init/profile-<unix_ts>-<pid>-<rand>.tsv with the shape:

# dodot shell-init profile v1
# shell\tbash 5.3.9(1)-release
# start_t\t1714000000.123456
# init_script\t/home/alice/.local/share/dodot/shell/dodot-init.sh
# columns\tphase\tpack\thandler\ttarget\tstart_t\tend_t\texit_status
path\tvim\tpath\t/home/alice/dotfiles/vim/bin\t1714000000.123500\t1714000000.123502\t0
source\tvim\tshell\t/home/alice/dotfiles/vim/aliases.sh\t1714000000.123600\t1714000000.124900\t0
# end_t\t1714000000.125100

Both the reader and the rotator are tolerant of malformed input — a partial write from a crashed shell should leave the next dodot probe shell-init working, just with a short report.

Structs§

AggregatedTarget
Per-target stats across N runs.
AggregatedView
Aggregate output, one row per (pack, handler, target) keyed by all the profiles passed in.
GroupedProfile
Aggregate one profile by (pack, handler) for the rendered table.
HistoryEntry
One row in the history view: a single run’s headline metrics.
Profile
A whole profile file, post-parse.
ProfileEntry
One parsed entry row from a profile TSV.
ProfileErrorRecord
One captured stderr record from a sourced shell file. The shell wrapper writes one record per source whose stderr was non-empty, regardless of exit status (warnings emitted on a successful source are surfaced too).
ProfileGroup

Functions§

aggregate_profiles
Roll up a slice of profiles into per-target percentile stats.
group_profile
Roll up a profile into per-(pack, handler) groups for display.
parse_errors_log
Parse the textual content of an errors log. Format:
parse_profile
Parse the textual content of a profile file. Tolerates missing preamble lines, unknown comments, and malformed rows (skipped).
read_latest_profile
Read the most recently written profile under <data_dir>/probes/shell-init/, or None if the directory is empty / missing.
read_recent_profiles
Read up to limit most recent profiles, newest first.
rotate_profiles
Prune <data_dir>/probes/shell-init/ to the newest keep files (by filename). Returns the number of files removed. keep == 0 is treated as “no pruning” — we don’t want a stray miscalibrated config to wipe the whole profile history.
summarize_history
Build a history view from a slice of profiles (newest-first input, preserved order in the output — caller decides cadence).