claw-code/tests
YeonGyu-Kim ded0c5bbc1 test: #173 prep — JSON envelope field consistency validation
Adds parametrised test suite validating that clawable-surface commands'
JSON output matches their declared envelope contracts per SCHEMAS.md.

Two phases:

Phase 1 (this commit): Consistency baseline.
  - Collect ENVELOPE_CONTRACTS registry mapping each command to its
    required and optional fields
  - TestJsonEnvelopeConsistency: parametrised test iterates over 13
    commands, invokes with --output-format json, validates that
    actual JSON envelope contains all required fields
  - test_envelope_field_value_types: spot-check types (int, str, list)
    for consistency

Phase 2 (future #173): Common field wrapping.
  - Once wrap_json_envelope() is applied, all commands will emit
    timestamp, command, exit_code, output_format, schema_version
  - Currently skipped via @pytest.mark.skip, these tests will activate
    automatically when wrapping is implemented:
      TestJsonEnvelopeCommonFieldPrep::test_all_envelopes_include_timestamp
      TestJsonEnvelopeCommonFieldPrep::test_all_envelopes_include_command
      TestJsonEnvelopeCommonFieldPrep::test_all_envelopes_include_exit_code_and_schema_version

Why this matters:
  - #172 documented the JSON contract; this test validates it
  - Currently detects when actual output diverges from SCHEMAS.md
    (e.g. list-sessions emits 'count', not 'sessions_count')
  - As #173 wraps commands, test suite auto-validates new common fields
  - Prevents regression: accidental field removal breaks the test suite

Current status: 11 passed (consistency), 6 skipped (awaiting #173)
Full suite: 168 → 179 passing, zero regression.

Closes ROADMAP #173 prep (framework for common field validation).
Actual field wrapping remains for next cycle.
2026-04-22 19:20:15 +09:00
..
test_cli_parity_audit.py fix: #171 — automate cross-surface CLI parity audit via argparse introspection 2026-04-22 19:02:10 +09:00
test_command_graph_tool_pool_output_format.py fix: #169 — command-graph and tool-pool now accept --output-format; diagnostic inventory JSON parity 2026-04-22 18:47:34 +09:00
test_exec_route_bootstrap_output_format.py fix: #168 — exec-command / exec-tool / route / bootstrap now accept --output-format; CLI family JSON parity COMPLETE 2026-04-22 18:34:26 +09:00
test_flush_transcript_cli.py fix: #166 — flush-transcript now accepts --directory / --output-format / --session-id; session-creation command parity with #160/#165 lifecycle triplet 2026-04-22 18:04:25 +09:00
test_json_envelope_field_consistency.py test: #173 prep — JSON envelope field consistency validation 2026-04-22 19:20:15 +09:00
test_load_session_cli.py fix: #165 — load-session CLI now parity-matches list/delete (--directory, --output-format, typed JSON errors) 2026-04-22 17:44:48 +09:00
test_porting_workspace.py feat(#160): wire claw list-sessions and delete-session CLI commands 2026-04-22 17:16:53 +09:00
test_run_turn_loop_cancellation.py fix: #164 Stage A — cooperative cancellation via cancel_event in submit_message 2026-04-22 18:14:14 +09:00
test_run_turn_loop_continuation.py fix: #163 — remove [turn N] suffix pollution from run_turn_loop; file #164 timeout-cancellation followup 2026-04-22 17:37:22 +09:00
test_run_turn_loop_permissions.py fix: #159 — run_turn_loop no longer hardcodes empty denied_tools; permission denials now parity-match bootstrap_session 2026-04-22 17:50:21 +09:00
test_run_turn_loop_timeout.py fix: #164 Stage A — cooperative cancellation via cancel_event in submit_message 2026-04-22 18:14:14 +09:00
test_session_store.py fix(#160): harden delete_session contract — idempotency, race-safety, typed partial-failure 2026-04-22 17:11:26 +09:00
test_show_command_tool_output_format.py fix: #167 — show-command and show-tool now accept --output-format flag; CLI parity with session-lifecycle family 2026-04-22 18:21:38 +09:00
test_submit_message_budget.py fix: #162 — budget-overflow no longer corrupts session state in submit_message 2026-04-22 17:29:55 +09:00
test_submit_message_cancellation.py fix: #164 Stage A — cooperative cancellation via cancel_event in submit_message 2026-04-22 18:14:14 +09:00