feat: BACKFILL_HOURS env var to replay Jetstream history for backfilling

Author: Aaron Steven White
Commit aedb601e59aed974e60f478a74585fe3ac5747b5
Parent: 2180e05b32
Structural diff unavailable

These commits were pushed via plain git push, so no pre-parsed schemas are available. Install git-remote-cospan and re-push via panproto:// to see scope-level changes, breaking change detection, and semantic diffs.

brew install panproto/tap/git-remote-cospan
4 files changed +26 -4
@@ -1,5 +1,11 @@
11 # Changelog
22 
3+## v0.5.3
4+
5+- All Row struct fields now have `#[serde(default)]` so panproto transforms that don't produce every field don't crash deserialization
6+- Added `BACKFILL_HOURS` env var: set to replay Jetstream history (up to ~72h) to backfill Tangled and Cospan records
7+- Restored original logo and favicon
8+
39 ## v0.5.0
410 
511 ### Reskin + Tangled interop
@@ -436,7 +436,7 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
436436 
437437 [[package]]
438438 name = "cospan-appview"
439-version = "0.5.0"
439+version = "0.5.3"
440440 dependencies = [
441441  "anyhow",
442442  "async-trait",
@@ -482,7 +482,7 @@ dependencies = [
482482 
483483 [[package]]
484484 name = "cospan-codegen"
485-version = "0.5.0"
485+version = "0.5.3"
486486 dependencies = [
487487  "anyhow",
488488  "panproto-check",
@@ -499,7 +499,7 @@ dependencies = [
499499 
500500 [[package]]
501501 name = "cospan-node"
502-version = "0.5.0"
502+version = "0.5.3"
503503 dependencies = [
504504  "anyhow",
505505  "async-trait",
@@ -7,7 +7,7 @@ members = [
77 resolver = "2"
88 
99 [workspace.package]
10-version = "0.5.0"
10+version = "0.5.3"
1111 edition = "2024"
1212 license = "AGPL-3.0-or-later"
1313 repository = "https://github.com/cospan-dev/cospan"
@@ -36,6 +36,22 @@ async fn main() -> anyhow::Result<()> {
3636     sqlx::migrate!("./migrations").run(&pool).await?;
3737     tracing::info!("database migrations applied");
3838 
39+    // Backfill: if BACKFILL_HOURS is set, reset the cursor to N hours ago
40+    // so the indexer replays Jetstream history (up to ~72h retained)
41+    if let Some(h) = std::env::var("BACKFILL_HOURS")
42+        .ok()
43+        .and_then(|s| s.parse::<i64>().ok())
44+    {
45+        let now_us = chrono::Utc::now().timestamp_micros();
46+        let backfill_us = now_us - (h * 3600 * 1_000_000);
47+        cospan_appview::db::cursor::save_cursor(&pool, backfill_us).await?;
48+        tracing::info!(
49+            hours = h,
50+            cursor_us = backfill_us,
51+            "backfill: cursor reset to {h} hours ago"
52+        );
53+    }
54+
3955     // Initialize auth infrastructure
4056     let dpop_key = DpopKey::generate();
4157     tracing::info!(kid = %dpop_key.kid, "DPoP signing key generated");
cospan · schematic version control on atproto built on AT Protocol