Implements the engine side of the redaction-policy schema change proposed in philterd/phisql#31: an optional color on each filter strategy that sets the PDF/image redaction bar color for spans that strategy redacts.
Blocked by philterd/phisql#31. Do not start until that RFC is accepted and the change lands in redaction-policy schema 1.2.0 (an additive, backward-compatible edit in place of the current schema version). The schema leads; Phileas follows, and the Phileas conformance test enforces that the engine implements everything the embedded schema declares.
Behavior to implement
- A strategy may carry an optional
color. When rendering a redacted PDF or image, the bar over a span uses the color of the strategy that redacted it, if set; otherwise config.pdf.redactionColor; otherwise black. Exactly one strategy applies per span, so the color is unambiguous.
- Supported values: named colors
black, white, red, orange, yellow, green, blue, gray, or a 6-digit hex string #RRGGBB. Any unrecognized or malformed value renders as black.
- The same set + fallback apply to the existing
config.pdf.redactionColor and graphical.boundingBoxes[].color, which already share the COLORS table in PdfRedactor.
- No effect on text redaction: string output is unchanged.
Implementation notes (current code)
src/main/java/ai/philterd/phileas/services/strategies/AbstractFilterStrategy.java holds the shared strategy fields (redactionFormat, maskCharacter, ...). Add color here so every strategy, including DateFilterStrategy, inherits it.
src/main/java/ai/philterd/phileas/services/pdf/PdfRedactor.java:
- The static
COLORS map currently holds only white, black, red, yellow and does not parse hex, so blue, orange, green, gray, and any #RRGGBB currently fall back to black. Expand it to the 8 named colors and add 6-digit hex parsing, keeping the getOrDefault(..., black) fallback.
- Fix the pre-existing scale bug in the
yellow entry ({1, 1, 100 / 255F} mixes 0-1 and 0-255 component scales, while red uses {255, 0, 0}). Make the named-color RGB values use one consistent component scale.
- Thread the redacting strategy's
color onto each RedactedRectangle so the per-span bar (around lines 247-261) uses it instead of always config.pdf.getRedactionColor().
- Embed the updated
1.2.0 schema (now including color) and update the conformance test.
Acceptance criteria
Implements the engine side of the redaction-policy schema change proposed in philterd/phisql#31: an optional
coloron each filter strategy that sets the PDF/image redaction bar color for spans that strategy redacts.Blocked by philterd/phisql#31. Do not start until that RFC is accepted and the change lands in redaction-policy schema
1.2.0(an additive, backward-compatible edit in place of the current schema version). The schema leads; Phileas follows, and the Phileas conformance test enforces that the engine implements everything the embedded schema declares.Behavior to implement
color. When rendering a redacted PDF or image, the bar over a span uses the color of the strategy that redacted it, if set; otherwiseconfig.pdf.redactionColor; otherwiseblack. Exactly one strategy applies per span, so the color is unambiguous.black,white,red,orange,yellow,green,blue,gray, or a 6-digit hex string#RRGGBB. Any unrecognized or malformed value renders asblack.config.pdf.redactionColorandgraphical.boundingBoxes[].color, which already share theCOLORStable inPdfRedactor.Implementation notes (current code)
src/main/java/ai/philterd/phileas/services/strategies/AbstractFilterStrategy.javaholds the shared strategy fields (redactionFormat,maskCharacter, ...). Addcolorhere so every strategy, includingDateFilterStrategy, inherits it.src/main/java/ai/philterd/phileas/services/pdf/PdfRedactor.java:COLORSmap currently holds onlywhite,black,red,yellowand does not parse hex, soblue,orange,green,gray, and any#RRGGBBcurrently fall back to black. Expand it to the 8 named colors and add 6-digit hex parsing, keeping thegetOrDefault(..., black)fallback.yellowentry ({1, 1, 100 / 255F}mixes 0-1 and 0-255 component scales, whilereduses{255, 0, 0}). Make the named-color RGB values use one consistent component scale.coloronto eachRedactedRectangleso the per-span bar (around lines 247-261) uses it instead of alwaysconfig.pdf.getRedactionColor().1.2.0schema (now includingcolor) and update the conformance test.Acceptance criteria
AbstractFilterStrategyexposes an optionalcolor(getter/setter,@SerializedName("color")), inherited by all strategies including date.PdfRedactordraws each span's bar in its redacting strategy'scolorwhen set, elseconfig.pdf.redactionColor, elseblack.COLORSsupports all 8 named colors and 6-digit#RRGGBBhex; unrecognized or malformed values fall back toblack.yellownamed-color RGB scale bug is fixed and all named colors use a consistent component scale.config.pdf.redactionColorandgraphical.boundingBoxes[].coloralso resolve against the expanded set (shared table).colorset.1.2.0(the revision that addscolor) and the conformance test passes.PdfRedactorTestcovers per-strategy color, the named palette, 6-digit hex, and black fallback for an unknown value.docs/docs/is updated for the new strategy property and the supported-color set.