Skip to main content
Glama
tetracoralla

decision-table

by tetracoralla

Decision Table

Decision Table 是面向 AI 代理的确定性决策与约束原语。它将有界的业务判断从模型推理中移出,放入一个严格、可版本化、可执行的 IR 中。

产品名称以及稳定的包、CLI、插件、Skill 和 MCP 标识符记录在 docs/PRODUCT_IDENTITY.md 中。

首个版本提供:

  • decision.evaluate:使用 first、unique、collect 或 priority 命中策略评估事实;

  • decision.validate:验证模型,并在支持的情况下保守地证明重复、重叠或遮蔽规则;

  • constraint.check:检查提议的候选结果,并返回违规项、缺失输入以及配置的修复提示;

  • constraint.check_approved:当由宿主配置时,针对调用方无法替换或回填日期的精确已批准规则集执行只读检查;

  • 一个共享的 TypeScript 核心、一个 JSON CLI,以及一个 MCP 服务器和 Codex 插件。

在 Codex 中安装

codex plugin marketplace add tetracoralla/decision-table --ref main
codex plugin add decision-table@decision-table

安装后启动一个新的 Codex 任务,以便从已安装的插件中加载 Skill 和 MCP 工具。无需 npm 账户、npm 包或源码构建;该插件包含一个预构建的 MCP 服务器,只需要 PATH 上有 Node.js 20.19 或更高版本。

仓库根目录是 marketplace,plugins/decision-table 是可安装的插件。有关更新、移除和验证,请参阅 docs/INSTALLATION.md。

使用普通请求,例如:

  • “在我使用之前验证这个决策规则集。”

  • “用这些事实评估这个规则集。”

  • “检查这个提议的操作是否满足这些约束。”

Decision Table 作为 Codex 插件从 GitHub 分发。本仓库中的 Node 包是私有的,仅用于构建、测试和本地库开发;它不会发布到 npm。

Related MCP server: agent-orchestrator

从源码开发

npm install
npm run check

对于本地插件开发,将此仓库目录本身添加为 marketplace,并使用 npm run check:plugin 验证源码插件。

CLI

npm run cli -- validate examples/payment-approval.decision.json
npm run cli -- evaluate examples/payment-approval.decision.json \
  --facts examples/payment-approval.facts.json \
  --expected-version 1.0.0
npm run cli -- check examples/email-marketing.constraint.json \
  --candidate examples/email-marketing.candidate.json \
  --facts examples/email-marketing.facts.json

所有输出均为 JSON。使用 - 代替输入路径,以从 stdin 读取该单个文档。所选命令未定义的选项会被拒绝。规则集、事实和候选文档共享一个累计 256 KiB 的限制。

对于精确内容固定,同时传递 --expected-version 和 --expected-fingerprint <sha256>。

已批准检查与宿主强制

内联的 constraint.check 是建议性的,因为其调用者提供规则集。对于使用宿主批准策略的只读分析,请在启动 MCP 服务器之前绑定规则集:

import {
  createApprovedConstraintChecker,
  createConstraintExecutionGuard,
  fingerprintRuleset,
} from "@openadam/decision-table";

const expected = {
  id: approvedRuleset.id,
  version: approvedRuleset.version,
  fingerprint: fingerprintRuleset(approvedRuleset),
};
const checker = createApprovedConstraintChecker({ ruleset: approvedRuleset, expected });

捆绑的 stdio 服务器在其宿主将 DECISION_TABLE_APPROVED_CONSTRAINT_JSON 设置为相同的严格绑定对象时,暴露 constraint.check_approved。Agent 无法替换策略或回填检查日期,但它仍然提供候选和事实,因此此只读 MCP 工具不是执行边界。

对于受治理的副作用,将候选构建、可信事实加载、检查和执行保持在宿主拥有的上下文中:

const guard = createConstraintExecutionGuard(checker, async (action, run) =>
  database.transaction(async (transaction) =>
    run({
      candidate: candidateFromActualAction(action),
      facts: await loadTrustedFacts(transaction, action),
      execute: (sameActionSnapshot) =>
        executeActualAction(transaction, sameActionSnapshot),
    }),
  ),
);

const outcome = await guard.execute(actualToolArguments);

守卫对实际动作进行快照,除非约束返回有效,否则阻止执行器,并将相同的冻结快照传递给执行。宿主拥有的上下文是事务或锁必须保持易变事实在副作用期间有效的地方。守卫是一个库边界,并且有意不作为 Agent 可调用的 MCP 工具。

规则集形状

条件是标记数据,绝不是可执行字符串:

{
  "op": "compare",
  "left": { "kind": "fact", "path": "amount" },
  "comparator": "gte",
  "right": { "kind": "literal", "value": "10000" }
}

十进制输入是字符串。缺失路径产生 UNKNOWN;它们不会被强制转换为 false。日期时间要求真实的 ISO 日历值、显式偏移、秒,并且精度不超过毫秒。参见 examples/ 和 docs/PRODUCT_MODEL.md 以了解完整的产品边界。

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides deterministic AST graph queries and rule validation for AI coding agents via MCP tools, enabling structural intelligence without LLM calls.
    3 npm
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Deterministic logical reasoning server for MCP clients that compiles facts, rules, and queries to Prolog and returns exact answers with proof trees.
    4
    MIT
  • A
    license
    Not graded
    quality
    F
    maintenance
    Enables AI agents to perform auditable A* reasoning, import world graphs, incorporate physical carrier constraints, and maintain a learning knowledge base through a zero-dependency local MCP stdio service.
    MIT