cookbook: add lazy-optional-import-wrapper + export-compatibility-alias-with-rename

ober

ee351ff080f22a2c1ede4e369fc2bcce49440821

diff --git a/data/cookbooks.sexp b/data/cookbooks.sexp
index bdf1250..3f442a2 100644
--- a/data/cookbooks.sexp
+++ b/data/cookbooks.sexp
@@ -4592,4 +4592,28 @@
      "Sforeign_symbol")
    ("title"
      .
-     "Static musl binaries need dlopen stubs for main executable lookups")))
+     "Static musl binaries need dlopen stubs for main executable lookups"))
+ (("code"
+    .
+    "#!chezscheme\n(import (chezscheme))\n\n;; Keep optional modules out of the top-level import set. Whole-program\n;; builds still require every top-level import even when a feature flag\n;; prevents the code path from running.\n(define *optional-module-state* #f)\n\n(define (optional-module-available?)\n  (unless *optional-module-state*\n    (set! *optional-module-state*\n      (guard (e (#t 'unavailable))\n        (eval '(import (only (std misc string) string-trim))\n              (interaction-environment))\n        'ready)))\n  (eq? *optional-module-state* 'ready))\n\n(define (optional-call proc-name . args)\n  (if (optional-module-available?)\n      (apply (eval proc-name (interaction-environment)) args)\n      (error 'optional-call \"optional module not available\" proc-name)))\n\n(displayln (optional-call 'string-trim \"  ok  \"))") ("id" . "lazy-optional-import-wrapper")
+   ("imports" "(chezscheme)")
+   ("notes"
+     .
+     "Use this when a feature-disabled command references a package that may be absent in a platform build. A top-level `(import ...)` still makes Chez compile/load the library, even if runtime feature gating would skip the command. Cache the import attempt, guard missing libraries, and resolve the procedure from `(interaction-environment)` only inside the wrapper.")
+   ("tags" "chezscheme" "eval" "optional-import" "feature-gate"
+     "interaction-environment" "compile")
+   ("title"
+     .
+     "Lazy-load optional libraries behind feature gates"))
+ (("code"
+    .
+    "#!chezscheme\n(library (example compat)\n  (export canonical-name\n          (rename (canonical-name legacy-name)))\n  (import (chezscheme))\n\n  (define (canonical-name x)\n    x))\n\n(import (except (example compat) legacy-name))\n(displayln (canonical-name \"ok\"))") ("id" . "export-compatibility-alias-with-rename")
+   ("imports")
+   ("notes"
+     .
+     "Useful for vendored R6RS/Chez libraries when older consumers still import or exclude a legacy export name. Exporting `(rename (canonical legacy))` lets `(except (module) legacy)` remain valid without defining a second binding in the library body.")
+   ("tags" "library" "export" "rename" "compatibility" "alias"
+     "chezscheme")
+   ("title"
+     .
+     "Export compatibility aliases with R6RS rename")))