Skip to content

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

Python

Leave graff learn out of release binaries

Rach Pradhan6f405a7bec52
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 0277b60e..9bef2970 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -231,6 +231,17 @@ jobs:
- name: Expired codex token recovered mid-turn, retry carries it (#402)
run: python3 scripts/test-codex-auth-recovery.py zig-out/bin/graff
+ - name: Release builds leave graff learn out
+ run: |
+ zig build graff -Dlearn=false --prefix "$RUNNER_TEMP/no-learn"
+ if "$RUNNER_TEMP/no-learn/bin/graff" learn status 2>"$RUNNER_TEMP/learn.err"; then
+ echo "graff learn ran in a -Dlearn=false build" >&2; exit 1
+ fi
+ grep -q 'not included in this build' "$RUNNER_TEMP/learn.err"
+ if "$RUNNER_TEMP/no-learn/bin/graff" --help | grep -q 'graff learn'; then
+ echo "--help lists graff learn in a -Dlearn=false build" >&2; exit 1
+ fi
+
- name: SDK generation drift
run: |
python3 sdk/generate.py --harness ./zig-out/bin/graff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a6266b92..d2da8284 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ current is part of cutting a release.
- `/workers` opens a read-only subagent browser with clickable rows, live activity, Markdown reports, and keyboard navigation. `/agents` still lists agent types.
- Includes independent conversation forks for subagents and workflow fan-out, optional retained workers, and bounded workflow synthesis that preserves earlier findings.
- Release binaries are built ReleaseSafe: an out-of-range index or overflow stops graff with a clear panic instead of silently corrupting state, and the stripped binaries are about 17-20% smaller.
+- `graff learn` is no longer part of the release binary, which is about 300 KB smaller for it; sessions no longer start background learning trials.
- Retains all changes from v0.302.51.
## v0.302.51
diff --git a/build.zig b/build.zig
index e7fd1211..38b3ddd7 100644
--- a/build.zig
+++ b/build.zig
@@ -37,9 +37,13 @@ pub fn build(b: *std.Build) void {
"telemetry-endpoint",
"default OTLP endpoint baked into builds (pass \"\" to disable; default = the deployed collector)",
) orelse "https://harness-telemetry.rachpradhan.workers.dev";
+ // `graff learn` (local policy learning) and its embedded Python kit. Dev
+ // builds keep it so CI exercises it; release builds leave it out.
+ const learn = b.option(bool, "learn", "include `graff learn` local policy learning (default true)") orelse true;
const opts = b.addOptions();
opts.addOption([]const u8, "version", version);
opts.addOption([]const u8, "telemetry_endpoint", telemetry_endpoint);
+ opts.addOption(bool, "learn", learn);
// Release binaries ship without unwind tables or frame pointers: they are
// stripped, so a panic can't print a useful trace anyway. Windows keeps its
diff --git a/install.sh b/install.sh
index 98e8d844..a4aa1e84 100644
--- a/install.sh
+++ b/install.sh
@@ -223,7 +223,7 @@ build_from_source() {
fi
printf " ${D}│${N} %-10s " "build"
- ( cd "$src" && zig build -Doptimize=ReleaseSafe ) >/dev/null 2>&1 \
+ ( cd "$src" && zig build -Doptimize=ReleaseSafe -Dlearn=false ) >/dev/null 2>&1 \
&& printf "${G}✓${N}\n" \
|| { printf "${R}failed${N}\n\n ${R}zig build failed${N} — run it manually in $src to see the error\n\n" >&2; exit 1; }
diff --git a/scripts/build-release.py b/scripts/build-release.py
index c1210b78..b2e4af5a 100644
--- a/scripts/build-release.py
+++ b/scripts/build-release.py
@@ -66,7 +66,7 @@ def fetch_dependencies(zig, env):
def contract(target, version, zig, telemetry=None, portable_host=False):
# A fixed version avoids an undeclared dependency on git describe / .git.
output = ROOT / "zig-out" / target / "bin" / ("graff.exe" if target.endswith("windows") else "graff")
- command = [str(zig), "build", "graff", "-Doptimize=ReleaseSafe",
+ command = [str(zig), "build", "graff", "-Doptimize=ReleaseSafe", "-Dlearn=false",
"-Dtarget=" + target, "-Dversion=" + version,
"--prefix", str(ROOT / "zig-out" / target)]
if portable_host:
diff --git a/src/cli.zig b/src/cli.zig
index 454918ab..f2b915f0 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -243,6 +243,12 @@ pub const changelog_text =
\\
;
+/// Release builds leave `graff learn` out (build option `learn`).
+const learn_usage = if (@import("build_options").learn)
+ " graff learn [help] local mutate/evaluate/promote/rollback engine\n"
+else
+ "";
+
pub const usage_text =
\\graff — a minimal agentic coding harness in Zig (zero deps)
\\
@@ -270,7 +276,8 @@ pub const usage_text =
\\ graff mcp install configure local HTTP service and MCP clients
\\ graff mcp serve [--http] [--port N] expose run_task to MCP clients
\\ graff plugins [load <name>] list Claude/Cursor/Grok/Codex plugin trees (in place)
- \\ graff learn [help] local mutate/evaluate/promote/rollback engine
+ \\
+++ learn_usage ++
\\ graff worktree list list -w tabs and experiment-pool trees (tagged)
\\ graff worktree create <name> [base] mint a task workspace from the remote base (origin/main after fetch; optional base)
\\ graff worktree run <name> run the workspace run script from that checkout
diff --git a/src/session_run.zig b/src/session_run.zig
index acb8fb57..f06d852d 100644
--- a/src/session_run.zig
+++ b/src/session_run.zig
@@ -449,6 +449,7 @@ pub fn shouldAutoLearn(unattended: bool, json_mode: bool) bool {
/// does not wait on suite generation; the next session that finds a store
/// starts the cadence.
pub fn startBackgroundLearning(gpa: Allocator, arena: Allocator, io: Io, environ_map: *const std.process.Environ.Map, budget: *const run_budget_mod.RunBudget, telemetry_allowed: bool) void {
+ if (comptime !@import("build_options").learn) return;
if (!shouldAutoLearn(main_mod.unattended, main_mod.json_mode)) return;
const options: learn_auto.Options = .{
.model_calls = budget.used(),
diff --git a/src/startup.zig b/src/startup.zig
index 8e63ce82..1015527b 100644
--- a/src/startup.zig
+++ b/src/startup.zig
@@ -44,6 +44,7 @@ const prompts = @import("prompts.zig");
const learn_store = @import("learn_store.zig");
const learn_bootstrap = @import("learn_bootstrap.zig");
const learn_auto = @import("learn_auto.zig");
+const build_options = @import("build_options"); // .learn: is `graff learn` in this build
const imagegen = @import("imagegen.zig"); // #352: codex-skill detection + the personal-tier skill mirror
const plugins = @import("plugins.zig");
@@ -95,7 +96,9 @@ pub fn buildSystemPrompt(
// authoring guidance is only sent where a repository exists to act on.
prompts.probeGitRepo(io);
// A learned policy is used unless this session opted out of it.
- const learned: ?learn_store.ActiveAgent = if (system_prompt_flag == null and learn_auto.enabled(learned_policy_env)) learnedRootPolicy(io, arena) else null;
+ const learned: ?learn_store.ActiveAgent = if (comptime !build_options.learn)
+ null
+ else if (system_prompt_flag == null and learn_auto.enabled(learned_policy_env)) learnedRootPolicy(io, arena) else null;
if (learned) |policy| if (!quiet) {
try out.print("root policy: learned generation {d} ({s})\n", .{ policy.generation, policy.genome_id[0..12] });
try out.flush();
@@ -323,6 +326,8 @@ pub fn runSubcommand(io: Io, gpa: Allocator, arena: Allocator, init: std.process
// resolution and normal session construction; configured child tools get
// only their explicitly allowlisted environment.
if (flags.positionals.items.len > 0 and std.mem.eql(u8, flags.positionals.items[0], "learn")) {
+ if (comptime !build_options.learn)
+ std.process.fatal("learn: `graff learn` is not included in this build", .{});
learn_cli.command(io, gpa, arena, init, flags.positionals.items[1..]) catch |err|
std.process.fatal("learn: {s}", .{@errorName(err)});
return true;