# Streams dshackle access-log lines unchanged, and every 1000 lines OR 30s
# injects a __shipstat__ checkpoint carrying the cumulative sent-count for this
# connection. The splits cruncher (claude host) filters these OUT of event
# processing and uses them to reconcile shipped-vs-ingested per gateway per hour
# — the completeness signal the time-based floor cannot see (event-loss-by-
# rotation, 2026-07-10). `sess` = connection-start epoch so the cruncher detects
# counter resets on shipper reconnect (retry loop resumes at file END).
BEGIN { sess = systime(); last = sess; n = 0 }
{
    n++
    print
    now = systime()
    if (n % 1000 == 0 || now - last >= 30) {
        printf "{\"__shipstat__\":1,\"sess\":%d,\"sent\":%d,\"ts\":%d}\n", sess, n, now
        fflush()
        last = now
    }
}
