本页内容
Sommatic 文档
打开控制台

Append Audit Log

向安全审计轨迹追加一条不可变记录。

以 Markdown 查看
在以下应用中打开
运维 部分可用 audit.append 版本 1.0.0 执行方式: async

向编排器日志写入一行 [AUDIT] <action> by <actor> on <resource>,并返回 { success: true }。该记录不会签名、不会做哈希链,也不会存储到其他地方。

该算子通过记录关键决策、数据访问或修改来保障合规与可追溯性。记录会被签名,并存储在防篡改的审计日志中。

字段:

  • Actor: 执行操作的主体(用户/服务)。
  • Action: 发生了什么(例如“Approved Loan”)。
  • Resource: 目标实体(例如“Loan #123”)。
  • Evidence: 证明该操作的 JSON 载荷。

适用场景:

  • 法规合规(GDPR、HIPAA)。
  • 排查安全事件。
  • 跟踪审批链。

工作原理

  1. 将输入项与解析后的配置合并(配置优先)。
  2. 当其中任一字段为空时,抛出 Missing 'action'、Missing 'actor' 或 Missing 'resource'。
  3. 以 info 级别记录 [AUDIT] <action> by <actor> on <resource>。随附的 audit 对象(decision、evidence、timestamp)不会写入,因为运行时 logger 只输出消息。
  4. 返回不带端口的 { success: true },因此引擎走 out。

在工作流中

节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。

{
  "node_id": "node-audit-approval",
  "label": "Audit approval",
  "operator_slug": "audit.append",
  "operator_version": "1.0.0",
  "config": {
    "action": "INVOICE_APPROVED",
    "actor": "{{ $json.approver_id }}",
    "resource": "invoice:{{ $json.invoice_id }}",
    "decision": "Permit"
  }
}

配置

action string 必填

具体的操作标识符(例如“ITEM_DELETED”)。

配置中会显示通用执行设置,但该节点目前不执行重试(retryOnFail、maxTries)。所有节点均未实现 continueOnFail。

代码中的行为

除 schema 描述之外,实现代码对这些键的实际处理。

actor
不在配置 schema 中(仅出现在输入契约中),但会从节点配置读取;节点上未设置时从输入项读取:actor、resource、decision、evidence。

输出端口

success 默认

永远不会输出:worker 不返回端口,引擎因此走 out,而本节点并未声明该端口。从 success 画出的连线永远不会触发。

error

永远不会输出:失败时会直接抛错,导致运行失败。

在表达式中

后续节点可通过 $("Append Audit Log").item.json.<路径> 读取此节点输出中的内容,即工作流编辑器在 Previous Nodes 中提示的路径(输出契约)。

表达式
$("Append Audit Log").item.json.successboolean

错误

消息 端口 原因与处理
Missing 'action' error 节点和输入项中都没有设置 action。该错误会被抛出:运行失败。
Missing 'actor' error 节点和输入项中都没有设置 actor。该错误会被抛出:运行失败。
Missing 'resource' error 节点和输入项中都没有设置 resource。该错误会被抛出:运行失败。

输入契约

actor string 必填

用户 ID 或服务名称

resource string 必填

目标资源 ID

decision string 可选

结果(例如 Permit/Deny)

evidence object 可选

支撑性上下文/数据

输出契约

success boolean 可选

契约(JSON Schema)

与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。

{
  "slug": "audit.append",
  "name": "Append Audit Log",
  "category": "ops",
  "version": "1.0.0",
  "description": "Appends an immutable entry to the secure audit trail.\n\n  This operator ensures compliance and traceability by recording key decisions, data access, or modifications. Entries are signed and stored in a tamper-evident audit log.\n\n  **Fields:**\n  - **Actor:** Who performed the action (User/Service).\n  - **Action:** What happened (e.g., \"Approved Loan\").\n  - **Resource:** Target entity (e.g., \"Loan #123\").\n  - **Evidence:** JSON payload proving the action.\n\n  **Use Cases:**\n  - Regulatory compliance (GDPR, HIPAA).\n  - Debugging security incidents.\n  - Tracking approval chains.",
  "capabilities": [
    "audit",
    "compliance",
    "security",
    "log"
  ],
  "config_schema": {
    "type": "object",
    "required": [
      "action"
    ],
    "properties": {
      "action": {
        "type": "string",
        "title": "Action Name",
        "description": "The specific action identifier (e.g. \"ITEM_DELETED\")."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    }
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "actor": {
        "type": "string",
        "description": "User ID or Service Name"
      },
      "resource": {
        "type": "string",
        "description": "Target Resource ID"
      },
      "decision": {
        "type": "string",
        "description": "Outcome (e.g. Permit/Deny)"
      },
      "evidence": {
        "type": "object",
        "description": "Supporting context/data"
      }
    },
    "required": [
      "actor",
      "resource"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "description": "Confirmation of audit persistence.",
    "properties": {
      "success": {
        "type": "boolean"
      }
    }
  },
  "ports": [
    {
      "port_id": "success",
      "label": "Success",
      "is_default": true,
      "description": "Audit logged successfully."
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Failed to write audit log."
    }
  ],
  "execution_mode": "async",
  "tags": [
    "audit",
    "compliance",
    "security"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_vectry",
    "profile": {
      "name": "Vectry Analytics",
      "verified": true,
      "url": "https://me.veripass.com/vectry",
      "logo_url": null
    }
  }
}

执行

执行方式
async
有状态
否
重试(retryOnFail)
否
能力
auditcompliancesecuritylog
标签
auditcompliancesecurity

说明与限制

  • 部分实现:没有签名、没有哈希链、没有防篡改证据,也不写数据库。唯一的痕迹是编排器的一行日志,内容仅限操作、执行者和资源。
  • 请把它作为分支的最后一个节点:连在 success 之后的节点永远不会运行。该节点在运行中的输出为 { success: true }。
  • 抛出的错误会使整个运行失败,信息为 Node <node_id> (<slug>) failed: <message>,error 上的连线不会触发。在 flow.try 作用域内,引擎会将其转到 catch 节点。
  • execution 设置(retryOnFail、maxTries、waitBetweenTries、continueOnFail、timeout_ms)可以填写,但本 worker 和引擎都不会应用。

已对照编排器代码核实 · 31e874b · 2026-11-26

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

安装 Sommatic AI CLI,并为检测到的智能体配置合适的插件。

npx @sommatic/cli agent setup
智能体如何读取本文档