Closedloop.ai
MCP Server

Audit Ledger

Verify your organization's tamper-evident audit chain and read its head

Overview

Closedloop keeps a hash-chained audit ledger for each organization. Each row stores a hash of its own fields and the hash of the row before it, and rows are numbered in sequence from 1. verify-audit-ledger recomputes that chain and reports whether it is intact.

ToolScopePurpose
verify-audit-ledgerreadVerify the chain and return its head

The tool only reads your own organization's ledger. It returns JSON text. A failure comes back as a tool result with isError: true whose text carries a title, a description, any remediation steps, and the error code, message, and timestamp when the API supplied them.


Verify Audit Ledger

Tool: verify-audit-ledger Scope: read Underlying API: POST /audit/verify, then GET /audit/head when the chain is broken

Takes no parameters. Verification walks the whole chain, so it can take longer on an organization with a large ledger.

Returns

For an intact chain:

{
  "ok": true,
  "head": {
    "seq": "1842",
    "hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
  }
}

For a broken chain, brokenAtSeq is the first row that fails and reason says why. The tool adds head from a second request:

{
  "ok": false,
  "brokenAtSeq": "1203",
  "reason": "hash_mismatch",
  "head": {
    "seq": "1842",
    "hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
  }
}
reasonMeaning
hash_mismatchA row's stored hash does not match a recompute of its fields.
broken_linkA row's previous-hash does not equal the previous row's hash.
sequence_gapThe sequence is not gap-free and strictly increasing from 1.

seq and brokenAtSeq are decimal strings, because the underlying sequence number is a big integer that a JSON number cannot carry exactly. An empty ledger has head seq "0" and a hash of 64 zeros.

Errors

  • If the verify or head request fails, the tool returns the error result described in the overview.

Example

verify-audit-ledger()

On this page