Restore immediate log persistence

ober

382c056c7b92fbfabfb65461b38b54d94001cbc6

diff --git a/README.md b/README.md
index 38b42d9..7fccf4d 100644
--- a/README.md
+++ b/README.md
@@ -123,10 +123,11 @@ durability issues, use:
 jerboa-signal --trace-all /tmp/jerboa-signal.raw.trace --log-persist immediate tui
 ```
 
-The default is `close`, which defers jsqlite encrypted-container writes until
-clean exit so the TUI does not pause while rewriting a large encrypted history.
-`--log-persist immediate` persists after every logged message. If the process
-crashes in close-only mode, new log rows from that session may be lost.
+The default is `immediate`, which persists after every logged message so other
+readers and future app launches see the newest rows even if the TUI exits
+uncleanly. `--log-persist close` defers jsqlite encrypted-container writes until
+clean exit, which can reduce pauses with a large encrypted history, but new rows
+from that session may be lost if the process crashes.
 
 ## Security
 
diff --git a/signal/logdb.ss b/signal/logdb.ss
index 7e5c8b0..b5b1fad 100644
--- a/signal/logdb.ss
+++ b/signal/logdb.ss
@@ -354,7 +354,7 @@
   (def (log-persist-policy)
     (let ([v (getenv "JERBOA_SIGNAL_LOG_PERSIST")])
       (cond
-        [(not (and (string? v) (not (string=? v "")))) 'close]
+        [(not (and (string? v) (not (string=? v "")))) 'immediate]
         [(or (string-ci=? v "close")
              (string-ci=? v "defer")
              (string-ci=? v "deferred")
diff --git a/tests/test-logdb-jsqlite.ss b/tests/test-logdb-jsqlite.ss
index 2a60d5c..02ffc14 100644
--- a/tests/test-logdb-jsqlite.ss
+++ b/tests/test-logdb-jsqlite.ss
@@ -32,6 +32,8 @@
 (delete-if-exists! path)
 (delete-if-exists! (string-append path ".tmp"))
 
+(putenv "JERBOA_SIGNAL_LOG_PERSIST" "")
+
 (check "logdb backend available" (logdb-available?))
 
 (let ([h (logdb-open path "correct horse")])
@@ -47,6 +49,15 @@
          (equal? (logdb-recent h 10)
                  (list (list "in" "direct:+15550001" "Alice"
                              1000 "data" "hello"))))
+  (let ([reader (logdb-open path "correct horse")])
+    (check "default persists rows before close" reader)
+    (check "second handle sees unclosed writes"
+           (= (logdb-count reader) 2))
+    (check "recent persisted before close"
+           (equal? (logdb-recent reader 10)
+                   (list (list "in" "direct:+15550001" "Alice"
+                               1000 "data" "hello"))))
+    (logdb-close reader))
   (logdb-close h))
 
 (let ([bytes (read-file-bytevector path)])