WDP 5-Part Error Code Structure
A comprehensive overview of the Waddling Diagnostic Protocol
Notation Conventions#
This specification uses the following notation conventions throughout:
| Symbol | Meaning | Example |
|---|---|---|
โ | Transformation or mapping | E.Auth.Token.001 โ Xy8Qz |
โ | Annotation or comment | โ โ Part 1: Severity |
โ โโ | Hierarchy/tree structure | Component hierarchy diagrams |
โ โ โ | Box-drawing for diagrams | Structure overview boxes |
... | Continuation/ellipsis | 001, 002, ... 999 |
* | Wildcard in patterns | E.Auth.* (all Auth errors) |
[X] | Placeholder for value X | [SEVERITY.COMPONENT.PRIMARY.SEQUENCE] |
โ
/ โ | Recommended / Not recommended | Usage guidance |
| MUST, SHOULD, MAY | RFC 2119 keywords | Normative requirements |
Conformance
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
Note: This document is non-normative. Normative requirements are defined in the individual specification parts.
What is WDP?#
The Waddling Diagnostic Protocol (WDP) is a structured, cross-language error coding system that provides both human-readable semantic codes and compact machine-friendly identifiers.
WDP solves a critical problem: How do you create error codes that are both meaningful to developers and efficient for systems?
The 5-Part Structure#
Every WDP error code consists of five parts:
Severity.Component.Primary.Sequence -> CompactID
^ ^ ^ ^ ^
Part 1 Part 2 Part 3 Part 4 Part 5Structure Breakdown:
Parts 1-4: Structured Code | Part 5: Compact ID
(Human-readable, semantic) | (Machine-friendly, efficient)Complete Example
E.Auth.Token.001 -> Xy8Qz
โ โ โ โ โ
โ โ โ โ โโ Part 5: Compact ID (5-char hash)
โ โ โ โโโโโโโโโ Part 4: Sequence (specific event)
โ โ โโโโโโโโโโโโโโโ Part 3: Primary (failure domain)
โ โโโโโโโโโโโโโโโโโโโโ Part 2: Component (system module)
โโโโโโโโโโโโโโโโโโโโโโ Part 1: Severity (urgency level)Both representations identify the same error:
- Structured code:
E.Auth.Token.001(for humans, logs, debugging) - Compact ID:
Xy8Qz(for APIs, transmission, databases)
The Five Parts Explained#
Part 1: Severity#
Single character indicating urgency and type
| Code | Meaning | Use Case |
|---|---|---|
| E | Error | Operation failed, needs attention |
| W | Warning | Potential issue, operation continues |
| C | Critical | System-critical failure |
| B | Blocked | Operation waiting/blocked |
| S | Success | Operation succeeded |
| K | Completed | Long-running task finished |
| I | Info | Informational message |
| T | Trace | Debug/trace information |
| H | Help | User assistance needed |
Examples: E (Error), W (Warning), S (Success)
See: 1-SEVERITY for complete specification
Part 2: Component#
System module or domain (PascalCase, max 16 characters)
The Component identifies which part of your system produced the error.
Can be:
- Physical subsystem:
Database,Network,FileSystem,Cache - Logical module:
Auth,Validation,BusinessLogic,Parser - Service boundary:
UserService,OrderService,PaymentGateway - Architectural layer:
Api,Domain,Infrastructure
Examples: Auth, Database, TokenValidator, ServiceRegistry
See: 2-COMPONENT for complete specification
Part 3: Primary#
Failure domain within component (PascalCase, max 16 characters)
The Primary field narrows down the specific area within the Component.
Relationship:
Component.Primary
โ โ
Auth.Token - Token-related authentication errors
Auth.Session - Session-related authentication errors
Auth.Permission - Permission-related authentication errors
Database.Connection - Database connection errors
Database.Query - Database query errors
Database.Transaction - Database transaction errorsExamples: Token, Connection, Syntax, Parse, Validation
See: 3-PRIMARY for complete specification
Part 4: Sequence#
Specific event identifier
The Sequence uniquely identifies a specific error within the Component.Primary namespace.
Format:
- Numeric (canonical):
001,002,003, ...,999 - Named (alias):
TOKEN_MISSING,TOKEN_EXPIRED, etc.
Model:
Canonical Identity: 001, 002, 003 (numeric)
โ
Associated Name: TOKEN_MISSING, TOKEN_EXPIRED (semantic)
โ
Display: Can show either or both
โ
Hash: ALWAYS computed from numericExamples: 001, 042, 999
See: 4-SEQUENCE for complete specification
Part 5: Compact ID (Hash)#
5-character hash derived from parts 1-4
The Compact ID is a short, deterministic hash of the structured code.
Generation:
Structured Code: E.Auth.Token.001
โ
Normalize: E.AUTH.TOKEN.001 (uppercase)
โ
Hash (xxHash64): [64-bit integer]
โ
Encode (Base62): Xy8QzProperties:
- 5 characters: Easy to communicate (users can report "error Xy8Qz")
- Deterministic: Same input always produces same hash
- Collision-resistant: 916 million possible values (62^5)
- Cross-language: Same hash across all implementations
See: 5-COMPACT-IDS for complete specification
How the Parts Work Together#
Hierarchical Organization
Severity
โโ Component (e.g., Auth)
โโ Primary (e.g., Token)
โ โโ Sequence 001 (TOKEN_MISSING)
โ โโ Sequence 002 (TOKEN_EXPIRED)
โ โโ Sequence 003 (TOKEN_INVALID)
โ
โโ Primary (e.g., Session)
โ โโ Sequence 001 (SESSION_MISSING)
โ โโ Sequence 013 (SESSION_CLOSED)
โ
โโ Primary (e.g., Permission)
โโ Sequence 008 (PERMISSION_DENIED)Error Space
Each Component.Primary combination has 999 possible sequences (001-999).
E.Auth.Token.* - 999 possible token-related errors
E.Auth.Session.* - 999 possible session-related errors
E.Database.Connection.* - 999 possible connection-related errors
Total space: (Components ร Primaries ร 999) = effectively unlimitedDual Representation: Structured vs Compact#
WDP provides two ways to represent the same error:
Structured Code (Parts 1-4)
Format: SEVERITY.COMPONENT.PRIMARY.SEQUENCE
Example: E.Auth.Token.001
Use when:
- Writing logs (human-readable)
- Debugging (semantic meaning clear)
- Monitoring dashboards (can filter/group)
- Code comments (self-documenting)
- Developer communication
Benefits:
- Self-documenting
- Semantic meaning obvious
- Can grep/filter by component
- Understandable without lookup
Compact ID (Part 5)
Format: [0-9A-Za-z]{5}
Example: Xy8Qz
Use when:
- API responses (compact)
- Database storage (efficient)
- Network transmission (bandwidth-limited)
- User-facing references (easy to communicate)
- Mobile/IoT (constrained devices)
Benefits:
- Compact (5 chars vs ~15-30 chars)
- Easy to communicate (users can say "error Xy8Qz")
- Efficient storage
- URL-safe
Using Both Together
Logs:
[2024-01-15 10:30:00] ERROR E.Auth.Token.001 [Xy8Qz]: Token missing
^^^^^^^^^^^^^^^^ ^^^^^
Semantic meaning Searchable hashAPI Response:
{
"error": {
"code": "E.Auth.Token.001",
"compact_id": "Xy8Qz",
"message": "Token missing from Authorization header",
"timestamp": "2024-01-15T10:30:00Z"
}
}Monitoring Dashboard:
Filter by component: E.Auth.*
Group by primary: E.Auth.Token.*, E.Auth.Session.*
Search by hash: Xy8QzUser Support:
User: "I got error Xy8Qz"
Support: [looks up Xy8Qz] โ E.Auth.Token.001 (TOKEN_MISSING)
"You need to provide an authentication token"Usage Patterns#
Pattern 1: Simple Logging
[ERROR] E.Auth.Token.001: Authentication failedUse structured code only. Human-readable, self-documenting.
Pattern 2: Compact API
{"error": "Xy8Qz"}Use compact ID only. Client looks up details in catalog.
Pattern 3: Full Context
[ERROR] E.Auth.Token.001 (Xy8Qz): Authentication failedUse both. Semantic meaning + searchable hash.
Pattern 4: Structured Logging
{
"severity": "error",
"code": "E.Auth.Token.001",
"compact_id": "Xy8Qz",
"component": "Auth",
"primary": "Token",
"sequence": 1,
"message": "Token missing"
}Full decomposition for structured logging systems.
Benefits of the 5-Part Design#
1. Dual Representation
Humans: E.Auth.Token.001 (readable, semantic)
Machines: Xy8Qz (compact, efficient)
Best of both worlds!2. Hierarchical Organization
Group by component: E.Auth.*
Filter by primary: E.Auth.Token.*
Search by sequence: *.*.*.001 (all "missing" errors)
Find specific: Xy8Qz3. Cross-Language Compatibility
Rust: E.Auth.Token.001 -> Xy8Qz
Python: E.Auth.Token.001 -> Xy8Qz
TypeScript: E.Auth.Token.001 -> Xy8Qz
Same code, same hash, everywhere4. Graceful Degradation
If catalog unavailable:
- Structured code: Still somewhat understandable
"E.Auth.Token.001" โ probably auth token error
- Compact ID only: Meaningless without lookup
"Xy8Qz" โ what does this mean?
Redundancy provides fallback!5. Flexible Adoption
Simple systems: Use structured code only
Advanced systems: Use full 5-part structure
Network-limited: Use compact ID + catalog
Legacy integration: Map to/from other systems
One protocol, multiple adoption pathsInternationalization (i18n)#
Canonical Form
All error codes have a canonical English form:
[E.Auth.Token.001] -> Xy8QzLocalized Aliases
Display can be localized, but hash is universal:
English: [E.Auth.Token.001] -> Xy8Qz
Arabic: [ุฎ.ุงูู
ุตุงุฏูุฉ.ุงูุฑู
ุฒ.001] -> Xy8Qz
Japanese: [E.่ช่จผ.ใใผใฏใณ.001] -> Xy8Qz
Chinese: [E.่ฎค่ฏ.ไปค็.001] -> Xy8QzHash is computed from canonical English form, but all localized aliases map to the same hash!
Hash input: E.AUTH.TOKEN.001 (canonical English, uppercase)
Hash output: Xy8Qz (same for all languages)
Users see localized display
Systems use universal hashSee: 8-I18N for complete internationalization specification
Common Questions#
Q: Do I need to use all 5 parts?
A: You can use structured code only OR compact ID only, depending on your needs. Both represent the same error.
Q: Can I add custom fields?
A: The 5-part structure is the protocol core. You can add custom metadata in your implementation, but the 5 parts ensure interoperability.
Q: What if I need more than 999 sequences?
A: This usually indicates your Component.Primary is too broad. Split it into more specific categories. Example: Parser.Syntax.*, Parser.Semantic.*, Parser.Lexical.*
Q: Are named sequences required?
A: No! Numeric sequences (001-999) are the canonical identity. Named sequences are optional aliases for documentation and code readability.
Q: Can components be logical, not just physical?
A: Yes! Components can be physical (Database), logical (Auth), services (UserService), or architectural layers (Api). Choose what fits your system.
Stability and Evolution#
For version 0.1.0-draft, the specification parts are classified by stability level:
Stable (Breaking changes unlikely)
These parts define the core protocol and are considered stable:
| Part | Document | Stability | Notes |
|---|---|---|---|
| 1 | 1-SEVERITY | Stable | Severity codes (E, W, C, I, H) are fixed |
| 2 | 2-COMPONENT | Stable | Component field format is fixed |
| 3 | 3-PRIMARY | Stable | Primary field format is fixed |
| 4 | 4-SEQUENCE | Stable | Sequence format (001-999) is fixed |
| 5 | 5-COMPACT-IDS | Stable | xxHash64 + Base62 encoding is fixed |
Provisional (May evolve with feedback)
These parts are well-designed but may evolve based on implementation experience:
| Part | Document | Stability | Notes |
|---|---|---|---|
| 7 | 7-NAMESPACES | Provisional | Namespace hash format is stable; boundary semantics may refine |
| 8 | 8-I18N | Provisional | Core model stable; locale fallback rules may evolve |
| 9 | 9-CATALOGS | Provisional | Catalog concept stable; format details may evolve |
| 9a | 9a-CATALOG-FORMAT | Provisional | JSON schema may add optional fields |
| 9b | 9b-WIRE-PROTOCOL | Provisional | Wire format stable; content negotiation may be added |
| 9c | 9c-IMPLEMENTATION | Provisional | Examples may expand; patterns are recommendations |
| 11 | 11-SECURITY | Provisional | Security model stable; requirements may strengthen |
| 12 | 12-METADATA | Provisional | Schema structure stable; optional fields may be added |
Informative (Non-normative guidance)
These parts provide recommendations and may change freely:
| Part | Document | Stability | Notes |
|---|---|---|---|
| 6 | 6-SEQUENCE-CONVENTIONS | Informative | Conventions are suggestions only |
| 10 | 10-PRESENTATION | Informative | Visual guidelines are recommendations |
Evolution Principles
- Backward Compatibility: Stable parts will not introduce breaking changes without a major version bump
- Catalog Versioning: The
versionfield in catalogs enables graceful migration - Optional Extension: New features will be added as optional fields where possible
- Deprecation Policy: Features will be deprecated before removal, with at least one minor version warning
Specification Documents#
For detailed implementation specifications, see:
Core Specification (Parts 1-5)
- 1-SEVERITY โ Part 1: Severity levels
- 2-COMPONENT โ Part 2: Component field
- 3-PRIMARY โ Part 3: Primary field
- 4-SEQUENCE โ Part 4: Sequence field
- 5-COMPACT-IDS โ Part 5: Hash generation
Extensions & Conventions
- 6-SEQUENCE-CONVENTIONS โ Informative: Recommended sequence meanings
- 7-NAMESPACES โ Optional: Namespace collision prevention
- 8-I18N โ Optional: Internationalization
- 9-CATALOGS โ Optional: Catalog formats and usage
- 10-PRESENTATION โ Informative: Visual guidelines
- 11-SECURITY โ Security considerations
- 12-METADATA โ Additional metadata
Quick Reference#
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ WDP Error Code Structure โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ [SEVERITY.COMPONENT.PRIMARY.SEQUENCE] -> COMPACT_ID โ
โ โ โ โ โ โ โ
โ โ โ โ โ โโ Part 5: Hash โ
โ โ โ โ โโโโโโโโโโโโโโโ Part 4: Event โ
โ โ โ โโโโโโโโโโโโโโโโโโโโโโโโ Part 3: Domain โ
โ โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Part 2: Module โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Part 1: Urgency โ
โ โ
โ Example: [E.Auth.Token.001] -> Xy8Qz โ
โ โ
โ Parts 1-4: Human-readable structured code โ
โ Part 5: Machine-friendly compact identifier โ
โ โ
โ Hash is ALWAYS generated from structured code โ
โ Both representations can be used independently โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ