Skip to content

fix(acquisition): harden live freshness and reparse writes - #714

Merged
Sinity merged 2 commits into
masterfrom
feature/fix/live-cursor-source-identity
May 2, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/fix/live-cursor-source-identity

Conversation

@Sinity

@Sinity Sinity commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

Make live ingestion cursor decisions content-aware and preserve forced reparse replacement semantics. This PR records richer live cursor state, stops deriving watcher source names from parent directories, forwards Drive acquisition diagnostics through the raw stream, and folds in the pending forced-reparse write fix from the other-agent workstream.

Problem

#620 tracks that live ingestion used byte size as truth: same-size rewrites could be skipped, parser changes could not invalidate cursor state, partial trailing lines did not leave a replay boundary, and watcher source names could become arbitrary directory names. Drive raw acquisition also bypassed the observation/progress diagnostics used by local sources.

The pending force-write ingestion fix also needed cleanup before incorporation: the uncommitted hunk allowed same-hash forced reparses to append new message rows while leaving old rows behind, and one SQL condition was initially placed in the update expression rather than the WHERE predicate.

Solution

  • Add CursorRecord and extend live_cursor with byte offset, last complete newline, parser fingerprint, content fingerprint, source name, and optional last-record timestamp fields, including migration for old size-only rows.
  • Make LiveWatcher skip only when size, content fingerprint, and parser fingerprint all match, and persist the configured WatchSource.name instead of path.parent.name.
  • Leave the replay offset at the last complete newline when a file has a partial trailing JSONL line, while still using the existing full-file parser path for now.
  • Forward Drive raw acquisition observation/progress callbacks through iter_drive_raw_stream() and iter_drive_raw_data().
  • Preserve forced reparse replacement behavior in sync ingest and keep the large ingest file under the configured file budget.

Verification

  • ruff check polylogue/pipeline/services/acquisition_streams.py polylogue/sources/drive/__init__.py polylogue/sources/live/cursor.py polylogue/sources/live/watcher.py tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_source_laws.py
  • ruff format --check polylogue/pipeline/services/acquisition_streams.py polylogue/sources/drive/__init__.py polylogue/sources/live/cursor.py polylogue/sources/live/watcher.py tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_source_laws.py
  • pytest -q tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py
  • pytest -q tests/unit/sources/test_source_laws.py -k 'drive_raw_data'
  • pytest -q tests/unit/pipeline/test_ingest_batch.py
  • devtools render-all --check
  • devtools verify-topology
  • devtools affected-obligations --path polylogue/sources/live/watcher.py --path polylogue/sources/live/cursor.py --path polylogue/sources/drive/__init__.py --path polylogue/pipeline/services/acquisition_streams.py
  • devtools verify --quick
  • pre-push hook: devtools verify --quick

Ref #620
Ref #618

Sinity added 2 commits May 2, 2026 18:32
Store live watcher cursor records with byte offset, last complete newline, parser fingerprint, content fingerprint, and stable source identity. The watcher now reingests same-size rewrites, truncation rewrites, legacy size-only cursor rows, and parser-fingerprint changes instead of relying on byte size alone.

Forward Drive acquisition observation and progress callbacks through the Drive raw stream so remote acquisition participates in the same diagnostics surface as local sources.

Ref #620
Keep force_write as a true replacement path even when the incoming conversation has the same content hash. This preserves the same-hash reparse behavior needed by source refresh workflows while still keeping the file-budget cleanup under the pipeline services ceiling.

Ref #618

Ref #620
Copilot AI review requested due to automatic review settings May 2, 2026 16:39
@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 35 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: b6afed9a-41b3-4f40-ab4d-60faa7a0ad4a

📥 Commits

Reviewing files that changed from the base of the PR and between 18c9b6a and d018f45.

📒 Files selected for processing (8)
  • polylogue/pipeline/services/acquisition_streams.py
  • polylogue/pipeline/services/ingest_batch.py
  • polylogue/sources/drive/__init__.py
  • polylogue/sources/live/cursor.py
  • polylogue/sources/live/watcher.py
  • tests/unit/pipeline/test_acquisition_streams.py
  • tests/unit/sources/test_live_watcher.py
  • tests/unit/sources/test_source_laws.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/live-cursor-source-identity

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 35 minutes and 33 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: 8

Affected Domains

  • spec_completeness — 1 claim(s), maturity seed
Additional routed domains with zero affected claims
  • mutation_coverage — maturity growing

Focused Gates

  • none

Required PR Gates

  • devtools verify --quick — full PR gate remains explicit
  • devtools verify — full PR gate remains explicit

Optional Confidence Gates

  • 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

  • none for domains with affected claims

Oracle / Cost

  • oracle mix: {"construction_sanity": 2}
  • cost tier: {"static": 2}
  • stable affected obligations: 2
  • agent judgment cells: 0

@Sinity
Sinity merged commit 863e73c into master May 2, 2026
12 of 16 checks passed
@Sinity
Sinity deleted the feature/fix/live-cursor-source-identity branch May 2, 2026 16:40

@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: d018f45151

ℹ️ 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".

@Sinity
Sinity removed the request for review from Copilot May 2, 2026 17:03
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Make live ingestion cursor decisions content-aware and preserve forced reparse replacement semantics. This PR records richer live cursor state, stops deriving watcher source names from parent directories, forwards Drive acquisition diagnostics through the raw stream, and folds in the pending forced-reparse write fix from the other-agent workstream.

## Problem

#620 tracks that live ingestion used byte size as truth: same-size rewrites could be skipped, parser changes could not invalidate cursor state, partial trailing lines did not leave a replay boundary, and watcher source names could become arbitrary directory names. Drive raw acquisition also bypassed the observation/progress diagnostics used by local sources.

The pending force-write ingestion fix also needed cleanup before incorporation: the uncommitted hunk allowed same-hash forced reparses to append new message rows while leaving old rows behind, and one SQL condition was initially placed in the update expression rather than the `WHERE` predicate.

## Solution

- Add `CursorRecord` and extend `live_cursor` with byte offset, last complete newline, parser fingerprint, content fingerprint, source name, and optional last-record timestamp fields, including migration for old size-only rows.
- Make `LiveWatcher` skip only when size, content fingerprint, and parser fingerprint all match, and persist the configured `WatchSource.name` instead of `path.parent.name`.
- Leave the replay offset at the last complete newline when a file has a partial trailing JSONL line, while still using the existing full-file parser path for now.
- Forward Drive raw acquisition observation/progress callbacks through `iter_drive_raw_stream()` and `iter_drive_raw_data()`.
- Preserve forced reparse replacement behavior in sync ingest and keep the large ingest file under the configured file budget.

## Verification

- `ruff check polylogue/pipeline/services/acquisition_streams.py polylogue/sources/drive/__init__.py polylogue/sources/live/cursor.py polylogue/sources/live/watcher.py tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_source_laws.py`
- `ruff format --check polylogue/pipeline/services/acquisition_streams.py polylogue/sources/drive/__init__.py polylogue/sources/live/cursor.py polylogue/sources/live/watcher.py tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py tests/unit/sources/test_source_laws.py`
- `pytest -q tests/unit/pipeline/test_acquisition_streams.py tests/unit/sources/test_live_watcher.py`
- `pytest -q tests/unit/sources/test_source_laws.py -k 'drive_raw_data'`
- `pytest -q tests/unit/pipeline/test_ingest_batch.py`
- `devtools render-all --check`
- `devtools verify-topology`
- `devtools affected-obligations --path polylogue/sources/live/watcher.py --path polylogue/sources/live/cursor.py --path polylogue/sources/drive/__init__.py --path polylogue/pipeline/services/acquisition_streams.py`
- `devtools verify --quick`
- pre-push hook: `devtools verify --quick`

Ref #620
Ref #618
@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.

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.

1 participant