gabriel / muse public
feat patch agent task/agent-json-schema #1 / 1
gabriel · 158 days ago · Apr 16, 2026 · Diff

feat(agent): JSON error responses + schema tests

- Add _emit_error() helper: prints {error, message} JSON to stdout (or plain text to stderr) before raising SystemExit(1) - _require_mnemonic, _resolve_hub_url now accept as_json kwarg and forward to _emit_error so agents get structured errors on every failure - run_keygen, run_list, run_register all pass as_json through from args - Add tests/test_agent_json_schema.py (24 tests covering I–IV): keygen schema invariants, list schema, register schema, JSON error paths (IV1–IV6: no_identity, no_mnemonic, invalid_account, no_hub)

sha256:eeff8965a8a5e09879261d0eb6b83c5cb3d2ba08752095b5d712c74ee9e44f41 sha
+50 ~5 symbols
sha256:320123feb8bb8bd93c310d0f93b63890919fd88c4f5c161bd2f0587e2528d390 snapshot
+50
symbols added
~5
symbols modified
0
dead code introduced
Semantic Changes 55 symbols
~ tests/test_agent_json_schema.py .py 49 symbols added
+ TestErrorPathsIV class class TestErrorPathsIV L337–450
+ test_IV1_keygen_no_identity_json_error method method test_IV1_keygen_no_identity_json_error L338–355
+ test_IV2_keygen_no_mnemonic_json_error method method test_IV2_keygen_no_mnemonic_json_error L357–376
+ test_IV3_keygen_negative_account_json_error method method test_IV3_keygen_negative_account_json_error L378–393
+ test_IV4_keygen_no_hub_json_error method method test_IV4_keygen_no_hub_json_error L395–412
+ test_IV5_error_has_error_key method method test_IV5_error_has_error_key L414–431
+ test_IV6_error_has_message_key method method test_IV6_error_has_message_key L433–450
+ TestKeygenSchemaI class class TestKeygenSchemaI L145–217
+ test_I1_all_required_keys_present method method test_I1_all_required_keys_present L146–151
+ test_I2_status_is_ok method method test_I2_status_is_ok L153–157
+ test_I3_hd_seed_b64_decodes_to_64_bytes method method test_I3_hd_seed_b64_decodes_to_64_bytes L159–164
+ test_I4_public_key_b64_decodes_to_32_bytes method method test_I4_public_key_b64_decodes_to_32_bytes L166–171
+ test_I5_fingerprint_is_sha256_of_public_key method method test_I5_fingerprint_is_sha256_of_public_key L173–181
+ test_I6_name_is_null_without_name_flag method method test_I6_name_is_null_without_name_flag L183–187
+ test_I7_name_reflects_name_flag method method test_I7_name_reflects_name_flag L189–199
+ test_I8_msign_path_contains_account_index method method test_I8_msign_path_contains_account_index L201–211
+ test_I9_hub_is_full_url method method test_I9_hub_is_full_url L213–217
+ TestListSchemaII class class TestListSchemaII L225–294
+ test_II1_returns_json_array method method test_II1_returns_json_array L226–234
+ test_II2_empty_array_when_no_slots method method test_II2_empty_array_when_no_slots L236–244
+ test_II3_each_entry_has_required_keys method method test_II3_each_entry_has_required_keys L246–261
+ test_II4_entries_sorted_by_account method method test_II4_entries_sorted_by_account L263–277
+ test_II5_hub_is_hostname_not_url method method test_II5_hub_is_hostname_not_url L279–294
+ TestRegisterSchemaIII class class TestRegisterSchemaIII L302–329
+ test_III1_all_required_keys_present method method test_III1_all_required_keys_present L303–308
+ test_III2_status_is_ok method method test_III2_status_is_ok L310–314
+ test_III3_hub_is_hostname method method test_III3_hub_is_hostname L316–322
+ test_III4_msign_path_contains_account_index method method test_III4_msign_path_contains_account_index L324–329
+ _KEYGEN_REQUIRED_KEYS variable variable _KEYGEN_REQUIRED_KEYS L59–62
+ _LIST_ENTRY_REQUIRED_KEYS variable variable _LIST_ENTRY_REQUIRED_KEYS L63–63
+ _REGISTER_REQUIRED_KEYS variable variable _REGISTER_REQUIRED_KEYS L64–64
+ _TEST_HOSTNAME variable variable _TEST_HOSTNAME L53–53
+ _TEST_HUB variable variable _TEST_HUB L52–52
+ _TEST_MNEMONIC variable variable _TEST_MNEMONIC L54–57
+ _keygen function function _keygen L109–119
+ _list_slots function function _list_slots L122–127
+ _register function function _register L130–137
+ cli variable variable cli L49–49
+ identity_with_mnemonic function function identity_with_mnemonic L97–106
+ CliRunner import import CliRunner L47–47
+ annotations import import annotations L38–38
+ base64 import import base64 L40–40
+ hashlib import import hashlib L41–41
+ json import import json L42–42
+ pathlib import import pathlib L43–43
+ pytest import import pytest L45–45
+ isolated_identity function function isolated_identity L73–81
+ isolated_slots function function isolated_slots L85–93
+ runner variable variable runner L50–50
~ muse/cli/commands/agent.py .py 1 symbol added, 5 symbols modified
+ _emit_error function function _emit_error L186–202
← Older Oldest on task/agent-json-schema
All commits
Newer → Latest on task/agent-json-schema

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:eeff8965a8a5e09879261d0eb6b83c5cb3d2ba08752095b5d712c74ee9e44f41 --body "your comment"