Skip to content

[WIP] feat: roar agent#45

Open
christophergeyer wants to merge 2 commits intomainfrom
cg/roar-agent
Open

[WIP] feat: roar agent#45
christophergeyer wants to merge 2 commits intomainfrom
cg/roar-agent

Conversation

@christophergeyer
Copy link
Member

Summary

  • roar agent — new CLI command that traces file I/O without requiring a clean git working tree or even a git repository. Jobs recorded with job_type="agent".
  • Process tree in roar show — agent jobs display "Executed commands:" showing the subprocess tree extracted from existing tracer data.
  • Preload tracer fork/exec tracking — the LD_PRELOAD tracer now interposes fork() and emits Exec events via a library constructor, so short-lived children like ls appear in the process tree.

Detail

Reuses the entire run pipeline (tracer → provenance → job recording → report) with two differences:

  • get_git_root_optional() instead of validate_git_clean() — returns cwd if not in a git repo
  • job_type="agent" passed through to job recording

Git info captured best-effort; _get_git_info returns {} outside a repo. Git provider get_status stderr leak suppressed.

Process tree display

The summarized process tree is stored in job metadata as process_tree. roar show renders:

  Executed commands:                                                                                               
    bash -c 'echo test 1; ls; echo test 2'                        
      - ls

Preload fork/exec

Two new NativeTraceEvent variants: Fork { parent_pid, child_pid } and Exec { pid, command }. C shim interposes fork(), library constructor sends Exec with /proc/self/cmdline after successful exec. Launcher reconciles out-of-order events by back-filling parent_pid.

Known limitation: clone3/posix_spawn (used by glibc system() and Python subprocess) bypass fork() interposition.

Shell commands work correctly since bash uses libc fork().

Test plan

  • roar agent bash -c "echo test; ls; echo done" in dirty git repo succeeds
  • roar agent outside a git repo succeeds with no git error
  • roar show @n for agent job displays "Executed commands:" tree
  • roar agent --tracer preload bash -c "ls; echo done" — ls appears in tree
  • roar agent --tracer ptrace bash -c "ls; echo done" — ls appears in tree
  • Existing roar run / roar build unchanged
  • cargo test -p roar-tracer-preload passes

🤖 Generated with https://claude.com/claude-code

chrisgeyertreqs and others added 2 commits March 18, 2026 17:06
New CLI command for tracing AI agents and tools that modify the
working tree.  Unlike `roar run`, it does not require a clean git
state or even a git repository.

- `roar agent <cmd>` traces file I/O and records job_type="agent"
- Process tree stored in job metadata, rendered by `roar show`
- Git info captured best-effort (graceful when outside a repo)
- Suppressed git stderr noise from provider's get_status

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The preload tracer previously only discovered processes when they
performed file I/O.  Short-lived children like `ls` were invisible.

Add Fork and Exec variants to NativeTraceEvent.  Interpose fork() in
the C shim so the launcher learns about child processes immediately.
A library constructor sends an Exec event after successful exec,
carrying the new command from /proc/self/cmdline.  The launcher
reconciles out-of-order Exec-before-Fork by back-filling parent_pid
when the Fork event arrives.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants