Skip to content

feat: require reason and audit trail for verification override#574

Merged
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
Vvictor-commits:feature/override-audit-trail-impl
May 29, 2026
Merged

feat: require reason and audit trail for verification override#574
greatest0fallt1me merged 1 commit into
Predictify-org:masterfrom
Vvictor-commits:feature/override-audit-trail-impl

Conversation

@Vvictor-commits
Copy link
Copy Markdown
Contributor

@Vvictor-commits Vvictor-commits commented May 28, 2026

Closes #548


Summary

Closes the oracle-manipulation accountability gap in admin_override_verification. Every override now requires a non-empty justification, appends an immutable audit-trail record, and emits a dedicated event for off-chain monitors.

Changes

audit_trail.rs

  • Added OracleVerificationOverride variant to AuditAction enum

events.rs

  • Added AdminOverrideEvent struct (market_id, admin, old_result, new_result, reason, timestamp)
  • Added EventEmitter::emit_admin_override with topic key adm_ovrd

lib.rs

  • Replaced the always-failing stub with a real implementation:
    1. require_primary_admin — auth before any storage write
    2. Empty reasonErr(InvalidInput) before touching storage
    3. Loads market, captures old_result, sets oracle_result + state = Resolved, saves
    4. Appends audit record with old_result/new_result/reason
    5. Emits AdminOverrideEvent

override_audit_tests.rs (new, #[cfg(test)])

  • 6 self-contained tests, no external test helpers

Acceptance Criteria

Criterion Test
Override rejects empty reason test_override_rejects_empty_reason
Audit record written with correct action/actor/reason test_override_appends_audit_record
verify_audit_integrity passes after override test_override_preserves_audit_integrity
Market state = Resolved, oracle_result set test_override_resolves_market
Non-admin rejected test_override_rejects_non_admin
No partial state on auth failure test_override_no_partial_state_on_auth_failure

Testing

cargo test -p predictify-hybrid -- override_audit

- Reject empty reason in admin_override_verification (Error::InvalidInput)
- Append immutable AuditRecord with OracleVerificationOverride action,
  capturing old_result, new_result, and reason in the details map
- Emit AdminOverrideEvent (market_id, admin, old/new result, reason,
  timestamp) via a dedicated 'adm_ovrd' topic for off-chain monitors
- Add AdminOverrideEvent struct and emit_admin_override to events.rs
- Add OracleVerificationOverride variant to AuditAction enum
- Auth (require_primary_admin) precedes all storage writes
- 6 tests in override_audit_tests.rs covering: empty reason rejection,
  audit record content, chain integrity, market state, non-admin rejection,
  and no-partial-state guarantee on auth failure
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@Vvictor-commits 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! 🚀

Learn more about application limits

@greatest0fallt1me greatest0fallt1me merged commit c06b9f0 into Predictify-org:master May 29, 2026
1 check passed
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.

Add admin_override_verification audit-trail entry and event with mandatory reason String

3 participants