Skip to content

[codex] raise ctl core mesh responder coverage#362

Merged
maiconburn merged 2 commits intomainfrom
codex/ctl-core-mesh-responder-tests
May 1, 2026
Merged

[codex] raise ctl core mesh responder coverage#362
maiconburn merged 2 commits intomainfrom
codex/ctl-core-mesh-responder-tests

Conversation

@maiconburn
Copy link
Copy Markdown
Collaborator

Summary

  • Add command-level coverage for commands/core.rs daily dispatch and capability listing paths.
  • Exercise mesh enable/disable/add-peer/status flows against temporary config and state files.
  • Extract responder interactive mode application into a testable helper and cover observe, dry-run, live, dry-run CLI, and config-write paths.

Coverage

cargo llvm-cov -p innerwarden-ctl --json --summary-only --output-path target/llvm-cov/ctl-lote1-summary.json

  • commands/core.rs: 91.53% line coverage
  • commands/mesh.rs: 98.31% line coverage
  • commands/responder.rs: 81.59% line coverage

Validation

  • cargo test -p innerwarden-ctl core
  • cargo test -p innerwarden-ctl mesh
  • cargo test -p innerwarden-ctl responder
  • cargo test -p innerwarden-ctl

Closes #236
Closes #244
Closes #245

Copilot AI review requested due to automatic review settings May 1, 2026 03:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Raises innerwarden-ctl command-module coverage by adding focused tests and extracting a small piece of interactive responder logic into a testable helper.

Changes:

  • Add coverage for commands/core.rs daily dispatch paths and capability listing.
  • Add coverage for commands/mesh.rs enable/disable/add-peer/status flows using temporary config/state files.
  • Refactor commands/responder.rs interactive selection into a ResponderMode helper and add tests for mode application and flag-driven configuration.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
crates/ctl/src/commands/core.rs Adds tests covering daily command dispatch and list output wiring.
crates/ctl/src/commands/mesh.rs Adds tests covering config edits and status rendering with temp files.
crates/ctl/src/commands/responder.rs Introduces ResponderMode, refactors interactive flow, and adds responder config/mode tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +376 to +380
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);

apply_responder_mode(&cli, ResponderMode::DryRun, false).unwrap();

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test calls apply_responder_mode() with cli.dry_run = false, which triggers a systemctl restart innerwarden-agent via restart_agent(). Please gate or decouple restarts so unit tests don't invoke external service managers.

Copilot uses AI. Check for mistakes.
Comment on lines +398 to +402
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);

apply_responder_mode(&cli, ResponderMode::Live, true).unwrap();

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With cli.dry_run = false, apply_responder_mode(... Live, true) will call restart_agent(cli) and run systemctl restart innerwarden-agent. Unit tests should not perform real restarts; refactor to separate config mutation from restart side effects or add a mechanism to skip restarts in tests.

Copilot uses AI. Check for mistakes.
Comment on lines +328 to +332
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);

cmd_configure_responder(&cli, true, false, Some(true)).unwrap();

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests run with cli.dry_run = false, so cmd_configure_responder() will call restart_agent(cli), which spawns systemctl restart innerwarden-agent via helpers::restart_agent(). Unit tests should avoid invoking external service managers; consider refactoring responder configuration to separate “write config” from “restart agent”, or add a test-only/flagged way to skip restarts so the tests remain hermetic.

Copilot uses AI. Check for mistakes.
Comment on lines +340 to +344
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);

cmd_configure_responder(&cli, false, true, None).unwrap();

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test invokes cmd_configure_responder() with cli.dry_run = false, which triggers restart_agent(cli) and therefore executes systemctl restart innerwarden-agent (errors ignored). That external side effect makes the test suite environment-dependent; please refactor or gate restarts so tests don't call systemctl.

Copilot uses AI. Check for mistakes.
Comment on lines +352 to +356
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);

cmd_configure_responder(&cli, false, false, Some(false)).unwrap();

Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling cmd_configure_responder() here with cli.dry_run = false will run restart_agent(cli) and attempt systemctl restart innerwarden-agent. Please avoid system-level restarts in unit tests (e.g., split config writes into a pure helper and test that, or add a skip-restart flag used by tests).

Copilot uses AI. Check for mistakes.
#[test]
fn apply_responder_mode_observe_only_writes_disabled_state() {
let dir = tempfile::tempdir().unwrap();
let cli = test_cli(&dir, false);
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply_responder_mode() always calls restart_agent(cli) for ObserveOnly when cli.dry_run is false, which runs systemctl restart innerwarden-agent. This makes the unit test non-hermetic; consider injecting the restart behavior (or returning an action to restart) so tests can verify config writes without shelling out.

Suggested change
let cli = test_cli(&dir, false);
let cli = test_cli(&dir, true);

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

❌ Patch coverage is 28.00000% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ctl/src/commands/responder.rs 28.00% 18 Missing ⚠️

📢 Thoughts on this report? Let us know!

@maiconburn maiconburn requested a review from esteves-uk May 1, 2026 06:28
@maiconburn maiconburn merged commit fd67905 into main May 1, 2026
15 of 16 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

3 participants