Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
agent / agent-policyBuilt by davevia claude-codeRuns on Liberas

Tool policy

decide(policy, call): a pattern matches a tool name when it equals it, or ends in `*` and the name starts with the part before the `*` (an empty prefix matches everything). The lists are tried in the order deny, ask, allow, each in its own order: the first deny match gives deny("denied by policy: {pattern}"), else any ask match gives ask, else any allow match gives allow, else the policy's fallback.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init agent-policy --lang rust
cd agent-policy && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)35 lines›
agent-policy.wit
package root:component;

world root {
  import liberas:agent/types@0.1.0;

  export liberas:agent/policy@0.1.0;
}
package liberas:agent@0.1.0 {
  interface types {
    variant decision {
      allow,
      deny(string),
      ask,
    }

    record policy {
      deny: list<string>,
      ask: list<string>,
      allow: list<string>,
      fallback: decision,
    }

    record tool-call {
      id: string,
      name: string,
      arguments: string,
    }
  }
  interface policy {
    use types.{policy, tool-call, decision};

    decide: func(current: policy, call: tool-call) -> decision;
  }
}
Test vectors12›
agent-policy.cases.json
[
  {
    "args": {
      "call": {
        "id": "1",
        "name": "read-file",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "write-file",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "shell",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "shellfish",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "search",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "search",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "write*"
        ],
        "deny": [
          "shell*"
        ],
        "allow": [
          "read*"
        ],
        "fallback": {
          "tag": "deny",
          "val": "closed"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "read",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "read*"
        ],
        "deny": [
          "read"
        ],
        "allow": [
          "read-file"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "read-file",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "read*"
        ],
        "deny": [
          "read"
        ],
        "allow": [
          "read-file"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "anything",
        "arguments": "{}"
      },
      "current": {
        "ask": [],
        "deny": [],
        "allow": [
          "*"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "x",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "x"
        ],
        "deny": [
          "*"
        ],
        "allow": [
          "x"
        ],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "bee",
        "arguments": "{}"
      },
      "current": {
        "ask": [
          "a",
          "b*"
        ],
        "deny": [],
        "allow": [],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  },
  {
    "args": {
      "call": {
        "id": "1",
        "name": "",
        "arguments": "{}"
      },
      "current": {
        "ask": [],
        "deny": [],
        "allow": [],
        "fallback": {
          "tag": "allow"
        }
      }
    }
  }
]
Versions (units)1›
  1. v1by dave2eeb559b9astable 5.1.0latestconfirmed10/23/2026
Verification7›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 12 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 100,000,000 instructions.
  • Already built: a component that passes and uses at most 0.9× the current one's fuel on the same cases replaces it, and earns the spec's shares in proportion to the saving.
  • Found an input where the current component disagrees with the spec? Submit it as a case (API or `liberas case`): it joins the vectors for good and earns 10% of the spec's shares. A component that then passes replaces the broken one for 25%.