Repository F# setup
open System
open System.IO
open System.Threading
open System.Threading.Tasks
open Axial
open Axial.Console
open Axial.FileSystem
open Axial.Hosting
open Axial.Hosting.Browser
open Axial.Hosting.Node
open Axial.State
open Axial.Telemetry
open Axial.Telemetry.JavaScript

Supplying Platform Services

A root Flow starts with live clock/random/GUID implementations and an Information+ stderr log sink. No platform bundle is required in 'env. Keep authority such as configuration, HTTP, files and process execution in an application record; override runtime values around the flow itself.

Show page setup
open System
open Axial
open Axial
let shouldEqual expected actual =
    if actual <> expected then failwithf "Expected %A but got %A" expected actual
Verified
let startup : Flow<unit, Never, int> =
    flow {
        let! now = Clock.now
        do! Log.info ("Starting port 8080 in " + string now.Year)
        return 8080
    }
Requires & types
Requires: open Axial (packages: Axial)
val startup: Flow<unit,Never,int>

A port decoded from an environment variable with a Reified schema is shown in the configuration guide; this page stays on the runtime values themselves.

Verified
let log = Log.memory ()
startup
|> Flow.withClock (Clock.fromValue (DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero)))
|> Flow.withRandom (Random.seeded 42)
|> Flow.withGuid (Guid.fromValue System.Guid.Empty)
|> Flow.withLogSink log
|> Flow.run ()
|> shouldEqual (Exit.Success 8080)
log.Entries |> Seq.map _.Message |> Seq.toList |> shouldEqual ["Starting port 8080 in 2026"]
Requires & types
Requires: open Axial; open System (packages: Axial)
val log: TestLog

Overrides apply to a subtree and its forks; the outer values are restored afterwards. Flow.mapLogSink decorates an installed sink instead of replacing it. Flow.withTelemetry installs annotation and typed-attribute callbacks; Activity and JavaScript OpenTelemetry adapters compose through them rather than replacing them.

Host logging defaults

Host Installed destination
Generic Host Microsoft logging, category Axial
ASP.NET Core flowEndpoint RequestServices' Microsoft logging factory, category Axial.Endpoint
GenHTTP Runtime default unless EndpointOptions.LogSink is supplied
Node NodeLogging.sink LogLevel.Information, through console.error on stderr
Browser BrowserLogging.sink LogLevel.Information, mapped to console.debug/info/warn/error

HostedAppOptions.LogSink and ASP.NET EndpointOptions.LogSink accept an optional factory callback from ILoggerFactory to ILogSink. GenHTTP, Node and Browser options accept an optional sink directly. None leaves the runtime default in force; a supplied LogSink.none silences logs. An inner Flow.withLogSink always wins. Microsoft logging scopes include annotations and named FiberLocals; empty entries add no empty scope. FiberLogging.observe remains opt-in and separate from message logging.

The default flowEndpoint functions retain their existing argument order. Use flowEndpointWithOptions for an explicit endpoint policy. Node offers startWithOptions / runWithOptions; Browser offers mountWithOptions / startWithSignalOptions. See .NET hosting, Node and application lifecycle.

Tests and authority

Flow.runTest env creates a fresh deterministic TestPlatform. Flow.runTestWith platform env exposes its manual clock, recording log, random and GUID implementations. Neither advances time automatically: fork a timed flow, await its sleeper-registration signal, call TestClock.advance, then join. advanceAll stops at the latest deadline registered at entry rather than following a repeating timer forever.

These runners are .NET-only. Fable uses the same ManualClock and scoped overrides; after advancing, await the released promise/fiber before a dependent advance.

A container should resolve application authority once and construct the environment. It is not a runtime-service registry. See providing the environment and service details. Cryptographic randomness belongs in explicit capability code using System.Security.Cryptography, not the runtime random generator.