diff --git a/website/docs/architecture-memory.html b/website/docs/architecture-memory.html index a687972b..4f1d0abf 100644 --- a/website/docs/architecture-memory.html +++ b/website/docs/architecture-memory.html @@ -133,6 +133,7 @@ Columnar Storage IPC & Serialization + IPC Connection Hooks

Connection Hooks

-

The server side exposes the inbound connection lifecycle to Rayfall code through five hook slots under .ipc.on.*. Each is a user-installable lambda; when unbound the server falls back to its built-in default, so installing a hook is purely opt-in.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameSignatureFiresReturn value
.ipc.on.open(fn [h] ...)Inbound connection fully handshaked (and authed when -u/-U is on), just before the first header read.Ignored.
.ipc.on.close(fn [h] ...)Inbound connection about to close, before its socket is closed and per-conn state is freed. Pairs 1-to-1 with .ipc.on.open — never fires for connections that died mid-handshake.Ignored.
.ipc.on.sync(fn [m] ...)Inbound sync request, after the payload is deserialised into m. Replaces the default in-process eval.Serialised and shipped to the client as the response.
.ipc.on.async(fn [m] ...)Inbound async message. Same dispatch point as on.sync, but the wire produces no response.Ignored (errors are logged to stderr).
.ipc.on.auth(fn [u p] ...)After the constant-time secret compare in -u/-U auth passes. Servers started without auth never reach this hook.Truthy = accept connection, falsy / error = reject and close.
.ipc.handle(.ipc.handle)Builtin readable inside any of the five hooks above — returns the current connection's handle.-1 outside any hook.
- -

Install with plain set or the colon binder:

- -
(set .ipc.on.open  (fn [h] (println "+ " h)))
-(set .ipc.on.close (fn [h] (println "- " h)))
-
-;; Sync hook receives the raw deserialised payload.  Strings need an
-;; explicit parse before eval; the default in-server dispatch does this
-;; for you, but a hook gets the message as-is.
-(set .ipc.on.sync  (fn [m] (eval (parse m))))
-
-;; Narrow auth: hook runs AFTER the password check, so it can only
-;; deny extras — never widen access.  Here, deny the username "ban".
-(set .ipc.on.auth  (fn [u p] (!= u "ban")))
- -
- Reserved-namespace carve-out. The five .ipc.on.* names are the only dotted-reserved names a user can set — the rest of .ipc.* (open, close, send, handle) and every other system namespace (.sys.*, .os.*, .csv.*, …) stays unsettable and returns a reserve error on any binding attempt. -
- -

Clear a hook by assigning a non-lambda value:

- -
;; Cleared — server falls back to the default behaviour.
-(set .ipc.on.open 0)
- -

Anything that isn’t a callable lambda is treated as “no hook installed”, so a stale binding never wedges the server. Per-hook error handling:

- - - - - - - - - - - - - - -
HookError in hook body
.ipc.on.open / .ipc.on.closeLogged to stderr, swallowed. Connection teardown proceeds.
.ipc.on.syncSerialised and shipped to the client as the response — same as a raw eval error.
.ipc.on.asyncLogged to stderr, dropped. No wire response on async.
.ipc.on.authTreated as reject. Same 0x01 handshake byte as a wrong-password rejection.
- -

Hooks run under the same restricted-mode flag the inbound message would otherwise see — a .ipc.on.sync installed on a -U server cannot escalate privilege; the same blocked-builtins list above applies inside the hook body.

+

The server side exposes the inbound connection lifecycle to Rayfall code through five user-installable lambdas under .ipc.on.*open, close, sync, async, and auth — plus the (.ipc.handle) accessor that returns the current connection’s handle inside any hook. See IPC Connection Hooks for the full reference: signatures, install / clear semantics, the reserved-namespace carve-out, per-hook error handling, and the restricted-mode interaction.

Serialization with ser

The ser builtin converts any value to a binary buffer (a U8 vector). Pass it any Rayforce value — atom, vector, list, or table:

@@ -585,7 +495,7 @@

Limitations

diff --git a/website/docs/operations-math.html b/website/docs/operations-math.html index 15910559..3b0a85d8 100644 --- a/website/docs/operations-math.html +++ b/website/docs/operations-math.html @@ -133,6 +133,7 @@ Columnar Storage IPC & Serialization + IPC Connection Hooks