Skip to content

[codex] コマンド層の重複を削減し adapter と validation を共通化#45

Merged
6uclz1 merged 1 commit intomainfrom
codex/reduce-command-layer-duplication
Feb 23, 2026
Merged

[codex] コマンド層の重複を削減し adapter と validation を共通化#45
6uclz1 merged 1 commit intomainfrom
codex/reduce-command-layer-duplication

Conversation

@6uclz1
Copy link
Owner

@6uclz1 6uclz1 commented Feb 23, 2026

概要

コマンド層で繰り返されていた「引数検証」「get_client(ctx) 呼び出し」「execute_command(...) 包装」を adapter 化し、track / scenes / synth / effect の実装を共通パターンに整理しました。併せて検証関数を commands/_validation.py へ集約し、コマンド追加時の実装漏れリスクを下げています。

背景とユーザー影響

これまで各コマンドに同型の処理が分散していたため、仕様変更時に横断修正が必要になり、修正漏れで CLI の挙動やエラーメッセージの一貫性が崩れるリスクがありました。
利用者目線では、新規コマンド追加や既存コマンド修正時の品質ぶれにつながる可能性がありました。

根本原因

  • 実行前処理(検証・client 解決・実行ラップ)の責務が個々のコマンド関数に分散していた
  • 検証ルールがコマンド側に局在し、再利用可能な単位に分離されていなかった

対応内容

  • trackrun_track_command / run_track_value_command を導入
  • scenesrun_scene_command / run_scene_value_command / run_scene_move_command を導入
  • syntheffectrun_track_device_command を導入
  • commands/_validation.py に以下を追加して検証を集約
    • require_track_and_value
    • require_track_and_name
    • require_track_and_volume
    • require_track_and_pan
    • require_scene_index
    • require_scene_and_value
    • require_scene_and_name
    • require_scene_move
    • require_scene_insert_index
    • require_optional_track_index
    • require_track_and_device
  • adapter/validation の振る舞いを担保するユニットテストを追加
    • tests/commands/test_track_command_adapter.py
    • tests/commands/test_scenes_command_adapter.py
    • tests/commands/test_synth_command_adapter.py
    • tests/commands/test_effect_command_adapter.py
    • tests/commands/test_validation.py のケース拡張

変更による効果

  • 変更点が 1 箇所にまとまり、横断修正時の保守性が向上
  • コマンド実装の形が統一され、レビューと追加開発が容易
  • エラー条件・ヒントの一貫性が向上

検証

以下を実行し、すべて成功を確認しました。

  • uv run python -m ableton_cli.dev_checks
  • uv run ruff check .
  • uv run ruff format --check .
  • uv run pytest(389 passed)

@6uclz1 6uclz1 changed the title reduce command layer duplication [codex] コマンド層の重複を削減し adapter と validation を共通化 Feb 23, 2026
@6uclz1 6uclz1 marked this pull request as ready for review February 23, 2026 03:44
@6uclz1 6uclz1 merged commit a9b7611 into main Feb 23, 2026
8 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.

1 participant