Skip to content

refactor(daemon): move live watch into polylogued - #680

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/polylogued-watch
May 2, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/polylogued-watch

Conversation

@Sinity

@Sinity Sinity commented May 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Moves the standalone live source watcher out of the query-first polylogue CLI and into a new daemon executable, polylogued watch.

Problem

The UX direction keeps polylogue focused on archive querying and one-shot operations while long-running live ingestion belongs to a daemon/service surface. The old root polylogue watch command mixed those concerns and kept service mode beside query verbs.

Solution

  • Added the polylogued console script and polylogue.daemon.cli entrypoint.
  • Moved the live watcher command to polylogued watch while preserving its source/default-root/debounce behavior.
  • Removed the root polylogue watch registration and refreshed CLI help baselines, proof catalog, topology, and scenario projections.
  • Kept polylogue run --watch unchanged because it is the continuous pipeline-run mode, not the standalone source tailer.

Verification

  • ruff format polylogue tests devtools
  • ruff check polylogue tests devtools --fix
  • pytest -q tests/unit/daemon/test_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py tests/unit/showcase/test_exercise_catalog.py → 94 passed
  • devtools render-all --check
  • devtools verify-topology
  • devtools verify-layering
  • devtools verify-test-ownership
  • mypy polylogue/
  • devtools verify --quick
  • devtools build-package
  • .local/result/bin/polylogued --help
  • .local/result/bin/polylogued watch --help
  • push hook reran devtools verify --quick successfully

Ref #635
Ref #593

Summary by CodeRabbit

  • New Features

    • Introduced polylogued daemon executable for managing live source watching via polylogued watch.
  • Changed

    • Live source watching moved from root CLI to daemon subcommand.
    • polylogue run --watch remains available for continuous pipeline execution.

Problem: the standalone live source watcher was still exposed as a root polylogue command, mixing long-running service mode into the query-first archive CLI while the UX direction calls for daemon-owned live ingestion.\n\nWhat changed: add the polylogued console script and daemon Click entrypoint, move the live watcher command behind polylogued watch, remove the root polylogue watch registration, and refresh generated CLI/proof/topology/showcase surfaces. The pipeline run --watch mode remains unchanged.\n\nVerification: ruff format polylogue tests devtools; ruff check polylogue tests devtools --fix; pytest -q tests/unit/daemon/test_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py tests/unit/showcase/test_exercise_catalog.py; devtools render-all --check; devtools verify-topology; devtools verify-layering; devtools verify-test-ownership; mypy polylogue/; devtools verify --quick; devtools build-package; .local/result/bin/polylogued --help; .local/result/bin/polylogued watch --help.\n\nRef #635\nRef #593
Copilot AI review requested due to automatic review settings May 2, 2026 00:24
@coderabbitai

coderabbitai Bot commented May 2, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 32 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b965c550-5a41-4f7b-88bc-0188894567f1

📥 Commits

Reviewing files that changed from the base of the PR and between bb0e8ce and a4dea6e.

📒 Files selected for processing (1)
  • tests/unit/daemon/test_daemon_cli.py
📝 Walkthrough

Walkthrough

The PR relocates the watch command from the root polylogue CLI to a separate daemon entrypoint polylogued. The watch command is removed from root CLI registration, the daemon CLI is restructured around a click.group entrypoint, a new polylogued console script is registered, and all documentation and tests are updated to reflect the new command structure.

Changes

Watch Command CLI Restructure

Layer / File(s) Summary
Daemon CLI Restructuring
polylogue/daemon/cli.py
Converts CLI from standalone watch command to a click.group entrypoint main(). Renames internal _run to public run_live_watcher() and updates watch_command to remove AppEnv dependency. Exports main, run_live_watcher, and watch_command in __all__.
Daemon Package Init
polylogue/daemon/__init__.py
Creates package initializer re-exporting main from polylogue.daemon.cli as the public daemon entrypoint.
Root CLI Registration
polylogue/cli/click_command_registration.py
Removes watch_command import and deletes it from ROOT_COMMANDS tuple, eliminating the root-level polylogue watch command.
Console Script Entrypoint
pyproject.toml
Adds new polylogued script entrypoint pointing to polylogue.daemon.cli:main.
CLI Documentation
CHANGELOG.md, README.md, docs/cli-reference.md
Documents the new polylogued watch daemon command, updates CLI shape guide, and removes root watch from reference. Notes that polylogued watch handles long-running live ingestion while polylogue run --watch remains for continuous pipeline runs.
Generated Topology Metadata
docs/plans/topology-target.yaml, docs/topology-status.md, docs/test-quality-workflows.md, docs/verification-catalog.md
Updates location counts for modified files, adds polylogue/daemon/* entries, and adjusts metrics (stable count +1, subjects −1, proof obligations −3, scenario projections −1).
CLI Help Baselines & Snapshots
tests/baselines/showcase/help-main.txt, tests/baselines/showcase/help-watch.txt, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
Removes watch command from main help output, deletes standalone help-watch.txt baseline, and updates snapshot assertions across narrow and wide terminal widths.
CLI Test Fixtures & Assertions
tests/data/witnesses/cli-command-surface.json, tests/unit/cli/test_click_app.py
Updates required_root_commands (removes watch), required_console_scripts (adds polylogued), and test assertions confirming watch is no longer a root subcommand.
Daemon CLI Unit Tests
tests/unit/daemon/test_cli.py
Adds 4 new test functions: verifying main --help includes watch, confirming default and custom root sources, validating coroutine closure, and asserting KeyboardInterrupt stops the watcher via run_live_watcher().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Suggested labels

type:refactor, area:cli, area:daemon, area:docs

Poem

🐰 The watch command hops away,
From root CLI to daemon's way,
polylogued now tends the source stream,
While polylogue run --watch keeps its dream,
A cleaner CLI for all to see! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: moving live watch functionality from the polylogue CLI into a new polylogued daemon executable.
Description check ✅ Passed The description comprehensively covers all required sections: summary of changes, problem statement, solution details, verification with specific commands, and changelog entry in CHANGELOG.md.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/polylogued-watch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 45 minutes and 32 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented May 2, 2026 •

Copy link
Copy Markdown
Contributor

Polylogue Proof Pack

Refs: origin/master..HEAD
Changed paths: 17

Affected Domains

  • architecture_discipline — 2 claim(s), maturity growing
  • distribution — 0 claim(s), maturity seed
  • docs_media — 0 claim(s), maturity seed
  • spec_completeness — 1 claim(s), maturity seed
  • test_quality — 0 claim(s), maturity growing
  • unclassified — 4 claim(s), maturity seed

Required Gates

  • devtools render-all --check — generated surface or renderer changed
  • devtools verify-manifests — structural manifest changed
  • devtools affected-obligations --path docs/plans/topology-target.yaml — refresh structural obligation routing
  • devtools verify-topology — topology projection changed
  • devtools affected-obligations --path docs/topology-status.md — refresh structural obligation routing
  • pytest tests/unit/cli — CLI command surface changed
  • pytest tests/unit/proof/test_evidence_runners.py — CLI proof runners exercise command output
  • devtools render-cli-reference --check — CLI reference is generated from command help
  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit
  • devtools build-package — deployment readiness gate; run when packaging or release confidence matters
  • nix flake check — deployment readiness gate; run when packaging or release confidence matters

Known Gaps

  • distribution: dev_install: Not verified in CI; devshell is canonical environment [owner: distribution; next: Add package/build or cross-artifact CI gate], distribution: No scenario for install/package verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], install_parity: No cross-artifact equivalence verification (wheel vs sdist vs Nix) [owner: distribution; next: Add package/build or cross-artifact CI gate], macos: No macOS CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate], sdist: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], wheel: Not built or tested in CI [owner: distribution; next: Add package/build or cross-artifact CI gate], windows: No Windows CI runner [owner: distribution; next: Add package/build or cross-artifact CI gate]
  • docs_media: docs_media: No scenario for documentation freshness verification [owner: scenario-coverage; next: Add scenario family or generated projection for this subject], docs_media: README examples and media are not yet generated from executable scenario projections. [owner: docs-media; next: Add executable scenario projection or media integrity gate], docs_media: Screenshots and VHS media have no committed nonblank/readability verification. [owner: docs-media; next: Add executable scenario projection or media integrity gate]
  • test_quality: direct_coverage: Coverage per-module not tracked (only aggregate fail_under) [owner: test-quality; next: Add measurable quality gate for this dimension], flakiness: No systematic flakiness tracking, CI retry, or quarantine [owner: test-quality; next: Add measurable quality gate for this dimension], fuzz: Atheris fuzz targets not run in CI [owner: test-quality; next: Add measurable quality gate for this dimension], mock_depth: Mock depth not measured or enforced [owner: test-quality; next: Add measurable quality gate for this dimension]

Oracle / Cost

  • oracle mix: {"construction_sanity": 185, "drift_check": 2}
  • cost tier: {"static": 182, "unit": 5}
  • stale evidence: 187
  • manual review cells: 0

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
polylogue/daemon/cli.py (1)

22-25: ⚠️ Potential issue | 🟠 Major

Ensure shutdown cleanup runs on the real Ctrl-C path.

Line 24 catches KeyboardInterrupt inside the coroutine, but with asyncio.run(...), SIGINT is delivered as task cancellation (CancelledError), not KeyboardInterrupt, so Line 25 never runs. Move watcher.stop() into finally to guarantee cleanup on interruption.

💡 Suggested fix
 async def run_live_watcher(
     *,
     sources: tuple[WatchSource, ...],
     debounce_s: float,
 ) -> None:
     async with Polylogue() as polylogue:
         watcher = LiveWatcher(polylogue, sources, debounce_s=debounce_s)
-        try:
-            await watcher.run()
-        except KeyboardInterrupt:
-            watcher.stop()
+        try:
+            await watcher.run()
+        finally:
+            watcher.stop()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/daemon/cli.py` around lines 22 - 25, The cleanup call
watcher.stop() is placed in an except KeyboardInterrupt block but asyncio.run
delivers SIGINT as task cancellation, so watcher.stop() may never run; move the
watcher.stop() invocation into a finally block that always runs after awaiting
watcher.run() (or surrounding the await watcher.run() with try/finally) so that
regardless of CancelledError or normal completion watcher.stop() is executed;
update the code around watcher.run() and watcher.stop() (the async context where
asyncio.run is used) to use try/finally instead of except KeyboardInterrupt.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/verification-catalog.md`:
- Around line 11-14: The daemon/CLI proof coverage lost bindings when `polylogue
watch` was renamed/moved; update the verification catalog to add the
daemon-scoped subjects and claim bindings for the new daemon command surface
(e.g., the `polylogued watch` command) so the proof envelope matches the current
`cli.command.*` surface—specifically add subject entries for the daemon commands
and corresponding claim entries (matching the prior `polylogue watch` bindings
such as `help`, `no_traceback`, `plain_mode`) or create an equivalent
daemon-scoped proof pack that includes those obligations; ensure the new entries
mirror the previous proof obligations count and binding names referenced in the
review (addresses around the 43-43 and 297-300 changes) so verification coverage
is preserved.

In `@tests/unit/daemon/test_cli.py`:
- Around line 40-60: The test currently only asserts the source count message
which can pass if defaults are used; update
test_polylogued_watch_builds_sources_from_roots to also verify the forwarded
roots rather than defaults by extracting the coroutine passed to asyncio.run
(variable coroutine from run.call_args) and inspecting its frame locals to
assert the roots argument contains the two provided paths (e.g., check
coroutine.cr_frame.f_locals["roots"] or the appropriate local name used by
main/watcher equals [str(root_a), str(root_b)]), then close the coroutine as
before and keep the existing exit_code and stderr message assertions.

---

Outside diff comments:
In `@polylogue/daemon/cli.py`:
- Around line 22-25: The cleanup call watcher.stop() is placed in an except
KeyboardInterrupt block but asyncio.run delivers SIGINT as task cancellation, so
watcher.stop() may never run; move the watcher.stop() invocation into a finally
block that always runs after awaiting watcher.run() (or surrounding the await
watcher.run() with try/finally) so that regardless of CancelledError or normal
completion watcher.stop() is executed; update the code around watcher.run() and
watcher.stop() (the async context where asyncio.run is used) to use try/finally
instead of except KeyboardInterrupt.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c365bb2c-3ea2-4bad-8625-70210974b873

📥 Commits

Reviewing files that changed from the base of the PR and between 92f1fc9 and bb0e8ce.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • README.md
  • docs/cli-reference.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/cli/click_command_registration.py
  • polylogue/daemon/__init__.py
  • polylogue/daemon/cli.py
  • pyproject.toml
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-watch.txt
  • tests/data/witnesses/cli-command-surface.json
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py
  • tests/unit/daemon/test_cli.py
💤 Files with no reviewable changes (5)
  • tests/baselines/showcase/help-watch.txt
  • polylogue/cli/click_command_registration.py
  • tests/unit/cli/snapshots/test_terminal_snapshots.ambr
  • tests/baselines/showcase/help-main.txt
  • docs/cli-reference.md

Comment on lines +11 to +14
- subjects: `503`
- claims: `44`
- runner bindings: `44`
- proof obligations: `576`
- proof obligations: `573`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Daemon CLI appears outside proof-obligation coverage.

These count reductions indicate polylogue watch was removed from cli.command.* claims, but there is no corresponding addition for polylogued watch. That leaves a new public command surface outside help/no_traceback/plain_mode proof contracts.

Please add daemon command subjects + claim bindings (or an equivalent daemon-scoped proof pack) so the verification envelope is preserved after the move.

Also applies to: 43-43, 297-300

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/verification-catalog.md` around lines 11 - 14, The daemon/CLI proof
coverage lost bindings when `polylogue watch` was renamed/moved; update the
verification catalog to add the daemon-scoped subjects and claim bindings for
the new daemon command surface (e.g., the `polylogued watch` command) so the
proof envelope matches the current `cli.command.*` surface—specifically add
subject entries for the daemon commands and corresponding claim entries
(matching the prior `polylogue watch` bindings such as `help`, `no_traceback`,
`plain_mode`) or create an equivalent daemon-scoped proof pack that includes
those obligations; ensure the new entries mirror the previous proof obligations
count and binding names referenced in the review (addresses around the 43-43 and
297-300 changes) so verification coverage is preserved.

Comment on lines +40 to +60
def test_polylogued_watch_builds_sources_from_roots(tmp_path: Path) -> None:
root_a = tmp_path / "claude-code"
root_b = tmp_path / "codex"

with patch("polylogue.daemon.cli.asyncio.run") as run:
result = CliRunner().invoke(
main,
[
"watch",
"--root",
str(root_a),
"--root",
str(root_b),
],
)

assert result.exit_code == 0
coroutine = run.call_args.kwargs.get("main") or run.call_args.args[0]
assert inspect.iscoroutine(coroutine)
coroutine.close()
assert "Watching 2 source(s); debounce=2.0s" in result.stderr

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

watch --root test can pass even if roots are ignored.

Right now it only checks source count/message. If code accidentally falls back to defaults with the same count, this still passes. Assert forwarded roots (and non-use of defaults) to prevent false greens.

Suggested test hardening
-from unittest.mock import patch
+from unittest.mock import AsyncMock, patch
@@
 def test_polylogued_watch_builds_sources_from_roots(tmp_path: Path) -> None:
@@
-    with patch("polylogue.daemon.cli.asyncio.run") as run:
+    with (
+        patch("polylogue.daemon.cli.default_sources") as default_sources,
+        patch("polylogue.daemon.cli.run_live_watcher", new_callable=AsyncMock) as run_live_watcher,
+        patch("polylogue.daemon.cli.asyncio.run") as run,
+    ):
         result = CliRunner().invoke(
             main,
             [
@@
     assert result.exit_code == 0
+    default_sources.assert_not_called()
+    run_live_watcher.assert_called_once()
+    forwarded_sources = run_live_watcher.call_args.kwargs["sources"]
+    assert tuple(source.root for source in forwarded_sources) == (root_a, root_b)
     coroutine = run.call_args.kwargs.get("main") or run.call_args.args[0]
     assert inspect.iscoroutine(coroutine)
     coroutine.close()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/daemon/test_cli.py` around lines 40 - 60, The test currently only
asserts the source count message which can pass if defaults are used; update
test_polylogued_watch_builds_sources_from_roots to also verify the forwarded
roots rather than defaults by extracting the coroutine passed to asyncio.run
(variable coroutine from run.call_args) and inspecting its frame locals to
assert the roots argument contains the two provided paths (e.g., check
coroutine.cr_frame.f_locals["roots"] or the appropriate local name used by
main/watcher equals [str(root_a), str(root_b)]), then close the coroutine as
before and keep the existing exit_code and stderr message assertions.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request moves the standalone live source watcher off the query-first polylogue CLI and into a dedicated daemon/service executable, polylogued, aligning long-running ingestion with a service-oriented surface.

Changes:

  • Added the polylogued console script and polylogue.daemon.cli Click entrypoint with polylogued watch.
  • Removed polylogue watch from root command registration and updated CLI surface tests/snapshots accordingly.
  • Refreshed generated docs/baselines/topology/proof catalog outputs to reflect the new command surface.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Adds the polylogued console script entrypoint.
polylogue/daemon/cli.py Introduces the daemon Click group and moves the live watcher command implementation here.
polylogue/daemon/__init__.py Exposes the daemon entrypoint at the package level.
polylogue/cli/click_command_registration.py Removes watch from the root polylogue CLI command registration.
tests/unit/daemon/test_cli.py Adds unit tests for polylogued --help and polylogued watch behavior.
tests/unit/cli/test_click_app.py Updates CLI registration expectations to ensure watch is no longer on polylogue.
tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr Updates polylogue --help snapshots to remove watch.
tests/data/witnesses/cli-command-surface.json Updates required console scripts and removes watch from required root commands.
tests/baselines/showcase/help-watch.txt Removes the old polylogue watch help baseline.
tests/baselines/showcase/help-main.txt Updates root help baseline to remove watch.
docs/cli-reference.md Removes watch from the documented polylogue command list.
docs/verification-catalog.md Regenerates proof catalog counts and removes the polylogue watch subject entry.
docs/test-quality-workflows.md Updates generated scenario projection counts and removes the help-watch exercise row.
docs/topology-status.md Updates generated topology status counts.
docs/plans/topology-target.yaml Removes the old watch command file entry and adds daemon files to the topology target.
README.md Updates usage examples to show polylogued watch.
CHANGELOG.md Documents the new daemon executable and the migration from polylogue watch to polylogued watch.
Comments suppressed due to low confidence (3)

polylogue/daemon/cli.py:26

  • run_live_watcher() catches KeyboardInterrupt, but when running under asyncio.run() a Ctrl-C typically cancels the running task (raising asyncio.CancelledError inside the coroutine) and re-raises KeyboardInterrupt outside the coroutine. As a result, this handler often won’t run and watcher.stop() may never be called. Consider using a try/finally to always call watcher.stop() and/or explicitly handling asyncio.CancelledError (re-raising it after cleanup), and optionally catching KeyboardInterrupt around the asyncio.run(...) call in watch_command for a clean exit.
    polylogue/daemon/cli.py:33
  • This entrypoint doesn’t set context_settings={"help_option_names": ["-h", "--help"]} like the main polylogue CLI and polylogue-mcp do. That makes -h stop working for polylogued and its subcommands, which is an observable CLI regression. Suggest adding the same help_option_names context setting to @click.group(...) (and/or @main.command(...)) here for consistency.
    polylogue/daemon/cli.py:55
  • polylogued never calls configure_logging(...), but LiveWatcher/pipeline code uses structlog (get_logger) for warnings like parse failures and missing roots. Without configuring structlog in this entrypoint, operator-visible logs may be dropped or use unexpected defaults. Consider configuring logging early (e.g., in main() before running subcommands), and optionally adding a --verbose flag to control log level the same way the primary CLI does.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +63 to +96
def test_run_live_watcher_stops_on_keyboard_interrupt() -> None:
from polylogue.daemon import cli as daemon_cli

class FakePolylogue:
async def __aenter__(self) -> object:
return object()

async def __aexit__(self, *exc: object) -> None:
return None

stopped: list[bool] = []

class FakeWatcher:
stopped = False

def __init__(self, *_args: object, **_kwargs: object) -> None:
pass

async def run(self) -> None:
raise KeyboardInterrupt

def stop(self) -> None:
self.stopped = True
stopped.append(self.stopped)

sources = (WatchSource(name="codex", root=Path("/tmp/codex")),)

with (
patch.object(daemon_cli, "Polylogue", FakePolylogue),
patch.object(daemon_cli, "LiveWatcher", FakeWatcher),
):
asyncio.run(daemon_cli.run_live_watcher(sources=sources, debounce_s=1.0))

assert stopped == [True]

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb0e8cec4e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread polylogue/daemon/cli.py


@click.command("watch", help="Watch source directories and ingest new sessions live.")
@click.group(help="Run long-lived Polylogue local services.")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve -h help alias on daemon commands

The new polylogued group is declared without context_settings={"help_option_names": ["-h", "--help"]}, so polylogued -h and polylogued watch -h will now fail with an unknown option while the previous polylogue watch surface (and other repo CLIs) accepted -h. This is a user-visible CLI regression for existing shell habits/scripts that rely on the short help flag; adding the same context setting used by polylogue/polylogue-mcp keeps behavior consistent.

Useful? React with 👍 / 👎.

Problem: full pytest collection treats same-basename test modules as import-colliding when tests are collected without package imports; CI hit this between daemon/test_cli.py and mcp/test_cli.py.\n\nWhat changed: rename the daemon CLI test module to test_daemon_cli.py.\n\nVerification: ruff format tests/unit/daemon/test_daemon_cli.py; ruff check tests/unit/daemon/test_daemon_cli.py; pytest -q tests/unit/daemon/test_daemon_cli.py tests/unit/mcp/test_cli.py; pytest -q tests/unit/daemon/test_daemon_cli.py tests/unit/cli/test_click_app.py tests/unit/cli/test_terminal_snapshots.py tests/unit/proof/test_witnesses.py tests/unit/showcase/test_exercise_catalog.py.\n\nRef #635
@Sinity
Sinity merged commit 9370f85 into master May 2, 2026
15 checks passed
@Sinity
Sinity deleted the feature/refactor/polylogued-watch branch May 2, 2026 00:51
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Moves the standalone live source watcher out of the query-first
`polylogue` CLI and into a new daemon executable, `polylogued watch`.

## Problem

The UX direction keeps `polylogue` focused on archive querying and
one-shot operations while long-running live ingestion belongs to a
daemon/service surface. The old root `polylogue watch` command mixed
those concerns and kept service mode beside query verbs.

## Solution

- Added the `polylogued` console script and `polylogue.daemon.cli`
entrypoint.
- Moved the live watcher command to `polylogued watch` while preserving
its source/default-root/debounce behavior.
- Removed the root `polylogue watch` registration and refreshed CLI help
baselines, proof catalog, topology, and scenario projections.
- Kept `polylogue run --watch` unchanged because it is the continuous
pipeline-run mode, not the standalone source tailer.

## Verification

- `ruff format polylogue tests devtools`
- `ruff check polylogue tests devtools --fix`
- `pytest -q tests/unit/daemon/test_cli.py
tests/unit/cli/test_click_app.py
tests/unit/cli/test_terminal_snapshots.py
tests/unit/proof/test_witnesses.py
tests/unit/showcase/test_exercise_catalog.py` → `94 passed`
- `devtools render-all --check`
- `devtools verify-topology`
- `devtools verify-layering`
- `devtools verify-test-ownership`
- `mypy polylogue/`
- `devtools verify --quick`
- `devtools build-package`
- `.local/result/bin/polylogued --help`
- `.local/result/bin/polylogued watch --help`
- push hook reran `devtools verify --quick` successfully

Ref #635
Ref #593

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Introduced `polylogued` daemon executable for managing live source
watching via `polylogued watch`.

* **Changed**
  * Live source watching moved from root CLI to daemon subcommand.
* `polylogue run --watch` remains available for continuous pipeline
execution.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants