fix(confidence): stop an unreadable confidence from reading as 0.0 - #1877
Open
CaptainMittens wants to merge 1 commit into
Open
fix(confidence): stop an unreadable confidence from reading as 0.0#1877CaptainMittens wants to merge 1 commit into
CaptainMittens wants to merge 1 commit into
Conversation
strtod answers 0.0 for text it cannot read, and 0.0 is a real confidence in both places that call it. So a property blob carrying a malformed value, such as "confidence":null, came back as a recorded confidence of zero. Two things went wrong with that. In src/graph_buffer/graph_buffer.c, edge_props_confidence answers CBM_EDGE_CONF_ABSENT (-1) when an edge carries no confidence, so any real confidence outranks it. A malformed value answered 0.0, which beats -1 in the merge comparison, so the malformed blob displaced a clean stored one. The function's own comment already promised that "absent/unparseable reads as -1". Only the absent half was true. In src/mcp/mcp.c, bfs_edge_evidence_for_hop sets the confidence to -1 and the emitter publishes any value of 0 or more as a recorded number. A malformed value printed as 0.00, which reads as "the resolver was certain this is wrong" rather than "nobody wrote a number here". Both sites now pass an end pointer to strtod and keep the absent sentinel when the pointer never moved, which is the shape src/store/store.c:402 already uses. Two tests come with the change, and both were seen failing before the fix and passing after: gbuf_edge_props_unreadable_confidence_does_not_displace_absent tool_trace_path_unreadable_confidence_reports_not_recorded Red: 258 passed, 2 failed. Green: 260 passed, 0 failed. The full suite reports 7633 passed, 2 failed. Both failures are in tests/test_cli.c (lines 1749 and 6725) and reproduce on a clean tree without this change. They depend on the coding agents installed on the machine, not on this change. make -f Makefile.cbm lint-ci passes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Joshua Richter <jrichter5781@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
This was referenced Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
strtodanswers0.0for text it cannot read. Two places treat the numberit returns as a real confidence, so a property blob carrying a malformed
value —
"confidence":null, an empty string, anything non-numeric — cameback as a recorded confidence of zero. Zero is a meaningful value in
both places, so nothing looked wrong.
1.
src/graph_buffer/graph_buffer.c— the wrong blob wins a mergeedge_props_confidenceanswersCBM_EDGE_CONF_ABSENT(-1) for an edgethat carries no confidence, so that any real confidence outranks it. The
merge in
edge_props_should_replaceis a plain comparison:A malformed value answered
0.0, which beats-1. So a blob whoseconfidence the code cannot even read displaced a clean stored blob that
simply carried no confidence at all. The stored
"strategy"went with it.The function's own doc comment already promised the correct behaviour:
Only the absent half was true.
2.
src/mcp/mcp.c— "not recorded" published as0.00bfs_edge_evidence_for_hopsets the confidence to-1.0first, and theemitter publishes any value of
0or more as a recorded number(
%.2fin the text renderer, a real in the JSON renderer) and-/nullbelow zero. A malformed value therefore printed as
0.00.That is the one number the surrounding code works to keep meaningful. A
caller reading
0.00cannot tell "the resolver was certain this call iswrong" from "nobody wrote a number here".
The fix
Both sites now pass an end pointer to
strtodand keep the absent sentinelwhen the pointer never moved — nothing was read. This is the shape
src/store/store.c:402already uses.Only the unreadable case changes. A real
0.0still reads as0.0everywhere, and every existing confidence test passes untouched.
Tests
Two tests come with the change. Both were seen failing before the fix and
passing after — not written after the fact.
gbuf_edge_props_unreadable_confidence_does_not_displace_absenttests/test_graph_buffer.ctool_trace_path_unreadable_confidence_reports_not_recordedtests/test_mcp.cEach carries positive controls, so a later failure points at the confidence
and not at a broken request. The mcp test asserts the hop and its readable
strategyclass still come through, then asserts the output holds no0.00.Red, before the fix:
Green, after the fix:
Checks run
make -f Makefile.cbm test-focused TEST_SUITES="graph_buffer mcp"260 passed, 0 failed, 6 skipped— exit 0make -f Makefile.cbm lint-ci=== CI linters passed ===— exit 0make -f Makefile.cbm cbmmake -f Makefile.cbm test7633 passed, 2 failed, 8 skippedThe two full-suite failures are in
tests/test_cli.c(lines 1749 and 6725)and reproduce on a clean tree without this change. Both print
error: one or more agent cleanup operations failed, so they depend on thecoding agents installed on the machine rather than on anything here.
How this was found
By scanning for siblings of the parse bug fixed in #1875 — the same shape
of "a parse reports success while the input stays unread". These two are
the confidence-sentinel pair from that scan. Four more candidates remain
and will come as separate pull requests.
Checklist
git commit -s(DCO)make -f Makefile.cbm testrunmake -f Makefile.cbm lint-cirun