Skip to content

feat: upgrade hook system with multi-executor types, structured output, and event telemetry#75

Merged
yishuiliunian merged 2 commits intomainfrom
feat/hook-system-upgrade
Apr 4, 2026
Merged

feat: upgrade hook system with multi-executor types, structured output, and event telemetry#75
yishuiliunian merged 2 commits intomainfrom
feat/hook-system-upgrade

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Upgrade hook system from shell-command-only to full Harness Hook architecture with Command/HTTP/Prompt executor types, structured output interpretation, and condition-based matching with glob expressions
  • Wire all 8 hook events (PreToolUse, PostToolUse, PreRequest, PostInput, Stop, SessionStart, SessionEnd, PreCompact) with correct data flow
  • Add configurable agent control-loop thresholds (HarnessConfig), per-turn metrics (TurnMetrics/TurnCompleted), and event causality tracking (event_id/turn_id/correlation_id)

Changes

New files (19):

  • loopal-hooks: executor.rs, executor_command.rs, executor_http.rs, executor_prompt.rs, output.rs, input.rs, service.rs, async_store.rs + 3 test files
  • loopal-config: harness.rs, hook_condition.rs, resolver_hooks_test.rs
  • loopal-kernel: hook_factory.rs
  • loopal-protocol: event_id.rs, event_payload.rs
  • loopal-runtime: turn_metrics.rs, fire_hooks.rs

Modified files (60):

  • Hook config types: HookEvent 8 variants, HookType enum, HookConfig new fields, cross-layer dedup
  • Kernel: hook_registry → hook_service, DefaultExecutorFactory with graceful None handling
  • Runtime: tool_pipeline pre/post hook rewrite, 8 event wiring points, rewake_rx 3-way select
  • Protocol: AgentEvent gains event_id/turn_id/correlation_id, TurnCompleted variant
  • Auto-mode: configurable thresholds for LoopDetector/CircuitBreaker/AutoClassifier
  • All AgentEvent/HookConfig/AgentLoopParams construction sites updated

Test plan

  • bazel build //... passes
  • bazel test //... — 48/48 tests pass
  • bazel build //... --config=clippy — zero warnings
  • Condition glob matching integration tests (registry_test.rs)
  • Executor factory validation tests (None provider, missing URL)
  • Hook dedup test (resolver_hooks_test.rs)
  • CI passes

…t, and event telemetry

Upgrade the hook system from shell-command-only to a full Harness Hook
architecture supporting Command/HTTP/Prompt executor types, structured
output interpretation, condition-based matching with glob expressions,
cross-layer dedup, configurable agent control-loop thresholds, and
per-turn event telemetry with causality tracking.

Key changes:
- HookExecutor trait + CommandExecutor/HttpExecutor/PromptExecutor
- HookService as single orchestration entry point
- 8 hook events fully wired (PreToolUse, PostToolUse, PreRequest,
  PostInput, Stop, SessionStart, SessionEnd, PreCompact)
- HookOutput structured protocol with permission/context/input override
- Condition expressions: "Bash(git push*)", "Write(*.rs)", "Tool1|Tool2"
- HarnessConfig for loop/circuit-breaker/stop-feedback thresholds
- AgentEvent gains event_id, turn_id, correlation_id fields
- TurnCompleted event with aggregated metrics
- AsyncHookStore + rewake channel infrastructure (prepared, not yet activated)
@yishuiliunian yishuiliunian merged commit 082439e into main Apr 4, 2026
3 checks passed
@yishuiliunian yishuiliunian deleted the feat/hook-system-upgrade branch April 4, 2026 10:17
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