You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2026/05/01 11:53:28 UTC
(airflow-steward) branch fix-sandbox-statusline-local-json created (now aab24a4)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a change to branch fix-sandbox-statusline-local-json
in repository https://gitbox.apache.org/repos/asf/airflow-steward.git
at aab24a4 docs(secure-agent-setup): sync status-line docs with settings.local.json reader
This branch includes the following new commits:
new 43f16b2 fix(agent-isolation): reflect /sandbox toggle in status-line prefix
new aab24a4 docs(secure-agent-setup): sync status-line docs with settings.local.json reader
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(airflow-steward) 02/02: docs(secure-agent-setup): sync status-line docs with settings.local.json reader
Posted by po...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch fix-sandbox-statusline-local-json
in repository https://gitbox.apache.org/repos/asf/airflow-steward.git
commit aab24a43d10b3a2f31bd883a1c5b3b3fe512fc8e
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Fri May 1 13:52:23 2026 +0200
docs(secure-agent-setup): sync status-line docs with settings.local.json reader
Match the doc's description of the Sandbox-state status line to the
script's actual lookup precedence — project settings.local.json first,
then project settings.json, then ~/.claude/settings.local.json, then
~/.claude/settings.json — and call out that `/sandbox` toggles are now
reflected (since they persist to project settings.local.json). Drop the
outdated "in-session permission-mode changes are missed" trade-off; CLI
flags remain the only blind spot.
Co-Authored-By: Claude Opus 4.7 (1M context) <no...@anthropic.com>
---
secure-agent-setup.md | 44 ++++++++++++++++++++++++++---------------
tools/agent-isolation/README.md | 2 +-
2 files changed, 29 insertions(+), 17 deletions(-)
diff --git a/secure-agent-setup.md b/secure-agent-setup.md
index 0e3e6eb..7cf21e2 100644
--- a/secure-agent-setup.md
+++ b/secure-agent-setup.md
@@ -516,9 +516,18 @@ The framework ships
[`tools/agent-isolation/sandbox-status-line.sh`](tools/agent-isolation/sandbox-status-line.sh)
to render exactly that:
-- `<model> [sandbox]` in green when the active `settings.json`
- sets `"sandbox": { "enabled": true }`, OR
-- `<model> [NO SANDBOX]` in bold red when it does not.
+- `<model> [sandbox]` in green when the active settings set
+ `"sandbox": { "enabled": true }`, OR
+- `<model> [NO SANDBOX]` in bold red when they do not.
+
+The script walks the same precedence Claude Code itself uses for
+`sandbox.enabled` — project `settings.local.json` first, then
+project `settings.json`, then `~/.claude/settings.local.json`,
+then `~/.claude/settings.json` — and stops at the first file
+that sets the key (to `true` *or* `false`). The `/sandbox`
+slash-command toggle persists to project `settings.local.json`,
+so flipping it mid-session is reflected in the prefix on the
+next render.
Like the [Sandbox-bypass visibility hook](#sandbox-bypass-visibility-hook),
this is **complementary**, not authoritative — see Trade-offs
@@ -565,28 +574,31 @@ echo '{"model":{"display_name":"Sonnet 4.6"},"workspace":{"current_dir":"'"$PWD"
Expected output, *inside* this repo (its
[`.claude/settings.json`](.claude/settings.json) sets
-`sandbox.enabled: true`): `Sonnet 4.6 [sandbox]` with `[sandbox]`
-rendered in green. From a directory whose `.claude/settings.json`
-does **not** enable the sandbox (or does not exist) and whose
-`~/.claude/settings.json` likewise does not set
-`sandbox.enabled: true`, the output is `[NO SANDBOX]` in bold red.
+`sandbox.enabled: true`, and assuming `.claude/settings.local.json`
+either does not exist or does not override the key):
+`Sonnet 4.6 [sandbox]` with `[sandbox]` rendered in green. From a
+directory whose project and user settings files do **not** enable
+the sandbox (or do not exist), the output is `[NO SANDBOX]` in
+bold red.
**Trade-offs.**
- **Settings-level truth, not session-level truth.** The script
reads `sandbox.enabled` from the file system. It cannot see CLI
- flags (`--bypass-permissions`, equivalent runtime overrides) or
- in-session permission-mode changes that override the file —
+ flags (`--bypass-permissions`, equivalent runtime overrides) —
those still display as `[sandbox]` even though the running
- session is unprotected. Pair the indicator with the
+ session is unprotected. The `/sandbox` slash-command toggle
+ *is* reflected, because it persists to project
+ `settings.local.json`, which the script reads. Pair the
+ indicator with the
[Sandbox-bypass visibility hook](#sandbox-bypass-visibility-hook)
so per-call bypass attempts also surface in real time.
- **Schema robustness.** The Claude Code statusLine input JSON
- does not currently expose sandbox state — we read settings.json
- ourselves. If a future Claude Code release adds a sandbox field
- to the statusLine input, the script can be simplified to read
- that field directly. Until then the file-read approach is the
- only option, with the trade-off above.
+ does not currently expose sandbox state — we read the settings
+ files ourselves. If a future Claude Code release adds a sandbox
+ field to the statusLine input, the script can be simplified to
+ read that field directly. Until then the file-read approach is
+ the only option, with the trade-off above.
## Syncing user-scope config across machines
diff --git a/tools/agent-isolation/README.md b/tools/agent-isolation/README.md
index 34b7f10..a5ceb50 100644
--- a/tools/agent-isolation/README.md
+++ b/tools/agent-isolation/README.md
@@ -29,7 +29,7 @@ versions.
| [`check-tool-updates.sh`](check-tool-updates.sh) | Reads the manifest and reports upstream releases that are newer than the pin AND have themselves aged past the 7-day cooldown. Side-effect-free — no installs, no edits, no PRs. |
| [`claude-iso.sh`](claude-iso.sh) | Shell function to launch Claude Code with `env -i` and a tiny passthrough list, stripping every credential-shaped environment variable from the parent shell. The framework's "layer 0" of the secure setup. |
| [`sandbox-bypass-warn.sh`](sandbox-bypass-warn.sh) | Claude Code `PreToolUse` hook (Bash matcher). Prints a bold-red banner to stderr whenever the model invokes the Bash tool with `dangerouslyDisableSandbox: true`. Belt-and-braces visibility for the sandbox-bypass permission prompt. Recommended user-scope (`~/.claude/settings.json`) so it fires across every session on the host. |
-| [`sandbox-status-line.sh`](sandbox-status-line.sh) | Claude Code `statusLine` helper. Renders `<model> [sandbox]` (green) or `<model> [NO SANDBOX]` (bold red) based on `sandbox.enabled` in the active `settings.json`, so the terminal footer always shows whether the current session is sandboxed. Recommended user-scope. |
+| [`sandbox-status-line.sh`](sandbox-status-line.sh) | Claude Code `statusLine` helper. Renders `<model> [sandbox]` (green) or `<model> [NO SANDBOX]` (bold red) based on `sandbox.enabled` in the active settings — project `settings.local.json` first, then project `settings.json`, then user-scope, mirroring Claude Code's own precedence. Reflects in-session `/sandbox` toggles (which persist to project `settings.local.json`). Recommended user-scope. |
## Usage at a glance
(airflow-steward) 01/02: fix(agent-isolation): reflect /sandbox toggle in status-line prefix
Posted by po...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch fix-sandbox-statusline-local-json
in repository https://gitbox.apache.org/repos/asf/airflow-steward.git
commit 43f16b2201db27974c1fdaac31a102651f367163
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Fri May 1 13:43:14 2026 +0200
fix(agent-isolation): reflect /sandbox toggle in status-line prefix
The status-line script only walked `settings.json` files, so the
`[sandbox]` / `[NO SANDBOX]` prefix did not change when the user
toggled sandbox in-session via the `/sandbox` slash command — that
command persists its state to `<project>/.claude/settings.local.json`,
which the script never read.
Walk all four files in Claude Code's settings precedence order
(project local → project shared → user local → user) and stop at
the first file with `.sandbox.enabled` set to `true` *or* `false`.
Also fixes a jq quirk: `.sandbox.enabled // empty` mis-treats an
explicit `"enabled": false` as missing because jq's `//` operator
fires on `false`. Switched to `tostring` and an explicit value
check so a deliberate `false` is read correctly.
Co-Authored-By: Claude Opus 4.7 (1M context) <no...@anthropic.com>
---
tools/agent-isolation/sandbox-status-line.sh | 37 +++++++++++++++++++---------
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/tools/agent-isolation/sandbox-status-line.sh b/tools/agent-isolation/sandbox-status-line.sh
index e3bc514..5832546 100755
--- a/tools/agent-isolation/sandbox-status-line.sh
+++ b/tools/agent-isolation/sandbox-status-line.sh
@@ -28,17 +28,21 @@
# sets `"sandbox": { "enabled": true }`.
# - "<model> [NO SANDBOX]" — bold red, otherwise.
#
-# Lookup order for `sandbox.enabled` (project-scope wins):
-# 1. <workspace.current_dir>/.claude/settings.json
-# 2. ~/.claude/settings.json
-# Anything not found in either file is treated as "not enabled".
+# Lookup order for `sandbox.enabled` (most-specific first, matches
+# Claude Code's settings precedence):
+# 1. <workspace.current_dir>/.claude/settings.local.json
+# 2. <workspace.current_dir>/.claude/settings.json
+# 3. ~/.claude/settings.local.json
+# 4. ~/.claude/settings.json
+# First file with `.sandbox.enabled` set (true *or* false) wins. The
+# `/sandbox` slash command persists its toggle to project-scope
+# `settings.local.json`, so reading that file is what makes the prefix
+# update after an in-session toggle.
#
# Caveat — the script reads settings *files*, not the live runtime
-# state. CLI flags (`--bypass-permissions`, `--no-sandbox`) and
-# in-session permission-mode changes that override the file are not
-# visible here, and will still show as `[sandbox]`. Pair with the
-# sibling `sandbox-bypass-warn.sh` PreToolUse hook for a per-call
-# signal.
+# state. CLI flags (`--bypass-permissions`, `--no-sandbox`) are not
+# visible here. Pair with the sibling `sandbox-bypass-warn.sh`
+# PreToolUse hook for a per-call signal.
#
# Wiring (user-scope, applies to every session on the host):
#
@@ -60,10 +64,19 @@ model=$(printf '%s' "$input" | jq -r '.model.display_name // .model.id // ""' 2>
cwd=$(printf '%s' "$input" | jq -r '.workspace.current_dir // ""' 2>/dev/null || true)
sandbox=""
-for f in "${cwd:+$cwd/.claude/settings.json}" "$HOME/.claude/settings.json"; do
+for f in \
+ "${cwd:+$cwd/.claude/settings.local.json}" \
+ "${cwd:+$cwd/.claude/settings.json}" \
+ "$HOME/.claude/settings.local.json" \
+ "$HOME/.claude/settings.json"; do
[ -n "$f" ] && [ -f "$f" ] || continue
- v=$(jq -r '.sandbox.enabled // empty' "$f" 2>/dev/null || true)
- if [ -n "$v" ]; then
+ # `.sandbox.enabled | tostring` yields "true" / "false" / "null"; we
+ # treat "null" (key absent or `sandbox` block missing) as unset and
+ # fall through to the next file. Using `// empty` here would be
+ # wrong — jq's `//` operator treats `false` as a fallback trigger,
+ # so an explicit `"enabled": false` would be mis-read as missing.
+ v=$(jq -r '.sandbox.enabled | tostring' "$f" 2>/dev/null || true)
+ if [ "$v" = "true" ] || [ "$v" = "false" ]; then
sandbox="$v"
break
fi