Repository navigation
Conversation
cmungall
force-pushed
the
cmungall/feat-native-clauz3-approval
branch
3 times, most recently
from
November 29, 2026 08:32
d8e53f4 to
f4b8c0f
Compare
cmungall
pushed a commit
that referenced
this pull request
Nov 30, 2026
…e share a name (stablyai#52701) Check runs were keyed by suite and name, so two same-named runs in one suite shared one saved row. Every poll one of them carried a different run id than the saved row and read as a rerun, posting a new "CI green" line for the same head. Sort observed runs by run id and suffix repeated names (#2, #3) so each run keeps its own row and an unchanged read compares equal. Fixes stablyai#52700 Co-authored-by: Neil <[email protected]>
Add an optional per-agent `agentSessionModes` setting (default native). When claude is set to `clauz3-restricted`, the pty spawn choke points rewrite the launch, after `agent.launch.before`, from `claude … -- <prompt>` to `clauz3 start claude [--model M] --prompt <prompt>`. It fails closed for resumes, compound lines, unsupported agents and Windows. docs/clauz3-restricted-worker/FINDINGS.md records the end-to-end dev-build run (worker-start → proved programs approved in clauz3's web page → worker_done) and what breaks: the approver key leaking into terminal output, lost transcripts and status hooks, and the worker protocol needing a trusted orca library (spike copy included). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Restricted workers now start as `clauz3 start claude --policy .clauz3/cz3tools/orca/worker-approval-policy.json …`, so routine mail to the worker's own coordinator (worker_done, status, questions) is auto-approved and everything else still goes to a person. A new optional `clauz3Command` setting pins the clauz3 build that workers run (here clauz3 PR stablyai#61's branch, until it merges) without touching the global install. Drop the spike's own cz3tools/orca copy in favour of stdlib:orca (normalform-ai/clauz3#61). Update FINDINGS with the re-run: one approval, 68 s, one worker_done, ORCA_TERMINAL_HANDLE kept through to the runner, and ORCA_AGENT_SESSION_ID unset for terminal-mode workers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With agentDefaultSurface=chat, worker-start (and new tabs, bots, automations) created a structured native-chat Claude session that never went through the clauz3-restricted PTY wrapper. A restricted agent now fails closed on every structured path: - routing: nativeChatPreferenceFor never prefers chat for a restricted agent, so chat defaults fall back to the wrapped terminal agent (also when a paired client sends its own chat default); - create: prepareStructuredAgentSessionCreateForWorktree, which every structured create goes through (tabs, agent launch, orchestration structured workers, bot chats, background chats), refuses with structured_agent_session_unsupported and a clear message, before any effect; - spawn: composeStructuredLaunch, which resolves every structured start (resume, restore, queued start of an existing chat), refuses with a pre-spawn error; - PTY: a spawn that names no agent but runs `claude` is wrapped too. clauz3-launch-paths.test.ts enumerates the launch paths, one row each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
stdlib:orca moved out of clauz3 into normalform-ai/clauz3-tools-agents (PR #1, cmungall/orca-library) as cz3tools.agents.orca, with shared delegation contracts in cz3tools.agents.core. Restricted workers now start with --policy .clauz3/cz3tools/agents/orca/worker-approval-policy.json. clauz3 core is pinned to stablyai#61's (now core-only) branch through clauz3Command. FINDINGS: new setup (gh: install, then stdlib git/filesystem), item 2, and the 2026-11-29 dev-build re-run (85 s, one approval, worker_done auto-approved, default chat surface). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…blyai#61, stablyai#62 and tools-agents #1/#2 merged Co-Authored-By: Claude Opus 5.5 <[email protected]>
… --approver-key-fd Restricted Claude sessions (agentSessionModes.claude = clauz3-restricted) are approved inside Orca instead of clauz3's web page. - Key handoff over a pipe Orca owns (normalform-ai/clauz3#62): main makes a private FIFO, opens its read end, and launches `clauz3 start claude ... --no-browser --approver-key-fd 3 ... 3>'<fifo>'`. clauz3 writes {origin, key, login_url} to fd 3 once ready; main reads it, removes the FIFO and only then registers the session. The key is never in env, argv, the pty or on disk; an undelivered key registers nothing. - A main-process broker polls each approval service, mints one-time card ids, freezes the shown snapshot (incl. program_sha256), re-reads the record before deciding, and maps 404/409/400 to card outcomes. - Decide IPC is accepted only from the Orca window's main frame; no CLI, runtime RPC, automation or agent path reaches it. - Card with parity to clauz3's web card, Approve once / Reject / Always allow when eligible, keyboard shortcuts with a 750 ms arm delay, pane dock, sidebar badge and OS notification. Normalform-Patch: fork-clauz3-approval-panel Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nts main Re-ran the combined isolated dev-build demo with every dependency from main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cmungall
force-pushed
the
cmungall/feat-native-clauz3-approval
branch
from
November 30, 2026 07:31
f4b8c0f to
f341cd5
Compare
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.
Phase 1 of weaving clauz3 into Orca. Restricted Claude sessions (
agentSessionModes.claude = 'clauz3-restricted') are now approved inside Orca, beside the agent pane that asked, rather than in clauz3's web page.Stacked on the spike (#2), now
8a00c03d168on upstreamstablyai/orcabe4d21c0c94. #2 uses the agents/orca and agents/core libraries from clauz3-tools-agentsmain, with the policy at.clauz3/cz3tools/agents/orca/worker-approval-policy.json, and clauz3main(8468da1+, with stablyai#61 and stablyai#62 merged). It also makes restricted agents refuse or fall back on every structured or chat launch path. This branch is #2's five commits plus the panel commit and a demo-docs commit. Design: #1 (docs/clauz3/DESIGN.md). Notes, key handoff, keyboard map and known gaps:docs/clauz3-approval-panel/README.md.What it does
--approver-key-fd). Main makes a private FIFO (0600 in a 0700 temp dir), opens its read end, and launchesclauz3 start claude --no-browser --approver-key-fd 3 … 3>'<fifo>'. clauz3 picks its own port, writes{origin, key, login_url}to fd 3 once ready, and closes it before the agent starts. Main reads the line, removes the FIFO, and only then registers the session. The key is never in env, argv, the pty, scrollback or on disk; clauz3 writes no link file. A one-line pipe write is atomic and reaches exactly one reader, so if main got it, nobody else did. If it never arrives (an old clauz3, a failed start), nothing is registered and nothing in Orca can approve (fail closed).8468da1or later, which has fix: use autoUpdater.quitAndInstall() on macOS to apply updates stablyai/orca#62):uv tool install git+https://github.com/normalform-ai/clauz3, or point spike: run an Orca worker as a restricted clauz3 session #2'sclauz3Commandsetting at a venv built from main. An older clauz3 rejects the flag and the session is never registered.src/main/clauz3/): polls each service'sGET /api/requestswith a fast-then-backoff timer that stops when no session is left. It sends the renderer display-only card views keyed by a one-timecardId, and keeps a frozenshownsnapshot, includingprogram_sha256. On decide it re-reads the record and refuses a stale card itself, thenPOST /decisionwithBearerandshown. 404 maps to gone, 409 to decided or changed, 400 to refused. Approve is withheld when the program does not hash toprogram_sha256.clauz3Approvals:decideis accepted only from the Orca window's main frame. No runtime RPC, CLI verb, automation, plugin frame or paired client reaches it. Card ids are single-use. Card buttons and keys ignore script-dispatched (untrusted) events, and approve is inert for 750 ms after a card appears or changes._render_cardandrender_guarantees: resolved and unresolved guarantees with provenance, coverage with clauz3's labels and severity order (gaps also summarised above the buttons), simulated tools, profile problems, paused auto-approvals, proof results, and the syntax-highlighted program with its line count and hash. The actions are Approve once, Always allow… (only whenprofile_eligible, with a confirm step), Reject, Reject contract and Need more info, plus an optional note.⌘↩approve once,⌘⇧↩always allow,⌘⌫reject.Demo (isolated dev build, scratch profile)
Combined worker run, everything from main (2026-11-29). clauz3
8468da1(main) in a venv built from main, pinned withclauz3Command(the global clauz3 was left alone). The toy repo has agents/core and agents/orca fromclauz3 install gh:normalform-ai/clauz3-tools-agents(main), plus stdlib git and filesystem.agentDefaultSurfaceset tochat(upstream's default isterminal, so it was set explicitly to exercise the chat fallback).orca orchestration worker-start --agent claudereturnedmode: terminal: it fell back from chat to a restricted terminal worker.worker_doneinto one program. That card was rejected from the panel with a note asking for two programs.clr_a128c7d693b1,only_writes_files([hello.txt]),only_subcommands([add, commit, log]),no_push(),protocol_messages_at_most(0)) was approved with⌘↩beside the worker's pane, with the key handed over--approver-key-fd. The worker's scrollback contains nologin?key=.worker_done-only program was auto-approved by agents/orca'sworker-approval-policy.json; no card appeared.worker_donewith outcomesucceeded, and the task iscompleted, about 4 min afterworker-start(one reject plus one approve). Commit8bbbd20 add hello.txt.awaiting_approvallooks finished (FINDINGS item 4).Earlier run (clauz3 stablyai#61 + stablyai#62 merged in a scratch venv, before they landed): one click,
succeeded72 s afterworker-start.Single-session runs:

With clauz3 stablyai#62's fd handoff. The terminal shows only "sign-in key handed to the host process". The clauz3 process env has no key, and no link file exists:
Approved from the panel with

⌘↩;hi.txtwas written and the dock cleared:Earlier run, same panel, interim env route:

A request waiting beside the agent pane, with the sidebar badge:
After

⌘↩, clauz3 verified the receipt and ran the program.hello.txtwas written, and the dock and badge cleared:Component fixtures (

pnpm fixtures:shot clauz3/Clauz3ApprovalCard --theme both):A forged decide call from the renderer with an unknown card id returned
{ok:false, reason:"unknown-card"}.Tests
src/main/clauz3/clauz3-approval-broker.test.ts: runs against a real loopback HTTP stand-in for the service. It covers: no token or origin in renderer data; token only on the POST;shown(withprogram_sha256) taken from main's snapshot; card ids spent and forged ids refused; a stale card refused without posting; 409 decided and 409 changed (C1-style service); 404; 400 with its detail; hash mismatch blocks approve; Always allow only when eligible; a dead service dropped.src/shared/clauz3/clauz3-approval-view.test.ts: coverage and guarantee parity with clauz3's text and order; approve blockers.src/renderer/src/components/clauz3/Clauz3ApprovalCard.test.tsx: the arm delay, untrusted clicks and keys ignored, no approve when blocked, Always allow only when eligible.src/main/clauz3/clauz3-key-pipe.test.ts(real FIFO, Node pool): a process launched throughshwith the exact3>'<fifo>'redirect hands over the key, and the pipe dir is removed afterwards; a timeout rejects and cleans up; a non-loopback origin or malformed line is refused.src/main/runtime/agent-session/launch/clauz3-launch-paths.test.ts(from spike: run an Orca worker as a restricted clauz3 session #2): its PTY rows now await the async seam with fake handoff deps, and the exact-command row includes the handoff and pipe arguments.--approver-key-fd 3and the redirect but no key, nothing is added to env, the session registers only after the key arrives, an undelivered key registers nothing, and a refused line registers nothing.pnpm typecheckclean.pnpm check:changed: all 45 checks pass.Known gaps
shownre-check relies on main's pre-read until clauz3 C1 makes the HTTP endpoint re-checkshownunder the signing lock. The field is already sent.clauz3-key-pipe.tsmakes three sync fs calls once per restricted launch: twoO_NONBLOCKopens of the just-made FIFO, which return at once, and one close. The raw fd must go tonet.Socket, which an asyncFileHandlecannot hand over. They are added tomain-sync-fs-baselineandmain-blocking-helper-baselinewith that reason. The FIFO test runs in the Node test pool, since Bun never reads a FIFO throughnet.Socket.stdlib:githit clauz3's 30 s proof timeout.🤖 Generated with Claude Code