Skip to content

feat: wire invoke_capability() dispatch, CLI run command, and integration tests#2

Merged
marcuspat merged 3 commits into
mainfrom
feat/production-wiring
Jun 15, 2026
Merged

feat: wire invoke_capability() dispatch, CLI run command, and integration tests#2
marcuspat merged 3 commits into
mainfrom
feat/production-wiring

Conversation

@marcuspat

Copy link
Copy Markdown
Owner

Summary

Production wiring that connects the reasoning loop to real capability implementations and turns the sentinel run CLI command into a working investigate → plan → approve → act flow.

Reasoning loop (sentinel-agent-llm/src/reasoning_loop.rs)

  • Added a capability_impls: HashMap<String, Box<dyn Capability>> field plus a with_capabilities(...) builder.
  • invoke_capability() now dispatches to the registered concrete capability via cap.invoke(args, ctx), falling back to the previous stub result when no implementation is registered (preserving existing stub-mode behavior/tests).
  • Rollback path now calls cap.invoke_inverse(...) for completed steps before marking them RolledBack, logging success / failure / no-inverse.

CLI (sentinel-tui/src/main.rs)

  • New run_agent() wires the LLM backend (Anthropic/OpenAI), executor, all capabilities, registry, default policy, and audit log into a ReasoningLoop, then runs investigate → plan → approve → act. Approval comes from stdin or --auto-approve; --dry-run prints the plan without executing.
  • Commands::Run gained --auto-approve; the stub body now calls run_agent(...).
  • list_capabilities() now enumerates the real capabilities from all_capabilities(...) with kind, risk tier, and rollback support.

Tests (sentinel-agent-llm/tests/integration_test.rs)

  • New end-to-end integration suite wiring real capabilities through a recording mock executor and a sequential mock LLM backend, covering: real capability dispatch during investigation, full investigate→plan→execute, policy-deny observation, audit-chain validity, the 14-capability registry, and stub-mode fallback.

Notes on deviations from the patch spec

A few surgical adjustments were required so the workspace compiles and cargo test --workspace passes:

  • all_capabilities(...) requires an Arc<dyn CommandExecutorTrait>. The struct CommandExecutor does not implement that trait (only RealCommandExecutor does), so the executor used in both run_agent and list_capabilities is RealCommandExecutor. Added sentinel-exec to the TUI dependencies.
  • The test's CommandOutput construction was corrected to the actual struct (exit_code: Option<i32>, plus the truncated field).
  • CapabilityResult::Success exposes its payload as output (not data), and AuditLog exposes event_count() and persists on append (no separate flush()), so the test was adjusted accordingly.

Testing

  • cargo build --workspace — clean
  • cargo test --workspace — all green (integration suite: 6/6)
  • cargo clippy --workspace --all-targets — no warnings

Do not merge.

https://claude.ai/code/session_01PrvrHsArvuyDmDvn5Cuvri


Generated by Claude Code

@marcuspat marcuspat merged commit 56e1b5f into main Jun 15, 2026
3 checks passed
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