fix(digest-dedup): CLUSTERING typo fallback fails closed to complete-link#3331
Conversation
…link DIGEST_DEDUP_CLUSTERING previously fell to 'single' on unrecognised values, which silently defeated the documented kill switch. A typo like `DIGEST_DEDUP_CLUSTERING=complet` during an over-merge incident would stick with the aggressive single-link merger instead of rolling back to the conservative complete-link algorithm. Mirror the DIGEST_DEDUP_MODE typo pattern (PR #3247): - Unrecognised value → fall to 'complete' (SAFE / conservative). - Surface the raw value via new `invalidClusteringRaw` config field. - Emit a warn line on the dedup orchestrator's entry path so operators see the typo alongside the kill-switch-took-effect message. Valid values 'single' (default), 'complete', unset, empty, and any case variation all behave unchanged. Only true typos change behaviour — and the new behaviour is the kill-switch-safe one. Tests: updated the existing case that codified the old behaviour plus added coverage for (a) multiple typo variants falling to complete with invalidClusteringRaw set, (b) case-insensitive valid values not triggering the typo path, and (c) the orchestrator emitting the warn line even on the jaccard-kill-switch codepath (since CLUSTERING intent applies to both modes). 81/81 dedup tests pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Greptile SummaryThis PR fixes a silent fail-open bug in Confidence Score: 5/5Safe to merge — narrow, well-tested fix with no unintended scope. All findings are P2 or absent. The logic change is correct, mirrors an established pattern, and is covered by 4 new tests plus an updated existing one. No security, data-integrity, or correctness issues found. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["env.DIGEST_DEDUP_CLUSTERING"] --> B["clusteringRaw = (value ?? '').toLowerCase()"]
B --> C{clusteringRaw}
C -->|"'' or 'single'"| D["clustering = 'single'\ninvalidClusteringRaw = null"]
C -->|"'complete'"| E["clustering = 'complete'\ninvalidClusteringRaw = null"]
C -->|"anything else (typo)"| F["clustering = 'complete' ← BEFORE: 'single'\ninvalidClusteringRaw = clusteringRaw"]
F --> G["deduplicateStories: emit warn log"]
D --> H["Return config"]
E --> H
G --> H
Reviews (1): Last reviewed commit: "fix(digest-dedup): CLUSTERING typo fallb..." | Re-trigger Greptile |
Why this PR?
DIGEST_DEDUP_CLUSTERINGpreviously fell tosingleon unrecognised values, which silently defeated the documented kill switch. An operator typingDIGEST_DEDUP_CLUSTERING=completduring an over-merge incident would stick with the aggressive single-link merger instead of rolling back to conservative complete-link.Before:
After — mirrors the
DIGEST_DEDUP_MODEtypo pattern from PR #3247:The orchestrator emits a warn line on entry whenever
invalidClusteringRawis non-null, so operators see the typo alongside the kill-switch-took-effect message. Warn fires on bothembedandjaccardcodepaths because the operator's intent (conservative algorithm) applies in both modes.Behaviour change surface
singlesingle''singlesinglesingle/SINGLEsinglesinglecomplete/Completecompletecompletecomplet/avarage/ any typosinglecomplete+ warnOnly true typos change behaviour, and the new behaviour is the kill-switch-safe one.
Scope
Intentionally narrow. No change to:
DIGEST_DEDUP_CLUSTERING.Tests
node --test tests/brief-dedup-embedding.test.mjs→ 61/61 pass (prior 59 unchanged + 3 new: case-insensitive valid values, typo → complete withinvalidClusteringRaw, warn emission on jaccard codepath). The one prior test that codified the old buggy behaviour is updated to the new contract.node --test tests/brief-dedup-embedding.test.mjs tests/brief-dedup-jaccard.test.mjs→ 81/81 pass total.npx biome lint→ cleannpm run typecheck→ cleanRollback
Revert the commit.
DIGEST_DEDUP_CLUSTERING=single(explicit) restores the previous aggressive-merger behaviour without any code change.Related
Test plan
node --test tests/brief-dedup-embedding.test.mjs tests/brief-dedup-jaccard.test.mjsnpx biome linton changed filesnpm run typecheckDIGEST_DEDUP_CLUSTERING=complet) on a staging Railway service emits the expected warn line