Engine primitives for composing and running a Coven: MagikBlocks, Scriveners (journals), orchestration, and DI helpers to build a spine (ritual) of work.
- IMagikBlock<TIn,TOut>: unit of work with
DoMagik. - IScrivener: append‑only, typed journal with tailing; includes
InMemoryScrivener<T>. - Builder:
BuildCoven,CovenServiceBuilderto register blocks and finalize runtime. - Orchestration:
ICovento invoke rituals;IBoardand pull mode options. - Utilities:
Emptymarker type; capability tags and selection strategy hooks.
- Deterministic pipelines: execute a chain of typed blocks with explicit I/O.
- Decoupled comms: components communicate via journals instead of callbacks.
- Testable by design: swap
InMemoryScrivener<T>and run blocks in isolation.
using Coven.Core;
using Coven.Core.Builder;
using Microsoft.Extensions.DependencyInjection;
// A minimal block that writes/reads journals or orchestrates other services
internal sealed class HelloBlock : IMagikBlock<Empty, Empty>
{
public Task<Empty> DoMagik(Empty input, CancellationToken cancellationToken = default)
{
// do work; start daemons; read/write journals
return Task.FromResult(input);
}
}
ServiceCollection services = new();
services.BuildCoven(c =>
{
c.MagikBlock<Empty, Empty, HelloBlock>();
c.Done();
});
ServiceProvider provider = services.BuildServiceProvider();
ICoven coven = provider.GetRequiredService<ICoven>();
await coven.Ritual<Empty, Empty>(new Empty());- Prefer
InMemoryScrivener<T>for journals and invoke blocks directly. - Treat
OperationCanceledExceptionas cooperative shutdown when using tokens.
- Architecture: Journaling and Scriveners; Windowing and Shattering.
- Samples:
src/samples/01.DiscordAgentfor end‑to‑end orchestration.