carlos / platform Public

litestream: hold replication logs to warnings (#802)

carlos-litestream.service sets LOG_LEVEL=warn; the activator's embedded
replicator gets a WARN-floor slog handler. At INFO litestream logged a
line per database per sync and a 256M journal kept about two hours.
Census approval census-ruling-litestream-quiet-802 (Astra, #280).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from litestream-quiet-802 into main.
claude agent, operated by paul@keymail.dev 3a8eabde708115019360c538581b779884954b8e parent 32a59ad
8 files changed, +138 −0
  • docs/superpowers/notes/census-proposal-litestream-quiet-802.md +19 −0
  • internal/host/units/carlos-litestream.service +6 −0
  • internal/host/units_isolation_test.go +14 −0
  • internal/lease/lease.go +1 −0
  • internal/lease/quietlog.go +41 −0
  • internal/lease/quietlog_test.go +50 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-litestream-quiet-802.tsv +6 −0

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-litestream-quiet-802.md b/docs/superpowers/notes/census-proposal-litestream-quiet-802.md
new file mode 100644
index 000000000..76d8ab119
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-litestream-quiet-802.md
@@ -0,0 +1,19 @@
+# Census approval: litestream-quiet-802
+
+Ruling `census-ruling-litestream-quiet-802`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/host/units/carlos-litestream.service` `external` | body | unchanged (1) | adds Environment=LOG_LEVEL=warn (litestream logs warnings and errors only, #802); ExecStart, user, sandboxing, EnvironmentFile and the config path it reads are unchanged; no new read |
+
+Envelopes re-pinned: `internal/host/units`, `internal/lease`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/host/units/carlos-litestream.service` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-ls284;basis=MemoryMax 256M -> 512M, adds Environment=GOMEMLIMIT=384MiB and RestartSteps=5/RestartMaxDelaySec=60 backoff; ExecStart, user, sandboxing and the config path it reads are unchanged; no new read
+
+Seal: `837f27a6b7b6ed272f8c68aca07650fa32cf3ec92ce28bf9d812a4282eeb0b58` → `6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-litestream-quiet-802.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/host/units/carlos-litestream.service b/internal/host/units/carlos-litestream.service
index 89472b450..235421d3b 100644
--- a/internal/host/units/carlos-litestream.service
+++ b/internal/host/units/carlos-litestream.service
@@ -15,6 +15,12 @@ Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/litestream replicate -config /etc/litestream.yml
EnvironmentFile=/data/litestream.env
+# Warnings and errors only. At INFO litestream logs one "replica sync" line
+# per database per sync, about 220k lines an hour on a box with a few dozen
+# databases, which pushed everything else out of a 256M journal after two
+# hours (discussion #802). LogLevelMax= is no substitute: journald stamps
+# every stdout line of this unit as info, so it would drop the errors too.
+Environment=LOG_LEVEL=warn
User=carlos
Group=carlos
CapabilityBoundingSet=
diff --git a/internal/host/units_isolation_test.go b/internal/host/units_isolation_test.go
index 9b7d8b114..3b1b98f09 100644
--- a/internal/host/units_isolation_test.go
+++ b/internal/host/units_isolation_test.go
@@ -635,3 +635,17 @@ func TestGenerationTemplateKeysNothingByItsInstanceString(t *testing.T) {
}
}
}
+
+// Litestream at INFO logs a line per database per sync and pushes everything
+// else out of a capped journal (#802). LOG_LEVEL holds it to warnings; a
+// LogLevelMax= would also drop its errors, since journald stamps every stdout
+// line of the unit as info.
+func TestLitestreamUnitLogsWarningsOnly(t *testing.T) {
+ l := readUnit(t, "carlos-litestream.service")
+ if !strings.Contains(l, "\nEnvironment=LOG_LEVEL=warn\n") {
+ t.Error("carlos-litestream.service does not set LOG_LEVEL=warn")
+ }
+ if strings.Contains(l, "\nLogLevelMax=") {
+ t.Error("carlos-litestream.service sets LogLevelMax=, which would drop litestream's errors")
+ }
+}
diff --git a/internal/lease/lease.go b/internal/lease/lease.go
index 389bf4804..e3d9bb2bc 100644
--- a/internal/lease/lease.go
+++ b/internal/lease/lease.go
@@ -457,6 +457,7 @@ func (h *Held) newStore(dbPath string, syncInterval time.Duration) (*litestream.
db.Replica.SyncInterval = syncInterval
}
store := litestream.NewStore([]*litestream.DB{db}, compactionLevels)
+ quietStoreLogs(store, db)
store.SnapshotInterval = SnapshotInterval
store.SnapshotRetention = SnapshotRetention
if h.generationPrefix != "" {
diff --git a/internal/lease/quietlog.go b/internal/lease/quietlog.go
new file mode 100644
index 000000000..315b56757
--- /dev/null
+++ b/internal/lease/quietlog.go
@@ -0,0 +1,41 @@
+package lease
+
+import (
+ "context"
+ "log/slog"
+ "path/filepath"
+
+ "github.com/benbjohnson/litestream"
+)
+
+// Litestream logs one INFO "replica sync" line per database on every sync.
+// The box-wide binary is held to WARN by LOG_LEVEL in its unit; this is the
+// same floor for the replicator embedded here, whose lines would otherwise
+// land in carlos's own journal through slog.Default(). On a capped journal
+// those lines are what pushed everything else out after about two hours
+// (discussion #802). Warnings and errors still come through.
+
+// warnFloor passes on only records at WARN or above.
+type warnFloor struct{ slog.Handler }
+
+func (h warnFloor) Enabled(ctx context.Context, l slog.Level) bool {
+ return l >= slog.LevelWarn && h.Handler.Enabled(ctx, l)
+}
+
+func (h warnFloor) WithAttrs(attrs []slog.Attr) slog.Handler {
+ return warnFloor{h.Handler.WithAttrs(attrs)}
+}
+
+func (h warnFloor) WithGroup(name string) slog.Handler {
+ return warnFloor{h.Handler.WithGroup(name)}
+}
+
+// quietStoreLogs replaces the loggers litestream.NewStore gave the store and
+// its database with the same ones held to WARN. Call it after NewStore and
+// before Open: NewStore sets the database's logger, Open starts the work
+// that logs.
+func quietStoreLogs(store *litestream.Store, db *litestream.DB) {
+ quiet := slog.New(warnFloor{slog.Default().Handler()}).With(litestream.LogKeySystem, litestream.LogSystemStore)
+ store.Logger = quiet
+ db.SetLogger(quiet.With(litestream.LogKeyDB, filepath.Base(db.Path())))
+}
diff --git a/internal/lease/quietlog_test.go b/internal/lease/quietlog_test.go
new file mode 100644
index 000000000..ad6ef9d3a
--- /dev/null
+++ b/internal/lease/quietlog_test.go
@@ -0,0 +1,50 @@
+package lease
+
+import (
+ "bytes"
+ "log/slog"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ lss3 "github.com/benbjohnson/litestream/s3"
+)
+
+// The embedded replicator's per-sync INFO lines stay out of carlos's journal
+// (#802); its warnings still reach it, labelled as litestream labels them.
+func TestNewStoreHoldsLitestreamToWarn(t *testing.T) {
+ var buf bytes.Buffer
+ prev := slog.Default()
+ slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: slog.LevelDebug})))
+ t.Cleanup(func() { slog.SetDefault(prev) })
+
+ l := lss3.NewLeaser()
+ l.Path = "instances/x.example/inc"
+ h := &Held{leaser: l, replicaClient: &generationFake{}}
+ store, db, err := h.newStore(filepath.Join(t.TempDir(), "app.db"), time.Second)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ db.Replica.Logger().Info("replica sync")
+ db.Logger.Info("db info")
+ store.Logger.Info("starting compaction monitor")
+ db.Replica.Logger().Warn("replica sync warn")
+ db.Logger.Error("compaction failed")
+
+ got := buf.String()
+ for _, quiet := range []string{"msg=\"replica sync\"", "db info", "starting compaction monitor"} {
+ if strings.Contains(got, quiet) {
+ t.Errorf("INFO line %s reached the log:\n%s", quiet, got)
+ }
+ }
+ for _, loud := range []string{"replica sync warn", "compaction failed"} {
+ if !strings.Contains(got, loud) {
+ t.Errorf("%q did not reach the log:\n%s", loud, got)
+ }
+ }
+ if !strings.Contains(got, "system=store") || !strings.Contains(got, "db=app.db") {
+ t.Errorf("warnings lost litestream's labels:\n%s", got)
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index a1bc01fc6..38f9dc899 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -154,3 +154,4 @@ plan14-root-reads-warm-set-published-724.tsv 158a30344d45448de74c9d6fbcc46eeab1e
plan14-root-reads-gvisor-probe-diag.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee
plan14-root-reads-deploy-happy-path.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee
plan14-root-reads-held-move-speed.tsv 837f27a6b7b6ed272f8c68aca07650fa32cf3ec92ce28bf9d812a4282eeb0b58
+plan14-root-reads-litestream-quiet-802.tsv 6d3ea7fccce1a7f4bc507b6eb8d368ed0b62f83022504aa04c7684c72c93aa9a
diff --git a/internal/provision/testdata/plan14-root-reads-litestream-quiet-802.tsv b/internal/provision/testdata/plan14-root-reads-litestream-quiet-802.tsv
new file mode 100644
index 000000000..34005d4fc
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-litestream-quiet-802.tsv
@@ -0,0 +1,6 @@
+# Census overlay litestream-quiet-802, written by census-propose (#369). census-ruling-litestream-quiet-802, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-litestream-quiet-802.md.
+# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 1c221b073d38eec62bf1995804256125ea66ba141a0cd32af975e6915d1ab1e4 internal/host/units/carlos-litestream.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-ls284;basis=MemoryMax 256M -> 512M, adds Environment=GOMEMLIMIT=384MiB and RestartSteps=5/RestartMaxDelaySec=60 backoff; ExecStart, user, sandboxing and the config path it reads are unchanged; no new read;rev3=census-ruling-litestream-quiet-802;basis=adds Environment=LOG_LEVEL=warn (litestream logs warnings and errors only, #802); ExecStart, user, sandboxing, EnvironmentFile and the config path it reads are unchanged; no new read file:external@0 c6b8a0aacef922143bc21c52b4c22bca98f90e6b7d3dbf8629dc7040f2a00664
+internal/host/units/carlos-litestream.service external legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-ls284;basis=MemoryMax 256M -> 512M, adds Environment=GOMEMLIMIT=384MiB and RestartSteps=5/RestartMaxDelaySec=60 backoff; ExecStart, user, sandboxing and the config path it reads are unchanged; no new read;rev3=census-ruling-litestream-quiet-802;basis=adds Environment=LOG_LEVEL=warn (litestream logs warnings and errors only, #802); ExecStart, user, sandboxing, EnvironmentFile and the config path it reads are unchanged; no new read file:external@0 c6b8a0aacef922143bc21c52b4c22bca98f90e6b7d3dbf8629dc7040f2a00664
+@coverage internal/host/units 429984217ca0fccd69aa739521fb2d7fc7851f050145c06ffaab8afc391d981e
+@coverage internal/lease f6505e89d92b6146c3394f2a61718e349da9b57649b50742d3ef71b5ae8a07de