Loading...
Searching...
No Matches
gpr::runtime Namespace Reference

Classes

struct  Component

Functions

void registerComponent (Component component)
std::vector< Component > components ()
 A stable snapshot including the linked ABI dependencies.
std::string manifestJson ()
std::string manifestSha256 ()

Function Documentation

◆ components()

std::vector< Component > gpr::runtime::components ( )
nodiscard

A stable snapshot including the linked ABI dependencies.

Definition at line 129 of file RuntimeManifest.cpp.

130{
131 return sortedSnapshot();
132}

◆ manifestJson()

std::string gpr::runtime::manifestJson ( )
nodiscard

Canonical JSON record used by run provenance. Keys and components are sorted. The top-level sha256 identifies the same record with that digest field omitted, avoiding a self-referential hash.

Definition at line 134 of file RuntimeManifest.cpp.

135{
136 const auto snapshot = sortedSnapshot();
137 const auto payload = manifestJsonWithoutDigest(snapshot);
138 const auto digest = sha256Hex(payload.data(), payload.size());
139 std::ostringstream out;
140 out << "{\"components\":[";
141 for (std::size_t i = 0; i < snapshot.size(); ++i) {
142 if (i) out << ',';
143 out << componentJson(snapshot[i]);
144 }
145 out << "],\"format\":\"gpridge-runtime-components\",\"sha256\":"
146 << quote(digest) << ",\"version\":1}";
147 return out.str();
148}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out
std::string sha256Hex(const void *data, std::size_t size)
Lowercase hexadecimal SHA-256 digest of a byte range (FIPS 180-4).
Definition Sha256.cpp:127

◆ manifestSha256()

std::string gpr::runtime::manifestSha256 ( )
nodiscard

Definition at line 150 of file RuntimeManifest.cpp.

151{
152 const auto manifest = manifestJsonWithoutDigest(sortedSnapshot());
153 return sha256Hex(manifest.data(), manifest.size());
154}

◆ registerComponent()

void gpr::runtime::registerComponent ( Component component)

Register a component observed by a driver or loader. Re-registering the same role/name replaces it, so repeated setup stays deterministic.

Definition at line 115 of file RuntimeManifest.cpp.

116{
117 const std::lock_guard<std::mutex> lock(registry_mutex);
118 const auto existing = std::find_if(
119 registry.begin(), registry.end(), [&](const Component& current) {
120 return current.role == component.role &&
121 current.name == component.name;
122 });
123 if (existing == registry.end())
124 registry.push_back(std::move(component));
125 else
126 *existing = std::move(component);
127}