Skip to content

Compatibility and Epochs

Caliper versions the ABI, the services, the SDK, the applets and their stored data separately. Each one changes without breaking applets that are already built.

flowchart LR
    manifest[Applet manifest] -->|declares epoch and services| host[Host checks]
    host -->|a check fails| refused[REFUSED with reason]
    host -->|all checks pass| load[Open library]
    load -->|descriptor and data checks| run[create and initialize]

The loader does not download dependencies.

The host is a service registry, not a struct of fields. Applets obtain capabilities by name through a single extension point:

struct CaliperHost {
    uint32_t    struct_size;
    uint32_t    abi_epoch;          // epoch this host is speaking
    uint32_t    host_version;       // (major<<16)|(minor<<8)|patch, informational
    const char* applet_data_dir;    // per-applet data folder, UTF-8
    /* THE extension point. Returns a service table or NULL. The pointer is
       valid for the applet's lifetime. Unknown ids return NULL — never UB. */
    const void* (*get_service)(const CaliperHost* host, const char* service_id);
};

New capabilities arrive as new service ids and never change the base ABI. Thus the base ABI stays small and stable while the host grows. Every applet must cope with a missing service, which the fallback rule in Architecture already requires.

Toolchain Contract

A binary applet is compatible with a host only when both use the same toolchain family for the platform.

Platform Compiler and runtime Notes
macOS arm64 AppleClang with libc++ macOS 14 (Sonoma) or later. Every binary targets macOS 14.0.
Windows x64 MSVC with the dynamic CRT (/MD) Host and applets share one CRT heap.

On Windows the dynamic CRT is the default, and thus the CRT state of the host and of every applet agrees: heap, locale, FILE* and errno. The CMake option CALIPER_STATIC_CRT=ON selects the static runtime (/MT) for a build that needs it. Linux is not a supported platform.

ABI Hygiene

Every type that crosses the boundary follows the same rules:

  • C types only. The C++ sugar catches every exception at the edge and reports it through caliper.log.v1.
  • No third-party C++ or graphics-API type in any signature. Applets draw through ImGui, ImPlot and textures from caliper.tensor_bridge, so the renderer stays swappable.
  • The side that allocated memory frees it. A string or buffer that the host returns is host-owned, and its header documents how long it stays valid.
  • Every string is UTF-8 const char*, and every struct is a plain struct with struct_size first.

Excluded Boundary Types

Type Why not Interchange used
torch::Tensor The libtorch C++ ABI differs between versions and builds, so using it would tie every applet to the host's torch. CaliperTensor: a raw pointer with dtype, shape, strides and device. See Tensor.
duckdb::* The same reason. SQL strings in, Arrow C streams out. See Arrow.
std::string, std::vector The libstdc++, libc++ and MSVC layouts differ. const char*, or a pointer and a length.
Exceptions They are undefined across runtimes. A bool or error-code return, plus caliper.log.v1.
ImGui, Metal and Vulkan handles They would fix the renderer. CaliperTextureId, an opaque 64-bit handle.

The UI contexts do cross, because applets write raw ImGui. caliper.ui.v1 hands over the ImGui, ImPlot and ImPlot3D contexts together with the host's allocator pair. The caliper::ui::connect(host) call in the sugar installs both. On Windows, an applet DLL would otherwise free ImGui memory on its own heap.

Versioning

Four layers are versioned separately, so a change in one rarely forces a change in another.

Layer What it versions Scheme Declared in
The host ABI epoch and service revisions The entry points, the CaliperHost layout and the UI-stack pin, and each service table An integer epoch, 3 now. A service id with a revision suffix. [compat].abi_epoch and [services]
The SDK version The installed caliper-sdk package Semver [build].sdk, written by the build
Each applet's version The applet and what it requires Semver, chosen by the applet's author [applet].version, [compat] and [services]
The version of stored data The applet's data folder An integer of at least 1, chosen by the applet's author [data].schema

The host application has its own semver version, which an applet compares against in [compat].min_host. Manifest lists the keys.

Host ABI Epoch and Service Revisions

The ABI epoch is an integer that versions the frozen contract. The contract is the entry points in abi.h, the CaliperHost layout and the UI-stack pin. A host speaks exactly one epoch, and the epoch check is exact equality. Before it opens an applet's library, the host compares [compat].abi_epoch with its own epoch. It refuses an applet built for an older or a newer epoch, so an epoch change means a rebuild of every applet. After it opens the library, the host checks that the descriptor carries the same epoch.

Within an epoch, the id of a service carries its version. caliper.tensor_bridge.v1 is the first version of a table. The ids caliper.tensor_bridge.v1_1 and caliper.tensor_bridge.v1_2 are revisions that append to it. A major id such as caliper.metrics.v2 is reserved for an incompatible change. Epoch 3 removed the applet-facing geometry service (caliper.geometry.v1 to v1_3) and export service (caliper.export.v1 and caliper.export.v1_1). An applet built for epoch 2 is refused before its library opens.

Why epochs, not a rolling ABI

Applets write raw ImGui against the host's headers and share its ImGui context. Thus the UI-stack pin is part of the epoch. The pin is the exact ImGui, ImPlot, ImPlot3D and ImGuiFileDialog versions and the imconfig. A change of the pin costs an applet rebuild instead of a silent break. See Architecture.

Growth rules

These four rules let the contract grow without breaking an applet that is already built:

  1. A published service table is immutable. A new capability ships as a new service id with a revision suffix, such as caliper.metrics.v1_1, caliper.tensor_bridge.v1_2 or caliper.ui.v1_1. The new table starts with a byte-identical copy of the previous table and appends its new entries. The host keeps serving every older id unchanged, so an applet that asks for caliper.tensor_bridge.v1 still gets the original table. If a revision adds behavior that a host may not provide, one caps() bit per revision says so. A change that cannot be made by appending gets a new major id, served beside the old one.
  2. Hosts may provide any set of services. An applet lists the services it cannot run without in [services].required and probes optional ones at run time. A host that lacks a required service refuses the applet, and the landing screen lists it as REFUSED with the reason.
  3. struct_size is always the first field. A reader never touches bytes beyond the size that the writer declared.
  4. The ABI epoch changes only for an entry-point change, a CaliperHost layout change, a UI-stack pin change or the removal of a published service.

Under these rules, an applet built years ago keeps running on a new host. A new applet checks for a newer id and falls back when the host lacks it. The ABI tests pin every frozen layout.

SDK Version

The SDK is the installed caliper-sdk package, and it uses semver. From version 1.0 on, the three numbers have these meanings:

  • A patch version fixes the SDK without a change to what it offers.
  • A minor version adds services, sugar or build helpers within the same epoch.
  • The major version changes when the epoch changes, and only then.

Thus each major version builds applets for one epoch. Before 1.0, a minor version may also change the epoch.

The package's version file uses the CMake SameMajorVersion rule. The call find_package(caliper-sdk <version>) accepts an installed SDK with the same major version, at or above the requested one. Without a version, it accepts any installed SDK. While the major version is 0, a request for 0.2 also accepts a later 0.x SDK built for another epoch. Then caliper_add_applet() stops the configure, because the abi_epoch of the manifest must equal the epoch of the SDK.

The build records how it built an applet. caliper_add_applet() copies the manifest that the author writes to the folder beside the built library and adds a [build] table to the copy (SDK package). Nobody writes the [build] table by hand. It holds two keys:

  • [build].sdk is the SDK version that built the applet. It is a record for diagnosis, and the host never compares it. The epoch, the UI-stack hash and service negotiation decide compatibility.
  • [build].ui_stack is a hash of the ImGui version number, the checked-out commits of ImGui, ImPlot, ImPlot3D and ImGuiFileDialog, the imconfig.h and the UI-stack definitions that the applet used (The UI-stack hash). Uncommitted edits to those sources do not change it. The epoch number does not catch a mismatch such as a changed imconfig, and such a mismatch crashes the shared ImGui context. If the key is present and differs from the host's hash, the host refuses the applet before it opens the library. A manifest without the key, or a host built without a hash, is not checked.

Applet Versions and Requirements

The [applet].version of an applet is strict semver, chosen by its author. The descriptor compiled into the library must carry the same string. The manifest also states what the applet requires, and the host checks each requirement before it opens the library:

Requirement Key The host accepts the applet when
ABI epoch [compat].abi_epoch The value equals the host's epoch.
Oldest host [compat].min_host The host's version is at least this one, compared numerically. Without the key there is no floor.
Required services [services].required The host serves every id. The refusal names the first missing one, and the host checks the binary's own list again after it opens the library.
Optional services [services].optional Always. The applet probes these services at run time and falls back when one is missing.
libtorch [compat].torch The value equals the version of the libtorch that the host provides. Applets that do not link libtorch leave the key out.

A process loads one libtorch, which the host provides for every applet in it (see Embedding). The libtorch C++ ABI differs between versions, so an applet that links libtorch runs only beside the exact version it used at build time. A host that provides no libtorch, such as one built with CALIPER_WITH_TORCH=OFF, refuses every applet that sets [compat].torch. The call caliper_add_applet(... TORCH) writes the key into the built manifest, with the libtorch version that the SDK names.

Several copies of one applet

Several copies of one applet id can be installed at once, such as a shipped copy, a user copy and a development build. The host loads one copy per id. It takes the highest version whose library is present and that passes every check made before the library opens. These checks are the requirements above, the UI-stack hash and the data schema. If the host refuses the newest copy, it falls back to the next highest, and so on. The choice never runs applet code. The landing screen lists every copy: a refused copy with its reason, and each other passing copy as SHADOWED, with the name of the chosen copy.

The host searches in this order:

  1. The development folders: the caliper dev folder, those given with --applets <dir> in order, then those in CALIPER_APPLET_PATH (see Caliper CLI).
  2. The applets/ folder of the open workspace, which holds spec applets only.
  3. The user applets folder.
  4. The applets/ folder beside the executable, which holds the applets shipped with the app.

Spec applets and compiled applets share one set of ids, and the same rule compares their copies. A spec applet has no library. It passes when its spec file is in place and the host meets its min_host and spec format version.

Version decides, and the search order only breaks ties between equal versions in favor of the copy found first. Thus a development build replaces an installed copy only when its version is at least as high.

Stored Data Versions

Each applet owns a data folder, data/<id>/ under the app-data root, which the host passes to it as applet_data_dir. [data].schema is an integer of at least 1 that versions what the applet stores there.

  • The applet migrates its own data upward in initialize(). A version that finds data written under a lower schema converts it before use. The host never migrates the data.
  • The host records the highest schema that has opened the folder in a stamp file, .caliper-data.toml. It raises the stamp before it calls create() and initialize(), because migration begins there. Thus data that a failed initialize() left half-migrated is still marked. The stamp belongs to the host, and the applet does not write or remove it.
  • The host refuses an applet whose declared schema is lower than the recorded one, before it opens the library. With the fallback in Several copies of one applet, this stops an older version from opening data written under a higher schema.
  • An applet that declares no schema is never checked and leaves the stamp unchanged. An older version without the key can open data that a newer version migrated. Thus an applet that stores data declares a schema from its first version that does.

An author raises the schema when a change to the stored data makes it unreadable for older versions. The author keeps it when older versions can still read the data.

Promotion Rule

A feature moves into the core only when a second applet needs it. Until then it stays in the applet that built it. A published table cannot be taken back, so a service comes from working code.

A promoted feature arrives as a new service id or as a new revision of an existing service, never as a change to a published table (see Growth rules). From then on:

  • An applet that needs the feature declares the new service id. A host that lacks the service refuses the applet when the id is in [services].required. The applet falls back when the id is in [services].optional.
  • An applet that bundles its own copy of the feature keeps working unchanged, because nothing it depends on changed. It can move to the service in a later release of its own.

Sugar that is compiled into the applet, such as the caliper::viz components, needs nothing from the host at run time. It arrives in a minor version of the SDK, changes no table, and reaches an applet when the applet is rebuilt.

Load Negotiation

The checks run in order, and the first nine happen before dlopen. The first failure becomes the status of the applet on the landing screen, with the reason (see Refusal messages), instead of a loader crash:

  1. The manifest parses, with a valid, path-safe id.
  2. The platform binary is present.
  3. The abi_epoch of the manifest equals the host's epoch.
  4. min_host is satisfied.
  5. [build].ui_stack equals the host's UI-stack hash, when both are present.
  6. [compat].torch equals the host's libtorch version, when the key is present.
  7. The required services are available (the list in the manifest).
  8. [data].schema is not lower than the recorded schema, when the key is present.
  9. Of the copies of one id that pass, the host chooses the highest version.
  10. The data-schema check runs again, then dlopen.
  11. The descriptor id, version and epoch agree with the manifest.
  12. The required services are available (the list in the binary).
  13. The host raises the data-schema stamp, then create and initialize run.