gabriel / muse public
feat patch restore task/supercharge-restore #1 / 1
AI Agent gabriel · 162 days ago · Apr 17, 2026 · Diff

feat(restore): supercharge — elapsed_ms, exit_code, INTERNAL_ERROR fix, full docstrings

- Add elapsed_ms (wall-clock ms) and exit_code to --json output so agents can budget time and branch on error type without parsing shell exit codes - Fix critical bug: restore_object() failure now exits 3 (INTERNAL_ERROR) instead of silently mapping to 1 (USER_ERROR) - Remove always-empty skipped field from _RestoreResult; replace with the two-field any_user_error / any_io_error distinction that drives exit code - Suppress per-file stderr prints in --json mode to keep stdout valid JSON - Add summary text line: 'Restored N file(s).' after non-JSON output - Add logger.debug / logger.error calls throughout run() - Expand _RestoreResult, _resolve_source_manifest, _resolve_file_path, and run() docstrings to cover all edge cases and the agent-facing JSON schema - Fix test_cmd_restore.py _sha() to emit sha256: prefix (was breaking 23/26) - Add 20-test supercharge suite covering: performance (elapsed_ms timing), data integrity (schema completeness, field types), INTERNAL_ERROR exit code 3, concurrent two-thread restore, source+staged combos, summary text output

sha256:c7d2ed76a997734cf49aa0d76048a6507f0ee0ccf2b667eb3492018dc8f4797a sha
+50 ~5 symbols
sha256:9c23ce6f11a59582a97a8972352ca922ca9639fbe460968aa02bf2e5597be98e snapshot
+50
symbols added
~5
symbols modified
0
dead code introduced
Semantic Changes 55 symbols
~ tests/test_cmd_restore_supercharge.py .py 49 symbols added
+ _REPO_ID variable variable _REPO_ID L35–35
+ _commit_files function function _commit_files L58–87
+ _counter variable variable _counter L36–36
+ _env function function _env L54–55
+ _init_repo function function _init_repo L43–51
+ _invoke function function _invoke L90–92
+ _sha function function _sha L39–40
+ CliRunner import import CliRunner L25–25
+ CommitRecord import import CommitRecord L29–29
+ Manifest import import Manifest L30–30
+ SnapshotRecord import import SnapshotRecord L29–29
+ StagedFileMap import import StagedFileMap L31–31
+ annotations import import annotations L14–14
+ compute_commit_id import import compute_commit_id L28–28
+ compute_snapshot_id import import compute_snapshot_id L28–28
+ datetime import import datetime L20–20
+ hashlib import import hashlib L21–21
+ json import import json L16–16
+ make_entry import import make_entry L31–31
+ pathlib import import pathlib L17–17
+ pytest import import pytest L23–23
+ read_stage import import read_stage L31–31
+ threading import import threading L18–18
+ time import import time L19–19
+ write_commit import import write_commit L29–29
+ write_object import import write_object L27–27
+ write_snapshot import import write_snapshot L29–29
+ write_stage import import write_stage L31–31
+ runner variable variable runner L33–33
+ test_resolve_source_manifest_bad_ref_returns_empty function function test_resolve_source_manifest_bad_ref_returns_empty L427–433
+ test_resolve_source_manifest_valid_ref function function test_resolve_source_manifest_valid_ref L436–444
+ test_restore_50_files_elapsed_ms_reasonable function function test_restore_50_files_elapsed_ms_reasonable L475–488
+ test_restore_concurrent_independent_files function function test_restore_concurrent_independent_files L304–338
+ test_restore_dry_run_json_has_elapsed_ms function function test_restore_dry_run_json_has_elapsed_ms L126–135
+ test_restore_elapsed_ms_is_reasonable function function test_restore_elapsed_ms_is_reasonable L114–123
+ test_restore_json_exit_code_one_when_file_not_found function function test_restore_json_exit_code_one_when_file_not_found L174–182
+ test_restore_json_exit_code_zero_on_success function function test_restore_json_exit_code_zero_on_success L162–171
+ test_restore_json_has_elapsed_ms function function test_restore_json_has_elapsed_ms L100–111
+ test_restore_json_not_found_list_correct function function test_restore_json_not_found_list_correct L198–207
+ test_restore_json_restored_list_correct function function test_restore_json_restored_list_correct L185–195
+ test_restore_json_schema_complete_on_success function function test_restore_json_schema_complete_on_success L143–159
+ test_restore_json_staged_and_worktree_flags_reflect_args function function test_restore_json_staged_and_worktree_flags_reflect_args L210–222
+ test_restore_missing_object_exits_3 function function test_restore_missing_object_exits_3 L230–263
+ test_restore_missing_object_json_exit_code_3 function function test_restore_missing_object_json_exit_code_3 L266–296
+ test_restore_source_and_staged_clears_stage_from_source function function test_restore_source_and_staged_clears_stage_from_source L346–367
+ test_restore_source_staged_worktree_restores_from_source function function test_restore_source_staged_worktree_restores_from_source L370–388
+ test_restore_staged_only_source_does_not_require_disk_file function function test_restore_staged_only_source_does_not_require_disk_file L452–467
+ test_restore_text_output_errors_noted function function test_restore_text_output_errors_noted L409–419
+ test_restore_text_output_summary_line function function test_restore_text_output_summary_line L396–406
~ muse/cli/commands/restore.py .py 1 symbol added, 4 symbols modified
+ time import import time L75–75
~ run
~ tests/test_cmd_restore.py .py 1 symbol modified
~ _sha
← Older Oldest on task/supercharge-restore
All commits
Newer → Latest on task/supercharge-restore

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:c7d2ed76a997734cf49aa0d76048a6507f0ee0ccf2b667eb3492018dc8f4797a --body "your comment"