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

feat: implement muse count-objects — object store diagnostics

- _count_loose_objects: stat-only walk of .muse/objects/<shard>/<id> using os.scandir; no content reads; returns (count, bytes) - _count_by_shard: per-shard breakdown for --verbose; sorted by prefix - _collect_reachable_ids: BFS from all branch tips following parent_commit_id chains; collects every blob object_id in every referenced snapshot manifest - run: loose count + optional --unreachable (store walk minus reachable set) + optional --verbose shard breakdown; --json or text output - JSON schema: loose_objects, loose_size_kb, total_objects, total_size_kb, object_store_path, unreachable_objects (opt), shards (opt) - 21 tests: unit helpers (empty/single/multi-shard, reachable BFS), integration (schema, count accuracy, size, --verbose shard sum, --unreachable zero and orphan detection, empty repo, text format), security (read-only mutation guard), stress (200-obj store, 10-commit multi-file repo with proper parent chain)

sha256:d7f496024350a0fcbb94ef0a6916b95edb93592e486b7d325c3c374c7952d204 sha
+66 ~27 symbols
sha256:589e9b59d91aa41daa91d15fce33e20a6ddbae84638c6c4bc6f3e23cdf90795d snapshot
+66
symbols added
~27
symbols modified
0
dead code introduced
Semantic Changes 93 symbols
~ muse/cli/commands/count_objects.py .py 20 symbols added
+ _collect_reachable_ids function function _collect_reachable_ids L163–217
+ _count_by_shard function function _count_by_shard L118–160
+ _count_loose_objects function function _count_loose_objects L77–115
+ ExitCode import import ExitCode L60–60
+ _json import import _json L53–53
+ annotations import import annotations L50–50
+ argparse import import argparse L52–52
+ deque import import deque L58–58
+ get_head_commit_id import import get_head_commit_id L63–63
+ logging import import logging L54–54
+ objects_dir import import objects_dir L61–61
+ os import import os L55–55
+ pathlib import import pathlib L56–56
+ read_commit import import read_commit L63–63
+ read_snapshot import import read_snapshot L63–63
+ require_repo import import require_repo L62–62
+ sys import import sys L57–57
+ logger variable variable logger L69–69
+ register function function register L225–256
+ run function function run L264–336
~ tests/test_cmd_count_objects.py .py 45 symbols added
+ _REPO_ID variable variable _REPO_ID L31–31
+ _commit_files function function _commit_files L59–97
+ _counter variable variable _counter L32–32
+ _env function function _env L55–56
+ _init_repo function function _init_repo L44–52
+ _invoke function function _invoke L100–102
+ _sha function function _sha L40–41
+ CliRunner import import CliRunner L23–23
+ CommitRecord import import CommitRecord L26–26
+ Manifest import import Manifest L27–27
+ SnapshotRecord import import SnapshotRecord L26–26
+ annotations import import annotations L13–13
+ compute_commit_id import import compute_commit_id L25–25
+ compute_snapshot_id import import compute_snapshot_id L25–25
+ datetime import import datetime L15–15
+ hashlib import import hashlib L16–16
+ json import import json L17–17
+ os import import os L18–18
+ pathlib import import pathlib L19–19
+ pytest import import pytest L21–21
+ write_commit import import write_commit L26–26
+ write_object import import write_object L24–24
+ write_snapshot import import write_snapshot L26–26
+ runner variable variable runner L29–29
+ test_collect_reachable_ids_after_commit function function test_collect_reachable_ids_after_commit L153–159
+ test_collect_reachable_ids_empty_repo function function test_collect_reachable_ids_empty_repo L145–150
+ test_collect_reachable_ids_includes_all_blobs function function test_collect_reachable_ids_includes_all_blobs L162–170
+ test_count_loose_objects_empty_store function function test_count_loose_objects_empty_store L110–115
+ test_count_loose_objects_multiple_shards function function test_count_loose_objects_multiple_shards L129–137
+ test_count_loose_objects_single_object function function test_count_loose_objects_single_object L118–126
+ test_count_objects_does_not_modify_store function function test_count_objects_does_not_modify_store L315–334
+ test_count_objects_json_count_matches_written function function test_count_objects_json_count_matches_written L189–197
+ test_count_objects_json_empty_store function function test_count_objects_json_empty_store L200–206
+ test_count_objects_json_object_store_path_present function function test_count_objects_json_object_store_path_present L217–221
+ test_count_objects_json_schema_keys function function test_count_objects_json_schema_keys L178–186
+ test_count_objects_json_size_nonzero_after_write function function test_count_objects_json_size_nonzero_after_write L209–214
+ test_count_objects_large_store function function test_count_objects_large_store L342–351
+ test_count_objects_text_mentions_count function function test_count_objects_text_mentions_count L237–243
+ test_count_objects_text_output_nonempty function function test_count_objects_text_output_nonempty L229–234
+ test_count_objects_unreachable_detects_orphan_blobs function function test_count_objects_unreachable_detects_orphan_blobs L290–299
+ test_count_objects_unreachable_empty_repo function function test_count_objects_unreachable_empty_repo L302–307
+ test_count_objects_unreachable_large_repo function function test_count_objects_unreachable_large_repo L354–363
+ test_count_objects_unreachable_zero_after_clean_commit function function test_count_objects_unreachable_zero_after_clean_commit L279–287
+ test_count_objects_verbose_json_has_shards function function test_count_objects_verbose_json_has_shards L251–260
+ test_count_objects_verbose_shards_sum_to_total function function test_count_objects_verbose_shards_sum_to_total L263–271
← Older Oldest on task/count-objects
All commits
Newer → Latest on task/count-objects

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