baton-proxy 0.7.1__tar.gz → 0.7.2__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.
Files changed (59) hide show
  1. baton_proxy-0.7.2/.github/workflows/test.yml +54 -0
  2. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/CHANGELOG.md +7 -1
  3. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/PKG-INFO +1 -1
  4. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/__init__.py +1 -1
  5. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/scrub.py +25 -12
  6. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_scrub.py +42 -0
  7. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/try/kit.py +1 -1
  8. baton_proxy-0.7.1/.github/workflows/test.yml +0 -29
  9. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/.claude/settings.json +0 -0
  10. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/.github/workflows/release.yml +0 -0
  11. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/.gitignore +0 -0
  12. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/.gitmodules +0 -0
  13. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/CLAUDE.md +0 -0
  14. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/LICENSE +0 -0
  15. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/Makefile +0 -0
  16. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/README.md +0 -0
  17. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/SECURITY.md +0 -0
  18. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/examples/live-claude-invocation/instructions.md +0 -0
  19. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/examples/live-claude-invocation/result.md +0 -0
  20. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/examples/live-claude-invocation/setup.sh +0 -0
  21. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/examples/live-claude-invocation/unregister.sh +0 -0
  22. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/pyproject.toml +0 -0
  23. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/__main__.py +0 -0
  24. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/_llm_text.py +0 -0
  25. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/config.py +0 -0
  26. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/emitter.py +0 -0
  27. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/identity.py +0 -0
  28. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/mcp_error.py +0 -0
  29. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/proxy.py +0 -0
  30. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/sinks.py +0 -0
  31. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/src/baton_proxy/transport_http.py +0 -0
  32. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/__init__.py +0 -0
  33. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/fixture_http_server.py +0 -0
  34. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/fixture_responses.py +0 -0
  35. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/fixture_server.py +0 -0
  36. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_a1_emit_e2e.py +0 -0
  37. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_a1_proxy.py +0 -0
  38. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_config.py +0 -0
  39. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_emitter.py +0 -0
  40. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_http_bridge.py +0 -0
  41. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_identity.py +0 -0
  42. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_injection.py +0 -0
  43. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_intent_param.py +0 -0
  44. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_iserror_reclassification.py +0 -0
  45. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_llm_text.py +0 -0
  46. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_pending_eviction.py +0 -0
  47. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_proxy_env.py +0 -0
  48. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_residency_sinks.py +0 -0
  49. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_sinks.py +0 -0
  50. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_spec_conformance.py +0 -0
  51. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_surface_snapshot.py +0 -0
  52. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_tool_list_events.py +0 -0
  53. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_tooling.py +0 -0
  54. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/tests/test_try_kit.py +0 -0
  55. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/try/.gitignore +0 -0
  56. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/try/CLAUDE.md +0 -0
  57. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/try/PROMPT.md +0 -0
  58. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/try/SECURITY.md +0 -0
  59. {baton_proxy-0.7.1 → baton_proxy-0.7.2}/uv.lock +0 -0
@@ -0,0 +1,54 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ concurrency:
9
+ group: test-${{ github.ref }}
10
+ cancel-in-progress: true
11
+
12
+ jobs:
13
+ spec-pin:
14
+ # Warns, never fails: a stale pin is how SDKs drift apart unnoticed, but
15
+ # bumping it is its own change with its own vectors to pass. Not on PRs,
16
+ # so the same warning does not sit on every unrelated one.
17
+ if: github.event_name != 'pull_request'
18
+ runs-on: ubuntu-latest
19
+ timeout-minutes: 2
20
+ continue-on-error: true
21
+ steps:
22
+ - uses: actions/checkout@v5
23
+ with:
24
+ persist-credentials: false
25
+ sparse-checkout: .gitmodules
26
+ sparse-checkout-cone-mode: false
27
+ - name: Does the baton-spec pin differ from baton-spec main?
28
+ run: |
29
+ pinned=$(git ls-tree HEAD baton-spec | awk '$1 == "160000" { print $3 }')
30
+ url=$(git config -f .gitmodules submodule.baton-spec.url || true)
31
+ latest=$(timeout 30 git ls-remote "$url" refs/heads/main | awk '$2 == "refs/heads/main" { print $1 }' || true)
32
+ if [ -z "$pinned" ] || [ -z "$latest" ]; then
33
+ echo "::warning title=baton-spec pin not checked::could not read the pin or $url"
34
+ elif [ "$pinned" != "$latest" ]; then
35
+ echo "::warning title=baton-spec pin differs from main::pinned $pinned, baton-spec main is $latest"
36
+ fi
37
+
38
+ test:
39
+ runs-on: ubuntu-latest
40
+ strategy:
41
+ fail-fast: false
42
+ matrix:
43
+ python: ["3.11", "3.12", "3.13", "3.14"]
44
+ steps:
45
+ - uses: actions/checkout@v5
46
+ with:
47
+ submodules: true
48
+ - uses: actions/setup-python@v6
49
+ with:
50
+ python-version: ${{ matrix.python }}
51
+ - run: pip install -e ".[dev,s3]"
52
+ - run: ruff check .
53
+ - run: ruff format --check .
54
+ - run: pytest
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
+ ## [0.7.2] — 2026-11-01
9
+
10
+ ### Changed
11
+
12
+ - The scrubber's patterns use SPEC §7's fixed sets. A digit is `0`–`9`, a word boundary is ASCII, and whitespace is space, tab, LF, CR, FF and `U+00A0`. So `"éjane@example.com"` is now scrubbed, as in `baton-ts`, and a card or phone number in other digits, such as Arabic-Indic, is no longer matched. Any space outside the set, such as a thin space (`U+2009`), an em space or a vertical tab, no longer separates a phone number or a bearer token, so such a value is no longer redacted.
13
+
8
14
  ## [0.7.1] — 2026-10-30
9
15
 
10
16
  ### Added
@@ -858,7 +864,7 @@ Initial public release on PyPI.
858
864
  - Consent guard: refuses to start when an `http(s)://` sink is paired with the placeholder `BATON_CONSENT_TOKEN=local`, or when an `http(s)://` sink is configured without `BATON_API_KEY`.
859
865
  - Fail-open delivery: emission runs on a background thread; Console outage never blocks the MCP pipe.
860
866
 
861
- [Unreleased]: https://github.com/good-timing/baton-proxy/compare/v0.6.11...HEAD
867
+ [Unreleased]: https://github.com/good-timing/baton-proxy/compare/v0.7.1...HEAD
862
868
  [0.6.11]: https://github.com/good-timing/baton-proxy/compare/v0.6.10...v0.6.11
863
869
  [0.1.2]: https://github.com/good-timing/baton-proxy/compare/v0.1.1...v0.1.2
864
870
  [0.1.1]: https://github.com/good-timing/baton-proxy/compare/v0.1.0...v0.1.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: baton-proxy
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: MCP proxy that wraps a stdio server or bridges to a remote one, injects an annotation tool, and emits friction events.
5
5
  Author: Good Timing, Inc.
6
6
  License: Apache License
@@ -7,7 +7,7 @@ handshake, and emits friction events to a collector.
7
7
  See README.md for usage.
8
8
  """
9
9
 
10
- __version__ = "0.7.1"
10
+ __version__ = "0.7.2"
11
11
 
12
12
  # The product/version token, single-sourced here so the emitter's `sdk_version`
13
13
  # field and the HTTP bridge's outbound `User-Agent` header can never drift.
@@ -3,8 +3,8 @@
3
3
  The proxy emits whatever the wrapped MCP server returns — including tool
4
4
  params and results that may carry customer PII (emails in Notion search
5
5
  results, bearer tokens in error bodies, API keys pasted into chat tools).
6
- Persona B's trust pitch is that nothing unscrubbed ever leaves the
7
- customer's machine; this module is what makes that true. Every event
6
+ It is pattern matching, not a guarantee: a name or a street address passes
7
+ through. Every event
8
8
  payload runs through ``Scrubber`` in ``Emitter._enqueue`` before it lands
9
9
  in the queue, so both the local JSONL sink AND any HTTP sink see only
10
10
  scrubbed values.
@@ -21,14 +21,14 @@ scrubbed values.
21
21
  - cc — 13-19 digit candidates filtered by Luhn
22
22
 
23
23
  Plus field-name overrides: any dict key matching
24
- ``{email, phone, ssn, api_key, token, secret, password}`` (case-insensitive)
24
+ ``REDACT_FIELD_NAMES`` (case-insensitive)
25
25
  force-redacts its string value regardless of pattern.
26
26
 
27
27
  Differs from LangSmith's approach (off by default, bring-your-own regex)
28
28
  by shipping rules on by default — the right tradeoff for Persona B's
29
29
  consumer/SMB audience that won't write masking code.
30
30
 
31
- Mirrored in ``baton.scrub`` once the SDK port lands (P1 in the MVP plan).
31
+ baton-sdk's ``baton.scrub`` ships the same patterns; SPEC §7 is the rule for both.
32
32
  """
33
33
 
34
34
  from __future__ import annotations
@@ -53,25 +53,38 @@ REDACT_FIELD_NAMES: frozenset[str] = frozenset(
53
53
  {"email", "phone", "ssn", "api_key", "token", "secret", "password", "user_name"}
54
54
  )
55
55
 
56
+ # SPEC §7's fixed sets: digits are 0-9 and word boundaries are ASCII
57
+ # (re.ASCII), and whitespace is this class, because no runtime's \s matches it.
58
+ # Pinned by the SPEC §7 tests in tests/test_scrub.py.
59
+ _WS_CHARS = " \t\n\r\f\u00a0"
60
+ _WS = f"[{_WS_CHARS}]"
61
+ _PHONE_SEP = f"[{_WS_CHARS}.\\-]"
62
+
56
63
  # Ordered list of (category, pattern). Order matters where patterns can
57
64
  # overlap: JWT must run before bearer because a bare JWT can look
58
65
  # bearer-shaped. sk_key / aws_key run before email because their token
59
66
  # bodies could otherwise match the email local-part regex.
60
67
  _PATTERNS: tuple[tuple[str, re.Pattern[str]], ...] = (
61
- ("jwt", re.compile(r"\beyJ[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\b")),
62
- ("bearer", re.compile(r"\bBearer\s+[A-Za-z0-9_\-.+/=]{16,}", re.IGNORECASE)),
63
- ("sk_key", re.compile(r"\bsk-[A-Za-z0-9_\-]{20,}\b")),
64
- ("aws_key", re.compile(r"\bAKIA[0-9A-Z]{16}\b")),
65
- ("email", re.compile(r"\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b")),
68
+ ("jwt", re.compile(r"\beyJ[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\.[A-Za-z0-9_\-]+\b", re.ASCII)),
69
+ ("bearer", re.compile(rf"\bBearer{_WS}+[A-Za-z0-9_\-.+/=]{{16,}}", re.IGNORECASE | re.ASCII)),
70
+ ("sk_key", re.compile(r"\bsk-[A-Za-z0-9_\-]{20,}\b", re.ASCII)),
71
+ ("aws_key", re.compile(r"\bAKIA[0-9A-Z]{16}\b", re.ASCII)),
72
+ ("email", re.compile(r"\b[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}\b", re.ASCII)),
66
73
  # Phone: optional ``+1``, optional area-code parens, separators
67
- # ``-`` / ``.`` / space, 10 digits. Conservative — won't catch every
74
+ # ``-``, ``.`` or whitespace, 10 digits. Conservative — won't catch every
68
75
  # international format, but won't trip on every 10-digit identifier.
69
- ("phone", re.compile(r"\b(?:\+?1[\s\-.]?)?\(?\d{3}\)?[\s\-.]?\d{3}[\s\-.]?\d{4}\b")),
76
+ (
77
+ "phone",
78
+ re.compile(
79
+ rf"\b(?:\+?1{_PHONE_SEP}?)?\(?\d{{3}}\)?{_PHONE_SEP}?\d{{3}}{_PHONE_SEP}?\d{{4}}\b",
80
+ re.ASCII,
81
+ ),
82
+ ),
70
83
  )
71
84
 
72
85
  # Credit-card candidates — Luhn-filtered before redacting to keep false
73
86
  # positives down on long numeric IDs (timestamps, order numbers).
74
- _CC_CANDIDATE = re.compile(r"\b\d{13,19}\b")
87
+ _CC_CANDIDATE = re.compile(r"\b\d{13,19}\b", re.ASCII)
75
88
 
76
89
 
77
90
  def _luhn_valid(digits: str) -> bool:
@@ -110,6 +110,48 @@ def test_multiple_pii_in_one_string_counts_each() -> None:
110
110
  assert s.counts["phone"] == 1
111
111
 
112
112
 
113
+ # =============================================================================
114
+ # SPEC §7: digits, word boundaries and whitespace are fixed sets
115
+ # =============================================================================
116
+
117
+
118
+ @pytest.mark.parametrize(
119
+ "secret",
120
+ [
121
+ "jane@example.com",
122
+ "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.c2lnbmF0dXJl",
123
+ "sk-abcdefghijklmnopqrstuvwx",
124
+ "AKIAABCDEFGHIJKLMNOP",
125
+ "Bearer abcdefghijklmnop1234",
126
+ ],
127
+ )
128
+ def test_a_word_boundary_is_ascii(secret: str) -> None:
129
+ out = Scrubber()(f"é{secret}é")
130
+ assert secret not in out
131
+ assert out.startswith("é[REDACTED:")
132
+
133
+
134
+ def test_a_digit_is_0_to_9_only() -> None:
135
+ arabic_indic_card = "".join(chr(0x0660 + int(d)) for d in "4111111111111111")
136
+ assert Scrubber()(f"card {arabic_indic_card}") == f"card {arabic_indic_card}"
137
+ arabic_indic_phone = "".join(chr(0x0660 + int(d)) for d in "5551234567")
138
+ assert Scrubber()(f"call {arabic_indic_phone}") == f"call {arabic_indic_phone}"
139
+
140
+
141
+ @pytest.mark.parametrize("space", [" ", "\t", "\n", "\r", "\f", "\u00a0"])
142
+ def test_whitespace_in_the_set_separates(space: str) -> None:
143
+ s = Scrubber()
144
+ assert s(f"call 555{space}123{space}4567") == "call [REDACTED:phone]"
145
+ assert s(f"Bearer{space}abcdefghijklmnop1234") == "[REDACTED:bearer]"
146
+
147
+
148
+ @pytest.mark.parametrize("space", ["\u2009", "\u2003", "\u3000", "\x0b"])
149
+ def test_whitespace_outside_the_set_does_not(space: str) -> None:
150
+ s = Scrubber()
151
+ assert s(f"call 555{space}123{space}4567") == f"call 555{space}123{space}4567"
152
+ assert s(f"Bearer{space}abcdefghijklmnop1234") == f"Bearer{space}abcdefghijklmnop1234"
153
+
154
+
113
155
  # =============================================================================
114
156
  # Field-name override
115
157
  # =============================================================================
@@ -163,7 +163,7 @@ SETUP_URL = "https://baton.goodtiming.ai/setup/proxy"
163
163
  # it equal to `baton_proxy.__version__`. Editing the paste breaks the hash;
164
164
  # re-pinning the hash without bumping the version breaks the pair. The release
165
165
  # then carries a version the console can be updated to and named by.
166
- PASTE_VERSION = "0.7.1"
166
+ PASTE_VERSION = "0.7.2"
167
167
  PASTE_SHA256 = "6e0dbeb917a2ad6bf66aa3cfde69b516664e484b14c6a163af23114e035ad659"
168
168
 
169
169
 
@@ -1,29 +0,0 @@
1
- name: test
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
-
8
- concurrency:
9
- group: test-${{ github.ref }}
10
- cancel-in-progress: true
11
-
12
- jobs:
13
- test:
14
- runs-on: ubuntu-latest
15
- strategy:
16
- fail-fast: false
17
- matrix:
18
- python: ["3.11", "3.12", "3.13", "3.14"]
19
- steps:
20
- - uses: actions/checkout@v5
21
- with:
22
- submodules: true
23
- - uses: actions/setup-python@v6
24
- with:
25
- python-version: ${{ matrix.python }}
26
- - run: pip install -e ".[dev,s3]"
27
- - run: ruff check .
28
- - run: ruff format --check .
29
- - run: pytest
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