# Rotation for vectorapi's own access log (`access_log.path` in config.json).
#
# SHIPPED BUT NOT INSTALLED BY THE PACKAGE, because the log itself is off by
# default: a package that starts rotating a file nobody asked for is the same
# unrequested commitment as writing it. Copy to
# /etc/logrotate.d/smartbotic-vectorapi when the log is turned on.
#
# WHY THIS MATTERS MORE THAN DISK. This file names callers, so an IP address is
# personal data and retention is a legal question as much as a capacity one.
# 14 days matches what nginx's own rotation keeps on prod, so the two logs a
# diagnosis joins across do not disagree about how far back they go.
#
# AND THE CAUTIONARY TALE IS THIS BOX: logrotate was never installed on prod at
# all, so nginx's access log ran unrotated from 2025-11-24 to 2026-10-22 and
# reached 245 MB - which also made every "by hour" aggregate silently span
# eleven months bucketed by hour-of-day, producing a clean plausible histogram
# of the wrong thing. Verify `systemctl list-timers | grep logrotate` actually
# shows a timer before believing any of this runs.
/var/log/smartbotic-vectorapi/access.log {
    daily
    rotate 14
    missingok
    notifempty
    compress
    delaycompress
    # COPYTRUNCATE deliberately. The server holds the file open on an O_APPEND
    # fd and has no SIGHUP reopen, so `create` would leave it writing to the
    # renamed inode forever and the new file would stay empty - the exact
    # silent failure logrotate's postrotate hook exists to avoid for nginx.
    # The cost is a small race in which lines written during the copy can be
    # lost; for an access log that is the right trade against a log that
    # silently stops.
    copytruncate
    # 0640 and adm, matching nginx's own rotated logs: readable by an operator
    # in `adm` and by a monitor, not by everyone with a shell.
    create 0640 root adm
}
