feat: incremental wallet graph updates and shadow model deployment#360
Merged
Inkman007 merged 2 commits intoJun 30, 2026
Conversation
…edger-Lenz#203, Ledger-Lenz#204) Issue Ledger-Lenz#203 — Incremental Graph Update Mechanism: - Add IncrementalWalletGraph to detection/wallet_graph.py with add_trade_edge() (O(1) amortised), remove_stale_edges() (background staleness eviction), and get_ego_subgraph() (BFS-based 2-hop neighbourhood extraction < 10 ms for 500 direct neighbours). - Expose wallet_graph_nodes_total, wallet_graph_edges_total, and wallet_graph_stale_edges_total Prometheus gauges. - Add WalletGraphCache singleton to detection/feature_cache.py wrapping the incremental graph for use by the streaming scorer and feature pipeline. - Add GRAPH_STALE_EDGE_MAX_AGE_HOURS (168 h default) to config.py. - Add FEATURE_CACHE_TTL_SECONDS and FEATURE_CACHE_MAXSIZE to config.py. - Document incremental update strategy and staleness policy in docs/gnn_architecture.md. Issue Ledger-Lenz#204 — Concept Drift-Aware Model Versioning with Automatic Rollback: - Add ShadowScorer to detection/model_inference.py: routes SHADOW_TRAFFIC_PERCENT (default 20%) of live requests through the candidate model, counts disagreements > SHADOW_DRIFT_THRESHOLD_POINTS (15 pts) as drift events. - Add verify_model_artifact_signature() helper for Ed25519 chain verification before rollback. - Add ModelVersionRecord ORM model to detection/persistence.py tracking shadow/promoted/rolled_back status, drift rate, and training metadata. - Extend scripts/retrain_if_drifted.py: after drift detection, register the new model as a shadow candidate (exit 4) instead of promoting unconditionally; add --check-shadow flag for evaluation after the shadow period; auto-promote when drift rate < SHADOW_DRIFT_MAX_RATE (5%); auto-rollback when candidate FP rate exceeds production by > SHADOW_FP_RATE_MAX_EXCESS (10%); --no-shadow flag preserves legacy immediate-promotion behaviour. - Add docs/model_rollback_runbook.md with step-by-step manual intervention guide. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@brite-side0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
IncrementalWalletGraphtodetection/wallet_graph.pywithadd_trade_edge()(O(1) amortised),remove_stale_edges()(background staleness eviction viaGRAPH_STALE_EDGE_MAX_AGE_HOURS), andget_ego_subgraph()(BFS-based 2-hop extraction, < 10 ms for 500 direct neighbours). Prometheus gauges exposed for nodes, edges, and stale edges.WalletGraphCachesingleton added todetection/feature_cache.py. Docs section added tognn_architecture.md.ShadowScorertodetection/model_inference.pyroutingSHADOW_TRAFFIC_PERCENT(default 20%) of requests through the candidate model and counting drift events.ModelVersionRecordORM model added todetection/persistence.py.scripts/retrain_if_drifted.pyextended with shadow deployment flow (exit 4),--check-shadowevaluation flag, auto-promotion when drift rate < 5%, auto-rollback when candidate FP rate regresses by > 10%, and signature verification before rollback. Runbook added atdocs/model_rollback_runbook.md.Test plan
IncrementalWalletGraph.add_trade_edge()adds edges;get_ego_subgraph()returns correct 2-hop neighbourhoodremove_stale_edges()removes only edges older than the configured threshold; isolated nodes prunedWalletGraphCache.instance()is a true singleton across threadsShadowScorer.score()always returns the production result; drift events counted when diff > 15 ptsShadowScorer.should_promote()blocks before shadow period elapses and when drift rate ≥ 5%retrain_if_drifted --check-shadowpromotes when drift rate < 5%, rolls back when FP regression > 10%verify_model_artifact_signature()returns False on tampered artifactsModelVersionRecordrows persist status transitions to DBCloses #203
Closes #204
🤖 Generated with Claude Code