Skip to content

fix(agent): fire recording hooks inside sandboxes - #98

Merged
geekgonecrazy merged 1 commit into
devfrom
fix/agent-enable-sandbox-guard
Jul 1, 2026
Merged

geekgonecrazy merged 1 commit into
devfrom
fix/agent-enable-sandbox-guard

Conversation

@geekgonecrazy

Copy link
Copy Markdown
Contributor

Problem

atomic agent enable installs recording hooks guarded with:

test -d .atomic && atomic agent hooks <agent> <verb> || true

An agent sandbox working tree (atomic sandbox create) has no .atomic/ directory of its own — it carries only a .atomic-sandbox pointer file to the canonical graph. So inside a sandbox the guard is always false, the recorder never runs, and every turn's provenance is silently dropped.

Fix

Widen the guard to fire when either marker is present:

test -d .atomic || test -f .atomic-sandbox && atomic agent hooks <agent> <verb> || true

POSIX &&/|| are equal-precedence and left-associative, so this parses as (((test -d .atomic || test -f .atomic-sandbox) && CMD) || true):

State Recorder runs?
neither marker no
.atomic-sandbox pointer only (sandbox) yes
.atomic/ dir only (canonical checkout) yes
recorder itself fails turn not blocked (`

atomic agent hooks already resolves the sandbox pointer via Repository::open and records into the canonical graph, so nothing else needs to change on the runtime side.

Details

  • Centralized the guard in hooks::guarded_hook_command so claude-code, gemini-cli, and codex share one definition (previously duplicated as literals / format! calls in each adapter). The sandbox-pointer filename comes from atomic_repository::SANDBOX_POINTER.
  • Hook detection (is_installed, is_atomic_hook, uninstall) is substring-based on the atomic agent hooks <agent> prefix, so already-installed legacy hooks are still recognized for status/uninstall/--force reinstall.
  • Updated the manifest doc example and the is_atomic_hook tests to cover the new format.

Testing

  • cargo test -p atomic-agent hooks:: — 414 passed
  • cargo test -p atomic-cli agent — 59 passed
  • Verified guard precedence for all four states in a real shell.

@geekgonecrazy
geekgonecrazy force-pushed the fix/agent-enable-sandbox-guard branch from 6dd9ad0 to 3d65f29 Compare July 1, 2026 00:35
Installed agent hooks were guarded with `test -d .atomic && … || true`.
An agent sandbox working tree has no `.atomic/` of its own — only a
`.atomic-sandbox` pointer to the canonical graph — so the guard was
always false there and every turn's provenance was silently dropped.

Widen the guard to fire when either marker is present:

    test -d .atomic || test -f .atomic-sandbox && … || true

POSIX `&&`/`||` are equal-precedence and left-associative, so this
parses as `(((test -d .atomic || test -f .atomic-sandbox) && …) || true)`
— the recorder runs when either marker exists, and a recorder failure is
still swallowed so the agent turn is never blocked. `atomic agent hooks`
already resolves the sandbox pointer and records into the canonical graph.

Centralize the guard in `hooks::guarded_hook_command` so claude-code,
gemini-cli, and codex share one definition, and update the manifest doc
example. Hook detection is substring-based, so already-installed legacy
hooks are still recognized for `is_installed`/uninstall/--force.
@geekgonecrazy
geekgonecrazy force-pushed the fix/agent-enable-sandbox-guard branch from 3d65f29 to 33f71fe Compare July 1, 2026 00:51
@geekgonecrazy
geekgonecrazy merged commit 865a720 into dev Jul 1, 2026
8 checks passed
@geekgonecrazy
geekgonecrazy deleted the fix/agent-enable-sandbox-guard branch July 1, 2026 02:16
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