Skip to content

feat(dedup): fingerprint-based observation dedup with seen_count persistence#67

Merged
Gradata merged 2 commits intomainfrom
wt-observation-dedup
Apr 15, 2026
Merged

feat(dedup): fingerprint-based observation dedup with seen_count persistence#67
Gradata merged 2 commits intomainfrom
wt-observation-dedup

Conversation

@Gradata
Copy link
Copy Markdown
Owner

@Gradata Gradata commented Apr 15, 2026

Summary

Dedupes near-identical correction observations within a rolling window so repeated corrections don't inflate confidence N-fold. Policy: DROP (not MERGE), validated via 5-perspective polyclaude council (unanimous HIGH). seen_count is persisted either way so the policy is reversible via a backfill worker.

Council verdict (observation-dedup council, 2026-04-15)

Unanimous DROP across SRE, Statistician, Red-Team, Product/UX, Pipeline-Architect:

Files

  • src/gradata/enhancements/dedup.py (new) — fingerprint, is_duplicate, register_observation, annotate_event_with_dedup
  • src/gradata/_core.py — single 7-line hook at the ingestion seam
  • tests/test_dedup.py — 14 tests

Tests

2271 pass (+14), ruff clean.

Commits

  • 771cf66 feat(dedup): fingerprint-based observation dedup
  • 8ca5457 refactor(dedup): extract hook helper, reuse _db.get_connection

Follow-up flagged

  • observation_dedup DDL should move to _migrations._BASE_TABLES once this worktree's NO-TOUCH list expires

Co-Authored-By: Gradata noreply@gradata.ai

Gradata and others added 2 commits April 15, 2026 00:23
…e semantics

Problem: 10 sessions of "don't use em-dashes" produced 10 lesson
reinforcements and inflated confidence/fire_count 10x. Ties into
gap-analysis gap #4 (survival-bonus bypass inflating confidence).

Solution: A single sha1 fingerprint on (category, normalized(draft||final))
is persisted in a new observation_dedup SQLite table with seen_count,
first/last session, and timestamps. The ingestion path in
brain_correct (_core.py) calls check_and_register at exactly one point;
if the fingerprint was seen inside a recent 10-session window the
correction is tagged observation_deduped and the lesson-create /
lesson-reinforce branch is skipped, preventing confidence inflation
while preserving pattern extraction, FTS indexing, bus emit, and the
raw CORRECTION event.

Semantics: default is DROP within window. seen_count is still tracked
in the persisted row so MERGE (bump fire_count by seen_count at window
rollover) can be wired in later without data loss. True MERGE wiring
requires extending update_confidence in self_improvement.py, which is
off-limits for this worktree — flagged for polyclaude policy review.

Files:
- src/gradata/enhancements/dedup.py (new)
- src/gradata/_core.py (single hook point in brain_correct)
- tests/test_dedup.py (14 tests: fingerprint stability, normalization,
  category-awareness, window boundaries, end-to-end via Brain.correct)

Tests: 2271 pass, 23 skipped. ruff clean.

Co-Authored-By: Gradata <noreply@gradata.ai>
- Pull the 29-line inline dedup block in brain_correct into a single
  annotate_event_with_dedup() helper inside dedup.py. Call site in
  _core.py is now 7 lines including the import — one seam, one signature.
- Reuse gradata._db.get_connection and ensure_table instead of
  hand-rolling a sqlite3.connect + PRAGMA busy_timeout + CREATE TABLE
  path. Aligns dedup.py with the project's standard schema-creation
  pattern without touching _migrations.py.
- Collapse _normalize_text into two statements.

No behavior change. All 14 dedup tests pass, full suite still at
2271 passed / 23 skipped. ruff clean on the touched files.

Co-Authored-By: Gradata <noreply@gradata.ai>
Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@Gradata has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 25 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 25 seconds.

⌛ 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ae94df47-b340-4ec1-af36-29de9a066130

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd7215 and 8ca5457.

📒 Files selected for processing (3)
  • src/gradata/_core.py
  • src/gradata/enhancements/dedup.py
  • tests/test_dedup.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wt-observation-dedup

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

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying gradata-dashboard with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8ca5457
Status: ✅  Deploy successful!
Preview URL: https://8173d841.gradata-dashboard.pages.dev
Branch Preview URL: https://wt-observation-dedup.gradata-dashboard.pages.dev

View logs

@Gradata Gradata merged commit b3c968c into main Apr 15, 2026
16 checks passed
@Gradata Gradata deleted the wt-observation-dedup branch April 17, 2026 19:47
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