Skip to content

feat(phase2): belief propagation, packet bridge, graph query, compliance validator#90

Open
cryptoxdog wants to merge 3 commits into
mainfrom
feat/belief-propagation-phase2
Open

feat(phase2): belief propagation, packet bridge, graph query, compliance validator#90
cryptoxdog wants to merge 3 commits into
mainfrom
feat/belief-propagation-phase2

Conversation

@cryptoxdog

Copy link
Copy Markdown
Collaborator

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_chain
  • hop_trust_from_entry — COMPLETED=0.95, PENDING=0.60, FAILED/TIMEOUT=0.10 + timeout-proximity penalty
  • rescore_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.

…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.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Mar 31, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@cryptoxdog has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 14 minutes and 16 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8d612ba8-29b3-4329-b865-89ea8bd38c1c

📥 Commits

Reviewing files that changed from the base of the PR and between 4c0fb58 and 3b49fd1.

📒 Files selected for processing (108)
  • chassis/errors.py
  • docs/integration_runbook.md
  • engine/arbitration/engine.py
  • engine/arbitration/schema.py
  • engine/auth/capabilities.py
  • engine/boot.py
  • engine/causal/attribution.py
  • engine/causal/causal_compiler.py
  • engine/compliance/audit_persistence.py
  • engine/compliance/validator.py
  • engine/contract_enforcement.py
  • engine/convergence_controller_patch.py
  • engine/diagnostics/__init__.py
  • engine/diagnostics/dissimilarity.py
  • engine/diagnostics/fingerprint.py
  • engine/gates/packet_bridge.py
  • engine/gds/scheduler.py
  • engine/graph/circuit_breaker.py
  • engine/graph/community_export.py
  • engine/graph/driver.py
  • engine/graph/graph_sync_client_fix.py
  • engine/graph_return_channel.py
  • engine/handlers.py
  • engine/hoprag/config.py
  • engine/hoprag/indexer.py
  • engine/inference_bridge.py
  • engine/inference_rule_registry.py
  • engine/kge/cross_dimensional_ensemble.py
  • engine/models/outcomes.py
  • engine/outcomes/schema.py
  • engine/packet/bridge.py
  • engine/packet/packet_store.py
  • engine/personas/composer.py
  • engine/personas/suppression.py
  • engine/personas/synthesis.py
  • engine/scoring/assembler.py
  • engine/scoring/belief_propagation.py
  • engine/scoring/confidence.py
  • engine/scoring/helpfulness.py
  • engine/scoring/importance.py
  • engine/scoring/pareto_integrator.py
  • engine/scoring/weight_discovery.py
  • engine/security/P2_9_llm_schemas.py
  • engine/startup_wiring.py
  • engine/state.py
  • engine/traversal/edge_merger.py
  • engine/traversal/graph_query.py
  • engine/traversal/multihop.py
  • engine/traversal/pseudo_query.py
  • engine/utils/logger.py
  • l9_core/models.py
  • tests/conftest.py
  • tests/contracts/test_contracts.py
  • tests/gap_fixes/test_gap1_contract.py
  • tests/gap_fixes/test_gap2_return_channel.py
  • tests/gap_fixes/test_gap3_inference_registry.py
  • tests/gap_fixes/test_gap5_audit.py
  • tests/integration/test_admin_handler.py
  • tests/integration/test_graph_driver.py
  • tests/integration/test_handlers.py
  • tests/integration/test_handlers_integration.py
  • tests/integration/test_hoprag_pipeline.py
  • tests/integration/test_match_handler.py
  • tests/integration/test_outcomes_handler.py
  • tests/integration/test_sync_handler.py
  • tests/invariants/test_compliance.py
  • tests/invariants/test_configuration.py
  • tests/invariants/test_trust_boundary.py
  • tests/performance/test_query_latency.py
  • tests/performance/test_sync_throughput.py
  • tests/property/test_gates_property.py
  • tests/property/test_scoring_property.py
  • tests/scoring/test_benchmark.py
  • tests/security/test_compliance_security.py
  • tests/security/test_injection.py
  • tests/test_algorithmic_upgrades.py
  • tests/test_pareto_wiring.py
  • tests/unit/test_arbitration.py
  • tests/unit/test_belief_propagation.py
  • tests/unit/test_compliance_checker.py
  • tests/unit/test_cross_dimensional_ensemble.py
  • tests/unit/test_cypher_utils.py
  • tests/unit/test_domain_loader.py
  • tests/unit/test_edge_merger.py
  • tests/unit/test_gate_compiler.py
  • tests/unit/test_gates_packet_bridge.py
  • tests/unit/test_graph_query.py
  • tests/unit/test_handlers_enrich_health.py
  • tests/unit/test_handlers_extended.py
  • tests/unit/test_hgkr_gds_dag.py
  • tests/unit/test_loader.py
  • tests/unit/test_multihop_traversal.py
  • tests/unit/test_outcomes.py
  • tests/unit/test_packet_bridge.py
  • tests/unit/test_parameter_resolver.py
  • tests/unit/test_persona_composer.py
  • tests/unit/test_persona_selector.py
  • tests/unit/test_persona_synthesis.py
  • tests/unit/test_sanitize.py
  • tests/unit/test_scoring_assembler.py
  • tests/unit/test_sync_and_traversal.py
  • tests/unit/test_sync_generator.py
  • tests/unit/test_traversal_assembler.py
  • tests/unit/test_wave4_state_resilience.py
  • tests/unit/test_wave6_dormant_features.py
  • tools/contract_report.py
  • tools/hoprag_benchmark.py
  • tools/validate_domain.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/belief-propagation-phase2

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

PR Too Large
Lines changed: 1597
Limit: 1000 lines
Action Required: Break into smaller, atomic PRs

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Separate from manual changes

🚫 This PR is blocked from merging until size limits are met.

IgorBot and others added 2 commits April 3, 2026 13:13
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.
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown

Too Many Files Changed
Changed: 108 files
Limit: 50 files
Action Required: Split into multiple focused PRs

PR Too Large
Lines changed: 3258
Limit: 1000 lines
Action Required: Break into smaller, atomic PRs

📋 Best Practices for Large Changes

  1. Refactoring + Features: Separate into 2 PRs
  2. Multiple Features: One PR per feature
  3. Database + Code: Separate migration from logic
  4. Generated Code: Separate from manual changes

🚫 This PR is blocked from merging until size limits are met.

@sonarqubecloud

sonarqubecloud Bot commented Apr 3, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@cryptoxdog

Copy link
Copy Markdown
Collaborator Author

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.

  • CI status: FAILURE
  • Review decision: NONE
  • Draft: False
  • Files changed: 108 (python:99, docs:1)
  • Heuristic scan: error_handling=1, typing=2

Top findings:

  • engine/compliance/audit_persistence.py:16 — Type ignore comment
  • engine/graph/graph_sync_client_fix.py:95 — Broad except Exception
  • engine/traversal/multihop.py:287 — Type ignore comment

Suggested next action: fix failing CI, then request review .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant