graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
Merge typed sign-in recovery for v0.302.40
justrachfa5e2ef73c68
diff --cc docs/adr/README.mdindex 10aac396,c3636193..ee83d09c--- a/docs/adr/README.md+++ b/docs/adr/README.md@@@ -272,31 -272,7 +272,32 @@@ record only when you need the evidence| [0243](0243-repo-context-rides-as-an-input-item-on-responses.md) | On the Responses wire for codex, chatgpt-new and openai, root turns send the project-instructions section and the layout as one developer input item ahead of the conversation, so the instructions are byte-identical across repos and cache on turn 1. || [0244](0244-saved-workspaces-have-durable-discovery.md) | Remember saved workspace roots locally; remote picker targets are workspace-qualified, and resume must enter the selected tree before restoring it. || [0245](0245-fullscreen-tui-is-an-external-client.md) | The fullscreen UI is maintained separately; `graff tui` launches installed `graff-tui` before engine startup, sibling first then PATH, without downloading. TTY `graff repl` uses the line REPL. Supersedes 0041, 0042 and the fullscreen portion of 0142. |-| [0246](0246-acp-reauth-is-route-specific.md) | Terminal ChatGPT auth rejection carries fixed route-specific recovery metadata: ACP v1 `-32000` + `error.data`, v2 failed idle `_meta["graff/reauth"]`; `graff login chatgpt-new` repairs the new store, `codex login` the legacy one. Retry and non-auth error behavior stay unchanged. |+| [0246](0246-jev-picks-each-turns-effort-alongside-the-first-request.md) | On an eligible model at the default effort, graff asks Jev for the turn's effort alongside the first request; the pick applies from the next request, holds for that turn, is never saved, and never overrides a user's effort. `chatgpt-new` GPT-6 models are eligible. |+| [0247](0247-parked-work-is-named-above-the-prompt.md) | A parked turn names the work it waits on: the standing block draws `↻ waiting on <work> — graff continues when it finishes` while a job or agent that will wake the session runs, the yield prints only for a server, and a wake prints what finished before continuing. |+| [0248](0248-commentary-prose-does-not-tighten-the-stall-budget.md) | Commentary prose (the heads-up before a tool-call batch, which the server holds open until it releases the calls) counts as visible text but does not tighten the stall budget; final-answer prose and whitelisted tool-argument prose still do. Refines 0241. |+| [0249](0249-a-spec-task-ends-at-its-own-tests.md) | The work note no longer says a green public test is not the whole spec: it made the model write an extra verification script on every spec task without changing the pass rate. Spec tasks end at their own tests; the lean note is unchanged. Refines 0024. |+| [0250](0250-pr-publication-is-not-gated.md) | PR publication is not gated: no local-check, head-CI or claim-review preflight and no completion obligation; drafts complete like any task. Artifact claims and disclosure policy are unchanged. Supersedes 0120, 0123, 0126, 0133 and parts of 0100/0104. |+| [0251](0251-tool-results-inline-up-to-64-kib.md) | Tool results inline up to 64 KiB (was 16 KiB); `effectiveThreshold` still clamps to half the context window, so small windows are unchanged. The codedb small-read exemption follows the same number. |+| [0253](0253-an-interactive-session-signs-in-to-chatgpt-again.md) | When a ChatGPT request is rejected and the refresh cannot replace the token, an interactive root session opens the browser sign-in, waits up to three minutes and retries once; `-p`, piped, `--json`, ACP and sub-agents never do. One unfinished sign-in ends it for the process. |+| [0254](0254-imported-conversations-use-the-configured-route.md) | Imported Claude history uses the configured graff provider and credentials; source models are metadata, and foreign tool results remain historical receipts. |+| [0262](0262-a-follow-up-ends-a-blocking-output-wait.md) | A queued follow-up ends a blocking `action=output` wait like Esc does (the job keeps running and still reports on exit); an ACP prompt arriving mid-turn raises that follow-up without cancelling the turn. Refines ADR 0010. |+| [0255](0255-codegraff-claude-uses-native-messages.md) | Claude aliases on codegraff use the native Messages endpoint; `isClaudeApi` is the one predicate for the real Claude wire. |+| [0256](0256-gemini-takes-fewer-requests-per-task.md) | Gemini models get a working note (chained shell steps, no read-backs, no pasted files, check computed answers) and may batch `attempt_completion` with a final check or write; the completion is recorded only if every batched call succeeded. |+| [0257](0257-a-slimmed-comment-list-names-its-issue.md) | A slimmed MCP comment list keeps the issue id its rows share (`{issue, n, latest_author}`), so parallel results name what they describe. |+| [0258](0258-gemini-chat-sends-repo-context-once.md) | On the Codegraff chat wire, Gemini root turns send the project instructions and layout as the conversation's first user message (ADR 0243's split), so the system prompt every request repeats no longer carries them. |+| [0259](0259-openai-routes-compact-only-server-side.md) | First-party Responses routes (direct API, Codegraff GPT, ChatGPT plan) compact only server-side: no client-summary fallback while the server arm is on. A compaction item's `encrypted_content` is metered at 16 bytes/token, not as text, so a blob-anchored history does not re-compact every step. |+| [0260](0260-clef-compaction-replaces-client-summary.md) | `GRAFF_CLEF_COMPACT=1` routes client-summary compactions through the gateway's server-side `POST /v1/compact` (Clef decision-model pruning, text verbatim); OpenAI-family server paths are untouched and any failure falls back to the summary. |+| [0261](0261-client-summary-stays-the-compactor.md) | The client summary stays the compactor: `GRAFF_CLEF_COMPACT` defaults off (Clef rarely pruned and mostly fell back to the summary in measurement); first-party Responses routes use only the provider's own compaction. Supersedes 0260's default. |+| [0270](0270-a-closed-stdio-mcp-server-restarts-on-its-next-call.md) | A stdio MCP server whose connection closes goes back to dormant with its launch config and restarts on its next call; the failed call is never replayed, and after two restarts in a session its tools are withdrawn as before. |+| [0278](0278-t3-code-acp-profile.md) | An ACP client named `t3-code…` gets a profile: slash commands are the first prompt block, the client's `cwd` is never swapped for an auto-isolated tree, a `model` config option lists reachable models, and `/model` and `/yolo` are not advertised. |+| [0280](0280-mcp-servers-report-state-and-reconnect.md) | Every configured MCP server has one status row (`graff mcp status --json`, `/mcp`); `graff mcp reconnect` / `/mcp reconnect` run a real handshake and refresh its catalog; `graff mcp enable|disable` live in `~/.codegraff/mcp-state.json`; the catalog cache keys on cwd + env, and server `env` overlays graff's own. |+| [0281](0281-anthropic-console-sign-in-reads-the-sdk-profile.md) | Anthropic Console sign-in: graff reads the `user_oauth` profile Anthropic's CLI writes (`ant auth login`), in the SDK's precedence (API key wins), sends it as Bearer, and refreshes through `ant auth print-credentials`; `graff login anthropic` runs `ant auth login`. No claude.ai subscription login. |+| [0282](0282-claude-system-breakpoint-closes-before-the-repo-context.md) | On Claude, the system prompt is two text blocks with the same bytes: the cache breakpoint closes the static instructions, before the project instructions and layout, so every repo shares the tools + instructions prefix. |+| [0283](0283-agents-prepare-and-linked.md) | New task worktrees symlink the gitignored paths `.agents/linked` lists from the main checkout and run `.agents/prepare` when `.graff/workspace.toml` names no setup script. |+| [0284](0284-output-limits-are-recovery-not-completion.md) | Output limits continue with bounded recovery; empty replies back off; one-shots expose a saved-session handle and classified result without claiming unknown costs or exactly-once replay. |+| [0271](0271-gemini-interactions-continue-the-stored-interaction.md) | Direct Gemini (Interactions) requests are stored and continue the last Interaction with `previous_interaction_id` plus only the new steps while a content hash proves graff's history extends it; any rewrite, model switch or rejected id falls back to a full replay; usage meters the whole prompt from the per-invocation counts. Tool choice is `validated`, `minimal` thinking maps to `low`, thought summaries stream, and Gemini 3.1 Pro with tools uses its custom-tools variant. `GRAFF_INTERACTIONS_STORE=0` keeps it stateless. |+| [0272](0272-compaction-never-summarizes-unread-tool-results.md) | A compaction never summarizes tool results the model has not read: the cut keeps the newest model turn and its results verbatim, and the pre-send gate sends a batch that dominates the context and compacts after the model reads it. Summaries copy exact values. Interactions `user_input` steps are turn boundaries. Gemini compacts by default at 80% capped at 300k tokens. |++| [0285](0285-acp-reauth-is-route-specific.md) | Terminal ChatGPT auth rejection carries fixed route-specific recovery metadata: ACP v1 `-32000` + `error.data`, v2 failed idle `_meta["graff/reauth"]`; `graff login chatgpt-new` repairs the new store, `codex login` the legacy one. Retry and non-auth error behavior stay unchanged. |## When to write onediff --cc src/acp.zigindex ac06323f,308a5653..857c0e8f--- a/src/acp.zig+++ b/src/acp.zig@@@ -229,7 -238,7 +224,8 @@@ pub fn runAcpCommand(gpa: Allocator, iovar d: Dispatch = .{.turn = LiveTurn.run,.error_message = LiveTurn.errorMessage,+ .cancel_info = LiveTurn.cancelInfo,+ .error_recovery = LiveTurn.errorRecovery,.ctx = &live,.seed = @bitCast(util.unixMs(io)),.slash = liveSlash,diff --cc src/acp_engine.zigindex 770bcb8d,4c3e64f3..66c583a5--- a/src/acp_engine.zig+++ b/src/acp_engine.zig@@@ -82,12 -77,9 +82,13 @@@ pub const Dispatch = structextra: ?ExtraFn = null,config: ?ConfigFn = null,set_config: ?SetConfigFn = null,+ /// The `model` option; only T3 Code's profile offers it (acp_model_option.zig).+ model_config: ?ConfigFn = null,+ set_model: ?SetConfigFn = null,mcp_servers: ?McpServersFn = null,error_message: ?*const fn (ctx: *anyopaque, err: anyerror) []const u8 = null,+ cancel_info: ?*const fn (ctx: *anyopaque) ?Cancellation = null,+ error_recovery: ?*const fn (ctx: *anyopaque, err: anyerror) ?@import("auth_recovery.zig").Recovery = null,/// Live CLI: adopt the client's cwd, report `_meta["graff/worktree"]` (acp_workspace.zig).workspace: ?acp_workspace.Env = null,/// ACP v1 draft subagent updates are opt-in at initialize.@@@ -164,17 -166,16 +165,22 @@@ pub fn stripSgr(arena: Allocator, s: []}fn turnError(d: *Dispatch, w: *Io.Writer, req: proto.Request, err: anyerror) !void {- if (err == error.Interrupted or err == error.Canceled)+ if (err == error.Interrupted or err == error.Canceled) {+ if (d.cancel_info) |read| if (read(d.ctx)) |info|+ return respond(w, req, .{ .stopReason = "cancelled", ._meta = .{+ .@"graff/cancelSource" = info.source,+ .@"graff/cancelMessage" = info.message,+ } });return respond(w, req, .{ .stopReason = "cancelled" });+ }if (err == error.RunBudgetExhausted)return respond(w, req, .{ .stopReason = "max_turn_requests" });- return respondError(w, req, err_internal, if (d.error_message) |message| message(d.ctx, err) else @errorName(err));+ const message = if (d.error_message) |describe| describe(d.ctx, err) else @errorName(err);+ if (d.error_recovery) |recover| if (recover(d.ctx, err)) |data| {+ if (req.id != null) try proto.writeErrorData(w, req.id, err_auth_required, message, data);+ return;+ };+ return respondError(w, req, err_internal, message);}fn promptTurn(d: *Dispatch, arena: Allocator, w: *Io.Writer, req: proto.Request) !void {diff --cc src/main.zigindex f12feb90,a797df06..b8e8a577--- a/src/main.zig+++ b/src/main.zig@@@ -50,10 -50,10 +50,10 @@@ const learn_eval = @import("learn_eval.const learn_cli = @import("learn_cli.zig");test {_ = .{ @import("http2_buffered.zig"), @import("clipboard_native.zig"), @import("clipboard_edge_tests.zig"), @import("clipboard_failure_tests.zig"), @import("process_runner_clipboard_tests.zig") };- _ = @import("server_orphan.zig");+ _ = .{ @import("server_orphan.zig"), @import("term_sender.zig") };_ = @import("repo_transaction.zig");- _ = .{ @import("pr_command.zig"), @import("pr_evidence.zig"), @import("pr_verify.zig"), @import("artifact_repository.zig"), @import("artifact_claim_ledger.zig"), @import("artifact_claim_store.zig"), @import("artifact_claim_stale.zig"), @import("pr_review_input_tests.zig"), @import("artifact_claim_unresolved.zig") };+ _ = .{ @import("pr_command.zig"), @import("pr_evidence.zig"), @import("artifact_repository.zig"), @import("artifact_claim_ledger.zig"), @import("artifact_claim_store.zig"), @import("artifact_claim_stale.zig"), @import("artifact_claim_unresolved.zig"), @import("artifact_claim_inventory.zig") };- _ = @import("argstream_citation_tests.zig"); // unit_tests' root is main.zig only, so reference every split-out module or its tests silently never run+ _ = .{ @import("argstream_citation_tests.zig"), @import("acp_reauth_tests.zig") }; // unit_tests' root is main.zig only, so reference every split-out module or its tests silently never run_ = @import("codex_node_repl.zig");_ = pricing;_ = models_cache;