Install
openclaw skills install @cengcengcai-creator/agent-rule-enforcementAudit whether an agent's written rules are actually enforceable: classify each rule as interception, exit gate, detection, or prompt-only, compute blocking coverage, and run behavioral checks over event logs. Use when a rulebook has grown, when someone asks whether rules are really followed, or after changing agent instructions. Tool-agnostic; works on Markdown rules and JSONL event logs.
openclaw skills install @cengcengcai-creator/agent-rule-enforcementRules are cheap to write and expensive to enforce. This skill separates three questions that usually get merged:
Developed through agent operation and corrected against real failures, not hand-authored as a prompt template.
Use for
Do not use for
Required: a rule file in Markdown or plain text, and read access to execution artefacts (scripts, hooks, logs) if they exist.
Optional: an event log (JSONL) for the behavior audit; tool-policy configuration; exit-code gates.
Known limits:
Count must-clauses separately from descriptive prose. Only must/shall/required/never-style statements enter the audit.
Completion criterion: a number for must-clauses, plus the file and line range audited.
List everything that can actually stop or detect something: pre-action checks, tool policies, exit-code gates, scheduled audits, CI checks.
Completion criterion: each executor names the rules it covers.
| Tier | Test | Example |
|---|---|---|
| Interception | The action cannot complete without passing | tool not mounted, permission denied, sandbox boundary |
| Exit gate | A script returns non-zero and blocks “done” | deliverable check, linter, schema validation |
| Detection | A later scan can find it, but nothing stops it | transcript audit, log query, periodic report |
| Prompt-only | Written in the rule file, no checker anywhere | “ask when unsure” |
Completion criterion: every must-clause has one tier; counts sum to the total.
blocking coverage = (interception + exit gate) / must-clauses
Report detection coverage separately. Never merge the two. A rule that can be found afterwards is not a rule that is enforced.
Completion criterion: both percentages present, with the formula shown.
Structure inspection says what could happen; logs say what did. Run both, and keep the conclusions separate.
A check must be a predicate over event fields, not a reading of intent. Good checks:
| Check | Predicate |
|---|---|
| Long task, no checkpoint | duration_ms > threshold and checkpoint_count == 0 |
| Retry storm | same tool called >= N times consecutively after errors |
| Silent failure | outcome == error and user_visible_message == false |
| Unverified claim | task produced claims and tool_calls == 0 |
Completion criterion: every check names the fields it reads and the threshold it uses.
Group events into tasks by session and idle gap. State the gap and why; segmentation is a judgement that changes every count.
Completion criterion: segmentation rule written down; task count reported.
Report per-check: hits, base (how many tasks were eligible), rate. Do not report a naked hit count.
Completion criterion: each check has hits / base / rate, and the log window is stated.
Run the audit on a period where you know the answer. If the checks fire on known-good runs, the checks are wrong — fix the predicate, not the threshold.
Completion criterion: at least one false-positive check documented and corrected, or an explicit note that calibration was not performed.
Order of leverage, most to least:
Output at most three conversion proposals. Each must name the execution point: script, tool policy, or pre-action step. “Rewrite the rule more forcefully” is not a proposal.
Completion criterion: each proposal states where it executes and how it fails.
scripts/rule_scan.py <rules.md> — counts must-clauses and emits a CSV skeleton for manual tier assignment. Heuristic suggestions only.scripts/audit_events.py <events.jsonl> — runs the built-in checks and prints JSON. Event schema is documented in references/checks.md.