gabriel / muse public
feat patch feat/54-reflog-watch #1 / 1
AI Agent gabriel · 9 hours ago · Oct 21, 2026 · Diff

feat: muse#54 item 10 — muse reflog watch live-tail

Adds `muse reflog watch [--branch <name>] [--once] [--timeout SECONDS] [--max-events N] [--poll-interval SECONDS] [--json]`: streams reflog events as NDJSON, mirroring `muse coord watch`'s conventions (snapshot + incremental events, SIGTERM -> clean exit, --once for a deterministic one-shot read).

On start, emits a "snapshot" event for every pre-existing entry (oldest first), then polls the log file at --poll-interval and emits an "appended" event for each newly written entry, until --timeout or --max-events is reached or the process is interrupted (SIGINT/SIGTERM both exit cleanly, matching `muse coord watch`). --once prints just the snapshot and exits immediately — useful for scripting a deterministic baseline read without waiting on real-time activity.

@{N} index fields on emitted events reflect the log's state at the moment of emission (0 = newest), the same convention `muse reflog --json` already uses.

Covered by tests/test_reflog_watch.py (7 cases: snapshot-only via --once with correct chronological ordering and indices, empty reflog, --branch targeting, invalid branch name, invalid --poll-interval, --max-events capping the snapshot, and a real appended-event detected mid-poll via a monkeypatched time.sleep that writes a new raw reflog line on its first call). Confirmed genuine RED by reverting the fix file and re-running (all 7 failed, exit 2, unrecognized subcommand), then GREEN with the fix restored plus the full reflog regression suite (127 passed, zero regressions). Live-verified via muse-dev: --once against a disposable /tmp sandbox, plus a real background `reflog watch --timeout 5` process that correctly detected and emitted a commit made by a separate `muse-dev commit` call while it was running.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

sha256:799dc6f15b7dba389fdf5f088cd5e210da5fb66ec4b1ec9db7b16cde0e8fe734 sha
+32 ~4 symbols
3 changed · 1229 in snapshot files
sha256:e2d7f5748353a0f7b8ff2e88a35cc224145ca01d120509b416078a3949f5cfed snapshot
+32
symbols added
~4
symbols modified
3
files changed
1229
files in snapshot
0
dead code introduced
Semantic Changes 36 symbols
~ tests/test_reflog_watch.py .py 26 symbols added
+ TestReflogWatchAppended class class TestReflogWatchAppended L114–143
+ test_appended_event_detected_during_poll method method test_appended_event_detected_during_poll L115–143
+ TestReflogWatchOnce class class TestReflogWatchOnce L59–111
+ test_invalid_branch_name_errors method method test_invalid_branch_name_errors L92–95
+ test_invalid_poll_interval_errors method method test_invalid_poll_interval_errors L97–100
+ test_max_events_caps_snapshot method method test_max_events_caps_snapshot L102–111
+ test_once_emits_snapshot_only method method test_once_emits_snapshot_only L60–74
+ test_once_empty_reflog_emits_nothing method method test_once_empty_reflog_emits_nothing L76–80
+ test_once_respects_branch_flag method method test_once_respects_branch_flag L82–90
+ _commit_file function function _commit_file L46–52
+ _env function function _env L22–23
+ _init_repo function function _init_repo L30–43
+ _ndjson_lines function function _ndjson_lines L55–56
+ _run function function _run L26–27
+ cli variable variable cli L18–18
+ CliRunner import import CliRunner L14–14
+ Manifest import import Manifest L15–15
+ NULL_COMMIT_ID import import NULL_COMMIT_ID L15–15
+ annotations import import annotations L7–7
+ fake_id import import fake_id L15–15
+ json import import json L9–9
+ logs_dir import import logs_dir L16–16
+ muse_dir import import muse_dir L16–16
+ pathlib import import pathlib L10–10
+ pytest import import pytest L12–12
+ runner variable variable runner L19–19
~ muse/cli/commands/reflog.py .py 6 symbols added, 1 symbol modified
+ _print_watch_event function function _print_watch_event L1077–1090
+ _watch_event function function _watch_event L1063–1074
+ __version__ import import __version__ L83–83
+ signal import import signal L77–77
+ types import import types L80–80
+ run_watch function function run_watch L1093–1210
Files Changed
+1 ~2
1229 in snapshot
← Older Oldest on feat/54-reflog-watch
All commits
Newer → Latest on feat/54-reflog-watch

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