From 017a1bc8c404fc4f87c1aa2ba0107ba257ca8693 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sun, 21 Jun 2026 12:06:18 -0400 Subject: [PATCH] SCI conformance gate (pure Chez) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-port the SCI compatibility stress test to joltc: host/chez/run-sci.ss loads borkdude/sci's own source (vendor/sci, re-vendored) through the spine and requires its forms to compile+eval. Floor-gated at 160/218 forms (the tail is genuine host gaps — set! on vars, some macro/def shapes); raise as they close. Wired into 'make test' (skips if the submodule isn't checked out). jolt-cf1q.6 --- .gitmodules | 3 ++ Makefile | 8 +++-- README.md | 1 + host/chez/run-sci.ss | 81 ++++++++++++++++++++++++++++++++++++++++++++ vendor/sci | 1 + 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 host/chez/run-sci.ss create mode 160000 vendor/sci diff --git a/.gitmodules b/.gitmodules index 4c5a7e6..77affa0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/irregex"] path = vendor/irregex url = https://github.com/ashinn/irregex.git +[submodule "vendor/sci"] + path = vendor/sci + url = https://github.com/borkdude/sci.git diff --git a/Makefile b/Makefile index c2a6621..2a336b1 100644 --- a/Makefile +++ b/Makefile @@ -4,10 +4,10 @@ # build step. `make test` is the full gate. `make remint` rebuilds the seed after a # source change. -.PHONY: test values corpus unit smoke selfhost certify remint +.PHONY: test values corpus unit smoke selfhost sci certify remint # Full gate. Each step exits non-zero on failure, failing the target. -test: selfhost values corpus unit smoke certify +test: selfhost values corpus unit smoke sci certify @echo "OK: all gates passed" # Self-host fixpoint: bootstrap.ss rebuild == checked-in seed. @@ -30,6 +30,10 @@ unit: smoke: @sh host/chez/smoke.sh +# SCI conformance: load borkdude/sci's source through joltc (floor-gated). +sci: + @chez --script host/chez/run-sci.ss + # JVM oracle: certify the corpus against reference Clojure. Skips if clojure absent. certify: @if command -v clojure >/dev/null 2>&1; then \ diff --git a/README.md b/README.md index 82693ed..a6a8943 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ make corpus # conformance corpus vs the JVM-sourced spec make unit # host-specific unit cases make selfhost # bootstrap fixpoint (rebuild == checked-in seed) make smoke # bin/joltc CLI smoke +make sci # load borkdude/sci's source through joltc (compat stress) make certify # JVM oracle (skips if clojure is absent) ``` diff --git a/host/chez/run-sci.ss b/host/chez/run-sci.ss new file mode 100644 index 0000000..0e2dff0 --- /dev/null +++ b/host/chez/run-sci.ss @@ -0,0 +1,81 @@ +;; run-sci.ss — SCI conformance: load borkdude/sci's own source (vendor/sci) through +;; joltc and require its forms to compile+eval. A real-world Clojure-compatibility +;; stress test. Pure Chez, no Janet. Floor-gated like the corpus: a regression below +;; the floor (or the count today, 160/218) fails. Raise the floor as host gaps close +;; (the tail is genuine gaps — set! on vars, some macro/def shapes). +;; +;; chez --script host/chez/run-sci.ss +;; JOLT_SCI_FLOOR=N override the floor (default 160) +;; SCI_VERBOSE=1 print each failing form's error +(import (chezscheme)) + +;; Skip cleanly when the submodule isn't checked out. +(unless (file-exists? "vendor/sci/src/sci/core.cljc") + (display "skip: vendor/sci not checked out (git submodule update --init vendor/sci)\n") + (exit 0)) + +(load "host/chez/rt.ss") +(set-chez-ns! "clojure.core") +(load "host/chez/seed/prelude.ss") +(load "host/chez/post-prelude.ss") +(set-chez-ns! "user") +(load "host/chez/host-contract.ss") +(load "host/chez/seed/image.ss") +(load "host/chez/compile-eval.ss") + +;; SCI's .cljc selects host code via #?(:clj ...) with no :jolt branch — read clj. +(set! rdr-features (list "clj" "jolt" "default")) + +(define (slurp path) + (call-with-input-file path + (lambda (p) (let loop ((cs '()) (c (read-char p))) + (if (eof-object? c) (list->string (reverse cs)) (loop (cons c cs) (read-char p))))))) + +;; Load every form in a file, evaluating each in the current ns (an (ns ...) form +;; switches it). Returns (ok . fail); failures are tolerated (lenient — SCI requires +;; host libs that don't exist here). +(define (load-forms path verbose) + (let ((src (slurp path)) (ok 0) (fail 0)) + (let ((end (string-length src))) + (let loop ((i 0)) + (call-with-values (lambda () (rdr-read-form src i end)) + (lambda (form j) + (unless (rdr-eof? form) + (guard (e (#t (set! fail (+ fail 1)) + (when verbose + (printf " FAIL: ~a\n" (call-with-string-output-port + (lambda (p) (display-condition (if (condition? e) e + (make-message-condition (jolt-final-str e))) p))))))) + (jolt-compile-eval-form form (chez-current-ns)) + (set! ok (+ ok 1))) + (loop j)))))) + (cons ok fail))) + +(define verbose (and (getenv "SCI_VERBOSE") #t)) + +;; stubs first (host shims SCI's source expects) +(for-each (lambda (f) (load-forms (string-append "src/jolt/clojure/sci/" f) verbose)) + '("lang_stubs.clj" "io_stubs.clj" "host_stubs.clj")) + +(define sci-base "vendor/sci/src/sci/") +(define load-order + '("impl/macros.cljc" "impl/protocols.cljc" "impl/types.cljc" "impl/unrestrict.cljc" + "impl/vars.cljc" "lang.cljc" "impl/utils.cljc" "ctx_store.cljc" "impl/deftype.cljc" + "impl/records.cljc" "impl/core_protocols.cljc" "impl/hierarchies.cljc" + "impl/destructure.cljc" "impl/doseq_macro.cljc" "impl/for_macro.cljc" "impl/fns.cljc" + "impl/multimethods.cljc" "impl/namespaces.cljc" "core.cljc")) + +(define total-ok 0) (define total-fail 0) +(for-each + (lambda (f) + (let* ((r (load-forms (string-append sci-base f) verbose)) (ok (car r)) (fail (cdr r))) + (set! total-ok (+ total-ok ok)) (set! total-fail (+ total-fail fail)) + (printf " ~a: ~a ok, ~a fail\n" f ok fail))) + load-order) + +(printf "\nSCI load: ~a/~a forms ok (~a fail)\n" total-ok (+ total-ok total-fail) total-fail) +(define floor (let ((s (getenv "JOLT_SCI_FLOOR"))) (if s (string->number s) 160))) +(when (< total-ok floor) + (printf "REGRESSION: ~a forms loaded < floor ~a\n" total-ok floor)) +(flush-output-port) +(exit (if (< total-ok floor) 1 0)) diff --git a/vendor/sci b/vendor/sci new file mode 160000 index 0000000..32d62a5 --- /dev/null +++ b/vendor/sci @@ -0,0 +1 @@ +Subproject commit 32d62a5136ad3dc148588752f5bcc4cc30b14752