CLI 出力契約
このページでは、自動化や運用者が前提にしてよい CLI の観測可能な振る舞いを整理します。
help 出力
help 出力はプレーンテキストです。
rlq --helpは全体の操作モデルとコマンド群を説明しますrlq <group> --helpは 1 つのコマンド群の subcommand を説明しますrlq <group> <leaf> --helpは 1 つの実行コマンドに対する option レベルの使い方を説明します
help 出力は探索のためのものであり、厳密な機械パース対象ではありません。
実行出力
呼び出し元が安定した機械可読結果を必要とする場合は、実行系コマンドに --json を付けてください。
成功レスポンスは stdout に書かれ、次の envelope 形を取ります。
json
{
"success": true,
"data": {}
}失敗レスポンスは stderr に書かれ、次の envelope 形を取ります。
json
{
"success": false,
"error": {
"code": "ERROR_CODE",
"category": "CATEGORY",
"message": "Human-readable explanation"
}
}error.category は安定した機械可読分類です。error.code はより具体的なアプリケーションエラーのまま残ります。
人間向けの可読出力もありますが、自動化では --json を優先してください。
ストリーム
- 成功結果: stdout
- 失敗結果: stderr
- help テキスト: stdout
終了コード
Relqis はアプリケーションエラーを、安定した終了コード分類へ写像します。
| 終了コード | 意味 |
|---|---|
0 | 成功 |
2 | 不正な要求または validation error |
3 | not found |
4 | conflict または optimistic concurrency error |
5 | posting policy または master policy の違反 |
6 | period または state transition の違反 |
7 | persistence、audit、その他の内部失敗 |
1 | その他の未分類失敗 |
2 は、必須 option 不足のような CLI parse failure にも使います。
エラー分類
現在の JSON error.category は次のとおりです。
invalid_requestnot_foundconflictpolicy_violationperiod_state_violationinternal
SQLITE_BUSY と SQLITE_LOCKED は、再試行を促す文脈付きで internal として返ります。呼び出し元は再試行できますが、可能なら並列 writer 自体を避けてください。
追加されうる結果フィールド
特定のコマンド群では、自動化が次の追加フィールドも前提にできます。
- posting-request mutation results include
attempt_count, and create/validate results also includeretried - posting-request detail includes
attempt_countand anattemptsarray - posting-request list/work items include
attempt_count - tax-code show/list/create/update results include
tax_usage,rate_category,invoice_credit_rule, andbusiness_category balance-sheet showrows includerow_kindandis_synthetic; current-period net income usesrow_kind=current_period_net_income
自動化向けガイド
- JSON 出力は、実行した leaf command の結果だけをパースします。
- help テキストを、安定した機械インターフェースとしてパースしてはいけません。
--expected-versionを受け付けるコマンドでは、先に現在状態を読み、その最新 version を渡します。- idempotency 入力を受け付けるコマンドでは、オーケストレーションの再試行時にそれを使います。