Skip to content

Commit 462db9b

Browse files
committed
docs: update documentation and website for Milestone 5 (QoS=2) completion
- Update README.md with QoS=2 features and completion status - Update CLAUDE.md project status to Milestone 5 completed - Update docs/roadmap.md with QoS=2 completion details - Update docs/roadmap.html timeline for v0.5.0 completion - Update docs/features.html with QoS=2 feature section - Update docs/index.html to v0.5.0 release - Update docs/documentation.html with QoS=2 packet types and message flow https://claude.ai/code/session_01DTujjLzKvpKqxytbTwTVpc
1 parent 02fa769 commit 462db9b

7 files changed

Lines changed: 137 additions & 68 deletions

File tree

CLAUDE.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ IoTHub is a high-performance MQTT server implemented in Rust using Tokio. The ar
8787
5. **Event-driven**: tokio::select! for responsive packet and shutdown handling
8888
6. **Session Management**: SessionId starts as `__anon_$uuid`, becomes `__client_$clientId` after CONNECT
8989

90-
### Current Status (Milestone 3 - Completed)
90+
### Current Status (Milestone 5 - Completed)
9191

9292
**✅ Milestone 1 Completed:**
9393
- Event-driven architecture with tokio::select!
@@ -121,6 +121,22 @@ IoTHub is a high-performance MQTT server implemented in Rust using Tokio. The ar
121121
- Atomic session state save (all-or-nothing)
122122
- Config-based storage backend selection
123123

124+
**✅ Milestone 4 Completed:**
125+
- TLS/SSL encryption via `tls://` listener prefix
126+
- Multiple simultaneous listeners (TCP + TLS)
127+
- Username/password authentication (file-based)
128+
- Topic-based ACLs for publish/subscribe access control
129+
- Pluggable auth and ACL backends (`allowall`, `file`)
130+
131+
**✅ Milestone 5 Completed:**
132+
- QoS=2 "exactly once" delivery guarantee
133+
- PUBREC/PUBREL/PUBCOMP four-step handshake
134+
- QoS=2 state machine (AwaitingPubRec, AwaitingPubComp)
135+
- Inbound and outbound QoS=2 message handling
136+
- QoS=2 retransmission (PUBLISH and PUBREL retry)
137+
- QoS=2 state persistence across restarts
138+
- Comprehensive QoS=2 test coverage
139+
124140
### Project Structure
125141
- `src/auth/` - Authentication and authorization (Milestone 4+)
126142
- `src/protocol/` - MQTT protocol implementation (v3.1.1 in progress)
@@ -134,8 +150,8 @@ IoTHub is a high-performance MQTT server implemented in Rust using Tokio. The ar
134150
**Milestone 1** ✅: Full MQTTv3 Server (QoS=0, no persistency/auth)
135151
**Milestone 2** ✅: QoS=1 Support
136152
**Milestone 3** ✅: Persistence Layer
137-
**Milestone 4**: Security (TLS, Auth, ACLs)
138-
**Milestone 5**: QoS=2 Support
153+
**Milestone 4**: Security (TLS, Auth, ACLs)
154+
**Milestone 5**: QoS=2 Support
139155
**Milestone 6**: Observability (Prometheus, Grafana)
140156
**Milestone 7**: Flow Control & Production Features
141157
**v1.0**: Production Ready

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A high-performance MQTT server daemon implementation in Rust using Tokio, design
1515
## Features
1616

1717
- **MQTT v3.1.1 protocol support** with all packet types
18-
- **QoS=0 and QoS=1** message delivery with retransmission and DUP detection
18+
- **QoS=0, QoS=1, and QoS=2** message delivery with full protocol support
1919
- **Message routing** with full MQTT wildcard support (`+` single-level, `#` multi-level)
2020
- **Clean session** with session takeover and proper cleanup
2121
- **Keep-alive mechanism** with configurable timeouts
@@ -30,13 +30,13 @@ A high-performance MQTT server daemon implementation in Rust using Tokio, design
3030
- **Race-condition-free shutdown** using CancellationToken
3131
- **UNIX signal handling** (SIGINT graceful, SIGTERM immediate)
3232
- **Comprehensive configuration** with TOML support
33-
- **Extensive test coverage** with 100+ tests validating all functionality
33+
- **Extensive test coverage** with 136+ tests validating all functionality
3434

3535
## Current Status
3636

37-
**IoTD has completed Milestone 4 - Security! 🎉**
37+
**IoTD has completed Milestone 5 - QoS=2! 🎉**
3838

39-
The project now has full security support including TLS encryption, username/password authentication, and topic-based access control lists.
39+
The project now supports all three MQTT QoS levels, providing "exactly once" delivery guarantee with the complete PUBREC/PUBREL/PUBCOMP four-step handshake protocol.
4040

4141
### Completed Features ✅
4242

@@ -84,15 +84,25 @@ The project now has full security support including TLS encryption, username/pas
8484
-**Config-based TLS** - Certificate and key file paths in TOML
8585
-**TLS integration tests** - Self-signed cert testing with rcgen
8686

87+
#### Milestone 5 - QoS=2 ✅ **COMPLETED**
88+
-**QoS=2 message delivery** - "Exactly once" guarantee fully implemented
89+
-**PUBREC/PUBREL/PUBCOMP flow** - Complete four-step handshake protocol
90+
-**QoS=2 state machine** - AwaitingPubRec and AwaitingPubComp states
91+
-**Inbound QoS=2 tracking** - Broker receives and processes QoS=2 messages
92+
-**Outbound QoS=2 delivery** - Broker sends QoS=2 to subscribers
93+
-**QoS=2 retransmission** - PUBLISH and PUBREL retry on timeout
94+
-**QoS=2 persistence** - State survives server restarts
95+
-**Comprehensive QoS=2 tests** - 5+ integration tests covering all scenarios
96+
8797
### Roadmap 📋
8898

8999
#### Near-term (v0.x - v1.0)
90100
- **Milestone 1**: ✅ Basic MQTT Server (Completed)
91101
- **Milestone 2**: ✅ QoS=1 Support (Completed)
92102
- **Milestone 3**: ✅ Persistence Layer (Completed)
93103
- **Milestone 4**: ✅ Security - TLS, Authentication, ACLs (Completed)
94-
- **Milestone 5** (Next): QoS=2 "exactly once" delivery
95-
- **Milestone 6**: Observability (Prometheus, Grafana)
104+
- **Milestone 5**: ✅ QoS=2 "exactly once" delivery (Completed)
105+
- **Milestone 6** (Next): Observability (Prometheus, Grafana)
96106
- **Milestone 7**: Flow control & production features
97107
- **v1.0**: Production-ready single-node broker
98108

docs/documentation.html

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ <h2>MQTT Protocol Implementation</h2>
9696
<h3>Supported Packet Types</h3>
9797
<ul>
9898
<li><strong>Control</strong>: CONNECT, CONNACK, DISCONNECT, PINGREQ, PINGRESP</li>
99-
<li><strong>Publish</strong>: PUBLISH, PUBACK (QoS=1)</li>
99+
<li><strong>Publish QoS=1</strong>: PUBLISH, PUBACK</li>
100+
<li><strong>Publish QoS=2</strong>: PUBLISH, PUBREC, PUBREL, PUBCOMP</li>
100101
<li><strong>Subscribe</strong>: SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK</li>
101102
</ul>
102103

@@ -107,6 +108,24 @@ <h3>QoS=1 Message Flow</h3>
107108
└──── PUBACK ────────┘ └── PUBACK ─┘</pre>
108109
</div>
109110

111+
<h3>QoS=2 Message Flow (Exactly Once)</h3>
112+
<div class="code-block">
113+
<pre>Publisher IoTD Subscriber
114+
│ │ │
115+
├── PUBLISH (QoS=2) ──────►│ │
116+
│ │──── store message ────► │
117+
│◄────── PUBREC ───────────│ │
118+
│ │ │
119+
├────── PUBREL ───────────►│──── PUBLISH (QoS=2) ───►│
120+
│ │ │
121+
│ │◄────── PUBREC ───────────│
122+
│◄────── PUBCOMP ──────────│ │
123+
│ │────── PUBREL ───────────►│
124+
│ │ │
125+
│ │◄────── PUBCOMP ──────────│
126+
│ │ │</pre>
127+
</div>
128+
110129
<h3>Topic Validation Rules</h3>
111130
<ul>
112131
<li>Topics must not be empty</li>
@@ -129,11 +148,12 @@ <h3>Server Configuration</h3>
129148
# Default: 10000
130149
retained_message_limit = 10000
131150

132-
# Maximum retransmission attempts for QoS=1
151+
# Maximum retransmission attempts for QoS=1 and QoS=2
133152
# Default: 10
134153
max_retransmission_limit = 10
135154

136155
# Interval between retransmission attempts (milliseconds)
156+
# Applies to PUBLISH (QoS=1, QoS=2) and PUBREL (QoS=2)
137157
# Default: 5000 (5 seconds)
138158
retransmission_interval_ms = 5000
139159

docs/features.html

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h2>Core MQTT Features</h2>
3838
<li><strong>MQTT v3.1.1 Protocol Support</strong> - Full implementation of all packet types</li>
3939
<li><strong>QoS=0 (At Most Once)</strong> - Fire-and-forget message delivery</li>
4040
<li><strong>QoS=1 (At Least Once)</strong> - Reliable delivery with acknowledgments</li>
41-
<li>🚧 <strong>QoS=2 (Exactly Once)</strong> - Coming in Milestone 5</li>
41+
<li> <strong>QoS=2 (Exactly Once)</strong> - Guaranteed exactly-once delivery</li>
4242
<li><strong>Wildcard Subscriptions</strong> - Support for + and # wildcards</li>
4343
<li><strong>Retained Messages</strong> - Store and deliver last known good values</li>
4444
<li><strong>Will Messages</strong> - Last Will and Testament support</li>
@@ -57,6 +57,18 @@ <h2>Quality of Service Level 1</h2>
5757
<li><strong>QoS Downgrade</strong> - Proper min(publish, subscribe) handling</li>
5858
</ul>
5959

60+
<h2>Quality of Service Level 2</h2>
61+
<p>Our QoS=2 implementation guarantees exactly-once delivery with:</p>
62+
<ul>
63+
<li><strong>Four-Step Handshake</strong> - PUBLISH → PUBREC → PUBREL → PUBCOMP</li>
64+
<li><strong>State Machine</strong> - AwaitingPubRec and AwaitingPubComp states</li>
65+
<li><strong>Inbound Tracking</strong> - Proper handling of received QoS=2 messages</li>
66+
<li><strong>Outbound Delivery</strong> - QoS=2 delivery to subscribers</li>
67+
<li><strong>Retransmission</strong> - Automatic retry for PUBLISH and PUBREL</li>
68+
<li><strong>State Persistence</strong> - QoS=2 state survives server restarts</li>
69+
<li><strong>Duplicate Detection</strong> - Proper handling of duplicate messages</li>
70+
</ul>
71+
6072
<h2>Security</h2>
6173
<p>Production-grade security with TLS, authentication, and authorization:</p>
6274
<ul>
@@ -73,7 +85,8 @@ <h2>Persistence Layer</h2>
7385
<ul>
7486
<li><strong>Session Persistence</strong> - Restore sessions for clean_session=false clients</li>
7587
<li><strong>Subscription Recovery</strong> - Subscriptions survive reconnects</li>
76-
<li><strong>In-Flight Messages</strong> - QoS=1 messages restored on reconnect</li>
88+
<li><strong>In-Flight Messages</strong> - QoS=1 and QoS=2 messages restored on reconnect</li>
89+
<li><strong>QoS=2 State</strong> - Inbound QoS=2 messages persist across restarts</li>
7790
<li><strong>Retained Messages</strong> - Persist across server restarts</li>
7891
<li><strong>InMemoryStorage</strong> - Fast storage for development/testing</li>
7992
<li><strong>SqliteStorage</strong> - Durable storage for production</li>

docs/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h1>IoTD - IoT Daemon</h1>
3636
<p class="description">A modern, async MQTT v3.1.1 server implementation designed for scalability, reliability, and extensibility.</p>
3737
<div class="cta-buttons">
3838
<a href="getting-started.html" class="btn btn-primary">Get Started</a>
39-
<a href="https://github.com/lileding/iotd/releases/latest" class="btn btn-secondary">Download v0.4.0</a>
39+
<a href="https://github.com/lileding/iotd/releases/latest" class="btn btn-secondary">Download v0.5.0</a>
4040
</div>
4141
</div>
4242
</header>
@@ -73,7 +73,7 @@ <h3>🛡️ Reliable</h3>
7373
<div class="container">
7474
<h2>Quick Start</h2>
7575
<pre><code># Download and extract
76-
wget https://github.com/lileding/iotd/releases/download/v0.4.0/iotd-linux-x86_64.tar.gz
76+
wget https://github.com/lileding/iotd/releases/download/v0.5.0/iotd-linux-x86_64.tar.gz
7777
tar -xzf iotd-linux-x86_64.tar.gz
7878

7979
# Run the server
@@ -86,17 +86,17 @@ <h2>Quick Start</h2>
8686

8787
<section class="latest-release">
8888
<div class="container">
89-
<h2>Latest Release: v0.4.0</h2>
89+
<h2>Latest Release: v0.5.0</h2>
9090
<div class="release-info">
91-
<h3>Security Complete! 🎉</h3>
91+
<h3>QoS=2 Complete! 🎉</h3>
9292
<ul>
93-
<li>TLS/SSL encryption with configurable certificates</li>
94-
<li>Multiple simultaneous listeners (TCP + TLS)</li>
95-
<li>Username/password authentication (file-based)</li>
96-
<li>Topic-based access control lists (ACLs)</li>
97-
<li>100+ comprehensive tests</li>
93+
<li>QoS=2 "exactly once" delivery guarantee</li>
94+
<li>Complete PUBREC/PUBREL/PUBCOMP four-step handshake</li>
95+
<li>QoS=2 state persistence across restarts</li>
96+
<li>Full MQTT 3.1.1 QoS support (0, 1, and 2)</li>
97+
<li>136+ comprehensive tests</li>
9898
</ul>
99-
<a href="https://github.com/lileding/iotd/releases/tag/v0.4.0" class="btn btn-small">View Release Notes</a>
99+
<a href="https://github.com/lileding/iotd/releases/tag/v0.5.0" class="btn btn-small">View Release Notes</a>
100100
</div>
101101
</div>
102102
</section>

docs/roadmap.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,20 @@ <h3>v0.4.0 - Security <span class="status completed">Completed</span></h3>
9090
</ul>
9191
</div>
9292

93-
<div class="timeline-item">
94-
<h3>v0.5.0 - QoS=2 <span class="status planned">Next</span></h3>
93+
<div class="timeline-item completed">
94+
<h3>v0.5.0 - QoS=2 <span class="status completed">Completed</span></h3>
9595
<p><strong>Milestone 5: Exactly Once Delivery</strong></p>
9696
<ul>
97-
<li>🎯 QoS=2 implementation</li>
98-
<li>🎯 PUBREC/PUBREL/PUBCOMP flow</li>
99-
<li>🎯 Two-phase commit protocol</li>
100-
<li>🎯 State persistence for QoS=2</li>
97+
<li>✅ QoS=2 implementation with exactly-once guarantee</li>
98+
<li>✅ PUBREC/PUBREL/PUBCOMP four-step handshake</li>
99+
<li>✅ QoS=2 state machine and retransmission</li>
100+
<li>✅ State persistence for QoS=2 across restarts</li>
101+
<li>✅ Comprehensive QoS=2 test suite</li>
101102
</ul>
102103
</div>
103104

104105
<div class="timeline-item">
105-
<h3>v0.6.0 - Observability <span class="status planned">Planned</span></h3>
106+
<h3>v0.6.0 - Observability <span class="status planned">Next</span></h3>
106107
<p><strong>Milestone 6: Monitoring & Metrics</strong></p>
107108
<ul>
108109
<li>📊 Prometheus metrics export</li>

docs/roadmap.md

Lines changed: 47 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -150,29 +150,34 @@ IoTD (IoT Daemon) development follows a progressive milestone approach, where ea
150150

151151
---
152152

153-
### Milestone 5: QoS=2 Support 🎯 **PLANNED**
153+
### Milestone 5: QoS=2 Support **COMPLETED**
154154
**Target**: Exactly-once delivery guarantee
155155

156-
**Features to Implement:**
157-
- 🎯 QoS=2 (Exactly once) message delivery
158-
- 🎯 PUBREC/PUBREL/PUBCOMP flow
159-
- 🎯 Two-phase commit protocol
160-
- 🎯 Message state persistence for QoS=2
161-
- 🎯 Duplicate detection across restarts
162-
- 🎯 Proper error handling and recovery
163-
164-
**Technical Challenges:**
165-
- Complex state machine for QoS=2 flow
166-
- Ensuring exactly-once semantics
167-
- Performance impact of two-phase protocol
168-
- Recovery after crashes
156+
**✅ Completed Features:**
157+
- ✅ QoS=2 (Exactly once) message delivery
158+
- ✅ PUBREC/PUBREL/PUBCOMP four-step handshake
159+
- ✅ QoS=2 state machine (AwaitingPubRec, AwaitingPubComp)
160+
- ✅ Inbound QoS=2 tracking for received messages
161+
- ✅ Outbound QoS=2 delivery to subscribers
162+
- ✅ QoS=2 retransmission (PUBLISH and PUBREL retry)
163+
- ✅ QoS=2 state persistence across restarts
164+
- ✅ QoS downgrade handling (min of publish/subscribe QoS)
165+
- ✅ Duplicate detection and proper handling
166+
- ✅ Comprehensive QoS=2 test suite
169167

170-
**Timeline**: 6-8 weeks
171-
**Success Criteria**:
172-
- [ ] QoS=2 messages delivered exactly once
173-
- [ ] Proper handling of all edge cases
174-
- [ ] State survives server restarts
175-
- [ ] Acceptable performance
168+
**Architecture Implemented:**
169+
- Extended InflightMessage with qos2_state field
170+
- Separate inbound_qos2 HashMap for received messages
171+
- State machine: AwaitingPubRec → AwaitingPubComp → Complete
172+
- Retransmission logic handles both PUBLISH and PUBREL
173+
- Persistence types: PersistedQos2State, PersistedInboundQos2Message
174+
175+
**Timeline**: Completed
176+
**Success Criteria**: All achieved ✓
177+
- [] QoS=2 messages delivered exactly once
178+
- [] Proper handling of all edge cases
179+
- [] State survives server restarts
180+
- [] Acceptable performance
176181

177182
---
178183

@@ -268,11 +273,13 @@ IoTD (IoT Daemon) development follows a progressive milestone approach, where ea
268273
- Topic-based ACLs ✓
269274
- Multiple simultaneous listeners ✓
270275

271-
### v0.5.0 - QoS=2 (Milestone 5) 🎯
272-
- Exactly-once delivery
273-
- PUBREC/PUBREL/PUBCOMP flow
274-
- Two-phase commit protocol
275-
- State persistence for QoS=2
276+
### v0.5.0 - QoS=2 (Milestone 5) ✅ **COMPLETED**
277+
- Exactly-once delivery ✓
278+
- PUBREC/PUBREL/PUBCOMP flow ✓
279+
- QoS=2 state machine ✓
280+
- State persistence for QoS=2 ✓
281+
- Retransmission for PUBLISH and PUBREL ✓
282+
- Comprehensive test coverage ✓
276283

277284
### v0.6.0 - Observability (Milestone 6) 📊
278285
- Prometheus metrics
@@ -438,22 +445,24 @@ IoTD (IoT Daemon) development follows a progressive milestone approach, where ea
438445

439446
---
440447

441-
## What's Next: Milestone 5 - QoS=2 🎯
448+
## What's Next: Milestone 6 - Observability 📊
442449

443-
With security now complete, the next major milestone implements exactly-once delivery:
450+
With QoS=2 now complete, the next major milestone adds production monitoring capabilities:
444451

445452
**Key Features to Implement:**
446-
1. **QoS=2 Delivery**: PUBREC/PUBREL/PUBCOMP four-packet flow
447-
2. **Two-phase commit**: Ensure exactly-once semantics
448-
3. **State Persistence**: QoS=2 state survives server restarts
449-
4. **Duplicate Detection**: Across reconnects and restarts
450-
5. **Proper Error Handling**: Recovery after partial flows
451-
452-
**Preparation Tasks:**
453-
- Extend session state machine for QoS=2 states
454-
- Add QoS=2 in-flight tracking to storage trait
455-
- Design packet ID reuse rules per MQTT 3.1.1 spec
456-
- Plan comprehensive QoS=2 test scenarios
453+
1. **Prometheus Metrics**: Export broker metrics for monitoring
454+
2. **Grafana Dashboards**: Pre-built dashboard templates
455+
3. **Health Check Endpoints**: HTTP endpoints for load balancers
456+
4. **Structured Logging**: Enhanced logging with levels and context
457+
5. **Performance Metrics**: Connection, message, and latency tracking
458+
459+
**Metrics to Export:**
460+
- Connection count and connection rate
461+
- Message throughput by QoS level
462+
- Topic statistics and subscription counts
463+
- Error rates and types
464+
- Resource usage (memory, CPU)
465+
- Latency percentiles
457466

458467
---
459468

0 commit comments

Comments
 (0)