Frontier
Internals
You can use Stone.js without any of this, but seeing how a request actually flows makes the rest obvious. There are two timelines: setup, which runs once, and the per-event path, which runs for every cause. Both are pipelines over the same three primitives.
#Setup, once
At startup the CLI has already discovered your modules and their metadata. The BlueprintBuilder runs a pipeline of blueprint middleware that reads that metadata (and your define* modules) and composes the Blueprint. It is then frozen. The long-lived adapter is created and starts listening.
Setup is a pipeline over the manifest. It runs once, and freezes.
#The collapse, at run time
Between setup and the first event sits one decision: which context. When StoneFactory.run() executes, it resolves a single adapter from the stack. The one whose alias matches the current platform, else the one marked default, else the only one present. That resolution is the contextual collapse, and it happens when the app runs, never at build or deploy. The same artifact, started on Node, collapses to the Node adapter; started on Lambda, to the Lambda one.
Deploy places the artifact. Running is what chooses the context.
#Per event
| Step | Type | Description |
|---|---|---|
| 1. Capture | adapter | The adapter receives the platform’s raw cause. |
| 2. Normalise | adapter | It builds an IncomingEvent, the intention. |
| 3. Scope | kernel | The kernel creates a fresh container and resolves handlers/services into it. |
| 4. Pipeline | kernel | The event flows through the middleware pipeline to the resolved handler. |
| 5. Handle | domain | Your handler runs and returns a value (or throws). |
| 6. Resolve | kernel | The result (or a mapped error) becomes a response. |
| 7. Emit | adapter | The adapter turns the response into a native effect; the container is discarded. |
#Where the primitives show through
- Pipeline: both the build phase (step over the manifest) and the middleware chain (step over the event).
- Container: the per-event scope created at step 3 and discarded at step 7.
- Config: the frozen Blueprint every step reads.
#Resolution details
Handlers and services are resolved by alias, not by type reflection, because Stone.js uses TC39 metadata, not reflect-metadata. A constructor receives one object of resolved bindings and destructures the names it wants. Singletons are cached in the current container, so they live for one event.