D1/daemon hook: refresh the index if this cached project server's last sync is older than `threshold_secs`. Called by the daemon on a `project_server` cache hit so a long-lived cached server heals like a freshly launched one. Non-blocking: it kicks the same detached D4 refresh and returns immediately.
(&self, threshold_secs: u64)
| 1442 | /// freshly launched one. Non-blocking: it kicks the same detached D4 |
| 1443 | /// refresh and returns immediately. |
| 1444 | pub async fn refresh_if_session_stale(&self, threshold_secs: u64) { |
| 1445 | if !self.sync_config.read_refresh && !self.sync_config.auto_watch { |
| 1446 | return; |
| 1447 | } |
| 1448 | let cg = self.cg_snapshot().await; |
| 1449 | if cg.branch_drifted() { |
| 1450 | return; |
| 1451 | } |
| 1452 | let now = crate::tracedecay::current_timestamp(); |
| 1453 | let last_sync = cg.last_sync_timestamp().await; |
| 1454 | if last_sync != 0 && now.saturating_sub(last_sync) < threshold_secs as i64 { |
| 1455 | return; |
| 1456 | } |
| 1457 | // Single-flight against the read-refresh machinery. |
| 1458 | if self |
| 1459 | .background_refresh_running |
| 1460 | .compare_exchange(false, true, Ordering::AcqRel, Ordering::Acquire) |
| 1461 | .is_err() |
| 1462 | { |
| 1463 | return; |
| 1464 | } |
| 1465 | self.last_background_refresh_at |
| 1466 | .store(now, Ordering::Release); |
| 1467 | self.spawn_read_refresh_task(&cg, self.sync_config.full_sync_escalation_files); |
| 1468 | } |
| 1469 | |
| 1470 | /// Returns a compact one-line notice when automation runs have staged |
| 1471 | /// output awaiting review (skill drafts, fact proposals) that the user |
nothing calls this directly
no test coverage detected