Skip to content

tiny_orch.h Overview

tiny_orch.h is the unified entry header for TinyOrch, depending on tiny_bench.h.


Core Data Structures

Step tiny_orch_step_t

typedef struct {
    char src_name[TINY_ORCH_NAME_LEN];   // source data slot name
    char tool_name[TINY_ORCH_NAME_LEN];  // tool name
    char dst_name[TINY_ORCH_NAME_LEN];   // destination data slot name
    bool used;
} tiny_orch_step_t;

Flow tiny_orch_flow_t

typedef struct {
    char              name[TINY_ORCH_NAME_LEN];
    tiny_orch_state_t state;                         // current state
    tiny_orch_step_t  steps[TINY_ORCH_MAX_STEPS_PER_FLOW];
    int               step_count;
    int               last_executed;                 // last completed step index
    bool              used;
} tiny_orch_flow_t;

Orchestrator tiny_orch_t

typedef struct {
    tiny_bench_t      *bench;                           // external bench reference
    tiny_orch_flow_t   flows[TINY_ORCH_MAX_FLOWS];
} tiny_orch_t;

Flow State Machine

CREATED ──(add step)──→ DEFINED ──(go)──→ RUNNING ──(complete)──→ DONE
                                                    ──(error)──→ ERROR
           ──(destroy)──→ (deleted)
typedef enum {
    TINY_ORCH_STATE_NONE    = 0,  // not created / destroyed
    TINY_ORCH_STATE_DEFINED = 1,  // created, steps can be added
    TINY_ORCH_STATE_DONE    = 2,  // last execution completed successfully
    TINY_ORCH_STATE_ERROR   = 3,  // last execution failed
} tiny_orch_state_t;

API Overview

Initialization

Function Purpose
tiny_orch_init(orch, bench) Initialize orchestrator, bind TinyBench

Flow Definition

Function Purpose Error Code
tiny_orch_create(orch, "flow") Create a named flow OK, FULL, EXISTS
tiny_orch_step(orch, "flow", idx, src, tool, dst) Add/set a step OK, SRC_NOT_FOUND, TOOL_NOT_FOUND, TYPE_MISMATCH
tiny_orch_step_count(orch, "flow") Query step count Returns count or negative error code
tiny_orch_list_flows(orch, names, max) List all flows Returns count
tiny_orch_destroy(orch, "flow") Delete a flow OK, NOT_FOUND

Execution

Function Purpose Error Code
tiny_orch_go(orch, "flow") Execute all steps in order OK or execution error
tiny_orch_run(orch, src, tool, dst) One-shot single step execution OK or execution error

Status Query

Function Purpose Error Code
tiny_orch_status(orch, "flow", &state) Query flow state OK, NOT_FOUND

Error Codes

TINY_ORCH_OK                =  0
TINY_ORCH_ERR_NULL          = -1   // NULL pointer argument
TINY_ORCH_ERR_NOT_FOUND     = -2   // flow name does not exist
TINY_ORCH_ERR_FULL          = -3   // max flows reached
TINY_ORCH_ERR_EXISTS        = -4   // flow name already exists
TINY_ORCH_ERR_NAME_LEN      = -5   // name exceeds max length
TINY_ORCH_ERR_STEP_FULL     = -6   // step count exceeded
TINY_ORCH_ERR_SRC_NOT_FOUND = -7   // source data slot does not exist
TINY_ORCH_ERR_TOOL_NOT_FOUND= -8   // tool not registered
TINY_ORCH_ERR_TYPE_MISMATCH = -9   // src type ≠ tool input type
TINY_ORCH_ERR_EXEC_FAILED   = -10  // runtime execution failed

Configuration

Macro Default Description
TINY_ORCH_MAX_FLOWS 4 Maximum number of named flows
TINY_ORCH_MAX_STEPS_PER_FLOW 16 Maximum steps per flow
TINY_ORCH_NAME_LEN 24 Maximum name length