Skip to content

refactor(cli): replace arg-count suppressions with request structs - #591

Merged
beruro merged 1 commit into
developfrom
claude/clippy-suppressions-cleanup-00be2f
Jul 30, 2026
Merged

refactor(cli): replace arg-count suppressions with request structs#591
beruro merged 1 commit into
developfrom
claude/clippy-suppressions-cleanup-00be2f

Conversation

@Harry19081

Copy link
Copy Markdown
Member

Summary

Follow-up to #565, which introduced two #[allow(clippy::too_many_arguments)] suppressions in agent_sessions/cli/commands/run.rs. This removes both by grouping the arguments into request structs instead of silencing the lint.

Problem

#565 grew cli_agent_run_internal to 8 arguments and the cli_agent_message command to 9, and suppressed the resulting clippy warnings. Beyond the suppressions themselves, the flat signatures made every Rust caller unreadable — the agent-core bridge called cli_agent_message with five consecutive positional Nones, and the debug runtime probes had six such call sites. The "adopt the client's turn ids or mint fresh ones" rule was also duplicated across both entry points.

Solution

  • CliRunRequest / CliMessageRequest replace the flat argument lists. Both derive Default, so callers name only the fields they mean (..Default::default()) instead of padding with positional Nones. This matches the request: T command convention already used by benchmark_*, human_session_*, pagination_*, and xlsx_*.
  • TurnIdentity holds the turn_intent_id + client_message_id pair, with generate() (mint both) and from_client() (adopt whichever halves the client supplied). The id-defaulting rule now lives in one place.
  • cli_agent_run_internal becomes run_turn(request, turn) — 2 args, no suppression.
  • Wire change: cli_agent_message now takes a single request object, so the frontend sends { request: {...} }. CliMessageRequestSchema is the inner shape; CliMessageInputSchema wraps it.

Net: both suppressions gone, 159 lines deleted for 193 added (mostly doc comments on the new structs), and 8 call sites became self-documenting.

Potential risks

  • cli_agent_message payload shape changed. rpc.cli.message is the only caller (cliTransport.ts), updated in this PR along with its unit test. The zod input schema still enforces sessionId/content/turnIntentId/clientMessageId, so a stale caller fails validation before IPC rather than silently sending a malformed payload.
  • cli_agent_run's argument shape also changed, but it has no TS caller — only the agent-core bridge and the debug-only runtime probes invoke it, both updated here.
  • Default on the request structs means session_id can silently default to "" at a Rust call site that forgets it. Not reachable over the wire: serde still rejects missing non-Option fields, and all four Rust call sites set session_id explicitly.
  • No behavior change intended — this is signature-level only. The lifecycle contracts from perf(cli): replace status polling with turn-intent push #565 (acceptance persistence under the registry lock, turn_intent_id on every status_changed broadcast, receipt-based resolution) are untouched.

Test plan

  • cargo clippy --all-targets — clean; no warnings in the three touched Rust files. The 11 pre-existing org2 lib warnings are all in files this PR does not touch.
  • cargo fmt --check — no diffs in touched files (27 pre-existing diffs elsewhere in the repo).
  • npx tsc --noEmit — passes.
  • npx eslint on the three touched TS files — clean.
  • npx vitest run src/engines/SessionCore/sync/adapters/cli/__tests__/cliTransport.test.ts — 2/2 passing (expectation updated for the { request } payload).
  • Pre-commit hook (lint-staged + scoped tsc + scoped clippy) passed.

Not run: end-to-end CLI turn against a live agent. The change is signature-level with no behavioral edits, but a manual follow-up turn (send message → verify the optimistic row reconciles against the receipt) would confirm the { request } payload lands correctly through real IPC.

PR #565 papered over two `too_many_arguments` hits in the CLI run commands
with `#[allow]`. Group the arguments into `CliRunRequest` /
`CliMessageRequest` instead, matching the `request: T` command convention
already used by `benchmark_*`, `human_session_*`, and pagination.

`turn_intent_id` + `client_message_id` move into a `TurnIdentity` pair so
the "adopt the client's ids or mint fresh ones" rule lives in one place
rather than being duplicated across the two entry points.
@beruro
beruro merged commit 2b2accf into develop Jul 30, 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