Skip to content

feat: add nudge field to rule schema + 2 example rules#2

Merged
knhn1004 merged 3 commits intomainfrom
feat/rule-nudges
May 3, 2026
Merged

feat: add nudge field to rule schema + 2 example rules#2
knhn1004 merged 3 commits intomainfrom
feat/rule-nudges

Conversation

@knhn1004
Copy link
Copy Markdown
Collaborator

@knhn1004 knhn1004 commented May 3, 2026

Summary

Adds optional `nudge: string` to `gate.evaluate[]` entries. Lets rule authors provide a short prompt that the OpenAgentLock daemon concatenates onto the deny reason — agents see "use `trash` instead" or "use the secret-fetcher skill" rather than just being blocked.

Companion PR on the main repo: https://github.com/openagentlock/OpenAgentLock/pulls — that's where the daemon-side plumbing + hook output formatting lives.

What's in this PR

  • Schema: optional `nudge` field on `gate.evaluate[]` (`maxLength: 2000`).
  • Two example rules:
    • `safety.rm-suggest-trash` — Bash, denies dangerous `rm -rf` shapes (anchored at start-of-command so `git rm` etc. don't false-positive), nudges toward `trash` / `trash-cli`.
    • `safety.secret-read-suggest-skill` — Read, denies `.env` / `/.ssh` / `/.aws/credentials` paths, nudges toward an `openagentlock/skills` `secret-fetcher` skill.

Backward compat: schema change is purely additive (optional field), and `additionalProperties: true` was already on `evaluate[]`. All 27 pre-existing rules still validate.

Test plan

  • `bun run validate` from `tools/` — all 29 rules pass.
  • `bun run build-index` — both new rules in the rebuilt index.
  • Pages workflow green on merge.

🤖 Generated with Claude Code

knhn1004 and others added 3 commits May 3, 2026 14:43
Adds an optional `nudge: string` property to each entry of
`gate.evaluate[]`. It is purely additive — existing rules without it
remain valid and the daemon-side change is gated separately. The field
is intended to carry a human-readable recovery hint that the daemon
pipes through to the agent harness alongside the verdict (e.g. "use
trash instead of rm -rf"), so a deny can also teach the agent the
correct retry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds two community rules that exercise the new gate.evaluate[].nudge
field:

- safety.rm-suggest-trash (medium): denies dangerous rm shapes
  (-r/-R/-f bundles, --recursive, --force) and points the agent at
  `trash` / `trash-cli` for recoverable deletes, with `rm -i` as the
  middle ground and a "ask the operator" escape hatch for permanent
  recursive deletes. Deliberately softer than rogue.destructive-bash;
  this one teaches recovery, the other one hard-blocks the worst case.

- safety.secret-read-suggest-skill (high): denies Reads of canonical
  secret-bearing paths (.env / .env.*, ~/.ssh/*, ~/.aws/credentials,
  kubeconfig, .netrc, etc.) and nudges toward an illustrative
  openagentlock/skills `secret-fetcher` skill, with operator paste as
  the actually-actionable fallback today. Demonstrates the "force use
  of a skill" pattern — a deny that simultaneously teaches the agent
  the correct path forward.

Both rules use only RE2-compatible regex (no negative lookahead,
no backreferences) and follow the existing rule.yaml + README layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Anchor the rm-suggest-trash regexes to start-of-command (or after a
shell separator/sudo) so `git rm -rf`, `jj rm`, `cargo rm`, `npm rm`
no longer trigger the "use trash" nudge, which is wrong for those
operations. Plain `rm -rf`, `sudo rm -rf`, and inline-separator forms
(`cd / && rm -rf …`, `ls; rm -rf …`) still match.

Also cap `gate.evaluate[].nudge` at 2000 chars in the schema to keep
nudges as short prose rather than smuggled-in skill prompts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@knhn1004 knhn1004 merged commit 3c20769 into main May 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant