Skip to content

feat(admin): implement protocol administration service (BE-037) - #329

Merged
dDevAhmed merged 1 commit into
DigiNodes:mainfrom
TINEROW:fix/304-protocol-administration-service
Jul 30, 2026
Merged

feat(admin): implement protocol administration service (BE-037)#329
dDevAhmed merged 1 commit into
DigiNodes:mainfrom
TINEROW:fix/304-protocol-administration-service

Conversation

@TINEROW

@TINEROW TINEROW commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR implements the Protocol Administration Service — the secure operational control layer for the TruthBounty backend. It exposes privileged administrative capabilities required to operate, maintain, and monitor the protocol without compromising decentralisation.

The service manages backend infrastructure, operational configurations, integrations, monitoring, maintenance workflows, and emergency operational controls — all while ensuring every privileged action is RBAC-enforced and fully audited.

Related Issue

Closes #304

Changes

Administrative Authentication & RBAC

  • All endpoints guarded by AdminGuard + RolesGuard with role-based access control
  • Super admin and administrator roles have full control; auditors, security analysts, and other roles have read-only access where appropriate
  • Every administrative action validates the requesting admin's identity and permissions

Configuration Management

  • Protocol configuration CRUD via POST/GET /admin/protocol/config
  • Integration with existing ConfigurationService and FeatureFlagsService
  • All configuration changes are persisted to the database and audited with before/after state

Service Management

  • Queue control: pause, resume, drain, and retry failed jobs on all BullMQ queues
  • Notification service suspension and restoration
  • Webhook/integration suspension and restoration
  • Global cache invalidation via Redis FLUSHALL
  • Queue metrics endpoint exposing waiting/active/failed/completed counts

Health & Maintenance

  • Maintenance mode toggle with reason and scheduled end time
  • Maintenance scheduling with cancellation
  • System status endpoint aggregating maintenance state, emergency state, and service health
  • Detailed operational statistics with queue and resource usage data

Emergency Operations

  • Six emergency actions: suspend all services, disable notifications, pause all queues, enable API throttling, suspend integrations, emergency shutdown
  • Time-bound emergency actions with optional duration
  • Every emergency action is logged at CRITICAL severity
  • Emergency resolution restores affected services and generates audit trail

Audit Integration

  • 15 new audit action types added for protocol administration events
  • 6 new entity types and 5 new audit categories
  • Admin audit logs filtered by protocol categories
  • Every operation captures: admin identity, timestamp, affected resource, before/after state, and originating request context

Testing

  • 31 unit tests covering all service methods
  • Tests for system status, maintenance mode, scheduled maintenance, service control, queue metrics, emergency operations, configuration management, feature flags, and audit log retrieval
  • Mocked dependencies for isolated testing

Verification Results

npm test -- src/admin/protocol/tests/protocol-admin.service.spec.ts
31/31 passed

Acceptance Criteria Status
Administrative authentication functions correctly Guarded by AdminGuard + RolesGuard
Configuration changes are persisted Via ConfigurationService with DB storage
Audit events are generated 15 new action types, 3 new categories
Maintenance mode operates correctly Toggle with reason, schedule, cancel
Emergency controls function safely 6 actions, all CRITICAL-audited
Administrative APIs are documented Swagger/OpenAPI decorators on all endpoints
Tests pass successfully 31/31 passing

Add protocol administration service with RBAC-enforced operational
controls for maintenance mode, service management, emergency actions,
protocol configuration, and feature flags. Every administrative action
is fully audited via the existing AuditTrailService.

New endpoints under /admin/protocol:
- System status & operational statistics
- Maintenance mode toggle, schedule, and cancellation
- Service control (queue pause/resume, notification suspend/restore,
  cache invalidation)
- Queue metrics with failed job retry
- Emergency actions (service suspension, throttle, shutdown)
- Protocol configuration management
- Feature flag listing and evaluation
- Protocol and admin audit log retrieval

Closes DigiNodes#304
@dDevAhmed
dDevAhmed merged commit 27cf6e8 into DigiNodes:main Jul 30, 2026
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.

BE-037 — Implement Protocol Administration Service

2 participants