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

Function edge_props_confidence

src/graph_buffer/graph_buffer.c:1767–1788  ·  view source on GitHub ↗

Read "confidence": out of an edge property blob. Absent/unparseable * reads as -1 so any edge that carries a confidence outranks one that does * not. */

Source from the content-addressed store, hash-verified

1765 * reads as -1 so any edge that carries a confidence outranks one that does
1766 * not. */
1767static double edge_props_confidence(const char *props_json) {
1768 if (!props_json) {
1769 return CBM_EDGE_CONF_ABSENT;
1770 }
1771 static const char conf_key[] = "\"confidence\":";
1772 const char *p = strstr(props_json, conf_key);
1773 if (!p) {
1774 return CBM_EDGE_CONF_ABSENT;
1775 }
1776 /* strtod answers 0.0 for text it cannot read, and 0.0 is a real
1777 * confidence that beats CBM_EDGE_CONF_ABSENT. So a blob carrying
1778 * "confidence":null used to outrank a clean blob that carries no
1779 * confidence at all, and displace it. Ask strtod where it stopped: an
1780 * end pointer that never moved means it read nothing. */
1781 const char *value = p + sizeof(conf_key) - SKIP_ONE;
1782 char *end = NULL;
1783 double conf = strtod(value, &end);
1784 if (end == value) {
1785 return CBM_EDGE_CONF_ABSENT;
1786 }
1787 return conf;
1788}
1789
1790/* Decide whether an incoming property blob replaces the stored one on a
1791 * duplicate edge key.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected