Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::HookRegistry Class Reference

Thread-safe hook registration and dispatch. More...

#include <entropic/core/hook_registry.h>

Public Member Functions

entropic_error_t register_hook (entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data, int priority)
 Register a hook callback at a hook point.
 
entropic_error_t deregister_hook (entropic_hook_point_t point, entropic_hook_callback_t callback, void *user_data)
 Deregister a hook callback.
 
int fire_pre (entropic_hook_point_t point, const char *context_json, char **out_json)
 Fire pre-hooks.
 
void fire_post (entropic_hook_point_t point, const char *context_json, char **out_json)
 Fire post-hooks.
 
void fire_info (entropic_hook_point_t point, const char *context_json)
 Fire informational hooks (no modify, no cancel).
 
size_t hook_count (entropic_hook_point_t point) const
 Get the number of registered hooks for a point.
 

Detailed Description

Thread-safe hook registration and dispatch.

Owns a vector of HookEntry per hook point. Registration and deregistration take a write lock. Dispatch takes a read lock and a snapshot of the entry list (so hooks can register/deregister other hooks from within a callback without deadlock).

Version
1.9.1

Definition at line 48 of file hook_registry.h.

Member Function Documentation

◆ deregister_hook()

entropic_error_t entropic::HookRegistry::deregister_hook ( entropic_hook_point_t  point,
entropic_hook_callback_t  callback,
void *  user_data 
)

Deregister a hook callback.

Matches on (point, callback, user_data) triple. Idempotent — returns ENTROPIC_OK if no match found.

Parameters
pointHook point.
callbackCallback to remove.
user_datauser_data from registration.
Returns
ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG. @threadsafety Write-locks the hook point's mutex.
Version
1.9.1
Parameters
pointHook point.
callbackCallback to match.
user_datauser_data to match.
Returns
ENTROPIC_OK (idempotent).

Definition at line 78 of file hook_registry.cpp.

◆ fire_info()

void entropic::HookRegistry::fire_info ( entropic_hook_point_t  point,
const char *  context_json 
)

Fire informational hooks (no modify, no cancel).

Parameters
pointThe hook point.
context_jsonContext JSON. @threadsafety Read-locks, then dispatches on snapshot.
Version
1.9.1
Parameters
pointHook point.
context_jsonContext JSON.

Definition at line 234 of file hook_registry.cpp.

◆ fire_post()

void entropic::HookRegistry::fire_post ( entropic_hook_point_t  point,
const char *  context_json,
char **  out_json 
)

Fire post-hooks.

Fire post-hooks with result transformation chaining.

Returns transformed result.

Parameters
pointThe hook point.
context_jsonInput result JSON.
out_jsonOutput: transformed JSON (caller frees), or NULL. @threadsafety Read-locks, then dispatches on snapshot.
Version
1.9.1
Parameters
pointHook point.
context_jsonInput result JSON.
out_jsonOutput: accumulated transformed JSON, or NULL.

Definition at line 185 of file hook_registry.cpp.

◆ fire_pre()

int entropic::HookRegistry::fire_pre ( entropic_hook_point_t  point,
const char *  context_json,
char **  out_json 
)

Fire pre-hooks.

Fire pre-hooks with modification chaining and cancellation.

Returns modified context or cancellation.

Parameters
pointThe hook point.
context_jsonInput context JSON.
out_jsonOutput: modified JSON (caller frees), or NULL.
Returns
0 = proceed, non-zero = cancelled. @threadsafety Read-locks, then dispatches on snapshot.
Version
1.9.1
Parameters
pointHook point.
context_jsonInput context JSON.
out_jsonOutput: accumulated modified JSON, or NULL.
Returns
0 = proceed, non-zero = cancelled.

Definition at line 126 of file hook_registry.cpp.

◆ hook_count()

size_t entropic::HookRegistry::hook_count ( entropic_hook_point_t  point) const

Get the number of registered hooks for a point.

Parameters
pointHook point.
Returns
Entry count, or 0 if invalid point. @threadsafety Read-locks the hook point's mutex.
Version
1.9.1
Parameters
pointHook point.
Returns
Entry count.

Definition at line 266 of file hook_registry.cpp.

◆ register_hook()

entropic_error_t entropic::HookRegistry::register_hook ( entropic_hook_point_t  point,
entropic_hook_callback_t  callback,
void *  user_data,
int  priority 
)

Register a hook callback at a hook point.

Parameters
pointHook point enum value.
callbackFunction pointer.
user_dataOpaque consumer data.
priorityExecution order (0 = first, ascending).
Returns
ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG. @threadsafety Write-locks the hook point's mutex.
Version
1.9.1
Parameters
pointHook point.
callbackFunction pointer.
user_dataOpaque pointer.
priorityExecution order (ascending).
Returns
ENTROPIC_OK or ENTROPIC_ERROR_INVALID_CONFIG.

Definition at line 41 of file hook_registry.cpp.


The documentation for this class was generated from the following files: