🦁 SmartInno – Enterprise Unified SDK Master API Reference
Latest Release: v1.2.0 (Production Verified)\
📖 Comprehensive Guides:
- 👉 Complete Developer Guide & Architecture Manual — Exhaustive guide covering all process features one-by-one, Mermaid logic flows, cryptographic guarantees, and live cluster verification.
- 👉 End-to-End Cryptographic Lifecycle & Hotel Booking Scenario — Step-by-step production flow from mobile payment to Temporal Saga execution.
Welcome to the SmartInno Unified SDK Master API Reference. This SDK unifies Temporal Orchestration, Enterprise Custom Redis Connectivity (with transparent AES-256-GCM encryption at rest across all data structures and uniform cluster distribution), Resilient Messaging (Pulsar/Redis Failover with HMAC-SHA256 & 3-day nonces), Dead-Letter Queue (DLQ) Poison Pill Quarantine, and Observability Monitoring into a single, high-performance toolkit with built-in failover capabilities.
⚡ v1.2.0 Production Security & Feature Highlights
- Redis Cluster Dynamic Slotting & Uniform Key Distribution:
- Eliminates Fixed Single-Slot Bottleneck: Previously, hardcoded
{service_name} hash tags collapsed 100% of all cache keys, hashes, lists, sets, and streams onto a single hash slot (slot 3731), overloading a single master node while leaving all other cluster masters idle.
ClusterSlottingStrategy Enum:
DISTRIBUTED (Default): Full key CRC16 hashing across all 16,384 slots (service:action:key), uniformly distributing reads, writes, and memory across all available cluster nodes.
ENTITY_TAGGED: Automatically wraps the primary entity identifier in curly braces (service:action:{entity}:sub), co-locating related records for the same entity while distributing different entities across nodes.
VIRTUAL_SHARDS: Controlled hashing across $N$ virtual shard buckets ({service_shard_X}), preventing hotspots while managing shard counts.
LEGACY_FIXED: Backward-compatible mode retaining the fixed {service_name} hash tag.
- Preserves Explicit Hash Tags: Any caller-supplied hash tag
{...} (e.g. {order_100}:items) is always preserved for intentional slot co-location, transactional pipelines, or multi-key operations.
- Cluster Slot Diagnostics & Inspection: Built-in
get_key_slot(key) and get_slot_distribution(keys) utilities calculate CRC16 slots, detect skew (is_skewed), report distribution ratios, and map slots to physical nodes via get_node_for_key(key).
- Dead-Letter Queue (DLQ) & Poison Pill Quarantine:
DeadLetterQueueHandler automatically quarantines malformed, tampered, or repeatedly failing messages to a dedicated DLQ ({topic}:dlq or {topic}-dlq) with full audit diagnostics (dlq_id, original_topic, error, stack_trace, attempts, reason, failed_at).
- Tampered HMAC signatures (
HMAC_TAMPER_ALERT) and replay attacks (NONCE_REPLAY_ATTACK) are immediately quarantined without executing worker code.
- Redis Streams track retry attempts and acknowledge from PEL upon reaching
max_retries. Pulsar integrates negative_acknowledge() redeliveries before DLQ routing.
- PulsarSmartRouter Delayed Delivery Fix & Continuous Streaming:
- Fixed delayed delivery (
delete_after) to route through PulsarProducerAdapter.send(..., deliver_at=...), preserving the cryptographic envelope with AES-256-GCM encryption and 3-day Redis nonces.
- Enhanced
listen_to and added listen_stream() with transparent AES-256-GCM payload unwrapping and DLQ poison pill quarantine.
- Unified Cryptographic Envelope Parity Across Apache Pulsar & Redis:
- Every message sent to Apache Pulsar (
smart_send, send, PulsarProducerAdapter.send/send_async, publish_to) is strictly wrapped into the standardized JSON cryptographic envelope (request_id, nonce, group, event, type, service, tenant_name, payload, timestamp, signature).
- Seamless topic tenant extraction (
persistent://{tenant}/{namespace}/{topic}) guarantees complete tenant isolation.
- Broker
partition_key automatically defaults to request_id for deterministic partition distribution.
- Consumers (
receive_unwrapped, smart_listen, on(..., idempotent=True)) transparently unwrap and decrypt messages.
- Transparent AES-256-GCM Encryption At Rest Across All Redis Data Structures:
- Automatic write encryption (
enc:gcm:v1:...) and read decryption across Strings, Hashes, Lists, Sets, Sorted Sets (ZSets), and Streams.
- Zero plaintext leaks in raw Redis or Pulsar storage.
- HKDF (RFC 5869) Multi-Tenant Key Derivation:
- Symmetrically derived 256-bit keys from client TLS certificates and master entropy.
- Enforces mathematical isolation between tenants (
hotel, flight, agency, auth, public, etc.).
- Dual-Mode Nonce Replay Prevention:
- Pre-Registered Mode: 3-day TTL registration + atomic Lua GETDEL deletion upon receipt.
- Sliding-Window Mode: 300s window drift validation + post-ingest
SET NX EX 300.
- Strict Listener Mode:
require_registered_nonce=True drops unregistered and tampered nonces immediately.
- Timing-Safe HMAC-SHA256 Integrity Verification:
- All envelopes signed with tenant application keys. Detects tampered amounts, IDs, and spoofed tenants.
- Multi-Tier Distributed Idempotency Locks:
- Concurrency locking (
STARTED), cached responses (COMPLETED), and retry unlock (FAILED).
- Verified Test Coverage:
- 58/58 automated unit tests passed.
- Live 6-node Redis cluster integration test suite passed (all 6 tamper attack scenarios dropped, all data structures verified at rest).
📐 Core SDK Architecture Overview
The SmartInno SDK suite provides a high-reliability abstraction layer over databases, message buses, and workflow systems. It simplifies building microservices by exposing unified clients with built-in resiliency patterns.
graph TD
User[Application Code] --> tc[TemporalClient]
User --> rc[RedisClientFactory]
User --> mc[MessageClient]
User --> mon[Observability Monitors]
tc -->|Orchestration| TempServer[Temporal Cluster]
rc -->|Key-Value / Streams / Hashes / Sets| RedisCluster[Redis Sentinel / Cluster]
mc -->|Resilient Messaging| PubSub[Pulsar / Redis PubSub]
🛠️ Complete Enums & Configurations Guide
1. Architectural & Routing Enums
smartinno.redis_custom.config.Architecture
Defines the backend deployment topology for Redis connections.
SENTINEL ("sentinel"): High-Availability Sentinel setup with active-passive replication and automated master failover.
CLUSTER ("cluster"): Cryptographically sharded cluster distributing keys across 16,384 slots over multiple master nodes.
HYBRID ("hybrid"): Routes through a Predixy/Envoy proxy gateway to abstract cluster topology away from clients.
SMART_ROUTER ("smart_router"): Meta-architecture routing commands dynamically to different Redis topologies.
smartinno.redis_custom.config.UseCase
Guides the factory to auto-select the optimal Redis architecture for a given workload.
HIGH_CONCURRENCY: Maps to CLUSTER (Ideal for massive horizontal read/write scale).
HEAVY_TRANSACTIONS: Maps to SENTINEL (Ideal for multi-key pipelines and transactions).
MICROSERVICES: Maps to HYBRID (Ideal for polyglot systems and proxy gateways).
AUTO: Maps to SMART_ROUTER (Dynamically selects based on payload structure).
smartinno.redis_custom.config.ClusterSlottingStrategy
Controls how keys are formatted and routed across all 16,384 Redis Cluster hash slots.
DISTRIBUTED ("distributed", Default): Formats keys as {service}:{action}:{key} (no fixed curly braces around service). The full key is hashed using CRC16 across all 16,384 slots, ensuring balanced CPU, network, and memory distribution across all cluster master nodes. Any explicit hash tag {...} is preserved verbatim for intentional co-location.
ENTITY_TAGGED ("entity_tagged"): Automatically wraps the root entity identifier in curly braces ({service}:{action}:{{entity}}:{sub}), ensuring all keys belonging to the same entity co-locate on the same node for multi-key queries/transactions while distributing distinct entities.
VIRTUAL_SHARDS ("virtual_shards"): Partitions keys across $N$ virtual buckets ({{{service}_shard_X}}:{action}:{key}), preventing hotspots while providing bounded partition sets (configurable via cluster_virtual_shards).
LEGACY_FIXED ("legacy_fixed"): Legacy backward-compatible mode enclosing {service_name} in curly braces.
smartinno.temporal.client.Frequency
Defines scheduling intervals for recurring cron orchestrations.
ONCE ("once"): Fires exactly once.
REPEATED ("repeated"): Fires every minute.
HOURLY ("hourly"): Fires at the start of every hour.
DAILY ("daily"): Fires at midnight every day.
WEEKLY ("weekly"): Fires at midnight every Sunday.
MONTHLY ("monthly"): Fires at midnight on the first day of every month.
smartinno.redis_custom.smart_router.DataSensitivity
Categorizes data payloads based on PII/critical parameters to dictate caching TTL policies.
CRITICAL (Matches passport, visa): Bypasses persistent storage; cached for 60 seconds max.
HIGH (Matches password, payment, card, cvv, secret, ssn, token): Cached for 300 seconds.
MEDIUM (Matches email, phone, user_name): Standard caching rules apply.
LOW: Default category for standard operational logs or cache elements.
🔑 Redis Key Generation & Data Serialization Envelopes
To prevent key collision and ensure clean data parsing across heterogeneous systems (e.g. Go, Python, and Node.js microservices), the SDK enforces standardized key structures and JSON packaging envelopes.
1. Standardized Key Formatting Pattern
All keys written to Redis are transparently ran through the BaseRedisAdapter._format_key() handler. This prefixes keys according to a strict namespace convention:
$$\text{redis_key} = \text{service_name} : \text{action} : \text{original_key}$$
- Parameters:
service_name (str, default "safari_pro"): Declared in RedisConfig. Prevents cross-app database contamination.
action (str, default "data"): Scopes key usage (e.g., data, cache, stream, queue).
- Example Generation:
- Original Key:
"booking:8848"
- Generated Key:
safari_pro:data:booking:8848
2. Cache Data envelope Serialization
2. Standardized Cryptographic Envelope Schema (Redis & Pulsar)
For caching payloads and messages published to Pulsar or Redis Streams, data is packed into a standardized cryptographic JSON envelope with AES-256-GCM encryption, a 300-second sliding timestamp window, and raw-byte HMAC-SHA256 signature verification.
{
"request_id": "4020a6e3-fcf3-40e1-b4f6-6cbe702e5b85",
"nonce": "nonce-f89a-47cb-9912",
"group": "hotel-bookings",
"service": "safari_pro",
"tenant_name": "serengeti_hospitality",
"event": "create_booking",
"type": "hotel_reservation",
"payload": "enc:gcm:v1:qK8jF298AbxZ100...==",
"timestamp": "2026-09-22T11:40:00.123456Z",
"signature": "75dc07d19a6506dbaf406bf7855cdd067d15aa9683a2af3777e5e98560099acf"
}
- Envelope Fields:
request_id (str): UUIDv4 tracking and idempotency identifier.
nonce (str): Single-use token validated via sliding timestamp window and acquired via post-ingest SET NX EX 300 in Redis.
group (str): Idempotency scope / consumer group name.
service (str): Originating application namespace name.
tenant_name (Optional[str]): Tenant indicator for multi-tenancy and HKDF key derivation.
event (str): Action trigger description (e.g., create_booking, update, invalidate).
type (str): Target message/cache category type.
payload (str / Any): AES-256-GCM encrypted payload (enc:gcm:v1:...).
timestamp (str): UTC timestamp in ISO-8601 formatting.
signature (str): Raw-byte HMAC-SHA256 signature generated across canonical envelope keys.
[!TIP]
For the complete architectural deep dive and full Hotel Booking code walkthrough, see:
👉 End-to-End Cryptographic Lifecycle & Hotel Booking Scenario Guide
- Note: Read operations automatically verify signatures, validate timestamp windows & nonces, check idempotency locks, validate AES-256-GCM tags, and decrypt the underlying
payload back into Python dictionaries transparently.
3. Messaging Emergency Fallback Envelopes
When circuit breakers trip or connection drops occur, message payloads are wrapped with failover metadata.
Redis Emergency Fallback
Stranded messages waiting for Pulsar recovery are written to a Redis Stream with the key pattern:
$$\text{key} = \text{emergency-fallback} : {topic}$$
[!IMPORTANT]
If redis_config was not explicitly passed to the MessageClient (i.e. it is None), the Redis Fallback mechanisms are bypassed, and a warning is logged. The client will not automatically default to a local Redis configuration to prevent environment confusion.
Pulsar Emergency Fallback
When Redis is down and fallback is routed directly to Pulsar, messages are packaged with origin metadata:
[!IMPORTANT]
If pulsar_config was not explicitly passed to the MessageClient (i.e. it is None), the Pulsar Fallback mechanisms are bypassed. The client will not automatically default to a local Pulsar configuration.
⏳ 1. Temporal Orchestration SDK
TemporalConfig
A configuration dataclass used to initialize the TemporalClient.
| Field Name |
Type |
Default |
Description |
host |
str |
"localhost" |
Endpoint hostname of the Temporal frontend service. |
port |
int |
7233 |
Endpoint port of the Temporal frontend service. |
namespace |
str |
"default" |
Target namespace partition. |
ssl |
bool |
False |
Set to True to enable secure TLS communication. |
client_cert_path |
Optional[str] |
None |
Absolute path to the client certificate (.crt/.pem). |
client_key_path |
Optional[str] |
None |
Absolute path to the client private key (.key). |
auto_start_worker |
bool |
False |
Automatically boots background worker thread on execution. |
queues |
List[str] |
["default"] |
List of task queues the background worker monitors. |
mock_mode |
Optional[bool] |
None |
Explicit override. If omitted, mode is auto-detected from environment variables. |
@tc.workflow (Alias: @tc.process)
Marks an async function as a stateful workflow process coordinator.