Waddling Diagnostic Protocol (WDP) Specification
Comprehensive, structured error coding system designed for modern distributed systems.
Overview#
The Problem#
Error codes today force a tradeoff:
- Verbose messages are readable but waste bandwidth and couple clients to server text
- Opaque codes (
40103) are compact but meaningless without documentation - Flat enumerations require lookup tables for filtering and routing
The Solution#
The Waddling Diagnostic Protocol (WDP) provides error codes that are both structured for semantics and compact for transmission.
E.Auth.Token.001 โ sR5Kg
โ โ โ โ โ
โ โ โ โ โโ Compact ID: 5-character fingerprint
โ โ โ โโโโโโโโโ Sequence: specific error instance
โ โ โโโโโโโโโโโโโโโ Primary: failure domain (Token)
โ โโโโโโโโโโโโโโโโโโโโ Component: module (Auth)
โโโโโโโโโโโโโโโโโโโโโโ Severity: E = ErrorStructured code (E.Auth.Token.001): Hierarchical, parsable, queryable. Machines can route, filter, and aggregate. Humans can read it.
Compact ID (sR5Kg): Deterministic 5-character hash. Wire-efficient, language-neutral, lookup key.
Both representations identify the same diagnostic.
Quickstart#
Minimal Implementation (Level 0)
Use WDP structured codes directlyโno infrastructure required:
# Define errors in module namespaces (generic names compose well)
class token: # auth_token module
MISSING = "E.Auth.Token.001" # 001 = MISSING
EXPIRED = "E.Auth.Token.018" # 018 = EXPIRED
class session: # auth_session module
TIMEOUT = "W.Auth.Session.017" # 017 = TIMEOUT
# Use them
raise AuthError(token.EXPIRED, "Token expired at {timestamp}"){"error": {"code": "E.Auth.Token.018", "message": "Token expired"}}This is valid WDP. You get structured, queryable error codes immediately.
Add Compact IDs (Level 1)
Generate compact IDs for wire efficiency:
from wdp import compact_id
code = "E.Auth.Token.001"
cid = compact_id(code) # โ "sR5Kg"{"error": {"code": "sR5Kg", "message": "Token expired"}}See 5-COMPACT-IDS for the hash algorithm (xxHash3 + Base62).
Add Namespaces (Level 2)
When multiple services or libraries define codes independently:
from wdp import namespaced_compact_id
code = "E.Auth.Token.001"
cid = namespaced_compact_id("auth_service", code) # โ "05o5h-sR5Kg"See 7-NAMESPACES for namespace hashing.
Add Catalogs (Level 3)
For i18n, message templates, and rich metadata:
{"sR5Kg": {"f": {"timestamp": "2024-01-15T10:30:00Z"}}}Client expands using cached catalog โ localized message with interpolated fields.
See 9-CATALOGS for the catalog system.
Specification Documents#
Core (Start Here)
| Document | Description |
|---|---|
| STRUCTURE | Protocol overview and design rationale |
| 1-SEVERITY | Severity levels: E, W, C, I, H |
| 2-COMPONENT | System module identification |
| 3-PRIMARY | Failure domain within component |
| 4-SEQUENCE | Specific error instance numbering |
| 5-COMPACT-IDS | Hash algorithm and Base62 encoding |
Extended (As Needed)
| Document | When You Need It |
|---|---|
| 7-NAMESPACES | Multiple services/libraries defining codes |
| 8-I18N | Multi-language error messages |
| 9-CATALOGS | Catalog system for message expansion |
| 9a-CATALOG-FORMAT | Catalog JSON schema |
| 9b-WIRE-PROTOCOL | Catalog distribution over HTTP |
| 11-SECURITY | Security, PII handling, sensitive data |
Reference (Informative)
| Document | Description |
|---|---|
| 6-SEQUENCE-CONVENTIONS | Sequence numbering best practices |
| 9c-IMPLEMENTATION | Implementation examples |
| 10-PRESENTATION | UI/UX guidelines |
| 12-METADATA | Additional diagnostic metadata |
Key Concepts#
Catalog System (Optional)
Catalogs enable compact wire transmission with rich client-side expansion. A catalog is a JSON lookup table mapping compact IDs to full diagnostic metadata.
โโโโโโโโโโโโโโโโโโโ
โ Server โ Sends: {"sR5Kg": {"f": {"timestamp": "..."}}}
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Client โ 1. Downloads catalog once (cached)
โ + Catalog โ 2. Looks up sR5Kg โ full metadata
โ โ 3. Interpolates fields
โ โ 4. Displays: "Token expired at ..."
โโโโโโโโโโโโโโโโโโโNote: Derivation is one-way. Structured code โ compact ID is deterministic (hash). Compact ID โ structured code requires a catalog lookup.
Namespaces (Optional)
Namespaces identify the origin of a diagnosticโwhich service, library, or team defined it.
Why namespaces matter: Two services might independently define E.Auth.Token.001. Without namespaces, these are indistinguishable:
| Namespace | Code | Origin |
|---|---|---|
auth_service | E.Auth.Token.001 | Main auth service |
legacy_auth | E.Auth.Token.001 | Legacy system |
Same code, different sources, unambiguous identification.
Use Cases#
1. IoT Devices
Problem: Constrained bandwidth and battery
Solution: Send 5-character compact IDs instead of full error messages
Sensor โ {"sR5Kg": {"f": {"temp": "45.2"}}}
Gateway expands โ "Temperature 45.2ยฐC exceeds threshold"2. Mobile Applications
Problem: Slow/expensive mobile networks
Solution: Download catalog once, expand errors locally
1. App downloads catalog (cached for 7 days)
2. API returns compact diagnostics
3. App expands locally with cached catalog
4. Supports multiple languages3. Microservices Architecture
Problem: High-volume logging across distributed services
Solution: Compact log entries with efficient aggregation
Service A: [sR5Kg] Auth failure
Service B: [sR5Kg] Auth failure
Service C: [sR5Kg] Auth failure
โ Centralized logging aggregates by compact ID4. Multi-Language Support
Problem: Supporting multiple languages efficiently
Solution: Same compact IDs, different language catalogs
Backend โ {"sR5Kg": {"f": {"timestamp": "2024-01-15"}}}
English client: "Token expired at 2024-01-15"
Spanish client: "Token expirรณ el 2024-01-15"
Japanese client: "ใใผใฏใณใฎๆๅนๆ้ใๅใใพใใ 2024-01-15"Conformance Levels#
WDP defines four conformance levels:
| Level | Name | Parts | Use Case |
|---|---|---|---|
| 0 | Basic | 1-4 (Structured codes) | Single app, organized error codes |
| 1 | Compact | + Part 5 (Compact IDs) | Wire efficiency, lookup keys |
| 2 | Namespaced | + Part 7 (Namespaces) | Multiple services/libraries defining codes |
| 3 | Full | + Parts 8-9, 11-12 (Catalogs, i18n, metadata) | i18n, rich message templates, cross-system expansion |
Informative guidance (Parts 6, 10) applies at any level.
Most applications start at Level 0 or 1 and adopt higher levels as needed.
Status#
This specification is currently in DRAFT status. All documents are subject to change based on implementation feedback and community discussion.
| Field | Value |
|---|---|
| Current Version | 0.1.0-draft |
| Target Stable Version | 1.0.0 |
| License | CC BY 4.0 |
Specification Stability
For version 0.1.0-draft, specification parts are classified by stability:
| Classification | Parts | Description |
|---|---|---|
| Stable | 1-5 | Core protocol (Severity, Component, Primary, Sequence, Compact ID). Breaking changes unlikely. |
| Provisional | 7-9, 11-12 | Well-designed but may evolve. Catalog format includes version field for migration. |
| Informative | 6, 10 | Non-normative guidance. May change freely. |
Evolution Principles:
- Backward compatibility is prioritized for stable parts
- New features added as optional fields where possible
- Catalog
versionfield enables graceful format evolution - Deprecation before removal (minimum one minor version warning)
See STRUCTURE.md for detailed stability classifications.
Contributing#
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Ways to Contribute
- Report issues or suggest improvements
- Propose new features or extensions
- Share implementation feedback
- Improve documentation and examples
License
This specification is licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
Copyright ยฉ 2025 Ashutosh Mahala
Author
Ashutosh Mahala (Ash)
GitLab: @AshutoshMahala
Repository: gitlab.com/AshutoshMahala/wdp-specs