W14: build C21 perform-mode harness + 5 pins (test-infra only)

The synchronous harness binds mocks as plain NativeFns, so no harness test
could exercise the real CEK perform/suspend/resume path — the HO+perform
element-drop class (S10) was structurally invisible (hosts.md C21).

Add harness-run-perform to spec/harness.sx: drives make-cek-state/
cek-step-loop, services each (perform {:op X :args L}) suspension from the
session's platform mocks (entry logged before invocation, C22-consistent),
cek-resumes with the mock value, loops to terminal; clear error on an
unmocked op. Shared arity dispatch extracted as harness-invoke-mock.

Pins (gate-C21-perform-mode-harness): single suspension, arithmetic-frame
resume, sequential performs, unmocked-op error, and the S10 probe — map
over a perform-suspending lambda keeps ALL 3 elements through 3
suspensions on the CEK path (localizing the drop class to serving-JIT).
290/0 under OCaml run_tests; harness self-suite green.

Caveat (documented): requires the runner's cek-* driver bindings — absent
on bare sx_server/MCP, the same runner-only-binding theme as section B.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-04 02:30:40 +00:00
parent 6f52cff0d9
commit 53c0ec14da
3 changed files with 105 additions and 2 deletions

View File

@@ -13,6 +13,7 @@
harness-set!
make-interceptor
install-interceptors
harness-run-perform
io-calls
io-call-count
io-call-nth
@@ -76,6 +77,27 @@
(session key value)
(dict-set! (get session "state") key value)
nil))
(define
harness-invoke-mock
:effects ()
(fn
(mock-fn args)
(if
(empty? args)
(mock-fn)
(if
(= 1 (len args))
(mock-fn (first args))
(if
(= 2 (len args))
(mock-fn (first args) (nth args 1))
(if
(= 3 (len args))
(mock-fn
(first args)
(nth args 1)
(nth args 2))
(apply mock-fn args)))))))
(define
make-interceptor
:effects ()
@@ -87,7 +109,7 @@
((entry {:op op-name :result nil :args args}) (log (get session "log")))
(append! log entry)
(let
((result (if (empty? args) (mock-fn) (if (= 1 (len args)) (mock-fn (first args)) (if (= 2 (len args)) (mock-fn (first args) (nth args 1)) (if (= 3 (len args)) (mock-fn (first args) (nth args 1) (nth args 2)) (apply mock-fn args)))))))
((result (harness-invoke-mock mock-fn args)))
(dict-set! entry "result" result)
result)))))
(define
@@ -104,6 +126,14 @@
(env-bind! env key interceptor)))
(keys (get session "platform")))
env))
(define
harness-run-perform
:effects ()
(fn
(session expr env)
(let
((drive (fn (self state) (if (cek-suspended? state) (let ((req (cek-io-request state))) (let ((op (get req "op")) (args (or (get req "args") (list)))) (let ((mock-fn (get (get session "platform") op))) (when (nil? mock-fn) (error (str "harness-run-perform: no mock for op " op))) (let ((entry {:op op :result nil :args args}) (log (get session "log"))) (append! log entry) (let ((result (harness-invoke-mock mock-fn args))) (dict-set! entry "result" result) (self self (cek-resume state result))))))) (cek-value state)))))
(drive drive (cek-step-loop (make-cek-state expr env (list)))))))
(define
io-calls
:effects ()