Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

test: channel-worker deliver injects inbound as a user wake

Cursor Agent3ee51366162e
diff --git a/src/channel_worker.zig b/src/channel_worker.zig
index 76f0e9bf..17e204db 100644
--- a/src/channel_worker.zig
+++ b/src/channel_worker.zig
@@ -158,6 +158,29 @@ test "slashCommand send is a send line; inbox drains takeWake" {
try std.testing.expect(takeWake(io, &buf) == null);
}
+test "deliver injects recorded inbound as a user line" {
+ const io = std.testing.io;
+ const gpa = std.testing.allocator;
+ var arena = std.heap.ArenaAllocator.init(gpa);
+ defer arena.deinit();
+ _ = takeAll(io, arena.allocator());
+ record(io, gpa, "from irc");
+ const drop = struct {
+ fn emit(_: *anyopaque, _: @import("engine_sink.zig").Stamped) void {}
+ };
+ const vt = @import("engine_sink.zig").VTable{ .emit = drop.emit, .durable = false };
+ var root: Agent = undefined;
+ root.sub = false;
+ root.io = io;
+ root.arena = arena.allocator();
+ root.messages = std.json.Array.init(arena.allocator());
+ root.sink = .{ .ctx = undefined, .vt = &vt };
+ deliver(&root);
+ try std.testing.expectEqual(@as(usize, 1), root.messages.items.len);
+ try std.testing.expectEqualStrings("user", root.messages.items[0].object.get("role").?.string);
+ try std.testing.expect(std.mem.indexOf(u8, root.messages.items[0].object.get("content").?.string, "from irc") != null);
+}
+
test "record then takeAll drains once" {
const io = std.testing.io;
const gpa = std.testing.allocator;