Skip to content

Commit a8e9f6e

Browse files
committed
docs: incorporate PR feedback into SDK specification
- Clarify side-effects rule: allowed if they don't affect operation order - Change async integration from MUST to SHOULD - Replace ASCII state diagrams with mermaid flowcharts in Section 4 - Remove duplicate Appendix C, renumber appendices - Bump version to 1.2 Signed-off-by: Michael Gasch <[email protected]>
1 parent ea5d479 commit a8e9f6e

File tree

1 file changed

+92
-125
lines changed

1 file changed

+92
-125
lines changed

LANGUAGE_SDK_SPECIFICATION.md

Lines changed: 92 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# AWS Lambda Durable Functions Language SDK Specification
22

3-
**Version:** 1.1
4-
**Date:** December 9, 2025
3+
**Version:** 1.2
4+
**Date:** December 20, 2025
55
**Status:** Reviewing
66

77
## 1. Introduction
@@ -67,9 +67,11 @@ For correct replay behavior, **user code MUST be deterministic**:
6767

6868
1. Non-durable code (code outside operations) MUST execute identically on each replay
6969
2. User code MUST NOT use non-deterministic values (e.g., `Date.now()`, `Math.random()`) outside durable operations
70-
3. User code MUST NOT perform side effects (e.g., API calls, database writes) outside durable operations
70+
3. User code MUST NOT perform side effects (e.g., API calls, database writes) outside durable operations affecting operation order
7171
4. Operation order MUST remain consistent across replays
7272

73+
**Note:** User code MAY perform side effects outside durable operations as long as those side effects do not influence the order or execution of durable operations. For example, logging is acceptable, but using an API response to conditionally skip an operation is not.
74+
7375
**SDK Responsibilities for Determinism:**
7476

7577
The SDK MUST:
@@ -296,6 +298,17 @@ The SDK MUST:
296298
- `SUCCEED`: Complete execution successfully with a result
297299
- `FAIL`: Complete execution with an error
298300

301+
#### 4.3.4 State Transitions
302+
303+
```mermaid
304+
flowchart LR
305+
New[Customer calls operation] --> START
306+
START --> |Started| SUCCEED
307+
SUCCEED --> |Succeeded| Success[Completes successfully]
308+
START --> |Started| FAIL
309+
FAIL --> |Failed| Failure[Completes with error]
310+
```
311+
299312
### 4.4 STEP Operation
300313

301314
#### 4.4.1 Purpose
@@ -322,12 +335,18 @@ The SDK MUST:
322335

323336
#### 4.4.4 State Transitions
324337

325-
```
326-
[New] → START → STARTED → SUCCEED → SUCCEEDED [Done]
327-
328-
RETRY → PENDING → (delay) → READY → START
329-
330-
FAIL → FAILED [Done]
338+
```mermaid
339+
flowchart LR
340+
New[Customer calls ctx.step] --> START
341+
START --> |Started| SUCCEED
342+
SUCCEED --> |Succeeded| Success[ctx.step completes with result]
343+
344+
START --> |Started| RETRY
345+
RETRY --> |Pending| Delay[Wait for backoff period]
346+
Delay --> |Ready| START
347+
348+
START --> |Started| FAIL
349+
FAIL --> |Failed| Failed[ctx.step completes with error]
331350
```
332351

333352
#### 4.4.5 Retry Mechanism
@@ -367,10 +386,13 @@ The SDK MUST:
367386

368387
#### 4.5.4 State Transitions
369388

370-
```
371-
[New] → START → STARTED → (time passes) → SUCCEEDED [Done]
372-
373-
CANCEL → CANCELLED [Done]
389+
```mermaid
390+
flowchart LR
391+
New[Customer calls ctx.wait] --> START
392+
START --> |Started| Delay{Wait}
393+
Delay --> |Succeeded| Success[ctx.wait completes]
394+
Delay --> CANCEL
395+
CANCEL --> |Cancelled| Cancelled[ctx.wait completes]
374396
```
375397

376398
### 4.6 CALLBACK Operation
@@ -396,11 +418,25 @@ The SDK MUST:
396418

397419
#### 4.6.4 State Transitions
398420

399-
```
400-
[New] → START → STARTED → (external success) → SUCCEEDED [Done]
401-
402-
└→ (external failure) → FAILED [Done]
403-
└→ (timeout) → TIMED_OUT [Done]
421+
```mermaid
422+
flowchart LR
423+
New[Customer calls ctx.createCallback] --> START
424+
START --> |Started| Delay{Wait}
425+
SUCCEED --> |Succeeded| Success[ctx.createCallback completes successfully]
426+
FAIL --> |Failed| Failure[ctx.createCallback completes with error]
427+
TIMEOUT --> |TimedOut| Failure
428+
429+
Delay .-> SendDurableExecutionCallbackSuccess
430+
Delay .-> SendDurableExecutionCallbackFailure
431+
Delay .-> TIMEOUT
432+
433+
SendDurableExecutionCallbackSuccess --> SUCCEED
434+
SendDurableExecutionCallbackFailure --> FAIL
435+
436+
subgraph External System
437+
SendDurableExecutionCallbackSuccess
438+
SendDurableExecutionCallbackFailure
439+
end
404440
```
405441

406442
#### 4.6.5 Configuration Options
@@ -434,12 +470,26 @@ The SDK MUST:
434470

435471
#### 4.7.4 State Transitions
436472

437-
```
438-
[New] → START → STARTED → (invoke completes) → SUCCEEDED [Done]
439-
440-
└→ (invoke fails) → FAILED [Done]
441-
└→ (invoke timeout) → TIMED_OUT [Done]
442-
└→ (invoke stopped) → STOPPED [Done]
473+
```mermaid
474+
flowchart LR
475+
New[Customer calls ctx.invoke] --> START
476+
START --> |Started| Delay{Wait}
477+
SUCCEED --> |Succeeded| Success[ctx.invoke completes successfully]
478+
FAIL --> |Failed| Failure[ctx.invoke completes with error]
479+
TIMEOUT --> |TimedOut| Failure
480+
STOP[StopDurableExecution] --> |Stopped| Failure
481+
482+
Delay .-> External
483+
Delay .-> TIMEOUT
484+
485+
subgraph External System
486+
External@{ shape: fork }
487+
External .-> Invoked[Invoked Function]
488+
External .-> STOP
489+
end
490+
491+
Invoked .-> SUCCEED
492+
Invoked .-> FAIL
443493
```
444494

445495
#### 4.7.5 Configuration Options
@@ -476,10 +526,13 @@ The SDK MUST:
476526

477527
#### 4.8.4 State Transitions
478528

479-
```
480-
[New] → START → STARTED → SUCCEED → SUCCEEDED [Done]
481-
482-
└→ FAIL → FAILED [Done]
529+
```mermaid
530+
flowchart LR
531+
New[Customer calls operation] --> START
532+
START --> |Started| SUCCEED
533+
SUCCEED --> |Succeeded| Success[Completes successfully]
534+
START --> |Started| FAIL
535+
FAIL --> |Failed| Failure[Completes with error]
483536
```
484537

485538
#### 4.8.5 ReplayChildren Option
@@ -863,14 +916,16 @@ The SDK SHOULD provide type-safe interfaces where the language supports it:
863916

864917
### 11.2 Async Patterns
865918

866-
The SDK MUST integrate with the language's asynchronous programming model:
919+
The SDK SHOULD integrate with the language's asynchronous programming model where appropriate:
867920

868921
- JavaScript/TypeScript: Promises
869922
- Python: asyncio/coroutines
870923
- Go: goroutines/channels
871924
- Java: CompletableFuture, virtual threads (Java 21)
872925
- Rust: async/await
873926

927+
**Note:** Integration with async primitives is not mandatory. SDKs MAY provide synchronous-only implementations or alternative concurrency models based on language idioms and use case requirements.
928+
874929
### 11.3 Error Handling Idioms
875930

876931
The SDK SHOULD use idiomatic error handling:
@@ -1284,101 +1339,7 @@ except Exception as e:
12841339
return await context.step("fallback", lambda: fallback_operation())
12851340
```
12861341

1287-
## Appendix C: Operation State Diagrams
1288-
1289-
### C.1 STEP Operation
1290-
1291-
```
1292-
┌───────┐
1293-
│ New │
1294-
└───┬───┘
1295-
│ START action
1296-
1297-
┌─────────┐
1298-
│ STARTED │◄───────────────────────────────────────┐
1299-
└────┬────┘ │
1300-
│ │
1301-
├─ SUCCEED ──► SUCCEEDED (terminal) │
1302-
│ │
1303-
├─ FAIL ─────► FAILED (terminal) │
1304-
│ │
1305-
└─ RETRY ───► PENDING ──► (delay) ──► READY ──┘
1306-
(START action)
1307-
```
1308-
1309-
### C.2 WAIT Operation
1310-
1311-
```
1312-
┌───────┐
1313-
│ New │
1314-
└───┬───┘
1315-
│ START action
1316-
1317-
┌─────────┐
1318-
│ STARTED │──────► (time elapses) ──► SUCCEEDED (terminal)
1319-
└────┬────┘
1320-
1321-
└─ CANCEL action ──► CANCELLED (terminal)
1322-
```
1323-
1324-
### C.3 CALLBACK Operation
1325-
1326-
```
1327-
┌───────┐
1328-
│ New │
1329-
└───┬───┘
1330-
│ START action
1331-
1332-
┌─────────┐
1333-
│ STARTED │──────┬──► SendCallbackSuccess ──► SUCCEEDED (terminal)
1334-
└─────────┘ │
1335-
├──► SendCallbackFailure ──► FAILED (terminal)
1336-
1337-
└──► Timeout/HeartbeatTimeout ──► TIMED_OUT (terminal)
1338-
```
1339-
1340-
### C.4 CHAINED_INVOKE Operation
1341-
1342-
```
1343-
┌───────┐
1344-
│ New │
1345-
└───┬───┘
1346-
│ START action
1347-
1348-
┌─────────┐
1349-
│ STARTED │──────┬──► Invoke succeeds ──► SUCCEEDED (terminal)
1350-
└─────────┘ │
1351-
├──► Invoke fails ──► FAILED (terminal)
1352-
1353-
├──► Invoke timeout ──► TIMED_OUT (terminal)
1354-
1355-
└──► Invoke stopped ──► STOPPED (terminal)
1356-
```
1357-
1358-
### C.5 CONTEXT Operation
1359-
1360-
```
1361-
┌───────┐
1362-
│ New │
1363-
└───┬───┘
1364-
│ START action
1365-
1366-
┌─────────┐
1367-
│ STARTED │──────┬──► SUCCEED action ──► SUCCEEDED (terminal)
1368-
└─────────┘ │
1369-
└──► FAIL action ──► FAILED (terminal)
1370-
```
1371-
1372-
### C.6 EXECUTION Operation
1373-
1374-
```
1375-
┌─────────┐
1376-
│ STARTED │──────┬──► SUCCEED action (or return SUCCEEDED) ──► SUCCEEDED (terminal)
1377-
└─────────┘ │
1378-
└──► FAIL action (or return FAILED) ──► FAILED (terminal)
1379-
```
1380-
1381-
## Appendix D: Glossary
1342+
## Appendix C: Glossary
13821343

13831344
**Checkpoint**: The act of persisting operation state to the durable execution service, enabling resume after interruption.
13841345

@@ -1402,7 +1363,13 @@ except Exception as e:
14021363

14031364
**Completion Policy**: Rules determining when a batch operation (map/parallel) should stop based on success/failure counts.
14041365

1405-
## Appendix E: Change Log
1366+
## Appendix D: Change Log
1367+
1368+
### Version 1.2 (December 20, 2025)
1369+
1370+
- Clarified side-effects rule: allowed if they don't affect operation order (Section 2.5)
1371+
- Changed async integration from MUST to SHOULD (Section 11.2)
1372+
- Moved mermaid state diagrams into Section 4 operation definitions, removed Appendix C
14061373

14071374
### Version 1.1 (December 9, 2025)
14081375

0 commit comments

Comments
 (0)