graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(mcp): drop the codedbpro eager pin — the guard already owns routing
Rach Pradhan1e779e054a81
diff --git a/src/agent_request.zig b/src/agent_request.zigindex 9976ee1f..5bc4987a 100644--- a/src/agent_request.zig+++ b/src/agent_request.zig@@ -203,7 +203,27 @@ pub fn request(self: *Agent, tools_in: ?[]const u8) !std.json.ObjectMap {// — total body, tools JSON, system prompt; the remainder is messages.// Byte sizes, not tokens (÷~4 for a rough token read). stderr, never// json_mode's stdout.- if (reqStatsArmed()) std.debug.print(" [req] body={d}B tools={d}B system={d}B messages~={d}B\n", .{ body.len, if (tools) |t| t.len else 0, self.sys_normal.len, body.len -| (if (tools) |t| t.len else 0) -| self.sys_normal.len });+ if (reqStatsArmed()) {+ std.debug.print(" [req] body={d}B tools={d}B system={d}B messages~={d}B\n", .{ body.len, if (tools) |t| t.len else 0, self.sys_normal.len, body.len -| (if (tools) |t| t.len else 0) -| self.sys_normal.len });+ // Per-server split: attribute each tool's serialized span by its+ // name prefix (next-"name" boundary ≈ tool size, ±separators).+ if (tools) |t| {+ var cdbp: usize = 0;+ var other_mcp: usize = 0;+ var native: usize = 0;+ var pos: usize = 0;+ while (std.mem.indexOfPos(u8, t, pos, "\"name\":\"")) |n| {+ const name_start = n + 8;+ const name_end = std.mem.indexOfScalarPos(u8, t, name_start, '"') orelse break;+ const next = std.mem.indexOfPos(u8, t, name_end, "\"name\":\"") orelse t.len;+ const span = next - n;+ const nm = t[name_start..name_end];+ if (std.mem.startsWith(u8, nm, "mcp__codedbpro__")) cdbp += span else if (std.mem.startsWith(u8, nm, "mcp__")) other_mcp += span else native += span;+ pos = name_end;+ }+ std.debug.print(" [req] tools split: native={d}B codedbpro={d}B other_mcp={d}B\n", .{ native, cdbp, other_mcp });+ }+ }const t0: Io.Timestamp = .now(self.io, .awake);if (main_mod.json_mode and !self.sub) self.emit(.{ .type = "model_call_started", .provider = self.provider.id, .model = self.provider.model });// HTTP calls are flaky: a kept-alive connection the server closeddiff --git a/src/codedbpro_report.zig b/src/codedbpro_report.zigindex 419db479..30b27b74 100644--- a/src/codedbpro_report.zig+++ b/src/codedbpro_report.zig@@ -192,7 +192,7 @@ pub fn nativeRefusal(ctx: tools.ToolCtx, call: tools.ToolCall) ?tools.ToolOutputif (tools.strField(call.input, "command")) |cmd| leadingSearchCommand(cmd) else false;if (!is_bash_search and !replacedNative(call.name)) return null;const pro = replacementFor(call.name, is_bash_search, skills.binOnPath(ctx.io, "zigrep"));- const text = std.fmt.allocPrint(ctx.gpa, "{s} is blocked while the LICENSED code-intelligence suite is in charge of reads/searches — use {s} instead. If a codedb-pro call fails, the native tools unblock automatically for the rest of the session (and the failure is reported upstream).", .{ call.name, pro }) catch return null;+ const text = std.fmt.allocPrint(ctx.gpa, "{s} is blocked while the LICENSED code-intelligence suite is in charge of reads/searches — use {s} instead (if its schema is not loaded yet, pass its name to load_tool_schemas first — once per session). If a codedb-pro call fails, the native tools unblock automatically for the rest of the session (and the failure is reported upstream).", .{ call.name, pro }) catch return null;return .{ .text = text, .is_error = true };}diff --git a/src/main.zig b/src/main.zigindex 360da848..bea5e653 100644--- a/src/main.zig+++ b/src/main.zig@@ -167,7 +167,7 @@ const skills = @import("skills.zig");const skills_registry = skills.skills_registry;const companion_servers = skills.companion_servers;const mcpServerConnected = skills.mcpServerConnected;-const probeLicensedPinEager = session_start.probeLicensedPinEager; // probe + #416 eager pin in one startup step+const probeLicensed = session_start.probeLicensed; // license probe only — schemas stay deferred; the guard enforces routing (#476)/// PATH captured at startup for skill detection (PATH won't change mid-run).pub var g_path_env: []const u8 = "";/// Human-facing current workspace folder shown in the REPL prompt.@@ -392,7 +392,7 @@ pub fn main(init: std.process.Init) !void {try session_start.connectCompanion(io, arena, ®istry_storage, flags, out, json_mode, init.environ_map);const mcp_tools: []const mcp.Tool = registry_storage.tools;// If the metered companion connected, probe its license once so the note below can lean into paid tools (vs the conservative free-codedb note).- if (!session_start.leanMode(flags.effectiveLean(), init.environ_map) and mcpServerConnected(mcp_tools, "codedbpro")) g_codedbpro_licensed = probeLicensedPinEager(gpa, arena, io);+ if (!session_start.leanMode(flags.effectiveLean(), init.environ_map) and mcpServerConnected(mcp_tools, "codedbpro")) g_codedbpro_licensed = probeLicensed(gpa, io);boot.mark(io, "companion");var approvals: Approvals = undefined;diff --git a/src/session_start.zig b/src/session_start.zigindex bde1ff92..e5ebf454 100644--- a/src/session_start.zig+++ b/src/session_start.zig@@ -423,15 +423,15 @@ pub fn initRegistryConsent(io: Io, gpa: Allocator, arena: Allocator, out: *Io.Wrreturn registry;}-/// Licensed startup path (main.zig): probe the companion's license, and when-/// paid ALSO pin the server eager in the #416 schema gate — a licensed user-/// pays for these tools, so their full schemas belong in every request rather-/// than behind a per-session load_tool_schemas toll that steers the model-/// back to the native defaults. Runs before the first catalog render.-pub fn probeLicensedPinEager(gpa: Allocator, arena: Allocator, io: Io) bool {- if (!skills.probeCodedbproLicensed(gpa, io)) return false;- mcp_schema_gate.pinEagerRuntime(arena, "codedbpro");- return true;+/// Licensed startup path (main.zig): probe the companion's license so the+/// session can lean into the paid tools. Schemas stay DEFERRED like every+/// other server: routing to the suite is enforced by the codedbpro guard+/// (codedbpro_report.nativeRefusal blocks the native read/search tools and+/// points at the pro replacements), so the old eager pin paid ~17 KiB of+/// schema bytes on every request for behavior the guard already guarantees+/// (#476). GRAFF_MCP_EAGER=codedbpro restores the eager surface opt-in.+pub fn probeLicensed(gpa: Allocator, io: Io) bool {+ return skills.probeCodedbproLicensed(gpa, io);}/// Companion auto-activation: if the metered code-intelligence companiondiff --git a/src/skills.zig b/src/skills.zigindex 84b655b0..8a32518e 100644--- a/src/skills.zig+++ b/src/skills.zig@@ -67,7 +67,7 @@ pub const skills_registry = [_]SkillDef{/// Edits inside the cwd stay native: edit_file/write_file are/// /rewind-snapshotted and already splice via zigpatch, whereas codedb-pro/// edit/patch/replace bypass /rewind. Explicit external targets use gated bash.-const codedbpro_note_licensed = "The codedb-pro MCP server is connected and LICENSED, and its mcp__codedbpro__* tools ship with FULL schemas already loaded (pinned eager — no load_tool_schemas round trip needed). You are paying for them, so they REPLACE the native read/search defaults: use mcp__codedbpro__read (mode=outline first, then symbol/lines) instead of read_file for navigating code, mcp__codedbpro__faster_search / meta_search instead of the codedb tool and bash grep/find for symbol, content and fuzzy search, and mcp__codedbpro__batch to run several independent reads/searches in one round-trip. The native read_file/codedb (and leading bash grep/rg/find) are BLOCKED while the licensed server is healthy — read/search calls are refused with a pointer to the pro equivalent, shell searches with a pointer to `zigrep` (the suite's own search CLI — run it directly via bash); any codedb-pro failure automatically unblocks the natives for the rest of the session (and is reported upstream, so just fall back and keep working). KEEP EDITS inside the cwd on the native edit_file/write_file tools — they are snapshot-tracked for /rewind and already splice via zigpatch; codedb-pro edit/patch/replace bypass /rewind, so do not route edits through it. An explicitly user-requested external target is the exception: use permission-gated bash with quoted paths and explain that /rewind does not cover it.";+const codedbpro_note_licensed = "The codedb-pro MCP server is connected and LICENSED, and its mcp__codedbpro__* tools REPLACE the native read/search defaults — you are paying for them. Their schemas ship DEFERRED to keep every request lean: pass the mcp__codedbpro__* names to load_tool_schemas the first time you need one (once per session), then use mcp__codedbpro__read (mode=outline first, then symbol/lines) instead of read_file for navigating code, mcp__codedbpro__faster_search / meta_search instead of the codedb tool and bash grep/find for symbol, content and fuzzy search, and mcp__codedbpro__batch to run several independent reads/searches in one round-trip. The native read_file/codedb (and leading bash grep/rg/find) are BLOCKED while the licensed server is healthy — read/search calls are refused with a pointer to the pro equivalent, shell searches with a pointer to `zigrep` (the suite's own search CLI — run it directly via bash); any codedb-pro failure automatically unblocks the natives for the rest of the session (and is reported upstream, so just fall back and keep working). KEEP EDITS inside the cwd on the native edit_file/write_file tools — they are snapshot-tracked for /rewind and already splice via zigpatch; codedb-pro edit/patch/replace bypass /rewind, so do not route edits through it. An explicitly user-requested external target is the exception: use permission-gated bash with quoted paths and explain that /rewind does not cover it.";const McpNote = struct { server: []const u8, note: []const u8 };pub const mcp_notes = [_]McpNote{