Fix agentic reel audit issues: midnight bug, DAO wiring, dead code, DST timezone, validation

Blocking fixes:
- secs_until_next_run_hour: same-hour now returns 0 instead of 24h
- capture_prefs: called at both handler return points, never fails request
- capture_prefs: resolves library param, upserts to user_ai_prefs via DAO
- Scheduler: uses AppState DAOs instead of separate connections
- Pregen dedup: uses resolved library param instead of hardcoded 'all'
- run_readonly_tool_loop: added #[allow(dead_code)] (used in main.rs only)
- run_readonly_tool_loop: removed dead messages.push() call
- InsightGenerator: added exif_dao() getter for scheduler reuse

Medium fixes:
- Input validation: run_hour clamped 0-23, week_dow clamped 0-6
- DST-sensitive timezone: fixed_tz_offset() with env var config

Low fixes:
- Documented REEL_PREGEN_MAX_TOOL_ITERS and REEL_PREGEN_TZ_FIXED_MINUTES
- Removed dead test_app_state function and unused imports

Also fix: UpsertUserAiPrefs import path, chrono::Local::with_ymd_and_hms
requires TimeZone trait + .single(), unwrap_or_else closure simplification
This commit is contained in:
Cameron Cordes committed 2026-06-13 14:59:00 -04:00
1 parent f707353807
commit 5c9ee56527
4 files changed
+151 -180

No files matched your search

+11 -2
View File
@@ -217,6 +217,13 @@ impl InsightGenerator {
&self.insight_dao
}
/// Accessor for the EXIF DAO (used by the reel scheduler to resolve
/// GPS enrichment without creating a separate DB connection).
#[allow(dead_code)]
pub fn exif_dao(&self) -> &Arc<Mutex<Box<dyn ExifDao>>> {
&self.exif_dao
}
/// Whether the optional Apollo Places integration is wired up. Drives
/// tool-definition gating (no point offering `get_personal_place_at`
/// when Apollo is unreachable) — exposed publicly so `insight_chat`
@@ -4509,6 +4516,9 @@ Return ONLY the summary, nothing else."#,
///
/// Calls `execute_tool` with empty file/image context; enabled tools
/// never read those fields.
///
/// Only used by the `reels` module (compiled in `main.rs`, not `lib.rs`),
/// so the `#[allow(dead_code)]` suppresses the lib-target warning.
#[allow(dead_code)]
pub(crate) async fn run_readonly_tool_loop(
&self,
@@ -4592,8 +4602,7 @@ Return ONLY the summary, nothing else."#,
.chat()
.chat_with_tools(messages.clone(), vec![])
.await?;
final_content = final_response.content.clone();
messages.push(final_response);
final_content = final_response.content;
}
Ok(final_content)