Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…andling Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One rerun of the failed job: |
|
Correction to my rerun note above: this PR is not TypeScript-only. It also adds |
Record the redactor's output for the shared card and identifier fixture (direct and through keyed masking), the existing scalar and phone examples, and 400 fixed-seed numeric strings, so a later speed-up has to keep every result the same. Provider-key-shaped inputs are built at runtime instead of written as literals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge-gate review at head 1. A Luhn-valid card that follows a short number is no longer redacted Location: typescript/packages/fi-core/src/trace/trace-config/piiRedaction.ts (CARD_CANDIDATE generic alternative + replaceCard, diff lines ~417-463) Evidence: I ran the real redactPiiInString from head 3c9afcf and from merge-base cb04244 (node --experimental-strip-types; the file has no imports). 'qty 2 4111111111111111': base 'qty <CREDIT_CARD>', head 'qty 2 4111111111111111'. 'item 3 5555555555554444 thanks': base 'item <CREDIT_CARD> thanks', head unchanged. '2 378282246310005': base '<CREDIT_CARD>', head unchanged. '10:30 4111111111111111': base '10:<CREDIT_CARD>', head unchanged. '2026-11-30 4111111111111111': base '2026-11-<CREDIT_CARD>', head unchanged, so a timestamped log line leaks the whole card. Grouped: 'order 12 4111 1111 1111 1111': base 'order <CREDIT_CARD> 1111', head unchanged. Cause: the greedy generic candidate takes the leading short number, so the candidate is longer than one card (for example '2 4111111111111111' or '30 4111111111111111'). That candidate fails the grouping or Luhn check, replaceCard falls back only to a four-group prefix, and String.replace resumes after the whole match, so the card inside is never tried. The body's Behaviour change section says a card-grouped number that passes the check 'is still replaced', and this leak is not disclosed. The untouched Python _redact_credit_cards has the same gap, so parity does not cover it: in TypeScript this is a new false negative. Fix: When a candidate fails the card check, still replace any Luhn-valid, card-grouped 13-19 digit run inside it, for example by re-trying from each later group start or with a scan anchored at each digit-group boundary. Make the same change in the Python redactor so the shared fixture still holds for both SDKs. Add rows to spec/pii-redaction/card-and-ids.json for a short number before a card, both ungrouped ('qty 2 4111111111111111') and grouped ('order 12 4111 1111 1111 1111'), and for a date or time prefix. The piiPrefilterParity snapshot will then need re-recording. 2. International phone numbers without separators are no longer redacted at all Location: typescript/packages/fi-core/src/trace/trace-config/piiRedaction.ts (phone pattern with (?<!WORD) lookbehind, diff lines ~485-489) Evidence: Real redactPiiInString, base cb04244 vs head 3c9afcf: '+447911123456' base '+44<PHONE_NUMBER>', head '+447911123456'. '+919876543210' base '+9<PHONE_NUMBER>', head unchanged. 'call +447911123456 now' base 'call +44<PHONE_NUMBER> now', head unchanged. Base redacted the last 10 digits. Head rejects every start position inside the digit run, so the whole number is exported. The body frames the phone change as 'does not match the tail of a longer identifier'. Dropping real E.164 numbers that the base redacted (all but the country code) is not disclosed. US '+15551234567' is still redacted. Fix: Allow a match to start after a '+' plus country-code digits, or add an E.164 alternative such as +\p{Nd}{7,15} at a word boundary, so non-US international numbers are still redacted. Keep the identifier-suffix exclusion for letter or underscore prefixes. Add fixture rows for '+447911123456' and '+919876543210'. If Python is meant to match, change it the same way. The new parity test is good: the snapshot holds real outputs that would fail on any change. It will need re-recording after these fixes. CI was still running at review time, with nothing failing. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge-gate review at head Both regressions from the last round are fixed in TypeScript and Python. I checked this by running both redactors. A fuzz run of about 28k cases showed TypeScript and Python agree on every case. Two more TypeScript regressions against the merge-base 1. TS: an ungrouped Luhn-valid card right after a serialized \n, \t or \r escape is now exported in full Location: typescript/packages/fi-core/src/trace/trace-config/piiRedaction.ts: CARD_CANDIDATE (lookbehind Evidence: I ran redactPiiInString through node --experimental-strip-types on base cb04244 and on head. Each line shows input, then base output, then head output.
Fix: Add the 2. TS: a plus-prefixed E.164 number followed by a space and another number is no longer redacted at all Location: typescript/packages/fi-core/src/trace/trace-config/piiRedaction.ts: INTERNATIONAL_PHONE trailing guard Evidence: Same harness. Each line shows input, then base output, then head output.
Fix: Let the international match end before a ' ' delimiter, for example by trying the longest valid phone that is followed by a non-word character or by whitespace or punctuation and another number, instead of rejecting outright. Keep the identifier-suffix exclusions ('x' and '_'). Apply the same change in Python and add shared fixture rows for a plus-prefixed number followed by a date, time or short count. Scope for the next push: fix these two, add the fixture rows, and update the snapshot. After that, any further edge case where the base only redacted by accident gets a follow-up issue rather than another round here. The exceptions are a full Luhn-valid card number or a full E.164 number that the base hid and the head exports. |
Summary
With
piiRedactionon, the TypeScript@traceai/fi-corecard-number redaction works the same way as the Pythonfi_instrumentationredaction. One shared fixture,spec/pii-redaction/card-and-ids.json, drives both the Jest and pytest suites, so the two SDKs are checked against the same expected output.<CREDIT_CARD>only when it has a card's length (13 to 19 digits), a card's grouping, and a valid Luhn checksum. Unicode decimal digits (such as full-width digits) count as digits.session.id,user.id,gen_ai.conversation.idandconversation.id, and under their dot-delimited child keys (for exampleuser.id.0), are not scanned for PII. The base64 image cap, explicit hide rules and credential and registered-secret scrubbing still apply to them. Every other key is scanned, includingmetadataand keys that only look similar (for exampleuser.identity_note).Changes
piiRedaction.ts\n,\tor\rescape in serialized JSON is matched.maskingRules.ts:redactValue(config, value, key?)applies the image cap first. It skips the PII pass only for the four correlation key prefixes above. Values with no key (exception text, status description) are scanned.FISpan.tsandexport-privacy.tspass each attribute's key intoredactValue, so the correlation-key rule applies to early native attribute writes and on export.qty 2 4111…,2026-11-30 10:15 4111…,order 12 4111 1111 1111 1111) is still redacted. Long IDs and timestamps that fail the checksum are still kept. The same fix is in the Pythonpii_redaction.py.+(+447911123456,+44 7911 123456) are redacted whole, in both SDKs. Numbers followed by a letter or_(5551234567x,+447911123456_) are still kept, as identifiers.piiCardParity.test.tsand a parametrised pytest case, both driven by the shared fixture.eventPiiRedaction.test.ts.startSpanContext.test.tsexpects an unchanged correlation ID to be bound with PII redaction on, and a session ID rewritten by the image cap to stay unbound.fi-core-typescript-tests.ymlandfi-core-python-compat.ymlalso run on changes underspec/pii-redaction/**, for both push and pull_request.typescript/packages/fi-core/CHANGELOG.md: a Fixed entry under Unreleased.Tests
All cloud runs used a throwaway VM, with networking limited to loopback for the CI-equivalent runs:
TypeScript card and correlation-ID tests (
piiCardParity,eventPiiRedaction, written test-first): 26 of 26 passed.TypeScript PII suites (
piiRedaction,piiQuickCheckSuperset,piiEmailResourceBound,eventPiiRedaction): 109 of 109 passed.startSpanContext.test.ts: 16 of 16 passed.fi-corenode tests against packed OTel SDK 2.0.1 and 2.12.0: 144 of 144 passed on each.fi-semantic-conventionsJest: 124 of 124 passed.Google ADK native tests: 31 of 31 passed. The ADK native privacy wire check (ADK 2.4.0, numeric-pii mode) exited 0.
Python
tests/test_pii_redaction.pyandtests/test_config.py: 128 passed. The full Python core selection: 5712 passed, 25 skipped.The shared fixture
spec/pii-redaction/card-and-ids.jsongains 31 rows for these cases, including date and time prefixes, grouped cards, cards followed by a short number, separated and compact international numbers for four countries, and the identifier-suffix exclusions. The Jest and pytest fixture tests both run them.piiPrefilterParity.test.ts(new): snapshot tests that pin redaction output to this PR's redactor. They cover every row ofspec/pii-redaction/card-and-ids.json, both directly and through keyed masking, the existing scalar and phone examples, and 400 fixed-seed numeric strings with Unicode digits and near-boundary card lengths. The snapshot's original entries are unchanged. The only additions are 31 pairs for the new fixture rows: 22 newly redacted cards or phones, and 9 controls that stay as they were.Full
fi-coreJest on a throwaway VM at the base commit and at this PR's redactor: only timing limits failed, in the two image-cap performance suites. The interleaved A/B below shows those failures are noise (6 of 15 runs on base, 8 of 15 on the PR, medians within ±2.6%). Making those tests stable is tracked in fi-core: image-cap decode performance tests give the same result on every run #807.resourceDetection.test.tsneeds a passwd entry for the container's mapped UID, and passed (5 of 5) once one was provided.On a throwaway VM at this head: full
fi-coreJest 168 of 168 suites (6,067 tests, 13 existing skips, 3 parity snapshots), Python PII tests 159 passed and the Python core selection 5,747 passed (21 existing skips),fi-corenode tests against packed OTel SDK 2.0.1 and 2.12.0 144 of 144 each, andfi-semantic-conventions124 of 124.PR CI is the test of record.
Performance
Interleaved A/B on one idle VM, same Node 22.23.4, 15 runs per side, base
cb04244bvs this PR's redactor (evidence branchevidence/traceai-806-perf-1130@6d04c5a9):The PII rows are from a second interleaved A/B on this head, after the card and phone fixes: base
cb04244b, n=15 per arm, evidenceevidence/traceai-806-card-e164-1130@b7566944. The image-cap rows are from the first A/B.redactPiiInString(piiRedaction.ts:183–194). Long digit runs are real card candidates, so they are checked. The common short ID or counter shape (16 repeats) is +3.6%.evidence/traceai-806-prefilter-1130@3f431152), it gave numeric 1,024 +222.5%, numeric 8,192 +72.7% and many accepted addresses +46.0%. A profile (evidence/traceai-806-emailprof-1130@b1290633) put the extra time in the pre-filter's own length scan.Behaviour change
For users and operators with
piiRedactionenabled in TypeScript:+, are now redacted in both SDKs. Numbers followed by a letter or_are still kept.<CREDIT_CARD>only when its checksum is valid and its grouping looks like a card. Long numeric IDs, millisecond timestamps and similar numbers in exported text that fail the checksum are kept as they are, as in Python. A card-grouped 13 to 19 digit number that passes it is still replaced.session.id,user.id,gen_ai.conversation.id,conversation.idand their dot-delimited child keys skip PII redaction, so values that look like an email address or card number are kept, and session binding uses the original ID. The image cap, explicit hide rules and credential and registered-secret scrubbing still apply to these keys.piiRedactionoff, nothing changes.Linked: none
AI use: Claude Code (Opus) coordinated; a cloud worker wrote the change test-first on a throwaway VM and a review agent checked it.
Docs: none (the fi-core CHANGELOG entry covers it; no public option or API changed)
🤖 Generated with Claude Code