entropic.cpp¶
src/facade/entropic.cpp
@file entropic.cpp @brief librentropic facade — C API implementation.
Owners: @tvanfossen
alloc_cstr
static char * alloc_cstr(const char *src)
Allocate a C string copy via the engine allocator.
src/facade/entropic.cpp:108
Called by alloc_cstr, entropic_adapter_info, entropic_adapter_list, entropic_context_get, entropic_get_diagnostic_prompt, entropic_get_identity_config, entropic_grammar_get, entropic_grammar_list, entropic_grammar_validate, entropic_list_identities, entropic_list_mcp_keys, entropic_profile_get 16 more
entropic_profile_list, entropic_residency_snapshot, entropic_run, entropic_run_batch, entropic_run_session, entropic_serialize_mcp_keys, entropic_session_context_get, entropic_session_list, entropic_speculative_compat, entropic_validation_last_result, gh160_tool_prompt, gh88_meta_tool_prompt, lead_tool_prompt, reader_tool_prompt, run_as_inner, run_messages_inner
Calls entropic_alloc
Source · 7 lines
static char* alloc_cstr(const char* src) {
if (!src) { return nullptr; }
size_t len = std::strlen(src) + 1;
auto* dst = static_cast<char*>(entropic_alloc(len));
if (dst) { std::memcpy(dst, src, len); }
return dst;
}Activity · 7 steps
static char * alloc_cstr(const std::string &src)
Allocate a C string copy from std::string.
src/facade/entropic.cpp:123
Source · 3 lines
static char* alloc_cstr(const std::string& src) {
return alloc_cstr(src.c_str());
}Activity · 1 steps
Requirements
apply_identity_frontmatter
static void apply_identity_frontmatter(entropic_handle_t h, const std::string &name, const entropic::prompts::IdentityFrontmatter &fm)
Apply a parsed identity's frontmatter to the engine handle.
src/facade/entropic.cpp:1001
Source · 19 lines
static void apply_identity_frontmatter(
entropic_handle_t h,
const std::string& name,
const entropic::prompts::IdentityFrontmatter& fm) {
if (fm.allowed_tools.has_value()) {
h->tier_allowed_tools[name] = *fm.allowed_tools;
}
if (!fm.validation_rules.empty()) {
h->tier_validation_rules[name] = fm.validation_rules;
}
if (fm.relay_single_delegate) {
h->engine->set_relay_single_delegate(name);
}
// gh#94 (v2.7.3): per-tier frontmatter SAMPLERS are threaded earlier, in
// thread_frontmatter_samplers() BEFORE init_orchestrator, so they land in
// the orchestrator's by-value config snapshot. Threading them HERE (after
// the snapshot) was the gh#94 ordering bug — the values reached h->config
// but never the orchestrator's frozen copy, so tiers ran defaults.
}Activity · 6 steps
Requirements
c_api_try
static entropic_error_t c_api_try(entropic_handle_t handle, Fn &&fn)
Run a C-API entry-point body inside an exception barrier.
src/facade/entropic.cpp:77
Called by entropic_adapter_load, entropic_configure, entropic_configure_dir, entropic_configure_from_file, entropic_release_model, entropic_state_load, entropic_state_save
Calls capi_test_compactor_fn
Source · 19 lines
static entropic_error_t c_api_try(entropic_handle_t handle, Fn&& fn) {
entropic_error_t rc = ENTROPIC_ERROR_INTERNAL;
try {
rc = fn();
} catch (const std::filesystem::filesystem_error& e) {
if (handle) { handle->last_error = e.what(); }
s_log->error("c_api filesystem_error: {}", e.what());
rc = ENTROPIC_ERROR_IO;
} catch (const nlohmann::json::exception& e) {
if (handle) { handle->last_error = e.what(); }
s_log->error("c_api json::exception: {}", e.what());
rc = ENTROPIC_ERROR_INVALID_CONFIG;
} catch (const std::exception& e) {
if (handle) { handle->last_error = e.what(); }
s_log->error("c_api std::exception: {}", e.what());
rc = ENTROPIC_ERROR_INTERNAL;
}
return rc;
}Activity · 3 steps
Requirements
Flows
cache_tier_allowed_tools
static void cache_tier_allowed_tools(entropic_handle_t h, const std::filesystem::path &data_dir)
Cache per-tier frontmatter fields from identity files.
src/facade/entropic.cpp:1028
Called by wire_prompts_and_persistence
Calls apply_identity_frontmatter, load_identity, set_tier_allowed_tools
Source · 25 lines
static void cache_tier_allowed_tools(
entropic_handle_t h,
const std::filesystem::path& data_dir) {
for (const auto& [name, tier] : h->config.models.tiers) {
std::filesystem::path id_path;
if (tier.identity.has_value()) {
id_path = tier.identity.value();
} else if (!tier.identity_disabled) {
id_path = data_dir / "prompts" / ("identity_" + name + ".md");
}
if (id_path.empty() || !std::filesystem::exists(id_path)) {
continue;
}
entropic::prompts::ParsedIdentity id;
if (entropic::prompts::load_identity(id_path, id).empty()) {
apply_identity_frontmatter(h, name, id.frontmatter);
}
}
// gh#83 (v2.5.2): hand the populated allowlist map to the executor
// for dispatch-time enforcement. A pointer to the handle-owned map
// keeps this order-independent vs wire_tool_executor.
if (h->tool_executor) {
h->tool_executor->set_tier_allowed_tools(&h->tier_allowed_tools);
}
}Activity · 14 steps
Requirements
check_identity
static entropic_error_t check_identity(entropic_handle_t h)
Check handle prerequisites for identity manager APIs.
src/facade/entropic.cpp:201
Called by entropic_create_identity, entropic_destroy_identity, entropic_identity_count, entropic_update_identity
Calls none
Source · 7 lines
static entropic_error_t check_identity(entropic_handle_t h) {
if (!h) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!h->configured.load() || !h->identity_manager) {
return ENTROPIC_ERROR_INVALID_STATE;
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
check_mcp_auth
static entropic_error_t check_mcp_auth(entropic_handle_t h)
Check handle prerequisites for MCP auth APIs.
src/facade/entropic.cpp:186
Called by entropic_deserialize_mcp_keys, entropic_grant_mcp_key, entropic_grant_mcp_key_from, entropic_revoke_mcp_key
Calls none
Source · 7 lines
static entropic_error_t check_mcp_auth(entropic_handle_t h) {
if (!h) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!h->configured.load() || !h->mcp_auth) {
return ENTROPIC_ERROR_INVALID_STATE;
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
check_orchestrator
static entropic_error_t check_orchestrator(entropic_handle_t h)
Check handle prerequisites for orchestrator APIs.
src/facade/entropic.cpp:171
Called by entropic_adapter_load, entropic_adapter_swap, entropic_adapter_unload, entropic_compute_perplexity, entropic_get_logprobs, entropic_grammar_deregister, entropic_grammar_register, entropic_grammar_register_file, entropic_profile_deregister, entropic_profile_register, entropic_release_model, entropic_run 8 more
entropic_run_as, entropic_run_batch, entropic_run_messages, entropic_run_messages_streaming, entropic_run_session, entropic_run_session_as, entropic_run_streaming, run_session_streaming_impl
Calls none
Source · 7 lines
static entropic_error_t check_orchestrator(entropic_handle_t h) {
if (!h) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!h->configured.load() || !h->orchestrator) {
return ENTROPIC_ERROR_INVALID_STATE;
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
configure_common
static entropic_error_t configure_common(entropic_handle_t h)
Shared body of all entropic_configure* entry points.
src/facade/entropic.cpp:2064
Called by do_configure_dir, do_configure_from_file, do_configure_json
Calls init_engine_and_interfaces, init_orchestrator, reject_if_configured, resolve_data_dir, set_console_enabled, start_external_bridge, start_http_listener, thread_frontmatter_samplers, validate_prompt_sources, warn_tier_grammars_step, wire_prompts_and_persistence
Source · 43 lines
static entropic_error_t configure_common(entropic_handle_t h) {
auto rc = reject_if_configured(h);
if (rc != ENTROPIC_OK) { return rc; }
// gh#59 follow-up (v2.3.7): honor console_logging before any init
// logging fires. When false, strip the stderr console sink so the
// file sink (already installed by setup_session) is the only route
// — TUI consumers paint to fd 2 and can't tolerate engine output
// there. Default (true) is a no-op; operators keep stderr logs.
entropic::log::set_console_enabled(h->config.console_logging);
auto data_dir = entropic::config::resolve_data_dir(h->config);
// gh#156 (v2.13.0): a configured constitution / app_context path that
// cannot be loaded is a config error, and it is raised HERE — before
// init_orchestrator loads the model.
rc = validate_prompt_sources(h, data_dir);
if (rc == ENTROPIC_OK) {
// gh#94 (v2.7.3): thread per-tier frontmatter samplers into the
// config BEFORE the orchestrator snapshots it by value. The
// engine-bound frontmatter wiring stays in
// wire_prompts_and_persistence (post-engine).
thread_frontmatter_samplers(h, data_dir);
// gh#154 (v2.13.0): name a tier grammar stem that does not resolve
// YET. Not a refusal — entropic_grammar_register* needs the
// orchestrator this call is about to build, so a consumer's only
// legal order is configure-then-register. The run that selects the
// tier is what fails, loudly and typed, if nobody ever did.
warn_tier_grammars_step(h, data_dir);
}
if (rc == ENTROPIC_OK) {
rc = init_orchestrator(h, data_dir);
}
if (rc != ENTROPIC_OK) { return rc; }
init_engine_and_interfaces(h, data_dir);
wire_prompts_and_persistence(h, data_dir);
h->configured.store(true);
start_external_bridge(h);
// gh#204: an explicitly configured HTTP listener that cannot start fails
// configure, so a headless host exits instead of running unreachable.
const auto http_rc = start_http_listener(h);
s_log->info("configure complete");
return http_rc;
}Activity · 20 steps
Requirements
do_configure_dir
static entropic_error_t do_configure_dir(entropic_handle_t handle, const char *project_dir)
entropic_configure_dir body — wrapped by c_api_try .
src/facade/entropic.cpp:2223
Called by entropic_configure_dir
Calls auto_discover_and_load, configure_common, load_layered, register_handle_log, set_project_dir, setup_session
Source · 30 lines
static entropic_error_t do_configure_dir(
entropic_handle_t handle, const char* project_dir) {
// Session logging FIRST — capture everything from preload through init.
if (project_dir && project_dir[0] != '\0') {
entropic::log::setup_session(project_dir);
// gh#59 (v2.3.1): per-handle dispatcher registration. Routes
// session.log writes for this handle's HandleLogScope-tagged
// threads to this handle's file only — no cross-handle bleed.
entropic::log::register_handle_log(handle->log_id, project_dir);
}
handle->bundled_models.auto_discover_and_load();
std::filesystem::path proj_dir = (project_dir && project_dir[0] != '\0')
? project_dir : "";
auto err = entropic::config::load_layered(
proj_dir, "default_config.yaml",
handle->bundled_models, handle->config);
if (!err.empty()) {
handle->last_error = err;
s_log->error("configure_dir: {}", err);
return ENTROPIC_ERROR_INVALID_CONFIG;
}
auto rc = configure_common(handle);
// gh#31 (v2.1.6): propagate the configured project_dir into the
// engine so `AgentEngine::get_repo_dir()` uses it as the sandbox
// snapshot source.
if (rc == ENTROPIC_OK && handle->engine && !proj_dir.empty()) {
handle->engine->set_project_dir(std::filesystem::absolute(proj_dir));
}
return rc;
}Activity · 14 steps
Requirements
REQ-ABI-002 REQ-API-004 REQ-CFG-001
Flows
do_configure_from_file
static entropic_error_t do_configure_from_file(entropic_handle_t handle, const char *config_path)
entropic_configure_from_file body — wrapped by c_api_try .
src/facade/entropic.cpp:2168
Called by entropic_configure_from_file
Calls auto_discover_and_load, configure_common, load_config_from_file, register_handle_log, setup_session
Source · 24 lines
static entropic_error_t do_configure_from_file(
entropic_handle_t handle, const char* config_path) {
handle->bundled_models.auto_discover_and_load();
auto err = entropic::config::load_config_from_file(
config_path, handle->bundled_models, handle->config);
if (!err.empty()) {
handle->last_error = err;
s_log->error("configure_from_file: {}", err);
return ENTROPIC_ERROR_INVALID_CONFIG;
}
// Parity with configure_dir: if the parsed config specifies a
// log_dir, start session logging there. Without this, consumers
// using the file-based API get no session.log on disk even when
// their YAML declares log_dir.
if (!handle->config.log_dir.empty()) {
entropic::log::setup_session(handle->config.log_dir);
// gh#59 (v2.3.1): per-handle dispatcher file sink so log lines
// emitted within this handle's HandleLogScope route to this
// handle's session.log only.
entropic::log::register_handle_log(
handle->log_id, handle->config.log_dir);
}
return configure_common(handle);
}Activity · 10 steps
Requirements
do_configure_json
static entropic_error_t do_configure_json(entropic_handle_t handle, const char *config_json)
entropic_configure body — wrapped by c_api_try in the public entry.
src/facade/entropic.cpp:2115
Called by entropic_configure
Calls auto_discover_and_load, configure_common, load_config_from_string, register_handle_log, setup_session
Source · 23 lines
static entropic_error_t do_configure_json(
entropic_handle_t handle, const char* config_json) {
handle->bundled_models.auto_discover_and_load();
auto err = entropic::config::load_config_from_string(
config_json, handle->bundled_models, handle->config);
if (!err.empty()) {
handle->last_error = err;
s_log->error("configure: {}", err);
return ENTROPIC_ERROR_INVALID_CONFIG;
}
// gh#109 follow-up: parity with configure_dir/configure_from_file.
// Without this, a JSON-string config that sets "log_dir" got no
// session.log at all — config.log_dir was honored for the sqlite/
// conversation store (init_persistence) but never wired to the
// per-handle log dispatcher, so no file sink existed for any
// HandleLogScope-tagged log line to route to.
if (!handle->config.log_dir.empty()) {
entropic::log::setup_session(handle->config.log_dir);
entropic::log::register_handle_log(
handle->log_id, handle->config.log_dir);
}
return configure_common(handle);
}Activity · 10 steps
Requirements
entropic_adapter_info
ENTROPIC_EXPORT char * entropic_adapter_info(entropic_handle_t handle, const char *adapter_name)
Get adapter info as JSON.
src/facade/entropic.cpp:4212
Source · 18 lines
char* entropic_adapter_info(
entropic_handle_t handle,
const char* adapter_name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !adapter_name) {
return nullptr;
}
try {
auto ai = handle->orchestrator->adapter_manager().info(adapter_name);
return alloc_cstr(
facade_json::serialize_adapter_info(ai).c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_info: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_adapter_info(entropic_handle_t handle, const char *adapter_name)
Get adapter info as JSON string.
src/facade/entropic.cpp:4212
Source · 18 lines
char* entropic_adapter_info(
entropic_handle_t handle,
const char* adapter_name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !adapter_name) {
return nullptr;
}
try {
auto ai = handle->orchestrator->adapter_manager().info(adapter_name);
return alloc_cstr(
facade_json::serialize_adapter_info(ai).c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_info: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_adapter_list
ENTROPIC_EXPORT char * entropic_adapter_list(entropic_handle_t handle)
List all adapters as JSON array.
src/facade/entropic.cpp:4244
Called by SCENARIO, TEST_CASE
Calls adapter_manager, alloc_cstr, serialize_adapter_list
Source · 15 lines
char* entropic_adapter_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto adapters = handle->orchestrator->adapter_manager().list_adapters();
return alloc_cstr(
facade_json::serialize_adapter_list(adapters).c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_adapter_list(entropic_handle_t handle)
List all known adapters as a JSON array.
src/facade/entropic.cpp:4244
Source · 15 lines
char* entropic_adapter_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto adapters = handle->orchestrator->adapter_manager().list_adapters();
return alloc_cstr(
facade_json::serialize_adapter_list(adapters).c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_adapter_load
ENTROPIC_EXPORT entropic_error_t entropic_adapter_load(entropic_handle_t handle, const char *adapter_name, const char *adapter_path, const char *base_model_path, float scale)
Load a LoRA adapter into RAM.
src/facade/entropic.cpp:4066
Source · 24 lines
entropic_error_t entropic_adapter_load(
entropic_handle_t handle,
const char* adapter_name,
const char* adapter_path,
const char* base_model_path,
float scale)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the base model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !adapter_name || !adapter_path
|| !base_model_path
|| (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!adapter_name || !adapter_path || !base_model_path)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle, [&]() {
return do_adapter_load(handle, adapter_name, adapter_path,
base_model_path, scale);
});
}Activity · 6 steps
entropic_error_t entropic_adapter_load(entropic_handle_t handle, const char *adapter_name, const char *adapter_path, const char *base_model_path, float scale)
Load a LoRA adapter into RAM.
src/facade/entropic.cpp:4066
Source · 24 lines
entropic_error_t entropic_adapter_load(
entropic_handle_t handle,
const char* adapter_name,
const char* adapter_path,
const char* base_model_path,
float scale)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the base model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !adapter_name || !adapter_path
|| !base_model_path
|| (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!adapter_name || !adapter_path || !base_model_path)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle, [&]() {
return do_adapter_load(handle, adapter_name, adapter_path,
base_model_path, scale);
});
}Activity · 6 steps
Requirements
entropic_adapter_state
ENTROPIC_EXPORT int entropic_adapter_state(entropic_handle_t handle, const char *adapter_name)
Query adapter state.
src/facade/entropic.cpp:4181
Source · 17 lines
int entropic_adapter_state(
entropic_handle_t handle,
const char* adapter_name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !adapter_name) {
return -1;
}
try {
auto st = handle->orchestrator->adapter_manager().state(adapter_name);
return static_cast<int>(st);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_state: {}", handle->last_error);
return -1;
}
}Activity · 3 steps
int entropic_adapter_state(entropic_handle_t handle, const char *adapter_name)
Query adapter lifecycle state.
src/facade/entropic.cpp:4181
Source · 17 lines
int entropic_adapter_state(
entropic_handle_t handle,
const char* adapter_name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !adapter_name) {
return -1;
}
try {
auto st = handle->orchestrator->adapter_manager().state(adapter_name);
return static_cast<int>(st);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("adapter_state: {}", handle->last_error);
return -1;
}
}Activity · 3 steps
Requirements
entropic_adapter_swap
ENTROPIC_EXPORT entropic_error_t entropic_adapter_swap(entropic_handle_t handle, const char *adapter_name)
Swap the active LoRA adapter.
src/facade/entropic.cpp:4144
Called by TEST_CASE
Calls adapter_manager, check_orchestrator, get_backend, last_used_tier, llama_context_ptr
Source · 24 lines
entropic_error_t entropic_adapter_swap(
entropic_handle_t handle,
const char* adapter_name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !adapter_name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto tier = handle->orchestrator->last_used_tier();
auto* base = handle->orchestrator->get_backend(tier);
auto* llama = dynamic_cast<entropic::LlamaCppBackend*>(base);
if (!llama || !llama->llama_context_ptr()) {
throw std::runtime_error("no active llama context for swap");
}
bool ok = handle->orchestrator->adapter_manager().swap(
adapter_name, llama->llama_context_ptr());
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ADAPTER_SWAP_FAILED;
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_adapter_swap(entropic_handle_t handle, const char *adapter_name)
Swap active LoRA adapter.
src/facade/entropic.cpp:4144
Source · 24 lines
entropic_error_t entropic_adapter_swap(
entropic_handle_t handle,
const char* adapter_name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !adapter_name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto tier = handle->orchestrator->last_used_tier();
auto* base = handle->orchestrator->get_backend(tier);
auto* llama = dynamic_cast<entropic::LlamaCppBackend*>(base);
if (!llama || !llama->llama_context_ptr()) {
throw std::runtime_error("no active llama context for swap");
}
bool ok = handle->orchestrator->adapter_manager().swap(
adapter_name, llama->llama_context_ptr());
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ADAPTER_SWAP_FAILED;
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_adapter_unload
ENTROPIC_EXPORT entropic_error_t entropic_adapter_unload(entropic_handle_t handle, const char *adapter_name)
Unload a LoRA adapter.
src/facade/entropic.cpp:4104
Called by TEST_CASE
Calls adapter_manager, check_orchestrator, get_backend, info, last_used_tier, llama_context_ptr, unload, unload
Source · 26 lines
entropic_error_t entropic_adapter_unload(
entropic_handle_t handle,
const char* adapter_name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !adapter_name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto& mgr = handle->orchestrator->adapter_manager();
auto info = mgr.info(adapter_name);
if (info.state == entropic::AdapterState::COLD) {
throw std::runtime_error("adapter not loaded: "
+ std::string(adapter_name));
}
auto tier = handle->orchestrator->last_used_tier();
auto* base = handle->orchestrator->get_backend(tier);
auto* llama = dynamic_cast<entropic::LlamaCppBackend*>(base);
mgr.unload(adapter_name, llama ? llama->llama_context_ptr() : nullptr);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_adapter_unload(entropic_handle_t handle, const char *adapter_name)
Unload a LoRA adapter.
src/facade/entropic.cpp:4104
Source · 26 lines
entropic_error_t entropic_adapter_unload(
entropic_handle_t handle,
const char* adapter_name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !adapter_name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto& mgr = handle->orchestrator->adapter_manager();
auto info = mgr.info(adapter_name);
if (info.state == entropic::AdapterState::COLD) {
throw std::runtime_error("adapter not loaded: "
+ std::string(adapter_name));
}
auto tier = handle->orchestrator->last_used_tier();
auto* base = handle->orchestrator->get_backend(tier);
auto* llama = dynamic_cast<entropic::LlamaCppBackend*>(base);
mgr.unload(adapter_name, llama ? llama->llama_context_ptr() : nullptr);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_alloc
ENTROPIC_EXPORT void * entropic_alloc(size_t size)
Allocate memory using the engine's allocator.
src/facade/entropic.cpp:2379
Source · 3 lines
void* entropic_alloc(size_t size) {
return malloc(size);
}Activity · 1 steps
void * entropic_alloc(size_t size)
Allocate memory using the engine's allocator.
src/facade/entropic.cpp:2379
Source · 3 lines
void* entropic_alloc(size_t size) {
return malloc(size);
}Activity · 1 steps
Requirements
entropic_api_version
ENTROPIC_EXPORT int entropic_api_version(void)
Get the C API version number.
src/facade/entropic.cpp:2354
Source · 3 lines
int entropic_api_version(void) {
return 2;
}Activity · 1 steps
int entropic_api_version(void)
Get the plugin API version number.
src/facade/entropic.cpp:2354
Source · 3 lines
int entropic_api_version(void) {
return 2;
}Activity · 1 steps
Requirements
entropic_check_mcp_key
ENTROPIC_EXPORT int entropic_check_mcp_key(entropic_handle_t handle, const char *identity_name, const char *tool_name, entropic_mcp_access_level_t level)
Check if a tool call is authorized for an identity.
src/facade/entropic.cpp:4718
Source · 13 lines
int entropic_check_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* tool_name,
entropic_mcp_access_level_t level)
{
if (!handle || !handle->configured.load()
|| !handle->mcp_auth || !identity_name || !tool_name) {
return -1;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->check_access(identity_name, tool_name, lvl) ? 1 : 0;
}Activity · 4 steps
int entropic_check_mcp_key(entropic_handle_t handle, const char *identity_name, const char *tool_name, entropic_mcp_access_level_t level)
Check MCP key authorization for an identity.
src/facade/entropic.cpp:4718
Source · 13 lines
int entropic_check_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* tool_name,
entropic_mcp_access_level_t level)
{
if (!handle || !handle->configured.load()
|| !handle->mcp_auth || !identity_name || !tool_name) {
return -1;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->check_access(identity_name, tool_name, lvl) ? 1 : 0;
}Activity · 4 steps
Requirements
entropic_clear_user_message_queue
ENTROPIC_EXPORT entropic_error_t entropic_clear_user_message_queue(entropic_handle_t handle)
Drop all queued user messages.
src/facade/entropic.cpp:3269
Source · 8 lines
entropic_error_t entropic_clear_user_message_queue(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->engine) {
handle->engine->clear_user_message_queue();
}
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_clear_user_message_queue(entropic_handle_t handle)
Drop all queued mid-gen user messages.
src/facade/entropic.cpp:3269
Source · 8 lines
entropic_error_t entropic_clear_user_message_queue(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->engine) {
handle->engine->clear_user_message_queue();
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_compute_perplexity
ENTROPIC_EXPORT entropic_error_t entropic_compute_perplexity(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, float *perplexity)
Compute perplexity for a token sequence.
src/facade/entropic.cpp:5076
Source · 28 lines
entropic_error_t entropic_compute_perplexity(
entropic_handle_t handle,
const char* model_id,
const int32_t* tokens,
int n_tokens,
float* perplexity)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the tier's model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !model_id || !tokens || !perplexity
|| n_tokens < 2 || (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!model_id || !tokens || !perplexity || n_tokens < 2)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto* backend = require_ready_backend(handle, model_id);
*perplexity = backend->compute_perplexity(tokens, n_tokens);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("compute_perplexity: {}", handle->last_error);
return ENTROPIC_ERROR_EVAL_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_compute_perplexity(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, float *perplexity)
Compute perplexity for a token sequence.
src/facade/entropic.cpp:5076
Source · 28 lines
entropic_error_t entropic_compute_perplexity(
entropic_handle_t handle,
const char* model_id,
const int32_t* tokens,
int n_tokens,
float* perplexity)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the tier's model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !model_id || !tokens || !perplexity
|| n_tokens < 2 || (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!model_id || !tokens || !perplexity || n_tokens < 2)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto* backend = require_ready_backend(handle, model_id);
*perplexity = backend->compute_perplexity(tokens, n_tokens);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("compute_perplexity: {}", handle->last_error);
return ENTROPIC_ERROR_EVAL_FAILED;
}
}Activity · 5 steps
Requirements
entropic_configure
ENTROPIC_EXPORT entropic_error_t entropic_configure(entropic_handle_t handle, const char *config_json)
Configure the engine from a JSON config string.
src/facade/entropic.cpp:2149
Called by ConfiguredCapiHandle, ConfiguredHandle, GateHandle, Handle, Handle, Handle, RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO 6 more
SCENARIO, TEST_CASE, TEST_CASE, TEST_CASE, WsHandle, if
Calls c_api_try, do_configure_json
Source · 11 lines
entropic_error_t entropic_configure(
entropic_handle_t handle,
const char* config_json) {
if (!handle || !config_json) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_json(handle, config_json); });
}Activity · 4 steps
entropic_error_t entropic_configure(entropic_handle_t handle, const char *config_json)
Configure the engine from a JSON/YAML config string.
src/facade/entropic.cpp:2149
Called by ConfiguredCapiHandle, ConfiguredHandle, GateHandle, Handle, Handle, Handle, RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO 6 more
SCENARIO, TEST_CASE, TEST_CASE, TEST_CASE, WsHandle, if
Calls c_api_try, do_configure_json
Source · 11 lines
entropic_error_t entropic_configure(
entropic_handle_t handle,
const char* config_json) {
if (!handle || !config_json) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_json(handle, config_json); });
}Activity · 4 steps
Requirements
entropic_configure_dir
ENTROPIC_EXPORT entropic_error_t entropic_configure_dir(entropic_handle_t handle, const char *project_dir)
Configure engine using layered config resolution.
src/facade/entropic.cpp:2270
Called by SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, main, open_engine, setup, setup_engine, setup_engine
Calls c_api_try, do_configure_dir
Source · 8 lines
entropic_error_t entropic_configure_dir(
entropic_handle_t handle,
const char* project_dir) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_dir(handle, project_dir); });
}Activity · 4 steps
entropic_error_t entropic_configure_dir(entropic_handle_t handle, const char *project_dir)
Configure using layered resolution (project dir).
src/facade/entropic.cpp:2270
Called by SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, main, open_engine, setup, setup_engine, setup_engine
Calls c_api_try, do_configure_dir
Source · 8 lines
entropic_error_t entropic_configure_dir(
entropic_handle_t handle,
const char* project_dir) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_dir(handle, project_dir); });
}Activity · 4 steps
Requirements
REQ-ABI-001 REQ-ABI-002 REQ-API-004 REQ-API-005 REQ-CFG-001
Flows
entropic_configure_from_file
ENTROPIC_EXPORT entropic_error_t entropic_configure_from_file(entropic_handle_t handle, const char *config_path)
Configure engine from a YAML or JSON config file.
src/facade/entropic.cpp:2203
Called by TEST_CASE, TEST_CASE, configure_host
Calls c_api_try, do_configure_from_file
Source · 11 lines
entropic_error_t entropic_configure_from_file(
entropic_handle_t handle,
const char* config_path) {
if (!handle || !config_path) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_from_file(handle, config_path); });
}Activity · 4 steps
entropic_error_t entropic_configure_from_file(entropic_handle_t handle, const char *config_path)
Configure the engine from a YAML config file.
src/facade/entropic.cpp:2203
Called by TEST_CASE, TEST_CASE, configure_host
Calls c_api_try, do_configure_from_file
Source · 11 lines
entropic_error_t entropic_configure_from_file(
entropic_handle_t handle,
const char* config_path) {
if (!handle || !config_path) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return c_api_try(handle,
[&]() { return do_configure_from_file(handle, config_path); });
}Activity · 4 steps
Requirements
entropic_context_clear
ENTROPIC_EXPORT entropic_error_t entropic_context_clear(entropic_handle_t handle)
Clear conversation history, starting a new session.
src/facade/entropic.cpp:3321
Called by SCENARIO, TEST_CASE, run_scenarios
Calls active_session_key, clear_conversation, release_session_tool_state
Source · 8 lines
entropic_error_t entropic_context_clear(entropic_handle_t handle) {
if (!handle || !handle->engine) { return ENTROPIC_ERROR_INVALID_HANDLE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
const auto key = handle->engine->active_session_key();
handle->engine->clear_conversation();
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_context_clear(entropic_handle_t handle)
Clear conversation history.
src/facade/entropic.cpp:3321
Source · 8 lines
entropic_error_t entropic_context_clear(entropic_handle_t handle) {
if (!handle || !handle->engine) { return ENTROPIC_ERROR_INVALID_HANDLE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
const auto key = handle->engine->active_session_key();
handle->engine->clear_conversation();
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
REQ-ABI-001 REQ-API-005 REQ-LOOP-009
Flows
entropic_context_count
ENTROPIC_EXPORT entropic_error_t entropic_context_count(entropic_handle_t handle, size_t *count)
Get the number of messages in the conversation.
src/facade/entropic.cpp:3836
Source · 12 lines
entropic_error_t entropic_context_count(
entropic_handle_t handle, size_t* count) {
// gh#144 (v2.12.0): see entropic_context_get — same missing engine
// guard, same ordering constraint, same single-exit fold.
if (!handle || !count || !handle->engine) {
return (handle != nullptr && count == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
*count = handle->engine->message_count();
return ENTROPIC_OK;
}Activity · 4 steps
entropic_error_t entropic_context_count(entropic_handle_t handle, size_t *count)
Get conversation message count.
src/facade/entropic.cpp:3836
Source · 12 lines
entropic_error_t entropic_context_count(
entropic_handle_t handle, size_t* count) {
// gh#144 (v2.12.0): see entropic_context_get — same missing engine
// guard, same ordering constraint, same single-exit fold.
if (!handle || !count || !handle->engine) {
return (handle != nullptr && count == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
*count = handle->engine->message_count();
return ENTROPIC_OK;
}Activity · 4 steps
Requirements
entropic_context_get
ENTROPIC_EXPORT entropic_error_t entropic_context_get(entropic_handle_t handle, char **messages_json)
Get the current conversation history as a JSON array.
src/facade/entropic.cpp:3340
Source · 21 lines
entropic_error_t entropic_context_get(
entropic_handle_t handle, char** messages_json) {
// gh#144 (v2.12.0): the !handle->engine leg is new — an unconfigured
// handle has no engine, and this function dereferenced it. The siblings
// entropic_context_clear and entropic_context_usage both guarded it;
// this one and entropic_context_count did not. INVALID_HANDLE matches
// those siblings' contract for an unconfigured handle.
//
// Ordering matters and is not the siblings': a NULL out-param on a
// created-but-unconfigured handle must still report INVALID_ARGUMENT,
// which v2.3.10 pinned. Folded into one exit for the returns <= 3 gate.
if (!handle || !messages_json || !handle->engine) {
return (handle != nullptr && messages_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
*messages_json = alloc_cstr(
facade_json::serialize_messages(handle->engine->get_messages()));
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_context_get(entropic_handle_t handle, char **messages_json)
Get conversation as JSON array.
src/facade/entropic.cpp:3340
Source · 21 lines
entropic_error_t entropic_context_get(
entropic_handle_t handle, char** messages_json) {
// gh#144 (v2.12.0): the !handle->engine leg is new — an unconfigured
// handle has no engine, and this function dereferenced it. The siblings
// entropic_context_clear and entropic_context_usage both guarded it;
// this one and entropic_context_count did not. INVALID_HANDLE matches
// those siblings' contract for an unconfigured handle.
//
// Ordering matters and is not the siblings': a NULL out-param on a
// created-but-unconfigured handle must still report INVALID_ARGUMENT,
// which v2.3.10 pinned. Folded into one exit for the returns <= 3 gate.
if (!handle || !messages_json || !handle->engine) {
return (handle != nullptr && messages_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
*messages_json = alloc_cstr(
facade_json::serialize_messages(handle->engine->get_messages()));
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_context_usage
ENTROPIC_EXPORT entropic_error_t entropic_context_usage(entropic_handle_t handle, size_t *tokens_used, size_t *capacity)
Read current context-window pressure for the active tier.
src/facade/entropic.cpp:3864
Source · 13 lines
entropic_error_t entropic_context_usage(
entropic_handle_t handle,
size_t* tokens_used,
size_t* capacity) {
if (!handle || !handle->engine) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!tokens_used || !capacity) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto [used, max] = handle->engine->context_usage(
handle->engine->get_messages());
*tokens_used = static_cast<size_t>(used);
*capacity = static_cast<size_t>(max);
return max > 0 ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_STATE;
}Activity · 9 steps
entropic_error_t entropic_context_usage(entropic_handle_t handle, size_t *tokens_used, size_t *capacity)
Read current context-window pressure (gh#39, v2.1.8).
src/facade/entropic.cpp:3864
Source · 13 lines
entropic_error_t entropic_context_usage(
entropic_handle_t handle,
size_t* tokens_used,
size_t* capacity) {
if (!handle || !handle->engine) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!tokens_used || !capacity) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto [used, max] = handle->engine->context_usage(
handle->engine->get_messages());
*tokens_used = static_cast<size_t>(used);
*capacity = static_cast<size_t>(max);
return max > 0 ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_STATE;
}Activity · 9 steps
Requirements
entropic_create
ENTROPIC_EXPORT entropic_error_t entropic_create(entropic_handle_t *handle)
Create a new engine instance.
src/facade/entropic.cpp:262
Called by BridgeHandle, ConfiguredCapiHandle, ConfiguredHandle, CreatedOnlyHandle, Fixture, GateHandle, Handle, Handle, Handle, HandleGuard, HandleGuard, RawHandle 21 more
RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, UnconfiguredHandle, WsHandle, configure_host, main, open_engine, setup, setup_engine, setup_engine
Source · 26 lines
entropic_error_t entropic_create(entropic_handle_t* handle) {
if (handle == nullptr) {
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::log::init(spdlog::level::info);
entropic_inference_log_silence(); // silent until configure enables
auto* engine = new (std::nothrow) entropic_engine();
if (engine == nullptr) {
*handle = nullptr;
return ENTROPIC_ERROR_OUT_OF_MEMORY;
}
// gh#59 (v2.3.1): assign a monotonic log id. Used by the
// HandleAwareSink dispatcher to route session.log writes to the
// right file when multiple handles coexist. 0 is reserved for
// "no handle scope active."
static std::atomic<int> s_log_id_counter{0};
engine->log_id = ++s_log_id_counter;
s_log->info("entropic_create() — v{} (log_id={})",
CONFIG_ENTROPIC_VERSION_STRING, engine->log_id);
*handle = engine;
return ENTROPIC_OK;
}Activity · 13 steps
entropic_error_t entropic_create(entropic_handle_t *handle)
Create a new engine instance.
src/facade/entropic.cpp:262
Called by BridgeHandle, ConfiguredCapiHandle, ConfiguredHandle, CreatedOnlyHandle, Fixture, GateHandle, Handle, Handle, Handle, HandleGuard, HandleGuard, RawHandle 21 more
RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, UnconfiguredHandle, WsHandle, configure_host, main, open_engine, setup, setup_engine, setup_engine
Source · 26 lines
entropic_error_t entropic_create(entropic_handle_t* handle) {
if (handle == nullptr) {
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
entropic::log::init(spdlog::level::info);
entropic_inference_log_silence(); // silent until configure enables
auto* engine = new (std::nothrow) entropic_engine();
if (engine == nullptr) {
*handle = nullptr;
return ENTROPIC_ERROR_OUT_OF_MEMORY;
}
// gh#59 (v2.3.1): assign a monotonic log id. Used by the
// HandleAwareSink dispatcher to route session.log writes to the
// right file when multiple handles coexist. 0 is reserved for
// "no handle scope active."
static std::atomic<int> s_log_id_counter{0};
engine->log_id = ++s_log_id_counter;
s_log->info("entropic_create() — v{} (log_id={})",
CONFIG_ENTROPIC_VERSION_STRING, engine->log_id);
*handle = engine;
return ENTROPIC_OK;
}Activity · 13 steps
Requirements
REQ-ABI-001 REQ-API-002 REQ-API-003
Flows
entropic_create_identity
ENTROPIC_EXPORT entropic_error_t entropic_create_identity(entropic_handle_t handle, const char *config_json)
Create a dynamic identity.
src/facade/entropic.cpp:4842
Source · 23 lines
entropic_error_t entropic_create_identity(
entropic_handle_t handle,
const char* config_json)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !config_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
auto j = nlohmann::json::parse(config_json);
entropic::IdentityConfig cfg;
cfg.name = j.value("name", "");
cfg.system_prompt = j.value("system_prompt", "");
if (j.contains("focus") && j["focus"].is_array()) {
cfg.focus = j["focus"].get<std::vector<std::string>>();
}
cfg.origin = entropic::IdentityOrigin::DYNAMIC;
return handle->identity_manager->create(cfg);
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INVALID_CONFIG;
}
}Activity · 4 steps
entropic_error_t entropic_create_identity(entropic_handle_t handle, const char *config_json)
Create a dynamic identity from JSON config.
src/facade/entropic.cpp:4842
Source · 23 lines
entropic_error_t entropic_create_identity(
entropic_handle_t handle,
const char* config_json)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !config_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
auto j = nlohmann::json::parse(config_json);
entropic::IdentityConfig cfg;
cfg.name = j.value("name", "");
cfg.system_prompt = j.value("system_prompt", "");
if (j.contains("focus") && j["focus"].is_array()) {
cfg.focus = j["focus"].get<std::vector<std::string>>();
}
cfg.origin = entropic::IdentityOrigin::DYNAMIC;
return handle->identity_manager->create(cfg);
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INVALID_CONFIG;
}
}Activity · 4 steps
Requirements
entropic_deserialize_mcp_keys
ENTROPIC_EXPORT entropic_error_t entropic_deserialize_mcp_keys(entropic_handle_t handle, const char *json)
Deserialize all identity key sets from JSON.
src/facade/entropic.cpp:4819
Source · 11 lines
entropic_error_t entropic_deserialize_mcp_keys(
entropic_handle_t handle,
const char* json)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
bool ok = handle->mcp_auth->deserialize_all(json);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_CONFIG;
}Activity · 5 steps
entropic_error_t entropic_deserialize_mcp_keys(entropic_handle_t handle, const char *json)
Deserialize all identity key sets from JSON.
src/facade/entropic.cpp:4819
Source · 11 lines
entropic_error_t entropic_deserialize_mcp_keys(
entropic_handle_t handle,
const char* json)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
bool ok = handle->mcp_auth->deserialize_all(json);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_CONFIG;
}Activity · 5 steps
Requirements
entropic_destroy
ENTROPIC_EXPORT void entropic_destroy(entropic_handle_t handle)
Destroy an engine instance and free all resources.
src/facade/entropic.cpp:2291
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE 25 more
main, main, open_engine, run_explorer, run_game, run_serve, setup_engine, setup_engine, ~BridgeHandle, ~ConfiguredCapiHandle, ~ConfiguredHandle, ~CreatedOnlyHandle, ~FacadeProject, ~Fixture, ~GateHandle, ~Handle, ~Handle, ~Handle, ~Handle, ~HandleGuard, ~HandleGuard, ~RawHandle, ~RootsHandle, ~UnconfiguredHandle, ~WsHandle
Calls destroy_orchestrator_interface, entropic_inference_log_silence, shutdown, stop, unregister_handle_log
Source · 44 lines
void entropic_destroy(entropic_handle_t handle) {
if (handle == nullptr) {
return;
}
s_log->info("entropic_destroy()");
// Stop external bridge FIRST — it holds a raw pointer to handle
// gh#204: the HTTP front end dispatches into the bridge — stop it first.
handle->http_listener.reset();
if (handle->external_bridge) {
handle->external_bridge->stop();
handle->external_bridge.reset();
}
entropic_inference_log_silence();
// gh#58 follow-up (v2.2.6): release per-handle InterfaceContext
// before the orchestrator unloads, since the context holds a raw
// orchestrator pointer used by the iface callbacks.
entropic::destroy_orchestrator_interface(handle->inference_iface_ctx);
handle->inference_iface_ctx = nullptr;
// gh#166 (v2.13.0): named workspaces own server instances with live
// child processes. Shut them down explicitly, before the engine that
// may still hold a resolver pointing at them goes away — teardown
// order is the recurring gh#58 failure shape, not left to chance.
{
std::lock_guard<std::mutex> guard(handle->workspace_mutex);
for (auto& [name, ws] : handle->workspaces) {
if (ws && ws->servers) { ws->servers->shutdown(); }
}
handle->workspaces.clear();
handle->session_workspace.clear();
}
// gh#59 (v2.3.1): release the per-handle session.log file sink so
// a subsequent handle that happens to reuse the same log_id can
// open the file fresh. Safe on never-registered ids.
entropic::log::unregister_handle_log(handle->log_id);
// Phase 1+ subsystem teardown will go here in reverse order.
// Phase 0: struct itself owns hook_registry by value.
delete handle;
}Activity · 18 steps
void entropic_destroy(entropic_handle_t handle)
Destroy an engine instance.
src/facade/entropic.cpp:2291
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE 25 more
main, main, open_engine, run_explorer, run_game, run_serve, setup_engine, setup_engine, ~BridgeHandle, ~ConfiguredCapiHandle, ~ConfiguredHandle, ~CreatedOnlyHandle, ~FacadeProject, ~Fixture, ~GateHandle, ~Handle, ~Handle, ~Handle, ~Handle, ~HandleGuard, ~HandleGuard, ~RawHandle, ~RootsHandle, ~UnconfiguredHandle, ~WsHandle
Calls destroy_orchestrator_interface, entropic_inference_log_silence, unregister_handle_log
Source · 44 lines
void entropic_destroy(entropic_handle_t handle) {
if (handle == nullptr) {
return;
}
s_log->info("entropic_destroy()");
// Stop external bridge FIRST — it holds a raw pointer to handle
// gh#204: the HTTP front end dispatches into the bridge — stop it first.
handle->http_listener.reset();
if (handle->external_bridge) {
handle->external_bridge->stop();
handle->external_bridge.reset();
}
entropic_inference_log_silence();
// gh#58 follow-up (v2.2.6): release per-handle InterfaceContext
// before the orchestrator unloads, since the context holds a raw
// orchestrator pointer used by the iface callbacks.
entropic::destroy_orchestrator_interface(handle->inference_iface_ctx);
handle->inference_iface_ctx = nullptr;
// gh#166 (v2.13.0): named workspaces own server instances with live
// child processes. Shut them down explicitly, before the engine that
// may still hold a resolver pointing at them goes away — teardown
// order is the recurring gh#58 failure shape, not left to chance.
{
std::lock_guard<std::mutex> guard(handle->workspace_mutex);
for (auto& [name, ws] : handle->workspaces) {
if (ws && ws->servers) { ws->servers->shutdown(); }
}
handle->workspaces.clear();
handle->session_workspace.clear();
}
// gh#59 (v2.3.1): release the per-handle session.log file sink so
// a subsequent handle that happens to reuse the same log_id can
// open the file fresh. Safe on never-registered ids.
entropic::log::unregister_handle_log(handle->log_id);
// Phase 1+ subsystem teardown will go here in reverse order.
// Phase 0: struct itself owns hook_registry by value.
delete handle;
}Activity · 18 steps
Requirements
REQ-ABI-001 REQ-API-002 REQ-API-003
Flows
entropic_destroy_identity
ENTROPIC_EXPORT entropic_error_t entropic_destroy_identity(entropic_handle_t handle, const char *name)
Destroy a dynamic identity.
src/facade/entropic.cpp:4908
Source · 10 lines
entropic_error_t entropic_destroy_identity(
entropic_handle_t handle,
const char* name)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
return handle->identity_manager->destroy(name);
}Activity · 4 steps
entropic_error_t entropic_destroy_identity(entropic_handle_t handle, const char *name)
Destroy a dynamic identity.
src/facade/entropic.cpp:4908
Source · 10 lines
entropic_error_t entropic_destroy_identity(
entropic_handle_t handle,
const char* name)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
return handle->identity_manager->destroy(name);
}Activity · 4 steps
Requirements
entropic_free
ENTROPIC_EXPORT void entropic_free(void *ptr)
Free a string allocated by the server.
src/facade/entropic.cpp:2390
Source · 3 lines
void entropic_free(void* ptr) {
free(ptr);
}Activity · 1 steps
ENTROPIC_EXPORT void entropic_free(void *ptr)
Free memory allocated by the engine or entropic_alloc().
src/facade/entropic.cpp:2390
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, derive_async_final_state 11 more
final_answer_from_context, handle_ask_plain, handle_status, last_prefill_tokens, published_prefill, resident_count, resident_tiers, run_blocking, run_blocking_messages, snapshot, take_owned
Calls none
Source · 3 lines
void entropic_free(void* ptr) {
free(ptr);
}Activity · 1 steps
void entropic_free(void *ptr)
Free memory allocated by the engine.
src/facade/entropic.cpp:2390
Source · 3 lines
void entropic_free(void* ptr) {
free(ptr);
}Activity · 1 steps
Requirements
entropic_free_logprob_result
ENTROPIC_EXPORT void entropic_free_logprob_result(entropic_logprob_result_t *result)
Free internal arrays of a logprob result.
src/facade/entropic.cpp:5115
Source · 10 lines
void entropic_free_logprob_result(entropic_logprob_result_t* result)
{
if (result == nullptr) {
return;
}
free(result->logprobs);
result->logprobs = nullptr;
free(result->tokens);
result->tokens = nullptr;
}Activity · 6 steps
void entropic_free_logprob_result(entropic_logprob_result_t *result)
Free internal arrays of a logprob result.
src/facade/entropic.cpp:5115
Source · 10 lines
void entropic_free_logprob_result(entropic_logprob_result_t* result)
{
if (result == nullptr) {
return;
}
free(result->logprobs);
result->logprobs = nullptr;
free(result->tokens);
result->tokens = nullptr;
}Activity · 6 steps
Requirements
entropic_get_diagnostic_prompt
ENTROPIC_EXPORT entropic_error_t entropic_get_diagnostic_prompt(entropic_handle_t handle, char **prompt_out)
Get the diagnostic prompt text for /diagnose command.
src/facade/entropic.cpp:5239
Source · 31 lines
entropic_error_t entropic_get_diagnostic_prompt(
entropic_handle_t handle,
char** prompt_out) {
if (handle == nullptr || prompt_out == nullptr) {
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
(void)handle;
static const char* prompt =
"[SYSTEM DIRECTIVE: SELF-DIAGNOSIS]\n\n"
"Analyze your recent actions and identify any issues. "
"Follow these steps:\n\n"
"1. Call entropic.diagnose to get a full engine state "
"snapshot.\n"
"2. Review the tool call history for:\n"
" - Repeated failures (same tool, same error)\n"
" - Duplicate tool calls (circuit breaker risk)\n"
" - Tool calls that returned errors\n"
" - Unexpected state (wrong phase, wrong tier)\n"
"3. Review your reasoning for:\n"
" - Actions that didn't achieve the stated goal\n"
" - Unnecessary tool calls\n"
" - Missing context that led to errors\n"
"4. Produce a structured assessment:\n"
" - FINDINGS: What went wrong (be specific)\n"
" - ROOT CAUSE: Why it went wrong\n"
" - RECOMMENDATION: What to do differently\n\n"
"Be honest and specific. The goal is accurate "
"self-assessment, not self-defense.\n";
*prompt_out = alloc_cstr(prompt);
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_get_diagnostic_prompt(entropic_handle_t handle, char **prompt_out)
Get diagnostic prompt text for /diagnose command (stub).
src/facade/entropic.cpp:5239
Source · 31 lines
entropic_error_t entropic_get_diagnostic_prompt(
entropic_handle_t handle,
char** prompt_out) {
if (handle == nullptr || prompt_out == nullptr) {
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
(void)handle;
static const char* prompt =
"[SYSTEM DIRECTIVE: SELF-DIAGNOSIS]\n\n"
"Analyze your recent actions and identify any issues. "
"Follow these steps:\n\n"
"1. Call entropic.diagnose to get a full engine state "
"snapshot.\n"
"2. Review the tool call history for:\n"
" - Repeated failures (same tool, same error)\n"
" - Duplicate tool calls (circuit breaker risk)\n"
" - Tool calls that returned errors\n"
" - Unexpected state (wrong phase, wrong tier)\n"
"3. Review your reasoning for:\n"
" - Actions that didn't achieve the stated goal\n"
" - Unnecessary tool calls\n"
" - Missing context that led to errors\n"
"4. Produce a structured assessment:\n"
" - FINDINGS: What went wrong (be specific)\n"
" - ROOT CAUSE: Why it went wrong\n"
" - RECOMMENDATION: What to do differently\n\n"
"Be honest and specific. The goal is accurate "
"self-assessment, not self-defense.\n";
*prompt_out = alloc_cstr(prompt);
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_get_identity_config
ENTROPIC_EXPORT char * entropic_get_identity_config(entropic_handle_t handle, const char *name)
Get identity configuration as JSON by name.
src/facade/entropic.cpp:4929
Source · 18 lines
char* entropic_get_identity_config(
entropic_handle_t handle,
const char* name)
{
if (!handle || !handle->identity_manager || !name) { return nullptr; }
try {
auto* cfg = handle->identity_manager->get(name);
if (!cfg) { throw std::runtime_error("identity not found"); }
nlohmann::json j;
j["name"] = cfg->name;
j["system_prompt"] = cfg->system_prompt;
j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
? "static" : "dynamic";
return alloc_cstr(j.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
char * entropic_get_identity_config(entropic_handle_t handle, const char *name)
Get identity config as JSON by name.
src/facade/entropic.cpp:4929
Source · 18 lines
char* entropic_get_identity_config(
entropic_handle_t handle,
const char* name)
{
if (!handle || !handle->identity_manager || !name) { return nullptr; }
try {
auto* cfg = handle->identity_manager->get(name);
if (!cfg) { throw std::runtime_error("identity not found"); }
nlohmann::json j;
j["name"] = cfg->name;
j["system_prompt"] = cfg->system_prompt;
j["origin"] = (cfg->origin == entropic::IdentityOrigin::STATIC)
? "static" : "dynamic";
return alloc_cstr(j.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_get_logprobs
ENTROPIC_EXPORT entropic_error_t entropic_get_logprobs(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, entropic_logprob_result_t *result)
Evaluate per-token log-probabilities for a token sequence.
src/facade/entropic.cpp:5034
Called by TEST_CASE
Calls check_orchestrator, claim, fill_logprob_result, require_ready_backend
Source · 29 lines
entropic_error_t entropic_get_logprobs(
entropic_handle_t handle,
const char* model_id,
const int32_t* tokens,
int n_tokens,
entropic_logprob_result_t* result)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the tier's model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !model_id || !tokens || !result || n_tokens < 2
|| (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!model_id || !tokens || !result || n_tokens < 2)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto* backend = require_ready_backend(handle, model_id);
fill_logprob_result(backend->evaluate_logprobs(tokens, n_tokens),
result);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("get_logprobs: {}", handle->last_error);
return ENTROPIC_ERROR_EVAL_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_get_logprobs(entropic_handle_t handle, const char *model_id, const int32_t *tokens, int n_tokens, entropic_logprob_result_t *result)
Evaluate per-token log-probabilities for a token sequence.
src/facade/entropic.cpp:5034
Called by TEST_CASE
Calls check_orchestrator, claim, fill_logprob_result, require_ready_backend
Source · 29 lines
entropic_error_t entropic_get_logprobs(
entropic_handle_t handle,
const char* model_id,
const int32_t* tokens,
int n_tokens,
entropic_logprob_result_t* result)
{
auto rc = check_orchestrator(handle);
// gh#157: may load the tier's model — claim the turn first.
entropic::HandleTurnGuard turn(handle);
if (rc != ENTROPIC_OK || !model_id || !tokens || !result || n_tokens < 2
|| (handle->engine != nullptr && !turn.claim())) {
return rc != ENTROPIC_OK ? rc
: (!model_id || !tokens || !result || n_tokens < 2)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto* backend = require_ready_backend(handle, model_id);
fill_logprob_result(backend->evaluate_logprobs(tokens, n_tokens),
result);
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("get_logprobs: {}", handle->last_error);
return ENTROPIC_ERROR_EVAL_FAILED;
}
}Activity · 5 steps
Requirements
entropic_grammar_deregister
ENTROPIC_EXPORT entropic_error_t entropic_grammar_deregister(entropic_handle_t handle, const char *key)
Remove a grammar from the registry.
src/facade/entropic.cpp:4346
Source · 19 lines
entropic_error_t entropic_grammar_deregister(
entropic_handle_t handle,
const char* key)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry().deregister(key);
s_log->info("grammar_deregister: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_GRAMMAR_NOT_FOUND;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_deregister: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_grammar_deregister(entropic_handle_t handle, const char *key)
Remove a grammar from the registry.
src/facade/entropic.cpp:4346
Source · 19 lines
entropic_error_t entropic_grammar_deregister(
entropic_handle_t handle,
const char* key)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry().deregister(key);
s_log->info("grammar_deregister: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_GRAMMAR_NOT_FOUND;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_deregister: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_grammar_get
ENTROPIC_EXPORT char * entropic_grammar_get(entropic_handle_t handle, const char *key)
Get grammar content by key.
src/facade/entropic.cpp:4379
Source · 17 lines
char* entropic_grammar_get(
entropic_handle_t handle,
const char* key)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !key) {
return nullptr;
}
try {
auto content = handle->orchestrator->grammar_registry().get(key);
return content.empty() ? nullptr : alloc_cstr(content.c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_get: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_grammar_get(entropic_handle_t handle, const char *key)
Get grammar GBNF content by key.
src/facade/entropic.cpp:4379
Source · 17 lines
char* entropic_grammar_get(
entropic_handle_t handle,
const char* key)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !key) {
return nullptr;
}
try {
auto content = handle->orchestrator->grammar_registry().get(key);
return content.empty() ? nullptr : alloc_cstr(content.c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_get: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_grammar_list
ENTROPIC_EXPORT char * entropic_grammar_list(entropic_handle_t handle)
List all registered grammars as JSON array.
src/facade/entropic.cpp:4435
Source · 21 lines
char* entropic_grammar_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto entries = handle->orchestrator->grammar_registry().list();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : entries) {
arr.push_back({{"key", e.key},
{"source", e.source},
{"validated", e.validated},
{"error", e.error}});
}
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_grammar_list(entropic_handle_t handle)
List all registered grammars as a JSON array.
src/facade/entropic.cpp:4435
Source · 21 lines
char* entropic_grammar_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto entries = handle->orchestrator->grammar_registry().list();
nlohmann::json arr = nlohmann::json::array();
for (const auto& e : entries) {
arr.push_back({{"key", e.key},
{"source", e.source},
{"validated", e.validated},
{"error", e.error}});
}
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_grammar_register
ENTROPIC_EXPORT entropic_error_t entropic_grammar_register(entropic_handle_t handle, const char *key, const char *gbnf_content)
Register a grammar by key from a GBNF content string.
src/facade/entropic.cpp:4276
Source · 21 lines
entropic_error_t entropic_grammar_register(
entropic_handle_t handle,
const char* key,
const char* gbnf_content)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key || !gbnf_content) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry()
.register_grammar(key, gbnf_content);
s_log->info("grammar_register: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ALREADY_EXISTS;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_register: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_grammar_register(entropic_handle_t handle, const char *key, const char *gbnf_content)
Register a grammar by key with GBNF content.
src/facade/entropic.cpp:4276
Source · 21 lines
entropic_error_t entropic_grammar_register(
entropic_handle_t handle,
const char* key,
const char* gbnf_content)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key || !gbnf_content) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry()
.register_grammar(key, gbnf_content);
s_log->info("grammar_register: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ALREADY_EXISTS;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_register: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_grammar_register_file
ENTROPIC_EXPORT entropic_error_t entropic_grammar_register_file(entropic_handle_t handle, const char *key, const char *path)
Register a grammar from a file path.
src/facade/entropic.cpp:4311
Source · 21 lines
entropic_error_t entropic_grammar_register_file(
entropic_handle_t handle,
const char* key,
const char* path)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key || !path) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry()
.register_from_file(key, path);
s_log->info("grammar_register_file: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_IO;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_register_file: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_grammar_register_file(entropic_handle_t handle, const char *key, const char *path)
Register a grammar from a GBNF file.
src/facade/entropic.cpp:4311
Source · 21 lines
entropic_error_t entropic_grammar_register_file(
entropic_handle_t handle,
const char* key,
const char* path)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !key || !path) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->grammar_registry()
.register_from_file(key, path);
s_log->info("grammar_register_file: key={} ok={}", key, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_IO;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("grammar_register_file: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_grammar_validate
ENTROPIC_EXPORT char * entropic_grammar_validate(const char *gbnf_content)
Validate a GBNF grammar string without registering.
src/facade/entropic.cpp:4411
Source · 9 lines
char* entropic_grammar_validate(const char* gbnf_content) {
if (!gbnf_content) { return alloc_cstr("null input"); }
try {
auto err = entropic::GrammarRegistry::validate(gbnf_content);
return err.empty() ? nullptr : alloc_cstr(err.c_str());
} catch (const std::exception& e) {
return alloc_cstr(e.what());
}
}Activity · 3 steps
char * entropic_grammar_validate(const char *gbnf_content)
Validate a GBNF grammar string without registering.
src/facade/entropic.cpp:4411
Source · 9 lines
char* entropic_grammar_validate(const char* gbnf_content) {
if (!gbnf_content) { return alloc_cstr("null input"); }
try {
auto err = entropic::GrammarRegistry::validate(gbnf_content);
return err.empty() ? nullptr : alloc_cstr(err.c_str());
} catch (const std::exception& e) {
return alloc_cstr(e.what());
}
}Activity · 3 steps
Requirements
entropic_grant_mcp_key
ENTROPIC_EXPORT entropic_error_t entropic_grant_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern, entropic_mcp_access_level_t level)
Grant an MCP tool key to an identity.
src/facade/entropic.cpp:4676
Source · 13 lines
entropic_error_t entropic_grant_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* pattern,
entropic_mcp_access_level_t level)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !identity_name || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->grant(identity_name, pattern, lvl);
}Activity · 5 steps
entropic_error_t entropic_grant_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern, entropic_mcp_access_level_t level)
Grant an MCP tool key to an identity.
src/facade/entropic.cpp:4676
Source · 13 lines
entropic_error_t entropic_grant_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* pattern,
entropic_mcp_access_level_t level)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !identity_name || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->grant(identity_name, pattern, lvl);
}Activity · 5 steps
Requirements
entropic_grant_mcp_key_from
ENTROPIC_EXPORT entropic_error_t entropic_grant_mcp_key_from(entropic_handle_t handle, const char *granter, const char *grantee, const char *pattern, entropic_mcp_access_level_t level)
Grant a key from one identity to another.
src/facade/entropic.cpp:4772
Source · 14 lines
entropic_error_t entropic_grant_mcp_key_from(
entropic_handle_t handle,
const char* granter,
const char* grantee,
const char* pattern,
entropic_mcp_access_level_t level)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !granter || !grantee || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->grant_from(granter, grantee, pattern, lvl);
}Activity · 5 steps
entropic_error_t entropic_grant_mcp_key_from(entropic_handle_t handle, const char *granter, const char *grantee, const char *pattern, entropic_mcp_access_level_t level)
Grant a key from one identity to another.
src/facade/entropic.cpp:4772
Source · 14 lines
entropic_error_t entropic_grant_mcp_key_from(
entropic_handle_t handle,
const char* granter,
const char* grantee,
const char* pattern,
entropic_mcp_access_level_t level)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !granter || !grantee || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
auto lvl = static_cast<entropic::MCPAccessLevel>(level);
return handle->mcp_auth->grant_from(granter, grantee, pattern, lvl);
}Activity · 5 steps
Requirements
entropic_identity_count
ENTROPIC_EXPORT entropic_error_t entropic_identity_count(entropic_handle_t handle, size_t *total, size_t *dynamic)
Get identity count.
src/facade/entropic.cpp:4978
Source · 13 lines
entropic_error_t entropic_identity_count(
entropic_handle_t handle,
size_t* total,
size_t* dynamic)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !total) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
*total = handle->identity_manager->count();
if (dynamic) { *dynamic = handle->identity_manager->count_dynamic(); }
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_identity_count(entropic_handle_t handle, size_t *total, size_t *dynamic)
Get identity count (total and dynamic).
src/facade/entropic.cpp:4978
Source · 13 lines
entropic_error_t entropic_identity_count(
entropic_handle_t handle,
size_t* total,
size_t* dynamic)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !total) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
*total = handle->identity_manager->count();
if (dynamic) { *dynamic = handle->identity_manager->count_dynamic(); }
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_interrupt
ENTROPIC_EXPORT entropic_error_t entropic_interrupt(entropic_handle_t handle)
Interrupt a running generation.
src/facade/entropic.cpp:3177
Source · 6 lines
entropic_error_t entropic_interrupt(entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->engine) { return ENTROPIC_ERROR_INVALID_STATE; }
handle->engine->interrupt();
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_interrupt(entropic_handle_t handle)
Interrupt a running generation (thread-safe).
src/facade/entropic.cpp:3177
Source · 6 lines
entropic_error_t entropic_interrupt(entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->engine) { return ENTROPIC_ERROR_INVALID_STATE; }
handle->engine->interrupt();
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_interrupt_session
ENTROPIC_EXPORT entropic_error_t entropic_interrupt_session(entropic_handle_t handle, const char *session_key)
Interrupt the run belonging to ONE session (gh#158, v2.13.0).
src/facade/entropic.cpp:3199
Source · 9 lines
entropic_error_t entropic_interrupt_session(
entropic_handle_t handle,
const char* session_key) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->engine) { return ENTROPIC_ERROR_INVALID_STATE; }
const bool found = handle->engine->interrupt_session(
session_key != nullptr ? session_key : "");
return found ? ENTROPIC_OK : ENTROPIC_ERROR_NOT_RUNNING;
}Activity · 6 steps
entropic_error_t entropic_interrupt_session(entropic_handle_t handle, const char *session_key)
Interrupt one session's run — see entropic.h (gh#158, v2.13.0).
src/facade/entropic.cpp:3199
Source · 9 lines
entropic_error_t entropic_interrupt_session(
entropic_handle_t handle,
const char* session_key) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->engine) { return ENTROPIC_ERROR_INVALID_STATE; }
const bool found = handle->engine->interrupt_session(
session_key != nullptr ? session_key : "");
return found ? ENTROPIC_OK : ENTROPIC_ERROR_NOT_RUNNING;
}Activity · 6 steps
Requirements
entropic_last_error
ENTROPIC_EXPORT const char * entropic_last_error(entropic_handle_t handle)
Get the last error message for a handle.
src/facade/entropic.cpp:157
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, bind_session_workspace, derive_async_final_state, explore_loop, handle_ask, handle_ask_plain, handle_release 11 more
main, mentions, play_ai_turn, render_turn, resolve_workspace, run_scenarios, run_serve, run_step, serve_until_stopped, setup_engine, setup_engine
Calls none
Source · 6 lines
extern "C" const char* entropic_last_error(entropic_handle_t handle) {
if (!handle) { return s_pre_create_error; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
s_last_error_cache = handle->last_error;
return s_last_error_cache.c_str();
}Activity · 5 steps
const char * entropic_last_error(entropic_handle_t handle)
Read the per-handle last_error under api_mutex.
src/facade/entropic.cpp:157
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, bind_session_workspace, derive_async_final_state, explore_loop, handle_ask, handle_ask_plain, handle_release 11 more
main, mentions, play_ai_turn, render_turn, resolve_workspace, run_scenarios, run_serve, run_step, serve_until_stopped, setup_engine, setup_engine
Calls none
Source · 6 lines
extern "C" const char* entropic_last_error(entropic_handle_t handle) {
if (!handle) { return s_pre_create_error; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
s_last_error_cache = handle->last_error;
return s_last_error_cache.c_str();
}Activity · 5 steps
Requirements
REQ-ABI-001 REQ-API-003 REQ-API-007
Flows
entropic_list_identities
ENTROPIC_EXPORT char * entropic_list_identities(entropic_handle_t handle)
List all identity names as JSON array.
src/facade/entropic.cpp:4958
Source · 11 lines
char* entropic_list_identities(entropic_handle_t handle)
{
if (!handle || !handle->identity_manager) { return nullptr; }
try {
auto names = handle->identity_manager->list();
nlohmann::json arr(names);
return alloc_cstr(arr.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
char * entropic_list_identities(entropic_handle_t handle)
List all identity names as JSON array.
src/facade/entropic.cpp:4958
Source · 11 lines
char* entropic_list_identities(entropic_handle_t handle)
{
if (!handle || !handle->identity_manager) { return nullptr; }
try {
auto names = handle->identity_manager->list();
nlohmann::json arr(names);
return alloc_cstr(arr.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_list_mcp_keys
ENTROPIC_EXPORT char * entropic_list_mcp_keys(entropic_handle_t handle, const char *identity_name)
List all MCP keys for an identity as JSON.
src/facade/entropic.cpp:4742
Source · 21 lines
char* entropic_list_mcp_keys(
entropic_handle_t handle,
const char* identity_name)
{
if (!handle || !handle->configured.load()
|| !handle->mcp_auth || !identity_name) {
return nullptr;
}
try {
auto keys = handle->mcp_auth->list_keys(identity_name);
nlohmann::json arr = nlohmann::json::array();
for (const auto& k : keys) {
arr.push_back({{"pattern", k.tool_pattern},
{"level", static_cast<int>(k.level)}});
}
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
return nullptr;
}
}Activity · 3 steps
char * entropic_list_mcp_keys(entropic_handle_t handle, const char *identity_name)
List MCP keys for an identity as JSON array.
src/facade/entropic.cpp:4742
Source · 21 lines
char* entropic_list_mcp_keys(
entropic_handle_t handle,
const char* identity_name)
{
if (!handle || !handle->configured.load()
|| !handle->mcp_auth || !identity_name) {
return nullptr;
}
try {
auto keys = handle->mcp_auth->list_keys(identity_name);
nlohmann::json arr = nlohmann::json::array();
for (const auto& k : keys) {
arr.push_back({{"pattern", k.tool_pattern},
{"level", static_cast<int>(k.level)}});
}
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_metrics_json
ENTROPIC_EXPORT entropic_error_t entropic_metrics_json(entropic_handle_t handle, char **out)
Get loop metrics from the most recent run as JSON.
src/facade/entropic.cpp:3998
Called by TEST_CASE, handle_status, last_prefill_tokens, published_prefill
Calls sp_get_metrics
Source · 7 lines
entropic_error_t entropic_metrics_json(
entropic_handle_t handle, char** out) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!out) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
*out = sp_get_metrics(handle);
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_metrics_json(entropic_handle_t handle, char **out)
Get loop metrics as JSON (flat + per_tier).
src/facade/entropic.cpp:3998
Called by SCENARIO, TEST_CASE, handle_status, last_prefill_tokens, published_prefill
Calls sp_get_metrics
Source · 7 lines
entropic_error_t entropic_metrics_json(
entropic_handle_t handle, char** out) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!out) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
*out = sp_get_metrics(handle);
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_model_has_vision
ENTROPIC_EXPORT int entropic_model_has_vision(entropic_handle_t handle, const char *model_id)
Check if a model has vision capability.
src/facade/entropic.cpp:5141
Source · 20 lines
int entropic_model_has_vision(
entropic_handle_t handle,
const char* model_id)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !model_id) {
return 0;
}
try {
// gh#157: answer from CONFIG, not from the backend. The backend's
// has_vision_ is set while the mmproj context is built during
// ACTIVATION, so an unloaded tier answered 0 — wrong, not unknown —
// and with models.defer_load unloaded is the normal state.
return handle->orchestrator->tier_declares_vision(model_id) ? 1 : 0;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("model_has_vision: {}", handle->last_error);
return 0;
}
}Activity · 3 steps
int entropic_model_has_vision(entropic_handle_t handle, const char *model_id)
Check if a model has vision (multimodal) capability.
src/facade/entropic.cpp:5141
Source · 20 lines
int entropic_model_has_vision(
entropic_handle_t handle,
const char* model_id)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !model_id) {
return 0;
}
try {
// gh#157: answer from CONFIG, not from the backend. The backend's
// has_vision_ is set while the mmproj context is built during
// ACTIVATION, so an unloaded tier answered 0 — wrong, not unknown —
// and with models.defer_load unloaded is the normal state.
return handle->orchestrator->tier_declares_vision(model_id) ? 1 : 0;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("model_has_vision: {}", handle->last_error);
return 0;
}
}Activity · 3 steps
Requirements
entropic_profile_deregister
ENTROPIC_EXPORT entropic_error_t entropic_profile_deregister(entropic_handle_t handle, const char *name)
Remove a GPU resource profile.
src/facade/entropic.cpp:4515
Source · 19 lines
entropic_error_t entropic_profile_deregister(
entropic_handle_t handle,
const char* name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->profile_registry().deregister(name);
s_log->info("profile_deregister: name={} ok={}", name, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_PROFILE_NOT_FOUND;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_deregister: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
entropic_error_t entropic_profile_deregister(entropic_handle_t handle, const char *name)
Remove a GPU resource profile by name.
src/facade/entropic.cpp:4515
Source · 19 lines
entropic_error_t entropic_profile_deregister(
entropic_handle_t handle,
const char* name)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !name) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
bool ok = handle->orchestrator->profile_registry().deregister(name);
s_log->info("profile_deregister: name={} ok={}", name, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_PROFILE_NOT_FOUND;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_deregister: {}", handle->last_error);
return ENTROPIC_ERROR_INTERNAL;
}
}Activity · 4 steps
Requirements
entropic_profile_get
ENTROPIC_EXPORT char * entropic_profile_get(entropic_handle_t handle, const char *name)
Get a profile by name as JSON.
src/facade/entropic.cpp:4550
Source · 23 lines
char* entropic_profile_get(
entropic_handle_t handle,
const char* name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !name) {
return nullptr;
}
try {
auto p = handle->orchestrator->profile_registry().get(name);
nlohmann::json j;
j["name"] = p.name;
j["n_batch"] = p.n_batch;
j["n_threads"] = p.n_threads;
j["n_threads_batch"] = p.n_threads_batch;
j["description"] = p.description;
return alloc_cstr(j.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_get: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_profile_get(entropic_handle_t handle, const char *name)
Get a GPU resource profile by name as JSON.
src/facade/entropic.cpp:4550
Source · 23 lines
char* entropic_profile_get(
entropic_handle_t handle,
const char* name)
{
if (!handle || !handle->configured.load()
|| !handle->orchestrator || !name) {
return nullptr;
}
try {
auto p = handle->orchestrator->profile_registry().get(name);
nlohmann::json j;
j["name"] = p.name;
j["n_batch"] = p.n_batch;
j["n_threads"] = p.n_threads;
j["n_threads_batch"] = p.n_threads_batch;
j["description"] = p.description;
return alloc_cstr(j.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_get: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_profile_list
ENTROPIC_EXPORT char * entropic_profile_list(entropic_handle_t handle)
List all registered profiles as JSON array.
src/facade/entropic.cpp:4587
Source · 15 lines
char* entropic_profile_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto names = handle->orchestrator->profile_registry().list();
nlohmann::json arr = nlohmann::json(names);
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
char * entropic_profile_list(entropic_handle_t handle)
List all registered profile names as a JSON array.
src/facade/entropic.cpp:4587
Source · 15 lines
char* entropic_profile_list(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return nullptr;
}
try {
auto names = handle->orchestrator->profile_registry().list();
nlohmann::json arr = nlohmann::json(names);
return alloc_cstr(arr.dump().c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_list: {}", handle->last_error);
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_profile_register
ENTROPIC_EXPORT entropic_error_t entropic_profile_register(entropic_handle_t handle, const char *profile_json)
Register a custom GPU resource profile.
src/facade/entropic.cpp:4473
Source · 28 lines
entropic_error_t entropic_profile_register(
entropic_handle_t handle,
const char* profile_json)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !profile_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto j = nlohmann::json::parse(profile_json);
entropic::GPUResourceProfile p;
p.name = j.value("name", "");
if (p.name.empty()) { throw std::invalid_argument("missing 'name'"); }
p.n_batch = j.value("n_batch", 512);
p.n_threads = j.value("n_threads", 0);
p.n_threads_batch = j.value("n_threads_batch", 0);
p.description = j.value("description", "");
bool ok = handle->orchestrator->profile_registry()
.register_profile(p);
s_log->info("profile_register: name={} ok={}", p.name, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ALREADY_EXISTS;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_register: {}", handle->last_error);
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
}Activity · 4 steps
entropic_error_t entropic_profile_register(entropic_handle_t handle, const char *profile_json)
Register a custom GPU resource profile from JSON.
src/facade/entropic.cpp:4473
Source · 28 lines
entropic_error_t entropic_profile_register(
entropic_handle_t handle,
const char* profile_json)
{
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !profile_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
auto j = nlohmann::json::parse(profile_json);
entropic::GPUResourceProfile p;
p.name = j.value("name", "");
if (p.name.empty()) { throw std::invalid_argument("missing 'name'"); }
p.n_batch = j.value("n_batch", 512);
p.n_threads = j.value("n_threads", 0);
p.n_threads_batch = j.value("n_threads_batch", 0);
p.description = j.value("description", "");
bool ok = handle->orchestrator->profile_registry()
.register_profile(p);
s_log->info("profile_register: name={} ok={}", p.name, ok);
return ok ? ENTROPIC_OK : ENTROPIC_ERROR_ALREADY_EXISTS;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("profile_register: {}", handle->last_error);
return ENTROPIC_ERROR_INVALID_ARGUMENT;
}
}Activity · 4 steps
Requirements
entropic_queue_user_message
ENTROPIC_EXPORT entropic_error_t entropic_queue_user_message(entropic_handle_t handle, const char *message)
Queue a user message to be injected at the next top-level turn boundary.
src/facade/entropic.cpp:3228
Source · 14 lines
entropic_error_t entropic_queue_user_message(
entropic_handle_t handle, const char* message) {
entropic_error_t rc = ENTROPIC_OK;
if (!handle) {
rc = ENTROPIC_ERROR_INVALID_HANDLE;
} else if (!message) {
rc = ENTROPIC_ERROR_INVALID_ARGUMENT;
} else if (!handle->engine || !handle->engine->is_running()) {
rc = ENTROPIC_ERROR_INVALID_STATE;
} else if (!handle->engine->queue_user_message(message)) {
rc = ENTROPIC_ERROR_QUEUE_FULL;
}
return rc;
}Activity · 13 steps
entropic_error_t entropic_queue_user_message(entropic_handle_t handle, const char *message)
Enqueue a follow-up user message while a run is in flight.
src/facade/entropic.cpp:3228
Source · 14 lines
entropic_error_t entropic_queue_user_message(
entropic_handle_t handle, const char* message) {
entropic_error_t rc = ENTROPIC_OK;
if (!handle) {
rc = ENTROPIC_ERROR_INVALID_HANDLE;
} else if (!message) {
rc = ENTROPIC_ERROR_INVALID_ARGUMENT;
} else if (!handle->engine || !handle->engine->is_running()) {
rc = ENTROPIC_ERROR_INVALID_STATE;
} else if (!handle->engine->queue_user_message(message)) {
rc = ENTROPIC_ERROR_QUEUE_FULL;
}
return rc;
}Activity · 13 steps
Requirements
entropic_release_model
ENTROPIC_EXPORT entropic_error_t entropic_release_model(entropic_handle_t handle, const char *tier_name)
Release a resident model, keeping everything else on the handle.
src/facade/entropic.cpp:5377
Called by SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, handle_release, serve_until_stopped
Calls c_api_try, check_orchestrator, claim_exclusive, release_models
Source · 18 lines
entropic_error_t entropic_release_model(
entropic_handle_t handle,
const char* tier_name) {
auto rc = check_orchestrator(handle);
entropic::HandleTurnGuard turn(handle);
// gh#217 (v2.14.6): EXCLUSIVE. claim() covered only the default
// session, so a decode in any other session kept running while this
// unloaded its model — a CUDA error that killed `entropic serve`.
if (rc != ENTROPIC_OK
|| (handle->engine != nullptr && !turn.claim_exclusive())) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle, [&]() {
return handle->orchestrator->release_models(
tier_name != nullptr ? tier_name : "");
});
}Activity · 6 steps
entropic_error_t entropic_release_model(entropic_handle_t handle, const char *tier_name)
Release a resident model, keeping conversations and registrations.
src/facade/entropic.cpp:5377
Called by SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, handle_release, serve_until_stopped
Source · 18 lines
entropic_error_t entropic_release_model(
entropic_handle_t handle,
const char* tier_name) {
auto rc = check_orchestrator(handle);
entropic::HandleTurnGuard turn(handle);
// gh#217 (v2.14.6): EXCLUSIVE. claim() covered only the default
// session, so a decode in any other session kept running while this
// unloaded its model — a CUDA error that killed `entropic serve`.
if (rc != ENTROPIC_OK
|| (handle->engine != nullptr && !turn.claim_exclusive())) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle, [&]() {
return handle->orchestrator->release_models(
tier_name != nullptr ? tier_name : "");
});
}Activity · 6 steps
Requirements
entropic_residency_snapshot
ENTROPIC_EXPORT entropic_error_t entropic_residency_snapshot(entropic_handle_t handle, char **out_json)
Snapshot of the engine's current VRAM residency set.
src/facade/entropic.cpp:5412
Called by TEST_CASE, TEST_CASE, resident_count, resident_tiers
Calls alloc_cstr, residency_snapshot_json
Source · 18 lines
entropic_error_t entropic_residency_snapshot(
entropic_handle_t handle,
char** out_json) {
entropic_error_t rc = ENTROPIC_OK;
if (handle == nullptr || out_json == nullptr) {
rc = ENTROPIC_ERROR_INVALID_HANDLE;
} else if (!handle->orchestrator) {
rc = ENTROPIC_ERROR_INVALID_STATE;
} else {
std::string snapshot =
handle->orchestrator->residency_snapshot_json();
*out_json = alloc_cstr(snapshot);
if (*out_json == nullptr) {
rc = ENTROPIC_ERROR_OUT_OF_MEMORY;
}
}
return rc;
}Activity · 12 steps
entropic_error_t entropic_residency_snapshot(entropic_handle_t handle, char **out_json)
Return the engine's current residency-set snapshot as JSON.
src/facade/entropic.cpp:5412
Source · 18 lines
entropic_error_t entropic_residency_snapshot(
entropic_handle_t handle,
char** out_json) {
entropic_error_t rc = ENTROPIC_OK;
if (handle == nullptr || out_json == nullptr) {
rc = ENTROPIC_ERROR_INVALID_HANDLE;
} else if (!handle->orchestrator) {
rc = ENTROPIC_ERROR_INVALID_STATE;
} else {
std::string snapshot =
handle->orchestrator->residency_snapshot_json();
*out_json = alloc_cstr(snapshot);
if (*out_json == nullptr) {
rc = ENTROPIC_ERROR_OUT_OF_MEMORY;
}
}
return rc;
}Activity · 12 steps
Requirements
entropic_revoke_mcp_key
ENTROPIC_EXPORT entropic_error_t entropic_revoke_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern)
Revoke an MCP tool key from an identity.
src/facade/entropic.cpp:4698
Source · 11 lines
entropic_error_t entropic_revoke_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* pattern)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !identity_name || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
return handle->mcp_auth->revoke(identity_name, pattern);
}Activity · 4 steps
entropic_error_t entropic_revoke_mcp_key(entropic_handle_t handle, const char *identity_name, const char *pattern)
Revoke an MCP tool key from an identity.
src/facade/entropic.cpp:4698
Source · 11 lines
entropic_error_t entropic_revoke_mcp_key(
entropic_handle_t handle,
const char* identity_name,
const char* pattern)
{
auto rc = check_mcp_auth(handle);
if (rc != ENTROPIC_OK || !identity_name || !pattern) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
return handle->mcp_auth->revoke(identity_name, pattern);
}Activity · 4 steps
Requirements
entropic_run
ENTROPIC_EXPORT entropic_error_t entropic_run(entropic_handle_t handle, const char *input, char **result_json)
Synchronous agentic loop.
src/facade/entropic.cpp:2457
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, run_blocking, run_transcript
Calls alloc_cstr, check_orchestrator, claim, get_messages, serialize_messages, turn_outcome
Source · 47 lines
entropic_error_t entropic_run(
entropic_handle_t handle,
const char* input,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
auto result = handle->engine->run_turn(input);
*result_json = alloc_cstr(
facade_json::serialize_messages(result));
// Synthetic completion sentinel — lets observers detect the
// end of a non-streaming run. Contract: (token="", len=0).
// (P0-1, 2.0.6-rc16)
if (handle->stream_observer != nullptr) {
handle->stream_observer(
"", 0, handle->stream_observer_data);
}
return turn_outcome(handle); // gh#209/#212
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run: {}", handle->last_error);
// P3-19 follow-up (2.0.6-rc16.2): surface partial context on
// crash so callers can recover tool_results and any partial
// assistant content accumulated before the failure.
try {
*result_json = alloc_cstr(
facade_json::serialize_messages(
handle->engine->get_messages()));
} catch (...) {
*result_json = nullptr;
}
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_run(entropic_handle_t handle, const char *input, char **result_json)
Single-turn blocking agentic run.
src/facade/entropic.cpp:2457
Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, run_blocking, run_transcript
Calls alloc_cstr, check_orchestrator, claim, serialize_messages, turn_outcome
Source · 47 lines
entropic_error_t entropic_run(
entropic_handle_t handle,
const char* input,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
auto result = handle->engine->run_turn(input);
*result_json = alloc_cstr(
facade_json::serialize_messages(result));
// Synthetic completion sentinel — lets observers detect the
// end of a non-streaming run. Contract: (token="", len=0).
// (P0-1, 2.0.6-rc16)
if (handle->stream_observer != nullptr) {
handle->stream_observer(
"", 0, handle->stream_observer_data);
}
return turn_outcome(handle); // gh#209/#212
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run: {}", handle->last_error);
// P3-19 follow-up (2.0.6-rc16.2): surface partial context on
// crash so callers can recover tool_results and any partial
// assistant content accumulated before the failure.
try {
*result_json = alloc_cstr(
facade_json::serialize_messages(
handle->engine->get_messages()));
} catch (...) {
*result_json = nullptr;
}
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
Requirements
REQ-ABI-002 REQ-API-002 REQ-API-005 REQ-API-008 REQ-API-009 REQ-API-010
entropic_run_as
ENTROPIC_EXPORT entropic_error_t entropic_run_as(entropic_handle_t handle, const char *tier_or_identity, const char *input, char **result_json)
Single-turn agentic run under a named tier (gh#99).
src/facade/entropic.cpp:2559
Source · 29 lines
entropic_error_t entropic_run_as(
entropic_handle_t handle,
const char* tier_or_identity,
const char* input,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!tier_or_identity || !input || !result_json)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
if (!handle->engine->has_tier(tier_or_identity)) {
handle->last_error =
std::string("unknown tier: ") + tier_or_identity;
s_log->error("run_as: {}", handle->last_error);
return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
return run_as_inner(handle, tier_or_identity, input, result_json);
}Activity · 9 steps
entropic_error_t entropic_run_as(entropic_handle_t handle, const char *tier_or_identity, const char *input, char **result_json)
Single-turn blocking run under a named tier (gh#99).
src/facade/entropic.cpp:2559
Source · 29 lines
entropic_error_t entropic_run_as(
entropic_handle_t handle,
const char* tier_or_identity,
const char* input,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!tier_or_identity || !input || !result_json)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
if (!handle->engine->has_tier(tier_or_identity)) {
handle->last_error =
std::string("unknown tier: ") + tier_or_identity;
s_log->error("run_as: {}", handle->last_error);
return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
return run_as_inner(handle, tier_or_identity, input, result_json);
}Activity · 9 steps
Requirements
entropic_run_batch
ENTROPIC_EXPORT entropic_error_t entropic_run_batch(entropic_handle_t handle, const char **tiers, const char **prompts, size_t n, char **result_json)
Same-prefix batch run on a shared resident model (gh#98).
src/facade/entropic.cpp:2671
Called by none
Calls alloc_cstr, build_batch_messages, check_orchestrator, claim, generate_batch, run_cancel_flag, serialize_batch_results
Source · 46 lines
entropic_error_t entropic_run_batch(
entropic_handle_t handle,
const char** tiers,
const char** prompts,
size_t n,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !prompts || !result_json || !handle->engine
|| n == 0 || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!prompts || !result_json || n == 0)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
std::vector<std::string> tiers_vec;
auto msgs = build_batch_messages(handle, tiers, prompts, n, tiers_vec);
std::vector<entropic::GenerationParams> params(n);
// gh#158 (v2.13.0): this was a LOCAL `std::atomic<bool> cancel{false}`
// that nothing in the tree could ever set, so a batch was
// uninterruptible — `entropic_interrupt()` returned OK and the batch
// ran to completion. The run's own cancel token is the flag the
// handle-wide interrupt and `entropic_interrupt_session` both set,
// and `run_batch_gen_loop` already polls its argument per step.
std::atomic<bool>& cancel = handle->engine->run_cancel_flag();
auto results = handle->orchestrator->generate_batch(
msgs, params, tiers_vec, cancel);
*result_json = alloc_cstr(serialize_batch_results(results));
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_batch: {}", handle->last_error);
// Define *result_json on the error path (C-ABI: output params must be
// defined). No partial batch recovery — an empty JSON array.
*result_json = alloc_cstr("[]");
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_run_batch(entropic_handle_t handle, const char **tiers, const char **prompts, size_t n, char **result_json)
Same-prefix batch run on a shared resident model (gh#98).
src/facade/entropic.cpp:2671
Called by none
Calls alloc_cstr, build_batch_messages, check_orchestrator, claim, serialize_batch_results
Source · 46 lines
entropic_error_t entropic_run_batch(
entropic_handle_t handle,
const char** tiers,
const char** prompts,
size_t n,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !prompts || !result_json || !handle->engine
|| n == 0 || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!prompts || !result_json || n == 0)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
std::vector<std::string> tiers_vec;
auto msgs = build_batch_messages(handle, tiers, prompts, n, tiers_vec);
std::vector<entropic::GenerationParams> params(n);
// gh#158 (v2.13.0): this was a LOCAL `std::atomic<bool> cancel{false}`
// that nothing in the tree could ever set, so a batch was
// uninterruptible — `entropic_interrupt()` returned OK and the batch
// ran to completion. The run's own cancel token is the flag the
// handle-wide interrupt and `entropic_interrupt_session` both set,
// and `run_batch_gen_loop` already polls its argument per step.
std::atomic<bool>& cancel = handle->engine->run_cancel_flag();
auto results = handle->orchestrator->generate_batch(
msgs, params, tiers_vec, cancel);
*result_json = alloc_cstr(serialize_batch_results(results));
return ENTROPIC_OK;
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_batch: {}", handle->last_error);
// Define *result_json on the error path (C-ABI: output params must be
// defined). No partial batch recovery — an empty JSON array.
*result_json = alloc_cstr("[]");
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
Requirements
REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-API-009 REQ-INFER-018
entropic_run_messages
ENTROPIC_EXPORT entropic_error_t entropic_run_messages(entropic_handle_t handle, const char *messages_json, char **result_json)
Multimodal-aware agentic run with messages-array input (gh#37).
src/facade/entropic.cpp:2864
Called by SCENARIO, TEST_CASE, run_blocking_messages
Calls check_orchestrator, claim, run_messages_inner
Source · 27 lines
entropic_error_t entropic_run_messages(
entropic_handle_t handle,
const char* messages_json,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !messages_json || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!messages_json || !result_json || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
return run_messages_inner(handle, messages_json, result_json);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_messages: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_run_messages(entropic_handle_t handle, const char *messages_json, char **result_json)
Blocking multimodal agentic run (gh#37, v2.1.8).
src/facade/entropic.cpp:2864
Called by SCENARIO, TEST_CASE, run_blocking_messages
Calls check_orchestrator, claim, run_messages_inner
Source · 27 lines
entropic_error_t entropic_run_messages(
entropic_handle_t handle,
const char* messages_json,
char** result_json) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !messages_json || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!messages_json || !result_json || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
return run_messages_inner(handle, messages_json, result_json);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_messages: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
Requirements
REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-API-009 REQ-INFER-025
entropic_run_messages_streaming
ENTROPIC_EXPORT entropic_error_t entropic_run_messages_streaming(entropic_handle_t handle, const char *messages_json, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming variant of entropic_run_messages (gh#37).
src/facade/entropic.cpp:2940
Called by SCENARIO, TEST_CASE, stream_completion
Calls check_orchestrator, claim, on_token, run_messages_stream_inner
Source · 30 lines
entropic_error_t entropic_run_messages_streaming(
entropic_handle_t handle,
const char* messages_json,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !messages_json || !on_token
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!messages_json || !on_token || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
return run_messages_stream_inner(
handle, messages_json, on_token, user_data, cancel_flag);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_messages_streaming: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_run_messages_streaming(entropic_handle_t handle, const char *messages_json, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming multimodal agentic run (gh#37, v2.1.8).
src/facade/entropic.cpp:2940
Called by SCENARIO, TEST_CASE, stream_completion
Calls check_orchestrator, claim, on_token, run_messages_stream_inner
Source · 30 lines
entropic_error_t entropic_run_messages_streaming(
entropic_handle_t handle,
const char* messages_json,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !messages_json || !on_token
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!messages_json || !on_token || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
try {
return run_messages_stream_inner(
handle, messages_json, on_token, user_data, cancel_flag);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_messages_streaming: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
Requirements
entropic_run_session
ENTROPIC_EXPORT entropic_error_t entropic_run_session(entropic_handle_t handle, const char *session_key, const char *input, char **result_json)
Run a turn on a named session (gh#144).
src/facade/entropic.cpp:3387
Called by SCENARIO, SCENARIO, run_plain_turn, run_session_transcript
Calls alloc_cstr, check_orchestrator, claim, serialize_messages, set_active_session, turn_outcome
Source · 30 lines
entropic_error_t entropic_run_session(
entropic_handle_t handle,
const char* session_key,
const char* input,
char** result_json) {
entropic::HandleTurnGuard turn(handle, session_key);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
handle->engine->set_active_session(session_key ? session_key : "");
try {
auto result = handle->engine->run_turn(input);
*result_json = alloc_cstr(
facade_json::serialize_messages(result));
if (handle->stream_observer != nullptr) {
handle->stream_observer("", 0, handle->stream_observer_data);
}
return turn_outcome(handle); // gh#209/#212
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_session: {}", handle->last_error);
*result_json = nullptr;
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 6 steps
entropic_error_t entropic_run_session(entropic_handle_t handle, const char *session_key, const char *input, char **result_json)
Run a turn on a named session (gh#144, v2.12.0).
src/facade/entropic.cpp:3387
Called by SCENARIO, SCENARIO, run_plain_turn, run_session_transcript
Calls alloc_cstr, check_orchestrator, claim, serialize_messages, turn_outcome
Source · 30 lines
entropic_error_t entropic_run_session(
entropic_handle_t handle,
const char* session_key,
const char* input,
char** result_json) {
entropic::HandleTurnGuard turn(handle, session_key);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
handle->engine->set_active_session(session_key ? session_key : "");
try {
auto result = handle->engine->run_turn(input);
*result_json = alloc_cstr(
facade_json::serialize_messages(result));
if (handle->stream_observer != nullptr) {
handle->stream_observer("", 0, handle->stream_observer_data);
}
return turn_outcome(handle); // gh#209/#212
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_session: {}", handle->last_error);
*result_json = nullptr;
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 6 steps
Requirements
entropic_run_session_as
ENTROPIC_EXPORT entropic_error_t entropic_run_session_as(entropic_handle_t handle, const char *session_key, const char *tier_or_identity, const char *input, char **result_json)
Run a turn on a named session under a named tier (gh#144).
src/facade/entropic.cpp:3431
Called by run_plain_turn
Calls check_orchestrator, claim, has_tier, run_as_inner, set_active_session
Source · 24 lines
entropic_error_t entropic_run_session_as(
entropic_handle_t handle,
const char* session_key,
const char* tier_or_identity,
const char* input,
char** result_json) {
entropic::HandleTurnGuard turn(handle, session_key);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!tier_or_identity || !input || !result_json)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
if (!handle->engine->has_tier(tier_or_identity)) {
handle->last_error =
std::string("unknown tier: ") + tier_or_identity;
return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
handle->engine->set_active_session(session_key ? session_key : "");
return run_as_inner(handle, tier_or_identity, input, result_json);
}Activity · 9 steps
entropic_error_t entropic_run_session_as(entropic_handle_t handle, const char *session_key, const char *tier_or_identity, const char *input, char **result_json)
Run a turn on a named session under a named tier (gh#144).
src/facade/entropic.cpp:3431
Source · 24 lines
entropic_error_t entropic_run_session_as(
entropic_handle_t handle,
const char* session_key,
const char* tier_or_identity,
const char* input,
char** result_json) {
entropic::HandleTurnGuard turn(handle, session_key);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json
|| !handle->engine || !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!tier_or_identity || !input || !result_json)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: !handle->engine ? ENTROPIC_ERROR_INVALID_STATE
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
if (!handle->engine->has_tier(tier_or_identity)) {
handle->last_error =
std::string("unknown tier: ") + tier_or_identity;
return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;
}
handle->engine->set_active_session(session_key ? session_key : "");
return run_as_inner(handle, tier_or_identity, input, result_json);
}Activity · 9 steps
Requirements
entropic_run_session_streaming
ENTROPIC_EXPORT entropic_error_t entropic_run_session_streaming(entropic_handle_t handle, const char *session_key, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming turn on a named session (gh#144).
src/facade/entropic.cpp:3551
Source · 10 lines
entropic_error_t entropic_run_session_streaming(
entropic_handle_t handle,
const char* session_key,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
return run_session_streaming_impl(handle, session_key, nullptr, input,
on_token, user_data, cancel_flag);
}Activity · 1 steps
entropic_error_t entropic_run_session_streaming(entropic_handle_t handle, const char *session_key, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming turn on a named session (gh#144, v2.12.0).
src/facade/entropic.cpp:3551
Source · 10 lines
entropic_error_t entropic_run_session_streaming(
entropic_handle_t handle,
const char* session_key,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
return run_session_streaming_impl(handle, session_key, nullptr, input,
on_token, user_data, cancel_flag);
}Activity · 1 steps
Requirements
entropic_run_session_streaming_as
ENTROPIC_EXPORT entropic_error_t entropic_run_session_streaming_as(entropic_handle_t handle, const char *session_key, const char *tier_or_identity, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming turn on a named session, under a named tier (gh#205).
src/facade/entropic.cpp:3576
Source · 12 lines
entropic_error_t entropic_run_session_streaming_as(
entropic_handle_t handle,
const char* session_key,
const char* tier_or_identity,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
if (tier_or_identity == nullptr) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
return run_session_streaming_impl(handle, session_key, tier_or_identity,
input, on_token, user_data, cancel_flag);
}Activity · 3 steps
entropic_error_t entropic_run_session_streaming_as(entropic_handle_t handle, const char *session_key, const char *tier_or_identity, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming turn on a named session under a named tier (gh#205).
src/facade/entropic.cpp:3576
Source · 12 lines
entropic_error_t entropic_run_session_streaming_as(
entropic_handle_t handle,
const char* session_key,
const char* tier_or_identity,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
if (tier_or_identity == nullptr) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
return run_session_streaming_impl(handle, session_key, tier_or_identity,
input, on_token, user_data, cancel_flag);
}Activity · 3 steps
Requirements
entropic_run_streaming
ENTROPIC_EXPORT entropic_error_t entropic_run_streaming(entropic_handle_t handle, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming agentic loop with token callback.
src/facade/entropic.cpp:2737
Called by TEST_CASE, explore_loop, play_ai_turn, run_step
Calls check_orchestrator, claim, on_token, run_streaming, turn_outcome
Source · 39 lines
entropic_error_t entropic_run_streaming(
entropic_handle_t handle,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !on_token || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !on_token || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
// Observer multiplexing is handled inside ResponseGenerator — the
// facade passes on_token through untouched. (P0-1, 2.0.6-rc16)
try {
int code = handle->engine->run_streaming(
input, on_token, user_data, cancel_flag);
if (handle->stream_observer != nullptr) {
handle->stream_observer(
"", 0, handle->stream_observer_data);
}
return code == 1 ? ENTROPIC_ERROR_CANCELLED : turn_outcome(handle);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_streaming: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
entropic_error_t entropic_run_streaming(entropic_handle_t handle, const char *input, void(*on_token)(const char *token, size_t len, void *user_data), void *user_data, int *cancel_flag)
Streaming generation — delegates entirely to engine.
src/facade/entropic.cpp:2737
Called by TEST_CASE, explore_loop, play_ai_turn, run_step
Calls check_orchestrator, claim, on_token, turn_outcome
Source · 39 lines
entropic_error_t entropic_run_streaming(
entropic_handle_t handle,
const char* input,
void (*on_token)(const char* token, size_t len, void* user_data),
void* user_data,
int* cancel_flag) {
// gh#109: NO api_mutex — a long turn must not block entropic_interrupt()
// called from another thread. gh#144 (v2.12.0): the claim is a single
// compare-exchange, so that property holds by construction. The guard is
// declared BEFORE validation but claim() is evaluated LAST in the chain
// below, so a call rejected for a bad argument never momentarily claims
// the engine and bounces a legitimate concurrent caller.
entropic::HandleTurnGuard turn(handle);
auto rc = check_orchestrator(handle);
if (rc != ENTROPIC_OK || !input || !on_token || !handle->engine
|| !turn.claim()) {
return rc != ENTROPIC_OK ? rc
: (!input || !on_token || !handle->engine)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
// Observer multiplexing is handled inside ResponseGenerator — the
// facade passes on_token through untouched. (P0-1, 2.0.6-rc16)
try {
int code = handle->engine->run_streaming(
input, on_token, user_data, cancel_flag);
if (handle->stream_observer != nullptr) {
handle->stream_observer(
"", 0, handle->stream_observer_data);
}
return code == 1 ? ENTROPIC_ERROR_CANCELLED : turn_outcome(handle);
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("run_streaming: {}", handle->last_error);
return ENTROPIC_ERROR_GENERATE_FAILED;
}
}Activity · 5 steps
Requirements
entropic_seconds_since_last_activity
ENTROPIC_EXPORT int64_t entropic_seconds_since_last_activity(entropic_handle_t handle)
Seconds since the engine last serviced a run (gh#35, v2.3.0).
src/facade/entropic.cpp:2366
Source · 4 lines
int64_t entropic_seconds_since_last_activity(entropic_handle_t handle) {
if (!handle || !handle->engine) { return 0; }
return handle->engine->seconds_since_last_activity();
}Activity · 3 steps
int64_t entropic_seconds_since_last_activity(entropic_handle_t handle)
gh#35: idle-time accessor for host-side idle-exit policies.
src/facade/entropic.cpp:2366
Source · 4 lines
int64_t entropic_seconds_since_last_activity(entropic_handle_t handle) {
if (!handle || !handle->engine) { return 0; }
return handle->engine->seconds_since_last_activity();
}Activity · 3 steps
Requirements
entropic_serialize_mcp_keys
ENTROPIC_EXPORT char * entropic_serialize_mcp_keys(entropic_handle_t handle)
Serialize all identity key sets to JSON.
src/facade/entropic.cpp:4797
Source · 13 lines
char* entropic_serialize_mcp_keys(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->mcp_auth) {
return nullptr;
}
try {
auto json = handle->mcp_auth->serialize_all();
return alloc_cstr(json.c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
return nullptr;
}
}Activity · 3 steps
char * entropic_serialize_mcp_keys(entropic_handle_t handle)
Serialize all identity key sets to JSON.
src/facade/entropic.cpp:4797
Source · 13 lines
char* entropic_serialize_mcp_keys(entropic_handle_t handle)
{
if (!handle || !handle->configured.load() || !handle->mcp_auth) {
return nullptr;
}
try {
auto json = handle->mcp_auth->serialize_all();
return alloc_cstr(json.c_str());
} catch (const std::exception& e) {
handle->last_error = e.what();
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_session_context_clear
ENTROPIC_EXPORT entropic_error_t entropic_session_context_clear(entropic_handle_t handle, const char *session_key)
Clear one session's history, leaving other sessions intact (gh#144).
src/facade/entropic.cpp:3756
Called by end_session, handle_clear
Source · 12 lines
entropic_error_t entropic_session_context_clear(
entropic_handle_t handle,
const char* session_key) {
if (!handle || !handle->engine) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
const std::string key = session_key ? session_key : "";
handle->engine->clear_conversation_for(key);
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_session_context_clear(entropic_handle_t handle, const char *session_key)
Clear one session's history, leaving others intact (gh#144).
src/facade/entropic.cpp:3756
Source · 12 lines
entropic_error_t entropic_session_context_clear(
entropic_handle_t handle,
const char* session_key) {
if (!handle || !handle->engine) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
const std::string key = session_key ? session_key : "";
handle->engine->clear_conversation_for(key);
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_session_context_count
ENTROPIC_EXPORT entropic_error_t entropic_session_context_count(entropic_handle_t handle, const char *session_key, size_t *count)
Message count for one session (gh#144).
src/facade/entropic.cpp:3724
Source · 14 lines
entropic_error_t entropic_session_context_count(
entropic_handle_t handle,
const char* session_key,
size_t* count) {
if (!handle || !count || !handle->engine) {
return (handle != nullptr && count == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
*count = handle->engine->message_count_for(
session_key ? session_key : "");
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_session_context_count(entropic_handle_t handle, const char *session_key, size_t *count)
Message count for one session (gh#144, v2.12.0).
src/facade/entropic.cpp:3724
Source · 14 lines
entropic_error_t entropic_session_context_count(
entropic_handle_t handle,
const char* session_key,
size_t* count) {
if (!handle || !count || !handle->engine) {
return (handle != nullptr && count == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
*count = handle->engine->message_count_for(
session_key ? session_key : "");
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_session_context_get
ENTROPIC_EXPORT entropic_error_t entropic_session_context_get(entropic_handle_t handle, const char *session_key, char **messages_json)
Read one session's conversation as a JSON array (gh#144).
src/facade/entropic.cpp:3598
Called by final_answer_from_context, snapshot
Calls alloc_cstr, messages_for, serialize_messages
Source · 14 lines
entropic_error_t entropic_session_context_get(
entropic_handle_t handle,
const char* session_key,
char** messages_json) {
if (!handle || !messages_json || !handle->engine) {
return (handle != nullptr && messages_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
*messages_json = alloc_cstr(facade_json::serialize_messages(
handle->engine->messages_for(session_key ? session_key : "")));
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_session_context_get(entropic_handle_t handle, const char *session_key, char **messages_json)
Read one session's conversation as JSON (gh#144, v2.12.0).
src/facade/entropic.cpp:3598
Called by TEST_CASE, final_answer_from_context, snapshot
Calls alloc_cstr, serialize_messages
Source · 14 lines
entropic_error_t entropic_session_context_get(
entropic_handle_t handle,
const char* session_key,
char** messages_json) {
if (!handle || !messages_json || !handle->engine) {
return (handle != nullptr && messages_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
*messages_json = alloc_cstr(facade_json::serialize_messages(
handle->engine->messages_for(session_key ? session_key : "")));
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_session_context_set
ENTROPIC_EXPORT entropic_error_t entropic_session_context_set(entropic_handle_t handle, const char *session_key, const char *messages_json)
Replace one session's conversation (gh#165, v2.13.0).
src/facade/entropic.cpp:3701
Source · 13 lines
entropic_error_t entropic_session_context_set(
entropic_handle_t handle,
const char* session_key,
const char* messages_json) {
if (!handle || !handle->engine || !messages_json) {
return (handle != nullptr && handle->engine != nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
return session_context_set_inner(
handle, session_key != nullptr ? session_key : "", messages_json);
}Activity · 4 steps
entropic_error_t entropic_session_context_set(entropic_handle_t handle, const char *session_key, const char *messages_json)
Replace one session's conversation — see entropic.h (gh#165).
src/facade/entropic.cpp:3701
Source · 13 lines
entropic_error_t entropic_session_context_set(
entropic_handle_t handle,
const char* session_key,
const char* messages_json) {
if (!handle || !handle->engine || !messages_json) {
return (handle != nullptr && handle->engine != nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
return session_context_set_inner(
handle, session_key != nullptr ? session_key : "", messages_json);
}Activity · 4 steps
Requirements
entropic_session_drop
ENTROPIC_EXPORT entropic_error_t entropic_session_drop(entropic_handle_t handle, const char *session_key)
Forget a session entirely (gh#144).
src/facade/entropic.cpp:3783
Source · 12 lines
entropic_error_t entropic_session_drop(
entropic_handle_t handle,
const char* session_key) {
if (!handle || !handle->engine) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
const std::string key = session_key ? session_key : "";
handle->engine->drop_session(key);
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_session_drop(entropic_handle_t handle, const char *session_key)
Forget a session entirely (gh#144, v2.12.0).
src/facade/entropic.cpp:3783
Source · 12 lines
entropic_error_t entropic_session_drop(
entropic_handle_t handle,
const char* session_key) {
if (!handle || !handle->engine) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
const std::string key = session_key ? session_key : "";
handle->engine->drop_session(key);
entropic::release_session_tool_state(handle, key);
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_session_list
ENTROPIC_EXPORT entropic_error_t entropic_session_list(entropic_handle_t handle, char **sessions_json)
List the sessions this handle currently holds (gh#144).
src/facade/entropic.cpp:3809
Source · 17 lines
entropic_error_t entropic_session_list(
entropic_handle_t handle,
char** sessions_json) {
if (!handle || !sessions_json || !handle->engine) {
return (handle != nullptr && sessions_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
nlohmann::json arr = nlohmann::json::array();
for (const auto& key : handle->engine->session_keys()) {
arr.push_back({{"key", key},
{"messages", handle->engine->message_count_for(key)}});
}
*sessions_json = alloc_cstr(arr.dump());
return ENTROPIC_OK;
}Activity · 8 steps
entropic_error_t entropic_session_list(entropic_handle_t handle, char **sessions_json)
List the sessions this handle holds (gh#144, v2.12.0).
src/facade/entropic.cpp:3809
Source · 17 lines
entropic_error_t entropic_session_list(
entropic_handle_t handle,
char** sessions_json) {
if (!handle || !sessions_json || !handle->engine) {
return (handle != nullptr && sessions_json == nullptr)
? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_INVALID_HANDLE;
}
entropic::HandleApiLock lock(handle);
nlohmann::json arr = nlohmann::json::array();
for (const auto& key : handle->engine->session_keys()) {
arr.push_back({{"key", key},
{"messages", handle->engine->message_count_for(key)}});
}
*sessions_json = alloc_cstr(arr.dump());
return ENTROPIC_OK;
}Activity · 8 steps
Requirements
entropic_set_attempt_boundary_cb
ENTROPIC_EXPORT entropic_error_t entropic_set_attempt_boundary_cb(entropic_handle_t handle, ent_validation_attempt_boundary_cb cb, void *user_data)
Register an attempt-boundary callback for the validator.
src/facade/entropic.cpp:3058
Source · 10 lines
entropic_error_t entropic_set_attempt_boundary_cb(
entropic_handle_t handle,
ent_validation_attempt_boundary_cb cb,
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->validator) {
handle->validator->set_attempt_boundary_cb(cb, user_data);
}
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_set_attempt_boundary_cb(entropic_handle_t handle, ent_validation_attempt_boundary_cb cb, void *user_data)
Register attempt-boundary callback on the validator.
src/facade/entropic.cpp:3058
Source · 10 lines
entropic_error_t entropic_set_attempt_boundary_cb(
entropic_handle_t handle,
ent_validation_attempt_boundary_cb cb,
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->validator) {
handle->validator->set_attempt_boundary_cb(cb, user_data);
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_set_critique_callbacks
ENTROPIC_EXPORT entropic_error_t entropic_set_critique_callbacks(entropic_handle_t handle, void(*start_cb)(void *user_data), void(*end_cb)(void *user_data), void *user_data)
Register start/end callbacks for constitutional critique generation (gh#50, v2.1.12).
src/facade/entropic.cpp:3151
Source · 15 lines
entropic_error_t entropic_set_critique_callbacks(
entropic_handle_t handle,
void (*start_cb)(void* user_data),
void (*end_cb)(void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->critique_start_cb = start_cb;
handle->critique_end_cb = end_cb;
handle->critique_cb_data = user_data;
if (handle->validator) {
handle->validator->set_critique_callbacks(
start_cb, end_cb, user_data);
}
return ENTROPIC_OK;
}Activity · 8 steps
entropic_error_t entropic_set_critique_callbacks(entropic_handle_t handle, void(*start_cb)(void *user_data), void(*end_cb)(void *user_data), void *user_data)
Register critique start/end callbacks on the handle (gh#50, v2.1.12).
src/facade/entropic.cpp:3151
Source · 15 lines
entropic_error_t entropic_set_critique_callbacks(
entropic_handle_t handle,
void (*start_cb)(void* user_data),
void (*end_cb)(void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->critique_start_cb = start_cb;
handle->critique_end_cb = end_cb;
handle->critique_cb_data = user_data;
if (handle->validator) {
handle->validator->set_critique_callbacks(
start_cb, end_cb, user_data);
}
return ENTROPIC_OK;
}Activity · 8 steps
Requirements
entropic_set_delegation_callbacks
ENTROPIC_EXPORT entropic_error_t entropic_set_delegation_callbacks(entropic_handle_t handle, ent_delegation_start_cb on_start, ent_delegation_complete_cb on_complete, void *user_data)
Register start/complete callbacks for delegations.
src/facade/entropic.cpp:3081
Source · 12 lines
entropic_error_t entropic_set_delegation_callbacks(
entropic_handle_t handle,
ent_delegation_start_cb on_start,
ent_delegation_complete_cb on_complete,
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->engine) {
handle->engine->set_delegation_callbacks(
on_start, on_complete, user_data);
}
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_set_delegation_callbacks(entropic_handle_t handle, ent_delegation_start_cb on_start, ent_delegation_complete_cb on_complete, void *user_data)
Register delegation start/complete callbacks (gh#29, v2.1.5).
src/facade/entropic.cpp:3081
Source · 12 lines
entropic_error_t entropic_set_delegation_callbacks(
entropic_handle_t handle,
ent_delegation_start_cb on_start,
ent_delegation_complete_cb on_complete,
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->engine) {
handle->engine->set_delegation_callbacks(
on_start, on_complete, user_data);
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_set_queue_observer
entropic_error_t entropic_set_queue_observer(entropic_handle_t handle, void(*observer)(const char *, size_t, void *), void *user_data)
Register the queue-consumption observer.
src/facade/entropic.cpp:3292
Source · 12 lines
entropic_error_t entropic_set_queue_observer(
entropic_handle_t handle,
void (*observer)(const char*, size_t, void*),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->queue_observer = observer;
handle->queue_observer_data = user_data;
if (handle->engine) {
handle->engine->set_queue_observer(observer, user_data);
}
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_set_residency_observer
ENTROPIC_EXPORT entropic_error_t entropic_set_residency_observer(entropic_handle_t handle, entropic_residency_observer_t observer, void *user_data)
Register a residency observer on a handle.
src/facade/entropic.cpp:5331
Source · 29 lines
entropic_error_t entropic_set_residency_observer(
entropic_handle_t handle,
entropic_residency_observer_t observer,
void* user_data) {
if (handle == nullptr) { return ENTROPIC_ERROR_INVALID_HANDLE; }
// Engine-not-configured (no orchestrator yet) and observer==nullptr
// both collapse to a no-op set: pre-configure registration is
// ignored (consumers must re-register after configure_*), and
// an explicit nullptr clears any prior slot. Done as one branch
// to stay under the knots return-count gate.
entropic::ModelOrchestrator::ResidencyObserverFn fn;
if (observer != nullptr) {
fn = [observer, user_data](
entropic::ModelOrchestrator::ResidencyEvent event,
const std::string& tier_name,
const std::string& model_path,
size_t footprint) {
observer(static_cast<entropic_residency_event_t>(event),
tier_name.c_str(),
model_path.c_str(),
footprint,
user_data);
};
}
if (handle->orchestrator) {
handle->orchestrator->set_residency_observer(std::move(fn));
}
return ENTROPIC_OK;
}Activity · 8 steps
entropic_error_t entropic_set_residency_observer(entropic_handle_t handle, entropic_residency_observer_t observer, void *user_data)
Register a residency observer on the orchestrator.
src/facade/entropic.cpp:5331
Source · 29 lines
entropic_error_t entropic_set_residency_observer(
entropic_handle_t handle,
entropic_residency_observer_t observer,
void* user_data) {
if (handle == nullptr) { return ENTROPIC_ERROR_INVALID_HANDLE; }
// Engine-not-configured (no orchestrator yet) and observer==nullptr
// both collapse to a no-op set: pre-configure registration is
// ignored (consumers must re-register after configure_*), and
// an explicit nullptr clears any prior slot. Done as one branch
// to stay under the knots return-count gate.
entropic::ModelOrchestrator::ResidencyObserverFn fn;
if (observer != nullptr) {
fn = [observer, user_data](
entropic::ModelOrchestrator::ResidencyEvent event,
const std::string& tier_name,
const std::string& model_path,
size_t footprint) {
observer(static_cast<entropic_residency_event_t>(event),
tier_name.c_str(),
model_path.c_str(),
footprint,
user_data);
};
}
if (handle->orchestrator) {
handle->orchestrator->set_residency_observer(std::move(fn));
}
return ENTROPIC_OK;
}Activity · 8 steps
Requirements
entropic_set_state_observer
ENTROPIC_EXPORT entropic_error_t entropic_set_state_observer(entropic_handle_t handle, void(*observer)(int state, void *user_data), void *user_data)
Register an engine state-change observer.
src/facade/entropic.cpp:3112
Called by TEST_CASE, attach_phase_observer, detach_phase_observer
Calls set_state_observer
Source · 18 lines
entropic_error_t entropic_set_state_observer(
entropic_handle_t handle,
void (*observer)(int state, void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->state_observer = observer;
handle->state_observer_data = user_data;
if (handle->engine) {
// gh#40 fallout (v2.1.10): route through the engine's
// persistent state-observer slot rather than the legacy
// EngineCallbacks::on_state_change. The legacy path is
// wiped by run_streaming's set_callbacks() shuffle, so
// wiring there silently failed for streaming runs (the
// exact bridge use case this API was designed for).
handle->engine->set_state_observer(observer, user_data);
}
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_set_state_observer(entropic_handle_t handle, void(*observer)(int state, void *user_data), void *user_data)
Register a state-change observer on the handle.
src/facade/entropic.cpp:3112
Source · 18 lines
entropic_error_t entropic_set_state_observer(
entropic_handle_t handle,
void (*observer)(int state, void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->state_observer = observer;
handle->state_observer_data = user_data;
if (handle->engine) {
// gh#40 fallout (v2.1.10): route through the engine's
// persistent state-observer slot rather than the legacy
// EngineCallbacks::on_state_change. The legacy path is
// wiped by run_streaming's set_callbacks() shuffle, so
// wiring there silently failed for streaming runs (the
// exact bridge use case this API was designed for).
handle->engine->set_state_observer(observer, user_data);
}
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_set_stream_observer
ENTROPIC_EXPORT entropic_error_t entropic_set_stream_observer(entropic_handle_t handle, void(*observer)(const char *token, size_t len, void *user_data), void *user_data)
Set a global stream observer callback.
src/facade/entropic.cpp:2981
Source · 14 lines
entropic_error_t entropic_set_stream_observer(
entropic_handle_t handle,
void (*observer)(const char* token, size_t len, void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->stream_observer = observer;
handle->stream_observer_data = user_data;
// Propagate to engine so every generation path (streaming, batch,
// and child-loop delegations) reaches the observer. (P0-1, 2.0.6-rc16)
if (handle->engine) {
handle->engine->set_stream_observer(observer, user_data);
}
return ENTROPIC_OK;
}Activity · 7 steps
entropic_error_t entropic_set_stream_observer(entropic_handle_t handle, void(*observer)(const char *token, size_t len, void *user_data), void *user_data)
Set a global stream observer callback.
src/facade/entropic.cpp:2981
Source · 14 lines
entropic_error_t entropic_set_stream_observer(
entropic_handle_t handle,
void (*observer)(const char* token, size_t len, void* user_data),
void* user_data) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
handle->stream_observer = observer;
handle->stream_observer_data = user_data;
// Propagate to engine so every generation path (streaming, batch,
// and child-loop delegations) reaches the observer. (P0-1, 2.0.6-rc16)
if (handle->engine) {
handle->engine->set_stream_observer(observer, user_data);
}
return ENTROPIC_OK;
}Activity · 7 steps
Requirements
entropic_speculative_compat
ENTROPIC_EXPORT entropic_error_t entropic_speculative_compat(entropic_handle_t handle, int *compatible, char **diagnostic)
Query whether the configured target/draft pair is compatible for speculative decoding.
src/facade/entropic.cpp:5293
Source · 19 lines
entropic_error_t entropic_speculative_compat(
entropic_handle_t handle,
int* compatible,
char** diagnostic) {
if (handle == nullptr || compatible == nullptr) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
if (!handle->orchestrator) {
return ENTROPIC_ERROR_INVALID_STATE;
}
auto info = handle->orchestrator->check_speculative_compat();
*compatible = info.compatible ? 1 : 0;
if (diagnostic != nullptr) {
*diagnostic = info.compatible
? nullptr
: alloc_cstr(info.diagnostic);
}
return ENTROPIC_OK;
}Activity · 9 steps
entropic_error_t entropic_speculative_compat(entropic_handle_t handle, int *compatible, char **diagnostic)
Query speculative-decoding compatibility for the configured target/draft pair.
src/facade/entropic.cpp:5293
Source · 19 lines
entropic_error_t entropic_speculative_compat(
entropic_handle_t handle,
int* compatible,
char** diagnostic) {
if (handle == nullptr || compatible == nullptr) {
return ENTROPIC_ERROR_INVALID_HANDLE;
}
if (!handle->orchestrator) {
return ENTROPIC_ERROR_INVALID_STATE;
}
auto info = handle->orchestrator->check_speculative_compat();
*compatible = info.compatible ? 1 : 0;
if (diagnostic != nullptr) {
*diagnostic = info.compatible
? nullptr
: alloc_cstr(info.diagnostic);
}
return ENTROPIC_OK;
}Activity · 9 steps
Requirements
entropic_state_load
ENTROPIC_EXPORT entropic_error_t entropic_state_load(entropic_handle_t handle, const char *tier_name, const char *path)
Restore a tier's KV-cache state from a file (gh#23 MVP item 13).
src/facade/entropic.cpp:3967
Source · 16 lines
entropic_error_t entropic_state_load(
entropic_handle_t handle,
const char* tier_name,
const char* path) {
// gh#157: may load the tier's model — see entropic_state_save.
entropic::HandleTurnGuard turn(handle);
if (!handle || !tier_name || !path
|| (handle->engine != nullptr && !turn.claim())) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle,
[&]() { return do_state_load(handle, tier_name, path); });
}Activity · 5 steps
entropic_error_t entropic_state_load(entropic_handle_t handle, const char *tier_name, const char *path)
Restore a tier's KV cache from a file (gh#23 v2.3.25).
src/facade/entropic.cpp:3967
Source · 16 lines
entropic_error_t entropic_state_load(
entropic_handle_t handle,
const char* tier_name,
const char* path) {
// gh#157: may load the tier's model — see entropic_state_save.
entropic::HandleTurnGuard turn(handle);
if (!handle || !tier_name || !path
|| (handle->engine != nullptr && !turn.claim())) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle,
[&]() { return do_state_load(handle, tier_name, path); });
}Activity · 5 steps
Requirements
entropic_state_save
ENTROPIC_EXPORT entropic_error_t entropic_state_save(entropic_handle_t handle, const char *tier_name, const char *path)
Save a tier's KV-cache state to a file (gh#23 MVP item 13).
src/facade/entropic.cpp:3904
Source · 17 lines
entropic_error_t entropic_state_save(
entropic_handle_t handle,
const char* tier_name,
const char* path) {
// gh#157: this may now LOAD the tier's model. Claim the turn so the
// load cannot land in the middle of a generation on another thread.
entropic::HandleTurnGuard turn(handle);
if (!handle || !tier_name || !path
|| (handle->engine != nullptr && !turn.claim())) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle,
[&]() { return do_state_save(handle, tier_name, path); });
}Activity · 5 steps
entropic_error_t entropic_state_save(entropic_handle_t handle, const char *tier_name, const char *path)
Save a tier's KV cache to a file (gh#23 v2.3.25, MVP item 13).
src/facade/entropic.cpp:3904
Source · 17 lines
entropic_error_t entropic_state_save(
entropic_handle_t handle,
const char* tier_name,
const char* path) {
// gh#157: this may now LOAD the tier's model. Claim the turn so the
// load cannot land in the middle of a generation on another thread.
entropic::HandleTurnGuard turn(handle);
if (!handle || !tier_name || !path
|| (handle->engine != nullptr && !turn.claim())) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT
: ENTROPIC_ERROR_ALREADY_RUNNING;
}
entropic::HandleApiLock lock(handle);
return c_api_try(handle,
[&]() { return do_state_save(handle, tier_name, path); });
}Activity · 5 steps
Requirements
entropic_throughput_reset
ENTROPIC_EXPORT void entropic_throughput_reset(entropic_handle_t handle, const char *model_path)
Reset throughput tracking data for a model.
src/facade/entropic.cpp:4649
Source · 16 lines
void entropic_throughput_reset(
entropic_handle_t handle,
const char* model_path)
{
(void)model_path;
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return;
}
try {
handle->orchestrator->throughput_tracker().reset();
s_log->info("throughput_reset: data cleared");
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("throughput_reset: {}", handle->last_error);
}
}Activity · 4 steps
void entropic_throughput_reset(entropic_handle_t handle, const char *model_path)
Reset throughput tracking data.
src/facade/entropic.cpp:4649
Source · 16 lines
void entropic_throughput_reset(
entropic_handle_t handle,
const char* model_path)
{
(void)model_path;
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return;
}
try {
handle->orchestrator->throughput_tracker().reset();
s_log->info("throughput_reset: data cleared");
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("throughput_reset: {}", handle->last_error);
}
}Activity · 4 steps
Requirements
entropic_throughput_tok_per_sec
ENTROPIC_EXPORT double entropic_throughput_tok_per_sec(entropic_handle_t handle, const char *model_path)
Get current throughput estimate for a model.
src/facade/entropic.cpp:4619
Source · 16 lines
double entropic_throughput_tok_per_sec(
entropic_handle_t handle,
const char* model_path)
{
(void)model_path;
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return 0.0;
}
try {
return handle->orchestrator->throughput_tracker().tok_per_sec();
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("throughput_tok_per_sec: {}", handle->last_error);
return 0.0;
}
}Activity · 4 steps
double entropic_throughput_tok_per_sec(entropic_handle_t handle, const char *model_path)
Get EWMA throughput estimate in tokens per second.
src/facade/entropic.cpp:4619
Source · 16 lines
double entropic_throughput_tok_per_sec(
entropic_handle_t handle,
const char* model_path)
{
(void)model_path;
if (!handle || !handle->configured.load() || !handle->orchestrator) {
return 0.0;
}
try {
return handle->orchestrator->throughput_tracker().tok_per_sec();
} catch (const std::exception& e) {
handle->last_error = e.what();
s_log->error("throughput_tok_per_sec: {}", handle->last_error);
return 0.0;
}
}Activity · 4 steps
Requirements
entropic_update_identity
ENTROPIC_EXPORT entropic_error_t entropic_update_identity(entropic_handle_t handle, const char *name, const char *config_json)
Update a dynamic identity.
src/facade/entropic.cpp:4875
Source · 24 lines
entropic_error_t entropic_update_identity(
entropic_handle_t handle,
const char* name,
const char* config_json)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !name || !config_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
auto j = nlohmann::json::parse(config_json);
entropic::IdentityConfig cfg;
cfg.name = name;
cfg.system_prompt = j.value("system_prompt", "");
if (j.contains("focus") && j["focus"].is_array()) {
cfg.focus = j["focus"].get<std::vector<std::string>>();
}
cfg.origin = entropic::IdentityOrigin::DYNAMIC;
return handle->identity_manager->update(name, cfg);
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INVALID_CONFIG;
}
}Activity · 4 steps
entropic_error_t entropic_update_identity(entropic_handle_t handle, const char *name, const char *config_json)
Update an existing dynamic identity.
src/facade/entropic.cpp:4875
Source · 24 lines
entropic_error_t entropic_update_identity(
entropic_handle_t handle,
const char* name,
const char* config_json)
{
auto rc = check_identity(handle);
if (rc != ENTROPIC_OK || !name || !config_json) {
return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;
}
try {
auto j = nlohmann::json::parse(config_json);
entropic::IdentityConfig cfg;
cfg.name = name;
cfg.system_prompt = j.value("system_prompt", "");
if (j.contains("focus") && j["focus"].is_array()) {
cfg.focus = j["focus"].get<std::vector<std::string>>();
}
cfg.origin = entropic::IdentityOrigin::DYNAMIC;
return handle->identity_manager->update(name, cfg);
} catch (const std::exception& e) {
handle->last_error = e.what();
return ENTROPIC_ERROR_INVALID_CONFIG;
}
}Activity · 4 steps
Requirements
entropic_user_message_queue_depth
ENTROPIC_EXPORT entropic_error_t entropic_user_message_queue_depth(entropic_handle_t handle, size_t *count)
Query the current depth of the mid-gen user-message queue.
src/facade/entropic.cpp:3252
Source · 8 lines
entropic_error_t entropic_user_message_queue_depth(
entropic_handle_t handle, size_t* count) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!count) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
*count = handle->engine
? handle->engine->user_message_queue_depth() : 0;
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_user_message_queue_depth(entropic_handle_t handle, size_t *count)
Snapshot the mid-gen queue depth.
src/facade/entropic.cpp:3252
Source · 8 lines
entropic_error_t entropic_user_message_queue_depth(
entropic_handle_t handle, size_t* count) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!count) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
*count = handle->engine
? handle->engine->user_message_queue_depth() : 0;
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_validation_accept_last
ENTROPIC_EXPORT entropic_error_t entropic_validation_accept_last(entropic_handle_t handle)
Finalize the last attempt as the turn's response.
src/facade/entropic.cpp:3041
Source · 7 lines
entropic_error_t entropic_validation_accept_last(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return handle->validator->accept_last();
}Activity · 6 steps
entropic_error_t entropic_validation_accept_last(entropic_handle_t handle)
Accept the last paused attempt as the final answer.
src/facade/entropic.cpp:3041
Source · 7 lines
entropic_error_t entropic_validation_accept_last(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return handle->validator->accept_last();
}Activity · 6 steps
Requirements
entropic_validation_last_result
ENTROPIC_EXPORT char * entropic_validation_last_result(entropic_handle_t handle)
Get the last validation result as JSON.
src/facade/entropic.cpp:5214
Source · 14 lines
char* entropic_validation_last_result(entropic_handle_t handle)
{
if (!handle || !handle->validator) { return nullptr; }
try {
auto result = handle->validator->last_result();
nlohmann::json j;
j["content"] = entropic::mcp::sanitize_utf8(result.content);
j["was_revised"] = result.was_revised;
j["revision_count"] = result.revision_count;
return alloc_cstr(j.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
char * entropic_validation_last_result(entropic_handle_t handle)
Get last validation result as JSON.
src/facade/entropic.cpp:5214
Source · 14 lines
char* entropic_validation_last_result(entropic_handle_t handle)
{
if (!handle || !handle->validator) { return nullptr; }
try {
auto result = handle->validator->last_result();
nlohmann::json j;
j["content"] = entropic::mcp::sanitize_utf8(result.content);
j["was_revised"] = result.was_revised;
j["revision_count"] = result.revision_count;
return alloc_cstr(j.dump().c_str());
} catch (...) {
return nullptr;
}
}Activity · 3 steps
Requirements
entropic_validation_resume_retry
ENTROPIC_EXPORT entropic_error_t entropic_validation_resume_retry(entropic_handle_t handle)
Opt the engine into running the constitutional revision pass.
src/facade/entropic.cpp:3024
Source · 7 lines
entropic_error_t entropic_validation_resume_retry(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return handle->validator->resume_retry();
}Activity · 6 steps
entropic_error_t entropic_validation_resume_retry(entropic_handle_t handle)
Resume a paused constitutional revision pass.
src/facade/entropic.cpp:3024
Source · 7 lines
entropic_error_t entropic_validation_resume_retry(
entropic_handle_t handle) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
entropic::HandleApiLock lock(handle); // gh#59 v2.3.1: mutex + log scope
return handle->validator->resume_retry();
}Activity · 6 steps
Requirements
entropic_validation_set_auto_retry
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_auto_retry(entropic_handle_t handle, int enabled)
Toggle automatic constitutional revision after rejection.
src/facade/entropic.cpp:3006
Source · 8 lines
entropic_error_t entropic_validation_set_auto_retry(
entropic_handle_t handle, int enabled) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->validator) {
handle->validator->set_auto_retry(enabled != 0);
}
return ENTROPIC_OK;
}Activity · 5 steps
entropic_error_t entropic_validation_set_auto_retry(entropic_handle_t handle, int enabled)
Toggle automatic constitutional revision.
src/facade/entropic.cpp:3006
Source · 8 lines
entropic_error_t entropic_validation_set_auto_retry(
entropic_handle_t handle, int enabled) {
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (handle->validator) {
handle->validator->set_auto_retry(enabled != 0);
}
return ENTROPIC_OK;
}Activity · 5 steps
Requirements
entropic_validation_set_enabled
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_enabled(entropic_handle_t handle, bool enabled)
Enable or disable constitutional validation.
src/facade/entropic.cpp:5172
Source · 9 lines
entropic_error_t entropic_validation_set_enabled(
entropic_handle_t handle,
bool enabled)
{
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
handle->validator->set_global_enabled(enabled);
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_validation_set_enabled(entropic_handle_t handle, bool enabled)
Enable or disable constitutional validation globally.
src/facade/entropic.cpp:5172
Source · 9 lines
entropic_error_t entropic_validation_set_enabled(
entropic_handle_t handle,
bool enabled)
{
if (!handle) { return ENTROPIC_ERROR_INVALID_HANDLE; }
if (!handle->validator) { return ENTROPIC_ERROR_INVALID_STATE; }
handle->validator->set_global_enabled(enabled);
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_validation_set_identity
ENTROPIC_EXPORT entropic_error_t entropic_validation_set_identity(entropic_handle_t handle, const char *identity_name, bool enabled)
Set per-identity validation override.
src/facade/entropic.cpp:5190
Source · 13 lines
entropic_error_t entropic_validation_set_identity(
entropic_handle_t handle,
const char* identity_name,
bool enabled)
{
if (!handle || !handle->validator) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_STATE;
}
if (!identity_name) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
handle->validator->set_identity_validation(identity_name, enabled);
return ENTROPIC_OK;
}Activity · 6 steps
entropic_error_t entropic_validation_set_identity(entropic_handle_t handle, const char *identity_name, bool enabled)
Set per-identity validation override.
src/facade/entropic.cpp:5190
Source · 13 lines
entropic_error_t entropic_validation_set_identity(
entropic_handle_t handle,
const char* identity_name,
bool enabled)
{
if (!handle || !handle->validator) {
return !handle ? ENTROPIC_ERROR_INVALID_HANDLE
: ENTROPIC_ERROR_INVALID_STATE;
}
if (!identity_name) { return ENTROPIC_ERROR_INVALID_ARGUMENT; }
handle->validator->set_identity_validation(identity_name, enabled);
return ENTROPIC_OK;
}Activity · 6 steps
Requirements
entropic_version
ENTROPIC_EXPORT const char * entropic_version(void)
Get the library version string.
src/facade/entropic.cpp:2343
Called by SCENARIO, TEST_CASE, handle_status, initialize_result, main, main, run_json
Calls none
Source · 3 lines
const char* entropic_version(void) {
return CONFIG_ENTROPIC_VERSION_STRING;
}Activity · 1 steps
const char * entropic_version(void)
Get the library version string.
src/facade/entropic.cpp:2343
Called by SCENARIO, TEST_CASE, handle_status, initialize_result, main, main, run_json
Calls none
Source · 3 lines
const char* entropic_version(void) {
return CONFIG_ENTROPIC_VERSION_STRING;
}Activity · 1 steps
Requirements
facade_session_root
static std::filesystem::path facade_session_root(const std::string &session_key, void *ud)
Root a session's MCP tools resolve against (gh#160).
src/facade/entropic.cpp:1693
Source · 7 lines
static std::filesystem::path facade_session_root(
const std::string& session_key, void* ud) {
auto* h = static_cast<entropic_handle_t>(ud);
auto* servers = entropic::workspace_servers(h, session_key);
if (servers == nullptr) { return {}; }
return servers->project_dir();
}Activity · 5 steps
Requirements
init_orchestrator
static entropic_error_t init_orchestrator(entropic_handle_t h, const std::filesystem::path &data_dir)
Shared body of all entropic_configure* entry points.
src/facade/entropic.cpp:1888
Called by TEST_CASE, TEST_CASE, TEST_CASE, configure_common, init_orchestrator_for_v219_family
Calls grammar_registry, initialize, load_grammars_from
Source · 15 lines
static entropic_error_t init_orchestrator(
entropic_handle_t h, const std::filesystem::path& data_dir) {
h->orchestrator = std::make_unique<entropic::ModelOrchestrator>();
if (!h->orchestrator->initialize(h->config)) {
h->last_error = "orchestrator initialization failed";
s_log->error("{}", h->last_error);
return ENTROPIC_ERROR_LOAD_FAILED;
}
// Fallback grammar loading: only if initialize() didn't find
// grammars via config_dir. Avoids overwriting patched grammars.
if (h->orchestrator->grammar_registry().size() == 0) {
h->orchestrator->load_grammars_from(data_dir / "grammars");
}
return ENTROPIC_OK;
}Activity · 8 steps
Requirements
reject_if_configured
static entropic_error_t reject_if_configured(entropic_handle_t h)
Post-parse config setup: subsystem construction + wiring.
src/facade/entropic.cpp:1863
Source · 6 lines
static entropic_error_t reject_if_configured(entropic_handle_t h) {
if (!h->configured.load()) { return ENTROPIC_OK; }
h->last_error = "handle already configured";
s_log->error("{}", h->last_error);
return ENTROPIC_ERROR_INVALID_STATE;
}Activity · 5 steps
Requirements
require_ready_backend
static entropic::InferenceBackend * require_ready_backend(entropic_handle_t h, const char *tier_name)
Resolve a tier name to a resident backend, loading it if needed.
src/facade/entropic.cpp:232
Called by do_state_load, do_state_save, entropic_compute_perplexity, entropic_get_logprobs
Calls ensure_model, get_backend
Source · 14 lines
static entropic::InferenceBackend* require_ready_backend(
entropic_handle_t h, const char* tier_name)
{
const std::string tier(tier_name);
if (h->orchestrator->get_backend(tier) == nullptr) {
throw std::runtime_error("no backend for tier: " + tier);
}
auto* backend = h->orchestrator->ensure_model(tier);
if (backend == nullptr || !backend->is_active()) {
throw std::runtime_error(
"model could not be made resident for tier: " + tier);
}
return backend;
}Activity · 7 steps
Requirements
rewire_critique_callbacks
static void rewire_critique_callbacks(entropic_handle_t h)
Propagate pre-configure critique callbacks to a newly- constructed ConstitutionalValidator (gh#50, v2.1.12).
src/facade/entropic.cpp:527
Source · 9 lines
static void rewire_critique_callbacks(entropic_handle_t h) {
if ((h->critique_start_cb != nullptr || h->critique_end_cb != nullptr)
&& h->validator) {
h->validator->set_critique_callbacks(
h->critique_start_cb,
h->critique_end_cb,
h->critique_cb_data);
}
}Activity · 2 steps
Requirements
rewire_observers
static void rewire_observers(entropic_handle_t h)
Re-bind every pre-configure observer to the new engine.
src/facade/entropic.cpp:547
Called by init_engine_and_interfaces
Calls rewire_critique_callbacks, rewire_queue_observer, rewire_state_observer, rewire_stream_observer
Source · 6 lines
static void rewire_observers(entropic_handle_t h) {
rewire_stream_observer(h);
rewire_queue_observer(h);
rewire_critique_callbacks(h);
rewire_state_observer(h);
}Activity · 4 steps
Requirements
rewire_queue_observer
static void rewire_queue_observer(entropic_handle_t h)
Propagate any pre-configure queue observer to the new engine.
src/facade/entropic.cpp:488
Source · 6 lines
static void rewire_queue_observer(entropic_handle_t h) {
if (h->queue_observer != nullptr && h->engine) {
h->engine->set_queue_observer(
h->queue_observer, h->queue_observer_data);
}
}Activity · 2 steps
Requirements
rewire_state_observer
static void rewire_state_observer(entropic_handle_t h)
Propagate any pre-configure state observer to the new engine.
src/facade/entropic.cpp:507
Source · 6 lines
static void rewire_state_observer(entropic_handle_t h) {
if (h->state_observer != nullptr && h->engine) {
h->engine->set_state_observer(
h->state_observer, h->state_observer_data);
}
}Activity · 2 steps
Requirements
rewire_stream_observer
static void rewire_stream_observer(entropic_handle_t h)
Propagate any pre-configure stream observer to the new engine.
src/facade/entropic.cpp:469
Source · 6 lines
static void rewire_stream_observer(entropic_handle_t h) {
if (h->stream_observer != nullptr && h->engine) {
h->engine->set_stream_observer(
h->stream_observer, h->stream_observer_data);
}
}Activity · 2 steps
Requirements
si_latest_delegation_for_target
static bool si_latest_delegation_for_target(const char *target_tier, std::string &delegation_id, void *user_data)
StorageInterface bridge: latest_delegation_for_target (gh#162).
src/facade/entropic.cpp:736
Source · 7 lines
static bool si_latest_delegation_for_target(
const char* target_tier, std::string& delegation_id,
void* user_data) {
auto* sb = static_cast<entropic::SqliteStorageBackend*>(user_data);
if (sb == nullptr || target_tier == nullptr) { return false; }
return sb->latest_delegation_for_target(target_tier, delegation_id);
}Activity · 4 steps
Requirements
start_external_bridge
static void start_external_bridge(entropic_handle_t h)
Start the external MCP bridge if enabled in config.
src/facade/entropic.cpp:1827
Source · 10 lines
static void start_external_bridge(entropic_handle_t h) {
if (!h->config.mcp.external.enabled) { return; }
// Same derivation the self-connection guard uses (gh#200).
h->external_bridge = std::make_unique<entropic::ExternalBridge>(
h, h->config.mcp.external, entropic::bridge_project_dir(h));
if (!h->external_bridge->start()) {
s_log->warn("External MCP bridge failed to start");
h->external_bridge.reset();
}
}Activity · 6 steps
Requirements
start_http_listener
static entropic_error_t start_http_listener(entropic_handle_t h)
Start the Streamable-HTTP listener when one is configured (gh#204).
src/facade/entropic.cpp:1797
Source · 18 lines
static entropic_error_t start_http_listener(entropic_handle_t h) {
const int port = h->config.mcp.external.http_port;
std::string err;
if (port != 0 && (port < 0 || port > 65535)) {
err = "mcp.external.http_port out of range: " + std::to_string(port);
} else if (port != 0 && !h->external_bridge) {
err = "the unix bridge did not start";
} else if (port != 0) {
h->http_listener = std::make_unique<entropic::http::HttpListener>(
h->external_bridge.get(), port);
if (!h->http_listener->start(err)) { h->http_listener.reset(); }
}
if (!err.empty()) {
h->last_error = "HTTP listener: " + err;
s_log->error("{}", h->last_error);
}
return err.empty() ? ENTROPIC_OK : ENTROPIC_ERROR_IO;
}Activity · 16 steps
Requirements
thread_frontmatter_sampler
static void thread_frontmatter_sampler(entropic::TierConfig &tc, const entropic::prompts::IdentityFrontmatter &fm)
Cache per-tier frontmatter fields (allowed_tools, validation_rules, relay).
src/facade/entropic.cpp:963
Source · 29 lines
static void thread_frontmatter_sampler(
entropic::TierConfig& tc,
const entropic::prompts::IdentityFrontmatter& fm) {
// gh#95 (v2.7.4): thread the identity `grammar:` key so the orchestrator's
// resolve_grammar_key() finds it and constrains the tier's generation.
// Without this the field is parsed but dropped here — registers OK, never
// enforces (same class as the gh#82/85/94 sampler-threading gaps).
if (fm.grammar.has_value()) {
tc.grammar = std::filesystem::path(*fm.grammar);
}
if (fm.temperature.has_value()) { tc.temperature = *fm.temperature; }
if (fm.max_output_tokens.has_value()) {
tc.max_output_tokens = *fm.max_output_tokens;
}
if (fm.top_p.has_value()) { tc.top_p = *fm.top_p; }
if (fm.top_k.has_value()) { tc.top_k = *fm.top_k; }
if (fm.min_p.has_value()) { tc.min_p = *fm.min_p; }
if (fm.presence_penalty.has_value()) {
tc.presence_penalty = *fm.presence_penalty;
}
if (fm.frequency_penalty.has_value()) {
tc.frequency_penalty = *fm.frequency_penalty;
}
// gh#86 (v2.5.4): repeat_penalty + enable_thinking.
if (fm.repeat_penalty.has_value()) { tc.repeat_penalty = *fm.repeat_penalty; }
if (fm.enable_thinking.has_value()) {
tc.enable_thinking = *fm.enable_thinking;
}
}Activity · 20 steps
Requirements
thread_frontmatter_samplers
static void thread_frontmatter_samplers(entropic_handle_t h, const std::filesystem::path &data_dir)
Thread per-tier frontmatter SAMPLERS into config pre-orchestrator.
src/facade/entropic.cpp:1073
Source · 19 lines
static void thread_frontmatter_samplers(
entropic_handle_t h,
const std::filesystem::path& data_dir) {
for (auto& [name, tier] : h->config.models.tiers) {
std::filesystem::path id_path;
if (tier.identity.has_value()) {
id_path = tier.identity.value();
} else if (!tier.identity_disabled) {
id_path = data_dir / "prompts" / ("identity_" + name + ".md");
}
if (id_path.empty() || !std::filesystem::exists(id_path)) {
continue;
}
entropic::prompts::ParsedIdentity id;
if (entropic::prompts::load_identity(id_path, id).empty()) {
thread_frontmatter_sampler(tier, id.frontmatter);
}
}
}Activity · 12 steps
Requirements
validate_prompt_sources
static entropic_error_t validate_prompt_sources(entropic_handle_t h, const std::filesystem::path &data_dir)
Reject a configured prompt path that cannot be loaded (gh#156).
src/facade/entropic.cpp:2004
Source · 12 lines
static entropic_error_t validate_prompt_sources(
entropic_handle_t h, const std::filesystem::path& data_dir) {
auto err = entropic::prompts::validate_configured_prompts(
h->config, data_dir);
entropic_error_t rc = ENTROPIC_OK;
if (!err.empty()) {
h->last_error = err;
s_log->error("configure: {}", err);
rc = ENTROPIC_ERROR_INVALID_CONFIG;
}
return rc;
}Activity · 7 steps
Requirements
warn_tier_grammars_step
static void warn_tier_grammars_step(entropic_handle_t h, const std::filesystem::path &data_dir)
Warn about a tier grammar stem that resolves to nothing (gh#154).
src/facade/entropic.cpp:2042
Called by configure_common
Source · 9 lines
static void warn_tier_grammars_step(
entropic_handle_t h, const std::filesystem::path& data_dir) {
auto warning = entropic::config::warn_unresolved_tier_grammars(
h->config,
entropic::config::grammar_search_paths(h->config, data_dir));
if (!warning.empty()) {
s_log->warn("configure: {}", warning);
}
}Activity · 3 steps
Requirements
wire_tool_executor
static void wire_tool_executor(entropic_handle_t h)
Wire the ToolExecutor and attach it to the engine.
src/facade/entropic.cpp:1135
Called by init_engine_and_interfaces
Calls ToolExecutor, build_directive_hooks, callbacks, loop_config, set_server_resolver, set_tool_executor, tool_history_json_thunk, workspace_servers
Source · 26 lines
static void wire_tool_executor(entropic_handle_t h) {
h->tool_executor = std::make_unique<entropic::ToolExecutor>(
*h->server_manager,
h->engine->loop_config(),
h->engine->callbacks(),
h->engine->build_directive_hooks());
entropic::ToolExecutionInterface tei;
tei.process_tool_calls = [](entropic::LoopContext& ctx,
const std::vector<entropic::ToolCall>& calls,
void* ud) -> std::vector<entropic::Message> {
return static_cast<entropic::ToolExecutor*>(ud)
->process_tool_calls(ctx, calls);
};
tei.user_data = h->tool_executor.get();
tei.history_json = tool_history_json_thunk; // P1-11
tei.free_fn = [](char* p) { std::free(p); };
// gh#166 (v2.13.0): a bound session's tool calls run against its
// workspace's own server instances, not the handle's default set.
h->tool_executor->set_server_resolver(
+[](const std::string& key, void* ud)
-> entropic::ServerManager* {
return entropic::workspace_servers(
static_cast<entropic_handle_t>(ud), key);
}, h);
h->engine->set_tool_executor(tei);
}