Skip to content

Remove the enterprise action hook - #44

Merged
TeoSlayer merged 1 commit into
mainfrom
remove-action-hook
Oct 1, 2026
Merged

TeoSlayer merged 1 commit into
mainfrom
remove-action-hook

Conversation

@TeoSlayer

Copy link
Copy Markdown
Contributor

Why

The action hook was this plugin's boundary to the hosted control plane, which has been retired. The daemon stopped installing a hook in v1.14.0 (pilotprotocol#485), so every call has gone through the nil-hook branch since then and the rest is unreachable. This is also the last importer of common/actionhook, and one of three remaining importers of common/decision.

What is removed

  • action_hook.go: ActionHook, SetActionHook, prepareTrustAction, trustActionAttempt.
  • The actionHook field on Manager.
  • The six prepareTrustAction call sites in handshake.go and their post-action bookkeeping (autoAllowed, autoExecuted, autoReason, granted, skipReason, and the handshake.control_blocked event, which was only published when a hook blocked an action).
  • enterprise_action_hook_test.go.

Why behaviour without a hook is unchanged

prepareTrustAction returned (nil, nil) when no hook was attached, and (*trustActionAttempt)(nil).complete was a no-op. At each call site the kept code is exactly that branch:

Call site With no hook Now
handleRequest autoAllowed is always true; deferred completion returns immediately the four auto-accept conditions drop && autoAllowed
handleAccept no early return; deferred completion is a no-op block removed, rest unchanged
SendRequest err is nil; completions are no-ops block removed; err = hm.sendMessage(...) becomes err := ...
processRelayedRequest as handleRequest the four auto-accept conditions drop && autoAllowed
processRelayedApproval as handleAccept block removed, rest unchanged
ApproveHandshake err is nil; completions are no-ops block removed; the first pending lookup keeps its early return

The pre-checks that ran before the hook (already-trusted fast path, pending-queue caps in handleRequest and processRelayedRequest) run on every request and are untouched, including their log lines, which still say "before control hook". Auto-accept rules, the pending queue, replay protection, flood caps, relay handling and trust persistence are not changed. Apart from two reworded comments, every added line in handshake.go is one of the simplified conditions above.

Tests

zz_action_hook_flood_test.go asserted that the hook was not invoked for an already-trusted peer or for over-cap spam. It is now zz_precheck_flood_test.go and asserts the same outcomes directly: the trusted peer keeps its record and is not queued; over-cap direct and relayed requests are neither queued nor trusted. The caps themselves are also still covered by TestHandleRequestPendingQueueFullRejects and TestPendingQueuePerSourceCapPreventsSingleSourceExhaustion.

What I ran

With GOWORK=off:

  • go build ./..., go vet ./...: clean.
  • go test -race -count=1 ./...: pass.
  • go mod tidy: no change to go.mod or go.sum; the go directive stays at 1.25.13.
  • gofmt -l is clean for the files touched (four untouched test files are already unformatted on main).
  • pilotprotocol, runtime and libpilot at their current main, each with a replace pointing at this branch: go build ./... and go vet ./... pass. None of them references SetActionHook or ActionHook.

Not run: pilotprotocol's ./tests integration suite.

🤖 Generated with Claude Code

The hook was the handshake plugin's boundary to the hosted control
plane, which has been retired. The daemon stopped installing a hook in
v1.14.0, so every call went through the nil-hook branch and the rest was
unreachable.

Remove action_hook.go, the Manager's actionHook field and
SetActionHook, the six prepareTrustAction call sites and their
post-action bookkeeping. What remains at each site is the code that ran
when no hook was attached; the pre-checks that settle already-trusted
peers and over-cap spam are unchanged, including their log lines.

The hook-only tests go with it. The flood test that asserted the hook
was not called for already-trusted and over-cap requests now asserts the
same outcomes directly (record kept, nothing queued or trusted).

The module no longer imports common/decision or common/actionhook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TeoSlayer
TeoSlayer merged commit 2f69a51 into main Oct 1, 2026
4 checks passed
TeoSlayer pushed a commit that referenced this pull request Oct 7, 2026
…ld take

handleRequest and processRelayedRequest dropped any new peer when the
pending queue was full, before the mutual / shared-network / trusted-agent /
trust-auto-approve rules ran. The check was there to keep over-cap spam away
from the control hook; the hook is gone (#44) and the check is not: a node
with trust-auto-approve on, or with a mutual request outstanding, refused
peers it would have trusted without queueing them.

The caps are still enforced where a request is actually queued, so over-cap
spam with nothing to auto-accept is neither queued nor trusted, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
TeoSlayer added a commit that referenced this pull request Oct 7, 2026
…ld take (#45)

handleRequest and processRelayedRequest dropped any new peer when the
pending queue was full, before the mutual / shared-network / trusted-agent /
trust-auto-approve rules ran. The check was there to keep over-cap spam away
from the control hook; the hook is gone (#44) and the check is not: a node
with trust-auto-approve on, or with a mutual request outstanding, refused
peers it would have trusted without queueing them.

The caps are still enforced where a request is actually queued, so over-cap
spam with nothing to auto-accept is neither queued nor trusted, as before.

Co-authored-by: Teo Calin <calinteodor@Teos-MacBook-Pro.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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