flowchart TB
subgraph LEFT["Replay Command — lrs replay --from T1 --to T2 --into <table>"]
direction TB
A1["Read immutable log for district + time window"]:::la
A2["Recompute projection, keyed by statement_id"]:::lasafe
A3["Write into new shadow table
invisible to live queries"]:::la
A4["Rebuild complete: atomic swap"]:::la
A5["Shadow table becomes the live table"]:::la
A1 --> A2 --> A3 --> A4 --> A5
end
subgraph RIGHT["Rebuild Graph Command — lrs replay --rebuild-graph"]
direction TB
B1["Reset summarizer watermark to zero"]:::ra
B2["Ordinary 60-second sync loop runs as normal"]:::ra
B3["Summarizer reads 'unsynced' rollups
which is now all of them"]:::ra
B4["MERGE upserts every summary vertex
guarded by the Grain Uniqueness Constraint"]:::rasafe
B5["Graph fully rebuilt, no dedicated rebuild code path"]:::ra
B1 --> B2 --> B3 --> B4 --> B5
end
classDef la fill:#2a9d8f,stroke:#1f7a6f,color:#fff,font-size:13px
classDef lasafe fill:#1a7f72,stroke:#0f5c53,color:#fff,font-size:13px
classDef ra fill:#8fd3c9,stroke:#3bab9d,color:#0c2f2b,font-size:13px
classDef rasafe fill:#5cbcb0,stroke:#3bab9d,color:#08312c,font-size:13px
linkStyle default stroke:#999,stroke-width:2px