Generate SSD truth store constants from typed Jerboa

ober

2ab19996092960d9617377f84dda7735eb139b9d

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 6a7664e..64c02a9 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -12611,6 +12611,78 @@
                 length)
               (set! count (+ count (int length))))))))
 
+    (typed-kotlin-file "com/sfb/ssdreview/TruthStoreConstants.kt"
+      (typed-library (com sfb ssdreview)
+        (export DEFAULT_TRUTH_API_URL
+                MAX_HTTP_TEXT_BYTES
+                MAX_HTTP_COMPRESSED_BYTES
+                MAX_REMOTE_ZIP_BYTES
+                MAX_ZIP_ENTRY_BYTES
+                MAX_ZIP_TOTAL_BYTES
+                MAX_ZIP_ENTRIES
+                MAX_ZIP_DEPTH
+                MAX_ZIP_PATH_CHARS
+                MAX_COMPRESSION_RATIO
+                RATIO_FLOOR_BYTES
+                MAX_STORAGE_BYTES
+                MAX_STORAGE_FILES
+                MAX_LEARNED_EXAMPLES
+                MAX_JSONL_LINES
+                MAX_SOURCE_KEY_CHARS
+                MAX_AUTH_TOKEN_CHARS)
+        (type Int32)
+        (val DEFAULT_TRUTH_API_URL : String
+          "https://10.66.60.2:8797/api"
+          (modifiers internal const))
+        (val MAX_HTTP_TEXT_BYTES : Int
+          (* (* (int 32) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_HTTP_COMPRESSED_BYTES : Int
+          (* (* (int 2) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_REMOTE_ZIP_BYTES : Int
+          (* (* (int 96) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_ZIP_ENTRY_BYTES : Int
+          (* (* (int 4) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_ZIP_TOTAL_BYTES : Int
+          (* (* (int 64) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_ZIP_ENTRIES : Int32
+          (int32 512)
+          (modifiers internal const))
+        (val MAX_ZIP_DEPTH : Int32
+          (int32 8)
+          (modifiers internal const))
+        (val MAX_ZIP_PATH_CHARS : Int32
+          (int32 240)
+          (modifiers internal const))
+        (val MAX_COMPRESSION_RATIO : Int
+          (int 100)
+          (modifiers internal const))
+        (val RATIO_FLOOR_BYTES : Int
+          (* (int 64) (int 1024))
+          (modifiers internal const))
+        (val MAX_STORAGE_BYTES : Int
+          (* (* (int 128) (int 1024)) (int 1024))
+          (modifiers internal const))
+        (val MAX_STORAGE_FILES : Int32
+          (int32 16384)
+          (modifiers internal const))
+        (val MAX_LEARNED_EXAMPLES : Int32
+          (int32 10000)
+          (modifiers internal const))
+        (val MAX_JSONL_LINES : Int32
+          (int32 51200)
+          (modifiers internal const))
+        (val MAX_SOURCE_KEY_CHARS : Int32
+          (int32 96)
+          (modifiers internal const))
+        (val MAX_AUTH_TOKEN_CHARS : Int32
+          (int32 4096)
+          (modifiers internal const))))
+
     (kotlin-file-lines "com/sfb/ssdreview/TruthStore.kt"
       (
        "package com.sfb.ssdreview"
@@ -12656,26 +12728,6 @@
        "import kotlin.concurrent.thread"
        ""
        "class TruthStore(private val context: Context) {"
-       "    companion object {"
-       "        private const val DEFAULT_TRUTH_API_URL = \"https://10.66.60.2:8797/api\""
-       "        private const val MAX_HTTP_TEXT_BYTES = 32L * 1024L * 1024L"
-       "        private const val MAX_HTTP_COMPRESSED_BYTES = 2L * 1024L * 1024L"
-       "        private const val MAX_REMOTE_ZIP_BYTES = 96L * 1024L * 1024L"
-       "        private const val MAX_ZIP_ENTRY_BYTES = 4L * 1024L * 1024L"
-       "        private const val MAX_ZIP_TOTAL_BYTES = 64L * 1024L * 1024L"
-       "        private const val MAX_ZIP_ENTRIES = 512"
-       "        private const val MAX_ZIP_DEPTH = 8"
-       "        private const val MAX_ZIP_PATH_CHARS = 240"
-       "        private const val MAX_COMPRESSION_RATIO = 100L"
-       "        private const val RATIO_FLOOR_BYTES = 64L * 1024L"
-       "        private const val MAX_STORAGE_BYTES = 128L * 1024L * 1024L"
-       "        private const val MAX_STORAGE_FILES = 16384"
-       "        private const val MAX_LEARNED_EXAMPLES = 10000"
-       "        private const val MAX_JSONL_LINES = 51200"
-       "        private const val MAX_SOURCE_KEY_CHARS = 96"
-       "        private const val MAX_AUTH_TOKEN_CHARS = 4096"
-       "    }"
-       ""
        "    private val root = File(context.filesDir, \"ssd_review\")"
        "    private val groundTruthDir = File(root, \"ground_truth\")"
        "    private val learnedDir = File(root, \"learned\")"
diff --git a/tests/ssd-security-test.sh b/tests/ssd-security-test.sh
index 5dbebf9..7a8be2b 100755
--- a/tests/ssd-security-test.sh
+++ b/tests/ssd-security-test.sh
@@ -58,13 +58,13 @@ require_text 'StandardCopyOption.ATOMIC_MOVE'
 require_text 'LinkOption.NOFOLLOW_LINKS'
 require_text 'LimitedInputStream(input, MAX_REMOTE_ZIP_BYTES)'
 require_text 'LimitedInputStream(connection.inputStream, MAX_HTTP_COMPRESSED_BYTES)'
-require_text 'MAX_HTTP_COMPRESSED_BYTES = 2L * 1024L * 1024L'
-require_text 'MAX_ZIP_ENTRY_BYTES = 4L * 1024L * 1024L'
-require_text 'MAX_ZIP_TOTAL_BYTES = 64L * 1024L * 1024L'
-require_text 'MAX_ZIP_ENTRIES = 512'
-require_text 'MAX_COMPRESSION_RATIO = 100L'
-require_text 'MAX_STORAGE_BYTES = 128L * 1024L * 1024L'
-require_text 'MAX_LEARNED_EXAMPLES = 10000'
+require_generated_text 'MAX_HTTP_COMPRESSED_BYTES: Long = ((2L * 1024L) * 1024L)'
+require_generated_text 'MAX_ZIP_ENTRY_BYTES: Long = ((4L * 1024L) * 1024L)'
+require_generated_text 'MAX_ZIP_TOTAL_BYTES: Long = ((64L * 1024L) * 1024L)'
+require_generated_text 'MAX_ZIP_ENTRIES: Int = 512'
+require_generated_text 'MAX_COMPRESSION_RATIO: Long = 100L'
+require_generated_text 'MAX_STORAGE_BYTES: Long = ((128L * 1024L) * 1024L)'
+require_generated_text 'MAX_LEARNED_EXAMPLES: Int = 10000'
 require_text 'validateImportedFile(name, stagedFile)'
 require_text 'stage.deleteRecursively()'