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

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
lines 109–109◇ if (!src)lines 109–109return nullptr;lines 110–110size_t len = std::strlen(src) + 1;lines 111–111auto* dst = static_cast<char*>(entropic_alloc(len));lines 112–112◇ if (dst)lines 112–112std::memcpy(dst, src, len);lines 113–113return dst;
static char * alloc_cstr(const std::string &src)

Allocate a C string copy from std::string.

src/facade/entropic.cpp:123

Show on the map →

Called by none

Calls alloc_cstr

Source · 3 lines
static char* alloc_cstr(const std::string& src) {
    return alloc_cstr(src.c_str());
}
Activity · 1 steps
lines 124–124return alloc_cstr(src.c_str());

Requirements

REQ-API-008

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
lines 1005–1005◇ if (fm.allowed_tools.has_value())lines 1006–1006h->tier_allowed_tools[name] = *fm.allowed_tools;lines 1008–1008◇ if (!fm.validation_rules.empty())lines 1009–1009h->tier_validation_rules[name] = fm.validation_rules;lines 1011–1011◇ if (fm.relay_single_delegate)lines 1012–1012h->engine->set_relay_single_delegate(name);

Requirements

REQ-API-013

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

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
lines 78–78entropic_error_t rc = ENTROPIC_ERROR_INTERNAL;lines 79–93try { 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; }lines 94–94return rc;

Requirements

REQ-ABI-002

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

Show on the map →

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
lines 1031–1031◇ for (const auto& [name, tier] : h->config.models.tiers)lines 1032–1032std::filesystem::path id_path;lines 1033–1033◇ if (tier.identity.has_value())lines 1034–1034id_path = tier.identity.value();lines 1035–1035elselines 1035–1035◇ if (!tier.identity_disabled)lines 1036–1036id_path = data_dir / "prompts" / ("identity_" + name + ".md");lines 1038–1038◇ if (id_path.empty() || !std::filesystem::exists(id_path))lines 1039–1039continue;lines 1041–1041entropic::prompts::ParsedIdentity id;lines 1042–1042◇ if (entropic::prompts::load_identity(id_path, id).empty())lines 1043–1043apply_identity_frontmatter(h, name, id.frontmatter);lines 1049–1049◇ if (h->tool_executor)lines 1050–1050h->tool_executor->set_tier_allowed_tools(&h->tier_allowed_tools);

Requirements

REQ-API-013

check_identity

static entropic_error_t check_identity(entropic_handle_t h)

Check handle prerequisites for identity manager APIs.

src/facade/entropic.cpp:201

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
lines 202–202◇ if (!h)lines 202–202return ENTROPIC_ERROR_INVALID_HANDLE;lines 203–203◇ if (!h->configured.load() || !h->identity_manager)lines 204–204return ENTROPIC_ERROR_INVALID_STATE;lines 206–206return ENTROPIC_OK;

Requirements

REQ-API-005

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

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
lines 187–187◇ if (!h)lines 187–187return ENTROPIC_ERROR_INVALID_HANDLE;lines 188–188◇ if (!h->configured.load() || !h->mcp_auth)lines 189–189return ENTROPIC_ERROR_INVALID_STATE;lines 191–191return ENTROPIC_OK;

Requirements

REQ-API-005

check_orchestrator

static entropic_error_t check_orchestrator(entropic_handle_t h)

Check handle prerequisites for orchestrator APIs.

src/facade/entropic.cpp:171

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
lines 172–172◇ if (!h)lines 172–172return ENTROPIC_ERROR_INVALID_HANDLE;lines 173–173◇ if (!h->configured.load() || !h->orchestrator)lines 174–174return ENTROPIC_ERROR_INVALID_STATE;lines 176–176return ENTROPIC_OK;

Requirements

REQ-API-005

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

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
lines 2065–2065auto rc = reject_if_configured(h);lines 2066–2066◇ if (rc != ENTROPIC_OK)lines 2066–2066return rc;lines 2072–2072entropic::log::set_console_enabled(h->config.console_logging);lines 2073–2073auto data_dir = entropic::config::resolve_data_dir(h->config);lines 2077–2077rc = validate_prompt_sources(h, data_dir);lines 2078–2078◇ if (rc == ENTROPIC_OK)lines 2083–2083thread_frontmatter_samplers(h, data_dir);lines 2089–2089warn_tier_grammars_step(h, data_dir);lines 2091–2091◇ if (rc == ENTROPIC_OK)lines 2092–2092rc = init_orchestrator(h, data_dir);lines 2094–2094◇ if (rc != ENTROPIC_OK)lines 2094–2094return rc;lines 2096–2096init_engine_and_interfaces(h, data_dir);lines 2097–2097wire_prompts_and_persistence(h, data_dir);lines 2099–2099h->configured.store(true);lines 2100–2100start_external_bridge(h);lines 2103–2103const auto http_rc = start_http_listener(h);lines 2104–2104s_log->info("configure complete");lines 2105–2105return http_rc;

Requirements

REQ-API-004

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

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
lines 2226–2226◇ if (project_dir && project_dir[0] != '\0')lines 2227–2227entropic::log::setup_session(project_dir);lines 2231–2231entropic::log::register_handle_log(handle->log_id, project_dir);lines 2233–2233handle->bundled_models.auto_discover_and_load();lines 2234–2235std::filesystem::path proj_dir = (project_dir && project_dir[0] != '\0') ? project_dir : "";lines 2236–2238auto err = entropic::config::load_layered( proj_dir, "default_config.yaml", handle->bundled_models, handle->config);lines 2239–2239◇ if (!err.empty())lines 2240–2240handle->last_error = err;lines 2241–2241s_log->error("configure_dir: {}", err);lines 2242–2242return ENTROPIC_ERROR_INVALID_CONFIG;lines 2244–2244auto rc = configure_common(handle);lines 2248–2248◇ if (rc == ENTROPIC_OK && handle->engine && !proj_dir.empty())lines 2249–2249handle->engine->set_project_dir(std::filesystem::absolute(proj_dir));lines 2251–2251return rc;

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

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
lines 2170–2170handle->bundled_models.auto_discover_and_load();lines 2171–2172auto err = entropic::config::load_config_from_file( config_path, handle->bundled_models, handle->config);lines 2173–2173◇ if (!err.empty())lines 2174–2174handle->last_error = err;lines 2175–2175s_log->error("configure_from_file: {}", err);lines 2176–2176return ENTROPIC_ERROR_INVALID_CONFIG;lines 2182–2182◇ if (!handle->config.log_dir.empty())lines 2183–2183entropic::log::setup_session(handle->config.log_dir);lines 2187–2188entropic::log::register_handle_log( handle->log_id, handle->config.log_dir);lines 2190–2190return configure_common(handle);

Requirements

REQ-ABI-002 REQ-API-004

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

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
lines 2117–2117handle->bundled_models.auto_discover_and_load();lines 2118–2119auto err = entropic::config::load_config_from_string( config_json, handle->bundled_models, handle->config);lines 2120–2120◇ if (!err.empty())lines 2121–2121handle->last_error = err;lines 2122–2122s_log->error("configure: {}", err);lines 2123–2123return ENTROPIC_ERROR_INVALID_CONFIG;lines 2131–2131◇ if (!handle->config.log_dir.empty())lines 2132–2132entropic::log::setup_session(handle->config.log_dir);lines 2133–2134entropic::log::register_handle_log( handle->log_id, handle->config.log_dir);lines 2136–2136return configure_common(handle);

Requirements

REQ-ABI-002 REQ-API-004

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

Show on the map →

Called by TEST_CASE

Calls adapter_manager, alloc_cstr, serialize_adapter_info

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
lines 4216–4217◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !adapter_name)lines 4218–4218return nullptr;lines 4220–4228try { 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; }
char * entropic_adapter_info(entropic_handle_t handle, const char *adapter_name)

Get adapter info as JSON string.

src/facade/entropic.cpp:4212

Show on the map →

Called by TEST_CASE

Calls alloc_cstr, serialize_adapter_info

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
lines 4216–4217◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !adapter_name)lines 4218–4218return nullptr;lines 4220–4228try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-023

entropic_adapter_list

ENTROPIC_EXPORT char * entropic_adapter_list(entropic_handle_t handle)

List all adapters as JSON array.

src/facade/entropic.cpp:4244

Show on the map →

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
lines 4246–4246◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4247–4247return nullptr;lines 4249–4257try { 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; }
char * entropic_adapter_list(entropic_handle_t handle)

List all known adapters as a JSON array.

src/facade/entropic.cpp:4244

Show on the map →

Called by SCENARIO, TEST_CASE

Calls 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
lines 4246–4246◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4247–4247return nullptr;lines 4249–4257try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-023

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

Show on the map →

Called by TEST_CASE

Calls c_api_try, check_orchestrator, claim, do_adapter_load

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
lines 4073–4073auto rc = check_orchestrator(handle);lines 4075–4075entropic::HandleTurnGuard turn(handle);lines 4076–4078◇ if (rc != ENTROPIC_OK || !adapter_name || !adapter_path || !base_model_path || (handle->engine != nullptr && !turn.claim()))lines 4079–4082return rc != ENTROPIC_OK ? rc : (!adapter_name || !adapter_path || !base_model_path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 4084–4084entropic::HandleApiLock lock(handle);lines 4085–4088return c_api_try(handle, [&]() { return do_adapter_load(handle, adapter_name, adapter_path, base_model_path, scale); });
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

Show on the map →

Called by TEST_CASE

Calls c_api_try, check_orchestrator, claim, do_adapter_load

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
lines 4073–4073auto rc = check_orchestrator(handle);lines 4075–4075entropic::HandleTurnGuard turn(handle);lines 4076–4078◇ if (rc != ENTROPIC_OK || !adapter_name || !adapter_path || !base_model_path || (handle->engine != nullptr && !turn.claim()))lines 4079–4082return rc != ENTROPIC_OK ? rc : (!adapter_name || !adapter_path || !base_model_path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 4084–4084entropic::HandleApiLock lock(handle);lines 4085–4088return c_api_try(handle, [&]() { return do_adapter_load(handle, adapter_name, adapter_path, base_model_path, scale); });

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-023

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls adapter_manager

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
lines 4185–4186◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !adapter_name)lines 4187–4187return -1;lines 4189–4196try { 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; }
int entropic_adapter_state(entropic_handle_t handle, const char *adapter_name)

Query adapter lifecycle state.

src/facade/entropic.cpp:4181

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 4185–4186◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !adapter_name)lines 4187–4187return -1;lines 4189–4196try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-023

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

Show on the map →

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
lines 4148–4148auto rc = check_orchestrator(handle);lines 4149–4149◇ if (rc != ENTROPIC_OK || !adapter_name)lines 4150–4150return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4152–4166try { 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; }
entropic_error_t entropic_adapter_swap(entropic_handle_t handle, const char *adapter_name)

Swap active LoRA adapter.

src/facade/entropic.cpp:4144

Show on the map →

Called by TEST_CASE

Calls check_orchestrator

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
lines 4148–4148auto rc = check_orchestrator(handle);lines 4149–4149◇ if (rc != ENTROPIC_OK || !adapter_name)lines 4150–4150return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4152–4166try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-023

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

Show on the map →

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
lines 4108–4108auto rc = check_orchestrator(handle);lines 4109–4109◇ if (rc != ENTROPIC_OK || !adapter_name)lines 4110–4110return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4112–4128try { 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; }
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
lines 4108–4108auto rc = check_orchestrator(handle);lines 4109–4109◇ if (rc != ENTROPIC_OK || !adapter_name)lines 4110–4110return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4112–4128try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-023

entropic_alloc

ENTROPIC_EXPORT void * entropic_alloc(size_t size)

Allocate memory using the engine's allocator.

src/facade/entropic.cpp:2379

Show on the map →

Called by none

Calls none

Source · 3 lines
void* entropic_alloc(size_t size) {
    return malloc(size);
}
Activity · 1 steps
lines 2380–2380return malloc(size);
void * entropic_alloc(size_t size)

Allocate memory using the engine's allocator.

src/facade/entropic.cpp:2379

Show on the map →

Called by TEST_CASE, _alloc_c_string, _build_trampoline, alloc_cstr

Calls none

Source · 3 lines
void* entropic_alloc(size_t size) {
    return malloc(size);
}
Activity · 1 steps
lines 2380–2380return malloc(size);

Requirements

REQ-ABI-001 REQ-API-008

entropic_api_version

ENTROPIC_EXPORT int entropic_api_version(void)

Get the C API version number.

src/facade/entropic.cpp:2354

Show on the map →

Called by SCENARIO, TEST_CASE, main, main

Calls none

Source · 3 lines
int entropic_api_version(void) {
    return 2;
}
Activity · 1 steps
lines 2355–2355return 2;
int entropic_api_version(void)

Get the plugin API version number.

src/facade/entropic.cpp:2354

Show on the map →

Called by SCENARIO, TEST_CASE, main, main

Calls none

Source · 3 lines
int entropic_api_version(void) {
    return 2;
}
Activity · 1 steps
lines 2355–2355return 2;

Requirements

REQ-ABI-001 REQ-TYPE-002

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_access

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
lines 4724–4725◇ if (!handle || !handle->configured.load() || !handle->mcp_auth || !identity_name || !tool_name)lines 4726–4726return -1;lines 4728–4728auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4729–4729return handle->mcp_auth->check_access(identity_name, tool_name, lvl) ? 1 : 0;
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 4724–4725◇ if (!handle || !handle->configured.load() || !handle->mcp_auth || !identity_name || !tool_name)lines 4726–4726return -1;lines 4728–4728auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4729–4729return handle->mcp_auth->check_access(identity_name, tool_name, lvl) ? 1 : 0;

Requirements

REQ-API-005 REQ-MCP-010

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls clear_user_message_queue

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
lines 3271–3271◇ if (!handle)lines 3271–3271return ENTROPIC_ERROR_INVALID_HANDLE;lines 3272–3272◇ if (handle->engine)lines 3273–3273handle->engine->clear_user_message_queue();lines 3275–3275return ENTROPIC_OK;
entropic_error_t entropic_clear_user_message_queue(entropic_handle_t handle)

Drop all queued mid-gen user messages.

src/facade/entropic.cpp:3269

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 3271–3271◇ if (!handle)lines 3271–3271return ENTROPIC_ERROR_INVALID_HANDLE;lines 3272–3272◇ if (handle->engine)lines 3273–3273handle->engine->clear_user_message_queue();lines 3275–3275return ENTROPIC_OK;

Requirements

REQ-ABI-001 REQ-API-005

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
lines 5083–5083auto rc = check_orchestrator(handle);lines 5085–5085entropic::HandleTurnGuard turn(handle);lines 5086–5087◇ if (rc != ENTROPIC_OK || !model_id || !tokens || !perplexity || n_tokens < 2 || (handle->engine != nullptr && !turn.claim()))lines 5088–5091return rc != ENTROPIC_OK ? rc : (!model_id || !tokens || !perplexity || n_tokens < 2) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5093–5102try { 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; }
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
lines 5083–5083auto rc = check_orchestrator(handle);lines 5085–5085entropic::HandleTurnGuard turn(handle);lines 5086–5087◇ if (rc != ENTROPIC_OK || !model_id || !tokens || !perplexity || n_tokens < 2 || (handle->engine != nullptr && !turn.claim()))lines 5088–5091return rc != ENTROPIC_OK ? rc : (!model_id || !tokens || !perplexity || n_tokens < 2) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5093–5102try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-024

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

Show on the map →

Called by ConfiguredCapiHandle, ConfiguredHandle, GateHandle, Handle, Handle, Handle, RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO

6 moreSCENARIO, 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
lines 2152–2152◇ if (!handle || !config_json)lines 2153–2154return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 2156–2156entropic::HandleApiLock lock(handle);lines 2157–2158return c_api_try(handle, [&]() { return do_configure_json(handle, config_json); });
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

Show on the map →

Called by ConfiguredCapiHandle, ConfiguredHandle, GateHandle, Handle, Handle, Handle, RootsHandle, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO

6 moreSCENARIO, 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
lines 2152–2152◇ if (!handle || !config_json)lines 2153–2154return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 2156–2156entropic::HandleApiLock lock(handle);lines 2157–2158return c_api_try(handle, [&]() { return do_configure_json(handle, config_json); });

Requirements

REQ-ABI-001 REQ-ABI-002 REQ-API-004 REQ-API-005

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

Show on the map →

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
lines 2273–2273◇ if (!handle)lines 2273–2273return ENTROPIC_ERROR_INVALID_HANDLE;lines 2274–2274entropic::HandleApiLock lock(handle);lines 2275–2276return c_api_try(handle, [&]() { return do_configure_dir(handle, project_dir); });
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

Show on the map →

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
lines 2273–2273◇ if (!handle)lines 2273–2273return ENTROPIC_ERROR_INVALID_HANDLE;lines 2274–2274entropic::HandleApiLock lock(handle);lines 2275–2276return c_api_try(handle, [&]() { return do_configure_dir(handle, project_dir); });

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

Show on the map →

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
lines 2206–2206◇ if (!handle || !config_path)lines 2207–2208return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 2210–2210entropic::HandleApiLock lock(handle);lines 2211–2212return c_api_try(handle, [&]() { return do_configure_from_file(handle, config_path); });
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

Show on the map →

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
lines 2206–2206◇ if (!handle || !config_path)lines 2207–2208return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 2210–2210entropic::HandleApiLock lock(handle);lines 2211–2212return c_api_try(handle, [&]() { return do_configure_from_file(handle, config_path); });

Requirements

REQ-ABI-001 REQ-ABI-002 REQ-API-004 REQ-API-005

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

Show on the map →

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
lines 3322–3322◇ if (!handle || !handle->engine)lines 3322–3322return ENTROPIC_ERROR_INVALID_HANDLE;lines 3323–3323entropic::HandleApiLock lock(handle);lines 3324–3324const auto key = handle->engine->active_session_key();lines 3325–3325handle->engine->clear_conversation();lines 3326–3326entropic::release_session_tool_state(handle, key);lines 3327–3327return ENTROPIC_OK;
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
lines 3322–3322◇ if (!handle || !handle->engine)lines 3322–3322return ENTROPIC_ERROR_INVALID_HANDLE;lines 3323–3323entropic::HandleApiLock lock(handle);lines 3324–3324const auto key = handle->engine->active_session_key();lines 3325–3325handle->engine->clear_conversation();lines 3326–3326entropic::release_session_tool_state(handle, key);lines 3327–3327return ENTROPIC_OK;

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

Show on the map →

Called by TEST_CASE, check_context_count, handle_status

Calls message_count

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
lines 3840–3840◇ if (!handle || !count || !handle->engine)lines 3841–3843return (handle != nullptr && count == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3845–3845*count = handle->engine->message_count();lines 3846–3846return ENTROPIC_OK;
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
lines 3840–3840◇ if (!handle || !count || !handle->engine)lines 3841–3843return (handle != nullptr && count == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3845–3845*count = handle->engine->message_count();lines 3846–3846return ENTROPIC_OK;

Requirements

REQ-ABI-001 REQ-API-005

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

Show on the map →

Called by TEST_CASE, TEST_CASE

Calls alloc_cstr, get_messages, serialize_messages

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
lines 3351–3351◇ if (!handle || !messages_json || !handle->engine)lines 3352–3354return (handle != nullptr && messages_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3356–3356entropic::HandleApiLock lock(handle);lines 3357–3358*messages_json = alloc_cstr( facade_json::serialize_messages(handle->engine->get_messages()));lines 3359–3359return ENTROPIC_OK;
entropic_error_t entropic_context_get(entropic_handle_t handle, char **messages_json)

Get conversation as JSON array.

src/facade/entropic.cpp:3340

Show on the map →

Called by TEST_CASE, TEST_CASE

Calls alloc_cstr, serialize_messages

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
lines 3351–3351◇ if (!handle || !messages_json || !handle->engine)lines 3352–3354return (handle != nullptr && messages_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3356–3356entropic::HandleApiLock lock(handle);lines 3357–3358*messages_json = alloc_cstr( facade_json::serialize_messages(handle->engine->get_messages()));lines 3359–3359return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-008 REQ-SAFE-001

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

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE

Calls context_usage, get_messages

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
lines 3868–3868◇ if (!handle || !handle->engine)lines 3868–3868return ENTROPIC_ERROR_INVALID_HANDLE;lines 3869–3869◇ if (!tokens_used || !capacity)lines 3869–3869return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3870–3870entropic::HandleApiLock lock(handle);lines 3871–3872auto [used, max] = handle->engine->context_usage( handle->engine->get_messages());lines 3873–3873*tokens_used = static_cast<size_t>(used);lines 3874–3874*capacity = static_cast<size_t>(max);lines 3875–3875return max > 0 ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_STATE;
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

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE

Calls none

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
lines 3868–3868◇ if (!handle || !handle->engine)lines 3868–3868return ENTROPIC_ERROR_INVALID_HANDLE;lines 3869–3869◇ if (!tokens_used || !capacity)lines 3869–3869return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3870–3870entropic::HandleApiLock lock(handle);lines 3871–3872auto [used, max] = handle->engine->context_usage( handle->engine->get_messages());lines 3873–3873*tokens_used = static_cast<size_t>(used);lines 3874–3874*capacity = static_cast<size_t>(max);lines 3875–3875return max > 0 ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_STATE;

Requirements

REQ-ABI-001 REQ-API-005

entropic_create

ENTROPIC_EXPORT entropic_error_t entropic_create(entropic_handle_t *handle)

Create a new engine instance.

src/facade/entropic.cpp:262

Show on the map →

Called by BridgeHandle, ConfiguredCapiHandle, ConfiguredHandle, CreatedOnlyHandle, Fixture, GateHandle, Handle, Handle, Handle, HandleGuard, HandleGuard, RawHandle

21 moreRootsHandle, 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

Calls entropic_inference_log_silence, init

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
lines 263–263◇ if (handle == nullptr)lines 264–264return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 266–266entropic::log::init(spdlog::level::info);lines 267–267entropic_inference_log_silence();lines 269–269auto* engine = new (std::nothrow) entropic_engine();lines 270–270◇ if (engine == nullptr)lines 271–271*handle = nullptr;lines 272–272return ENTROPIC_ERROR_OUT_OF_MEMORY;lines 279–279static std::atomic<int> s_log_id_counter{0};lines 280–280engine->log_id = ++s_log_id_counter;lines 282–283s_log->info("entropic_create() — v{} (log_id={})", CONFIG_ENTROPIC_VERSION_STRING, engine->log_id);lines 285–285*handle = engine;lines 286–286return ENTROPIC_OK;
entropic_error_t entropic_create(entropic_handle_t *handle)

Create a new engine instance.

src/facade/entropic.cpp:262

Show on the map →

Called by BridgeHandle, ConfiguredCapiHandle, ConfiguredHandle, CreatedOnlyHandle, Fixture, GateHandle, Handle, Handle, Handle, HandleGuard, HandleGuard, RawHandle

21 moreRootsHandle, 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

Calls entropic_inference_log_silence, init

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
lines 263–263◇ if (handle == nullptr)lines 264–264return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 266–266entropic::log::init(spdlog::level::info);lines 267–267entropic_inference_log_silence();lines 269–269auto* engine = new (std::nothrow) entropic_engine();lines 270–270◇ if (engine == nullptr)lines 271–271*handle = nullptr;lines 272–272return ENTROPIC_ERROR_OUT_OF_MEMORY;lines 279–279static std::atomic<int> s_log_id_counter{0};lines 280–280engine->log_id = ++s_log_id_counter;lines 282–283s_log->info("entropic_create() — v{} (log_id={})", CONFIG_ENTROPIC_VERSION_STRING, engine->log_id);lines 285–285*handle = engine;lines 286–286return ENTROPIC_OK;

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity, create

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
lines 4846–4846auto rc = check_identity(handle);lines 4847–4847◇ if (rc != ENTROPIC_OK || !config_json)lines 4848–4848return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4850–4863try { 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; }
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity

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
lines 4846–4846auto rc = check_identity(handle);lines 4847–4847◇ if (rc != ENTROPIC_OK || !config_json)lines 4848–4848return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4850–4863try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-IDEN-002

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

Show on the map →

Called by TEST_CASE

Calls check_mcp_auth, deserialize_all

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
lines 4823–4823auto rc = check_mcp_auth(handle);lines 4824–4824◇ if (rc != ENTROPIC_OK || !json)lines 4825–4825return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4827–4827bool ok = handle->mcp_auth->deserialize_all(json);lines 4828–4828return ok ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_CONFIG;
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

Show on the map →

Called by TEST_CASE

Calls check_mcp_auth

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
lines 4823–4823auto rc = check_mcp_auth(handle);lines 4824–4824◇ if (rc != ENTROPIC_OK || !json)lines 4825–4825return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4827–4827bool ok = handle->mcp_auth->deserialize_all(json);lines 4828–4828return ok ? ENTROPIC_OK : ENTROPIC_ERROR_INVALID_CONFIG;

Requirements

REQ-API-005 REQ-MCP-010

entropic_destroy

ENTROPIC_EXPORT void entropic_destroy(entropic_handle_t handle)

Destroy an engine instance and free all resources.

src/facade/entropic.cpp:2291

Show on the map →

Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE

25 moremain, 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
lines 2292–2292◇ if (handle == nullptr)lines 2293–2293return;lines 2295–2295s_log->info("entropic_destroy()");lines 2299–2299handle->http_listener.reset();lines 2300–2300◇ if (handle->external_bridge)lines 2301–2301handle->external_bridge->stop();lines 2302–2302handle->external_bridge.reset();lines 2305–2305entropic_inference_log_silence();lines 2310–2310entropic::destroy_orchestrator_interface(handle->inference_iface_ctx);lines 2311–2311handle->inference_iface_ctx = nullptr;lines 2318–2318std::lock_guard<std::mutex> guard(handle->workspace_mutex);lines 2319–2319◇ for (auto& [name, ws] : handle->workspaces)lines 2320–2320◇ if (ws && ws->servers)lines 2320–2320ws->servers->shutdown();lines 2322–2322handle->workspaces.clear();lines 2323–2323handle->session_workspace.clear();lines 2329–2329entropic::log::unregister_handle_log(handle->log_id);lines 2333–2333delete handle;
void entropic_destroy(entropic_handle_t handle)

Destroy an engine instance.

src/facade/entropic.cpp:2291

Show on the map →

Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE

25 moremain, 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
lines 2292–2292◇ if (handle == nullptr)lines 2293–2293return;lines 2295–2295s_log->info("entropic_destroy()");lines 2299–2299handle->http_listener.reset();lines 2300–2300◇ if (handle->external_bridge)lines 2301–2301handle->external_bridge->stop();lines 2302–2302handle->external_bridge.reset();lines 2305–2305entropic_inference_log_silence();lines 2310–2310entropic::destroy_orchestrator_interface(handle->inference_iface_ctx);lines 2311–2311handle->inference_iface_ctx = nullptr;lines 2318–2318std::lock_guard<std::mutex> guard(handle->workspace_mutex);lines 2319–2319◇ for (auto& [name, ws] : handle->workspaces)lines 2320–2320◇ if (ws && ws->servers)lines 2320–2320ws->servers->shutdown();lines 2322–2322handle->workspaces.clear();lines 2323–2323handle->session_workspace.clear();lines 2329–2329entropic::log::unregister_handle_log(handle->log_id);lines 2333–2333delete handle;

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity, destroy

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
lines 4912–4912auto rc = check_identity(handle);lines 4913–4913◇ if (rc != ENTROPIC_OK || !name)lines 4914–4914return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4916–4916return handle->identity_manager->destroy(name);
entropic_error_t entropic_destroy_identity(entropic_handle_t handle, const char *name)

Destroy a dynamic identity.

src/facade/entropic.cpp:4908

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity

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
lines 4912–4912auto rc = check_identity(handle);lines 4913–4913◇ if (rc != ENTROPIC_OK || !name)lines 4914–4914return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4916–4916return handle->identity_manager->destroy(name);

Requirements

REQ-API-005 REQ-IDEN-002

entropic_free

ENTROPIC_EXPORT void entropic_free(void *ptr)

Free a string allocated by the server.

src/facade/entropic.cpp:2390

Show on the map →

Called by none

Calls none

Source · 3 lines
void entropic_free(void* ptr) {
    free(ptr);
}
Activity · 1 steps
lines 2391–2391free(ptr);
ENTROPIC_EXPORT void entropic_free(void *ptr)

Free memory allocated by the engine or entropic_alloc().

src/facade/entropic.cpp:2390

Show on the map →

Called by SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, derive_async_final_state

11 morefinal_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
lines 2391–2391free(ptr);
void entropic_free(void *ptr)

Free memory allocated by the engine.

src/facade/entropic.cpp:2390

Show on the map →

Called by none

Calls none

Source · 3 lines
void entropic_free(void* ptr) {
    free(ptr);
}
Activity · 1 steps
lines 2391–2391free(ptr);

Requirements

REQ-ABI-001 REQ-API-008

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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 5117–5117◇ if (result == nullptr)lines 5118–5118return;lines 5120–5120free(result->logprobs);lines 5121–5121result->logprobs = nullptr;lines 5122–5122free(result->tokens);lines 5123–5123result->tokens = nullptr;
void entropic_free_logprob_result(entropic_logprob_result_t *result)

Free internal arrays of a logprob result.

src/facade/entropic.cpp:5115

Show on the map →

Called by TEST_CASE

Calls none

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
lines 5117–5117◇ if (result == nullptr)lines 5118–5118return;lines 5120–5120free(result->logprobs);lines 5121–5121result->logprobs = nullptr;lines 5122–5122free(result->tokens);lines 5123–5123result->tokens = nullptr;

Requirements

REQ-ABI-001 REQ-API-008

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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 5242–5242◇ if (handle == nullptr || prompt_out == nullptr)lines 5243–5243return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 5245–5245(void)handle;lines 5246–5266static 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";lines 5267–5267*prompt_out = alloc_cstr(prompt);lines 5268–5268return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 5242–5242◇ if (handle == nullptr || prompt_out == nullptr)lines 5243–5243return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 5245–5245(void)handle;lines 5246–5266static 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";lines 5267–5267*prompt_out = alloc_cstr(prompt);lines 5268–5268return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-008

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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr, get

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
lines 4933–4933◇ if (!handle || !handle->identity_manager || !name)lines 4933–4933return nullptr;lines 4934–4945try { 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; }
char * entropic_get_identity_config(entropic_handle_t handle, const char *name)

Get identity config as JSON by name.

src/facade/entropic.cpp:4929

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 4933–4933◇ if (!handle || !handle->identity_manager || !name)lines 4933–4933return nullptr;lines 4934–4945try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-IDEN-002

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

Show on the map →

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
lines 5041–5041auto rc = check_orchestrator(handle);lines 5043–5043entropic::HandleTurnGuard turn(handle);lines 5044–5045◇ if (rc != ENTROPIC_OK || !model_id || !tokens || !result || n_tokens < 2 || (handle->engine != nullptr && !turn.claim()))lines 5046–5049return rc != ENTROPIC_OK ? rc : (!model_id || !tokens || !result || n_tokens < 2) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5051–5061try { 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; }
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

Show on the map →

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
lines 5041–5041auto rc = check_orchestrator(handle);lines 5043–5043entropic::HandleTurnGuard turn(handle);lines 5044–5045◇ if (rc != ENTROPIC_OK || !model_id || !tokens || !result || n_tokens < 2 || (handle->engine != nullptr && !turn.claim()))lines 5046–5049return rc != ENTROPIC_OK ? rc : (!model_id || !tokens || !result || n_tokens < 2) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5051–5061try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-024

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator, grammar_registry

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
lines 4350–4350auto rc = check_orchestrator(handle);lines 4351–4351◇ if (rc != ENTROPIC_OK || !key)lines 4352–4352return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4354–4363try { 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; }
entropic_error_t entropic_grammar_deregister(entropic_handle_t handle, const char *key)

Remove a grammar from the registry.

src/facade/entropic.cpp:4346

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator

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
lines 4350–4350auto rc = check_orchestrator(handle);lines 4351–4351◇ if (rc != ENTROPIC_OK || !key)lines 4352–4352return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4354–4363try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, grammar_registry

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
lines 4383–4384◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !key)lines 4385–4385return nullptr;lines 4387–4394try { 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; }
char * entropic_grammar_get(entropic_handle_t handle, const char *key)

Get grammar GBNF content by key.

src/facade/entropic.cpp:4379

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr

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
lines 4383–4384◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !key)lines 4385–4385return nullptr;lines 4387–4394try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, grammar_registry

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
lines 4437–4437◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4438–4438return nullptr;lines 4440–4454try { 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; }
char * entropic_grammar_list(entropic_handle_t handle)

List all registered grammars as a JSON array.

src/facade/entropic.cpp:4435

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr

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
lines 4437–4437◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4438–4438return nullptr;lines 4440–4454try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator, grammar_registry

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
lines 4281–4281auto rc = check_orchestrator(handle);lines 4282–4282◇ if (rc != ENTROPIC_OK || !key || !gbnf_content)lines 4283–4283return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4285–4295try { 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; }
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator

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
lines 4281–4281auto rc = check_orchestrator(handle);lines 4282–4282◇ if (rc != ENTROPIC_OK || !key || !gbnf_content)lines 4283–4283return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4285–4295try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE, setup

Calls check_orchestrator, grammar_registry

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
lines 4316–4316auto rc = check_orchestrator(handle);lines 4317–4317◇ if (rc != ENTROPIC_OK || !key || !path)lines 4318–4318return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4320–4330try { 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; }
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

Show on the map →

Called by SCENARIO, TEST_CASE, setup

Calls check_orchestrator

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
lines 4316–4316auto rc = check_orchestrator(handle);lines 4317–4317◇ if (rc != ENTROPIC_OK || !key || !path)lines 4318–4318return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4320–4330try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, validate

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
lines 4412–4412◇ if (!gbnf_content)lines 4412–4412return alloc_cstr("null input");lines 4413–4418try { 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()); }
char * entropic_grammar_validate(const char *gbnf_content)

Validate a GBNF grammar string without registering.

src/facade/entropic.cpp:4411

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, validate

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
lines 4412–4412◇ if (!gbnf_content)lines 4412–4412return alloc_cstr("null input");lines 4413–4418try { 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()); }

Requirements

REQ-ABI-001 REQ-ABI-002 REQ-API-008 REQ-INFER-007

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_mcp_auth, grant

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
lines 4682–4682auto rc = check_mcp_auth(handle);lines 4683–4683◇ if (rc != ENTROPIC_OK || !identity_name || !pattern)lines 4684–4684return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4686–4686auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4687–4687return handle->mcp_auth->grant(identity_name, pattern, lvl);
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_mcp_auth

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
lines 4682–4682auto rc = check_mcp_auth(handle);lines 4683–4683◇ if (rc != ENTROPIC_OK || !identity_name || !pattern)lines 4684–4684return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4686–4686auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4687–4687return handle->mcp_auth->grant(identity_name, pattern, lvl);

Requirements

REQ-API-005 REQ-MCP-010

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

Show on the map →

Called by TEST_CASE

Calls check_mcp_auth, grant_from

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
lines 4779–4779auto rc = check_mcp_auth(handle);lines 4780–4780◇ if (rc != ENTROPIC_OK || !granter || !grantee || !pattern)lines 4781–4781return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4783–4783auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4784–4784return handle->mcp_auth->grant_from(granter, grantee, pattern, lvl);
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

Show on the map →

Called by TEST_CASE

Calls check_mcp_auth

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
lines 4779–4779auto rc = check_mcp_auth(handle);lines 4780–4780◇ if (rc != ENTROPIC_OK || !granter || !grantee || !pattern)lines 4781–4781return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4783–4783auto lvl = static_cast<entropic::MCPAccessLevel>(level);lines 4784–4784return handle->mcp_auth->grant_from(granter, grantee, pattern, lvl);

Requirements

REQ-API-005 REQ-MCP-010

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity, count, count_dynamic

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
lines 4983–4983auto rc = check_identity(handle);lines 4984–4984◇ if (rc != ENTROPIC_OK || !total)lines 4985–4985return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4987–4987*total = handle->identity_manager->count();lines 4988–4988◇ if (dynamic)lines 4988–4988*dynamic = handle->identity_manager->count_dynamic();lines 4989–4989return ENTROPIC_OK;
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_identity

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
lines 4983–4983auto rc = check_identity(handle);lines 4984–4984◇ if (rc != ENTROPIC_OK || !total)lines 4985–4985return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4987–4987*total = handle->identity_manager->count();lines 4988–4988◇ if (dynamic)lines 4988–4988*dynamic = handle->identity_manager->count_dynamic();lines 4989–4989return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-IDEN-002

entropic_interrupt

ENTROPIC_EXPORT entropic_error_t entropic_interrupt(entropic_handle_t handle)

Interrupt a running generation.

src/facade/entropic.cpp:3177

Show on the map →

Called by SCENARIO, TEST_CASE

Calls interrupt

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
lines 3178–3178◇ if (!handle)lines 3178–3178return ENTROPIC_ERROR_INVALID_HANDLE;lines 3179–3179◇ if (!handle->engine)lines 3179–3179return ENTROPIC_ERROR_INVALID_STATE;lines 3180–3180handle->engine->interrupt();lines 3181–3181return ENTROPIC_OK;
entropic_error_t entropic_interrupt(entropic_handle_t handle)

Interrupt a running generation (thread-safe).

src/facade/entropic.cpp:3177

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 3178–3178◇ if (!handle)lines 3178–3178return ENTROPIC_ERROR_INVALID_HANDLE;lines 3179–3179◇ if (!handle->engine)lines 3179–3179return ENTROPIC_ERROR_INVALID_STATE;lines 3180–3180handle->engine->interrupt();lines 3181–3181return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-009 REQ-LOOP-006

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
lines 3202–3202◇ if (!handle)lines 3202–3202return ENTROPIC_ERROR_INVALID_HANDLE;lines 3203–3203◇ if (!handle->engine)lines 3203–3203return ENTROPIC_ERROR_INVALID_STATE;lines 3204–3205const bool found = handle->engine->interrupt_session( session_key != nullptr ? session_key : "");lines 3206–3206return found ? ENTROPIC_OK : ENTROPIC_ERROR_NOT_RUNNING;
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

Show on the map →

Called by SCENARIO, TEST_CASE, cancel_inflight_async_tasks

Calls none

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
lines 3202–3202◇ if (!handle)lines 3202–3202return ENTROPIC_ERROR_INVALID_HANDLE;lines 3203–3203◇ if (!handle->engine)lines 3203–3203return ENTROPIC_ERROR_INVALID_STATE;lines 3204–3205const bool found = handle->engine->interrupt_session( session_key != nullptr ? session_key : "");lines 3206–3206return found ? ENTROPIC_OK : ENTROPIC_ERROR_NOT_RUNNING;

Requirements

REQ-API-009 REQ-LOOP-006

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

Show on the map →

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 moremain, 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
lines 158–158◇ if (!handle)lines 158–158return s_pre_create_error;lines 159–159entropic::HandleApiLock lock(handle);lines 160–160s_last_error_cache = handle->last_error;lines 161–161return s_last_error_cache.c_str();
const char * entropic_last_error(entropic_handle_t handle)

Read the per-handle last_error under api_mutex.

src/facade/entropic.cpp:157

Show on the map →

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 moremain, 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
lines 158–158◇ if (!handle)lines 158–158return s_pre_create_error;lines 159–159entropic::HandleApiLock lock(handle);lines 160–160s_last_error_cache = handle->last_error;lines 161–161return s_last_error_cache.c_str();

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, list

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
lines 4960–4960◇ if (!handle || !handle->identity_manager)lines 4960–4960return nullptr;lines 4961–4967try { auto names = handle->identity_manager->list(); nlohmann::json arr(names); return alloc_cstr(arr.dump().c_str()); } catch (...) { return nullptr; }
char * entropic_list_identities(entropic_handle_t handle)

List all identity names as JSON array.

src/facade/entropic.cpp:4958

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr

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
lines 4960–4960◇ if (!handle || !handle->identity_manager)lines 4960–4960return nullptr;lines 4961–4967try { auto names = handle->identity_manager->list(); nlohmann::json arr(names); return alloc_cstr(arr.dump().c_str()); } catch (...) { return nullptr; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-IDEN-002

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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr, list_keys

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
lines 4746–4747◇ if (!handle || !handle->configured.load() || !handle->mcp_auth || !identity_name)lines 4748–4748return nullptr;lines 4750–4761try { 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; }
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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 4746–4747◇ if (!handle || !handle->configured.load() || !handle->mcp_auth || !identity_name)lines 4748–4748return nullptr;lines 4750–4761try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-MCP-010

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

Show on the map →

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
lines 4000–4000◇ if (!handle)lines 4000–4000return ENTROPIC_ERROR_INVALID_HANDLE;lines 4001–4001◇ if (!out)lines 4001–4001return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4002–4002*out = sp_get_metrics(handle);lines 4003–4003return ENTROPIC_OK;
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

Show on the map →

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
lines 4000–4000◇ if (!handle)lines 4000–4000return ENTROPIC_ERROR_INVALID_HANDLE;lines 4001–4001◇ if (!out)lines 4001–4001return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4002–4002*out = sp_get_metrics(handle);lines 4003–4003return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-008

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
lines 5145–5146◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !model_id)lines 5147–5147return 0;lines 5149–5159try { // 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; }
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 5145–5146◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !model_id)lines 5147–5147return 0;lines 5149–5159try { // 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-025

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

Show on the map →

Called by TEST_CASE

Calls check_orchestrator, profile_registry

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
lines 4519–4519auto rc = check_orchestrator(handle);lines 4520–4520◇ if (rc != ENTROPIC_OK || !name)lines 4521–4521return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4523–4532try { 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; }
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

Show on the map →

Called by TEST_CASE

Calls check_orchestrator

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
lines 4519–4519auto rc = check_orchestrator(handle);lines 4520–4520◇ if (rc != ENTROPIC_OK || !name)lines 4521–4521return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4523–4532try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-019

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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr, profile_registry

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
lines 4554–4555◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !name)lines 4556–4556return nullptr;lines 4558–4571try { 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; }
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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 4554–4555◇ if (!handle || !handle->configured.load() || !handle->orchestrator || !name)lines 4556–4556return nullptr;lines 4558–4571try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-019

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, profile_registry

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
lines 4589–4589◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4590–4590return nullptr;lines 4592–4600try { 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; }
char * entropic_profile_list(entropic_handle_t handle)

List all registered profile names as a JSON array.

src/facade/entropic.cpp:4587

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr

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
lines 4589–4589◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4590–4590return nullptr;lines 4592–4600try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-INFER-019

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator, profile_registry

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
lines 4477–4477auto rc = check_orchestrator(handle);lines 4478–4478◇ if (rc != ENTROPIC_OK || !profile_json)lines 4479–4479return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4481–4499try { 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; }
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_orchestrator

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
lines 4477–4477auto rc = check_orchestrator(handle);lines 4478–4478◇ if (rc != ENTROPIC_OK || !profile_json)lines 4479–4479return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4481–4499try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-019

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls is_running, queue_user_message

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
lines 3230–3230entropic_error_t rc = ENTROPIC_OK;lines 3231–3231◇ if (!handle)lines 3232–3232rc = ENTROPIC_ERROR_INVALID_HANDLE;lines 3233–3233elselines 3233–3233◇ if (!message)lines 3234–3234rc = ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3235–3235elselines 3235–3235◇ if (!handle->engine || !handle->engine->is_running())lines 3236–3236rc = ENTROPIC_ERROR_INVALID_STATE;lines 3237–3237elselines 3237–3237◇ if (!handle->engine->queue_user_message(message))lines 3238–3238rc = ENTROPIC_ERROR_QUEUE_FULL;lines 3240–3240return rc;
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 3230–3230entropic_error_t rc = ENTROPIC_OK;lines 3231–3231◇ if (!handle)lines 3232–3232rc = ENTROPIC_ERROR_INVALID_HANDLE;lines 3233–3233elselines 3233–3233◇ if (!message)lines 3234–3234rc = ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3235–3235elselines 3235–3235◇ if (!handle->engine || !handle->engine->is_running())lines 3236–3236rc = ENTROPIC_ERROR_INVALID_STATE;lines 3237–3237elselines 3237–3237◇ if (!handle->engine->queue_user_message(message))lines 3238–3238rc = ENTROPIC_ERROR_QUEUE_FULL;lines 3240–3240return rc;

Requirements

REQ-ABI-001 REQ-API-005

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

Show on the map →

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
lines 5380–5380auto rc = check_orchestrator(handle);lines 5381–5381entropic::HandleTurnGuard turn(handle);lines 5385–5386◇ if (rc != ENTROPIC_OK || (handle->engine != nullptr && !turn.claim_exclusive()))lines 5387–5387return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5389–5389entropic::HandleApiLock lock(handle);lines 5390–5393return c_api_try(handle, [&]() { return handle->orchestrator->release_models( tier_name != nullptr ? tier_name : ""); });
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

Show on the map →

Called by SCENARIO, SCENARIO, SCENARIO, TEST_CASE, TEST_CASE, handle_release, serve_until_stopped

Calls c_api_try, check_orchestrator, claim_exclusive

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
lines 5380–5380auto rc = check_orchestrator(handle);lines 5381–5381entropic::HandleTurnGuard turn(handle);lines 5385–5386◇ if (rc != ENTROPIC_OK || (handle->engine != nullptr && !turn.claim_exclusive()))lines 5387–5387return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_ALREADY_RUNNING;lines 5389–5389entropic::HandleApiLock lock(handle);lines 5390–5393return c_api_try(handle, [&]() { return handle->orchestrator->release_models( tier_name != nullptr ? tier_name : ""); });

Requirements

REQ-ABI-001 REQ-API-005 REQ-INFER-019

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

Show on the map →

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
lines 5415–5415entropic_error_t rc = ENTROPIC_OK;lines 5416–5416◇ if (handle == nullptr || out_json == nullptr)lines 5417–5417rc = ENTROPIC_ERROR_INVALID_HANDLE;lines 5418–5418elselines 5418–5418◇ if (!handle->orchestrator)lines 5419–5419rc = ENTROPIC_ERROR_INVALID_STATE;lines 5420–5420elselines 5421–5422std::string snapshot = handle->orchestrator->residency_snapshot_json();lines 5423–5423*out_json = alloc_cstr(snapshot);lines 5424–5424◇ if (*out_json == nullptr)lines 5425–5425rc = ENTROPIC_ERROR_OUT_OF_MEMORY;lines 5428–5428return rc;
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

Show on the map →

Called by TEST_CASE, TEST_CASE, resident_count, resident_tiers

Calls alloc_cstr

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
lines 5415–5415entropic_error_t rc = ENTROPIC_OK;lines 5416–5416◇ if (handle == nullptr || out_json == nullptr)lines 5417–5417rc = ENTROPIC_ERROR_INVALID_HANDLE;lines 5418–5418elselines 5418–5418◇ if (!handle->orchestrator)lines 5419–5419rc = ENTROPIC_ERROR_INVALID_STATE;lines 5420–5420elselines 5421–5422std::string snapshot = handle->orchestrator->residency_snapshot_json();lines 5423–5423*out_json = alloc_cstr(snapshot);lines 5424–5424◇ if (*out_json == nullptr)lines 5425–5425rc = ENTROPIC_ERROR_OUT_OF_MEMORY;lines 5428–5428return rc;

Requirements

REQ-API-005 REQ-API-008 REQ-INFER-019

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_mcp_auth, revoke

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
lines 4703–4703auto rc = check_mcp_auth(handle);lines 4704–4704◇ if (rc != ENTROPIC_OK || !identity_name || !pattern)lines 4705–4705return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4707–4707return handle->mcp_auth->revoke(identity_name, pattern);
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls check_mcp_auth

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
lines 4703–4703auto rc = check_mcp_auth(handle);lines 4704–4704◇ if (rc != ENTROPIC_OK || !identity_name || !pattern)lines 4705–4705return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4707–4707return handle->mcp_auth->revoke(identity_name, pattern);

Requirements

REQ-API-005 REQ-MCP-010

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

Show on the map →

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
lines 2467–2467entropic::HandleTurnGuard turn(handle);lines 2468–2468auto rc = check_orchestrator(handle);lines 2469–2470◇ if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine || !turn.claim())lines 2471–2474return rc != ENTROPIC_OK ? rc : (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2476–2502try { 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; }
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

Show on the map →

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
lines 2467–2467entropic::HandleTurnGuard turn(handle);lines 2468–2468auto rc = check_orchestrator(handle);lines 2469–2470◇ if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine || !turn.claim())lines 2471–2474return rc != ENTROPIC_OK ? rc : (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2476–2502try { 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; }

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

Show on the map →

Called by SCENARIO, run_as

Calls check_orchestrator, claim, has_tier, run_as_inner

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
lines 2570–2570entropic::HandleTurnGuard turn(handle);lines 2571–2571auto rc = check_orchestrator(handle);lines 2572–2573◇ if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json || !handle->engine || !turn.claim())lines 2574–2578return rc != ENTROPIC_OK ? rc : (!tier_or_identity || !input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2580–2580◇ if (!handle->engine->has_tier(tier_or_identity))lines 2581–2582handle->last_error = std::string("unknown tier: ") + tier_or_identity;lines 2583–2583s_log->error("run_as: {}", handle->last_error);lines 2584–2584return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 2586–2586return run_as_inner(handle, tier_or_identity, input, result_json);
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

Show on the map →

Called by SCENARIO, run_as

Calls check_orchestrator, claim, run_as_inner

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
lines 2570–2570entropic::HandleTurnGuard turn(handle);lines 2571–2571auto rc = check_orchestrator(handle);lines 2572–2573◇ if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json || !handle->engine || !turn.claim())lines 2574–2578return rc != ENTROPIC_OK ? rc : (!tier_or_identity || !input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2580–2580◇ if (!handle->engine->has_tier(tier_or_identity))lines 2581–2582handle->last_error = std::string("unknown tier: ") + tier_or_identity;lines 2583–2583s_log->error("run_as: {}", handle->last_error);lines 2584–2584return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 2586–2586return run_as_inner(handle, tier_or_identity, input, result_json);

Requirements

REQ-API-005 REQ-API-008 REQ-API-009 REQ-API-010

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

Show on the map →

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
lines 2683–2683entropic::HandleTurnGuard turn(handle);lines 2684–2684auto rc = check_orchestrator(handle);lines 2685–2686◇ if (rc != ENTROPIC_OK || !prompts || !result_json || !handle->engine || n == 0 || !turn.claim())lines 2687–2691return rc != ENTROPIC_OK ? rc : (!prompts || !result_json || n == 0) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2693–2715try { 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; }
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

Show on the map →

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
lines 2683–2683entropic::HandleTurnGuard turn(handle);lines 2684–2684auto rc = check_orchestrator(handle);lines 2685–2686◇ if (rc != ENTROPIC_OK || !prompts || !result_json || !handle->engine || n == 0 || !turn.claim())lines 2687–2691return rc != ENTROPIC_OK ? rc : (!prompts || !result_json || n == 0) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2693–2715try { 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; }

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

Show on the map →

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
lines 2874–2874entropic::HandleTurnGuard turn(handle);lines 2875–2875auto rc = check_orchestrator(handle);lines 2876–2877◇ if (rc != ENTROPIC_OK || !messages_json || !result_json || !handle->engine || !turn.claim())lines 2878–2881return rc != ENTROPIC_OK ? rc : (!messages_json || !result_json || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2883–2889try { 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; }
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

Show on the map →

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
lines 2874–2874entropic::HandleTurnGuard turn(handle);lines 2875–2875auto rc = check_orchestrator(handle);lines 2876–2877◇ if (rc != ENTROPIC_OK || !messages_json || !result_json || !handle->engine || !turn.claim())lines 2878–2881return rc != ENTROPIC_OK ? rc : (!messages_json || !result_json || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2883–2889try { 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; }

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

Show on the map →

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
lines 2952–2952entropic::HandleTurnGuard turn(handle);lines 2953–2953auto rc = check_orchestrator(handle);lines 2954–2955◇ if (rc != ENTROPIC_OK || !messages_json || !on_token || !handle->engine || !turn.claim())lines 2956–2959return rc != ENTROPIC_OK ? rc : (!messages_json || !on_token || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2961–2968try { 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; }
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

Show on the map →

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
lines 2952–2952entropic::HandleTurnGuard turn(handle);lines 2953–2953auto rc = check_orchestrator(handle);lines 2954–2955◇ if (rc != ENTROPIC_OK || !messages_json || !on_token || !handle->engine || !turn.claim())lines 2956–2959return rc != ENTROPIC_OK ? rc : (!messages_json || !on_token || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2961–2968try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-009 REQ-INFER-025

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

Show on the map →

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
lines 3392–3392entropic::HandleTurnGuard turn(handle, session_key);lines 3393–3393auto rc = check_orchestrator(handle);lines 3394–3395◇ if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine || !turn.claim())lines 3396–3399return rc != ENTROPIC_OK ? rc : (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3401–3401handle->engine->set_active_session(session_key ? session_key : "");lines 3402–3415try { 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; }
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

Show on the map →

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
lines 3392–3392entropic::HandleTurnGuard turn(handle, session_key);lines 3393–3393auto rc = check_orchestrator(handle);lines 3394–3395◇ if (rc != ENTROPIC_OK || !input || !result_json || !handle->engine || !turn.claim())lines 3396–3399return rc != ENTROPIC_OK ? rc : (!input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3401–3401handle->engine->set_active_session(session_key ? session_key : "");lines 3402–3415try { 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; }

Requirements

REQ-API-009 REQ-LOOP-001

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

Show on the map →

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
lines 3437–3437entropic::HandleTurnGuard turn(handle, session_key);lines 3438–3438auto rc = check_orchestrator(handle);lines 3439–3440◇ if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json || !handle->engine || !turn.claim())lines 3441–3445return rc != ENTROPIC_OK ? rc : (!tier_or_identity || !input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3447–3447◇ if (!handle->engine->has_tier(tier_or_identity))lines 3448–3449handle->last_error = std::string("unknown tier: ") + tier_or_identity;lines 3450–3450return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 3452–3452handle->engine->set_active_session(session_key ? session_key : "");lines 3453–3453return run_as_inner(handle, tier_or_identity, input, result_json);
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

Show on the map →

Called by run_plain_turn

Calls check_orchestrator, claim, run_as_inner

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
lines 3437–3437entropic::HandleTurnGuard turn(handle, session_key);lines 3438–3438auto rc = check_orchestrator(handle);lines 3439–3440◇ if (rc != ENTROPIC_OK || !tier_or_identity || !input || !result_json || !handle->engine || !turn.claim())lines 3441–3445return rc != ENTROPIC_OK ? rc : (!tier_or_identity || !input || !result_json) ? ENTROPIC_ERROR_INVALID_ARGUMENT : !handle->engine ? ENTROPIC_ERROR_INVALID_STATE : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3447–3447◇ if (!handle->engine->has_tier(tier_or_identity))lines 3448–3449handle->last_error = std::string("unknown tier: ") + tier_or_identity;lines 3450–3450return ENTROPIC_ERROR_IDENTITY_NOT_FOUND;lines 3452–3452handle->engine->set_active_session(session_key ? session_key : "");lines 3453–3453return run_as_inner(handle, tier_or_identity, input, result_json);

Requirements

REQ-API-009 REQ-IDEN-001

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

Show on the map →

Called by run_stream_turn

Calls on_token, run_session_streaming_impl

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
lines 3558–3559return run_session_streaming_impl(handle, session_key, nullptr, input, on_token, user_data, cancel_flag);
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

Show on the map →

Called by run_stream_turn

Calls on_token, run_session_streaming_impl

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
lines 3558–3559return run_session_streaming_impl(handle, session_key, nullptr, input, on_token, user_data, cancel_flag);

Requirements

REQ-API-009

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

Show on the map →

Called by SCENARIO, run_stream_turn

Calls on_token, run_session_streaming_impl

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
lines 3584–3584◇ if (tier_or_identity == nullptr)lines 3584–3584return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3585–3586return run_session_streaming_impl(handle, session_key, tier_or_identity, input, on_token, user_data, cancel_flag);
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

Show on the map →

Called by SCENARIO, run_stream_turn

Calls on_token, run_session_streaming_impl

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
lines 3584–3584◇ if (tier_or_identity == nullptr)lines 3584–3584return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3585–3586return run_session_streaming_impl(handle, session_key, tier_or_identity, input, on_token, user_data, cancel_flag);

Requirements

REQ-API-009 REQ-IDEN-001

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

Show on the map →

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
lines 2749–2749entropic::HandleTurnGuard turn(handle);lines 2750–2750auto rc = check_orchestrator(handle);lines 2751–2752◇ if (rc != ENTROPIC_OK || !input || !on_token || !handle->engine || !turn.claim())lines 2753–2756return rc != ENTROPIC_OK ? rc : (!input || !on_token || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2762–2774try { 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; }
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

Show on the map →

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
lines 2749–2749entropic::HandleTurnGuard turn(handle);lines 2750–2750auto rc = check_orchestrator(handle);lines 2751–2752◇ if (rc != ENTROPIC_OK || !input || !on_token || !handle->engine || !turn.claim())lines 2753–2756return rc != ENTROPIC_OK ? rc : (!input || !on_token || !handle->engine) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 2762–2774try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-009 REQ-API-010

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls seconds_since_last_activity

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
lines 2367–2367◇ if (!handle || !handle->engine)lines 2367–2367return 0;lines 2368–2368return handle->engine->seconds_since_last_activity();
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 2367–2367◇ if (!handle || !handle->engine)lines 2367–2367return 0;lines 2368–2368return handle->engine->seconds_since_last_activity();

Requirements

REQ-ABI-001 REQ-API-005

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, serialize_all

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
lines 4799–4799◇ if (!handle || !handle->configured.load() || !handle->mcp_auth)lines 4800–4800return nullptr;lines 4802–4808try { 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; }
char * entropic_serialize_mcp_keys(entropic_handle_t handle)

Serialize all identity key sets to JSON.

src/facade/entropic.cpp:4797

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr

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
lines 4799–4799◇ if (!handle || !handle->configured.load() || !handle->mcp_auth)lines 4800–4800return nullptr;lines 4802–4808try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-MCP-010

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

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
lines 3759–3759◇ if (!handle || !handle->engine)lines 3760–3760return ENTROPIC_ERROR_INVALID_HANDLE;lines 3762–3762entropic::HandleApiLock lock(handle);lines 3763–3763const std::string key = session_key ? session_key : "";lines 3764–3764handle->engine->clear_conversation_for(key);lines 3765–3765entropic::release_session_tool_state(handle, key);lines 3766–3766return ENTROPIC_OK;
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
lines 3759–3759◇ if (!handle || !handle->engine)lines 3760–3760return ENTROPIC_ERROR_INVALID_HANDLE;lines 3762–3762entropic::HandleApiLock lock(handle);lines 3763–3763const std::string key = session_key ? session_key : "";lines 3764–3764handle->engine->clear_conversation_for(key);lines 3765–3765entropic::release_session_tool_state(handle, key);lines 3766–3766return ENTROPIC_OK;

Requirements

REQ-LOOP-001 REQ-LOOP-009

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

Show on the map →

Called by SCENARIO, SCENARIO, handle_count

Calls message_count_for

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
lines 3728–3728◇ if (!handle || !count || !handle->engine)lines 3729–3731return (handle != nullptr && count == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3733–3733entropic::HandleApiLock lock(handle);lines 3734–3735*count = handle->engine->message_count_for( session_key ? session_key : "");lines 3736–3736return ENTROPIC_OK;
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

Show on the map →

Called by SCENARIO, SCENARIO, TEST_CASE, handle_count

Calls none

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
lines 3728–3728◇ if (!handle || !count || !handle->engine)lines 3729–3731return (handle != nullptr && count == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3733–3733entropic::HandleApiLock lock(handle);lines 3734–3735*count = handle->engine->message_count_for( session_key ? session_key : "");lines 3736–3736return ENTROPIC_OK;

Requirements

REQ-LOOP-001

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

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
lines 3602–3602◇ if (!handle || !messages_json || !handle->engine)lines 3603–3605return (handle != nullptr && messages_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3607–3607entropic::HandleApiLock lock(handle);lines 3608–3609*messages_json = alloc_cstr(facade_json::serialize_messages( handle->engine->messages_for(session_key ? session_key : "")));lines 3610–3610return ENTROPIC_OK;
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

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
lines 3602–3602◇ if (!handle || !messages_json || !handle->engine)lines 3603–3605return (handle != nullptr && messages_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3607–3607entropic::HandleApiLock lock(handle);lines 3608–3609*messages_json = alloc_cstr(facade_json::serialize_messages( handle->engine->messages_for(session_key ? session_key : "")));lines 3610–3610return ENTROPIC_OK;

Requirements

REQ-LOOP-001

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

Show on the map →

Called by SCENARIO, end_session

Calls session_context_set_inner

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
lines 3705–3705◇ if (!handle || !handle->engine || !messages_json)lines 3706–3708return (handle != nullptr && handle->engine != nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3710–3710entropic::HandleApiLock lock(handle);lines 3711–3712return session_context_set_inner( handle, session_key != nullptr ? session_key : "", messages_json);
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

Show on the map →

Called by SCENARIO, TEST_CASE, end_session

Calls session_context_set_inner

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
lines 3705–3705◇ if (!handle || !handle->engine || !messages_json)lines 3706–3708return (handle != nullptr && handle->engine != nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3710–3710entropic::HandleApiLock lock(handle);lines 3711–3712return session_context_set_inner( handle, session_key != nullptr ? session_key : "", messages_json);

Requirements

REQ-LOOP-010

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

Show on the map →

Called by SCENARIO, end_session

Calls drop_session, release_session_tool_state

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
lines 3786–3786◇ if (!handle || !handle->engine)lines 3787–3787return ENTROPIC_ERROR_INVALID_HANDLE;lines 3789–3789entropic::HandleApiLock lock(handle);lines 3790–3790const std::string key = session_key ? session_key : "";lines 3791–3791handle->engine->drop_session(key);lines 3792–3792entropic::release_session_tool_state(handle, key);lines 3793–3793return ENTROPIC_OK;
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

Show on the map →

Called by SCENARIO, end_session

Calls release_session_tool_state

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
lines 3786–3786◇ if (!handle || !handle->engine)lines 3787–3787return ENTROPIC_ERROR_INVALID_HANDLE;lines 3789–3789entropic::HandleApiLock lock(handle);lines 3790–3790const std::string key = session_key ? session_key : "";lines 3791–3791handle->engine->drop_session(key);lines 3792–3792entropic::release_session_tool_state(handle, key);lines 3793–3793return ENTROPIC_OK;

Requirements

REQ-LOOP-001 REQ-LOOP-009

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

Show on the map →

Called by SCENARIO, handle_status

Calls alloc_cstr, message_count_for, session_keys

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
lines 3812–3812◇ if (!handle || !sessions_json || !handle->engine)lines 3813–3815return (handle != nullptr && sessions_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3817–3817entropic::HandleApiLock lock(handle);lines 3818–3818nlohmann::json arr = nlohmann::json::array();lines 3819–3819◇ for (const auto& key : handle->engine->session_keys())lines 3820–3821arr.push_back({{"key", key}, {"messages", handle->engine->message_count_for(key)}});lines 3823–3823*sessions_json = alloc_cstr(arr.dump());lines 3824–3824return ENTROPIC_OK;
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
lines 3812–3812◇ if (!handle || !sessions_json || !handle->engine)lines 3813–3815return (handle != nullptr && sessions_json == nullptr) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_INVALID_HANDLE;lines 3817–3817entropic::HandleApiLock lock(handle);lines 3818–3818nlohmann::json arr = nlohmann::json::array();lines 3819–3819◇ for (const auto& key : handle->engine->session_keys())lines 3820–3821arr.push_back({{"key", key}, {"messages", handle->engine->message_count_for(key)}});lines 3823–3823*sessions_json = alloc_cstr(arr.dump());lines 3824–3824return ENTROPIC_OK;

Requirements

REQ-LOOP-001

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
lines 3062–3062◇ if (!handle)lines 3062–3062return ENTROPIC_ERROR_INVALID_HANDLE;lines 3063–3063◇ if (handle->validator)lines 3064–3064handle->validator->set_attempt_boundary_cb(cb, user_data);lines 3066–3066return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3062–3062◇ if (!handle)lines 3062–3062return ENTROPIC_ERROR_INVALID_HANDLE;lines 3063–3063◇ if (handle->validator)lines 3064–3064handle->validator->set_attempt_boundary_cb(cb, user_data);lines 3066–3066return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010 REQ-VALID-003

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
lines 3156–3156◇ if (!handle)lines 3156–3156return ENTROPIC_ERROR_INVALID_HANDLE;lines 3157–3157handle->critique_start_cb = start_cb;lines 3158–3158handle->critique_end_cb = end_cb;lines 3159–3159handle->critique_cb_data = user_data;lines 3160–3160◇ if (handle->validator)lines 3161–3162handle->validator->set_critique_callbacks( start_cb, end_cb, user_data);lines 3164–3164return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3156–3156◇ if (!handle)lines 3156–3156return ENTROPIC_ERROR_INVALID_HANDLE;lines 3157–3157handle->critique_start_cb = start_cb;lines 3158–3158handle->critique_end_cb = end_cb;lines 3159–3159handle->critique_cb_data = user_data;lines 3160–3160◇ if (handle->validator)lines 3161–3162handle->validator->set_critique_callbacks( start_cb, end_cb, user_data);lines 3164–3164return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010 REQ-VALID-002

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
lines 3086–3086◇ if (!handle)lines 3086–3086return ENTROPIC_ERROR_INVALID_HANDLE;lines 3087–3087◇ if (handle->engine)lines 3088–3089handle->engine->set_delegation_callbacks( on_start, on_complete, user_data);lines 3091–3091return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3086–3086◇ if (!handle)lines 3086–3086return ENTROPIC_ERROR_INVALID_HANDLE;lines 3087–3087◇ if (handle->engine)lines 3088–3089handle->engine->set_delegation_callbacks( on_start, on_complete, user_data);lines 3091–3091return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010 REQ-DELEG-002 REQ-DELEG-005

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

Show on the map →

Called by none

Calls set_queue_observer

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
lines 3296–3296◇ if (!handle)lines 3296–3296return ENTROPIC_ERROR_INVALID_HANDLE;lines 3297–3297handle->queue_observer = observer;lines 3298–3298handle->queue_observer_data = user_data;lines 3299–3299◇ if (handle->engine)lines 3300–3300handle->engine->set_queue_observer(observer, user_data);lines 3302–3302return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010

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

Show on the map →

Called by TEST_CASE, TEST_CASE

Calls set_residency_observer

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
lines 5335–5335◇ if (handle == nullptr)lines 5335–5335return ENTROPIC_ERROR_INVALID_HANDLE;lines 5341–5341entropic::ModelOrchestrator::ResidencyObserverFn fn;lines 5342–5342◇ if (observer != nullptr)lines 5343–5353fn = [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); };lines 5355–5355◇ if (handle->orchestrator)lines 5356–5356handle->orchestrator->set_residency_observer(std::move(fn));lines 5358–5358return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE, TEST_CASE

Calls none

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
lines 5335–5335◇ if (handle == nullptr)lines 5335–5335return ENTROPIC_ERROR_INVALID_HANDLE;lines 5341–5341entropic::ModelOrchestrator::ResidencyObserverFn fn;lines 5342–5342◇ if (observer != nullptr)lines 5343–5353fn = [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); };lines 5355–5355◇ if (handle->orchestrator)lines 5356–5356handle->orchestrator->set_residency_observer(std::move(fn));lines 5358–5358return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010 REQ-INFER-019

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

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
lines 3116–3116◇ if (!handle)lines 3116–3116return ENTROPIC_ERROR_INVALID_HANDLE;lines 3117–3117handle->state_observer = observer;lines 3118–3118handle->state_observer_data = user_data;lines 3119–3119◇ if (handle->engine)lines 3126–3126handle->engine->set_state_observer(observer, user_data);lines 3128–3128return ENTROPIC_OK;
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
lines 3116–3116◇ if (!handle)lines 3116–3116return ENTROPIC_ERROR_INVALID_HANDLE;lines 3117–3117handle->state_observer = observer;lines 3118–3118handle->state_observer_data = user_data;lines 3119–3119◇ if (handle->engine)lines 3126–3126handle->engine->set_state_observer(observer, user_data);lines 3128–3128return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010 REQ-LOOP-001

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

Show on the map →

Called by none

Calls set_stream_observer

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
lines 2985–2985◇ if (!handle)lines 2985–2985return ENTROPIC_ERROR_INVALID_HANDLE;lines 2986–2986handle->stream_observer = observer;lines 2987–2987handle->stream_observer_data = user_data;lines 2990–2990◇ if (handle->engine)lines 2991–2991handle->engine->set_stream_observer(observer, user_data);lines 2993–2993return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE, register_token_observer

Calls none

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
lines 2985–2985◇ if (!handle)lines 2985–2985return ENTROPIC_ERROR_INVALID_HANDLE;lines 2986–2986handle->stream_observer = observer;lines 2987–2987handle->stream_observer_data = user_data;lines 2990–2990◇ if (handle->engine)lines 2991–2991handle->engine->set_stream_observer(observer, user_data);lines 2993–2993return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-010

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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr, check_speculative_compat

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
lines 5297–5297◇ if (handle == nullptr || compatible == nullptr)lines 5298–5298return ENTROPIC_ERROR_INVALID_HANDLE;lines 5300–5300◇ if (!handle->orchestrator)lines 5301–5301return ENTROPIC_ERROR_INVALID_STATE;lines 5303–5303auto info = handle->orchestrator->check_speculative_compat();lines 5304–5304*compatible = info.compatible ? 1 : 0;lines 5305–5305◇ if (diagnostic != nullptr)lines 5306–5308*diagnostic = info.compatible ? nullptr : alloc_cstr(info.diagnostic);lines 5310–5310return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls alloc_cstr

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
lines 5297–5297◇ if (handle == nullptr || compatible == nullptr)lines 5298–5298return ENTROPIC_ERROR_INVALID_HANDLE;lines 5300–5300◇ if (!handle->orchestrator)lines 5301–5301return ENTROPIC_ERROR_INVALID_STATE;lines 5303–5303auto info = handle->orchestrator->check_speculative_compat();lines 5304–5304*compatible = info.compatible ? 1 : 0;lines 5305–5305◇ if (diagnostic != nullptr)lines 5306–5308*diagnostic = info.compatible ? nullptr : alloc_cstr(info.diagnostic);lines 5310–5310return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-API-008 REQ-INFER-016

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

Show on the map →

Called by TEST_CASE

Calls c_api_try, claim, do_state_load

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
lines 3972–3972entropic::HandleTurnGuard turn(handle);lines 3973–3974◇ if (!handle || !tier_name || !path || (handle->engine != nullptr && !turn.claim()))lines 3975–3977return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3979–3979entropic::HandleApiLock lock(handle);lines 3980–3981return c_api_try(handle, [&]() { return do_state_load(handle, tier_name, path); });
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

Show on the map →

Called by TEST_CASE

Calls c_api_try, claim, do_state_load

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
lines 3972–3972entropic::HandleTurnGuard turn(handle);lines 3973–3974◇ if (!handle || !tier_name || !path || (handle->engine != nullptr && !turn.claim()))lines 3975–3977return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3979–3979entropic::HandleApiLock lock(handle);lines 3980–3981return c_api_try(handle, [&]() { return do_state_load(handle, tier_name, path); });

Requirements

REQ-ABI-001 REQ-ABI-002 REQ-API-005

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

Show on the map →

Called by TEST_CASE

Calls c_api_try, claim, do_state_save

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
lines 3910–3910entropic::HandleTurnGuard turn(handle);lines 3911–3912◇ if (!handle || !tier_name || !path || (handle->engine != nullptr && !turn.claim()))lines 3913–3915return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3917–3917entropic::HandleApiLock lock(handle);lines 3918–3919return c_api_try(handle, [&]() { return do_state_save(handle, tier_name, path); });
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

Show on the map →

Called by TEST_CASE

Calls c_api_try, claim, do_state_save

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
lines 3910–3910entropic::HandleTurnGuard turn(handle);lines 3911–3912◇ if (!handle || !tier_name || !path || (handle->engine != nullptr && !turn.claim()))lines 3913–3915return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : (!tier_name || !path) ? ENTROPIC_ERROR_INVALID_ARGUMENT : ENTROPIC_ERROR_ALREADY_RUNNING;lines 3917–3917entropic::HandleApiLock lock(handle);lines 3918–3919return c_api_try(handle, [&]() { return do_state_save(handle, tier_name, path); });

Requirements

REQ-ABI-001 REQ-ABI-002 REQ-API-005

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

Show on the map →

Called by TEST_CASE

Calls throughput_tracker

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
lines 4653–4653(void)model_path;lines 4654–4654◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4655–4655return;lines 4657–4663try { 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); }
void entropic_throughput_reset(entropic_handle_t handle, const char *model_path)

Reset throughput tracking data.

src/facade/entropic.cpp:4649

Show on the map →

Called by TEST_CASE

Calls none

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
lines 4653–4653(void)model_path;lines 4654–4654◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4655–4655return;lines 4657–4663try { 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); }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-021

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls throughput_tracker

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
lines 4623–4623(void)model_path;lines 4624–4624◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4625–4625return 0.0;lines 4627–4633try { 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; }
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 4623–4623(void)model_path;lines 4624–4624◇ if (!handle || !handle->configured.load() || !handle->orchestrator)lines 4625–4625return 0.0;lines 4627–4633try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-INFER-021

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

Show on the map →

Called by TEST_CASE

Calls check_identity, update

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
lines 4880–4880auto rc = check_identity(handle);lines 4881–4881◇ if (rc != ENTROPIC_OK || !name || !config_json)lines 4882–4882return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4884–4897try { 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; }
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

Show on the map →

Called by TEST_CASE

Calls check_identity

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
lines 4880–4880auto rc = check_identity(handle);lines 4881–4881◇ if (rc != ENTROPIC_OK || !name || !config_json)lines 4882–4882return rc != ENTROPIC_OK ? rc : ENTROPIC_ERROR_INVALID_ARGUMENT;lines 4884–4897try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-IDEN-002

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls user_message_queue_depth

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
lines 3254–3254◇ if (!handle)lines 3254–3254return ENTROPIC_ERROR_INVALID_HANDLE;lines 3255–3255◇ if (!count)lines 3255–3255return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3256–3257*count = handle->engine ? handle->engine->user_message_queue_depth() : 0;lines 3258–3258return ENTROPIC_OK;
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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls none

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
lines 3254–3254◇ if (!handle)lines 3254–3254return ENTROPIC_ERROR_INVALID_HANDLE;lines 3255–3255◇ if (!count)lines 3255–3255return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 3256–3257*count = handle->engine ? handle->engine->user_message_queue_depth() : 0;lines 3258–3258return ENTROPIC_OK;

Requirements

REQ-ABI-001 REQ-API-005

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

Show on the map →

Called by TEST_CASE

Calls accept_last

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
lines 3043–3043◇ if (!handle)lines 3043–3043return ENTROPIC_ERROR_INVALID_HANDLE;lines 3044–3044◇ if (!handle->validator)lines 3044–3044return ENTROPIC_ERROR_INVALID_STATE;lines 3045–3045entropic::HandleApiLock lock(handle);lines 3046–3046return handle->validator->accept_last();
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3043–3043◇ if (!handle)lines 3043–3043return ENTROPIC_ERROR_INVALID_HANDLE;lines 3044–3044◇ if (!handle->validator)lines 3044–3044return ENTROPIC_ERROR_INVALID_STATE;lines 3045–3045entropic::HandleApiLock lock(handle);lines 3046–3046return handle->validator->accept_last();

Requirements

REQ-API-005 REQ-VALID-003

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

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, last_result, sanitize_utf8

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
lines 5216–5216◇ if (!handle || !handle->validator)lines 5216–5216return nullptr;lines 5217–5226try { 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; }
char * entropic_validation_last_result(entropic_handle_t handle)

Get last validation result as JSON.

src/facade/entropic.cpp:5214

Show on the map →

Called by SCENARIO, TEST_CASE

Calls alloc_cstr, sanitize_utf8

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
lines 5216–5216◇ if (!handle || !handle->validator)lines 5216–5216return nullptr;lines 5217–5226try { 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; }

Requirements

REQ-ABI-002 REQ-API-005 REQ-API-008 REQ-VALID-001

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

Show on the map →

Called by TEST_CASE

Calls resume_retry

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
lines 3026–3026◇ if (!handle)lines 3026–3026return ENTROPIC_ERROR_INVALID_HANDLE;lines 3027–3027◇ if (!handle->validator)lines 3027–3027return ENTROPIC_ERROR_INVALID_STATE;lines 3028–3028entropic::HandleApiLock lock(handle);lines 3029–3029return handle->validator->resume_retry();
entropic_error_t entropic_validation_resume_retry(entropic_handle_t handle)

Resume a paused constitutional revision pass.

src/facade/entropic.cpp:3024

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3026–3026◇ if (!handle)lines 3026–3026return ENTROPIC_ERROR_INVALID_HANDLE;lines 3027–3027◇ if (!handle->validator)lines 3027–3027return ENTROPIC_ERROR_INVALID_STATE;lines 3028–3028entropic::HandleApiLock lock(handle);lines 3029–3029return handle->validator->resume_retry();

Requirements

REQ-API-005 REQ-VALID-003

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

Show on the map →

Called by TEST_CASE

Calls set_auto_retry

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
lines 3008–3008◇ if (!handle)lines 3008–3008return ENTROPIC_ERROR_INVALID_HANDLE;lines 3009–3009◇ if (handle->validator)lines 3010–3010handle->validator->set_auto_retry(enabled != 0);lines 3012–3012return ENTROPIC_OK;
entropic_error_t entropic_validation_set_auto_retry(entropic_handle_t handle, int enabled)

Toggle automatic constitutional revision.

src/facade/entropic.cpp:3006

Show on the map →

Called by TEST_CASE

Calls none

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
lines 3008–3008◇ if (!handle)lines 3008–3008return ENTROPIC_ERROR_INVALID_HANDLE;lines 3009–3009◇ if (handle->validator)lines 3010–3010handle->validator->set_auto_retry(enabled != 0);lines 3012–3012return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-VALID-003

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

Show on the map →

Called by TEST_CASE

Calls set_global_enabled

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
lines 5176–5176◇ if (!handle)lines 5176–5176return ENTROPIC_ERROR_INVALID_HANDLE;lines 5177–5177◇ if (!handle->validator)lines 5177–5177return ENTROPIC_ERROR_INVALID_STATE;lines 5178–5178handle->validator->set_global_enabled(enabled);lines 5179–5179return ENTROPIC_OK;
entropic_error_t entropic_validation_set_enabled(entropic_handle_t handle, bool enabled)

Enable or disable constitutional validation globally.

src/facade/entropic.cpp:5172

Show on the map →

Called by TEST_CASE

Calls none

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
lines 5176–5176◇ if (!handle)lines 5176–5176return ENTROPIC_ERROR_INVALID_HANDLE;lines 5177–5177◇ if (!handle->validator)lines 5177–5177return ENTROPIC_ERROR_INVALID_STATE;lines 5178–5178handle->validator->set_global_enabled(enabled);lines 5179–5179return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-VALID-001

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
lines 5195–5195◇ if (!handle || !handle->validator)lines 5196–5197return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_STATE;lines 5199–5199◇ if (!identity_name)lines 5199–5199return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 5200–5200handle->validator->set_identity_validation(identity_name, enabled);lines 5201–5201return ENTROPIC_OK;
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

Show on the map →

Called by TEST_CASE

Calls none

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
lines 5195–5195◇ if (!handle || !handle->validator)lines 5196–5197return !handle ? ENTROPIC_ERROR_INVALID_HANDLE : ENTROPIC_ERROR_INVALID_STATE;lines 5199–5199◇ if (!identity_name)lines 5199–5199return ENTROPIC_ERROR_INVALID_ARGUMENT;lines 5200–5200handle->validator->set_identity_validation(identity_name, enabled);lines 5201–5201return ENTROPIC_OK;

Requirements

REQ-API-005 REQ-VALID-001

entropic_version

ENTROPIC_EXPORT const char * entropic_version(void)

Get the library version string.

src/facade/entropic.cpp:2343

Show on the map →

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
lines 2344–2344return CONFIG_ENTROPIC_VERSION_STRING;
const char * entropic_version(void)

Get the library version string.

src/facade/entropic.cpp:2343

Show on the map →

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
lines 2344–2344return CONFIG_ENTROPIC_VERSION_STRING;

Requirements

REQ-ABI-001 REQ-API-008

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

Show on the map →

Called by wire_session_roots

Calls workspace_servers

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
lines 1695–1695auto* h = static_cast<entropic_handle_t>(ud);lines 1696–1696auto* servers = entropic::workspace_servers(h, session_key);lines 1697–1697◇ if (servers == nullptr)lines 1697–1697return {};lines 1698–1698return servers->project_dir();

Requirements

REQ-DELEG-005

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

Show on the map →

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
lines 1890–1890h->orchestrator = std::make_unique<entropic::ModelOrchestrator>();lines 1891–1891◇ if (!h->orchestrator->initialize(h->config))lines 1892–1892h->last_error = "orchestrator initialization failed";lines 1893–1893s_log->error("{}", h->last_error);lines 1894–1894return ENTROPIC_ERROR_LOAD_FAILED;lines 1898–1898◇ if (h->orchestrator->grammar_registry().size() == 0)lines 1899–1899h->orchestrator->load_grammars_from(data_dir / "grammars");lines 1901–1901return ENTROPIC_OK;

Requirements

REQ-API-004 REQ-API-013

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
lines 1864–1864◇ if (!h->configured.load())lines 1864–1864return ENTROPIC_OK;lines 1865–1865h->last_error = "handle already configured";lines 1866–1866s_log->error("{}", h->last_error);lines 1867–1867return ENTROPIC_ERROR_INVALID_STATE;

Requirements

REQ-API-004

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

Show on the map →

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
lines 235–235const std::string tier(tier_name);lines 236–236◇ if (h->orchestrator->get_backend(tier) == nullptr)lines 237–237throw std::runtime_error("no backend for tier: " + tier);lines 239–239auto* backend = h->orchestrator->ensure_model(tier);lines 240–240◇ if (backend == nullptr || !backend->is_active())lines 241–242throw std::runtime_error( "model could not be made resident for tier: " + tier);lines 244–244return backend;

Requirements

REQ-INFER-019

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
lines 528–529◇ if ((h->critique_start_cb != nullptr || h->critique_end_cb != nullptr) && h->validator)lines 530–533h->validator->set_critique_callbacks( h->critique_start_cb, h->critique_end_cb, h->critique_cb_data);

Requirements

REQ-API-010

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

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
lines 548–548rewire_stream_observer(h);lines 549–549rewire_queue_observer(h);lines 550–550rewire_critique_callbacks(h);lines 551–551rewire_state_observer(h);

Requirements

REQ-API-010

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

Show on the map →

Called by rewire_observers

Calls set_queue_observer

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
lines 489–489◇ if (h->queue_observer != nullptr && h->engine)lines 490–491h->engine->set_queue_observer( h->queue_observer, h->queue_observer_data);

Requirements

REQ-API-010

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
lines 508–508◇ if (h->state_observer != nullptr && h->engine)lines 509–510h->engine->set_state_observer( h->state_observer, h->state_observer_data);

Requirements

REQ-API-010

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

Show on the map →

Called by rewire_observers

Calls set_stream_observer

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
lines 470–470◇ if (h->stream_observer != nullptr && h->engine)lines 471–472h->engine->set_stream_observer( h->stream_observer, h->stream_observer_data);

Requirements

REQ-API-010

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

Show on the map →

Called by build_storage_iface

Calls latest_delegation_for_target

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
lines 739–739auto* sb = static_cast<entropic::SqliteStorageBackend*>(user_data);lines 740–740◇ if (sb == nullptr || target_tier == nullptr)lines 740–740return false;lines 741–741return sb->latest_delegation_for_target(target_tier, delegation_id);

Requirements

REQ-DELEG-006

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
lines 1828–1828◇ if (!h->config.mcp.external.enabled)lines 1828–1828return;lines 1830–1831h->external_bridge = std::make_unique<entropic::ExternalBridge>( h, h->config.mcp.external, entropic::bridge_project_dir(h));lines 1832–1832◇ if (!h->external_bridge->start())lines 1833–1833s_log->warn("External MCP bridge failed to start");lines 1834–1834h->external_bridge.reset();

Requirements

REQ-BRIDGE-001

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
lines 1798–1798const int port = h->config.mcp.external.http_port;lines 1799–1799std::string err;lines 1800–1800◇ if (port != 0 && (port < 0 || port > 65535))lines 1801–1801err = "mcp.external.http_port out of range: " + std::to_string(port);lines 1802–1802elselines 1802–1802◇ if (port != 0 && !h->external_bridge)lines 1803–1803err = "the unix bridge did not start";lines 1804–1804elselines 1804–1804◇ if (port != 0)lines 1805–1806h->http_listener = std::make_unique<entropic::http::HttpListener>( h->external_bridge.get(), port);lines 1807–1807◇ if (!h->http_listener->start(err))lines 1807–1807h->http_listener.reset();lines 1809–1809◇ if (!err.empty())lines 1810–1810h->last_error = "HTTP listener: " + err;lines 1811–1811s_log->error("{}", h->last_error);lines 1813–1813return err.empty() ? ENTROPIC_OK : ENTROPIC_ERROR_IO;

Requirements

REQ-BRIDGE-001

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
lines 970–970◇ if (fm.grammar.has_value())lines 971–971tc.grammar = std::filesystem::path(*fm.grammar);lines 973–973◇ if (fm.temperature.has_value())lines 973–973tc.temperature = *fm.temperature;lines 974–974◇ if (fm.max_output_tokens.has_value())lines 975–975tc.max_output_tokens = *fm.max_output_tokens;lines 977–977◇ if (fm.top_p.has_value())lines 977–977tc.top_p = *fm.top_p;lines 978–978◇ if (fm.top_k.has_value())lines 978–978tc.top_k = *fm.top_k;lines 979–979◇ if (fm.min_p.has_value())lines 979–979tc.min_p = *fm.min_p;lines 980–980◇ if (fm.presence_penalty.has_value())lines 981–981tc.presence_penalty = *fm.presence_penalty;lines 983–983◇ if (fm.frequency_penalty.has_value())lines 984–984tc.frequency_penalty = *fm.frequency_penalty;lines 987–987◇ if (fm.repeat_penalty.has_value())lines 987–987tc.repeat_penalty = *fm.repeat_penalty;lines 988–988◇ if (fm.enable_thinking.has_value())lines 989–989tc.enable_thinking = *fm.enable_thinking;

Requirements

REQ-API-013

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
lines 1076–1076◇ for (auto& [name, tier] : h->config.models.tiers)lines 1077–1077std::filesystem::path id_path;lines 1078–1078◇ if (tier.identity.has_value())lines 1079–1079id_path = tier.identity.value();lines 1080–1080elselines 1080–1080◇ if (!tier.identity_disabled)lines 1081–1081id_path = data_dir / "prompts" / ("identity_" + name + ".md");lines 1083–1083◇ if (id_path.empty() || !std::filesystem::exists(id_path))lines 1084–1084continue;lines 1086–1086entropic::prompts::ParsedIdentity id;lines 1087–1087◇ if (entropic::prompts::load_identity(id_path, id).empty())lines 1088–1088thread_frontmatter_sampler(tier, id.frontmatter);

Requirements

REQ-API-013

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
lines 2006–2007auto err = entropic::prompts::validate_configured_prompts( h->config, data_dir);lines 2008–2008entropic_error_t rc = ENTROPIC_OK;lines 2009–2009◇ if (!err.empty())lines 2010–2010h->last_error = err;lines 2011–2011s_log->error("configure: {}", err);lines 2012–2012rc = ENTROPIC_ERROR_INVALID_CONFIG;lines 2014–2014return rc;

Requirements

REQ-API-004

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

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
lines 2044–2046auto warning = entropic::config::warn_unresolved_tier_grammars( h->config, entropic::config::grammar_search_paths(h->config, data_dir));lines 2047–2047◇ if (!warning.empty())lines 2048–2048s_log->warn("configure: {}", warning);

Requirements

REQ-INFER-007

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

Show on the map →

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);
}
Activity · 8 steps
lines 1136–1140h->tool_executor = std::make_unique<entropic::ToolExecutor>( *h->server_manager, h->engine->loop_config(), h->engine->callbacks(), h->engine->build_directive_hooks());lines 1141–1141entropic::ToolExecutionInterface tei;lines 1142–1147tei.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); };lines 1148–1148tei.user_data = h->tool_executor.get();lines 1149–1149tei.history_json = tool_history_json_thunk;lines 1150–1150tei.free_fn = [](char* p) { std::free(p); };lines 1153–1158h->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);lines 1159–1159h->engine->set_tool_executor(tei);

Requirements

REQ-API-013 REQ-MCP-014