Docs · Context Exploration Engine
Context Exploration Engine API reference.
Signatures and defaults below are taken from context-exploration-engine/api/include/clio_cee/api/context_interface.h and api/src/python_bindings.cc. The Python names are snake_case versions of the C++ methods with the same defaults.
- Header
- clio_cee/api/context_interface.h
- Module
- clio_cee (nanobind)
- CMake
- find_package(clio_cee_api), clio::cee::api
- MCP
- iowarp-cei-mcp/server.py
ContextInterface (C++)
#include <clio_cee/api/context_interface.h>
namespace iowarp {
class ContextInterface {
public:
ContextInterface(); // does not touch the runtime
~ContextInterface();
int ContextBundle(const std::vector<clio::cae::core::AssimilationCtx> &bundle);
std::vector<std::string> ContextQuery(const std::string &tag_re,
const std::string &blob_re,
unsigned int max_results = 0,
const std::string &prompt = "",
uint64_t time_begin = 0,
uint64_t time_end = 0);
std::vector<std::string> ContextRetrieve(const std::string &tag_re,
const std::string &blob_re,
unsigned int max_results = 1024,
size_t max_context_size = 256 * 1024 * 1024,
unsigned int batch_size = 32,
const std::string &prompt = "",
uint64_t time_begin = 0,
uint64_t time_end = 0);
int ContextSplice(const std::string &new_ctx, const std::string &tag_re,
const std::string &blob_re);
int ContextDestroy(const std::vector<std::string> &context_names);
};
}Initialization
Every public method first calls a private EnsureInitialized(). On the first call it runs clio::run::CLIO_INIT(RuntimeMode::kClient, false), then CLIO_CAE_CLIENT_INIT(), which initializes the CTE client, then checks that the IPC manager exists. If CLIO_INIT fails, the failure is cached in a static flag for the rest of the process and every later call fails immediately. On failure the methods return 1 (bundle, destroy) or an empty vector (query, retrieve) and log an error.
ContextBundle(bundle)
- bundle: vector of
AssimilationCtx. Empty: logs a warning, returns 0. - Creates a
clio::cae::core::ClientonkCaePoolId(400.0), callsAsyncParseOmni(bundle)and waits. - Returns: 0 on success; the task's
result_code_when non-zero; 1 on an exception. The CAE result codes are on the CAE API page.
ContextQuery(tag_re, blob_re, max_results, prompt, time_begin, time_end)
- tag_re, blob_re: full-string regular expressions over tag and blob names.
- max_results (0): result cap. 0 means unlimited for regex and temporal, and 10 for semantic.
- prompt (
""): BM25 query text. Empty disables semantic mode. - time_begin, time_end (0): inclusive bounds on last-modified time; 0 means no bound. Any non-zero value selects temporal mode.
- Mode selection, in order: temporal if either time bound is non-zero; else semantic if
promptis non-empty; else regex. - Calls:
AsyncTemporalSearch(tag_re, blob_re, time_begin, time_end, max_results, PoolQuery::Broadcast()),AsyncSemanticSearch(tag_re, blob_re, prompt, k, PoolQuery::Broadcast())withk = max_results > 0 ? max_results : 10, orAsyncBlobQuery(tag_re, blob_re, max_results, PoolQuery::Broadcast()). - Returns: blob names only. Temporal results are sorted ascending by timestamp; semantic results are ordered by descending score; regex results are in the order the runtime returned them. Empty vector on failure.
ContextRetrieve(tag_re, blob_re, max_results, max_context_size, batch_size, prompt, time_begin, time_end)
- Same mode selection and CTE calls as query, but keeps (tag name, blob name) pairs.
- max_results (1024): same 0 rules as query.
- max_context_size (268435456, 256 MiB): size of one buffer allocated with
CLIO_IPC->AllocateBufferbefore any read. The loop stops at the first blob that would exceed it. - batch_size (32): number of
AsyncGetBlobfutures in flight per batch. For each blob in a batch the code waits onAsyncGetOrCreateTag(tag_name)andAsyncGetBlobSize(tag_id, blob_name)sequentially, skips the blob if the tag id is null or the size is 0, then issuesAsyncGetBlob(tag_id, blob_name, 0, size, 0, ptr)into the next free offset of the buffer. All futures of the batch are then waited; a non-zero return code logs a warning and leaves the reserved bytes in place. - Returns: a vector with one
std::stringholding the bytes written to the buffer, back to back and in query order, or an empty vector when no blob matched or no bytes were copied. The buffer is freed before return.
ContextSplice(new_ctx, tag_re, blob_re)
Not implemented. Logs a warning and returns 1 without initializing anything.
ContextDestroy(context_names)
- context_names: tag names. Empty: logs a warning, returns 0.
- For each name, waits on
AsyncDelTag(name). - Returns: 0 if every delete returned 0, else 1.
clio_cee (Python)
Built with nanobind from api/src/python_bindings.cc. The module docstring is IOWarp Context Exploration Engine API - Python Bindings. Lists map to Python lists and strings to str.
import clio_cee as cee
class cee.ContextInterface:
def __init__(self)
def context_bundle(self, bundle: list[AssimilationCtx]) -> int
def context_query(self, tag_re: str, blob_re: str, max_results: int = 0,
prompt: str = "", time_begin: int = 0, time_end: int = 0) -> list[str]
def context_retrieve(self, tag_re: str, blob_re: str, max_results: int = 1024,
max_context_size: int = 268435456, batch_size: int = 32,
prompt: str = "", time_begin: int = 0, time_end: int = 0) -> list[str]
def context_splice(self, new_ctx: str, tag_re: str, blob_re: str) -> int
def context_destroy(self, context_names: list[str]) -> intArguments can be passed by keyword. Behavior and return values are those of the C++ methods above. context_retrieve returns a list of zero or one str; nanobind converts the packed bytes to str, so binary payloads that are not valid UTF-8 are not safely recoverable through this call.
AssimilationCtx
The CAE's clio::cae::core::AssimilationCtx, bound as cee.AssimilationCtx. Three constructors:
cee.AssimilationCtx()
cee.AssimilationCtx(src, dst, format, depends_on="", range_off=0, range_size=0,
src_token="", dst_token="")
cee.AssimilationCtx(src, dst, format, src_data, depends_on="", range_off=0, range_size=0,
src_token="", dst_token="")The third form is selected by passing a fourth positional argument or the src_data keyword. Read-write attributes:
| Attribute | Type | Default | Meaning |
|---|---|---|---|
src | str | required | Source URL, for example file::/path/to/file or string::<blob_name>. |
dst | str | required | Destination URL, iowarp::<tag_name>. |
format | str | required | Data format: binary, hdf5, hdf5_vol or globus. |
depends_on | str | "" | The src or dst of an earlier item in the same bundle. |
range_off | int | 0 | Byte offset in the source. |
range_size | int | 0 | Bytes to read; 0 means to the end. |
src_token | str | "" | Source credential (HTTP bearer token, Globus access token). |
dst_token | str | "" | Destination credential. |
src_data | str | "" | Inline payload for a string:: source, stored verbatim as one blob named by the part after string::. |
repr() gives <AssimilationCtx src='...' dst='...' format='...'>. The C++ fields s3_region, s3_profile, include_patterns, exclude_patterns, on_fault, chunk_size and blob_prefix are not bound; see the CAE API page for them.
Environment variables
CLIO_CTE_POOL(major.minor): binds the CTE client to an interposing pool. Set563.0or564.0for semantic queries to reach the indexer. A malformed value is ignored with an error in the log.CLIO_WITH_RUNTIME:1ortruemakes the client try to start a runtime in-process; otherwise it only attaches. CEE passes attach-only as the default.CLIO_SERVER_CONF: the runtime configuration file the client reads. Must describe the same runtime the server started.CLIO_BIND_ADDR,CLIO_SERVER_ADDR: bind and connect addresses; use127.0.0.1for both on Windows.
Build and link
- Library target
clio_cee_api(shared, SOVERSION 1, C++20). Aliasclio::cee::api. Linksclio::run::cxx,clio_cte_core_clientandclio_cae_core_clientpublicly. - Installed CMake package
clio_cee_apiunderlib/cmake/clio_cee_api, version 1.0.0, compatibilityAnyNewerVersion. Its config findsclio_run,clio_cte_coreandclio_cae_core. - Python module target
clio_cee, built only withCLIO_CORE_ENABLE_PYTHON=ON, installed toPYTHON_SITE_PACKAGES(and toiowarp_core/extin the pip wheel). - Tests are added under
api/testwhenBUILD_TESTINGis on.
MCP tools
Defined in context-exploration-engine/iowarp-cei-mcp/server.py with FastMCP under the server name IOWarp Context Transfer Engine (CTE) MCP Server. Every tool returns a JSON string. The tools wrap clio_cte_core_ext; there is no tool for clio_cee methods and no semantic or temporal search.
Safe before initialization
get_client_status():available,initialized,pool_query_available,message, plusnoteorwarningwhen something is missing.get_cte_types(): which ofTagId,BlobId,CteTelemetryandPoolQueryare bound, and theCteOpvalues.initialize_cte_runtime(): setsCLIO_REPO_PATHandLD_LIBRARY_PATHto the module's directory, usesCLIO_SERVER_CONFor generates a one-tier file configuration (port 9129 to 9199,num_threads: 2, a 512MBfiletier under the temp directory), callsclio_init(RuntimeMode.kClient, True), waits 0.5 s, callsinitialize_cte(config_path, PoolQuery.Dynamic()), and registers a 512 MB file target at pool id 700.0. Returnssuccess,runtime_init,client_init,cte_init,messages, andtarget_registeredandtarget_pathwhen it got that far. Progress is also written tocte_init_log_<pid>.jsonin the temp directory.
Data operations
put_blob(tag_name, blob_name, data, offset=0):Tag(tag_name).PutBlob(blob_name, data.encode(), offset). Returnsdata_sizeandsuccess.get_blob(tag_name, blob_name, size=0, offset=0): size 0 means the blob's size; a blob of size 0 is reported as not found. Returnsdatawhen the bytes are UTF-8, otherwisedata_base64.get_blob_size(tag_name, blob_name):sizeandsize_bytes.list_blobs_in_tag(tag_name):blobsandcount.delete_blob(tag_name, blob_name):Client.DelBlob(tag_id, blob_name);success.
Query and placement
tag_query(tag_regex, max_tags=0):Client.TagQuerywithPoolQuery.Dynamic();tagsandcount.blob_query(tag_regex, blob_regex, max_blobs=0):Client.BlobQuery;blobsas (tag name, blob name) pairs andcount.poll_telemetry_log(minimum_logical_time=0): entries withop,off,size,tag_id(major,minor,is_null),logical_time, andmod_timeandread_timewhen serializable.reorganize_blob(tag_id_major, tag_id_minor, blob_name, new_score):Client.ReorganizeBlob;result_codeandsuccess.
The query and placement tools return an error object when the client is not initialized, but the README documents that calling them before initialize_cte_runtime can still crash the server process.