Move SSD native detector status reads to typed Kotlin

ober

c3d35a4ad9e57eddedc28dac6114ed809adac7cf

diff --git a/.build.yml b/.build.yml
index bdd7ec9..dd3e6ae 100644
--- a/.build.yml
+++ b/.build.yml
@@ -5,7 +5,7 @@ packages:
   - make=4.4.1-r4
 sources:
   # Build dependency: full immutable commit, mirrored in dependencies.lock.json.
-  - "https://git.sr.ht/~lisp/jerboa#827fdca88b92fe51dcc04dca3c09a245a7d03f4e"
+  - "https://git.sr.ht/~lisp/jerboa#a56576481905e9152869948b3fd80f9274e8a5d3"
   # The second source is the build subject selected by the SourceHut submitter.
   - https://git.sr.ht/~lisp/jerboa-android
 tasks:
@@ -14,6 +14,6 @@ tasks:
       test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2
       test "$(apk info -v git)" = git-2.54.0-r0
       test "$(apk info -v make)" = make-4.4.1-r4
-      test "$(git -C ../jerboa rev-parse HEAD)" = 827fdca88b92fe51dcc04dca3c09a245a7d03f4e
-      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 00f6aa18dac4f12834f49bc6bd3d70a5114e37ad
+      test "$(git -C ../jerboa rev-parse HEAD)" = a56576481905e9152869948b3fd80f9274e8a5d3
+      test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 2e6a1b52a9d086817471e35e4b45f64c43f2862c
       JERBOA="chez --libdirs .:../jerboa/lib --script" make test
diff --git a/dependencies.lock.json b/dependencies.lock.json
index f01ee04..2ecaa1e 100644
--- a/dependencies.lock.json
+++ b/dependencies.lock.json
@@ -11,8 +11,8 @@
   "generator_runtime": {
     "name": "jerboa",
     "repository": "https://git.sr.ht/~lisp/jerboa",
-    "commit": "827fdca88b92fe51dcc04dca3c09a245a7d03f4e",
-    "tree": "00f6aa18dac4f12834f49bc6bd3d70a5114e37ad"
+    "commit": "a56576481905e9152869948b3fd80f9274e8a5d3",
+    "tree": "2e6a1b52a9d086817471e35e4b45f64c43f2862c"
   },
   "assurance_tools": {
     "osv_scanner": {
diff --git a/scripts/verify-supply-chain.sh b/scripts/verify-supply-chain.sh
index 2627a42..21668b4 100755
--- a/scripts/verify-supply-chain.sh
+++ b/scripts/verify-supply-chain.sh
@@ -3,8 +3,8 @@ set -eu
 
 repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P)
 lock="$repo/dependencies.lock.json"
-jerboa_commit=827fdca88b92fe51dcc04dca3c09a245a7d03f4e # gitsafe:ignore
-jerboa_tree=00f6aa18dac4f12834f49bc6bd3d70a5114e37ad # gitsafe:ignore
+jerboa_commit=a56576481905e9152869948b3fd80f9274e8a5d3 # gitsafe:ignore
+jerboa_tree=2e6a1b52a9d086817471e35e4b45f64c43f2862c # gitsafe:ignore
 gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78
 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336
 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331
diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 428e29a..5fc5911 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -3210,6 +3210,7 @@
       (kotlin-imports (org json JSONArray) (org json JSONObject))
       (typed-library (com sfb ssdreview)
         (export nativeDetectionCellsFromJson nativeDetectionGroupsFromJson
+                nativeDetectionRootOk nativeDetectionRootError
                 nativeDetectionFromJsonRoot)
         (type JSONArray)
         (type JSONObject)
@@ -3227,6 +3228,10 @@
         (def (nativeDetectionGroupId (index : Int32)) : String
           (string-append "g"
             (string-pad-start (int32->string (+ index (int32 1))) (int32 4) #\0)))
+        (def (nativeDetectionRootOk (root : JSONObject)) : Bool
+          (json-object-opt-bool-default root "ok" #t))
+        (def (nativeDetectionRootError (root : JSONObject)) : String
+          (json-object-opt-string-default root "error" "native detector failed"))
         (def (nativeDetectionCellsFromJson (raw : (Nullable JSONArray))) : (MutableList SsdCell)
           (let ((cells (mutable-list-empty SsdCell)))
             (let ((items (nullableJsonArrayOrEmpty raw)))
@@ -5915,8 +5920,8 @@
        "            return null"
        "        }"
        "        val root = try { JSONObject(jsonText) } catch (_: Exception) { return null }"
-       "        if (!root.optBoolean(\"ok\", true)) {"
-       "            loadError = IllegalStateException(root.optString(\"error\", \"native detector failed\"))"
+       "        if (!nativeDetectionRootOk(root)) {"
+       "            loadError = IllegalStateException(nativeDetectionRootError(root))"
        "            return null"
        "        }"
        "        return nativeDetectionFromJsonRoot(root)"