Skip to content

refactor(run): register managed runs per agent - #138

Merged
Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/register-managed-run
Oct 6, 2026
Merged

Stephen Belanger (Qard) merged 1 commit into
mainfrom
refactor/register-managed-run

Conversation

@Qard

@Qard Stephen Belanger (Qard) commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Based on main now that #137 has merged.

run_traced matched on RunSource throughout:

  • rejecting Codex's --dangerously-bypass-hook-trust and non-interactive Cursor runs
  • choosing each agent's executable
  • creating Cursor's invocation-local plugin and discovery hooks
  • setting OpenCode's inline config

Those branches now live in ManagedRun impls in managed_run/<agent>.rs. The Codex, Claude Code, Cursor, OpenCode and Pi agent types register them next to their setup adapters. Grok and Antigravity don't support managed runs, so they don't register one.

pub(crate) trait ManagedRun: Agent {
    fn executable(&self) -> (&'static str, &'static str);                // (env override, default)
    fn check(&self, agent_args: &[OsString], terminal: Terminal) -> anyhow::Result<()>;
    fn inject(&self, hook_command: &RunHookCommand, managed_run_id: &str) -> anyhow::Result<Injection>;
}
pub(crate) struct Injection {
    pub args: Vec<OsString>,
    pub env: Vec<(&'static str, String)>,
    pub guards: Vec<Box<dyn Send>>,   // e.g. Cursor's temp plugin dir and discovery hooks
}

run_traced looks up the agent, then runs the shared steps itself:

  • the destination check
  • daemon isolation
  • the launch
  • the Ctrl-C handling
  • the flush and cleanup

It holds the agent's guards until the agent exits. A new test checks that every RunSource variant resolves to a registered managed run.

Behaviour

Unchanged, apart from two orderings:

  • Check order. Agent-specific checks now run before the destination check. A Codex run that has both a missing destination and --dangerously-bypass-hook-trust now reports the flag first. Cursor's terminal check already ran first.
  • Cursor hook install. Cursor's discovery hooks are installed during inject, which is slightly earlier than before (before the isolated daemon directory is created, rather than just before spawn). They are still removed when the run exits.

Testing

  • cargo clippy --all-features --all-targets -D warnings is clean.
  • cargo test --all-features --no-fail-fast: everything passes except trace_runtime::tests::doctor_reports_a_daemon_that_{cannot_authenticate_the_route,resolves_other_credentials}, which fail the same way on main in my local environment.
  • Managed-run tests moved beside each agent's impl and now call inject directly. One new registry test.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T12:37:10.848320Z 40a95f7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-managed-run branch from f264028 to cd40bdb Compare October 6, 2026 14:04
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-managed-run branch from cd40bdb to 2e38e1a Compare October 6, 2026 14:48
Base automatically changed from refactor/agent-registry to main October 6, 2026 15:01
run_traced matched on RunSource throughout. It checked Codex and Cursor
arguments, chose executables, created Cursor's plugin directory and
discovery hooks, and set OpenCode's inline config. Those branches now
live in `ManagedRun` impls on the Codex, Claude Code, Cursor, OpenCode
and Pi agent types, which register them alongside setup. run_traced
looks up the agent and runs the shared launch, flush and cleanup steps
with the arguments, environment and cleanup guards the agent injects.

Agent-specific argument checks now run before the destination check,
so a Codex run with both problems reports the hook-trust flag first.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Qard
Stephen Belanger (Qard) force-pushed the refactor/register-managed-run branch from 2e38e1a to f20a120 Compare October 6, 2026 15:03
@Qard
Stephen Belanger (Qard) merged commit cd74102 into main Oct 6, 2026
20 checks passed
@Qard
Stephen Belanger (Qard) deleted the refactor/register-managed-run branch October 6, 2026 15:21
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