工具与字段参考

本页整页由生成器从线上代码抽取,直接反映实况。

智能体工具

工具做什么
update_working_memorySubmit a batch of working-memory operations to a board; the kernel applies them, recomputes the rule closure once, and returns the updated working memory (derived facts, goal satisfaction, hypothesis verdicts, and hints about which facts to observe next)
get_logic_contextRead the current working memory of a board: goals (with satisfied flags), facts, hypotheses, findings, axioms, actions, results, conflicts, vocabulary
explain_factExplain WHY a derived fact is true: the rule that derived it and its supporting facts recursively back to asserted/effect leaves, each marked [derived]/[asserted]/[effect]
close_taskFinish a task: archive its tree (the goal node and everything under it) and get an honest capsule of what was actually established

工具面不出现板/智能体参数:一个连接对应一个智能体(由接入地址决定),工具调用不需要指定它。

工作记忆操作

update_working_memory 收下面这些操作。只列云上真支持的——工具说明是给模型的承诺,兑现不了就是把它往坑里带。

操作做什么
declare_goal声明"什么算做完"(可判定的原子);板每批回未满足目标还差什么
assert_fact记一条材料(你知道的事)
add_axiom立一条判据规则;闭包据此推导结论
derive_aggregate求和/计数/最小/最大/平均,可 where 过滤、group_by 分组
retract_node撤回错的那条——不要再断言一条相反的事实压上去

其余操作(define_actionrecord_resultdeclare_hypothesisrevise_fact)云上尚未开放,用了会收到 unimplemented

可照抄的形状

立一条规则:

{
  "op": "add_axiom",
  "id": "ax_cost",
  "label": "金额 = 单价 × 数量",
  "when": [
    { "predicate": "line", "args": { "item": "?i", "unit": "?u", "qty": "?q" } },
    { "predicate": "mul",  "args": { "left": "?u", "right": "?q", "result": "?t" } }
  ],
  "then": [ { "predicate": "cost", "args": { "item": "?i", "total": "?t" } } ]
}

声明目标:

{
  "op": "declare_goal",
  "id": "G1",
  "label": "钢筋已定价",
  "desired": [ { "predicate": "priced", "args": { "item": "steel" } } ]
}

聚合(求总额):

{
  "op": "derive_aggregate",
  "id": "agg_total",
  "kind": "sum",
  "source": { "predicate": "cost", "valueArg": "total" },
  "into": { "predicate": "grand_total", "valueArg": "value" }
}

kind 可为 sum / count / min / max / avg;可选 where{"arg":…,"equals":…})与 group_by。它固定当下在场的那些事实——源事实变了之后,用同一个 id 再跑一次即可刷新。

内建谓词(写在规则的 when 里)

可用
比较eq neq lt lte gt gte between contains
算术add sub mul div mod pow min max neg abs sqrt ln exp concat

算术是 exact-or-fail:±253 内精确,越界/无穷/非数一律失败,绝不静默舍入。

二元算术的形状是 {left, right, result}——result 写变量时它产出这个值,写常量时它校验这个值。

极性与缺席

写法含义
{"predicate":"p","args":{…}}p 成立
{"predicate":"p","args":{…},"negated":true}强否定:已验证 p 不成立
{"predicate":"p","args":{…},"naf":true}缺席:p 无法被证明(只能出现在 when 里)

negatednaf 的区别是要紧的:前者是"我查过,没有",后者是"我没查到"。审批场景里"还没签字"是后者。

包字段支持矩阵

字段状态说明
meta.name / meta.versiondomain支持包名与版本;同一块板不可重复装同名包
vocab[].predicate / vocab[].argsdomain支持词汇:这一行的名词与它的参数名(args 是参数名字符串数组)
vocab[].descriptiondomain未点亮带上会被宿主守卫挡住——先去掉,说明写进文档或规则 label 里
vocab[].key(→ functional_dependency)domain未点亮函数依赖声明未点亮
axioms[]domain换路径域内核只收词汇空壳;判据规则改由 ApplyBatch 的 add_axiom 上板(控制台的"装能力"已自动走这条)
empirical / theorems / actions / pins / planGuidancedomain未点亮经验律/定理/动作/钉/计划提示暂不收
tools[].name / kind / impl / desctools支持kind ∈ read|write|run;落板成 tool_def(板证:现场有哪几双手),desc 截 240 字
tools[].params / fencetools支持须为对象;全文存宿主注册表不落板(防板胀),注册者自持
channels[]channels支持通道定义/放电路由/绑定 + CA 钉:证据从哪来、进什么档
norms(宪法包)norms未点亮云上 RegisterPack 暂不收 norms;"什么许做"目前靠领域判据表达

接入地址

用途地址
默认智能体https://api.rulith.com/mcp
指定智能体https://api.rulith.com/mcp?agent=<名字>
控制台https://console.rulith.com

错误码

拒绝一律带教学文本(告诉你怎么改),错误码用于程序判断:

含义
unauthenticated没带令牌或令牌无效
not_authorized认证通过但无权碰这块板
unknown_board板不存在
stale_revision修订号过期(乐观并发,重拉后重试)
rejected语义被拒——读 teaching,它会说清差什么
unimplemented云上还没点亮这个操作
正文住 content/*.md;能力清单、工具清单、字段矩阵由生成器从实现代码抽取 (快照在 facts.json)——改了实现而忘了改文档,校验会自己发现。