Skip to content

feat: reject digit-adjacent tokens and raise default threshold to 8 - #16

Merged
larkiny merged 3 commits into
mainfrom
feat/improve-detection
Feb 7, 2026
Merged

feat: reject digit-adjacent tokens and raise default threshold to 8#16
larkiny merged 3 commits into
mainfrom
feat/improve-detection

Conversation

@larkiny

@larkiny larkiny commented Feb 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Digit rejection in stripToken — Tokens where the stripped leading/trailing portion contains digits (e.g. board[0], abandon123, 3abandon) are now disqualified as sequence-breaking (null), preventing false positives from array indexing and code constructs. Applied to TypeScript and both Bash scripts.
  • Default threshold raised from 5 → 8 — Exported as DEFAULT_THRESHOLD from detect.ts and shared across check-staged.ts and scan-repo.ts. Reduces false positives from prose containing common BIP39 words while still catching 12/24/25-word mnemonics.
  • README updated — All threshold references updated from 5 to 8; config example now shows BIP39_THRESHOLD=12 as the override illustration.

Test plan

  • All 122 existing tests pass (pnpm vitest run)
  • New tests for digit-prefixed, digit-suffixed, and array-indexed tokens
  • New test for Python board[0]..board[8] code snippet (no false positive)
  • All test data updated to use 8-word BIP39 sequences matching new threshold
  • DEFAULT_THRESHOLD constant verified in detect.ts, check-staged.ts, scan-repo.ts

Tokens like board[0] or abandon123 where the stripped non-alpha
portion contains digits are now disqualified (return null) instead
of matching as BIP39 words. This prevents false positives from
array indexing and variable naming in code.

Also raises DEFAULT_THRESHOLD from 5 to 8 via a shared constant
exported from detect.ts, reducing false positives from prose that
happens to contain common BIP39 words.
@codecov

codecov Bot commented Feb 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
ts/check-staged.ts 90.80% <100.00%> (ø)
ts/detect.ts 92.96% <100.00%> (+0.16%) ⬆️
ts/scan-repo.ts 85.02% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@larkiny
larkiny merged commit ca1a043 into main Feb 7, 2026
6 checks passed
@larkiny
larkiny deleted the feat/improve-detection branch February 7, 2026 15:54
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