Skip to content

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

Python

Merge PR #264 into release/v0.0.215

Rach Pradhan4ed0332c1a9b
diff --cc docs/releases/v0.0.215.md
index ba3a1691,00000000..da4eda37
mode 100644,000000..100644
--- a/docs/releases/v0.0.215.md
+++ b/docs/releases/v0.0.215.md
@@@ -1,55 -1,0 +1,70 @@@
+# Private, correctness-first prompt-policy tournaments
+
+v0.0.215 turns the experimental local learning loop into a resumable,
- privacy-bounded tournament. It generates and evaluates competing prompt
- variants in parallel, ranks correctness before measured tool economy, and
- exposes only the primary winner to the hidden holdout.
++privacy-bounded tournament and adds native remote MCP support. It generates and
++evaluates competing prompt variants in parallel, ranks correctness before
++measured tool economy, exposes only the primary winner to the hidden holdout,
++and connects Streamable HTTP tools without a Node bridge.
+
+## Safer evidence and promotion
+
+- Mutation arms and primary evaluations run concurrently with shared pair
+ seeds and one verified parent baseline.
+- Ranking minimizes critical failures and regressions before considering
+ correctness, tool calls, cost, and prompt size. Latency is reported but does
+ not influence selection.
+- Expensive progress is checkpointed after each barrier and can be resumed
+ without silently repeating completed work.
+- Promotion remains a separate manual action by default. Automatic promotion
+ still requires both configuration and command-line consent, a holdout, and
+ all statistical gates.
+- Adapter programs and declared inputs are hashed, copied into private scratch,
+ and executed from the verified snapshots. Timeouts clean up descendant
+ processes as well as their parent.
+
+## Explicit, revocable aggregate sharing
+
- - \`learn run --submit\` grades and publishes one signed aggregate receipt in
- the same operation; \`learn submit RUN_ID\` retries an existing immutable run.
- - The model-facing \`learn_candidate\` tool can request that bundled operation,
++- `learn run --submit` grades and publishes one signed aggregate receipt in
++ the same operation; `learn submit RUN_ID` retries an existing immutable run.
++- The model-facing `learn_candidate` tool can request that bundled operation,
+ but cannot promote a candidate. Local mode requires a one-shot interactive
- confirmation that \`--yolo\`, saved approvals, subagents, and noninteractive
++ confirmation that `--yolo`, saved approvals, subagents, and noninteractive
+ runs cannot bypass.
+- Receipt payloads have no fields for prompts, tasks, code, paths, adapter
+ output, errors, or traces. Learning submissions also omit stable installation
+ identity, OS, architecture, and service version.
- - Backend receipts expire after 30 days. \`graff learn delete-remote RUN_ID\`
++- Backend receipts expire after 30 days. `graff learn delete-remote RUN_ID`
+ removes one earlier aggregate receipt using a run-scoped capability derived
+ locally from immutable evidence. Revocation remains available even when
+ telemetry and fleet sharing are disabled.
+- Local genomes, reports, and immutable evidence are never deleted by the
+ remote deletion command.
+
++## Streamable HTTP MCP and OAuth
++
++- Remote MCP servers accept JSON or SSE Streamable HTTP responses, retain
++ `Mcp-Session-Id`, and negotiate the supported MCP protocol version.
++- `graff mcp login NAME` performs protected-resource and authorization-server
++ discovery, dynamic client registration, browser PKCE login, persistent token
++ storage, and automatic refresh.
++- Authentication tokens live outside the repository with user-only
++ permissions. Static headers remain available for servers that do not use
++ OAuth.
++- Smolify is available as an anonymous core documentation server without
++ project configuration. `GRAFF_NO_SMOLIFY=1` disables its startup discovery
++ and tool surface for offline or privacy-sensitive sessions.
++
+## Validation
+
+- Complete Zig test suite and native build
+- Windows cross-build
+- End-to-end local learning and hidden-holdout tournament flows
+- Adapter retry/crash recovery and process-tree cleanup
+- Aggregate receipt signature and deletion-token cross-checks
+- Privacy efficacy suite, including an API-key canary that was absent from all
+ 8/8 captured SDK egress cases
+
+This branch intentionally requires manual promotion until the evidence is
+adequately powered.
+
+**Full changelog:** https://github.com/justrach/codegraff/compare/v0.0.214...v0.0.215
diff --cc scripts/codex_ws_test.py
index 00000000,46cb1399..a48a5ee3
mode 000000,100644..100644
--- a/scripts/codex_ws_test.py
+++ b/scripts/codex_ws_test.py
@@@ -1,0 -1,583 +1,581 @@@
+ #!/usr/bin/env python3
+ """Deterministic real-PTY tests for Codex transport and mid-turn compaction.
+
+ The transport smokes cover WebSocket primary, forced SSE fallback, and
+ GRAFF_CODEX_WS=off. The regression scenarios drive real tool loops whose
+ server-reported usage crosses compact@ while local history stays tiny. They
+ prove both successful compaction and transactional rollback after an empty
+ summary across WS -> quiet SSE compaction -> fresh WS.
+ """
+
+ import json
+ import os
+ import re
+ import sys
+ import tempfile
+
+ from codex_ws_mock import REPLY_TEXT, CodexMock, RecordedRequest
+ from pty_harness import PtySession, terminal_text
+
+ _arg = sys.argv[1] if len(sys.argv) > 1 else "graff"
+ GRAFF = os.path.abspath(_arg) if os.sep in _arg else _arg
+
+
+ # The reported 1500-token usage is conservatively floored by graff's serialized
+ # request estimate, so the displayed used count can move with the built-in tool
+ # schema. Assert the meter shape and invariants rather than freezing either the
+ # prefill estimate or the Codex catalog window.
+ METER_RE = re.compile(r"(\d+)(k?)/(\d+)k ctx \((\d+)% · compact@(\d+)k\)")
+ COMPACTING_RE = re.compile(r"compacting ~(\d+) tokens")
+
+ MIDTURN_PROMPT = "exercise the server-side context meter"
+ MIDTURN_SUMMARY = "The user asked to exercise the server-side context meter."
+ MIDTURN_FINAL = "done after mid-turn compact"
+ # Cross compact@ (80%) but stay below the destructive recovery boundary (95%).
+ # The smoke scenarios set this from the context meter emitted after the runtime
+ # Codex catalog has loaded, rather than the static --schema catalog.
+ MIDTURN_TOTAL_TOKENS = 0
+ MIDTURN_CONTEXT_TOKENS = 0
+ MIDTURN_REASONING_MARKER = "retained-active-reasoning:"
+ MIDTURN_REASONING_BYTES = 128 * 1024
+
+ TRANSACTIONAL_PROMPT = "prove failed compaction keeps the live tool loop"
+ TRANSACTIONAL_FINAL = "done after transactional compaction failure"
+ TRANSACTIONAL_REASONING_MARKER = "transactional-active-reasoning:"
+ TRANSACTIONAL_CALL_ID = "call_transactional_1"
+
+
+ def response_events(
+ item: dict | list[dict], response_id: str, total_tokens: int
+ ) -> list[dict]:
+ """Build the two Responses events parseResponses consumes."""
+ output_tokens = 1_000 if total_tokens > 2_000 else 100
+ items = item if isinstance(item, list) else [item]
+ return [
+ *(
+ {"type": "response.output_item.done", "item": output_item}
+ for output_item in items
+ ),
+ {
+ "type": "response.completed",
+ "response": {
+ "id": response_id,
+ "usage": {
+ "input_tokens": total_tokens - output_tokens,
+ "input_tokens_details": {"cached_tokens": 0},
+ "output_tokens": output_tokens,
+ "total_tokens": total_tokens,
+ },
+ },
+ },
+ ]
+
+
+ def message_item(text: str, item_id: str) -> dict:
+ return {
+ "type": "message",
+ "id": item_id,
+ "status": "completed",
+ "role": "assistant",
+ "content": [{"type": "output_text", "text": text, "annotations": []}],
+ }
+
+
+ def active_reasoning_item() -> dict:
+ """A large current-loop item that compact() must prune before full resend."""
+ encrypted = MIDTURN_REASONING_MARKER + "R" * (
+ MIDTURN_REASONING_BYTES - len(MIDTURN_REASONING_MARKER)
+ )
+ return {
+ "type": "reasoning",
+ "id": "rs_midturn_1",
+ "summary": [],
+ "encrypted_content": encrypted,
+ }
+
+
+ def midturn_events(request: RecordedRequest) -> list[dict]:
+ """Script tool call -> compaction summary -> final answer."""
+ if request.ordinal == 1:
+ item = {
+ "type": "function_call",
+ "id": "fc_midturn_1",
+ "call_id": "call_midturn_1",
+ "name": "todo_read",
+ "arguments": "{}",
+ "status": "completed",
+ }
+ # Real high-effort Responses tool loops return reasoning immediately
+ # before the function call. It is current-turn history here, but once
+ # compact() appends its synthetic user turn it must be pruned before the
+ # full SSE summary resend.
+ return response_events(
+ [active_reasoning_item(), item],
+ "resp_midturn_1",
+ MIDTURN_TOTAL_TOKENS,
+ )
+ if request.ordinal == 2:
+ return response_events(
+ message_item(MIDTURN_SUMMARY, "msg_midturn_summary"),
+ "resp_midturn_summary",
+ 1_100,
+ )
+ return response_events(
+ message_item(MIDTURN_FINAL, "msg_midturn_final"),
+ f"resp_midturn_{request.ordinal}",
+ 1_300,
+ )
+
+
+ def transactional_reasoning_item() -> dict:
+ encrypted = TRANSACTIONAL_REASONING_MARKER + "R" * (
+ MIDTURN_REASONING_BYTES - len(TRANSACTIONAL_REASONING_MARKER)
+ )
+ return {
+ "type": "reasoning",
+ "id": "rs_transactional_1",
+ "summary": [],
+ "encrypted_content": encrypted,
+ }
+
+
+ def transactional_events(request: RecordedRequest) -> list[dict]:
+ """Script tool call -> empty summary -> answer from restored live history."""
+ if request.ordinal == 1:
+ call = {
+ "type": "function_call",
+ "id": "fc_transactional_1",
+ "call_id": TRANSACTIONAL_CALL_ID,
+ "name": "todo_read",
+ "arguments": "{}",
+ "status": "completed",
+ }
+ return response_events(
+ [transactional_reasoning_item(), call],
+ "resp_transactional_1",
+ MIDTURN_TOTAL_TOKENS,
+ )
+ if request.ordinal == 2:
+ # A syntactically valid Responses answer with no summary text exercises
+ # compact()'s EmptySummary rollback, rather than a transport failure.
+ return response_events(
+ message_item("", "msg_transactional_empty_summary"),
+ "resp_transactional_empty_summary",
+ 1_100,
+ )
+ return response_events(
+ message_item(TRANSACTIONAL_FINAL, "msg_transactional_final"),
+ f"resp_transactional_{request.ordinal}",
+ 1_300,
+ )
+
+
+ def user_text(item: object) -> str | None:
+ if not isinstance(item, dict) or item.get("role") != "user":
+ return None
+ content = item.get("content")
+ return content if isinstance(content, str) else None
+
+
+ def assert_compaction_meter(label: str, rendered: str) -> None:
+ match = COMPACTING_RE.search(rendered)
+ if match is None:
+ raise AssertionError(
+ f"{label}: server-reported usage did not trigger pre-send "
+ f"compaction:\n{rendered}"
+ )
+ observed = int(match.group(1))
+ # The provider sample is the lower bound. A tool result appended after that
+ # sample should increase the anchored effective meter slightly, while the
+ # compaction still runs before the advertised context wall.
+ if not MIDTURN_TOTAL_TOKENS <= observed < MIDTURN_CONTEXT_TOKENS:
+ raise AssertionError(
+ f"{label}: compacted at {observed} tokens, expected at least the "
+ f"{MIDTURN_TOTAL_TOKENS} provider sample and below the "
+ f"{MIDTURN_CONTEXT_TOKENS} context window"
+ )
+
+
+ def run_scenario(
+ label: str,
+ tmp: str,
+ codex_home: str,
+ port: int,
+ mock: CodexMock,
+ extra_env: dict,
+ expect_ws: int,
+ expect_sse: int,
+ health: str,
+ ) -> int:
+ env = {
+ "HOME": tmp,
+ "CODEX_HOME": codex_home,
+ "CODEGRAFF_API_KEY": "local-pty-test",
+ "GRAFF_FLEET": "off",
+ "GRAFF_NO_TELEMETRY": "1",
+ "GRAFF_CODEX_URL": f"http://127.0.0.1:{port}/backend-api/codex/responses",
+ }
+ env.update(extra_env)
+ # PtySession builds the child env from os.environ.copy(), so ambient
+ # transport/credential knobs (an exported GRAFF_CODEX_WS=off, a leftover
+ # GRAFF_WS_FORCE_FAIL_ONCE=1, CODEX_DISABLED, ...) would leak into every
+ # scenario and flip its transport. Strip all ambient GRAFF_*/CODEX_* the
+ # scenario does not set itself; unset_env is applied AFTER env, so keys we
+ # set deliberately must be excluded.
+ ambient = tuple(
+ k
+ for k in os.environ
+ if (k.startswith("GRAFF_") or k.startswith("CODEX_") or k == "NO_COLOR")
+ and k not in env
+ )
+ with PtySession(
+ GRAFF,
+ ["--model", "codex", "--no-telemetry"],
+ cwd=tmp,
+ env=env,
+ unset_env=ambient,
+ timeout=20.0,
+ ) as session:
+ session.wait_for_literal("] ›")
+ cursor = len(session.raw)
+ session.send_line("ping")
+ session.wait_for_literal(REPLY_TEXT, start=cursor)
+ session.wait_for(METER_RE, start=cursor)
+ meter = METER_RE.search(terminal_text(bytes(session.raw[cursor:])))
+ used = int(meter.group(1)) * (1000 if meter.group(2) == "k" else 1)
+ ctx_k, pct, compact_k = map(int, meter.group(3, 4, 5))
+ if used <= 0 or not 0 <= pct <= 100:
+ raise AssertionError(
+ f"{label}: invalid context meter values used={used} pct={pct}"
+ )
+ if ctx_k <= 0 or not 79 * ctx_k <= 100 * compact_k <= 81 * ctx_k:
+ raise AssertionError(
+ f"{label}: inconsistent meter context={ctx_k}k compact@={compact_k}k"
+ )
+ if mock.ws_turns != expect_ws or mock.sse_turns != expect_sse:
+ raise AssertionError(
+ f"{label}: transport mismatch — ws_turns={mock.ws_turns} "
+ f"sse_turns={mock.sse_turns}, expected ws={expect_ws} sse={expect_sse}"
+ )
+ cursor = len(session.raw)
+ session.send_line("/models health")
+ session.wait_for_literal(f"Codex transport: {health}", start=cursor)
+ session.wait_for_literal("] ›", start=cursor)
+ session.send_key("ctrl-d")
+ result = session.read_until_exit(5.0)
+ if result.timed_out or result.exit_code != 0:
+ raise SystemExit(
+ f"{label}: REPL did not exit cleanly: "
+ f"exit={result.exit_code} timed_out={result.timed_out}"
+ )
+ return ctx_k * 1000
+
+
+ def assert_midturn_requests(mock: CodexMock) -> None:
+ requests = mock.recorded_requests()
+ if len(requests) != 3:
+ raise AssertionError(
+ f"midturn: expected exactly 3 model requests, got {len(requests)}: {requests!r}"
+ )
+ first, compact, final = requests
+ if any("max_output_tokens" in request.body for request in requests):
+ raise AssertionError("midturn: Responses requests must omit max_output_tokens")
+ transports = [request.transport for request in requests]
+ if transports != ["ws", "sse", "ws"]:
+ raise AssertionError(f"midturn: expected WS -> SSE -> WS, got {transports!r}")
+ if mock.ws_turns != 2 or mock.sse_turns != 1 or mock.ws_connections != 2:
+ raise AssertionError(
+ "midturn: expected two turns on two fresh WS connections plus one SSE "
+ f"turn; ws_turns={mock.ws_turns} sse_turns={mock.sse_turns} "
+ f"ws_connections={mock.ws_connections}"
+ )
+ if first.connection_id == final.connection_id:
+ raise AssertionError("midturn: final request reused the pre-compaction WS")
+ for request in requests:
+ if "previous_response_id" in request.body:
+ raise AssertionError(
+ f"midturn: request {request.ordinal} carried stale previous_response_id: "
+ f"{request.body['previous_response_id']!r}"
+ )
+
+ first_input = first.body.get("input")
+ if (
+ first.body.get("type") != "response.create"
+ or not isinstance(first_input, list)
+ or not any(user_text(item) == MIDTURN_PROMPT for item in first_input)
+ or "tools" not in first.body
+ ):
+ raise AssertionError(
+ f"midturn: first WS request was not full tool-enabled input: {first.body!r}"
+ )
+
+ compact_input = compact.body.get("input")
+ compact_texts = (
+ [text for item in compact_input if (text := user_text(item)) is not None]
+ if isinstance(compact_input, list)
+ else []
+ )
+ compact_types = (
+ [item.get("type") for item in compact_input if isinstance(item, dict)]
+ if isinstance(compact_input, list)
+ else []
+ )
+ compact_json = json.dumps(compact.body, separators=(",", ":"))
+ if "reasoning" in compact_types or MIDTURN_REASONING_MARKER in compact_json:
+ raise AssertionError(
+ "midturn: SSE compaction request retained the active-loop reasoning item"
+ )
+ if (
+ compact.connection_id is not None
+ or "tools" in compact.body
+ or MIDTURN_PROMPT not in compact_texts
+ or "function_call" not in compact_types
+ or "function_call_output" not in compact_types
+ or not any(
+ text.startswith("Summarize this entire conversation")
+ for text in compact_texts
+ )
+ ):
+ raise AssertionError(
+ f"midturn: compaction request was not a full, tool-free SSE summary request: {compact.body!r}"
+ )
+
+ final_input = final.body.get("input")
+ final_texts = (
+ [text for item in final_input if (text := user_text(item)) is not None]
+ if isinstance(final_input, list)
+ else []
+ )
+ if (
+ final.body.get("type") != "response.create"
+ or not isinstance(final_input, list)
+ or len(final_input) != 1
+ or len(final_texts) != 1
+ or not final_texts[0].startswith(
+ "Context: the earlier conversation was compacted"
+ )
+ or MIDTURN_SUMMARY not in final_texts[0]
+ or "tools" not in final.body
+ ):
+ raise AssertionError(
+ "midturn: final WS request did not fully re-anchor on the handoff: "
+ f"{final.body!r}"
+ )
+
+
+ def assert_transactional_requests(mock: CodexMock) -> None:
+ requests = mock.recorded_requests()
+ if len(requests) != 3:
+ raise AssertionError(
+ "transactional: expected exactly 3 model requests, "
+ f"got {len(requests)}: {requests!r}"
+ )
+ first, compact, final = requests
+ if any("max_output_tokens" in request.body for request in requests):
+ raise AssertionError("transactional: Responses requests must omit max_output_tokens")
+ transports = [request.transport for request in requests]
+ if transports != ["ws", "sse", "ws"]:
+ raise AssertionError(
+ f"transactional: expected WS -> SSE -> WS, got {transports!r}"
+ )
+ if mock.ws_turns != 2 or mock.sse_turns != 1 or mock.ws_connections != 2:
+ raise AssertionError(
+ "transactional: expected two turns on two fresh WS connections plus "
+ f"one SSE turn; ws_turns={mock.ws_turns} sse_turns={mock.sse_turns} "
+ f"ws_connections={mock.ws_connections}"
+ )
+ if first.connection_id == final.connection_id:
+ raise AssertionError(
+ "transactional: final request reused the pre-compaction WS"
+ )
+ for request in requests:
+ if "previous_response_id" in request.body:
+ raise AssertionError(
+ f"transactional: request {request.ordinal} carried stale "
+ f"previous_response_id: {request.body['previous_response_id']!r}"
+ )
+
+ first_input = first.body.get("input")
+ if (
+ first.body.get("type") != "response.create"
+ or not isinstance(first_input, list)
+ or not any(user_text(item) == TRANSACTIONAL_PROMPT for item in first_input)
+ or "tools" not in first.body
+ ):
+ raise AssertionError(
+ "transactional: first WS request was not full tool-enabled input: "
+ f"{first.body!r}"
+ )
+
+ compact_input = compact.body.get("input")
+ compact_texts = (
+ [text for item in compact_input if (text := user_text(item)) is not None]
+ if isinstance(compact_input, list)
+ else []
+ )
+ compact_json = json.dumps(compact.body, separators=(",", ":"))
+ if (
+ compact.connection_id is not None
+ or "tools" in compact.body
+ or TRANSACTIONAL_PROMPT not in compact_texts
+ or TRANSACTIONAL_REASONING_MARKER in compact_json
+ or not any(
+ text.startswith("Summarize this entire conversation")
+ for text in compact_texts
+ )
+ ):
+ raise AssertionError(
+ "transactional: second request was not the pruned, synthetic SSE "
+ f"summary request: {compact.body!r}"
+ )
+
+ final_input = final.body.get("input")
+ final_texts = (
+ [text for item in final_input if (text := user_text(item)) is not None]
+ if isinstance(final_input, list)
+ else []
+ )
+ final_objects = (
+ [item for item in final_input if isinstance(item, dict)]
+ if isinstance(final_input, list)
+ else []
+ )
+ reasoning = [
+ item
+ for item in final_objects
+ if item.get("type") == "reasoning" and item.get("id") == "rs_transactional_1"
+ ]
+ calls = [
+ item
+ for item in final_objects
+ if item.get("type") == "function_call"
+ and item.get("id") == "fc_transactional_1"
+ and item.get("call_id") == TRANSACTIONAL_CALL_ID
+ ]
+ outputs = [
+ item
+ for item in final_objects
+ if item.get("type") == "function_call_output"
+ and item.get("call_id") == TRANSACTIONAL_CALL_ID
+ and isinstance(item.get("output"), str)
+ and len(item["output"]) > 0
+ ]
+ leaked_summary_response = any(
+ item.get("id") == "msg_transactional_empty_summary" for item in final_objects
+ )
+ if (
+ final.body.get("type") != "response.create"
+ or not isinstance(final_input, list)
+ or "tools" not in final.body
+ or TRANSACTIONAL_PROMPT not in final_texts
+ or any(
+ text.startswith("Summarize this entire conversation")
+ for text in final_texts
+ )
+ or not any(
+ isinstance(item.get("encrypted_content"), str)
+ and item["encrypted_content"].startswith(TRANSACTIONAL_REASONING_MARKER)
+ and len(item["encrypted_content"]) == MIDTURN_REASONING_BYTES
+ for item in reasoning
+ )
+ or len(calls) != 1
+ or len(outputs) != 1
+ or leaked_summary_response
+ ):
+ raise AssertionError(
+ "transactional: final WS request did not restore the original prompt, "
+ "reasoning, function call, and output without the synthetic compact "
+ f"instruction: {final.body!r}"
+ )
+
+
+ def run_midturn_compaction_scenario(
+ tmp: str, codex_home: str, port: int, mock: CodexMock
+ ) -> None:
+ env = {
+ "HOME": tmp,
+ "CODEX_HOME": codex_home,
+ "CODEGRAFF_API_KEY": "local-pty-test",
+ "GRAFF_FLEET": "off",
+ "GRAFF_NO_TELEMETRY": "1",
+ "GRAFF_CODEX_URL": f"http://127.0.0.1:{port}/backend-api/codex/responses",
+ }
+ ambient = tuple(
+ key
+ for key in os.environ
+ if (key.startswith("GRAFF_") or key.startswith("CODEX_") or key == "NO_COLOR")
+ and key not in env
+ )
+ with PtySession(
+ GRAFF,
+ ["--model", "codex", "--no-telemetry"],
+ cwd=tmp,
+ env=env,
+ unset_env=ambient,
+ timeout=20.0,
+ ) as session:
+ session.wait_for_literal("] ›")
+ cursor = len(session.raw)
+ session.send_line(MIDTURN_PROMPT)
+ session.wait_for_literal(MIDTURN_FINAL, start=cursor)
+ session.wait_for_literal("history compacted to a", start=cursor)
+ session.pump_for(0.1)
+ rendered = terminal_text(bytes(session.raw[cursor:]))
+ assert_compaction_meter("midturn", rendered)
+ assert_midturn_requests(mock)
+ session.send_key("ctrl-d")
+ result = session.read_until_exit(5.0)
+ if result.timed_out or result.exit_code != 0:
+ raise SystemExit(
+ "midturn: REPL did not exit cleanly: "
+ f"exit={result.exit_code} timed_out={result.timed_out}"
+ )
+
+
+ def run_transactional_compaction_scenario(
+ tmp: str, codex_home: str, port: int, mock: CodexMock
+ ) -> None:
+ env = {
+ "HOME": tmp,
+ "CODEX_HOME": codex_home,
+ "CODEGRAFF_API_KEY": "local-pty-test",
+ "GRAFF_FLEET": "off",
+ "GRAFF_NO_TELEMETRY": "1",
+ "GRAFF_CODEX_URL": f"http://127.0.0.1:{port}/backend-api/codex/responses",
+ }
+ ambient = tuple(
+ key
+ for key in os.environ
+ if (key.startswith("GRAFF_") or key.startswith("CODEX_") or key == "NO_COLOR")
+ and key not in env
+ )
+ with PtySession(
+ GRAFF,
+ ["--model", "codex", "--no-telemetry"],
+ cwd=tmp,
+ env=env,
+ unset_env=ambient,
+ timeout=20.0,
+ ) as session:
+ session.wait_for_literal("] ›")
+ cursor = len(session.raw)
+ session.send_line(TRANSACTIONAL_PROMPT)
+ session.wait_for_literal(
+ "compaction failed: empty summary, history unchanged", start=cursor
+ )
+ session.wait_for_literal(TRANSACTIONAL_FINAL, start=cursor)
+ session.pump_for(0.1)
+ rendered = terminal_text(bytes(session.raw[cursor:]))
+ assert_compaction_meter("transactional", rendered)
+ if "history compacted to a" in rendered:
+ raise AssertionError(
+ f"transactional: empty summary was incorrectly installed:\n{rendered}"
+ )
+ assert_transactional_requests(mock)
+ session.send_key("ctrl-d")
+ result = session.read_until_exit(5.0)
+ if result.timed_out or result.exit_code != 0:
+ raise SystemExit(
+ "transactional: REPL did not exit cleanly: "
+ f"exit={result.exit_code} timed_out={result.timed_out}"
+ )
-
-
diff --cc src/cli.zig
index 19772c8a,b554e5bc..013e7e08
--- a/src/cli.zig
+++ b/src/cli.zig
@@@ -21,11 -21,6 +21,12 @@@ const harness_version = root.harness_ve
pub const changelog_text =
\\What's new
\\──────────
+ \\0.0.215
+ \\ • Local learning can race multiple prompt variants, rank correctness before tool economy, and expose only the winner to a hidden holdout
+ \\ • Runs checkpoint safely, keep promotion manual by default, and can bundle an aggregate-only signed grade submission
+ \\ • Aggregate receipts expire after 30 days and can be deleted remotely without deleting local evidence or requiring telemetry consent
++ \\ • Remote MCP servers now support Streamable HTTP, OAuth discovery/PKCE/refresh, and an opt-out core Smolify connection
+ \\
\\0.0.209
\\ • Kimi Code now follows each live catalog model's native or Anthropic beta protocol, auth style, context, and thinking metadata
\\ • Native Kimi tool schemas are normalized to Moonshot's stricter validator; OAuth requests carry the current Kimi Code identity headers
@@@ -66,9 -61,10 +67,11 @@@ pub const usage_text
\\ graff key set <provider> <key> store a key (macOS Keychain, else 0600 file)
\\ graff key list show which providers have keys
\\ graff models [refresh] list the live catalog; refresh Codex + models.dev metadata
- \\ graff mcp add <name> -- <cmd> add an MCP server to .mcp.json
+ \\ graff mcp add <name> -- <cmd> add a stdio MCP server to .mcp.json
+ \\ graff mcp add <name> --url <url> add a Streamable HTTP MCP server
+ \\ graff mcp login <name> OAuth login for a remote MCP server
\\ graff mcp list configured MCP servers
+ \\ graff learn [help] local mutate/evaluate/promote/rollback engine
\\ graff worktree list list the per-tab worktrees created by -w
\\ graff worktree merge <name> squash-land worktree-<name> onto the current branch + clean up
\\ graff worktree remove <name> discard worktree-<name> (drops its scratch work) + delete the branch