6.0 KiB
Agriculture Trading Backoffice (ATB) — Operational Maintenance Runbook
| Field | Value |
|---|---|
| Product | Agriculture Trading Backoffice (ATB) |
| Release Version | v1.0.0 (Production / UAT Release) |
| Governed Standard | SEI-CMMI Level 3 (UP-AI v1.5 Standard Enterprise Tier) |
| Document Path | 04_generated_documentation/08_review_ready_baselines/02_handover_package/OPERATIONAL_RUNBOOK.md |
| Audience | Platform Operations, Security Officers, Database Administrators |
1. Tenant Lifecycle Administration
ATB enforces a strict multi-tenant control plane. Tenants represent autonomous trading firms with segregated data boundaries enforced at the PostgreSQL engine layer via Row-Level Security.
1.1 Tenant Provisioning Procedure
Tenants are provisioned via the Platform Administration API (/api/tenants):
- Submit Provisioning Request:
curl -X POST http://localhost:8000/api/tenants \ -H "Authorization: Bearer $PLATFORM_ADMIN_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Kisan Agri Corp", "slug": "kisan-agri", "gstin": "27AABCK1234F1Z5", "pan": "AABCK1234F", "admin_email": "admin@kisanagri.com" }' - Post-Provisioning Verification:
The system creates the tenant in state
ACTIVE, assigns a unique UUID, initializes tenant operating policy defaults, and registers the initial Tenant Administrator user membership.
1.2 Tenant Suspension & Reactivation
When a tenant firm is suspended (e.g. non-payment, compliance freeze), access is immediately cut off at the middleware layer:
- Suspend Tenant:
PATCH /api/tenants/{tenant_id}/statuswith{"status": "SUSPENDED", "reason": "Audit freeze"}. - Immediate Effect: All subsequent requests carrying this
tenant_idreceive403 TENANT_SUSPENDED. - Reactivate Tenant:
PATCH /api/tenants/{tenant_id}/statuswith{"status": "ACTIVE"}restores immediate operational capabilities.
2. User & RBAC Membership Management
Users authenticate via Keycloak OIDC, and their permissions within an active tenant are governed by the tenant membership registry.
2.1 Role Matrix & Segregation of Duties
The platform enforces 11 distinct operational roles:
Tenant Administrator: Tenant settings, user invitations, role assignments.Mandi Buyer: Live mandi auction arrivals, bidding, sauda purchase contract creation.Purchase Manager: Sauda contract approval, supplier limits, rate verification.Yard Supervisor: Weighbridge tare/gross weighment, vehicle gate-in/gate-out passes.Quality Officer: Lab assay moisture/admixture testing, lot grading, lab rejection slips.Sales Executive: Customer inquiry, sales order creation, dispatch requests.Sales Manager: Customer credit approvals, price band approvals, bilty release.Logistics Coordinator: Transporter fleet registry, truck assignment, bilty tracking.Accounts Executive: Invoicing, payments, supplier bills, mandi cess expense ledgers.Partner / MD: Executive snapshot dashboard, high-value overrides, financial audits.System Administrator: Platform health, break-glass security logs, tenant onboarding.
3. Privileged Support Access & Break-Glass Protocol (UC-020)
To protect confidential customer trading margins and farmer payment records, platform engineers have zero standing access to tenant business ledgers.
3.1 Standard Support Access (Dual-Authorization)
- Tenant Request: Tenant Administrator creates a support ticket:
POST /api/support/tickets. - Support Claim: Support engineer requests read-only session:
POST /api/support/sessions/request. - Dual Approval Rule: The requester cannot self-approve. A designated Tenant Administrator or Security Officer must approve:
POST /api/support/sessions/{id}/approve. - Time Bounds: Session token expires automatically after 60 minutes.
3.2 Emergency Break-Glass Procedure
In high-severity production outage scenarios (P1 incidents):
- Platform Security Officer issues emergency bypass:
POST /api/support/break-glass { "tenant_id": "<UUID>", "incident_ticket": "INC-88910", "justification": "Database index corruption affecting mandi yard auction", "duration_minutes": 45 } - System Enforcement:
- Duration is strictly capped at 120 minutes.
- Emits high-severity
SECURITY_ALERTto all tenant administrators within 15 minutes. - Records an immutable audit log entry in
audit_logswith before/after state captures.
4. Routine Database Maintenance & Backups
4.1 Daily Automated Backup Script
Run daily at 02:00 UTC via cron:
#!/bin/bash
BACKUP_DIR="/var/backups/atb"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p "$BACKUP_DIR"
docker exec atb-prod-postgres pg_dump -U atb -d atb -F c -b -v -f "/tmp/atb_backup_${TIMESTAMP}.dump"
docker cp atb-prod-postgres:/tmp/atb_backup_${TIMESTAMP}.dump "${BACKUP_DIR}/"
docker exec atb-prod-postgres rm "/tmp/atb_backup_${TIMESTAMP}.dump"
# Retain backups for 35 days
find "$BACKUP_DIR" -type f -name "atb_backup_*.dump" -mtime +35 -delete
4.2 Database Health & VACUUM Maintenance
Execute weekly to maintain PostgreSQL query performance:
docker exec -it atb-prod-postgres psql -U atb -d atb -c "VACUUM (ANALYZE, VERBOSE);"
5. Transactional Outbox & Poison-Queue Handling (AMB-011)
The platform implements an asynchronous Outbox Pattern (event_outbox table) for alerts and downstream notifications.
5.1 Poison Event Triage
If an external webhook or SMS gateway fails repeatedly:
- After 5 retries with exponential backoff, event status transitions to
POISON. - View poisoned events:
SELECT event_id, event_type, tenant_id, retry_count, last_error FROM event_outbox WHERE status = 'POISON'; - Manual Replay: After resolving the underlying gateway failure, reset the event:
UPDATE event_outbox SET status = 'PENDING', retry_count = 0, next_retry_at = NOW() WHERE event_id = '<EVENT_UUID>';