gabriel / muse public
feat patch task/maintenance #1 / 1
gabriel · 166 days ago · Apr 14, 2026 · Diff

feat: muse maintenance — scheduled store maintenance orchestration

Implements muse maintenance with three subcommands:

maintenance run [--task gc|verify-objects] [--all] [--dry-run] [--json] Executes selected tasks; persists last-run timestamps to .muse/maintenance.json. --dry-run previews without mutations.

maintenance status [--json] Shows schedule config (enabled, period_hours) and per-task last-run timestamps.

maintenance schedule [--period-hours N] [--enable] [--disable] Updates .muse/maintenance.json schedule configuration.

Tasks: gc — run_gc(full=True); removes unreachable objects, commits, and snapshots from the store. verify-objects — rehashes every object file; reports checked/failed.

JSON output for run: {tasks_run, results: {gc: {...}, verify-objects: {...}}, dry_run, elapsed_seconds}

- muse/cli/commands/maintenance.py: full implementation - muse/cli/app.py: maintenance registered as maintenance - tests/test_cmd_maintenance.py: 25 tests covering run/status/schedule, dry-run semantics, JSON schema, corrupt-object detection, 100-object stress

Closes #15

sha256:c67667c855a952b2c715c746eae439ea8824ba48aa3c9d1bb8f3e408576a2c3d sha
+82 ~113 symbols
sha256:3ce48e92f770920516f80019626881c683b6b16249182f2cfbab79b6d03a4ce8 snapshot
+82
symbols added
~113
symbols modified
0
dead code introduced
Semantic Changes 195 symbols
~ muse/cli/commands/maintenance.py .py 29 symbols added
+ _ALL_TASKS variable variable _ALL_TASKS L75–75
+ _CONFIG_FILE variable variable _CONFIG_FILE L78–78
+ _DEFAULT_PERIOD_HOURS variable variable _DEFAULT_PERIOD_HOURS L77–77
+ _DEFAULT_TASKS variable variable _DEFAULT_TASKS L76–76
+ _TASK_RUNNERS variable variable _TASK_RUNNERS L199–202
+ _cmd_run function function _cmd_run L205–277
+ _cmd_schedule function function _cmd_schedule L306–327
+ _cmd_status function function _cmd_status L280–303
+ _config_path function function _config_path L86–88
+ _now_iso function function _now_iso L115–116
+ _read_config function function _read_config L91–108
+ _run_gc function function _run_gc L124–141
+ _run_verify_objects function function _run_verify_objects L144–191
+ _write_config function function _write_config L111–112
+ Any import import Any L63–63
+ ExitCode import import ExitCode L65–65
+ _DEFAULT_GRACE_PERIOD_SECONDS import import _DEFAULT_GRACE_PERIOD_SECONDS L66–66
+ _json import import _json L59–59
+ annotations import import annotations L55–55
+ argparse import import argparse L57–57
+ datetime import import datetime L58–58
+ logging import import logging L60–60
+ require_repo import import require_repo L67–67
+ run_gc import import run_gc L66–66
+ sys import import sys L61–61
+ time import import time L62–62
+ logger variable variable logger L69–69
+ register function function register L335–417
+ run function function run L425–427
~ tests/test_cmd_maintenance.py .py 52 symbols added
+ TestRun class class TestRun L80–164
+ test_run_all method method test_run_all L116–122
+ test_run_creates_config_if_missing method method test_run_creates_config_if_missing L93–97
+ test_run_dry_run_flag_in_json method method test_run_dry_run_flag_in_json L158–164
+ test_run_dry_run_no_config_written method method test_run_dry_run_no_config_written L124–130
+ test_run_exits_zero method method test_run_exits_zero L81–84
+ test_run_json_schema method method test_run_json_schema L132–140
+ test_run_json_tasks_run_is_list method method test_run_json_tasks_run_is_list L142–149
+ test_run_records_timestamp method method test_run_records_timestamp L86–91
+ test_run_task_gc method method test_run_task_gc L99–104
+ test_run_task_verify_objects method method test_run_task_verify_objects L106–114
+ test_run_unknown_task_exits_nonzero method method test_run_unknown_task_exits_nonzero L151–156
+ TestSchedule class class TestSchedule L211–255
+ test_schedule_default_period_is_24 method method test_schedule_default_period_is_24 L251–255
+ test_schedule_disable method method test_schedule_disable L221–227
+ test_schedule_enable method method test_schedule_enable L229–235
+ test_schedule_invalid_period_exits_nonzero method method test_schedule_invalid_period_exits_nonzero L244–249
+ test_schedule_period_hours method method test_schedule_period_hours L212–219
+ test_schedule_status_reflects_period method method test_schedule_status_reflects_period L237–242
+ TestStatus class class TestStatus L172–203
+ test_status_json_has_last_run_timestamp method method test_status_json_has_last_run_timestamp L195–203
+ test_status_json_no_config method method test_status_json_no_config L179–186
+ test_status_no_config method method test_status_no_config L173–177
+ test_status_shows_last_run_after_run method method test_status_shows_last_run_after_run L188–193
+ TestStress class class TestStress L307–319
+ test_100_objects_verify_all_pass method method test_100_objects_verify_all_pass L308–319
+ TestVerifyObjectsIntegration class class TestVerifyObjectsIntegration L263–299
+ test_verify_objects_detects_corrupt_object method method test_verify_objects_detects_corrupt_object L275–289
+ test_verify_objects_json_has_checked_count method method test_verify_objects_json_has_checked_count L291–299
+ test_verify_objects_passes_on_clean_store method method test_verify_objects_passes_on_clean_store L264–273
+ _REPO_ID variable variable _REPO_ID L33–33
+ _env function function _env L56–57
+ _init_repo function function _init_repo L45–53
+ _invoke function function _invoke L60–62
+ _maint_config function function _maint_config L65–66
+ _sha function function _sha L41–42
+ _write_object function function _write_object L69–72
+ CliRunner import import CliRunner L25–25
+ Manifest import import Manifest L29–29
+ SnapshotRecord import import SnapshotRecord L28–28
+ annotations import import annotations L14–14
+ compute_snapshot_id import import compute_snapshot_id L27–27
+ datetime import import datetime L16–16
+ hashlib import import hashlib L17–17
+ json import import json L18–18
+ pathlib import import pathlib L19–19
+ pytest import import pytest L23–23
+ time import import time L20–20
+ mock import import unittest.mock L21–21
+ write_object import import write_object L26–26
+ write_snapshot import import write_snapshot L28–28
+ runner variable variable runner L31–31
← Older Oldest on task/maintenance
All commits
Newer → Latest on task/maintenance

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