Repository navigation
feat(harness): key-safe client, caller-bound waiter, fallback flag - #39
Merged
Merged
Conversation
Port from the private harness, 2026-11-18 pass: mcp-http-call.py redacts every key form before it clips server text; await-approval gains opt-in terminal refusals and per-kind key connectors; a model-fallback Stop hook; the briefing's effort line follows Claude Code's resolution order; suites that cannot run exit 77; resume text verifies DO NOT and HOLD lines; remote-session pane targets use =NAME:. Second-vendor review applied.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The code half of this month's port from the private harness. The docs half is #38.
mcp-http-call.pyredacts before it clips. Five error paths sliced server text first and scrubbed after, so a key that straddled the cut survived as a prefix. All server text the client shows (error bodies, tool answers, the call preview,listoutput) now has every form of the key redacted (raw, and JSON-escaped once or twice), then line breaks escaped so it stays on one line, then clipped.await-approval, opt-in. Where a server binds each request to the credential that made it, a poll with another key gets "not this caller", which the waiter retried five times as a gateway blip. A copy that lists those codes in the newterminal_refusalsconfig ends the wait on the first such answer (exit 2,state=<code>), naming the connector, where the key came from and at most its last four characters, and never offers another key. Refusals are read only from structured fields (the tool wrapper and envelope before the result) or from the oneNOTE:line the client prints, which carries the key provenance the client captured when it loaded the key. A kind's newkey_connectorlimits the~/.claude.jsonfallback to that one entry. Omitted or emptyterminal_refusalskeeps today's behavior. The client and the waiter ship and roll back together.hooks/model-fallback-watch.sh, new. When Claude Code moves a refused request to another model, the hook flags it once at Stop so the agent tells the Operator which work ran on the fallback model. Lock-protected ledger, checkpointed transcript offsets (a replaced or rewritten transcript is read again), owner-only state, a repair of an interrupted ledger row under the lock. The Stage-1 settings already register it behindtest -x.MODEL_FALLBACK_WATCH=0turns it off.effortLevelanywhere in the settings file, which since the per-model Stage-1 levels can be another model's. It now follows Claude Code's order (env, launch flag, this model's saved level in the active profile, the model default) and labels the source. The launch flag is read from at most 16 parent processes, keeping only a short alphanumeric--effortvalue.=NAME:. On tmux 3.6 the bare=NAMEmissed the pane, dropping the launch line. The launcher waits for the pane (about 5 s at most) and returnsERR_TMUXwhen a step fails instead of reporting OK.bin/README.md,remote-sessions/README.md,DEPLOYMENT.md,README.md,CONTEXT/model-roles.md(names the new hook),CHANGELOG.md.Rolling back
MODEL_FALLBACK_WATCH=0turns off the hook on an installed copy;"terminal_refusals": []turns off the new waiter classification. Restoremcp-http-call.pyandawait-approvaltogether.Checks
mainfirst: waiter 236 and client 140 cases (70 and 37 of the new assertions failed onmain; 16 hand-injected defects all caught), fallback hook 54 cases (mutants each caught), effort line 62 (48 failed onmain), tmux targets 29 and a real tmux 3.6 run on a private socket (both failed onmain), resume text 25 (1 failed onmain), and the five exit-77 suites (exit 0 onmainwith the prerequisite hidden, exit 77 now).CONTRIBUTING.mdstep 2 throughsandbox-run, with the Stage-1 settings bound forverify-ops-selftest.sh: 68 of 69 pass;t3-html-render-test.pyfails only because the sandbox hidesnode(installed under the home directory) and passes when run directly, as onmain; both PowerShell suites pass.HOMEinsandbox-run:deploy.sh --no-systemtwice,verify-ops.sh30 ok, 0 warn, 0 fail; then the Stop command exactly as the Stage-1 settings register it, against a synthetic fallback record: one block, none on the repeat, one ledger row, state directory 700 and ledger 600.OPS_DIRon this branch: the OPS model-rules parity test passes; one failure reads the host's pyenv versions and fails the same way onmain; one opt-in skip.gitleaks git --redactover this branch's full history: no leaks. The tests build their fake keys at run time, so no file holds a literal in a credential's shape.secrets-scan.sh CONTEXT SKILLS .claude-config: exit 0.Review
Second-vendor review of the written plan before the build, then of the integrated branch, one round: integrate, with fixes applied in this commit (the refusal check reads the tool wrapper before unwrapping; the note carries the key provenance captured at load time, so a key rotated mid-poll is named correctly; a note that arrives during a stalled cleanup is kept; the hook checkpoints each transcript and repairs an interrupted ledger row; the briefing stops at
--and reads only the active profile; failed tmux steps returnERR_TMUX). After the review, the test fixtures' fake keys were changed to be built at run time (tests only; the same cases pass and the redaction cases still fail onmain).Not verified here: Windows, a live MCP gateway. Left open: two concurrent launches of one remote-session name can register the losing session id (the registry write precedes the tmux create), and an in-place transcript rewrite confined to bytes the hook does not sample before its cursor can hide a fallback event.
Models: Opus 5.5, GPT-6.2 Sol (plan review, then code review, 1 round). Harness: Claude Code in T3 Code.