Skip to content

Commit 8dd11d4

Browse files
committed
docs: documentation improvements
1 parent d45c8eb commit 8dd11d4

File tree

16 files changed

+47
-49
lines changed

16 files changed

+47
-49
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Implementation details for contributors and advanced operators.
8989
| `UserService` | User accounts, emails, verification |
9090
| `AppService` | Application management, credentials, connections |
9191
| `TokenService` | JWT token lifecycle (sessions, vault tokens, signing keys) |
92+
| `InvitationService` | Organization invitation lifecycle |
9293
| `EventsService` | Audit event queries and ingestion |
9394
| `HealthService` | Liveness, readiness, and dependency checks |
9495
| `SystemDiscoveryService` | Peer discovery and cluster bootstrap |

docs/adr/count-min-sketch-hot-key-detection.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ Seahash produces a 64-bit hash formatted as a fixed 16-character hex string. Ope
115115

116116
- `crates/raft/src/hot_key_detector.rs` — CMS implementation, rotating windows, top-k tracking
117117
- `crates/types/src/config.rs``HotKeyConfig` with defaults and validation
118-
- `crates/services/src/services/write.rs``record_hot_keys()` integration in write path
119-
- `crates/services/src/services/multi_region_write.rs` — Multi-region coordinator integration
118+
- `crates/services/src/services/write.rs``record_hot_keys()` integration in write path (includes multi-region coordinator)
120119
- `crates/raft/src/metrics.rs``record_hot_key_detected()` with seahash label
121120
- Cormode & Muthukrishnan, "An Improved Data Stream Summary: The Count-Min Sketch and its Applications" (2005)

docs/adr/network-trust-model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ TLS is supported for transport encryption (defense in depth) but not enforced fo
7373

7474
- Default `listen_addr` is `127.0.0.1:50051` (localhost-only) — requires explicit override for cluster deployment
7575
- Optional TLS for transport encryption within the private network
76-
- Input validation (Task 1) and rate limiting (Task 4) protect against malformed or excessive requests from buggy upstream callers
76+
- Input validation and rate limiting protect against malformed or excessive requests from buggy upstream callers
7777
- Audit logging records all mutations with caller slug for attribution
7878

7979
## References

docs/adr/server-assigned-sequences.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ enum WriteErrorCode {
9292

9393
| Aspect | Old (Sequence-Based) | New (UUID-Based) |
9494
| --------------------- | ---------------------------------------- | ----------------------------------------------- |
95-
| **Key** | `(ns_id, vault_id, client_id, sequence)` | `(ns_id, vault_id, client_id, idempotency_key)` |
95+
| **Key** | `(org_id, vault_id, client_id, sequence)` | `(org_id, vault_id, client_id, idempotency_key)` |
9696
| **Assignment** | Client | Client (key), Server (sequence) |
9797
| **Validation** | `seq == last + 1` | Key exists in cache? |
9898
| **Retry** | Same sequence returns cached result | Same UUID returns cached result |

docs/client/admin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Only works on vaults in `DIVERGED` state unless `force: true` is set.
184184

185185
Simulates vault divergence for testing recovery procedures. Forces a vault into the `DIVERGED` state without actual data corruption.
186186

187-
**Note**: Only available when the server is built with the `test-utils` feature.
187+
Only available when the server is built with the `test-utils` feature.
188188

189189
```bash
190190
grpcurl -plaintext \

docs/client/api.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Client API
44

5-
This document covers read and write operations, error handling, and pagination.
5+
Read and write operations, error handling, and pagination for Ledger's gRPC API.
66

77
## gRPC Services Overview
88

@@ -16,6 +16,7 @@ This document covers read and write operations, error handling, and pagination.
1616
| `UserService` | User CRUD, emails, credentials (passkey/TOTP/recovery), TOTP verification |
1717
| `AppService` | App lifecycle, credentials, vault connections |
1818
| `TokenService` | JWT sessions, refresh, signing key management |
19+
| `InvitationService` | Organization invitation lifecycle |
1920
| `EventsService` | Audit event listing, filtering, ingestion |
2021
| `HealthService` | Readiness, liveness, startup probes |
2122
| `DiscoveryService` | Endpoint discovery, region topology |
@@ -63,7 +64,7 @@ All operations are idempotent, resolved by Raft total ordering:
6364
| `DeleteEntity` | exists | deleted | Transaction succeeds |
6465
| `DeleteEntity` | not exists | no change | Transaction succeeds (no-op) |
6566

66-
Note: `WriteResponse` is transaction-level (success or error), not per-operation. All operations in a transaction either succeed together or fail together.
67+
`WriteResponse` is transaction-level (success or error), not per-operation. All operations in a transaction either succeed together or fail together.
6768

6869
### Conditional Writes
6970

docs/client/errors.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,15 @@ grpcurl -plaintext \
129129

130130
**Resolution**: Retry with exponential backoff. Election should complete within seconds.
131131

132-
```go
133-
// Example retry logic
134-
maxRetries := 5
135-
for i := 0; i < maxRetries; i++ {
136-
resp, err := client.Write(ctx, req)
137-
if status.Code(err) == codes.Unavailable {
138-
time.Sleep(time.Duration(1<<i) * 100 * time.Millisecond)
139-
continue
140-
}
141-
return resp, err
142-
}
132+
```bash
133+
# Retry with exponential backoff until leader is elected
134+
grpcurl -plaintext \
135+
-d '{"organization_slug": {"id": "1"}, "client_id": {"id": "c1"}, "sequence": "1", ...}' \
136+
localhost:50051 ledger.v1.WriteService/Write
143137
```
144138

139+
The SDK handles retries automatically. See [SDK Guide](../client/sdk.md) for retry configuration.
140+
145141
### RATE_LIMITED
146142

147143
**Code**: `RESOURCE_EXHAUSTED`
@@ -235,7 +231,7 @@ Token-related operations (via `TokenService`) return specific error conditions:
235231
| `InvalidRefreshToken` | `UNAUTHENTICATED` | Refresh token is invalid or expired |
236232
| `RefreshTokenReuse` | `UNAUTHENTICATED` | Refresh token reuse detected; family revoked |
237233

238-
> **Note:** Refresh token reuse triggers family poisoning — all tokens in the same family are eventually revoked. This is a theft detection mechanism and cannot be reversed.
234+
Refresh token reuse triggers family poisoning — all tokens in the same family are eventually revoked. This is a theft detection mechanism and cannot be reversed.
239235

240236
## Error Details
241237

@@ -337,4 +333,4 @@ grpcurl -plaintext \
337333

338334
The idempotency cache ensures the operation is only applied once.
339335

340-
> **Note**: The idempotency cache is replicated via Raft and survives leader failover within the 24-hour TTL window. Retried requests with matching `(client_id, sequence)` return `ALREADY_COMMITTED` after leader change.
336+
The idempotency cache is replicated via Raft and survives leader failover within the 24-hour TTL window. Retried requests with matching `(client_id, sequence)` return `ALREADY_COMMITTED` after leader change.

docs/client/idempotency.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Idempotency & Retry Semantics
44

5-
This document covers transaction identification, sequence tracking, and retry behavior.
5+
Transaction identification, sequence tracking, and retry behavior for Ledger writes.
66

77
## Transaction Identification
88

@@ -120,8 +120,8 @@ Client state is tracked at two levels:
120120

121121
| Write Scope | GetClientState Call | Use Case |
122122
| --------------------- | -------------------------------------------- | -------------------------------- |
123-
| Organization entities | `GetClientState(ns_id, client_id)` | Control writing users, sessions |
124-
| Vault relationships | `GetClientState(ns_id, vault_id, client_id)` | App writing authorization tuples |
123+
| Organization entities | `GetClientState(org_slug, client_id)` | Control writing users, sessions |
124+
| Vault relationships | `GetClientState(org_slug, vault_slug, client_id)` | App writing authorization tuples |
125125

126126
A single client can have separate sequence streams for each scope.
127127

docs/client/sdk.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,11 @@ let stream = client.watch_blocks(
489489
use inferadb_ledger_types::Region;
490490

491491
// Create organization (requires a region for data residency)
492-
let ns = client.create_organization("my_app", Region::US_EAST_VA).await?;
493-
println!("Organization ID: {}", ns.id);
492+
let org = client.create_organization("my_app", Region::US_EAST_VA).await?;
493+
println!("Organization ID: {}", org.id);
494494

495495
// Get organization info
496-
let info = client.get_organization(ns.id).await?;
496+
let info = client.get_organization(org.id).await?;
497497
println!("Status: {:?}", info.status);
498498

499499
// List organizations
@@ -594,7 +594,7 @@ for key in &keys {
594594
}
595595
```
596596

597-
> **Note:** Refresh tokens use rotate-on-use semantics. Each refresh token can be used at most once — reuse triggers family poisoning (theft detection), revoking all tokens in that family.
597+
Refresh tokens use rotate-on-use semantics. Each refresh token can be used at most once — reuse triggers family poisoning (theft detection), revoking all tokens in that family.
598598

599599
## Organization Operations
600600

@@ -780,7 +780,7 @@ async fn handle_errors(client: &LedgerClient) -> Result<()> {
780780
use inferadb_ledger_sdk::SdkError;
781781
use tonic::Code;
782782

783-
match client.write(ns, vault, ops, None).await {
783+
match client.write(org_slug, vault, ops, None).await {
784784
Ok(result) => {
785785
println!("Committed: {}", result.tx_id);
786786
}
@@ -817,7 +817,7 @@ The SDK automatically retries transient errors. For custom retry logic:
817817
use inferadb_ledger_sdk::with_retry;
818818

819819
let result = with_retry(&retry_policy, || async {
820-
client.read(ns, None, "key").await
820+
client.read(org_slug, None, "key").await
821821
}).await?;
822822
```
823823

@@ -936,11 +936,11 @@ Prefer batch operations for bulk work:
936936

937937
```rust
938938
// Good: single round-trip
939-
let results = client.batch_read(ns, None, keys).await?;
939+
let results = client.batch_read(org_slug, None, keys).await?;
940940

941941
// Bad: N round-trips
942942
for key in keys {
943-
let result = client.read(ns, None, key).await?;
943+
let result = client.read(org_slug, None, key).await?;
944944
}
945945
```
946946

docs/development/architecture.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Foundational types used by all other crates.
4747
- `hash.rs` - SHA-256 and seahash implementations
4848
- `merkle.rs` - Merkle tree and proof types
4949
- `error.rs` - Error types with snafu
50-
- `identifiers.rs` - OrganizationSlug, VaultId, NodeId, etc.
50+
- `types/ids.rs` - OrganizationSlug, VaultId, NodeId, etc.
5151

5252
**Design principle:** No I/O, no external dependencies beyond crypto.
5353

@@ -111,6 +111,7 @@ gRPC service implementations and server assembly.
111111
- `UserService` - User accounts, emails, verification
112112
- `AppService` - Application management, credentials, connections
113113
- `TokenService` - JWT token lifecycle (sessions, vault tokens, signing keys)
114+
- `InvitationService` - Organization invitation lifecycle
114115
- `EventsService` - Audit event queries and ingestion
115116
- `HealthService` - Health checks with dependency probes
116117
- `RaftService` - Node-to-node Raft RPCs
@@ -123,7 +124,7 @@ Generated protobuf code and domain type conversions.
123124
**Key modules:**
124125

125126
- `generated/` - Auto-generated from `proto/ledger/v1/ledger.proto`
126-
- `convert.rs` - `From`/`TryFrom` conversions between proto and domain types
127+
- `convert/` - `From`/`TryFrom` conversions between proto and domain types
127128

128129
### `inferadb-ledger-server`
129130

0 commit comments

Comments
 (0)