Release: Issues+Systems, milestone-as-plan, plugin reliability/skills/dedup, compaction hygiene #71

Merged
bvandeusen merged 25 commits from dev into main 2026-06-14 15:51:44 -04:00
Showing only changes of commit 5102ffb558 - Show all commits
+9
View File
@@ -22,6 +22,7 @@ Two signals, both scoped to the same owner + project + kind:
""" """
from __future__ import annotations from __future__ import annotations
import logging
from dataclasses import dataclass from dataclasses import dataclass
from sqlalchemy import func, select from sqlalchemy import func, select
@@ -30,6 +31,8 @@ from scribe.models import async_session
from scribe.models.note import Note from scribe.models.note import Note
from scribe.services import embeddings as embeddings_svc from scribe.services import embeddings as embeddings_svc
logger = logging.getLogger(__name__)
# Run the semantic check only when the incoming body has at least this many # Run the semantic check only when the incoming body has at least this many
# characters — below it, embeddings are dominated by the title and false-positive. # characters — below it, embeddings are dominated by the title and false-positive.
_MIN_BODY_FOR_SEMANTIC = 200 _MIN_BODY_FOR_SEMANTIC = 200
@@ -82,7 +85,10 @@ async def find_duplicate_note(
norm = " ".join((title or "").split()).lower() norm = " ".join((title or "").split()).lower()
# --- Signal 1: normalized-title exact match (same scope) --- # --- Signal 1: normalized-title exact match (same scope) ---
# Fail-open: a dedup-check failure (DB down, etc.) must never block a
# legitimate create — degrade to "no duplicate found" and let it through.
if norm: if norm:
try:
async with async_session() as session: async with async_session() as session:
stmt = select(Note).where( stmt = select(Note).where(
Note.user_id == user_id, Note.user_id == user_id,
@@ -101,6 +107,9 @@ async def find_duplicate_note(
existing = (await session.execute(stmt.limit(1))).scalars().first() existing = (await session.execute(stmt.limit(1))).scalars().first()
if existing is not None: if existing is not None:
return DuplicateMatch(existing.id, existing.title, 1.0, "title") return DuplicateMatch(existing.id, existing.title, 1.0, "title")
except Exception:
logger.debug("dedup title check skipped — query failed", exc_info=True)
return None
# --- Signal 2: semantic similarity (only with a substantial body) --- # --- Signal 2: semantic similarity (only with a substantial body) ---
if body and len(body.strip()) >= _MIN_BODY_FOR_SEMANTIC: if body and len(body.strip()) >= _MIN_BODY_FOR_SEMANTIC: