memoryintelligence-mcp 0.2.9__tar.gz → 0.2.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of memoryintelligence-mcp might be problematic. Click here for more details.
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/CHANGELOG.md +67 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/PKG-INFO +22 -7
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/README.md +20 -5
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/pyproject.toml +1 -1
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/__init__.py +1 -1
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/cli.py +86 -6
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/scrub.py +39 -2
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/.gitignore +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/CONTRIBUTING.md +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/LICENSE +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/__main__.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/client.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/config.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/embedder.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/indexer.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/keys.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/local_index.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/localreads.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/paths.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/recall_guard.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/server.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/umo_format.py +0 -0
- {memoryintelligence_mcp-0.2.9 → memoryintelligence_mcp-0.2.11}/src/mi_mcp/vault.py +0 -0
|
@@ -3,6 +3,73 @@
|
|
|
3
3
|
All notable changes to `memoryintelligence-mcp` are documented here.
|
|
4
4
|
The format follows [Keep a Changelog](https://keepachangelog.com/); this project uses [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [0.2.11] — 2026-08-11
|
|
7
|
+
|
|
8
|
+
### Fixed — `doctor` only ever asked PyPI, so a mirror install could not learn it was behind (#1347)
|
|
9
|
+
|
|
10
|
+
This package ships on **two** channels — PyPI and the public GitHub mirror — and doctor
|
|
11
|
+
consulted one. A user installed from the mirror could be **ahead of** PyPI and be told
|
|
12
|
+
they were current. Not hypothetical: 0.2.6 was tagged and installable from the mirror
|
|
13
|
+
while PyPI went 0.2.5 → 0.2.7, and for ~20 hours `mi-mcp doctor` answered
|
|
14
|
+
`0.2.6 (latest)` with a green tick.
|
|
15
|
+
|
|
16
|
+
The unreachable-PyPI branch already handled this class carefully — `latest unknown`,
|
|
17
|
+
never "up to date". The divergence branch never got the same care.
|
|
18
|
+
|
|
19
|
+
Doctor now reads **both** channels and reports the newest across them. When the channels
|
|
20
|
+
disagree it names them, **even when you are on the newest of the two**, because the
|
|
21
|
+
divergence itself is the defect and whoever runs `doctor` is the only person positioned
|
|
22
|
+
to see it. When you are current, any unreachable channel is disclosed rather than hidden:
|
|
23
|
+
one channel agreeing with you is weaker evidence than two. An unreachable channel is
|
|
24
|
+
treated as *unknown*, never as *different*, so being offline does not raise a false alarm.
|
|
25
|
+
|
|
26
|
+
`--no-version-check` / `MI_MCP_NO_VERSION_CHECK=1` still make **zero** network calls, now
|
|
27
|
+
to either channel.
|
|
28
|
+
|
|
29
|
+
## [0.2.10] — 2026-08-11
|
|
30
|
+
|
|
31
|
+
### Fixed — the local PII floor over-redacted digit runs and ate the following space (#1586)
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
in : "the watermark is 1737654321 seconds"
|
|
35
|
+
out: "the watermark is <PHONE>seconds"
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`_PHONE_LONG_RE` was `(?:\+?\d[\s().-]?){10,15}` — **any** 10–15 digit run, each digit allowed
|
|
39
|
+
a trailing separator. Two defects compounded:
|
|
40
|
+
|
|
41
|
+
1. it matched **UNIX epoch seconds**, the most common 10-digit run in MI's own corpus, so a
|
|
42
|
+
timestamp was redacted as a phone number;
|
|
43
|
+
2. the final iteration's `[\s().-]?` **swallowed the following separator**, gluing the next
|
|
44
|
+
word to the marker.
|
|
45
|
+
|
|
46
|
+
**This was not a thin-install-only problem, as originally filed.** `scrub_text` applies the
|
|
47
|
+
`_HARD` floor on top of core's result **unconditionally** (`scrub.py:235`), so a floor looser
|
|
48
|
+
than core does not merely under-serve thin installs — it **overwrites a correct answer with a
|
|
49
|
+
wrong one on every MCP read**. Verified with core importable:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
core alone : "the watermark is 1737654321 seconds" (correct, untouched)
|
|
53
|
+
via floor : "the watermark is <PHONE>seconds" (degraded)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
One loose pattern split into three precise ones, mirroring `core/security/pii_detector.py`
|
|
57
|
+
rather than inventing a second design:
|
|
58
|
+
|
|
59
|
+
- **`_PHONE_SEP_RE`** — separated forms. The separators *are* the signal, so no digit-value
|
|
60
|
+
constraint is needed. Ends on a **digit**, which is defect 2's fix.
|
|
61
|
+
- **`_PHONE_E164_RE`** — the leading `+` is the signal (core measured 0 corpus matches for
|
|
62
|
+
this shape).
|
|
63
|
+
- **`_PHONE_BARE10_RE`** — defect 1's fix, and the dangerous one. NANP shape excludes epoch
|
|
64
|
+
seconds **structurally** (they start with `1` until 2033), and an alnum-aware boundary
|
|
65
|
+
excludes hex-hash digits (`"svo_hash": "914eb6579098371c"` contains a 10-digit run). Core
|
|
66
|
+
measured **360 → 48 → 1** as those are applied.
|
|
67
|
+
|
|
68
|
+
21 RED-first cases in `tests/test_scrub_precision.py`, 8 failing before the fix. Every
|
|
69
|
+
precision case has a recall partner (#1456), so closing the over-redaction cannot reopen the
|
|
70
|
+
leak, and the suite is green in **both** install shapes — with core importable and without —
|
|
71
|
+
because the defect and the fix both live in the floor that runs either way.
|
|
72
|
+
|
|
6
73
|
## [0.2.9] — 2026-08-09
|
|
7
74
|
|
|
8
75
|
### Fixed — the thin-install PII floor had drifted behind core (#1464)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: memoryintelligence-mcp
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.11
|
|
4
4
|
Summary: MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command
|
|
5
5
|
Project-URL: Homepage, https://memoryintelligence.io
|
|
6
6
|
Project-URL: Repository, https://github.com/somewhere11/memoryintelligence-mcp
|
|
@@ -227,17 +227,32 @@ mi-mcp status # wired surfaces + opt-in allowlist
|
|
|
227
227
|
mi-mcp wire --dry-run # preview wiring changes
|
|
228
228
|
```
|
|
229
229
|
|
|
230
|
-
**Staying current.** `doctor` compares your installed version against
|
|
231
|
-
|
|
230
|
+
**Staying current.** `doctor` compares your installed version against **both**
|
|
231
|
+
channels this package ships on — PyPI and the public GitHub mirror — and prints
|
|
232
|
+
the upgrade command for how you actually installed it:
|
|
232
233
|
|
|
233
234
|
```
|
|
234
235
|
[✗] version 0.2.5 installed, 0.2.8 available — `uv tool upgrade memoryintelligence-mcp && mi-mcp wire`
|
|
235
236
|
```
|
|
236
237
|
|
|
238
|
+
Both channels are checked because they can diverge, and reading one alone told
|
|
239
|
+
mirror users they were current when they were not (0.2.6 was installable from the
|
|
240
|
+
mirror while PyPI went straight 0.2.5 → 0.2.7). When the channels disagree,
|
|
241
|
+
`doctor` names them — even if you are on the newest of the two — because that
|
|
242
|
+
divergence is worth knowing about:
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
[✓] version 0.2.6 (latest) [channels differ: PyPI 0.2.5, mirror 0.2.6]
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
An unreachable channel reads as *unknown*, never as up to date, and never as a
|
|
249
|
+
disagreement.
|
|
250
|
+
|
|
237
251
|
Run `mi-mcp wire` after any upgrade — 0.2.6 renamed the server, and a config left
|
|
238
|
-
pointing at the old id loses its tools silently. The
|
|
239
|
-
index
|
|
240
|
-
`MI_MCP_NO_VERSION_CHECK=1`, and
|
|
252
|
+
pointing at the old id loses its tools silently. The checks are anonymous fetches
|
|
253
|
+
of the PyPI index and the mirror's `pyproject.toml`; skip them entirely with
|
|
254
|
+
`--no-version-check` or `MI_MCP_NO_VERSION_CHECK=1`, and they fail quietly when
|
|
255
|
+
you're offline.
|
|
241
256
|
|
|
242
257
|
**Which server am I talking to?** The local server announces `mi-local`; the
|
|
243
258
|
remote MCP surface announces `memoryintelligence-remote`. The local default
|
|
@@ -188,17 +188,32 @@ mi-mcp status # wired surfaces + opt-in allowlist
|
|
|
188
188
|
mi-mcp wire --dry-run # preview wiring changes
|
|
189
189
|
```
|
|
190
190
|
|
|
191
|
-
**Staying current.** `doctor` compares your installed version against
|
|
192
|
-
|
|
191
|
+
**Staying current.** `doctor` compares your installed version against **both**
|
|
192
|
+
channels this package ships on — PyPI and the public GitHub mirror — and prints
|
|
193
|
+
the upgrade command for how you actually installed it:
|
|
193
194
|
|
|
194
195
|
```
|
|
195
196
|
[✗] version 0.2.5 installed, 0.2.8 available — `uv tool upgrade memoryintelligence-mcp && mi-mcp wire`
|
|
196
197
|
```
|
|
197
198
|
|
|
199
|
+
Both channels are checked because they can diverge, and reading one alone told
|
|
200
|
+
mirror users they were current when they were not (0.2.6 was installable from the
|
|
201
|
+
mirror while PyPI went straight 0.2.5 → 0.2.7). When the channels disagree,
|
|
202
|
+
`doctor` names them — even if you are on the newest of the two — because that
|
|
203
|
+
divergence is worth knowing about:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
[✓] version 0.2.6 (latest) [channels differ: PyPI 0.2.5, mirror 0.2.6]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
An unreachable channel reads as *unknown*, never as up to date, and never as a
|
|
210
|
+
disagreement.
|
|
211
|
+
|
|
198
212
|
Run `mi-mcp wire` after any upgrade — 0.2.6 renamed the server, and a config left
|
|
199
|
-
pointing at the old id loses its tools silently. The
|
|
200
|
-
index
|
|
201
|
-
`MI_MCP_NO_VERSION_CHECK=1`, and
|
|
213
|
+
pointing at the old id loses its tools silently. The checks are anonymous fetches
|
|
214
|
+
of the PyPI index and the mirror's `pyproject.toml`; skip them entirely with
|
|
215
|
+
`--no-version-check` or `MI_MCP_NO_VERSION_CHECK=1`, and they fail quietly when
|
|
216
|
+
you're offline.
|
|
202
217
|
|
|
203
218
|
**Which server am I talking to?** The local server announces `mi-local`; the
|
|
204
219
|
remote MCP surface announces `memoryintelligence-remote`. The local default
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "memoryintelligence-mcp"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.11"
|
|
8
8
|
description = "MCP server for MemoryIntelligence — give Claude a memory you own, set up in one command"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -455,6 +455,11 @@ def cmd_wire(argv: list[str]) -> int:
|
|
|
455
455
|
#: PyPI project name — the package this CLI ships as.
|
|
456
456
|
PYPI_PROJECT = "memoryintelligence-mcp"
|
|
457
457
|
|
|
458
|
+
#: The public GitHub mirror — the SECOND channel this package ships on (#1347).
|
|
459
|
+
#: A release reaches users through either, and they have diverged before.
|
|
460
|
+
MIRROR_REPO = "somewhere11/memoryintelligence-mcp"
|
|
461
|
+
MIRROR_BRANCH = "main"
|
|
462
|
+
|
|
458
463
|
#: Set truthy to skip doctor's release check entirely (no network call at all).
|
|
459
464
|
NO_VERSION_CHECK_ENV = "MI_MCP_NO_VERSION_CHECK"
|
|
460
465
|
|
|
@@ -500,6 +505,60 @@ def _latest_pypi_version(project: str = PYPI_PROJECT, timeout: float = 2.0) -> s
|
|
|
500
505
|
return max(real, key=_version_tuple) if real else None
|
|
501
506
|
|
|
502
507
|
|
|
508
|
+
def _latest_mirror_version(repo: str = MIRROR_REPO, timeout: float = 2.0) -> str | None:
|
|
509
|
+
"""Version the public GitHub mirror currently holds, or None if unknowable.
|
|
510
|
+
|
|
511
|
+
Reads the mirror's own ``pyproject.toml`` rather than its tags, because that is
|
|
512
|
+
what a mirror install actually gives you (``pip install git+…@main``). A tag
|
|
513
|
+
marks a release; the file is the thing you get.
|
|
514
|
+
|
|
515
|
+
Never raises: offline, DNS, 404, rate limit and a changed file layout are all
|
|
516
|
+
"unknown", the same contract as :func:`_latest_pypi_version`.
|
|
517
|
+
"""
|
|
518
|
+
import urllib.request
|
|
519
|
+
|
|
520
|
+
url = f"https://raw.githubusercontent.com/{repo}/{MIRROR_BRANCH}/pyproject.toml"
|
|
521
|
+
req = urllib.request.Request(url, headers={"User-Agent": f"mi-mcp/{__version__}"})
|
|
522
|
+
try:
|
|
523
|
+
with urllib.request.urlopen(req, timeout=timeout) as resp: # noqa: S310 (fixed https URL)
|
|
524
|
+
text = resp.read().decode("utf-8", "replace")
|
|
525
|
+
except Exception:
|
|
526
|
+
return None
|
|
527
|
+
# Anchored to a line-leading `version`, so `requires-python = ">=3.10"` — which
|
|
528
|
+
# also holds a dotted number — cannot be mistaken for the package version.
|
|
529
|
+
m = re.search(r'(?m)^\s*version\s*=\s*["\']([^"\']+)["\']', text)
|
|
530
|
+
return m.group(1).strip() if m else None
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
def _latest_release(
|
|
534
|
+
pypi: str | None = None, mirror: str | None = None
|
|
535
|
+
) -> tuple[str | None, dict]:
|
|
536
|
+
"""(newest version across BOTH channels, {channel: version|None}).
|
|
537
|
+
|
|
538
|
+
"Latest" means newest *anywhere it ships*. Reading one channel and calling it
|
|
539
|
+
latest is what #1347 was filed about: for ~20 hours a mirror user on 0.2.6 was
|
|
540
|
+
told they were current because PyPI — which had never received 0.2.6 — was the
|
|
541
|
+
only thing consulted.
|
|
542
|
+
"""
|
|
543
|
+
channels = {
|
|
544
|
+
"PyPI": _latest_pypi_version() if pypi is None else pypi,
|
|
545
|
+
"mirror": _latest_mirror_version() if mirror is None else mirror,
|
|
546
|
+
}
|
|
547
|
+
known = [v for v in channels.values() if v]
|
|
548
|
+
return (max(known, key=_version_tuple) if known else None), channels
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
def _channels_diverge(channels: dict) -> bool:
|
|
552
|
+
"""True only when two channels are both KNOWN and disagree.
|
|
553
|
+
|
|
554
|
+
An unreachable channel is *unknown*, not *different* — reporting a divergence
|
|
555
|
+
because the network was down would train users to ignore the warning, which is
|
|
556
|
+
the same way the original green tick stopped meaning anything.
|
|
557
|
+
"""
|
|
558
|
+
known = {v for v in channels.values() if v}
|
|
559
|
+
return len(known) > 1
|
|
560
|
+
|
|
561
|
+
|
|
503
562
|
def _upgrade_command() -> str:
|
|
504
563
|
"""The upgrade command for THIS install, not a generic guess.
|
|
505
564
|
|
|
@@ -535,27 +594,48 @@ def cmd_doctor(argv: list[str]) -> int:
|
|
|
535
594
|
# Release check FIRST — being two versions behind explains most "the tool
|
|
536
595
|
# doesn't have X" reports, and it is the one thing nothing else surfaces.
|
|
537
596
|
# Non-critical: out of date is not broken, so it never fails doctor's exit code.
|
|
538
|
-
# Opt out with --no-version-check or MI_MCP_NO_VERSION_CHECK=1; the
|
|
539
|
-
# anonymous
|
|
597
|
+
# Opt out with --no-version-check or MI_MCP_NO_VERSION_CHECK=1; the calls are
|
|
598
|
+
# anonymous index/raw-file fetches (same as any install) and are skipped then.
|
|
599
|
+
#
|
|
600
|
+
# BOTH channels are consulted (#1347). This package ships on PyPI *and* the
|
|
601
|
+
# public GitHub mirror, and they have diverged in production: 0.2.6 was tagged
|
|
602
|
+
# and installable from the mirror while PyPI went straight 0.2.5 → 0.2.7. Asking
|
|
603
|
+
# PyPI alone told a mirror user on 0.2.6 they were on the latest, which is the
|
|
604
|
+
# false reassurance this whole check exists to prevent.
|
|
540
605
|
skip_vc = args.no_version_check or os.environ.get(
|
|
541
606
|
NO_VERSION_CHECK_ENV, ""
|
|
542
607
|
).strip().lower() in ("1", "true", "yes", "on")
|
|
543
608
|
if skip_vc:
|
|
544
609
|
check("version", True, f"{__version__} (release check skipped)", critical=False)
|
|
545
610
|
else:
|
|
546
|
-
latest =
|
|
611
|
+
latest, channels = _latest_release()
|
|
612
|
+
# Name the channels whenever they disagree — even when the user is already
|
|
613
|
+
# on the newest of the two. The divergence itself is the defect, and the
|
|
614
|
+
# person running doctor is the only one positioned to notice it.
|
|
615
|
+
where = ""
|
|
616
|
+
if _channels_diverge(channels):
|
|
617
|
+
where = " [channels differ: " + ", ".join(
|
|
618
|
+
f"{name} {v or 'unknown'}" for name, v in channels.items()
|
|
619
|
+
) + "]"
|
|
620
|
+
|
|
547
621
|
if latest is None:
|
|
548
622
|
# Unknown is NOT "up to date" — say so rather than imply green.
|
|
549
623
|
check("version", True,
|
|
550
|
-
f"{__version__} installed — could not reach PyPI,
|
|
624
|
+
f"{__version__} installed — could not reach PyPI or the mirror, "
|
|
625
|
+
f"latest unknown",
|
|
551
626
|
critical=False)
|
|
552
627
|
elif _version_tuple(latest) > _version_tuple(__version__):
|
|
553
628
|
check("version", False,
|
|
554
629
|
f"{__version__} installed, {latest} available — "
|
|
555
|
-
f"`{_upgrade_command()} && mi-mcp wire`",
|
|
630
|
+
f"`{_upgrade_command()} && mi-mcp wire`{where}",
|
|
556
631
|
critical=False)
|
|
557
632
|
else:
|
|
558
|
-
|
|
633
|
+
# Current, but say which channels were actually readable. A lone
|
|
634
|
+
# reachable channel agreeing with you is weaker evidence than both.
|
|
635
|
+
unknown = [n for n, v in channels.items() if not v]
|
|
636
|
+
note = f" ({', '.join(unknown)} unreachable)" if unknown else ""
|
|
637
|
+
check("version", True, f"{__version__} (latest){note}{where}",
|
|
638
|
+
critical=False)
|
|
559
639
|
|
|
560
640
|
bin_path = _mi_mcp_bin()
|
|
561
641
|
check("mi-mcp binary", Path(bin_path).exists(), bin_path)
|
|
@@ -87,7 +87,39 @@ _SSN_RE = re.compile(r"\b(?!000|666|9\d\d)\d{3}[\s.\-]+(?!00)\d{2}[\s.\-]+(?!000
|
|
|
87
87
|
#: Phone. `_PHONE_LONG` is the pre-existing 10–15 digit run. The short forms are
|
|
88
88
|
#: the #1446/A2 gap: every alternative needed THREE digit groups, so "555-0142"
|
|
89
89
|
#: and "+1-555-0142" leaked — including `pii-phone-001`, an EXEMPLAR fixture.
|
|
90
|
-
_PHONE_LONG_RE
|
|
90
|
+
# ⚠️ #1586 — `_PHONE_LONG_RE` was `(?:\+?\d[\s().-]?){10,15}`, i.e. ANY 10–15
|
|
91
|
+
# digit run, with each digit allowed a trailing separator. Two defects fell out
|
|
92
|
+
# of that, and they compounded:
|
|
93
|
+
#
|
|
94
|
+
# 1. it matched UNIX EPOCH SECONDS — 10 digits, and the most common 10-digit
|
|
95
|
+
# run in MI's own corpus — so `the watermark is 1737654321 seconds` became
|
|
96
|
+
# `<PHONE>`;
|
|
97
|
+
# 2. the final iteration's `[\s().-]?` SWALLOWED THE FOLLOWING SEPARATOR, so
|
|
98
|
+
# the next word was glued to the marker: `the watermark is <PHONE>seconds`.
|
|
99
|
+
#
|
|
100
|
+
# This is not merely a thin-install concern. `scrub_text` applies `_HARD` on top
|
|
101
|
+
# of core's result unconditionally, so a floor looser than core *overwrites a
|
|
102
|
+
# correct answer with a wrong one* on every MCP read.
|
|
103
|
+
#
|
|
104
|
+
# Split into three precise patterns, mirroring `core/security/pii_detector.py`:
|
|
105
|
+
#
|
|
106
|
+
# SEPARATED — the separators themselves are the signal, so no digit-value
|
|
107
|
+
# constraint is needed. Ends on a DIGIT, which is defect 2's fix.
|
|
108
|
+
_PHONE_SEP_RE = re.compile(
|
|
109
|
+
r"(?<![\d.])\+?\d{1,4}[\s().\-]+\d(?:[\s().\-]?\d){6,12}(?![\d.])"
|
|
110
|
+
)
|
|
111
|
+
# E.164 — the leading `+` is the signal. Measured in core: 0 matches across
|
|
112
|
+
# 2,618 of MI's own files, so it needs no further constraint.
|
|
113
|
+
_PHONE_E164_RE = re.compile(r"(?<![\d+])\+[1-9]\d{9,14}(?![\d])")
|
|
114
|
+
# BARE 10-DIGIT — the dangerous one, and the direct fix for defect 1. Same two
|
|
115
|
+
# constraints core measured its way to: a NANP shape (area code and exchange
|
|
116
|
+
# both start 2-9), which excludes epoch seconds structurally because they begin
|
|
117
|
+
# with `1` until 2033; and an ALNUM-AWARE boundary, because the digits of a hex
|
|
118
|
+
# hash are still digits (`"svo_hash": "914eb6579098371c"` contains a 10-digit
|
|
119
|
+
# run). Core measured 360 → 48 → 1 matches as those are applied.
|
|
120
|
+
_PHONE_BARE10_RE = re.compile(
|
|
121
|
+
r"(?<![0-9A-Za-z._\-:+])[2-9]\d{2}[2-9]\d{6}(?![0-9A-Za-z\-])"
|
|
122
|
+
)
|
|
91
123
|
_PHONE_INTL_SHORT_RE = re.compile(r"(?<![\d])\+\d{1,3}[\s.\-]?\d{3}[\s.\-]\d{4}(?![\d])")
|
|
92
124
|
#: A bare 7-digit run is NOT distinctive — core measured it hitting file:line
|
|
93
125
|
#: ranges, ULID fragments and coordinates — so it is CONTEXT-ANCHORED, as there.
|
|
@@ -126,7 +158,12 @@ _HARD = [
|
|
|
126
158
|
(re.compile(r"\b(?:\d[ -]?){13,19}\b"), "<CARD>"),
|
|
127
159
|
(_ADDRESS_RE, "<ADDRESS>"),
|
|
128
160
|
(_PHONE_INTL_SHORT_RE, "<PHONE>"),
|
|
129
|
-
|
|
161
|
+
# #1586 — order matters within the phone group: E.164 and the separated form
|
|
162
|
+
# first (both carry their own signal), bare-10 last so it only ever sees runs
|
|
163
|
+
# the more specific patterns did not already claim.
|
|
164
|
+
(_PHONE_E164_RE, "<PHONE>"),
|
|
165
|
+
(_PHONE_SEP_RE, "<PHONE>"),
|
|
166
|
+
(_PHONE_BARE10_RE, "<PHONE>"),
|
|
130
167
|
]
|
|
131
168
|
|
|
132
169
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|