Replace invoke with cek-call in reactive island primitives

All signal operations (computed, effect, batch, etc.) now dispatch
function calls through cek-call, which routes SX lambdas via cek-run
and native callables via apply. This replaces the invoke shim.

Key changes:
- cek.sx: add cek-call (defined before reactive-shift-deref), replace
  invoke in subscriber disposal and ReactiveResetFrame handler
- signals.sx: replace all 11 invoke calls with cek-call
- js.sx: fix octal escape in js-quote-string (char-from-code 0)
- platform_js.py: fix JS append to match Python (list concat semantics),
  add Continuation type guard in PLATFORM_CEK_JS, add scheduleIdle
  safety check, module ordering (cek before signals)
- platform_py.py: fix ident-char regex (remove [ ] from valid chars),
  module ordering (cek before signals)
- run_js_sx.py: emit PLATFORM_CEK_JS before transpiled spec files
- page-functions.sx: add cek and provide page functions for SX URLs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 10:11:48 +00:00
parent 30d9d4aa4c
commit 455e48df07
20 changed files with 911 additions and 600 deletions

View File

@@ -39,10 +39,10 @@ def _load_declarations() -> None:
len(_DECLARED_PURE), len(_DECLARED_IO), len(_DECLARED_HELPERS),
)
except Exception as e:
logger.warning("Failed to load boundary declarations: %s", e)
_DECLARED_PURE = frozenset()
_DECLARED_IO = frozenset()
_DECLARED_HELPERS = {}
# Don't cache failure — parser may not be ready yet (circular import
# during startup). Will retry on next call. Validation functions
# skip checks when declarations aren't loaded.
logger.debug("Boundary declarations not ready yet: %s", e)
def _is_strict() -> bool:
@@ -63,7 +63,8 @@ def _report(message: str) -> None:
def validate_primitive(name: str) -> None:
"""Validate that a pure primitive is declared in primitives.sx."""
_load_declarations()
assert _DECLARED_PURE is not None
if _DECLARED_PURE is None:
return # Not ready yet (circular import during startup), skip
if name not in _DECLARED_PURE:
_report(f"Undeclared pure primitive: {name!r}. Add to primitives.sx.")
@@ -71,7 +72,8 @@ def validate_primitive(name: str) -> None:
def validate_io(name: str) -> None:
"""Validate that an I/O primitive is declared in boundary.sx or boundary-app.sx."""
_load_declarations()
assert _DECLARED_IO is not None
if _DECLARED_IO is None:
return # Not ready yet, skip
if name not in _DECLARED_IO:
_report(
f"Undeclared I/O primitive: {name!r}. "
@@ -82,7 +84,8 @@ def validate_io(name: str) -> None:
def validate_helper(service: str, name: str) -> None:
"""Validate that a page helper is declared in {service}/sx/boundary.sx."""
_load_declarations()
assert _DECLARED_HELPERS is not None
if _DECLARED_HELPERS is None:
return # Not ready yet, skip
svc_helpers = _DECLARED_HELPERS.get(service, frozenset())
if name not in svc_helpers:
_report(
@@ -129,17 +132,14 @@ def validate_boundary_value(value: Any, context: str = "") -> None:
def declared_pure() -> frozenset[str]:
_load_declarations()
assert _DECLARED_PURE is not None
return _DECLARED_PURE
return _DECLARED_PURE or frozenset()
def declared_io() -> frozenset[str]:
_load_declarations()
assert _DECLARED_IO is not None
return _DECLARED_IO
return _DECLARED_IO or frozenset()
def declared_helpers() -> dict[str, frozenset[str]]:
_load_declarations()
assert _DECLARED_HELPERS is not None
return dict(_DECLARED_HELPERS)
return dict(_DECLARED_HELPERS) if _DECLARED_HELPERS else {}