christopherkarani/hive
Deterministic graph runtime for Swift.
What Hive Provides
- Typed schemas, channels, reducers, and update policies
- Deterministic graph compilation with validated nodes, edges, routers, and joins
- Superstep runtime with stable task ordering and atomic commits
- Interrupt/resume and checkpoint protocol support
- Runtime event streams for runs, steps, tasks, writes, checkpoints, snapshots, updates, and custom debug events
- Swift 6.2 concurrency-first APIs
Hive is intentionally a graph runtime. DSL, model/tool calling, RAG memory, and provider adapters are not part of this package.
Quick Start
import Hive
enum CounterSchema: HiveSchema {
static let value = HiveChannelKey<Self, Int>(HiveChannelID("value"))
static var channelSpecs: [AnyHiveChannelSpec<Self>] {
[
AnyHiveChannelSpec(
HiveChannelSpec(
key: value,
scope: .global,
reducer: .sum,
updatePolicy: .multi,
initial: { 0 },
persistence: .untracked
)
)
]
}
}
var builder = HiveGraphBuilder<CounterSchema>(start: [HiveNodeID("increment")])
builder.addNode(HiveNodeID("increment")) { _ in
HiveNodeOutput(
writes: [AnyHiveWrite(CounterSchema.value, 1)],
next: .end
)
}
let graph = try builder.compile()
let runtime = try HiveRuntime(
graph: graph,
environment: HiveEnvironment(
context: (),
clock: AppClock(),
logger: AppLogger()
)
)AppClock and AppLogger are your implementations of HiveClock and HiveLogger.
Products
| Product | Description | | --- | --- | | Hive | Umbrella library that re-exports HiveCore | | HiveCore | Core deterministic graph runtime | | HiveTinyGraphExample | Runnable fan-out, join, interrupt/resume example |
Requirements
| Platform | Min Version | | --- | --- | | Swift | 6.2 | | iOS | 17.0+ | | macOS | 14.0+ | | Linux | Swift 6.2 toolchain |
Run
swift build
swift run HiveTinyGraphExample
swift testDocumentation
Full documentation is available at christopherkarani.github.io/Hive.
License
MIT
Package Metadata
Repository: christopherkarani/hive
Default branch: master
README: README.md