Skip to content

fix(daemon): deduplicate durable watcher facts - #469

Merged
KooshaPari merged 1 commit into
mainfrom
fix/sessionledger-watcher-fact-idempotency
Aug 10, 2026
Merged

fix(daemon): deduplicate durable watcher facts#469
KooshaPari merged 1 commit into
mainfrom
fix/sessionledger-watcher-fact-idempotency

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • derive durable SQLite fact IDs from session, key, and content
  • make duplicate event writes SQLite no-ops at the durable boundary
  • add repeated-ETL regression coverage; HTTP and viewer paths are unchanged

Verification

  • RED: focused regression observed 6 facts after two identical transforms, expected 3
  • GREEN: focused regression passed with 3 facts
  • cargo test --manifest-path crates/sl-daemon/Cargo.toml --features sqlite (203 passed)
  • changed Rust files pass rustfmt --check

Known repository gates

  • repository-wide cargo fmt --check reports existing formatting drift in unrelated daemon files
  • cargo clippy is blocked by existing unsupported warn/allow keys in clippy.toml

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b368cb56-7210-469d-9cb9-50e03a775516

📥 Commits

Reviewing files that changed from the base of the PR and between e6f5008 and 719f828.

📒 Files selected for processing (9)
  • crates/sl-daemon/src/etl.rs
  • docs/sessions/20260809-watcher-fact-idempotency/00_SESSION_OVERVIEW.md
  • docs/sessions/20260809-watcher-fact-idempotency/01_RESEARCH.md
  • docs/sessions/20260809-watcher-fact-idempotency/02_SPECIFICATIONS.md
  • docs/sessions/20260809-watcher-fact-idempotency/03_DAG_WBS.md
  • docs/sessions/20260809-watcher-fact-idempotency/04_IMPLEMENTATION_STRATEGY.md
  • docs/sessions/20260809-watcher-fact-idempotency/05_KNOWN_ISSUES.md
  • docs/sessions/20260809-watcher-fact-idempotency/06_TESTING_STRATEGY.md
  • src/ports/sqlite_memory.rs

📝 Walkthrough

Summary

This PR makes durable watcher fact writes idempotent. SQLite IDs now derive from the session, key, and content. Duplicate inserts become no-ops.

It adds regression coverage for repeated ETL runs. Focused tests and the SQLite daemon suite pass.

Must Fix

None identified.

Should Fix

Run the repository-required locked checks when possible:

  • cargo test --all-features --locked
  • cargo clippy --all-targets --all-features
  • cargo fmt --all --check

The PR notes pre-existing formatting and Clippy issues. Track or resolve them before claiming full workspace validation.

Consider

The session documents explain the design and testing scope.

Approve / Request Changes

Approve with the workspace-check limitation noted above.

Walkthrough

The change gives SQLite memory facts deterministic IDs based on session, key, and content. Duplicate IDs are ignored. A SQLite-gated ETL test verifies repeated processing returns three facts, with supporting session documentation.

Changes

Watcher Fact Idempotency

Layer / File(s) Summary
Durable fact identity and persistence
src/ports/sqlite_memory.rs, docs/sessions/20260809-watcher-fact-idempotency/01_RESEARCH.md, docs/sessions/20260809-watcher-fact-idempotency/02_SPECIFICATIONS.md, docs/sessions/20260809-watcher-fact-idempotency/04_IMPLEMENTATION_STRATEGY.md
SqliteMemoryStore replaces sequential IDs with length-prefixed SHA-256 IDs based on session ID, key, and content. Duplicate inserts use conflict-ignore behavior. The session documents define the persistence contract and implementation approach.
Repeated-input regression validation
crates/sl-daemon/src/etl.rs, docs/sessions/20260809-watcher-fact-idempotency/00_SESSION_OVERVIEW.md, docs/sessions/20260809-watcher-fact-idempotency/03_DAG_WBS.md, docs/sessions/20260809-watcher-fact-idempotency/05_KNOWN_ISSUES.md, docs/sessions/20260809-watcher-fact-idempotency/06_TESTING_STRATEGY.md
A SQLite-gated test transforms identical input twice with one memory store and asserts that three durable facts remain. The session documents record the work breakdown, test procedure, validation results, and tooling limitations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sessionledger-watcher-fact-idempotency
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch fix/sessionledger-watcher-fact-idempotency

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.

@KooshaPari
KooshaPari marked this pull request as ready for review August 10, 2026 01:47
Copilot AI lite review requested due to automatic review settings August 10, 2026 01:47

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@KooshaPari
KooshaPari merged commit e0a89df into main Aug 10, 2026
102 of 113 checks passed
@KooshaPari
KooshaPari deleted the fix/sessionledger-watcher-fact-idempotency branch August 10, 2026 01:47
}
}

fn fact_id(session_id: &str, key: &str, content: &str) -> String {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

WARNING: Deterministic IDs change recall pagination semantics

fact_id generates SHA-256 hex IDs. The recall function's ORDER BY id ASC previously preserved insertion order because IDs were monotonically increasing. With hash-based IDs, ordering is now effectively random, which changes top_k pagination behavior for consumers expecting chronological results.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
WARNING 1
Issue Details (click to expand)

WARNING

File Line Issue
src/ports/sqlite_memory.rs 127 Deterministic IDs change recall pagination semantics
Files Reviewed (2 files)
  • src/ports/sqlite_memory.rs - 1 issue
  • crates/sl-daemon/src/etl.rs - reviewed

Fix these issues in Kilo Cloud


Reviewed by step-3.7-flash · Input: 63.1K · Output: 20.5K · Cached: 349.3K

KooshaPari pushed a commit that referenced this pull request Aug 12, 2026
…469)

Shards the unique viewer proptest from #489 onto main without the
obsolete pre-rename daemon source churn.
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