Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8dd3f81
feat(examples): add MinimalLambda.Example.EventProcessor project
j-d-ha Oct 26, 2026
ddf9a80
docs(design): add proposal for event processor API
j-d-ha Oct 27, 2026
de5e472
feat(event-processor): prototype handler overloads
j-d-ha Oct 27, 2026
5c89497
feat(event-processor): add MapEventHandler API, generator, and runtime
j-d-ha Oct 28, 2026
0289105
test(event-processor): cover runtime, generation, and package consumers
j-d-ha Oct 28, 2026
1e53553
docs(event-processor): document batch processing and update skills
j-d-ha Oct 28, 2026
2f919bc
feat(examples): add event processor sample with Native AOT coverage
j-d-ha Oct 28, 2026
9c5964e
test(event-processor): pin method-group and union-result binding fail…
j-d-ha Oct 28, 2026
faa2079
test(event-processor): cover concurrency caps, DI inputs, and provide…
j-d-ha Oct 28, 2026
4a950ae
test(event-processor): cover split, family, control, and coexistence …
j-d-ha Oct 28, 2026
85df7d6
test(event-processor): cover options, disposal, and stop boundaries
j-d-ha Oct 28, 2026
31c8d9e
test(event-processor): verify cancellation callbacks and fault preced…
j-d-ha Oct 28, 2026
d6c0213
test(event-processor): verify source identity, FIFO stop, and stream …
j-d-ha Oct 28, 2026
cdf6b7e
fix(source-generators): correct event bindings
j-d-ha Oct 29, 2026
4fd45cf
refactor: move event processing into library code
j-d-ha Oct 29, 2026
22ee3fa
refactor: simplify event processor internals
j-d-ha Oct 29, 2026
c4f3c31
refactor: streamline event processor execution
j-d-ha Oct 29, 2026
6cbf02b
refactor: extract optional event processing
j-d-ha Oct 31, 2026
5e823b1
refactor: reconcile event processor updates
j-d-ha Oct 31, 2026
cd1bb49
fix: preserve event handler default values
j-d-ha Oct 31, 2026
7f468a9
feat: add event error handling without responses
j-d-ha Nov 1, 2026
f3f303c
docs: align event processing docs and skill
j-d-ha Nov 1, 2026
cc1f473
Merge branch 'main' into feat/event-processor
j-d-ha Nov 1, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Core packages version synchronously:
- `MinimalLambda`
- `MinimalLambda.Abstractions`
- `MinimalLambda.DurableExecution`
- `MinimalLambda.EventProcessing`
- `MinimalLambda.Envelopes`
- `MinimalLambda.Envelopes.Alb`
- `MinimalLambda.Envelopes.ApiGateway`
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<PackageVersion Include="Amazon.Lambda.KinesisEvents" Version="4.0.0" />
<PackageVersion Include="Amazon.Lambda.KinesisFirehoseEvents" Version="3.0.0" />
<PackageVersion Include="Amazon.Lambda.RuntimeSupport" Version="2.3.0" />
<PackageVersion Include="Amazon.Lambda.S3Events" Version="4.0.0" />
<PackageVersion Include="Amazon.Lambda.Serialization.SystemTextJson" Version="3.0.1" />
<PackageVersion Include="Amazon.Lambda.TestUtilities" Version="4.2.0" />
<PackageVersion Include="Autofac.Extensions.DependencyInjection" Version="11.0.2" />
Expand Down
3 changes: 2 additions & 1 deletion MinimalLambda.Packages.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"src/MinimalLambda.OpenTelemetry/MinimalLambda.OpenTelemetry.csproj",
"src/MinimalLambda.Templates/MinimalLambda.Templates.csproj",
"src/MinimalLambda.Testing/MinimalLambda.Testing.csproj",
"src/MinimalLambda/MinimalLambda.csproj"
"src/MinimalLambda/MinimalLambda.csproj",
"src/MinimalLambda.EventProcessing/MinimalLambda.EventProcessing.csproj"
]
}
}
44 changes: 43 additions & 1 deletion MinimalLambda.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@


Microsoft Visual Studio Solution File, Format Version 12.00
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}"
EndProject
Expand Down Expand Up @@ -105,6 +105,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Testing.UnitT
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Example.DurableExecution", "examples\MinimalLambda.Example.DurableExecution\MinimalLambda.Example.DurableExecution.csproj", "{998085AA-AEC6-45D9-9E51-26F09BD5138C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Example.EventProcessor", "examples\MinimalLambda.Example.EventProcessor\MinimalLambda.Example.EventProcessor.csproj", "{42070274-45C6-4939-87D9-AD7E70F419F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.Testing.UnitTests.EventProcessorLambda", "tests\MinimalLambda.Testing.UnitTests\Lambdas\MinimalLambda.Testing.UnitTests.EventProcessorLambda\MinimalLambda.Testing.UnitTests.EventProcessorLambda.csproj", "{5BFFA5F3-9A74-4574-80B5-27968203E2F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.EventProcessing", "src\MinimalLambda.EventProcessing\MinimalLambda.EventProcessing.csproj", "{3D7592CE-9F18-4967-8F11-34C99ADBC454}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinimalLambda.EventProcessing.UnitTests", "tests\MinimalLambda.EventProcessing.UnitTests\MinimalLambda.EventProcessing.UnitTests.csproj", "{CE4F650D-C942-4695-9CC3-93C9A6BFF78D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -547,6 +555,38 @@ Global
{998085AA-AEC6-45D9-9E51-26F09BD5138C}.Release|x64.Build.0 = Release|Any CPU
{998085AA-AEC6-45D9-9E51-26F09BD5138C}.Release|x86.ActiveCfg = Release|Any CPU
{998085AA-AEC6-45D9-9E51-26F09BD5138C}.Release|x86.Build.0 = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|x64.ActiveCfg = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|x64.Build.0 = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Debug|x86.Build.0 = Debug|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|Any CPU.Build.0 = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|x64.ActiveCfg = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|x64.Build.0 = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|x86.ActiveCfg = Release|Any CPU
{42070274-45C6-4939-87D9-AD7E70F419F9}.Release|x86.Build.0 = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|x64.ActiveCfg = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|x64.Build.0 = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Debug|x86.Build.0 = Debug|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|Any CPU.Build.0 = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|x64.ActiveCfg = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|x64.Build.0 = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|x86.ActiveCfg = Release|Any CPU
{5BFFA5F3-9A74-4574-80B5-27968203E2F9}.Release|x86.Build.0 = Release|Any CPU
{3D7592CE-9F18-4967-8F11-34C99ADBC454}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D7592CE-9F18-4967-8F11-34C99ADBC454}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D7592CE-9F18-4967-8F11-34C99ADBC454}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D7592CE-9F18-4967-8F11-34C99ADBC454}.Release|Any CPU.Build.0 = Release|Any CPU
{CE4F650D-C942-4695-9CC3-93C9A6BFF78D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE4F650D-C942-4695-9CC3-93C9A6BFF78D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE4F650D-C942-4695-9CC3-93C9A6BFF78D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE4F650D-C942-4695-9CC3-93C9A6BFF78D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -591,5 +631,7 @@ Global
{A5852451-D1C2-4270-834C-BDCF03F4A9AA} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
{189636EE-6C05-46DB-8AEB-256F2617025C} = {D9109C8A-AFA8-49C8-A19C-381500902B4D}
{998085AA-AEC6-45D9-9E51-26F09BD5138C} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
{42070274-45C6-4939-87D9-AD7E70F419F9} = {B36A84DF-456D-A817-6EDD-3EC3E7F6E11F}
{5BFFA5F3-9A74-4574-80B5-27968203E2F9} = {D9109C8A-AFA8-49C8-A19C-381500902B4D}
EndGlobalSection
EndGlobal
107 changes: 107 additions & 0 deletions designs/event-processing-contracts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Event-processing contracts

Accepted for ml-ny2.1 on 2026-10-30. The epic's locked decisions are unchanged.

## Ownership and delivery

`MinimalLambda.EventProcessing` depends on the matching core version. Public processing types
use `MinimalLambda.EventProcessing`; interception extensions remain in `MinimalLambda.Builder`
for discoverability. The existing core-delivered generator recognizes the optional assembly.
The optional package ships no second analyzer. Core and general abstractions contain no processing APIs,
options registrations, or processing features. All four core TFMs are supported.

## Outcomes

`EventItemOutcome<TItem, TValue>` is immutable and contains `Index`, `Item`, `Status`,
`HasValue`, `Value`, and `Exception`. Status is `Succeeded`, `MappedError`, `Skipped`, or
`Cancelled`. Index is zero-based source position. Equal or identical items remain distinct entries.
`HasValue` distinguishes a genuine null contribution from no contribution. `Exception` is set
only for mapped errors. A handler returning a domain failure is still `Succeeded`; only the
application understands domain success. Invocation failure produces no response or outcome callback.

Split output is materialized once before handlers start. Null enumerables fail the invocation;
nullable items and values are retained. Empty input calls the response builder once with an empty list.
A response builder may return null when its response type allows it; core serializes that typed null normally.
The builder receives `IReadOnlyList<EventItemOutcome<TItem, TValue>>` in source order after all
admitted work and cleanup finish. It may enumerate repeatedly. Unstarted items are `Skipped`;
admitted work interrupted by processing cancellation is `Cancelled`. Successful work remains successful
even if cancellation was requested concurrently. Application code owns acknowledgement and retry.

## Callback families

Each mapping takes `Func<TEvent, ILambdaInvocationContext, IEnumerable<TItem>> split` and an
item-first handler returning `Task` or `Task<TResult>`. Up to ten additional parameters bind
services or framework values. The six compiler-selected families are:

| Family | Handler | Mapper | Outcome value |
| --- | --- | --- | --- |
| No response | Task | absent | no response callback |
| No response with errors | Task | synchronous action | no response callback |
| Source item | Task | absent | source item on success |
| Failures only | Task | TFailure | value only on mapped errors |
| Results | Task<TResult> | absent | handler result |
| Results with errors | Task<TResult> | TResult | handler or mapper result |

Response callbacks are synchronous `Func<IReadOnlyList<EventItemOutcome<TItem, TValue>>,
ILambdaInvocationContext, TResponse>`. Error callbacks are synchronous
`Func<TItem, Exception, IEventProcessingContext, TValue>` or, without a response,
`Action<TItem, Exception, IEventProcessingContext>`. The action handles an error by returning normally;
throwing fails the invocation. Async actions, including async void, are rejected. Awaitable mapper contributions,
nested handler task results, and awaitable responses are rejected with an actionable generator
diagnostic. Async error mappers are deliberately unsupported; put async recovery in the handler.
Required callbacks cannot be null. A null task from a handler is an item error eligible for mapping.

Example response policies:

```csharp
// Source-item family
createResponse: (outcomes, _) => outcomes.Where(x => x.Status != EventItemStatus.Succeeded)
.Select(x => x.Item.Id).ToArray()
// Failures-only and result families can inspect HasValue before reading Value.
// No-response handlers may omit onError or supply a synchronous action.
```

## Binding, errors, and lifetime

Each item gets an asynchronous scope, alive through argument resolution, execution, and error mapping.
Scope creation is an invocation failure because no item provider exists. DI resolution, synchronous
handler throws, asynchronous faults, and null handler tasks reach onError with the original exception.
Absent or throwing mappers fail the invocation; mapper failures are never recursively mapped.
Scope disposal failures always fail the invocation. Drain admitted work and cleanup before propagating errors;
preserve the first fatal exception and log additional failures. Invocation cancellation takes precedence.
Optional nullable services retain null fallback. Declared optional defaults are honored, including keyed
and value-type defaults; generated resolution distinguishes missing services from default-valued services.

StopProcessing stops admission without cancelling admitted items. CancelProcessing also cancels the
processing token. Invocation cancellation suppresses response construction through cleanup, including
cancellation callback draining. Check immediately before and after the synchronous response builder;
cancellation during construction suppresses storing its response. Once stored, core owns serialization.

## Factory and generated output

`EventHandlerFactory.Create` accepts the built `IServiceProvider`, split, the typed wrapper,
optional mapper, and optional response callback. Its six overloads mirror the families above.
Wrappers are `Func<TItem, IServiceProvider, IEventProcessingContext, Task>` or the corresponding
`Task<TResult>` shape. The factory validates callbacks and effective options at mapping time,
resolves scope/logging dependencies, and constructs an internal processor once. No required
AddEventProcessing call or processor DI registration exists. Configure<EventHandlerOptions> is optional.
Configuration failures propagate. Options are copied at mapping time.

```csharp
ArgumentNullException.ThrowIfNull(handle);
var terminal = EventHandlerFactory.Create<Batch, Item, int, Response>(
application.Services, split, HandleItem, onError, createResponse);
application.Handle(terminal); // Reject duplicates before changing provider properties.
// Same conditional provider registration as MapHandler, for Batch and Response only.
return application;

Task<int> HandleItem(Item item, IServiceProvider itemServices, IEventProcessingContext processing)
{
var importer = itemServices.GetRequiredKeyedService<Importer>("primary");
return handle(item, importer, processing.CancellationToken);
}
```

The runtime invokes and awaits HandleItem inside item-error handling. There is no generated binder,
BoundArguments, worker loop, or cancellation state machine. The splitter determines Batch; the final
response callback determines Response. Core serialization and middleware remain unchanged.
25 changes: 25 additions & 0 deletions designs/event-processor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Event-processing design

The accepted API and error/cancellation policies are in [event-processing-contracts.md](event-processing-contracts.md).
This replaces the earlier unshipped design. Beads epic `ml-ny2` tracks implementation and validation.

`MinimalLambda.EventProcessing` owns public mapping contracts, options, outcomes, the generated-code
factory, and internal scheduling/runtime code. It depends on matching core; core has no processing
services or APIs. The existing core analyzer recognizes the optional package and emits one item wrapper.

The interceptor calls the public factory with application services and typed callbacks, registers the
returned terminal using `application.Handle`, then conditionally registers normal event/final-response
providers. It rejects duplicate mappings before mutating providers. The splitter selects the full event
type. Intermediate item results never select the response provider.

The factory validates effective options at mapping time, resolves scope/logging dependencies, and
constructs the internal processor once. Each invocation gets fresh state. Each admitted item gets an
async scope alive through argument resolution, handler execution, error mapping, and awaited disposal.
Service resolution and handler errors reach onError; creation/disposal failures fail the invocation.

Response callbacks receive immutable ordered outcomes for every source position. Skipped and cancelled
items remain visible. Application code decides acknowledgements and retries. Invocation cancellation
remains effective through cleanup and is checked before constructing and storing the response.

Core serialization, features, envelopes, and middleware remain unchanged. There is no processing
feature, required service-registration call, generated worker algorithm, or separate binding stage.
Loading
Loading