MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / conflict_log_record

Function conflict_log_record

src/daemon/service.c:280–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278}
279
280static bool conflict_log_record(const cbm_daemon_conflict_t *conflict,
281 char out[DAEMON_SERVICE_LOG_RECORD_CAP], size_t *length_out) {
282 char active[DAEMON_SERVICE_ESCAPED_VERSION_CAP];
283 char requested[DAEMON_SERVICE_ESCAPED_VERSION_CAP];
284 const char *reason = conflict ? conflict_reason(conflict->status) : NULL;
285 if (!length_out || !reason || !conflict_valid(conflict) ||
286 !json_escape_version(conflict->active_version, active) ||
287 !json_escape_version(conflict->requested_version, requested)) {
288 return false;
289 }
290 time_t timestamp = time(NULL);
291 if (timestamp == (time_t)-1) {
292 return false;
293 }
294 int written;
295 if (conflict->status == CBM_DAEMON_HELLO_CACHE_CONFLICT) {
296 written = snprintf(out, DAEMON_SERVICE_LOG_RECORD_CAP,
297 "{\"event\":\"daemon.version_conflict\",\"timestamp_unix_s\":%lld,"
298 "\"reason\":\"%s\",\"active_cache\":\"%s\","
299 "\"requested_cache\":\"%s\",\"active_version\":\"%s\","
300 "\"active_build\":\"%s\",\"requested_version\":\"%s\","
301 "\"requested_build\":\"%s\"}\n",
302 (long long)timestamp, reason, conflict->active_cache_fingerprint,
303 conflict->requested_cache_fingerprint, active,
304 conflict->active_build_fingerprint, requested,
305 conflict->requested_build_fingerprint);
306 } else {
307 written = snprintf(out, DAEMON_SERVICE_LOG_RECORD_CAP,
308 "{\"event\":\"daemon.version_conflict\",\"timestamp_unix_s\":%lld,"
309 "\"reason\":\"%s\","
310 "\"active_version\":\"%s\",\"active_build\":\"%s\","
311 "\"requested_version\":\"%s\",\"requested_build\":\"%s\"}\n",
312 (long long)timestamp, reason, active, conflict->active_build_fingerprint,
313 requested, conflict->requested_build_fingerprint);
314 }
315 if (written < 0 || written >= DAEMON_SERVICE_LOG_RECORD_CAP) {
316 return false;
317 }
318 *length_out = (size_t)written;
319 return true;
320}
321
322#ifndef _WIN32
323

Callers 1

Calls 3

conflict_reasonFunction · 0.85
conflict_validFunction · 0.85
json_escape_versionFunction · 0.85

Tested by

no test coverage detected