DocumentREADME
Version0.1.0-draft
StatusDraft Specification
Last Updated2026-01-11

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 = Error

Structured 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:

Python
# 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}")
Json
{"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:

Python
from wdp import compact_id

code = "E.Auth.Token.001"
cid = compact_id(code)  # โ†’ "sR5Kg"
Json
{"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:

Python
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:

Json
{"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)

DocumentDescription
STRUCTUREProtocol overview and design rationale
1-SEVERITYSeverity levels: E, W, C, I, H
2-COMPONENTSystem module identification
3-PRIMARYFailure domain within component
4-SEQUENCESpecific error instance numbering
5-COMPACT-IDSHash algorithm and Base62 encoding

Extended (As Needed)

DocumentWhen You Need It
7-NAMESPACESMultiple services/libraries defining codes
8-I18NMulti-language error messages
9-CATALOGSCatalog system for message expansion
9a-CATALOG-FORMATCatalog JSON schema
9b-WIRE-PROTOCOLCatalog distribution over HTTP
11-SECURITYSecurity, PII handling, sensitive data

Reference (Informative)

DocumentDescription
6-SEQUENCE-CONVENTIONSSequence numbering best practices
9c-IMPLEMENTATIONImplementation examples
10-PRESENTATIONUI/UX guidelines
12-METADATAAdditional 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:

NamespaceCodeOrigin
auth_serviceE.Auth.Token.001Main auth service
legacy_authE.Auth.Token.001Legacy 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 languages

3. 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 ID

4. 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:

LevelNamePartsUse Case
0Basic1-4 (Structured codes)Single app, organized error codes
1Compact+ Part 5 (Compact IDs)Wire efficiency, lookup keys
2Namespaced+ Part 7 (Namespaces)Multiple services/libraries defining codes
3Full+ 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.

FieldValue
Current Version0.1.0-draft
Target Stable Version1.0.0
LicenseCC BY 4.0

Specification Stability

For version 0.1.0-draft, specification parts are classified by stability:

ClassificationPartsDescription
Stable1-5Core protocol (Severity, Component, Primary, Sequence, Compact ID). Breaking changes unlikely.
Provisional7-9, 11-12Well-designed but may evolve. Catalog format includes version field for migration.
Informative6, 10Non-normative guidance. May change freely.

Evolution Principles:

  • Backward compatibility is prioritized for stable parts
  • New features added as optional fields where possible
  • Catalog version field 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