-
Notifications
You must be signed in to change notification settings - Fork 0
fix(daemon): deduplicate durable watcher facts #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
docs/sessions/20260809-watcher-fact-idempotency/00_SESSION_OVERVIEW.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Watcher fact idempotency | ||
|
|
||
| Goal: prevent repeated filesystem-event handling of unchanged transcript input from duplicating SQLite episodic facts. | ||
|
|
||
| Success: a focused ETL regression test fails before the fix, passes after it, and the daemon's relevant test suite remains green. |
8 changes: 8 additions & 0 deletions
8
docs/sessions/20260809-watcher-fact-idempotency/01_RESEARCH.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Research | ||
|
|
||
| - `crates/sl-daemon/src/watcher.rs` forwards each create or modify event for a transcript; FSEvents may report repeated events for unchanged input. | ||
| - `crates/sl-daemon/src/etl.rs::transform_file` invokes `compile_and_store` once per parsed session when SQLite memory is configured. | ||
| - `src/ports/sqlite_memory.rs::store` currently assigns an incrementing identifier, so reprocessing the same session/key/content creates another durable row. | ||
| - `DistillMemoryWriter` already constructs a stable key from session id and bundle kind. A deterministic identity over session id, key, and content can make the SQLite primary key idempotent without changing watcher timing or HTTP behavior. | ||
|
|
||
| The red regression test transformed one JSONL fixture twice and recalled six SQLite facts where the three stable distilled facts were expected. This confirms the duplicate originates at the durable SQLite identity boundary. |
5 changes: 5 additions & 0 deletions
5
docs/sessions/20260809-watcher-fact-idempotency/02_SPECIFICATIONS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Specifications | ||
|
|
||
| Repeated handling of one unchanged transcript must leave one durable SQLite fact per distilled fact identity. Distinct content must remain independently persistable. | ||
|
|
||
| Scope excludes HTTP persistence, viewer changes, daemon configuration, and live daemon control. |
5 changes: 5 additions & 0 deletions
5
docs/sessions/20260809-watcher-fact-idempotency/03_DAG_WBS.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Work breakdown | ||
|
|
||
| 1. Trace watcher, ETL, memory writer, and SQLite store. | ||
| 2. Add a focused failing repeated-input regression test. | ||
| 3. Make durable identity idempotent and validate targeted tests. |
3 changes: 3 additions & 0 deletions
3
docs/sessions/20260809-watcher-fact-idempotency/04_IMPLEMENTATION_STRATEGY.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Implementation strategy | ||
|
|
||
| Use a deterministic content identity for SQLite memory facts and SQLite primary-key conflict handling. This fixes the durable boundary where duplicates are created and avoids debouncing heuristics that could discard legitimate later edits. |
5 changes: 5 additions & 0 deletions
5
docs/sessions/20260809-watcher-fact-idempotency/05_KNOWN_ISSUES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Known issues | ||
|
|
||
| OS filesystem event timing is intentionally not used in the test; the deterministic repeated ETL input reproduces its downstream effect. | ||
|
|
||
| The current checkout's repository-wide `cargo fmt --check` reports pre-existing formatting drift in unrelated daemon resolver, HTTP, main, and lib files. The changed Rust files pass an isolated `rustfmt --check`. `cargo clippy` is blocked before linting by the existing `clippy.toml` fields `warn` and `allow`, which this installed Clippy rejects. |
5 changes: 5 additions & 0 deletions
5
docs/sessions/20260809-watcher-fact-idempotency/06_TESTING_STRATEGY.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # Testing strategy | ||
|
|
||
| Run a focused `sl-daemon` ETL unit test that transforms the same real JSONL fixture twice through a SQLite memory store, then run the daemon crate test suite with the SQLite feature. | ||
|
|
||
| Observed RED: 6 recalled durable facts after two identical transforms. Expected and observed GREEN: 3 facts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING: Deterministic IDs change
recallpagination semanticsfact_idgenerates SHA-256 hex IDs. Therecallfunction'sORDER BY id ASCpreviously preserved insertion order because IDs were monotonically increasing. With hash-based IDs, ordering is now effectively random, which changestop_kpagination behavior for consumers expecting chronological results.Reply with
@kilocode-bot fix itto have Kilo Code address this issue.