feat(phase2): belief propagation, packet bridge, graph query, compliance validator#90
feat(phase2): belief propagation, packet bridge, graph query, compliance validator#90cryptoxdog wants to merge 3 commits into
Conversation
…nce validator Phase 2 core implementation — 10 files, all new, no conflicts with existing code. ### engine/scoring/belief_propagation.py Theory of Trust (ToTh) — Zhang et al. (2015) §3 implementation. - bayesian_update(prior, evidence) → posterior belief [0,1] - composite_score(trust_scores, prior) → entropy-penalized multi-parent fusion - chain_composite(trust_scores, prior) → hop trace quality (same formula, causal semantics) - propagate_chain(trust_scores, prior) → terminal confidence (no entropy penalty) - hop_trust_from_entry(status, duration_ms, timeout_ms) → GATE HopEntry trust signal COMPLETED=0.95 / PENDING|DELEGATED=0.60 / FAILED|TIMEOUT=0.10, timeout-proximity penalty - rescore_candidates(candidates, dimension_keys, prior_key, score_key) → sorted list Call after Neo4j query, before GMP-05 Pareto. Immutable — original candidates unchanged. ### engine/gates/packet_bridge.py PacketEnvelope safety layer for ingress/egress. - validate_packet(packet) → (bool, error) — checks header, 4 required fields, content_hash, payload - wrap_response(result, request_packet, intelligence_quality) → PacketEnvelope response Preserves tenant_id, appends packet_id to lineage chain, computes SHA-256 content_hash. ### engine/traversal/graph_query.py Parameterized Neo4j query execution. - execute_match_query(driver, entity_type, entity_id, dimension_keys, limit) Dynamic RETURN clause from dimension_keys. Values always . - execute_gate_lookup(driver, target_service, action) → endpoint config or None ### engine/compliance/validator.py Fail-fast domain validation layer. - validate_enrichment_request(payload) → (bool, error) Required: entity_id, entity_type (enum: Material/Facility/Buyer/Supplier). Optional: convergence_depth (int 1-5), enable_pareto (bool). - validate_gate_response(response) → (bool, error) Required: header.packet_id, header.status, hop_trace (list). ### engine/utils/logger.py structlog JSON setup. Call setup_logging() once at application startup. ### Tests (35 total) - tests/unit/test_belief_propagation.py — 30 tests across 5 classes - tests/unit/test_gates_packet_bridge.py — 14 tests - tests/unit/test_graph_query.py — 10 tests including injection-safety check - tests/integration/test_handlers_integration.py — 11 tests, no Neo4j required ### docs/integration_runbook.md Wire-up guide for all 3 integration points + trust tier table + formula reference.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 14 minutes and 16 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (108)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
❌ PR Too Large 📋 Best Practices for Large Changes
🚫 This PR is blocked from merging until size limits are met. |
Resolve remaining terminology-guard offenders, eliminate contract-scanner false positives in sanitized causal Cypher builders, and bring ruff back to green with bounded mechanical edits. GMP: Phase 0-6 complete; Scope: shared-blockers remediation on fix/shared-blockers-all-prs; Blast radius: engine/tests/tools mechanical lint+contract fixes; Validation: python3 tools/contract_scanner.py=PASS, ruff check .=PASS, terminology grep=PASS; Note: .pre-commit-config.yaml present but pre-commit executable/module unavailable in this environment.
- carry forward shared-blocker cleanup onto PR #90 branch - sanitize structural label input in engine/traversal/graph_query.py - remove engine-side logging configuration; keep logger accessor only - clear remaining Ruff findings in graph_query and packet-bridge-related tests Verification: - python3 tools/contract_scanner.py ✅ - ruff check . ✅ - pytest tests/unit/test_gates_packet_bridge.py tests/integration/test_handlers_integration.py -q ❌ missing local dependency: neo4j GMP: Phase 0-4 complete; scoped PR90 remediation only; static verification green; dynamic tests blocked by missing neo4j package in this environment.
|
❌ Too Many Files Changed ❌ PR Too Large 📋 Best Practices for Large Changes
🚫 This PR is blocked from merging until size limits are met. |
|
|
Automated PR patrol review — 2026-04-22 UTC Patrol note only; not a human approval. This PR has been open for 537.9h with no review.
Top findings:
Suggested next action: fix failing CI, then request review . |




Phase 2 Core Implementation — 10 new files, no conflicts
engine/scoring/belief_propagation.py
Theory of Trust (ToTh) — Zhang et al. (2015). Entropy-penalized Bayesian belief propagation.
bayesian_update/composite_score/chain_composite/propagate_chainhop_trust_from_entry— COMPLETED=0.95, PENDING=0.60, FAILED/TIMEOUT=0.10 + timeout-proximity penaltyrescore_candidates— drop-in after Neo4j query, before Pareto. Immutable.engine/gates/packet_bridge.py
PacketEnvelope ingress validation + response wrapping with lineage preservation and SHA-256 content hash.
engine/traversal/graph_query.py
Parameterized Cypher execution.
execute_match_query+execute_gate_lookup. Values always $param, injection test included.engine/compliance/validator.py
validate_enrichment_request(entity_type enum, depth range, bool types) +validate_gate_response.engine/utils/logger.py
structlog JSON setup. Call
setup_logging()once at startup.Tests — 35 unit + 11 integration
All pure-Python, no Neo4j required for unit tests.
docs/integration_runbook.md
Wire-up guide for all 3 integration points.