-module(aion@workflow). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/aion/workflow.gleam"). -export([run/1, run_with_default/2, all/1, all_with_default/2, race/1, race_with_default/2, all_settled/1, all_settled_with_default/2, map_settled/2, map_settled_with_default/3, map/2, map_with_default/3, id/0, now/0, random/0, random_int/2, sleep/1, start_timer/2, cancel_timer/1, with_timeout/2, continue_as_new/2, 'receive'/1, timer_id/1, spawn/6, spawn_and_wait/6, timestamp_to_milliseconds/1, define/5, name/1, input_codec/1, output_codec/1, error_codec/1, entry_fn/1, entrypoint/2]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " Workflow authoring surface.\n" "\n" " This module is an aggregator only: it forwards declarations from the\n" " workflow submodules and contains no workflow business logic. `run` is the\n" " only recorded activity dispatch surface in this brief; deterministic time\n" " and random values come from AD through `aion/internal/ffi`.\n" ). -file("src/aion/workflow.gleam", 38). -spec run(aion@activity:activity(any(), GPX)) -> {ok, GPX} | {error, aion@error:activity_error()}. run(Activity) -> aion@workflow@run:run(Activity). -file("src/aion/workflow.gleam", 47). ?DOC( " `run`, supplying the workflow-level default task queue applied when the\n" " activity selects none. Precedence (activity override > workflow default >\n" " the named `\"default\"` queue) is resolved once at the engine schedule seam.\n" ). -spec run_with_default( aion@activity:activity(any(), GQD), gleam@option:option(binary()) ) -> {ok, GQD} | {error, aion@error:activity_error()}. run_with_default(Activity, Workflow_default_task_queue) -> aion@workflow@run:run_with_default(Activity, Workflow_default_task_queue). -file("src/aion/workflow.gleam", 54). -spec all(list(aion@activity:activity(any(), GQK))) -> {ok, list(GQK)} | {error, aion@error:activity_error()}. all(Activities) -> aion@workflow@concurrency:all(Activities). -file("src/aion/workflow.gleam", 62). ?DOC( " `all`, supplying the workflow-level default task queue for any member that\n" " selects none. See [`run_with_default`] for the resolution precedence.\n" ). -spec all_with_default( list(aion@activity:activity(any(), GQS)), gleam@option:option(binary()) ) -> {ok, list(GQS)} | {error, aion@error:activity_error()}. all_with_default(Activities, Workflow_default_task_queue) -> aion@workflow@concurrency:all_with_default( Activities, Workflow_default_task_queue ). -file("src/aion/workflow.gleam", 69). -spec race(list(aion@activity:activity(any(), GRB))) -> {ok, GRB} | {error, aion@error:activity_error()}. race(Activities) -> aion@workflow@concurrency:race(Activities). -file("src/aion/workflow.gleam", 77). ?DOC( " `race`, supplying the workflow-level default task queue for any member that\n" " selects none. See [`run_with_default`] for the resolution precedence.\n" ). -spec race_with_default( list(aion@activity:activity(any(), GRI)), gleam@option:option(binary()) ) -> {ok, GRI} | {error, aion@error:activity_error()}. race_with_default(Activities, Workflow_default_task_queue) -> aion@workflow@concurrency:race_with_default( Activities, Workflow_default_task_queue ). -file("src/aion/workflow.gleam", 87). ?DOC( " Spawn all activities concurrently and settle every member independently:\n" " one `Result` slot per activity, input order, no fail-fast, no sibling\n" " cancellation. Each member's retry policy runs to its own final outcome.\n" ). -spec all_settled(list(aion@activity:activity(any(), GRQ))) -> list({ok, GRQ} | {error, aion@error:activity_error()}). all_settled(Activities) -> aion@workflow@concurrency:all_settled(Activities). -file("src/aion/workflow.gleam", 95). ?DOC( " `all_settled`, supplying the workflow-level default task queue for any\n" " member that selects none. See [`run_with_default`] for the precedence.\n" ). -spec all_settled_with_default( list(aion@activity:activity(any(), GRY)), gleam@option:option(binary()) ) -> list({ok, GRY} | {error, aion@error:activity_error()}). all_settled_with_default(Activities, Workflow_default_task_queue) -> aion@workflow@concurrency:all_settled_with_default( Activities, Workflow_default_task_queue ). -file("src/aion/workflow.gleam", 104). ?DOC( " Dynamically produce one activity per input element, then settle like\n" " [`all_settled`]: one `Result` slot per item, item order, no fail-fast.\n" ). -spec map_settled(list(GSG), fun((GSG) -> aion@activity:activity(any(), GSJ))) -> list({ok, GSJ} | {error, aion@error:activity_error()}). map_settled(Items, To_activity) -> aion@workflow@concurrency:map_settled(Items, To_activity). -file("src/aion/workflow.gleam", 114). ?DOC( " `map_settled`, supplying the workflow-level default task queue for any\n" " produced activity that selects none. See [`run_with_default`] for the\n" " precedence.\n" ). -spec map_settled_with_default( list(GSP), fun((GSP) -> aion@activity:activity(any(), GSS)), gleam@option:option(binary()) ) -> list({ok, GSS} | {error, aion@error:activity_error()}). map_settled_with_default(Items, To_activity, Workflow_default_task_queue) -> aion@workflow@concurrency:map_settled_with_default( Items, To_activity, Workflow_default_task_queue ). -file("src/aion/workflow.gleam", 126). -spec map(list(GSZ), fun((GSZ) -> aion@activity:activity(any(), GTC))) -> {ok, list(GTC)} | {error, aion@error:activity_error()}. map(Items, To_activity) -> aion@workflow@concurrency:map(Items, To_activity). -file("src/aion/workflow.gleam", 135). ?DOC( " `map`, supplying the workflow-level default task queue for any produced\n" " activity that selects none. See [`run_with_default`] for the precedence.\n" ). -spec map_with_default( list(GTI), fun((GTI) -> aion@activity:activity(any(), GTL)), gleam@option:option(binary()) ) -> {ok, list(GTL)} | {error, aion@error:activity_error()}. map_with_default(Items, To_activity, Workflow_default_task_queue) -> aion@workflow@concurrency:map_with_default( Items, To_activity, Workflow_default_task_queue ). -file("src/aion/workflow.gleam", 143). -spec id() -> {ok, binary()} | {error, aion@error:engine_error()}. id() -> aion@workflow@run:id(). -file("src/aion/workflow.gleam", 147). -spec now() -> {ok, aion@workflow@run:timestamp()} | {error, aion@error:engine_error()}. now() -> aion@workflow@run:now(). -file("src/aion/workflow.gleam", 151). -spec random() -> {ok, float()} | {error, aion@error:engine_error()}. random() -> aion@workflow@run:random(). -file("src/aion/workflow.gleam", 155). -spec random_int(integer(), integer()) -> {ok, integer()} | {error, aion@error:engine_error()}. random_int(Min, Max) -> aion@workflow@run:random_int(Min, Max). -file("src/aion/workflow.gleam", 159). -spec sleep(aion@duration:duration()) -> {ok, nil} | {error, aion@error:engine_error()}. sleep(Duration) -> aion@workflow@timer:sleep(Duration). -file("src/aion/workflow.gleam", 163). -spec start_timer(binary(), aion@duration:duration()) -> {ok, aion@workflow@timer:timer_ref()} | {error, aion@error:engine_error()}. start_timer(Name, Duration) -> aion@workflow@timer:start_timer(Name, Duration). -file("src/aion/workflow.gleam", 170). -spec cancel_timer(aion@workflow@timer:timer_ref()) -> {ok, nil} | {error, aion@error:engine_error()}. cancel_timer(Reference) -> aion@workflow@timer:cancel_timer(Reference). -file("src/aion/workflow.gleam", 174). -spec with_timeout( fun(() -> {ok, GUG} | {error, GUH}), aion@duration:duration() ) -> {ok, GUG} | {error, aion@error:timeout_result_error(GUH)}. with_timeout(Operation, Deadline) -> aion@workflow@timer:with_timeout(Operation, Deadline). -file("src/aion/workflow.gleam", 181). -spec continue_as_new(GUN, aion@codec:codec(GUN)) -> {ok, nil} | {error, aion@error:workflow_error()}. continue_as_new(Input, Input_codec) -> aion@workflow@continuation:continue_as_new(Input, Input_codec). -file("src/aion/workflow.gleam", 188). -spec 'receive'(aion@signal:signal_ref(GUR)) -> {ok, GUR} | {error, aion@error:receive_error()}. 'receive'(Reference) -> aion@signal:'receive'(Reference). -file("src/aion/workflow.gleam", 194). -spec timer_id(aion@workflow@timer:timer_ref()) -> binary(). timer_id(Reference) -> aion@workflow@timer:timer_id(Reference). -file("src/aion/workflow.gleam", 198). -spec spawn( binary(), fun((GUV) -> {ok, GUW} | {error, GUX}), GUV, aion@codec:codec(GUV), aion@codec:codec(GUW), aion@codec:codec(GUX) ) -> {ok, aion@child:child_handle(GUW, GUX)} | {error, aion@error:engine_error()}. spawn(Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec) -> aion@child:spawn( Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec ). -file("src/aion/workflow.gleam", 209). -spec spawn_and_wait( binary(), fun((GVH) -> {ok, GVI} | {error, GVJ}), GVH, aion@codec:codec(GVH), aion@codec:codec(GVI), aion@codec:codec(GVJ) ) -> {ok, GVI} | {error, aion@error:child_error(GVJ)}. spawn_and_wait(Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec) -> aion@child:spawn_and_wait( Name, Workflow_fn, Input, Input_codec, Output_codec, Error_codec ). -file("src/aion/workflow.gleam", 227). -spec timestamp_to_milliseconds(aion@workflow@run:timestamp()) -> integer(). timestamp_to_milliseconds(Timestamp) -> aion@workflow@run:timestamp_to_milliseconds(Timestamp). -file("src/aion/workflow.gleam", 231). -spec define( binary(), aion@codec:codec(GVS), aion@codec:codec(GVU), aion@codec:codec(GVW), fun((GVS) -> {ok, GVU} | {error, GVW}) ) -> aion@workflow@define:workflow_definition(GVS, GVU, GVW). define(Name, Input_codec, Output_codec, Error_codec, Entry_fn) -> aion@workflow@define:define( Name, Input_codec, Output_codec, Error_codec, Entry_fn ). -file("src/aion/workflow.gleam", 241). -spec name(aion@workflow@define:workflow_definition(any(), any(), any())) -> binary(). name(Definition) -> aion@workflow@define:name(Definition). -file("src/aion/workflow.gleam", 247). -spec input_codec(aion@workflow@define:workflow_definition(GWJ, any(), any())) -> aion@codec:codec(GWJ). input_codec(Definition) -> aion@workflow@define:input_codec(Definition). -file("src/aion/workflow.gleam", 253). -spec output_codec(aion@workflow@define:workflow_definition(any(), GWR, any())) -> aion@codec:codec(GWR). output_codec(Definition) -> aion@workflow@define:output_codec(Definition). -file("src/aion/workflow.gleam", 259). -spec error_codec(aion@workflow@define:workflow_definition(any(), any(), GWZ)) -> aion@codec:codec(GWZ). error_codec(Definition) -> aion@workflow@define:error_codec(Definition). -file("src/aion/workflow.gleam", 265). -spec entry_fn(aion@workflow@define:workflow_definition(GXE, GXF, GXG)) -> fun((GXE) -> {ok, GXF} | {error, GXG}). entry_fn(Definition) -> aion@workflow@define:entry_fn(Definition). -file("src/aion/workflow.gleam", 283). ?DOC( " Drive a workflow's typed entry from the engine's raw spawn argument,\n" " making the hand-written `run` adapter a one-line shim:\n" "\n" " ```gleam\n" " pub fn run(raw_input: Dynamic) -> Result(String, String) {\n" " workflow.entrypoint(definition(), raw_input)\n" " }\n" " ```\n" "\n" " Success encodes with the definition's output codec, typed failure with its\n" " error codec (byte-identical to the hand-written adapter); an undecodable\n" " input yields the documented `{\"aion_error\":\"input_decode\",...}` envelope.\n" ). -spec entrypoint( aion@workflow@define:workflow_definition(any(), any(), any()), gleam@dynamic:dynamic_() ) -> {ok, binary()} | {error, binary()}. entrypoint(Definition, Raw_input) -> aion@workflow@entrypoint:entrypoint(Definition, Raw_input).