Skip to content

feat(cli): tole hook add|list|remove|test (#582 part 3) - #648

Merged
ajianaz merged 1 commit into
developfrom
feat/hook-cli
Nov 12, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/hook-cli

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Part 3 of #582: tole hook add|list|remove|test and its docs. The end-to-end test showing that serve renders the template into a fired agent run's context is in a separate PR (#649), so this one stays under ~900 lines.

Why

Before this PR, routes were edited into the user config by hand, and there was no way to check a route before a real delivery arrived. The commands make that safe:

  • the key is named, never typed or printed;
  • routes go to the user config only;
  • test shows exactly what the fired run would see, without firing it.

Changes

  • crates/tole-cli/src/hook_cli.rs (new), wired in as tole hook under shell-tools with GatePolicy::Skip, like tole cron.
    • add ROUTE --key-env NAME | --key-file /abs/path [--job J] [--event E]... [--template T] [--rate-per-minute N] [--max-body-bytes N]:
      • appends one [hooks.ROUTE] section to the user config only, keeping the rest of the file and its comments, and writes through a temporary file and a rename;
      • needs exactly one key source, and no flag takes the key value;
      • refuses an existing route;
      • validates the route with hooks::load, the loader serve uses, and checks that the result round-trips through the config parser.
    • allow_writes, insecure_loopback and the filter have no flag. Widening a route stays a manual edit, as design P8 says.
    • list shows the job, events, filter shape (new hook_filter::summary: paths and operators, no values), writes: yes|no and signed or insecure. It shows no key, no key variable and no key file.
    • remove ROUTE cuts [hooks.ROUTE] and [hooks.ROUTE.*] and keeps the rest. It refuses ("edit by hand") if the route is still there afterwards, for example when it is written as an inline table.
    • test ROUTE [--payload FILE] [--event E] is a local dry run:
      • signs with the route's real key, then verifies;
      • applies the events allowlist and the filter;
      • prints the fenced template rendering, redacted with the process secrets and capped like serve's;
      • fires nothing and writes no ledger line.
    • --fire --url http://127.0.0.1:PORT posts the signed delivery to a running serve, which uses the real claim path. Only loopback http:// URLs are accepted (127/8, [::1], localhost).
  • tests/hook_cli.rs (new): 5 tests on the real binary.
  • Docs: CHANGELOG [Unreleased], design §6 "as implemented, part 3", README usage lines, and a threat-model row.
  • Dependencies: no change.

Testing

  • cargo fmt --all
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace
  • cargo test -p tole-core --no-default-features
  • No-mcp CI commands:
    • cargo check -p tole-cli --no-default-features
    • cargo clippy -p tole-cli --no-default-features --features shell-tools -- -D warnings
    • cargo test -p tole-cli --no-default-features
  • cora review --no-llm --staged: no issues.
  • Mutation breaks, each restored afterwards; the tests caught every one:
    • add accepts no key source;
    • add drops the existing file (comments lost);
    • list prints the key variable;
    • list prints filter values;
    • remove leaves [hooks.ROUTE.filter];
    • test renders with an empty secret set (no redaction);
    • test skips the events check;
    • --fire accepts a non-loopback IP;
    • --fire sends a bad signature.

Webhook routes are added to the user config only (never a project one),
checked with the loader tole serve uses. The key is named by --key-env or
--key-file, never given on the command line and never printed. Widening a
route (allow_writes, insecure_loopback, filters) stays a manual edit.
list shows job, events, filter shape and writes, no key source. test is a
local dry run that signs, filters and prints the fenced, redacted context;
--fire posts the signed delivery to a loopback tole serve only.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 023d088 into develop Nov 12, 2026
19 checks passed
@ajianaz
ajianaz deleted the feat/hook-cli branch November 20, 2026 08:36
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.

2 participants