graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(rlm): keep schema.zig under 600 lines and update catalog tests
Rach Pradhana58a9e9f0e80
diff --git a/src/native_fold.zig b/src/native_fold.zigindex d3a20d2d..52da3980 100644--- a/src/native_fold.zig+++ b/src/native_fold.zig@@ -271,6 +271,8 @@ pub fn renderLoadedTail(s: *std.json.Stringify, kind: @import("provider.zig").Prconst schema_mod = @import("schema.zig");const mcp = @import("mcp.zig");for (loadedNames()) |name| {+ // #868: available rlm is already in the catalog head.+ if (std.mem.eql(u8, name, "rlm") and @import("rlm_spec.zig").available) continue;const spec = (try findRootSpec(out, name)) orelse continue;try schema_mod.writeToolEntry(s, kind, spec.name, spec.desc, .{ .raw = spec.schema });}diff --git a/src/native_fold_rlm.zig b/src/native_fold_rlm.zigindex 7f325457..4ef85929 100644--- a/src/native_fold_rlm.zig+++ b/src/native_fold_rlm.zig@@ -226,17 +226,12 @@ test "showcasing rlm keeps the tools head bytes; schema rides the tail" {};const before = try schema_mod.renderRootTools(arena, .openai, &specs, &.{});- try std.testing.expect(std.mem.indexOf(u8, before, "rlm") == null);- try std.testing.expect(std.mem.indexOf(u8, before, rlm.tool_schema) == null);+ try std.testing.expect(std.mem.indexOf(u8, before, "rlm") != null);+ try std.testing.expect(std.mem.indexOf(u8, before, rlm.tool_schema) != null);try std.testing.expect(fold.noticeContext(50_000, 80_000));const after = try schema_mod.renderRootTools(arena, .openai, &specs, &.{});- try std.testing.expect(before.len >= 1 and before[before.len - 1] == ']');- try std.testing.expect(std.mem.startsWith(u8, after, before[0 .. before.len - 1]));- try std.testing.expect(after.len > before.len);- try std.testing.expect(after[before.len - 1] == ',');- try std.testing.expect(std.mem.indexOf(u8, after[before.len - 1 ..], rlm.tool_schema) != null);- try std.testing.expect(std.mem.indexOf(u8, after[before.len - 1 ..], "llm_query") != null);+ try std.testing.expectEqualStrings(before, after);fold.resetSession();try std.testing.expect(!fold.listed());diff --git a/src/no_local_tools.zig b/src/no_local_tools.zigindex fd96d3fc..01a24145 100644--- a/src/no_local_tools.zig+++ b/src/no_local_tools.zig@@ -431,6 +431,6 @@ test "lean catalog drops overflow pager and empty load_tool_schemas" {try std.testing.expect(std.mem.indexOf(u8, json, "write_file") != null);try std.testing.expect(std.mem.indexOf(u8, json, "read_tool_result") == null);try std.testing.expect(std.mem.indexOf(u8, json, "\"name\":\"load_tool_schemas\"") == null);- try std.testing.expect(std.mem.indexOf(u8, json, "\"rlm\"") == null);+ try std.testing.expect(std.mem.indexOf(u8, json, "\"rlm\"") != null);try std.testing.expect(std.mem.indexOf(u8, json, "\"name\":\"read_file\"") != null);}diff --git a/src/schema.zig b/src/schema.zigindex 37e1594b..1a6abd52 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -479,11 +479,8 @@ pub fn emitSchema(w: *Io.Writer) !void {try s.endArray();try s.objectField("tools");try s.beginArray();- // Optional tools (#352) are listed unconditionally even though they are- // advertised only when available: this document is the SDK codegen- // contract and must stay byte-identical across machines. Each such tool's- // description states what it needs in order to exist.- for (root_specs ++ optional_specs) |t| {+ // Optionals + rlm: SDK dump is unconditional (#352, #868).+ for (root_specs ++ optional_specs ++ [_]ToolSpec{.{ .name = rlm.tool_name, .desc = rlm.tool_desc, .schema = rlm.tool_schema }}) |t| {try s.beginObject();try s.objectField("name");try s.write(t.name);@@ -493,16 +490,6 @@ pub fn emitSchema(w: *Io.Writer) !void {try s.print("{s}", .{t.schema});try s.endObject();}- // #868: rlm is a default-on host tool (hidden only under --old). The SDK- // dump must name it like other always-documented optionals.- try s.beginObject();- try s.objectField("name");- try s.write(rlm.tool_name);- try s.objectField("description");- try s.write(rlm.tool_desc);- try s.objectField("parameters");- try s.print("{s}", .{rlm.tool_schema});- try s.endObject();try s.endArray();try s.objectField("flags");try s.print("{s}", .{schema_flags_json});