Skip to content

feat(harness): key-safe client, caller-bound waiter, fallback flag - #39

Merged
Exploitacious merged 1 commit into
mainfrom
chore/ops-port-code-2026-11-18
Nov 18, 2026
Merged

Exploitacious merged 1 commit into
mainfrom
chore/ops-port-code-2026-11-18

Conversation

@Exploitacious

Copy link
Copy Markdown
Owner

What

The code half of this month's port from the private harness. The docs half is #38.

  • mcp-http-call.py redacts 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, list output) 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.
  • Terminal refusals in 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 new terminal_refusals config 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 one NOTE: line the client prints, which carries the key provenance the client captured when it loaded the key. A kind's new key_connector limits the ~/.claude.json fallback to that one entry. Omitted or empty terminal_refusals keeps 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 behind test -x. MODEL_FALLBACK_WATCH=0 turns it off.
  • The briefing's effort line printed the first effortLevel anywhere 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 --effort value.
  • "Did not run" is never green. Five suites printed SKIP and exited 0 when a prerequisite was missing; they exit 77 with the reason.
  • Resume text asks the agent to verify a DO NOT or HOLD line against what it cites.
  • Remote sessions: pane-level tmux commands target =NAME:. On tmux 3.6 the bare =NAME missed the pane, dropping the launch line. The launcher waits for the pane (about 5 s at most) and returns ERR_TMUX when a step fails instead of reporting OK.
  • Docs: 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=0 turns off the hook on an installed copy; "terminal_refusals": [] turns off the new waiter classification. Restore mcp-http-call.py and await-approval together.

Checks

  • Each new or changed behavior has a test shown failing on main first: waiter 236 and client 140 cases (70 and 37 of the new assertions failed on main; 16 hand-injected defects all caught), fallback hook 54 cases (mutants each caught), effort line 62 (48 failed on main), tmux targets 29 and a real tmux 3.6 run on a private socket (both failed on main), resume text 25 (1 failed on main), and the five exit-77 suites (exit 0 on main with the prerequisite hidden, exit 77 now).
  • Every suite per CONTRIBUTING.md step 2 through sandbox-run, with the Stage-1 settings bound for verify-ops-selftest.sh: 68 of 69 pass; t3-html-render-test.py fails only because the sandbox hides node (installed under the home directory) and passes when run directly, as on main; both PowerShell suites pass.
  • Fresh-install smoke on a throwaway HOME in sandbox-run: deploy.sh --no-system twice, verify-ops.sh 30 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.
  • Stage-1 contract test with OPS_DIR on this branch: the OPS model-rules parity test passes; one failure reads the host's pyenv versions and fails the same way on main; one opt-in skip.
  • gitleaks git --redact over 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.
  • Private-term scan of the tree, this branch's history, and this title and body.

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 return ERR_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 on main).

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.

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.
@Exploitacious
Exploitacious merged commit 66dccaf into main Nov 18, 2026
8 checks passed
@Exploitacious
Exploitacious deleted the chore/ops-port-code-2026-11-18 branch November 18, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant