feat(scoring): Bayesian belief propagation over trust signals (salvaged from #90) - #153
Open
cryptoxdog wants to merge 1 commit into
Open
feat(scoring): Bayesian belief propagation over trust signals (salvaged from #90)#153cryptoxdog wants to merge 1 commit into
cryptoxdog wants to merge 1 commit into
Conversation
Salvaged from #90, which carried 108 files and could not merge. Two of them are novel and drop in cleanly beside pareto.py and calibration.py; the rest overlap existing modules (multihop.py, compliance/engine.py, engine/packet/bridge.py) and are left behind. Ships the parts that are mathematically sound and pass their own tests: bayesian_update single-step update, symmetric likelihood belief_entropy binary Shannon entropy in bits propagate_chain sequential updating over an ordered hop chain hop_trust_from_entry GATE HopEntry status -> trust, timeout-degraded Pure functions, no side effects, deterministic, outputs bounded [0, 1]. Drops composite_score, chain_composite, and rescore_candidates. Their penalty term subtracted entropy (bits) from a belief (probability), which is dimensionally incoherent and returned values contradicting the functions' own docstring examples. The accompanying tests asserted two incompatible scoring semantics at once -- Bayesian accumulation on one input, weakest-link on another -- so no formula could satisfy them; 8 of 38 failed. The module's citation to a "Theory of Trust" paper does not resolve to any published work and is removed rather than reproduced. Choosing between the two fusion semantics is a product decision, so composite scoring is recorded as DEFERRED-005 instead of guessed at. 31 unit tests + 4 doctests green. ruff, ruff format, mypy, contract scanner clean. Closes #90 Co-authored-by: Cursor <[email protected]>
|
📋 Best Practices for Large Changes
✅ This PR passes the blocking limit but is larger than recommended. |
|
This was referenced Jul 27, 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in 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.




Salvages the two genuinely novel files from #90 and leaves the other 106 behind.
What lands
engine/scoring/belief_propagation.py— pure functions, no side effects, deterministic, outputs bounded[0, 1]. Sits besidepareto.pyandcalibration.py.bayesian_updateevidence = 0.5is uninformativebelief_entropypropagate_chainhop_trust_from_entryHopEntrystatus → trust, degraded by timeout proximitytests/unit/test_belief_propagation.py— 31 tests. Plus 4 doctests in the module.What was dropped, and why
composite_score,chain_composite, andrescore_candidatesare not included.Their penalty term computed
mean_belief - mean_entropy, subtracting bits from a probability. That is dimensionally incoherent, and it produced values contradicting the functions' own docstring examples — the docstring forcomposite_score([0.9, 0.85, 0.8])claimed0.87; the code returned0.44.The accompanying tests could not be repaired because they asserted two incompatible semantics simultaneously:
composite_score([0.9], 0.5) > 0.85— a lone strong signal should score high (Bayesian accumulation)chain_composite([0.95, 0.6, 0.95], 0.6) < 0.7— one mediocre signal should cap the result despite two strong ones (weakest-link)No single formula satisfies both. 8 of the original 38 tests failed for this reason.
The module also cited a "Theory of Trust for Trust-Aware Recommender Systems" paper attributed to Zhang et al. 2015. That work does not resolve to any published paper — the closest real result, Sun/Yu/Han/Liu 2006, uses entropy as a trust metric, not as a subtractive penalty. The citation is removed rather than reproduced.
Choosing between Bayesian accumulation and weakest-link changes candidate ordering on mixed inputs, so it is a product decision. Recorded as DEFERRED-005 rather than guessed at.
Not taken from #90
traversal/graph_query.pymultihop.py,pseudo_query.pycompliance/validator.pycompliance/engine.pygates/packet_bridge.pyengine/packet/bridge.pyVerification
Closes #90
Made with Cursor