audit: add LEP-6 shadow scoring for storage truth#119
audit: add LEP-6 shadow scoring for storage truth#119j-rafique wants to merge 3 commits intoLEP-6-report-ingestionfrom
Conversation
Both previously flagged issues have been addressed in this revision. Params are now threaded through as parameters (no redundant store reads), and
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
51ea7b0 to
c86ef0e
Compare
Production-gate review by Zee — 12 findingsMethodology: full file-by-file read of every non-generated changed file in this PR's diff (pr-119 vs its base branch), cross-checked against:
Status legend: each finding's status is computed at the PR #122 stack-tip (consensus-gap-fixes commit Severity breakdown: HIGH=7, MEDIUM=5 119-F1 — Decay was linear instead of geometric (spec §14/§15/§16)
119-F2 — Node-suspicion deltas don't match spec §14 (no symbol/index split, wrong magnitudes)
119-F3 — Ticket-deterioration deltas don't match spec §16
119-F4 — Reporter-reliability deltas semantically inverted vs spec §15
119-F5 — Contradiction penalty applied to BOTH the contradicting and contradicted reporter
119-F6 — Trust multiplier 0.25 (LOW_TRUST=0.5, INELIGIBLE=0.25) violates spec §15.4 floor 0.5
119-F9 — Pattern-escalation predicate counts same-ticket repeats instead of distinct-ticket per node, magnitudes 2/4/6 vs spec 10/15/12
119-F10 —
|
There was a problem hiding this comment.
Pull request overview
Implements LEP-6 PR3 “shadow scoring” for storage-truth by executing scoring on ingested storage_proof_results, persisting additional scoring/bookkeeping state, and emitting a dedicated score-update event.
Changes:
- Add storage-truth scoring pipeline on
MsgSubmitEpochReportwith node/reporter/ticket score deltas, trust-band scaling, decay-on-update, and contradiction/repeated-failure bookkeeping. - Extend protobuf state with
ReporterTrustBandand additional persisted fields for reporter and ticket scoring/bookkeeping. - Add/expand tests to cover scoring outcomes, decay, trust thresholds, escalation/contradictions, query visibility, and event attributes.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| x/audit/v1/types/events.go | Introduces storage-truth score update event type and attribute keys. |
| x/audit/v1/types/audit.pb.go | Regenerated protobuf output to include trust band + added state fields. |
| x/audit/v1/keeper/storage_truth_scoring.go | Implements storage-truth scoring engine, bookkeeping, decay helpers, and event emission. |
| x/audit/v1/keeper/msg_submit_epoch_report.go | Hooks scoring execution into epoch report submission flow. |
| proto/lumera/audit/v1/audit.proto | Adds ReporterTrustBand enum and new persisted bookkeeping fields. |
| app/proto_bridge.go | Registers the new enum for proto bridge usage. |
| x/audit/v1/keeper/msg_submit_epoch_report_storage_truth_scores_test.go | Adds end-to-end tests for scoring, decay, scaling, events, escalation, contradictions. |
| x/audit/v1/keeper/query_storage_truth_test.go | Expands query tests to validate new fields and scored-ingestion visibility. |
| x/audit/v1/keeper/storage_truth_state_test.go | Updates state round-trip tests for newly persisted fields. |
| x/audit/v1/keeper/storage_truth_scoring_internal_test.go | Adds focused unit tests for internal math/scoring helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if isStorageTruthFailureClass(result.ResultClass) && epochID != state.LastFailureEpoch { | ||
| nextState.LastFailureEpoch = epochID | ||
| nextState.RecentFailureEpochCount = updateRecentFailureEpochCount(state, epochID, params) | ||
| } else if !found { | ||
| nextState.RecentFailureEpochCount = 0 | ||
| } |
There was a problem hiding this comment.
In applyTicketDeteriorationDelta, a brand-new ticket failure at epoch 0 won’t set LastFailureEpoch/RecentFailureEpochCount because the failure update is gated by epochID != state.LastFailureEpoch (and state.LastFailureEpoch is 0 for a new/zero-value state). This causes the first failure in epoch 0 to be recorded with RecentFailureEpochCount=0, and the next epoch’s failure will be treated as count=1 (no escalation) rather than count=2.
Consider changing the condition to also treat "not found" as needing initialization (e.g., update failure fields when !found || epochID != state.LastFailureEpoch), and add a test covering the first-ever failure when epochID == 0 to ensure RecentFailureEpochCount becomes 1.
cb16594 to
af4c9fc
Compare
Summary
Implements LEP-6 PR3 (shadow scoring) on
LEP-6-shadow-scoring(PR #119) by adding storage-truth score execution for ingestedstorage_proof_resultsand persisting shadow-only scoring state.This PR updates state + scoring + observability only. It does not enable enforcement penalties.
Base / Scope
LEP-6-report-ingestionLEP-6-shadow-scoringSHADOW/SOFT/FULL, with PR3 intent focused on shadow bookkeeping and score evolution.What Changed
1) Storage-truth score pipeline execution
MsgSubmitEpochReportnow applies storage-truth scoring after report persistence.N)R)D)2) Reporter trust band + bookkeeping state
3) PR3 scoring behavior coverage
4) Event observability
storage_truth_score_updatedevent and attributes for:5) PR review hardening fixes included
GetParams(...).WithDefaults()store reads in inner scoring helpers by threading already-fetched params.scaleInt64TowardZero) and added edge-case coverage.Tests
Added/updated focused tests for:
Non-Goals (explicitly deferred)
Risk / Compatibility