Skip to content

feat(sources): live filesystem watcher for Claude Code + Codex - #541

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/realtime-watcher
Apr 27, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/realtime-watcher

Conversation

@Sinity

@Sinity Sinity commented Apr 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds `polylogue/sources/live/` with a `watchfiles`-based watcher and a SQLite byte-size cursor. Ingests new and appended JSONL records into the archive within seconds of being written. Idempotent via content-hash dedup; the cursor only suppresses re-parsing files that haven't grown since last seen.

There is no "live session" concept — any JSONL under the watch roots may grow at any moment, including ones years old (resume).

CLI: `polylogue watch` (foreground; sinnix service swap is a follow-up).

Closes #539.

Problem

Polylogue ingested via an hourly systemd timer (`polylogue-run.timer` → `polylogue run acquire parse materialize render index`). `polylogue run --watch` existed but `WatchRunner` was `while True: full_pipeline(); sleep(interval)` — the polling pattern we wanted gone. The downstream goal is session-recall (#540): a fresh Claude Code session must see what happened in recent sessions, which requires conversations in the archive within seconds, not on the next hourly tick.

Both target sources are append-only JSONL; `/.claude/projects//.jsonl` and `/.codex/sessions/YYYY/MM/.jsonl`.

Solution

`polylogue/sources/live/`:

  • `cursor.py` — `CursorStore` over a small `live_cursor` table inside the archive SQLite (`CREATE IF NOT EXISTS`, no schema-version bump).
  • `watcher.py` — `LiveWatcher` runs `watchfiles.awatch` recursively over the source roots. On modify/create of `*.jsonl` it debounces 2s of inactivity, checks the cursor, and runs `Polylogue.parse_file()` if the file has grown.
  • `default_sources()` — returns the canonical roots (`claude_code_path()`, `codex_path()`).

CLI: `polylogue watch [--root PATH ...] [--debounce-s N]`. Long-running foreground command. `polylogue run` keeps its bulk-mode purpose.

Catch-up behaviour: on watcher start, `_catch_up` walks all files in roots and ingests anything that's grown past its cursor. Handles "watcher offline for a week, multiple files appended" and "year-old conversation resumed while watcher was off" identically.

Failure handling: parse errors don't advance the cursor — next event retries. Missing files are silent.

Verification

```bash
nix develop -c devtools verify --quick # green (format, lint, mypy, render-all, all 5 topology lints)
nix develop -c pytest -q tests/unit/sources/test_live_watcher.py # 25 passed
nix develop -c pytest -q --ignore=tests/integration # 5642 passed (no regressions)
```

Coverage:

  • CursorStore: round-trip, default, upsert, isolation, persistence, table creation, ISO-8601 timestamps.
  • ingest_if_grown: skip-when-unchanged, re-ingest-on-grow, year-old-resume, missing-file-silent, parse-failure-no-cursor-advance, retry-on-next-event, source_name=parent-dir.
  • catch_up: pre-existing files, skip-already-processed, recursive walk, non-jsonl ignored, empty roots.
  • Debounce: rapid changes coalesced.
  • End-to-end via `watchfiles.awatch`: modify-triggers-ingest, new-file-triggers-ingest, deletion-doesn't-ingest.

Follow-ups

  • Sinnix sibling PR: replace `polylogue-run.timer` with `polylogue-watch.service` (`Type=simple, Restart=always, MemoryMax=2G`); retire hourly polling.
  • Retire `polylogue/pipeline/watch.py:WatchRunner` once `polylogue watch` covers all watch use cases.
  • MCP + CLI session-recall surface: filters, pagination, resources #540 (MCP + CLI session-recall surface).

Summary by CodeRabbit

  • New Features

    • Added polylogue watch command to monitor source directories and ingest sessions live with configurable debounce and custom root paths.
  • Documentation

    • Updated CLI reference, topology plans, and verification catalog to reflect new watch functionality.
  • Tests

    • Added comprehensive test coverage for live filesystem watching and cursor persistence.
  • Chores

    • Added filesystem watching dependency.

@coderabbitai

coderabbitai Bot commented Apr 27, 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 33 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: e442301b-9ebd-46af-9079-4f0971001dcc

📥 Commits

Reviewing files that changed from the base of the PR and between 20785ef and f32be0e.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (16)
  • 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/cli/commands/watch.py
  • polylogue/sources/live/__init__.py
  • polylogue/sources/live/cursor.py
  • polylogue/sources/live/watcher.py
  • pyproject.toml
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-watch.txt
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py
  • tests/unit/sources/test_live_watcher.py
📝 Walkthrough

Walkthrough

Introduces a realtime JSONL ingestion system via a new polylogue watch CLI command that monitors configured source directories using a filesystem watcher, with SQLite cursor-based state persistence to track per-file ingestion progress and enable resume-on-restart functionality.

Changes

Cohort / File(s) Summary
CLI Watch Command
polylogue/cli/commands/watch.py, polylogue/cli/click_command_registration.py
Adds new watch_command Click subcommand that runs a long-lived LiveWatcher with configurable root paths and debounce interval. Registers command in root command set for CLI integration.
Live Sources Infrastructure
polylogue/sources/live/__init__.py, polylogue/sources/live/cursor.py, polylogue/sources/live/watcher.py
Implements LiveWatcher (async file monitor using watchfiles), WatchSource dataclass, CursorStore (SQLite-backed cursor persistence with upsert logic), and default_sources() helper. Handles debounced re-ingestion on file growth with catch-up scan on startup.
Dependencies
pyproject.toml
Adds watchfiles>=0.21 runtime dependency for cross-platform filesystem watching.
Documentation Updates
docs/cli-reference.md, docs/plans/topology-target.yaml, docs/test-quality-workflows.md, docs/topology-status.md, docs/verification-catalog.md
Updates generated CLI reference with watch command, increments topology/verification metrics (4 new stable modules, cursor/watcher subjects), increases test scenario count by 1, reflects updated LOC and file coverage.
Test Suite & Snapshots
tests/unit/sources/test_live_watcher.py, tests/unit/cli/test_click_app.py, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
Adds comprehensive integration tests for cursor persistence, watcher debounce, file growth detection, catch-up ingestion, and error handling. Updates CLI help snapshots and command registration test expectations.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant CLI as polylogue watch CLI
    participant Watcher as LiveWatcher
    participant FileSystem as FileSystem<br/>(watchfiles)
    participant CursorStore as CursorStore<br/>(SQLite)
    participant Parser as parse_file()
    participant Archive as Polylogue<br/>Archive

    User->>CLI: polylogue watch --root=...
    activate CLI
    CLI->>Watcher: __init__ + startup
    activate Watcher
    Watcher->>FileSystem: _catch_up scan roots
    FileSystem-->>Watcher: existing *.jsonl files
    loop For each unseen file
        Watcher->>CursorStore: get(path)
        CursorStore-->>Watcher: byte_offset=0 (default)
        Watcher->>FileSystem: read from offset
        FileSystem-->>Watcher: file content
        Watcher->>Parser: parse_file(path)
        Parser->>Archive: ingest records
        Watcher->>CursorStore: set(path, new_byte_size)
    end
    
    rect rgba(100, 150, 200, 0.5)
        Note over Watcher,FileSystem: Continuous watch loop
        Watcher->>FileSystem: awatch(roots) - monitor changes
        activate FileSystem
        FileSystem-->>Watcher: file modification event
        deactivate FileSystem
        
        Watcher->>Watcher: debounce_s quiet period
        Watcher->>CursorStore: get(path)
        CursorStore-->>Watcher: byte_offset
        Watcher->>FileSystem: read current size
        FileSystem-->>Watcher: size
        
        alt File has grown
            Watcher->>FileSystem: read from offset
            FileSystem-->>Watcher: new content
            Watcher->>Parser: parse_file(path)
            Parser->>Archive: ingest new records
            Watcher->>CursorStore: set(path, new_byte_size)
        else File unchanged or shrunk
            Watcher->>Watcher: skip (no growth)
        end
    end
    
    User->>CLI: Ctrl+C
    CLI->>Watcher: stop()
    deactivate Watcher
    deactivate CLI
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 A rabbit's ode to the watch command

Files flutter by in the filesystem night,
My watcher's awake—no polling to fight!
A cursor remembers where last I did peek,
So fresh Claude chats bloom within just a week! 🌱
Debounce on, dear watcher, thy vigil stands true! 🎪

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.35% 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 describes the primary change: adding a live filesystem watcher for Claude Code and Codex sources.
Description check ✅ Passed The PR description covers all required template sections: Summary, Problem, Solution, Verification, Changelog, and Risks/Follow-ups with comprehensive detail.
Linked Issues check ✅ Passed Code changes fully implement issue #539 objectives: live watcher via watchfiles, SQLite cursor tracking, CLI command, catch-up logic, debouncing, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: live watcher implementation, CLI integration, documentation updates, tests, and dependency additions (watchfiles). No extraneous modifications detected.

✏️ 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/feat/realtime-watcher

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

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

@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: 20785eff71

ℹ️ 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/sources/live/cursor.py Resolved
Comment thread polylogue/sources/live/watcher.py Resolved

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@polylogue/sources/live/watcher.py`:
- Around line 89-97: The current _catch_up builds a full in-memory list of files
which can OOM; instead, stream files and process each immediately: in _catch_up
iterate each root and then loop over root.rglob("*.jsonl"), for each p call
p.is_file() and if true immediately await self._ingest_if_grown(p) while
maintaining a simple counter to track how many files were processed; update the
logger to report the processed count (logger.info) after or during the streaming
loop rather than preloading all paths. Ensure you modify the references in
_catch_up (and keep using self._ingest_if_grown and logger) so no intermediate
list like files is created.
- Around line 99-117: The debounce logic can miss updates and never removes
entries from _pending; fix _schedule and _debounced: in _schedule always update
entry.last_change_at (before checking/creating a task) and ensure a task is
created only if none exists, and in _debounced after the sleep/ingest cycle
remove the entry from self._pending when this task is the current
entry.pending_task and there have been no new changes during the ingest;
additionally, after calling _ingest_if_grown(entry.path) check whether
entry.last_change_at changed during ingestion and if so continue the debounce
loop (or let a new loop run) instead of exiting so in-flight changes are not
missed; use the existing symbols _schedule, _debounced, _pending, _PendingFile,
entry.pending_task, entry.last_change_at, _debounce_s and _ingest_if_grown to
implement this behavior.
🪄 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: 0a336589-caca-4f28-93f5-39a4f8972f73

📥 Commits

Reviewing files that changed from the base of the PR and between f48ad75 and 20785ef.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (14)
  • 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/cli/commands/watch.py
  • polylogue/sources/live/__init__.py
  • polylogue/sources/live/cursor.py
  • polylogue/sources/live/watcher.py
  • pyproject.toml
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py
  • tests/unit/sources/test_live_watcher.py

Comment on lines +89 to +97
async def _catch_up(self, roots: list[Path]) -> None:
files: list[Path] = []
for root in roots:
files.extend(p for p in root.rglob("*.jsonl") if p.is_file())
if not files:
return
logger.info("live.watcher: catch-up scan over %d file(s)", len(files))
for path in files:
await self._ingest_if_grown(path)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Avoid preloading all catch-up files before ingest

This builds a full in-memory list of every *.jsonl before processing. For large histories, startup memory and time-to-first-ingest increase unnecessarily. Stream files directly and count as you go.

♻️ Proposed refactor
 async def _catch_up(self, roots: list[Path]) -> None:
-    files: list[Path] = []
-    for root in roots:
-        files.extend(p for p in root.rglob("*.jsonl") if p.is_file())
-    if not files:
-        return
-    logger.info("live.watcher: catch-up scan over %d file(s)", len(files))
-    for path in files:
-        await self._ingest_if_grown(path)
+    processed = 0
+    for root in roots:
+        for path in root.rglob("*.jsonl"):
+            if not path.is_file():
+                continue
+            processed += 1
+            await self._ingest_if_grown(path)
+    if processed:
+        logger.info("live.watcher: catch-up scan over %d file(s)", processed)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/sources/live/watcher.py` around lines 89 - 97, The current
_catch_up builds a full in-memory list of files which can OOM; instead, stream
files and process each immediately: in _catch_up iterate each root and then loop
over root.rglob("*.jsonl"), for each p call p.is_file() and if true immediately
await self._ingest_if_grown(p) while maintaining a simple counter to track how
many files were processed; update the logger to report the processed count
(logger.info) after or during the streaming loop rather than preloading all
paths. Ensure you modify the references in _catch_up (and keep using
self._ingest_if_grown and logger) so no intermediate list like files is created.

Comment on lines +99 to +117
def _schedule(self, path: Path) -> None:
entry = self._pending.get(path)
if entry is None:
entry = _PendingFile(path=path)
self._pending[path] = entry

loop = asyncio.get_running_loop()
entry.last_change_at = loop.time()
if entry.pending_task is None or entry.pending_task.done():
entry.pending_task = asyncio.create_task(self._debounced(entry))

async def _debounced(self, entry: _PendingFile) -> None:
loop = asyncio.get_running_loop()
while True:
await asyncio.sleep(self._debounce_s)
if loop.time() - entry.last_change_at >= self._debounce_s:
break
await self._ingest_if_grown(entry.path)

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

Debounce task can miss in-flight changes and leaks _pending entries

At Line 107, new events only update last_change_at when a task is already running. If a change lands while Line 116 is ingesting, no second task is queued; that event may not be ingested until a future change. Also, finished entries are never removed from _pending, so memory grows with unique paths seen.

💡 Proposed fix
 async def _debounced(self, entry: _PendingFile) -> None:
     loop = asyncio.get_running_loop()
-    while True:
-        await asyncio.sleep(self._debounce_s)
-        if loop.time() - entry.last_change_at >= self._debounce_s:
-            break
-    await self._ingest_if_grown(entry.path)
+    try:
+        while True:
+            await asyncio.sleep(self._debounce_s)
+            if loop.time() - entry.last_change_at < self._debounce_s:
+                continue
+
+            last_seen_change = entry.last_change_at
+            await self._ingest_if_grown(entry.path)
+
+            # If another event arrived during ingest, debounce and ingest again.
+            if entry.last_change_at <= last_seen_change:
+                break
+    finally:
+        current = self._pending.get(entry.path)
+        if current is entry:
+            self._pending.pop(entry.path, None)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/sources/live/watcher.py` around lines 99 - 117, The debounce logic
can miss updates and never removes entries from _pending; fix _schedule and
_debounced: in _schedule always update entry.last_change_at (before
checking/creating a task) and ensure a task is created only if none exists, and
in _debounced after the sleep/ingest cycle remove the entry from self._pending
when this task is the current entry.pending_task and there have been no new
changes during the ingest; additionally, after calling
_ingest_if_grown(entry.path) check whether entry.last_change_at changed during
ingestion and if so continue the debounce loop (or let a new loop run) instead
of exiting so in-flight changes are not missed; use the existing symbols
_schedule, _debounced, _pending, _PendingFile, entry.pending_task,
entry.last_change_at, _debounce_s and _ingest_if_grown to implement this
behavior.

Adds polylogue/sources/live/ with watchfiles-based watcher and a SQLite
byte-size cursor; ingests new + appended JSONL records into the archive
within seconds of being written. Idempotent via content-hash dedup; the
cursor only suppresses re-parsing files that have not grown since last
seen.

There is no "live session" concept — any JSONL under the watch roots
may grow at any moment, including ones years old (resume).

CLI: polylogue watch (foreground; sinnix service in a follow-up).

Tests: 25 unit tests over cursor round-trip, ingest-skip logic, catch-up
bootstrap, debounce, and end-to-end via the watchfiles event loop.

Ref #539

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/realtime-watcher branch from 20785ef to f32be0e Compare April 27, 2026 18:33
@Sinity
Sinity merged commit 1fae27c into master Apr 27, 2026
12 checks passed
@Sinity
Sinity deleted the feature/feat/realtime-watcher branch April 27, 2026 18:35
Sinity added a commit that referenced this pull request Apr 27, 2026
## Summary

\`polylogue watch\` (#539, landed in #541) imports \`watchfiles\` at
runtime; the pyproject dep was added but \`flake.nix\` hardcodes
\`propagatedBuildInputs\` separately and \`watchfiles\` was missed
there. Nix-built binary fails with \`ModuleNotFoundError: No module
named 'watchfiles'\` when \`polylogue-watch.service\` starts.

## Problem

The \`polylogue\` Nix derivation lists Python deps explicitly, not from
pyproject. Anyone deploying via \`pkgs.polylogue\` (sinnix) gets a
binary missing \`watchfiles\`.

## Solution

Add \`watchfiles\` to the \`propagatedBuildInputs\` list.

## Verification

\`\`\`bash
nix build .#polylogue
./result/bin/polylogue watch --help   # exits 0; previously crashed
\`\`\`

Repro of the underlying failure: starting \`polylogue-watch.service\` on
a host with the master version pre-fix produces:
\`\`\`
ModuleNotFoundError: No module named 'watchfiles'
\`\`\`

Co-authored-by: Claude <[email protected]>
@Sinity
Sinity requested a review from Copilot May 1, 2026 00:45

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Adds \`polylogue/sources/live/\` with a \`watchfiles\`-based watcher and
a SQLite byte-size cursor. Ingests new and appended JSONL records into
the archive within seconds of being written. Idempotent via content-hash
dedup; the cursor only suppresses re-parsing files that haven't grown
since last seen.

There is no "live session" concept — any JSONL under the watch roots may
grow at any moment, including ones years old (resume).

CLI: \`polylogue watch\` (foreground; sinnix service swap is a
follow-up).

Closes #539.

## Problem

Polylogue ingested via an hourly systemd timer (\`polylogue-run.timer\`
→ \`polylogue run acquire parse materialize render index\`). \`polylogue
run --watch\` existed but \`WatchRunner\` was \`while True:
full_pipeline(); sleep(interval)\` — the polling pattern we wanted gone.
The downstream goal is **session-recall** (#540): a fresh Claude Code
session must see what happened in recent sessions, which requires
conversations in the archive within seconds, not on the next hourly
tick.

Both target sources are append-only JSONL;
\`~/.claude/projects/<encoded-cwd>/<uuid>.jsonl\` and
\`~/.codex/sessions/YYYY/MM/<uuid>.jsonl\`.

## Solution

\`polylogue/sources/live/\`:
- \`cursor.py\` — \`CursorStore\` over a small \`live_cursor\` table
inside the archive SQLite (\`CREATE IF NOT EXISTS\`, no schema-version
bump).
- \`watcher.py\` — \`LiveWatcher\` runs \`watchfiles.awatch\`
recursively over the source roots. On modify/create of \`*.jsonl\` it
debounces 2s of inactivity, checks the cursor, and runs
\`Polylogue.parse_file()\` if the file has grown.
- \`default_sources()\` — returns the canonical roots
(\`claude_code_path()\`, \`codex_path()\`).

CLI: \`polylogue watch [--root PATH ...] [--debounce-s N]\`.
Long-running foreground command. \`polylogue run\` keeps its bulk-mode
purpose.

Catch-up behaviour: on watcher start, \`_catch_up\` walks all files in
roots and ingests anything that's grown past its cursor. Handles
"watcher offline for a week, multiple files appended" and "year-old
conversation resumed while watcher was off" identically.

Failure handling: parse errors don't advance the cursor — next event
retries. Missing files are silent.

## Verification

\`\`\`bash
nix develop -c devtools verify --quick # green (format, lint, mypy,
render-all, all 5 topology lints)
nix develop -c pytest -q tests/unit/sources/test_live_watcher.py # 25
passed
nix develop -c pytest -q --ignore=tests/integration # 5642 passed (no
regressions)
\`\`\`

Coverage:
- CursorStore: round-trip, default, upsert, isolation, persistence,
table creation, ISO-8601 timestamps.
- ingest_if_grown: skip-when-unchanged, re-ingest-on-grow,
year-old-resume, missing-file-silent, parse-failure-no-cursor-advance,
retry-on-next-event, source_name=parent-dir.
- catch_up: pre-existing files, skip-already-processed, recursive walk,
non-jsonl ignored, empty roots.
- Debounce: rapid changes coalesced.
- End-to-end via \`watchfiles.awatch\`: modify-triggers-ingest,
new-file-triggers-ingest, deletion-doesn't-ingest.

## Follow-ups

- Sinnix sibling PR: replace \`polylogue-run.timer\` with
\`polylogue-watch.service\` (\`Type=simple, Restart=always,
MemoryMax=2G\`); retire hourly polling.
- Retire \`polylogue/pipeline/watch.py:WatchRunner\` once \`polylogue
watch\` covers all watch use cases.
- #540 (MCP + CLI session-recall surface).

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

## Summary by CodeRabbit

* **New Features**
* Added `polylogue watch` command to monitor source directories and
ingest sessions live with configurable debounce and custom root paths.

* **Documentation**
* Updated CLI reference, topology plans, and verification catalog to
reflect new watch functionality.

* **Tests**
* Added comprehensive test coverage for live filesystem watching and
cursor persistence.

* **Chores**
  * Added filesystem watching dependency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude <[email protected]>
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

\`polylogue watch\` (#539, landed in #541) imports \`watchfiles\` at
runtime; the pyproject dep was added but \`flake.nix\` hardcodes
\`propagatedBuildInputs\` separately and \`watchfiles\` was missed
there. Nix-built binary fails with \`ModuleNotFoundError: No module
named 'watchfiles'\` when \`polylogue-watch.service\` starts.

## Problem

The \`polylogue\` Nix derivation lists Python deps explicitly, not from
pyproject. Anyone deploying via \`pkgs.polylogue\` (sinnix) gets a
binary missing \`watchfiles\`.

## Solution

Add \`watchfiles\` to the \`propagatedBuildInputs\` list.

## Verification

\`\`\`bash
nix build .#polylogue
./result/bin/polylogue watch --help   # exits 0; previously crashed
\`\`\`

Repro of the underlying failure: starting \`polylogue-watch.service\` on
a host with the master version pre-fix produces:
\`\`\`
ModuleNotFoundError: No module named 'watchfiles'
\`\`\`

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 70.F068 / P1: fixed-already at the checked revision: Cursor initialization uses the archive-tier bootstrap, which creates the database parent before opening SQLite. polylogue/storage/sqlite/archive_tiers/bootstrap.py:574 precedes sqlite3.connect at line 575, so a fresh archive directory no longer causes the reported startup failure.

Only the rows listed above are dispositioned. Held findings remain open.

@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 71.F065 / P2: fixed-already at the checked revision: The watcher resolves the deepest matching WatchSource at polylogue/sources/live/watcher.py:1354 and returns that source's name at line 1356. Nested Codex date directories therefore retain the configured Codex source identity instead of using the month directory as their provider hint.

Only the rows listed above are dispositioned. Held findings remain open.

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.

Realtime ingestion for Claude Code + Codex via filesystem watcher

2 participants