aws-lambda-dotnet / Amazon.Lambda.DurableExecution
CLAUDE.md1.7k starsChanged 7 months agoApache-2.0View on GitHub
Amazon.Lambda.DurableExecution is the .NET SDK (GA, 1.x) for resilient, long-running AWS Lambda workflows that checkpoint progress after each step and resume after failures or waits. A workflow can run for up to ~1 year (the WAIT cap is 31,622,400 seconds) and is only billed for active compute. The SDK is client-side glue: the durable execution service (part of Lambda) owns the checkpoint store, fires timers, and re-invokes the function; this library re-derives in-memory workflow position from the checkpoint history the…
Trending
Quiet since July.about the whole repository
Who's talking about aws/aws-lambda-dotnet
- aws/integrations-on-dotnet-aspire-for-aws“.NET Aspire Lambda Local Development Feature Tracker”GitHub · Jan 28, 2025 · 8 reactions
- aws-powertools/powertools-lambda-dotnet“Feature request: Support using with Amazon.Lambda.AspNetCoreServer.Hosting”GitHub · Jul 24, 2023 · 6 reactions
- getsentry/sentry-dotnet“Events are not sent in AWS Lambda ”GitHub · Oct 26, 2018 · 5 reactions
- aws/aws-extensions-for-dotnet-cli“Template Substitions are not supported for YAML”GitHub · Feb 2, 2018 · 4 reactions
- aws/aws-extensions-for-dotnet-cli“Re-enable JSON comment support in the config file”GitHub · Dec 16, 2025 · 3 reactions
The biggest 5 of 18 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 18
Talked about on GitHub (18 times).
On GitHub · 18
- Jan 28, 2025.NET Aspire Lambda Local Development Feature Tracker — aws/integrations-on-dotnet-aspire-for-aws8 reactions · 7 comments
- Jul 24, 2023Feature request: Support using with Amazon.Lambda.AspNetCoreServer.Hosting — aws-powertools/powertools-lambda-dotnet6 reactions · 7 comments
- Oct 26, 2018Events are not sent in AWS Lambda — getsentry/sentry-dotnet5 reactions · 28 comments
- Feb 2, 2018Template Substitions are not supported for YAML — aws/aws-extensions-for-dotnet-cli4 reactions · 4 comments
- Dec 16, 2025Re-enable JSON comment support in the config file — aws/aws-extensions-for-dotnet-cli3 reactions
13 more on GitHub
- Jul 17, 2025Static Assets are now included when packing a Blazor Web App — dotnet/sdk3 reactions · 6 comments
- Jan 19, 2023[release/7.0] Target lower glibc for Linux arm64 — dotnet/runtime3 reactions · 5 comments
- Nov 21, 2020Parallel build fails for .Net Core project — aws/aws-lambda-builders3 reactions · 4 comments
- Oct 31, 2019dotnet global tools failing to uninstall or update on 2.1-sdk-alpine — dotnet/sdk3 reactions · 8 comments
- Mar 20, 2018Razor pages and webapi — Azure/azure-functions-host3 reactions · 8 comments
- Sep 8, 2022dotnet tools use wrong architecture of libhostfxr.dylib on Mac M1 — dotnet/sdk2 reactions · 9 comments
- Jul 18, 2026Aspire: support AWS Lambda — GustavEikaas/easy-dotnet.nvim1 reaction · 1 comment
- May 20, 2024Certain lambda layers result in manifest error — aws/aws-extensions-for-dotnet-cli1 reaction · 4 comments
- Feb 2, 2024Improve cold starts on AL2023 — maxday/lambda-perf1 reaction · 1 comment
- May 10, 2023[CSharp] AWS Lambda Modelling — github/codeql1 reaction · 12 comments
- Apr 14, 2023Rider 2023 / aws.toolkit ver1.65-231 - Timeout while waiting for debugger to connect — aws/aws-toolkit-jetbrains1 reaction · 1 comment
- Apr 11, 2022'dotnet lambda publish-layer' fails in .NET 6 with ‘--enable-package-optimization true’ — aws/aws-extensions-for-dotnet-cli1 reaction · 5 comments
- Sep 30, 2020sam build dotnet core sends normal output to STDERR — aws/aws-lambda-builders1 reaction · 4 comments
In this repositoryOne other file it gives its agents.
- new-event-sourceSkill
The file
We split this CLAUDE.md into the rules it gives an agent
2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 84
When an op must suspend (wait timer, scheduled retry, pending callback/invoke) it calls Termination.SuspendAndAwait<T>(), which trips a …
- Very specific: line 152
When adding error-mapping logic, handle *both* the fresh path (InnerException is the live exception) and the replay path (InnerException is …
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What this is
Amazon.Lambda.DurableExecution is the .NET SDK (GA, 1.x) for resilient, long-running AWS Lambda
workflows that checkpoint progress after each step and resume after failures or waits. A workflow can run
for up to ~1 year (the WAIT cap is 31,622,400 seconds) and is only billed for active compute. The SDK is
client-side glue: the durable execution service (part of Lambda) owns the checkpoint store, fires timers,
and re-invokes the function; this library re-derives in-memory workflow position from the checkpoint history
the service sends on each invocation. See sibling SDKs (Python/JS/Java) listed in README.md for the shared
model — this SDK deliberately mirrors their semantics.
Build & test
Targets net8.0;net10.0 (DefaultPackageTargets in buildtools/common.props). TreatWarningsAsErrors is on
everywhere, and the main library is IsTrimmable with the trim analyzer enabled — keep new code AOT/trim-clean.
# Build the library (run from this directory)
dotnet build
# Unit tests (fast, no AWS). Project: Libraries/test/Amazon.Lambda.DurableExecution.Tests
dotnet test ../../test/Amazon.Lambda.DurableExecution.Tests/Amazon.Lambda.DurableExecution.Tests.csproj
# A single test
dotnet test ../../test/Amazon.Lambda.DurableExecution.Tests/Amazon.Lambda.DurableExecution.Tests.csproj \
--filter "FullyQualifiedName~StepOperationTests"
# Coverage report (requires reportgenerator tool)
../../test/Amazon.Lambda.DurableExecution.Tests/coverage.shUnit tests reach internal types via InternalsVisibleTo (declared in the .csproj). They use
Amazon.Lambda.TestUtilities (TestLambdaContext) and the real SourceGeneratorLambdaJsonSerializer —
set TestLambdaContext.Serializer so LambdaSerializerHelper.GetRequired finds one.
Integration tests (expensive, real AWS)
Libraries/test/Amazon.Lambda.DurableExecution.IntegrationTests deploys real Lambdas. Each test builds a
TestFunctions/<X>/ project with dotnet publish (framework-dependent, linux-x64), zips the publish
output, and deploys it as a zip package on the managed dotnet10 runtime (executable model,
Handler=bootstrap) — no Docker or ECR. DurableFunctionDeployment creates an IAM role + Lambda (with
DurableConfig and JSON LoggingConfig), invokes it, and tears everything down on dispose.
Requires only the .NET SDK + AWS creds (us-east-1); no Docker. Slow, but no container build. Every behavior
in docs/ should have a paired integration test under that project. Prefix AWS commands with
unset AWS_PROFILE to use [default] creds.
Run integration tests against net10.0. The project multi-targets net8.0;net10.0; dotnet test
without a framework spins up one testhost per TFW and runs them concurrently, which races two processes on
the same TestFunctions/<X>/ build dir. Pin the framework:
dotnet test ../../test/Amazon.Lambda.DurableExecution.IntegrationTests/Amazon.Lambda.DurableExecution.IntegrationTests.csproj \
-f net10.0 --filter "FullyQualifiedName~MultipleStepsTest"Architecture: the replay model
This is the part you must understand before changing anything. Read these together:
DurableFunction.cs, DurableExecutionHandler.cs, DurableContext.cs, Internal/DurableOperation.cs,
Internal/ExecutionState.cs, Internal/OperationIdGenerator.cs, Internal/TerminationManager.cs.
Entry point. The user's Lambda handler delegates to DurableFunction.WrapAsync<TInput,TOutput>, which:
hydrates ExecutionState from invocationInput.InitialExecutionState (paging the service via NextMarker),
extracts the user payload from the EXECUTION-type op, builds a CheckpointBatcher + DurableContext, runs
the workflow through DurableExecutionHandler.RunAsync, drains checkpoints, and maps the result to a
DurableExecutionInvocationOutput with status Succeeded / Failed / Pending.
Each operation runs the same workflow code every invocation. There is no persisted program counter.
On re-invocation the user function executes from the top again; each durable call (StepAsync, WaitAsync,
etc.) looks up its own checkpoint and either replays the cached result or runs fresh. This is why workflow
code must be deterministic — same operations, same order, same names across deployments.
Deterministic operation IDs (OperationIdGenerator). Each durable call gets an ID = SHA-256 of
"<parentPrefix>-<counter>", where the counter is per-context and pre-incremented. The same workflow position
yields the same opaque ID across replays, so a checkpoint correlates to a call by position, not by name —
renaming a step does not break replay (the human name rides separately on OperationUpdate.Name).
Reordering or adding/removing calls does break it. ValidateReplayConsistency enforces this and throws
NonDeterministicExecutionException on type/name drift.
Suspension is implemented by never completing a Task (TerminationManager + DurableExecutionHandler).
When an op must suspend (wait timer, scheduled retry, pending callback/invoke) it calls
Termination.SuspendAndAwait<T>(), which trips a one-shot signal and returns a Task that never resolves.
RunAsync runs the user code via Task.Run and races it against TerminationTask with Task.WhenAny:
- user task wins → Succeeded (or Failed if it threw)
- termination wins → Pending; the abandoned user task is GC'd, checkpoints flush, the service fires the timer and re-invokes. On replay the suspended op sees its now-terminal checkpoint and returns normally.
Operation classes (Internal/*Operation.cs) all extend DurableOperation<TResult>. The base's
ExecuteAsync does: ValidateReplayConsistency → TrackReplay → look up checkpoint → dispatch to
StartAsync (no prior checkpoint) or ReplayAsync (checkpoint exists). StepOperation is the canonical
example — read its class doc comment for the full status decision table (Succeeded→cached, Failed→rethrow,
Pending→re-suspend if retry timer hasn't fired, Started→crash-recovery under AtMostOncePerRetry,
Ready→run next attempt). DurableContext is a thin dispatcher: it allocates the op ID, pulls the serializer
off ILambdaContext.Serializer, constructs the right *Operation, and calls ExecuteAsync.
Checkpointing (CheckpointBatcher). Outbound OperationUpdates (START/SUCCEED/FAIL/RETRY) are enqueued
to a background channel worker that batches and flushes them via LambdaDurableServiceClient (which wraps
the AWSSDK.Lambda Checkpoint/GetExecutionState calls). EnqueueAsync awaits its batch's flush
(sync semantics); fire-and-forget callers (e.g. the START checkpoint under the default
AtLeastOncePerRetry) don't await but must observe the Task's exception. Flush errors become a terminal
error rethrown by the next EnqueueAsync/DrainAsync. DurableFunction.IsTerminalCheckpointError
classifies SDK errors on the final drain: 4xx (except 429 and stale-token) → Failed envelope; 429/5xx/
network → let it escape so Lambda retries the whole invocation.
Replay-mode tracking (ExecutionState). IsReplaying starts true iff any completed non-EXECUTION op
exists; TrackReplay decrements as each is visited and flips to false once the workflow catches up to the
frontier. ReplayAwareLogger uses this to suppress log lines emitted during replay so a 30-step workflow
re-invoked 30 times logs each line once — always use ctx.Logger, never Console.WriteLine.
ExecutionState is lock-guarded because the batcher worker thread and concurrent parallel/map branches all
touch it.
Operations surface (IDurableContext)
StepAsync (checkpointed code + retries), WaitAsync (1s–~1yr timer), RunInChildContextAsync (isolated
sub-workflow checkpointed as one CONTEXT op), CreateCallbackAsync / WaitForCallbackAsync (external
events; WaitForCallback is composed from child-context + callback + submitter step — see
DurableContext.RunWaitForCallback), InvokeAsync (durable-to-durable chained invoke, qualified ARN
required), and ParallelAsync / MapAsync (concurrent branches → IBatchResult<T>).
Nesting (NestingType) matters for parallel/map. Nested (default) gives each branch a full CONTEXT
checkpoint. Flat runs branches in virtual contexts that emit no CONTEXT op — inner ops re-parent to the
parallel/map op via OperationIdGenerator.CreateVirtualChild(operationId, reportedParentId), trading trace
granularity for fewer checkpoints. The idPrefix vs reportedParentId split is the subtle part: inner IDs
always derive from the branch's own op ID (so siblings never collide), but are reported under the nearest
non-virtual ancestor (so they reference a parent that actually exists in the checkpoint store).
Wire format (Operation.cs)
Operation and its *Details types mirror the service envelope JSON exactly ([JsonPropertyName]).
String constants live in OperationTypes (STEP/WAIT/CALLBACK/CHAINED_INVOKE/CONTEXT/EXECUTION),
OperationStatuses (STARTED/SUCCEEDED/FAILED/PENDING/READY/CANCELLED/STOPPED/TIMED_OUT), and
OperationSubTypes (PascalCase finer classifier). Plural type names (OperationTypes, not OperationType)
intentionally avoid collision with AWSSDK.Lambda model enums.
Conventions
- Programming model: both the executable model (
Mainbuilds aLambdaBootstrapwith a handler wrapper and anILambdaSerializer) and the class-library model on the manageddotnet10runtime (a plainHandlermethod, serializer via[assembly: LambdaSerializer(...)], deployed with anAssembly::Type::Methodhandler string) are supported and have integration coverage (ClassLibraryTestTestFunctions/ClassLibraryFunction). The serializer is read offILambdaContext.Serializer(a preview API; the project-wideAWSLAMBDA001suppression in the.csprojis intentional for that reason). All step/result/payload (de)serialization flows through that one registered serializer, so AOT and reflection callers share a single code path — there is no per-callJsonSerializerContextargument.
- Errors: durable exceptions carry
ErrorType/ErrorData/OriginalStackTraceso a failure can be reconstructed on replay when the live exception object is gone.StepException,ChildContextException,CallbackFailedException/CallbackTimeoutException/CallbackSubmitterException,ParallelException,MapException, andNonDeterministicExecutionExceptionall derive fromDurableExecutionException. When adding error-mapping logic, handle both the fresh path (InnerExceptionis the live exception) and the replay path (InnerExceptionis null,ErrorTypecarries the type string) — seeDurableContext.MapWaitForCallbackExceptionfor the pattern. - Public config types (
StepConfig,WaitForCallbackConfig,ParallelConfig,MapConfig,CompletionConfig, etc.) are nullable optional args; resolve to an effective config inside the dispatcher. - Inclusive language is enforced repo-wide (see the user's global rules): no master/slave, whitelist/blacklist.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

