Implement fail-safe fallback and PII redaction on guard failures - #1821
Merged
fderuiter merged 1 commit intoAug 8, 2026
Conversation
Contributor
Author
|
[CI/CD Fix Attempt 1] Cause of FailureThe upstream
Fix Implemented
|
fderuiter
deleted the
jules/fail-safe-regex-redaction-js0-3bd2d3d3-9911-48da-a422-63a6cb0f576d
branch
August 8, 2026 02:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why:
When text extraction from LLM responses fails, the
@guarddecorator previously returned raw payloads. This silent failure mechanism bypassed downstream schema validations and global PII/PHI redaction filters, creating a significant risk of leaking unredacted patient data and violating HIPAA compliance.To eliminate this vulnerability, we have introduced a robust, fail-safe fallback mechanism. Our architecture enforces a strict distinction based on the execution mode:
fail-fastmode: Prioritizes absolute data safety by immediately halting the workflow and raising a validation exception, ensuring unvalidated clinical data never enters downstream databases.warningmode: Facilitates safe system monitoring and debugging by stringifying the unrecognized payload, applying high-performance regex-based redaction for sensitive identifiers (SSNs, emails, phone numbers, dates), and returning the safe string.Key Decisions & Rationale:
.sig) generated via the workspace signing key. This guarantees the integrity of the audit trail for compliance verification.ValueErrorduringextract_text) is treated as a security event, triggering immediate interception before any logging or output returning occurs.What:
@guardDecorator (promptops/promptops/guard.py):ValueError.fail_fastBehavior: Intercepts failures, records a signed audit log, and raisesProomptsValidationError.warningBehavior: Converts raw payloads to standard strings, runs regex redaction targeting SSNs, emails, phone numbers, and dates, writes a signed audit log, and returns the sanitized string.get_signing_key()andget_workspace_audit_dir()to write companion.json(payload state) and.sig(HMAC signature) files to the workspace audit trail on failure.tests/test_guard.py):fail_fast.warning.