replace libc date math with chrono, extract memory_subdir helper

- date_to_epoch, iso_week_info, weeks_in_month: replaced unsafe libc
  (mktime, strftime, localtime_r) with chrono NaiveDate and IsoWeek
- epoch_to_local: replaced unsafe libc localtime_r with chrono Local
- New util.rs with memory_subdir() helper: ensures subdir exists and
  propagates errors instead of silently ignoring them
- Removed three duplicate agent_results_dir() definitions across
  digest.rs, consolidate.rs, enrich.rs
- load_digest_files, parse_all_digest_links, find_consolidation_reports
  now return Result to properly propagate directory creation errors

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2026-03-03 17:23:43 -05:00
parent 50da0b7b26
commit f4364e299c
7 changed files with 75 additions and 129 deletions

View file

@ -14,6 +14,7 @@
// interference detection, schema assimilation, reconsolidation.
mod store;
mod util;
mod llm;
mod digest;
mod audit;
@ -739,8 +740,7 @@ fn cmd_apply_agent(args: &[String]) -> Result<(), String> {
// Move processed file to avoid re-processing
if !process_all {
let done_dir = results_dir.join("done");
std::fs::create_dir_all(&done_dir).ok();
let done_dir = util::memory_subdir("agent-results/done")?;
let dest = done_dir.join(path.file_name().unwrap());
std::fs::rename(&path, &dest).ok();
}
@ -793,7 +793,7 @@ fn cmd_digest(args: &[String]) -> Result<(), String> {
fn cmd_digest_links(args: &[String]) -> Result<(), String> {
let do_apply = args.iter().any(|a| a == "--apply");
let links = digest::parse_all_digest_links();
let links = digest::parse_all_digest_links()?;
println!("Found {} unique links from digest files", links.len());
if !do_apply {