story-kit: merge 133_story_clean_up_agent_state_on_story_archive_and_add_ttl_for_completed_entries

This commit is contained in:
Dave
2026-02-24 13:20:59 +00:00
parent e49be6b905
commit 6170a7d984
4 changed files with 267 additions and 13 deletions

View File

@@ -95,6 +95,21 @@ async fn main() -> Result<(), std::io::Error> {
let app = build_routes(ctx);
// Background reaper: periodically remove completed/failed agent entries
// that have exceeded the TTL.
{
let reaper_agents = Arc::clone(&startup_agents);
let ttl = std::time::Duration::from_secs(agents::DEFAULT_AGENT_TTL_SECS);
tokio::spawn(async move {
// Check every 5 minutes.
let interval = std::time::Duration::from_secs(300);
loop {
tokio::time::sleep(interval).await;
reaper_agents.reap_expired_agents(ttl);
}
});
}
// On startup:
// 1. Reconcile any stories whose agent work was committed while the server was
// offline (worktree has commits ahead of master but pipeline didn't advance).