Skip to content

feat(redact): validate predicate + extraSensitiveKeys seam#6

Merged
drewstone merged 1 commit into
mainfrom
feat/redact-validate-and-keys
Jun 4, 2026
Merged

feat(redact): validate predicate + extraSensitiveKeys seam#6
drewstone merged 1 commit into
mainfrom
feat/redact-validate-and-keys

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

Widens @tangle-network/agent-app/redact so a consumer can express its full domain PII scrub as config, not a forked redactor.

  • RedactionPattern.validate?: (match: string) => boolean — a per-pattern predicate; the pattern fires only on a match that passes. Lets a card-number candidate be Luhn-checked, so a Luhn-invalid 16-digit string (e.g. an order id) is left alone. Honored in both redactForIngestion (one-way) and detectSpans (the reversible/UI path).
  • RedactForIngestionOptions.extraSensitiveKeys?: readonly string[] — extra object-key names (case-insensitive) for keys the defaults miss, e.g. snake_case api_key.

Both additive: with no options the output is byte-identical to before. 157 tests pass (+3 covering the Luhn predicate, the invalid-passthrough, and the extra key).

Unblocks deleting the hand-rolled card/key scrubbers in the consumers (they collapse to a single config call).

🤖 Generated with Claude Code

Lets a consumer fully express its domain PII scrub as config instead of a
forked redactor: a per-pattern `validate` predicate (e.g. Luhn over a
card-number candidate, so a Luhn-invalid 16-digit string is left alone) and
`extraSensitiveKeys` for key names the defaults miss (e.g. snake_case
`api_key`). Both additive; no-options behavior is byte-identical.
@drewstone
drewstone merged commit 8ab100b into main Jun 4, 2026
1 check passed
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