From: Vsevolod Stakhov Date: Tue, 18 Nov 2025 10:13:45 +0000 (+0000) Subject: [Minor] Migrate rules/controller/neural.lua to lua_shape X-Git-Tag: 3.14.1~11^2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6318480f6cc37780e6ca85b34840dfc68103cea4;p=thirdparty%2Frspamd.git [Minor] Migrate rules/controller/neural.lua to lua_shape Replace tableshape with lua_shape in neural controller. Changes: - ts.shape { ... } → T.table({ ... }) - ts.array_of(ts.array_of(x)) → T.array(T.array(x)) - ts.string, ts.number → T.string(), T.number() - :is_optional() → :optional() - Added comprehensive documentation to all fields Schema: learn_request_schema for neural network training requests with nested arrays for ham and spam training vectors. --- diff --git a/rules/controller/neural.lua b/rules/controller/neural.lua index 9fc9c567e8..601e512844 100644 --- a/rules/controller/neural.lua +++ b/rules/controller/neural.lua @@ -15,7 +15,7 @@ limitations under the License. ]] -- local neural_common = require "plugins/neural" -local ts = require("tableshape").types +local T = require "lua_shape.core" local ucl = require "ucl" local lua_util = require "lua_util" local rspamd_util = require "rspamd_util" @@ -27,11 +27,11 @@ local N = 'neural' -- Controller neural plugin -local learn_request_schema = ts.shape { - ham_vec = ts.array_of(ts.array_of(ts.number)), - rule = ts.string:is_optional(), - spam_vec = ts.array_of(ts.array_of(ts.number)), -} +local learn_request_schema = T.table({ + ham_vec = T.array(T.array(T.number())):doc({ summary = "Ham training vectors" }), + rule = T.string():optional():doc({ summary = "Rule name to train" }), + spam_vec = T.array(T.array(T.number())):doc({ summary = "Spam training vectors" }), +}):doc({ summary = "Neural network learning request" }) local function handle_learn(task, conn) lua_util.debugm(N, task, 'controller.neural: learn called')