Generate SSD JSONL merging from typed Jerboa

ober

5a34d3d7ff6f4a28759f899207447358ddaa3753

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 92761d2..1dbc6d4 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -15563,7 +15563,8 @@
                 truthStoreValidateImportedFileLocal
                 truthStoreAppendJsonLineLocal
                 truthStoreTruthTimeLocal
-                truthStoreShouldReplaceLocal)
+                truthStoreShouldReplaceLocal
+                truthStoreMergeJsonLinesLocal)
         (type AssetManager)
         (type Any)
         (type Context)
@@ -16343,7 +16344,41 @@
                   (truthStoreJsonTimeLocal localText)
                   (truthStoreJsonTimeLocal remoteText)
                   remoteModified
-                  (truthStoreFileLastModified local))))))))
+                  (truthStoreFileLastModified local))))))
+        (def (truthStoreMergeJsonLinesLocal
+               (store : TruthStore)
+               (file : File)
+               (remoteText : String)) : Unit
+          (begin
+            (truthStoreRequired
+              (textUtf8BytesWithinLimit
+                remoteText
+                (truthStoreMaxZipEntryBytes))
+              "Failed requirement.")
+            (truthStoreValidateImportedTextLocal
+              (truthStoreFileName file)
+              remoteText)
+            (let ((hasLocal (fileExists file)))
+              (let ((localText
+                      (if hasLocal
+                        (truthStoreReadLocalText file)
+                        "")))
+                (let ((merged
+                        (mergeJsonLinesTextFromLocalAndRemote
+                          localText
+                          remoteText
+                          hasLocal
+                          (truthStoreMaxJsonlLines))))
+                  (begin
+                    (truthStoreRequired
+                      (textUtf8BytesWithinLimit
+                        merged
+                        (truthStoreMaxZipEntryBytes))
+                      "Failed requirement.")
+                    (truthStoreAtomicWriteTextRaw
+                      store
+                      file
+                      merged)))))))))
 
     (kotlin-file-lines "com/sfb/ssdreview/TruthStore.kt"
       (
@@ -16954,15 +16989,8 @@
        "        }"
        "    }"
        ""
-       "    private fun mergeJsonLines(file: File, remoteText: String) {"
-       "        require(textUtf8BytesWithinLimit(remoteText, MAX_ZIP_ENTRY_BYTES))"
-       "        validateImportedText(file.name, remoteText)"
-       "        val hasLocal = fileExists(file)"
-       "        val localText = if (hasLocal) readLocalText(file) else \"\""
-       "        val merged = mergeJsonLinesTextFromLocalAndRemote(localText, remoteText, hasLocal, MAX_JSONL_LINES)"
-       "        require(textUtf8BytesWithinLimit(merged, MAX_ZIP_ENTRY_BYTES))"
-       "        atomicWriteText(file, merged)"
-       "    }"
+       "    private fun mergeJsonLines(file: File, remoteText: String) ="
+       "        truthStoreMergeJsonLinesLocal(this, file, remoteText)"
        ""
        "    internal fun shouldReplaceLocal(local: File, remoteText: String, remoteModified: Long): Boolean ="
        "        truthStoreShouldReplaceLocal(local, remoteText, remoteModified)"