Repository navigation
Conversation
Add the project skeleton (package, TypeScript strict ESM, vitest, CI on Linux, macOS and Windows, Apache-2.0 LICENSE and NOTICE, CLAUDE.md and AGENTS.md) and the frozen contracts the sandbox, host adapter, tool and benchmark parts build against. The run path is executable end to end with test fakes: MCP tools/call -> FakeSandbox -> Dispatcher (prepare, static rules, hooks, re-prepare on updated args, commit) -> StaticHostAdapter -> MemoryToolRuntime, with mutation ordering, cancellation, transactions with rollback, output caps with overflow files, and a command hook runner that kills the process group on timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Commit a dispatcher-owned deep-frozen copy of each prepared call; deep freeze now descends into objects that are already frozen. - Bound every await on adapter and runtime code by the run's abort signal or a grace: prepare, PostToolUse (which now receives the signal), loadPolicy (the run deadline starts before it), in-flight calls on stop, rollback and dispose. - Kill the command hook's whole process group on every completion path, so a backgrounded descendant cannot outlive the hook. - Send protocol and validation errors through the capped result formatter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implements HostAdapter and the context store for Claude Code in src/hosts/claude: settings from every source with Claude's precedence, deny/ask/allow permission rules (Bash with a real shell parser, Read/Edit gitignore-style paths), permission modes, PreToolUse/PostToolUse command and http hooks with the native payload (fail-closed), sandbox containment, protected paths, and the companion hook that records trusted session context keyed by the tool-use id. Adds sh-syntax (mvdan/sh compiled to WASM, synchronous, no dependencies) to parse Bash commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Auto mode: inner calls are allowed only when the run script reached Claude's classifier, that is when no allow rule approved the run tool; otherwise only reads and edits inside the working directories pass. - Critical-path rm/rmdir removals always ask (dontAsk denies). - Bash: parse env -S strings, skip shell option operands (-O, -o, --rcfile), strip every wrapper level (cap → ask), ask on alias/hash, match run-time words and absolute binaries by every static prefix. - File targets of sed, awk, grep, cp, dd and other file commands, with symlinks resolved in authorize. - Policy exposes isReadDenied for grep/glob result filtering. - Hooks deduplicate per event, not across events. - Context records are claimed with an atomic rename. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rename() let two concurrent readers win on Windows; O_EXCL creation of a claim file is atomic on every platform. The grep/glob filter test uses the POSIX-only in-memory runtime, so it is skipped on Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rule like `Bash[rm]` or `Read[./.env]` matched nothing, so a deny the user meant silently did not apply. Any deny, ask or allow rule that is not `Tool`, `Tool(specifier)` or an MCP form without a specifier now fails the policy load, naming the rule and its file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deny and ask globs (`*`, `B*`, `mcp__*`) match the full tool name; allow globs count only after a literal `mcp__<server>__` prefix, and unanchored allow globs approve nothing, as the permissions docs define. Forms the docs do not define still fail the policy load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Validate adapter decisions with a schema, reject non-string tool names and refresh the call summary after a hook rewrite. - Keep overflow output out of non-private state directories and off Windows. - Match path patterns across newlines and treat "..name" as inside a root. - Run a single deadline from the start of the run, counting policy loading, and give the sandbox the time left rounded up. - Roll back only after queued writes and edits end, report a pending rollback, and dispose the journal after the rollback has really finished. - Make the fake sandbox check its deadline before steps and calls, yield between steps, and tie its deadline and sleeps to one signal. - Describe the placeholder runtime the default server serves, with a runnable example. - Resolve in-memory paths against the session cwd and roots (Windows paths included), track file revisions for rollback, and run grep and glob in a stoppable worker thread. - Accept only a single --host option in serve. - Skip spawning a hook whose run was already cancelled and stop recording calls in the default runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Fake runtime: cap concurrent search workers per runtime; extra searches wait in a cancelable queue and a slot is reused only after its worker exits. - Fake runtime: build the search job after a slot is held, send grep content only for files that pass the name filter, and reject a search that would copy more than the text limit. - Fake runtime: count edit occurrences and build the diff without per-match or per-line arrays. - Normalize Windows drive paths in the fake runtime and path patterns, and restore original revisions on rollback. - Run: check the deadline before opening a transaction and word the pending-rollback warning accurately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…untime Network-share (UNC) paths are not supported: POSIX resolution folds their leading `//` while protected-path patterns keep it, so a protected share could go unrecognized. The fixed root, seeded files, session cwd and roots, and call paths now refuse UNC paths before any call is prepared. Edit and write preparation now size the change from cheap counts first and refuse, before building the edited text or the diff, an edit with more than MAX_EDIT_REPLACEMENTS (50,000) replacements or a diff over MAX_DIFF_LINES (200,000) lines. Changes under the budget produce the same text and diff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The session roots are checked for network-share (UNC) paths even when a fixed root replaces them, so a UNC session root is refused, not ignored. - setFile and revision refuse UNC paths like every other path entry point. - The diff line budget counts the rows the diff actually has: a text that ends with a line break no longer counts one extra row. Edit preparation works out whether the edited text ends with one from where the replaced occurrences sit, still before building the text or the diff, so diffs of up to MAX_DIFF_LINES rows are prepared and only larger ones refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep POSIX paths with redundant leading slashes local. Return actionable guidance when an edit exceeds the replacement limit. Stop glob after its first extra match and skip setup for cancelled searches.
Match local protection patterns and resolved paths with the same leading-slash normalization. Use one resolved key for in-memory reads, writes and file revisions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since the scaffold review, ensureStateDir refuses win32 because it cannot verify owner and mode bits there. The companion hook called it before writing each record, swallowed the error and wrote nothing, so every context lookup on Windows came back empty. Run the strict check on POSIX only and keep creating the context directory on Windows as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Deny bash writes to protected host paths; ask for write targets only known at run time. - Deny bash when sandbox read/write exclusions cannot be contained; managed filesystem settings lock the sandbox switch. - Auto mode no longer assumes a classifier verdict and drops wildcard shell allow rules. - Re-run the full static decision on link-resolved bash targets, including on Windows. - Track cwd-changing wrappers, `>&` file output, `--`, read-write commands, option file values and brace expansion in the shell analyzer. - Match allow rules against source word spelling; effectful find actions and exec wrappers need exact rules. - Refuse restrictive path rules with escapes or ranges; make path containment case- and `..x`-aware. - Read project and local settings from Claude's live working directory and anchor their `/path` rules there. - Validate mode values and locks, apply disableAutoMode, and ignore auto/bypass defaults from project and local settings. - Plan mode refuses changes before allow rules. - Apply blockReads/WritesOutsideWorkingDirectories. - Enforce allowedHttpHookUrls and httpHookAllowedEnvVars before any request. - Verify context record provenance and claim records by atomic rename; on Windows the companion hook writes no record, since none can be trusted. - Also load the main checkout's local settings (not on Windows, at home or on roots owned by others); its scalar values win; verify worktree trust both ways. - Apply managed hook controls before reading plugin hooks and keep managed-enabled plugin hooks. - Drop grants and refuse restrictions read from a lossy macOS command line. - Honor the dispatcher signal in PostToolUse hooks; run hooks in the session cwd. - PreToolUse failures always block; only command hooks run in the background. - Run `shell: bash` hooks under bash; shell-form hooks are unsupported on Windows; invalid matchers are unsupported. - Stream HTTP hook bodies with a cap; keep URLs and arguments out of hook errors. - Bound settings reads to regular files of limited size; validate plugin enablement booleans. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Skip the pruning test where no record is written and assert that none is on Windows. - Protect the canonical location of every protected path and ask when a write target cannot be canonicalized (dangling link, errors other than a missing entry). - Refuse bash under the sandbox when Read/Edit deny rules or the read block would need filesystem exclusions the containment cannot express. - Keep the working-directory boundary for redirection-only input under a blanket Bash allow rule. - Track file access by option and operand position, mark unknown attached option values, count escape parity for globs and braces, and read tilde prefixes as Bash does. - Slice parsed words by UTF-8 byte offsets. - Treat wrapper options that may change the child directory (combined flags, long options, sudo -i, env -S) as unknown directories. - Require exact allow rules for the documented exec wrappers and find -rm / -files0-from. - Anchor project, local and CLI rules at the primary directory, add it to the working directories, and run hooks in the session's current directory. - Leave repository-only additional directories out of the block-outside checks. - Match allowedHttpHookUrls against the parsed URL and fetch that same URL. - Verify the context directory on the writer side with the reader's private-directory check. - Resolve hook controls once and deny plugin hooks whose source cannot be verified where command-sourced plugins are disabled. - Scan joined macOS command lines word by word instead of using the exact-argv parser. - Validate every hook matcher that is not match-all or an exact list, so a malformed one denies. - Start default when a repository default mode is rejected. - Verify ownership and identity of worktree metadata before inheriting trust. - Stop forwarding hook runner diagnostics in failure reasons. - Deny mode-sensitive calls on Windows when no trusted live mode is known, checked on the real platform. - Anchor sandbox write grants at their settings source. - Build context validation fixtures in a private context directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
NEEDS_HUMAN on The remaining design question is how the adapter can establish the effects of a shell call and verify the active Claude policy before it grants access. It can limit the calls it accepts to those it can verify with the current contract, or rely on host-provided policy and containment that enforce the missing checks. The Windows fallback also needs to establish permissions before approving reads when the live mode is unknown. Linux and macOS CI passed. The Windows context test passed, and the Windows job failed on the absolute path fixture for the sandbox settings test. That fixture needs a fully qualified path. Windows job One full review and two confirmation rounds verified 28 fixes. The correction commits are Real Claude session behavior on Windows and Mac still needs verification. The adapter remains standalone. The design concerns matter when it starts authorizing live tool calls. Authorization choices to resolve before a later mergeThese choices apply once the authorization defects and Windows CI failure are resolved. 🔐 Require explicit permission for common shell file changes in Accept Edits
🔐 Require explicit permission for read-only shell commands
🔐 Keep critical directory removals behind approval in every mode
🔐 Keep file restrictions in force where a local exception exists
🔐 Apply shell restrictions through more command wrappers
🔐 Extend shell write access to folders shared with the tool server
🔐 Use only settings and plugin hooks for calls inside the script
🔐 Refuse Windows calls that require a shell command hook
🔐 Limit Windows operations without verified session context
🔐 Limit permissions derived from Mac launch options
🔐 Disable shell calls in Plan mode
🔐 Use only exact shell allow rules in Auto mode
🔐 Require every HTTP hook list to approve
🔐 Extend the outside-directory file write block to shell calls
🔐 Keep the outside-read block on directories added only in local project settings
Other behavior choices❓ Interpret an ambiguous shell rule as two restrictions
🧩 Drop notifications from background hooks
|
|
Decisions recorded for the next review round (the owner decided on 2026-11-19):
|
Summary
Claude Code host adapter (
src/hosts/claude/**): every binding call insiderunis authorized the way Claude Code would authorize the native tool call.Evidence
StaticHostAdapter.After:
npm run verifygreen, 147 tests insrc/hosts/claude(also green on Node 22.23):echo ok && rm -rf x,$(rm -rf x),`rm x`,FOO=1 rm x,timeout 5 rm x,sudo rm x,bash -c 'rm x',/bin/rm,xargs rm,find -exec rm,<(rm z)→ deny; unbalanced quotes,eval, heredoc with$(),$CMD x,… | bash→ ask//,~/,/(per source),./, bare any-depth, symlink to a denied file, rule written through a symlinked dircontinue:false, updatedInput, crash, exit 1, invalid JSON, timeout (child killed), matcher exact vs regex, parallel conflicts, duplicates run once,disableAllHooks, prompt/unknown type →unsupported-config,if, exec form placeholders, plugins, http hooks against a local server, byte-identicaltool_input.command../xrefused, symlink not followed, model_ctxignoredclaude -p --setting-sources project --strict-mcp-config, model claude-haiku-5-5): the hook'stool_use_idequals_meta["claudecode/toolUseId"]:runContextHook+createClaudeContextProviderand--permission-mode acceptEdits:Merge Danger
Door: two-way
Nothing outside
src/hosts/claudeimports the new code yet; the integrator wires it intocreateRuntimeandagent-code-mode hook.Blast Radius: contained
One new runtime dependency,
sh-syntax(MIT, no dependencies, ~4 MB with its WASM). Picked overshell-quote(tokenizer only: no backticks, no$(inside quotes, no heredocs) andbash-parser(unmaintained): it is the shfmt parser, maintained, and has a synchronous entry, whichcheckStaticneeds (no I/O, sync).Decisions
--allowedTools, approves this server'srun(mcp__agent-code-mode__run,mcp__agent-code-mode, or an anchored glob such asmcp__agent-code-mode__*), the classifier never saw the script, so inner calls no rule decides get only auto mode's step 2: reads and edits inside the working directories are allowed and everything else asks. Without such a rule, inner calls with no rule are allowed. Deny and ask rules apply to every call either way. The server name defaults toagent-code-mode(an adapter option). Alternative: always allow in auto mode, as the first version did.rm/rmdircritical-path removals (root, top-level directories, home, the working directory and its parents, a bare*under a working directory, a recursive removal of a target only known at run time, more than one glob level) are never approved by an allow rule, a hook or any mode: they ask, and dontAsk denies them (same doc, "Critical paths"). Alternative: let bypass/auto run them.sedscript orgreppattern, which is harmless to over-match. Symlinked operands are resolved with realpath inauthorize(the contract keepscheckStaticfree of I/O), also for a hook's rewritten command.alias,hash -p,enable) and more than 64 nested wrappers make the call ask; a run-time word where it could change which rule matches (git "$OP" origin) makes it ask when a deny or ask rule could match.PolicySnapshot.readFilter?: (absPath: string) => boolean, which the tools layer applies to every grep and glob result. The Claude policy already exposes it aspayload.isReadDenied. Until the integrator wires it, a recursive grep or glob can return a Read-denied file such as.env.--allowedTools/--disallowedTools) in a form the docs do not define fails the policy load, so every call is denied withunsupported-configand the message names the rule and its file. Native Claude Code ignores such rules (Bash[rm]denies nothing). Defined forms:ToolorTool(specifier)with a[A-Za-z0-9_]+tool name,mcp__serverandmcp__server__toolwithout a specifier, and tool-name globs without a specifier, matched as the docs say (https://code.claude.com/docs/en/permissions, "Tool name wildcards"). In deny and ask, a glob must match the full tool name, so*matches every tool,B*matches Bash andmcp__*matches only MCP tools, not Bash. In allow, a glob counts only after a literalmcp__<server>__prefix (mcp__server__*,mcp__github__get_*), and unanchored allow globs (*,B*,mcp__*) approve nothing, so they do not count as approvingrunfor auto mode either. Still load errors: a glob with a specifier (B*(x)) and an MCP rule with a specifier. Alternative: skip malformed rules with a warning, which fails open.allowdoes not lift a permission-mode prompt (in default mode a Bash call with no allow rule is still refused as ask-unavailable even if a hook allows it); natively the hook allow skips the prompt. Alternative: evaluate the mode after hooks, which breaks the static re-check of hook rewrites.continue:falseand an invalid matcher regex all deny; native Claude lets the call go ahead.onFailure: "continue"restores pass-through per hook.sudo,env,exec,xargswith flags,find -exec, the basename of/bin/rm, and insidesh -c; a deny rule that could match a run-time value ($X) makes the call ask; allow rules still only see Claude's documented wrappers.Tool(param:value)rules that collide with a command name (Bash(timeout:*)) are read both ways for deny/ask.!carve-outs are ignored: they never re-allow anything.-p); local settings are held too when untrusted, without the native git-tracked check.cwd, and addsrun_in_background: falseand a generateddescription; Grep addshead_limit.prompt/agent/mcp_toolhooks,shell: "powershell", exec-form hooks on Windows, plugins declaring hooks in their manifest. Skill and agent frontmatter hooks are not seen.async/asyncRewakehooks run in the background and their result is ignored (they cannot block natively either).pssplits arguments on spaces, so a--settingsJSON with spaces fails the load (fail closed).PreparedCall.argscarries the normalized path, so the "path as the script wrote it" check is only as good as what the tool runtime keeps inargs.path; proposedrequestedPathon read/write/edit/grep/glob effects. Grep/glob filtering: see thereadFilteritem above.🤖 Generated with Claude Code