Skip to content

libmoss v0.33.0

Choose a tag to compare

@moss-release-bot moss-release-bot released this 23 Nov 16:00
· 5 commits to main since this release
75e5fe4

Precompiled C SDK binaries for the Moss SDK.

Added

  • moss_client_new_with_options, moss_client_new_with_device_id_and_options, moss_client_new_with_authenticator_and_options and moss_client_new_with_authenticator_device_id_and_options take the arguments of moss_client_new, moss_client_new_with_device_id, moss_client_new_with_authenticator and moss_client_new_with_authenticator_and_device_id, plus a const MossClientOptions * before out. NULL options are the defaults, which the constructors without options use. Zero a MossClientOptions, then set struct_size to sizeof(MossClientOptions) and version to MOSS_CLIENT_OPTIONS_VERSION, 1. A smaller struct_size, another version or an unknown flag bit fails with ERR_INVALID_ARG. The MOSS_CLIENT_OPTIONS_FLAG_KEEP_MODELS flag, off by default, keeps each model the client loads after the last client or session that uses it is freed, for later clients of the same project in the process, until the grant it was opened under is within 30 seconds of expiring. A client created then loads a cached index without opening the model again, once its own grant for the same artifact arrives. The flag works on every platform, iOS and Android included.
  • moss_client_release_memory frees at once each kept model that no client or session holds. With a NULL client it frees only those models and writes 0 to out_unloaded, instead of failing with ERR_NULL_POINTER, so a host can answer memory pressure while no client is open.

Changed

  • Breaking change: moss_client_session and moss_client_session_v2 fail when the load of the cloud index of the same name fails, with that load's code, and leave *out NULL. For example, ERR_CLOUD when the Moss cloud cannot be reached, ERR_UNAUTHORIZED when the service rejects the credentials or the project is over its usage limit, ERR_INVALID_ARG when the service refuses the index's model artifact with HTTP 409, and ERR_DESERIALIZATION when the artifact's provenance is malformed or does not match the downloaded index. They used to log the failure and return an empty session, which a later moss_session_push_index could push over the cloud index. An index that does not exist yet, or a name the cloud cannot address, still opens an empty session. MOSS_SESSION_OPTIONS_V2_FLAG_SKIP_AUTO_LOAD_ON_INIT on moss_client_session_v2 skips the load, which moss_client_session cannot; unless model_id is custom, opening still checks the project credentials, which a client with a project key does over the network.
  • moss_set_model_cache_dir() installs the panic hook, as moss_sdk_version() does, so a host that never asks for the version still gets the panic message in moss-panic.log in the model cache directory. A panic aborts the process, as it did before, and the README says so under Error Handling.
  • A client or session that reuses an embedding model another client of the project holds, or one that MOSS_CLIENT_OPTIONS_FLAG_KEEP_MODELS kept, now asks the issuer for its own grant first. That adds one round trip and still skips the decrypt and session start. A client the issuer refuses now fails to load the model instead of using one another client opened.

Fixed

  • A session keeps its saved snapshot to itself while it serves vectors from it, also after moss_session_save_to_disk writes a new generation. moss_session_load_from_disk and moss_session_save_to_disk of the same session name and cache path in a second session, in this process or another, fail with ERR_INTERNAL and the message "The saved session snapshot is open in another session." until the first session is freed. A save used to replace the file that held the lock, so after one save a second session could load and save the same snapshot beside the first and overwrite its saves. The lock is the file session.lock in the session's directory, and it holds on Windows too. Loading from a directory this process cannot write works when the snapshot already has its session.lock, which every save writes, and fails otherwise. A snapshot that an earlier version saved has none. Add an empty session.lock file to its directory, or load a copy: while nothing saves to the snapshot, copy its directory under the same name into another directory, make the copy writable by the process, and pass that other directory as the cache path. On iOS and Android, a .mossvec that moss_client_load_index maps from cache_path is locked through a .lock file beside it. A second client that loads the same index from the same cache_path while the first holds it does not fail: it keeps that index's vectors in memory instead of mapping the file. Earlier versions take neither lock file, so a process on one of them and a process on this version do not lock each other out. Keep every process on an earlier version stopped while a process on this version has the same cache path open.
  • A client, session or MossInference built before fork() works in the forked child instead of hanging there. The child starts a runtime of its own for it on first use, and an inference client its own connections too, keeps the indexes the parent loaded, and starts its own telemetry. A child whose runtime fails to start with an I/O error fails that call with ERR_INTERNAL, and its next call tries again. A fork while another thread is inside a call on the same client or session is not supported. A query in a forked child no longer waits forever once the parent has run a query.

Platforms

Archive OS Arch
libmoss-v0.33.0-aarch64-apple-darwin.tar.gz macOS ARM64 (Apple Silicon)
libmoss-v0.33.0-x86_64-unknown-linux-gnu.tar.gz Linux x86_64
libmoss-v0.33.0-aarch64-unknown-linux-gnu.tar.gz Linux ARM64
libmoss-v0.33.0-x86_64-pc-windows-msvc.tar.gz Windows x86_64

Contents

Each archive contains:

  • include/libmoss.h - C header
  • lib/libmoss.dylib, lib/libmoss.so or lib/moss.dll - shared library
  • LICENSE.txt - the license of the library
  • LICENSE-THIRD-PARTY.txt - licenses of the third-party code the library links

Windows archives also contain the DLL import library lib/moss.dll.lib.

License

The library is licensed under the PolyForm Shield License 1.0.0, not under this repository's BSD 2-Clause License.

Required Notice: Copyright InferEdge Inc. (https://inferedge.dev)

Usage

Extract, then compile and link. The macOS dylib ships with an
@rpath/libmoss.dylib install name, so pass an -rpath that
resolves to lib/ or the binary aborts at launch with
"Library not loaded: @rpath/libmoss.dylib ... no LC_RPATH's found":

# macOS
clang your_app.c -o your_app -Iinclude -Llib -lmoss \
  -Wl,-rpath,@loader_path/lib \
  -framework Security -framework SystemConfiguration

# Linux
gcc your_app.c -o your_app -Iinclude -Llib -lmoss -lpthread -lm -ldl