Run typed wrappers before Jerboa callers

ober

9fa36934b9263dde78fadeb570088af6c0a31f49

diff --git a/Makefile b/Makefile
index 4731a9c..a1b9996 100644
--- a/Makefile
+++ b/Makefile
@@ -338,8 +338,9 @@ typed-split-tree-smoke:
 	  TYPED_WRAPPER_FILE="build/typed/split-tree-smoke/sample_typed_split_tree.ss" \
 	  $(SCHEME) --libdirs $(LIBDIRS) --script tests/test-typed-split-tree-e2e.ss && \
 	  JERBOA_TYPED_RUST_LIB="$$lib" \
-	  TYPED_WRAPPER_FILE="build/typed/split-tree-smoke/sample_typed_split_tree.ss" \
-	  $(SCHEME) --libdirs $(LIBDIRS) --script tests/test-typed-split-tree-caller.ss
+	  $(SCHEME) --libdirs $(LIBDIRS) --script support/typed-run.ss \
+	    build/typed/split-tree-smoke/sample_typed_split_tree.ss \
+	    tests/test-typed-split-tree-caller.ss
 
 typed-test: test-typed-parser test-typed-checker test-typed-rust test-typed-wrappers typecheck
 
diff --git a/docs/jerboa-to-rust.md b/docs/jerboa-to-rust.md
index 9246e31..498545b 100644
--- a/docs/jerboa-to-rust.md
+++ b/docs/jerboa-to-rust.md
@@ -567,10 +567,12 @@ Exports:
   small dynamic tagged-list reference implementation and rejects a split whose
   stored size disagrees with its recursive child sizes.
 - The split-tree smoke target also runs a small Jerboa caller that loads the
-  generated wrapper, builds a nested split tree through the wrapper API,
-  summarizes it with prelude helpers, and drops the handles.
-- Next split-tree work: make wrapper generation importable without explicit
-  `load` in callers.
+  generated wrapper through `support/typed-run.ss`, builds a nested split tree
+  through the wrapper API, summarizes it with prelude helpers, and drops the
+  handles. The caller itself does not need an explicit `load`.
+- Next split-tree work: decide whether generated wrappers should become
+  importable library-form `.ss` build artifacts or stay script wrappers loaded
+  by a typed runner.
 
 Why:
 
diff --git a/docs/typed-jerboa.md b/docs/typed-jerboa.md
index 04ae17a..3818007 100644
--- a/docs/typed-jerboa.md
+++ b/docs/typed-jerboa.md
@@ -185,8 +185,9 @@ Current landing:
   traversals, parent lookup, remove-by-leaf-id, leaf accessors, dynamic wrapper
   checks, rejection of inconsistent stored split sizes, string returns, opaque
   handles, and explicit handle drops. The same target now also runs a small
-  Jerboa caller that loads the generated wrapper and uses the public wrapper
-  functions from ordinary `(jerboa prelude)` code.
+  Jerboa caller through `support/typed-run.ss`, so the caller can use public
+  wrapper functions from ordinary `(jerboa prelude)` code without an explicit
+  wrapper `load`.
 - `support/typed-rust.ss`, `make typed-rust`, and `make typed-build` generate a
   disposable Cargo crate under `build/typed/rust`; `typed-build` also writes
   wrappers under `build/typed/jerboa` and runs `cargo build` against the
@@ -867,9 +868,10 @@ Minimum excluded features:
   checks that invalid stored split sizes are rejected by the typed validity
   function.
 - Use it from a small part of Jerboa. The first caller smoke test now lives in
-  `tests/test-typed-split-tree-caller.ss`; it loads the generated wrapper,
-  builds a nested tree, summarizes it with Jerboa prelude helpers, checks
-  invalid stored sizes, removes a nested leaf, and drops all generated handles.
+  `tests/test-typed-split-tree-caller.ss`; `support/typed-run.ss` loads the
+  generated wrapper first, and the caller builds a nested tree, summarizes it
+  with Jerboa prelude helpers, checks invalid stored sizes, removes a nested
+  leaf, and drops all generated handles.
 
 ### Milestone 5: Effects and Resources
 
diff --git a/support/typed-run.ss b/support/typed-run.ss
new file mode 100644
index 0000000..a51b5b0
--- /dev/null
+++ b/support/typed-run.ss
@@ -0,0 +1,19 @@
+#!chezscheme
+;;; typed-run.ss -- run a Jerboa caller after loading a generated typed wrapper
+;;;
+;;; Usage:
+;;;   scheme --libdirs lib --script support/typed-run.ss WRAPPER-FILE CALLER-FILE
+
+(import (chezscheme)) ; jerboa-security: suppress direct-chezscheme-import-user-code -- trusted typed wrapper runner
+
+(define (usage)
+  (display "Usage: scheme --libdirs lib --script support/typed-run.ss WRAPPER-FILE CALLER-FILE\n"))
+
+(define args (command-line-arguments))
+
+(when (not (= (length args) 2))
+  (usage)
+  (exit 2))
+
+(load (car args))
+(load (cadr args))
diff --git a/tests/test-typed-split-tree-caller.ss b/tests/test-typed-split-tree-caller.ss
index 7a9ae25..f5c9e21 100644
--- a/tests/test-typed-split-tree-caller.ss
+++ b/tests/test-typed-split-tree-caller.ss
@@ -1,11 +1,5 @@
 (import (jerboa prelude)
-        (only (chezscheme) exit getenv load))
-
-(def wrapper-file
-  (or (getenv "TYPED_WRAPPER_FILE")
-      "build/typed/split-tree-smoke/sample_typed_split_tree.ss"))
-
-(load wrapper-file)
+        (only (chezscheme) exit))
 
 (def pass 0)
 (def fail 0)