feat(dedup): the create gate's similarity bars are settings (#4385, rule 25)
CI & Build / Python lint (push) Successful in 3s
CI & Build / Plugin hooks (push) Successful in 10s
CI & Build / TypeScript typecheck (push) Successful in 57s
CI & Build / integration (push) Successful in 56s
CI & Build / Python tests (push) Successful in 1m38s
CI & Build / Build & push image (push) Successful in 38s

gate_bars(user_id, note_type) resolves the block bar and, for notes and
tasks, the overlap floor from kb_gate_* settings, with the old constants
as defaults. Fail-open on an unreadable value; a block bar clamps at 0.80
and the overlap floor at 0.70 and never above the bar. Five fields in
Settings beside the duplicate-report floors.

CLAIM_LEASE stays a constant, with the reason written at it: a per-user
lease would make one shared task live to one reader and dead to another.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-24 07:11:10 -04:00
co-authored by Claude Opus 5.5
parent baf22179ef
commit 4502f0a1ae
5 changed files with 286 additions and 11 deletions
+21
View File
@@ -178,3 +178,24 @@ def _no_rule_overlap():
with patch("scribe.services.dedup.find_overlapping_rules",
AsyncMock(return_value=[])):
yield
@pytest.fixture(autouse=True)
def _default_gate_bars():
"""Read the create gate's bars as their defaults, not from settings (#4385).
Every create through the note gate now asks the user's settings for its
similarity bars, which is a database read on a path the gate's unit tests
run without one. Stubbed one level down — `_gate_setting`, not `gate_bars`
— so the copy-band logic above it (which kinds read an overlap floor, the
floor never sitting above the bar) still runs in every test. The setting
read itself is tested in tests/test_gate_settings.py, which binds the real
function at import time, before this patch runs.
"""
from scribe.services.dedup import GATE_DEFAULT_THRESHOLDS
async def _default(user_id, key, lo):
return GATE_DEFAULT_THRESHOLDS[key]
with patch("scribe.services.dedup._gate_setting", AsyncMock(side_effect=_default)):
yield