1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: Apache-2.0
// Copyright 2024-2026 Dragonscale Team
//! GraphCompute kernel-dispatch host function for Extism guests.
//!
//! A guest algorithm imports a single host fn, `uni_graph_call`, and issues one
//! kernel call per invocation as a JSON string (proposal §4.5). The host resolves
//! the guest's session by id and dispatches the kernel through the shared
//! [`GraphComputeRegistry`](uni_plugin_builtin::algorithms::graph_compute::GraphComputeRegistry),
//! returning the result (handle / scalar / error) as JSON. Only handles and
//! scalars cross the boundary — the "conductor, not worker" property that makes
//! the same guest portable across loaders.
//
// Rust guideline compliant
use FnError;
use HostSvcCtx;
/// Dispatches one GraphCompute kernel call for a guest, JSON in / JSON out.
///
/// # Errors
/// Returns [`FnError`] `0xC33` only if no graph registry was configured on the
/// loader; per-kernel errors (bad handle, drained budget, …) are reported
/// in-band inside the returned JSON, never as a host error, so a hostile guest
/// cannot crash the worker (proposal §5.4).
pub
// The `host_fn!`-generated shell is thin: recover the ctx, run `do_graph_call`.
host_fn!;