Skip to content

Add M-Pesa transaction code protection for Kenya and Tanzania - #1681

Merged
maziyarpanahi merged 3 commits into
masterfrom
feature/om-859-mpesa-transaction-code-recognizer
Jul 22, 2026
Merged

maziyarpanahi merged 3 commits into
masterfrom
feature/om-859-mpesa-transaction-code-recognizer

Conversation

@maziyarpanahi

@maziyarpanahi maziyarpanahi commented Jul 18, 2026 •

Copy link
Copy Markdown
Owner

Description

Adds strict, context-gated detection for ten-character M-Pesa confirmation codes in Kenyan, Tanzanian, and Swahili billing text. Valid detected codes receive deterministic, validator-safe surrogates that preserve the leading date-encoding character and referential integrity without retaining the original transaction identifier.

Closes #1436.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Test addition/improvement

Changes Made

  • Added the transaction-code validator and context-gated locale patterns for sw, en_KE, and en_TZ.
  • Added a seeded surrogate provider, runtime dispatch, label normalization, and provider-registry aliases for Kenya and Tanzania.
  • Added synthetic English and Swahili receipt fixtures covering positive matches, hard negatives, repeated codes, and zero-leakage replacement.
  • Rebased onto current master without replacing the existing East African ID and phone locale overlays.
  • Restored end-to-end fixture validation through the real Kenya and Tanzania locale routes now supported by current master.

Testing

  • I have added tests that prove this feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this change with different contexts and inputs

Validation completed on the rebased branch:

  • .venv/bin/python -m pytest tests/ -q — 6,670 passed, 47 skipped
  • Focused validator/provider/receipt regression set — 137 passed
  • make format, make lint, make format-check, and make type-check
  • Scoped pre-commit hooks, including Ruff, Bandit, hardcoded-secret detection, and merge-conflict detection
  • /usr/local/bin/python3 -m build — wheel and source distribution built successfully
  • git diff --check

Documentation

  • I have added docstrings to new functions/classes
  • No user-facing documentation or changelog update is required for this scoped detector addition

Code Quality

  • I ran make format, make lint, and make format-check
  • I have performed a self-review of my own code
  • I have commented the format-preservation behavior where needed
  • My changes generate no new warnings
  • No dependencies were added

Dependencies

  • I have not added any new dependencies

Checklist

  • I have read the contributing guidelines
  • My commits have clear, descriptive messages
  • My commits are organized around this issue only

Related Issues

Closes #1436

Screenshots/Examples

The committed synthetic fixtures cover English and Swahili confirmation lines, ungated specimen/batch hard negatives, and repeated-code receipt copies.

@maziyarpanahi maziyarpanahi added roadmap-v2 OpenMed V2 roadmap backlog feature New capability P1 High labels Jul 18, 2026
@maziyarpanahi
maziyarpanahi force-pushed the feature/om-859-mpesa-transaction-code-recognizer branch from b2194ca to 5c7b483 Compare July 22, 2026 20:06
@maziyarpanahi

Copy link
Copy Markdown
Owner Author

Rebased onto the latest master and integrated the M-Pesa provider without displacing the existing East African ID or phone locale overlays. I also restored the end-to-end receipt test to the real Kenya/Tanzania locale routes now supported on master. The full local suite passes (6,670 passed, 47 skipped), all quality/build gates pass, every commit is owner-linked and verified, and the fresh hosted matrix is green on exact head 5c7b483. Ready to merge—thank you!

@maziyarpanahi
maziyarpanahi merged commit 9a31ba3 into master Jul 22, 2026
21 checks passed
@maziyarpanahi
maziyarpanahi deleted the feature/om-859-mpesa-transaction-code-recognizer branch July 22, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability P1 High roadmap-v2 OpenMed V2 roadmap backlog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add M-Pesa transaction code recognizer and surrogate generator for Kenya and Tanzania billing text

1 participant