다크 모드
JSON 엔벨로프와 종료 코드
stdout/stderr 계약
--json없이는 stdout은 사람용이며 machine oracle이 아니에요.--json이 있으면 stdout은 정확히 하나의 UTF-8 JSON object + trailing newline 하나예요. BOM 없음. progress bar, 추가 JSON line, human text를 stdout에 쓰지 않아요.--json모드의 stderr는 사람용 diagnostic일 수 있지만 oracle이 아니에요.- JSON serialization 실패 시 부분 JSON을 쓰지 않고 exit 13.
- secret 원문은 어떤 stream에도 쓰지 않아요.
성공 envelope (cli-envelope/v1)
json
{
"contract_version": "cli-operation/v7",
"envelope_version": "cli-envelope/v1",
"command": "verify",
"subcommand": null,
"cli_version": "0.0.0",
"correlation_id": "cli_example",
"project_ref": "prj_example",
"environment": "test",
"execution_mode": "execute",
"status": "succeeded",
"operation": null,
"result": {},
"issues": [],
"next_actions": []
}| 필드 | 규칙 |
|---|---|
status | succeeded / waiting_approval / blocked / failed / not_verified / unknown |
execution_mode | execute 또는 dry_run |
operation | mutating/async 명령에서는 operation object, read-only는 null |
result | 명령별 closed object. ad-hoc 필드 추가 금지 |
status=succeeded는 정의된 작업 완료일 뿐 독립 QA/보안 인수나 production readiness가 아니에요.
오류 envelope
json
{
"contract_version": "cli-operation/v7",
"envelope_version": "cli-envelope/v1",
"command": "deploy",
"subcommand": null,
"cli_version": "0.0.0",
"correlation_id": "cli_example",
"project_ref": "prj_example",
"environment": "test",
"execution_mode": "execute",
"status": "failed",
"operation": null,
"error": {
"source": "server",
"code": "approval_required",
"message": "승인이 필요한 작업이에요.",
"retryable": false,
"exit_code": 5,
"details": {},
"upstream_contract_version": "agent-authorization/v1"
}
}error.source:cli/local/network/server중 하나. server의 exacterror.code는 유지해요.message는 oracle이 아니에요. machine client는 exit code와error.code만 사용하세요.- exit-status 매핑: exit 2/3/4/6/7/9/10/11/13 →
failed, exit 5 중 human decision 대기면waiting_approval그 외failed, exit 8 →blocked, exit 12 →unknown.
종료 코드 closed table
| exit | 의미 | 대표 코드 |
|---|---|---|
| 0 | 정의된 outcome 성공 확정 (verify/preflight pass 포함) | succeeded |
| 2 | usage/parser/config 오류 | cli_usage_error, unsupported_cli_version, credential_ambiguous |
| 3 | 인증 부재/만료/revoked/type mismatch/replay/quarantine | agent_auth_required, agent_token_expired, agent_token_revoked, agent_token_replayed, agent_credential_quarantined |
| 4 | 인가/scope/project/environment/ownership 거부 | agent_forbidden, scope_insufficient, project_mismatch, environment_mismatch |
| 5 | approval 필요/대기/불일치로 미실행 | approval_required, approval_mismatch, waiting_approval |
| 6 | 실행됐으나 validation/doctor/preflight verdict fail/not ready | validation_failed, doctor_unhealthy, preflight_not_ready |
| 7 | authorization 통과했으나 operation definite failure | operation_failed, not_found |
| 8 | 계약/정책/production 차단 | production_blocked, environment_blocked, contract_dependency_blocked, interactive_required, dry_run_unsupported |
| 9 | network/dependency unavailable, bounded retry 소진 | dependency_unavailable, agent_auth_unavailable, agent_rate_limited |
| 10 | state conflict/idempotency reuse/checkpoint conflict | idempotency_key_reuse, checkpoint_conflict, concurrent_modification |
| 11 | local safety invariant 실패 (checkpoint/atomic write/path boundary) | local_state_unsafe, checkpoint_failed |
| 12 | interrupt/timeout으로 outcome unknown — 새 effect 만들지 말고 recovery read만 | operation_outcome_unknown |
| 13 | CLI internal defect/serialization failure | cli_internal_error |
machine client를 위한 실용 규칙
- shell/wrapper가 exit code를 삼키면 안 돼요.
retryable=true는 bounded retry만 의미해요. 무한 재시도 금지. serverretry_after_seconds가 있으면 존중하세요.- exit 12
operation_outcome_unknown은 절대 성공으로 추정하지 마세요. 같은 canonical command/body와 **같은--idempotency-key**로 다시 실행해 durable replay를 받아야 해요. 새 key로 대체하지 마세요. - unknown upstream error code는 exit 9
dependency_contract_invalid하나로 fail closed돼요. - replay/quarantine 계열(
agent_token_replayed,agent_credential_quarantined, exit 3)은 transient가 아니에요. 자동 재시도/재enrollment를 시도하지 말고 명시적 human browser flow로만 복구하세요.
project/environment mismatch의 deterministic pre-check
server-backed 요청 전에 CLI는 network 요청 0회로 로컬 pre-check를 해요:
--project-ref가 credential family binding과 다르면 → exit 4project_mismatch(error.source=cli) 정확히 하나.- project가 exact 일치할 때만 environment 검사 → 다르면 exit 4
environment_mismatch. - 둘 다 mismatch면
project_mismatch만 보고해요.
operation object (mutating 명령)
| 필드 | 의미 |
|---|---|
operation_class | 예: preview.create, integration.apply_local |
operation_ref | server/local ref 또는 null |
effect_scope | local / server / local_and_server |
idempotency_key_fingerprint | raw key가 아니라 lowercase hex SHA-256 fingerprint |
parameter_hash | server가 echo한 keyed hash. CLI 자체 계산값 금지. local-only면 null |
approval_ref | 사용된 approval ref 또는 null |
completion | synchronous / asynchronous / unknown |
recovery | none / operation_ref_read / checkpoint_restore |
next_actions 주의
next_actions[].command는 catalog의 canonical command만 담아요. CLI와 agent는 이를 자동 실행하지 않아요. 실행 시 새 invocation의 입력 검증/authorization/dry-run/approval 규칙을 다시 적용해야 해요.