Repository navigation
Description
Scope
Composite issue for live/source acquisition correctness: cursor semantics, source identity, truncation/rewrite handling, Drive diagnostics, and content freshness checks.
Problem
The current live/source freshness model relies too much on file metadata and reparsing whole files:
- live cursor state records byte size/record count/update time, not byte offset, last complete newline, last record timestamp, or parser/schema fingerprint;
- watcher ingestion reparses the whole file whenever size changes, then records the full size;
- same-size rewrites can be skipped, shrink/truncate cases are ambiguous, and partial trailing lines are not handled as tailer state;
- watcher source identity can come from parent directory names rather than provider names such as
claude-codeorcodex; - Drive acquisition does not forward the same observation/progress diagnostics as local/zip streams;
- source modified-time skips are content-blind and can miss same-mtime changes.
Already completed (#714 / fix(acquisition): harden live freshness and reparse writes)
- Live cursor rows now store
byte_offset,last_complete_newline, parser fingerprint, content fingerprint, source name, and optional last-record timestamp fields. - Old size-only cursor rows are migrated in place and reprocessed once to populate content/parser fingerprints.
- The watcher skips only when byte size, content fingerprint, and parser fingerprint still match.
- Same-size rewrite, truncate/rewrite, parser-fingerprint change, partial trailing-line cursor offset, append-after-partial-line, and stable watch-source identity are covered in
tests/unit/sources/test_live_watcher.py. - Watcher source identity now comes from
WatchSource.nameinstead ofpath.parent.name. - Drive raw acquisition now receives observation/progress callbacks through
iter_drive_raw_stream()anditer_drive_raw_data().
Remaining acceptance criteria
- True incremental tail parsing: resume from the saved byte offset rather than full-file reparse after every size change. The cursor now has the metadata to support this; the watcher still reparses the whole file.
- Drive freshness content guards: Drive still skips by mtime only. Needs remote file ID/revision/modifiedTime plus size/hash or conservative fallback.
- Daemon/status models: cursor lag, backlog, last ingest, and error facts should be surfaced through daemon status consumable by CLI doctor, TUI, web UI, and browser extension state.
polylogue watchretirement: remove only afterpolyloguedowns equivalent live ingestion behavior and status (feat(surfaces): implement polylogued local reader and query-native CLI UX #717). Do not keep as an alias.- Freshness target: aim for subsecond local ingestion under normal append-only JSONL conditions. Revisit debounce defaults (current 2s is probably too sluggish).
Service boundary
Live ingestion should be treated as daemon-owned infrastructure (polylogued run), not an interactive query CLI mode. The interactive polylogue CLI keeps one-shot archive/query/pipeline operations; long-running live ingestion belongs to the daemon alongside browser receiver and local web/API serving.
Design principle
The cursor invariant is replayability from the last complete, parser-valid boundary. A viable cursor says where ingestion can resume without duplicating, dropping, or accepting partial records, and when parser/schema changes invalidate that position. Size, mtime, and record count are diagnostics, not sufficient cursor identity.
Related
- refactor(acquisition): retire legacy polling WatchRunner #648 — legacy polling
WatchRunnerinpolylogue/pipeline/watch.py(retire or adapt) - feat(surfaces): implement polylogued local reader and query-native CLI UX #717 — polylogued daemon (live ingestion moves under daemon)
- fix(storage): unify schema, FTS, cache, and write side effects #618 — storage write-path correctness
- feat(pipeline): surface actionable performance diagnostics from existing telemetry #713 — pipeline performance diagnostics from existing telemetry
Ref #578
Activity
Sinity commentedon May 1, 2026
Additional integration from the 2026-05-01 audit: Drive acquisition should be part of this same cursor/diagnostics cleanup unless it proves too large.
Evidence:
polylogue/pipeline/services/acquisition_streams.py:111-137forwardsobservation_callbackandprogress_callbackonly toiter_source_raw_stream()for non-Drive sources.iter_drive_raw_stream()atpolylogue/pipeline/services/acquisition_streams.py:76-109has no observation/progress parameters.polylogue/sources/drive/__init__.py:229-234also skips Drive files by modified time only.Acceptance refinement:
[-]fix(live): replace size-cache ingestion with real cursors[/-][+]fix(acquisition): make live cursors and source freshness content-aware[/+]Sinity commentedon May 1, 2026
Cursor implementation guard: this should not become another metadata-only freshness heuristic with more fields.
The important invariant is replayability from the last complete, parser-valid boundary. A viable cursor needs to say where ingestion can resume without duplicating, dropping, or accepting partial records, and when parser/schema changes invalidate that position. Size, mtime, and record count can remain diagnostics, but they are not sufficient cursor identity.
Acceptance should include adversarial tests for append-after-partial-line, same-size rewrite, truncate-and-append, parser version/schema fingerprint change, and provider identity derived independently from the watched path. Drive/local/zip sources can have different mechanics, but the freshness decision should be content-aware or explicitly documented as a weaker source contract.
Sinity commentedon May 1, 2026
Implementation anchors and acceptance additions from the 2026-05-01 follow-up audit.
Code anchors:
polylogue/sources/live/cursor.py:15-21:live_cursorstores onlysource_path,byte_size,record_count, andupdated_at.polylogue/sources/live/cursor.py:38-46:get()returns byte size only;set()stores byte size.polylogue/sources/live/watcher.py:118-132: watcher skips when file size equals cursor size, reparses the whole file on growth, then stores the full size; source name ispath.parent.name.polylogue/pipeline/services/acquisition_streams.py:76-109: Drive stream has no observation/progress callback parameters.polylogue/pipeline/services/acquisition_streams.py:123-137: non-Drive stream gets callbacks; Drive path does not.polylogue/sources/drive/__init__.py:224-234: Drive freshness skip is modified-time based.Acceptance additions:
Adjacent cleanup:
polylogue/pipeline/watch.py:15-44still definesWatchRunner, a polling loop aroundsync_fn()andtime.sleep(interval). Either retire/adapt it here as “legacy polling abstraction must obey the live cursor contract,” or keep it linked to a small leaf issue if separate ownership is clearer.Sinity commentedon May 1, 2026
Opened leaf issue #648 for the legacy polling uncertainty so #620 can keep the main cursor/freshness contract focused while still tracking whether that old abstraction should be retired or adapted.
Sinity commentedon May 1, 2026
Correction to the previous link note: #648 is specifically for the legacy polling
WatchRunnerabstraction inpolylogue/pipeline/watch.py.Sinity commentedon May 1, 2026
Live ingestion decisions from 2026-05-01 bundle
Canonical live ingestion should be under ingest:
Do not keep top-level
polylogue watchas an alias after the rename.Freshness target:
Status should expose source/provider identity, source path as provenance, event time, parse time, commit time, event-to-commit lag, cursor offset, last complete newline/record, skipped partial trailing line count, and backlog/error state.
Drive acquisition should get the same freshness/diagnostics contract now, not as a later optional polish pass.
Ref #635
Sinity commentedon May 1, 2026
Integrated UX/service-boundary direction from the 2026-05-01 feedback pass.
Live ingestion should be treated as daemon-owned infrastructure rather than an interactive query CLI mode. Target shape:
polylogue watchshould not remain the long-term surface oncepolyloguedexists. The interactivepolylogueCLI should keep one-shot archive/query/pipeline operations; long-running live ingestion belongs to the daemon alongside browser receiver and local web/API serving.Status models from live ingestion should be consumable by
polylogue doctor, the local web UI, the TUI/dashboard, extension/popup status where relevant, and tests. Avoid separate semantics for CLI/web/TUI/MCP.Sinity commentedon May 2, 2026
Integrated
Polylogue MK2.zipdesign context where it affects live ingestion/daemon work.Relevant UX/status direction:
polyloguedcomponent, not a long-running interactivepolyloguecommand;DaemonStatus/component model rather than a separate status vocabulary;Already-landed context to avoid duplicate implementation:
polylogued watch/polylogued runslices have landed or are in flight from the daemon split work; this issue should focus on correctness of cursor/source freshness and status facts, not re-opening the command split.Sinity commentedon May 2, 2026
Implementation slice opened as PR #714.
What it covers:
byte_offset,last_complete_newline, parser fingerprint, content fingerprint, source name, and optional last-record timestamp fields;tests/unit/sources/test_live_watcher.py;WatchSource.nameinstead ofpath.parent.name;iter_drive_raw_stream()anditer_drive_raw_data().What remains in #620 after this PR:
Verification recorded in the PR includes focused live/Drive/ingest tests and
devtools verify --quick.fix(acquisition): harden live freshness and reparse writes (#714)
Sinity commentedon May 2, 2026
Surface ownership update from #717.
#620 remains the source of truth for live cursor/source freshness facts: line-aligned offsets, parser/content fingerprints, partial-line handling, Drive diagnostics/freshness, lag/backlog/error facts, and provider/source identity.
#717 should consume those facts through daemon/API/web/TUI/doctor status instead of redefining live-ingestion semantics. Command removal remains conditional:
polylogue watchshould disappear only afterpolyloguedowns equivalent live ingestion behavior and status.Ref #717
feat(cursor): stat metadata, failure quarantine, adversary tests (#620)…
Sinity commentedon May 3, 2026
Closed by #762. Cursor now stores st_dev/st_ino/mtime_ns stat metadata. Failure quarantine with exponential backoff (max 1h). mark_failed on parse errors, reset_failures on success. 10 adversary tests cover same-size rewrite, truncation, partial-line append, parser fingerprint change, rename detection, and quarantine listing.
fix(acquisition): harden live freshness and reparse writes (#714)
feat(cursor): stat metadata, failure quarantine, adversary tests (#620)…