bitflow

Workflow engine core with Starlark-subset parser, DAG execution, and cache planning primitives.

workflow
starlark
dag
cache
build
moon add mizchi/bitflow@0.4.1
Download zip
Author
Version
0.4.1
License
Apache-2.0
Last updated
4 months ago
Downloads
149K

Dependencies

README

#mizchi/bitflow

Workflow engine primitives for MoonBit.

#Package

  • mizchi/bitflow/workflow

#Features

  • DAG validation and topological planning
  • Starlark subset parser (workflow/node/task/entrypoint/var/config/load)
  • Direct execution APIs for IR and Starlark sources
  • Adapter boundary for command and filesystem integration
  • Cache helpers (flow_cache_key, flow_fingerprint, flow_task_fingerprint, plan_task_cache, writeback_task_cache)

#Layering

  • Language core: Python/Starlark subset expression parsing and evaluation
  • Host API: workflow declarative calls (workflow/node/task/entrypoint/var/config/load)
  • Execution layer: IR lowering, DAG planning, execution and cache integration

#Example

import {
"mizchi/bitflow/workflow" @wf,
}

let nodes = [@wf.new_node("root", []), @wf.new_node("dep", ["root"])]
let tasks = [
@wf.new_task("root:build", "root", "build", []),
@wf.new_task("dep:test", "dep", "test", ["root:build"]),
]
let ir = @wf.new_ir("ci", nodes, tasks, entry_targets=["dep:test"])
let result = @wf.execute_ir(ir, fn(_task : @wf.FlowTask) { (true, "") })
inspect(result.ok, content="true")

#Cache Roundtrip

import {
"mizchi/bitflow/workflow" @wf,
}

let adapter = @wf.WorkflowAdapter::new(
@wf.FsAdapter::memory_with({
"workflow.star":
#|workflow(name="ci")
#|node(id="root", depends_on=[])
#|task(id="root:build", node="root", cmd="build", needs=[])
#|entrypoint(targets=["root:build"]),
}),
@wf.CommandAdapter::none(),
)

let signatures : Map[String, String] = { "root": "sig-root" }
let writeback = @wf.writeback_task_cache_from_fs(
"workflow.star",
adapter,
signatures,
{},
["root:build"],
)
inspect(writeback.updated.length(), content="1")
let next_plan = @wf.plan_task_cache_from_fs(
"workflow.star",
adapter,
signatures,
writeback.entries,
)
inspect(next_plan.decisions[0].hit, content="true")

#
fib

fn fib(n : Int) -> Int64

Calculate the n-th Fibonacci number.

test {
inspect(fib(10), content="89")
}

#
sum

fn sum(data~ : Array[Int], start? : Int, length? : Int) -> Int

data is a labelled argument without default value having type Array[Int] start is an optional labelled argument with default value 0 having type Int length is an optional labelled argument without default value having type Option[Int]

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io