Swift text-processing package / 2026 / In progress
RedactionCore.
A Swift engine that swaps sensitive text for placeholders where it sits, and leaves the rest exactly as written
Part of the Omitto journey- Role
- Software engineering
- Built with
- Swift · Foundation · Swift Package Manager · XCTest
01What I built
The problem.
A redacted log is only worth sharing if it still reads like the log. One way to redact a settings file is to read it into the program and write it out again. That can lose the indentation, comments and order of settings that made it useful. And two detectors, the parts that spot secrets, can claim the same stretch of text. Picking the wrong one can leave the value in plain sight.
What I built.
RedactionCore is a Swift package, a bundle of code that apps can build on. It uses only Foundation, Apple’s basic Swift library. It has one call that does the whole job before it returns. Text and a policy go in. The policy says what to look for. Out come the redacted text, the findings with their values hidden, and a report. Inside, detectors suggest stretches of text to hide. Matches from switched-off groups are dropped, and overlapping matches are settled. Each winning match is swapped for a placeholder, a label that stands in for the value. It has no screens and no clipboard. It saves nothing and uses no network. Omitto decides when to run it and supplies the review screen.
The package
Swift, Foundation, Swift Package Manager, XCTest
- Main call
- One call takes text and a policy, does the whole job, then returns the redacted text, the findings and a report.
- Detectors
- Gathers the stretches of text that every detector suggests, and removes repeats.
- Overlap resolver
- Drops disabled groups first. Then it picks winners by priority, by how sure each match is, and by length.The storyStopping a disabled detector from beating an enabled one
- Placeholders
- Gives repeated values one shared placeholder within a call. Different values of the same kind get different numbers.
- Text replacement
- Edits the text from the end backwards, so earlier positions stay correct. It counts positions in UTF-16 units, a standard way of numbering the characters in text.
- Findings
- Each finding says where the match is, what kind it is, and how sure the scan is. It also gives a reason and a preview with the value hidden. It never holds the original value.
02The journey
What broke, and what changed.
Broke, then fixedA decisionA milestone
- 01 of 04Decided
Edit the original text instead of rebuilding it
The questionA redaction tool can read the whole file into the program and write it out again. Or it can change only the stretches of text it found.
What I choseRedactionCore changes only those stretches, in the original text. It works from right to leftRedactionCore · The packageText replacementEdits the text from the end backwards, so earlier positions stay correct. It counts positions in UTF-16 units, a standard way of numbering the characters in text.See it in the map above, so the positions of earlier matches stay correct. Indentation and comments stay, and so do the order of settings and the line endings. How well it finds secrets is a separate question.
- 02 of 04Broke
A disabled detector could beat an enabled one
What went wrongA disabled high-priority detectorRedactionCore · The packageDetectorsGathers the stretches of text that every detector suggests, and removes repeats.See it in the map above could win an overlapping matchRedactionCore · The packageOverlap resolverDrops disabled groups first. Then it picks winners by priority, by how sure each match is, and by length.See it in the map above and then be removed. Nothing was left to replace the value, so it stayed in the text.
What changedMatches from disabled groups are now removed before overlapping matches compete. The enabled detector stays in play and the value is replaced.
- 03 of 04Decided
Placeholders last for one call, not forever
The questionRepeated values should get the same label, so a result is easy to follow. But a table of values and labels kept forever would tie each label to one value across every document.
What I choseEach call starts a fresh set of placeholdersRedactionCore · The packagePlaceholdersGives repeated values one shared placeholder within a call. Different values of the same kind get different numbers.See it in the map above, so repeats share a placeholder inside one result only. If a new placeholder would be the same as the original value, RedactionCore changes it.
- 04 of 04Decided
The reviewer can overrule the automatic scan
The questionAutomatic detection misses some things and flags others it shouldn’t.
What I choseManual phrases are phrases the user adds by hand. They stay active even with every automatic group switched off. A Keep choice leaves that piece of text as it was, without hiding it. Phrases are used for the current call only and are never saved.
03Today
Where it stands.
The July audit shows 57 core tests passing. I cannot give a figure for how much it catches yet. First I need a fixed test set with a version number, checked by someone else. It must hold sensitive examples and ordinary text that should stay unchanged. Partway through a scan, the core does not check whether it was cancelled. So Omitto throws away results that arrive late.