Skip to content

fix(flow): prevent task placeholder rewriting and pin short-value binding (#2130) - #2170

Open
yunusarda-sudo wants to merge 2 commits into
OpenAdaptAI:mainfrom
yunusarda-sudo:fix/privacy-task-placeholder-rewrite
Open

yunusarda-sudo wants to merge 2 commits into
OpenAdaptAI:mainfrom
yunusarda-sudo:fix/privacy-task-placeholder-rewrite

Conversation

@yunusarda-sudo

Copy link
Copy Markdown
Contributor

Summary

In openadapt_flow/privacy.py:bind_text, bound values were replaced sequentially in descending length order using individual regex substitutions. Because ⟦ and . are non-word characters, a short value that also appears as a word within placeholder syntax (for example "task" in ⟦task.identity_1⟧) matched inside previously inserted placeholders, corrupting them into nested structures like ⟦⟦task.kind⟧.identity_1⟧.

Changes

  1. Single-Pass Placeholder Binding (bind_text):
    • Construct a single regex pattern that matches existing placeholder tokens (\u27e6[^\u27e6\u27e7]*\u27e7) or whole-word value branches sorted by length descending.
    • Any already-present placeholder span is emitted unmodified.
    • Matched values are substituted via dictionary lookup in a single pass without re-scanning or corrupting inserted placeholders.
  2. Tests:
    • Added test_task_value_cannot_rewrite_another_placeholder verifying that short values such as "task" cannot rewrite placeholder names.
    • Added test_bind_text_preserves_preexisting_placeholders ensuring pre-existing placeholders in text remain untouched.
    • Added test_short_value_overbinding_in_task_text_is_pinned pinning the intended privacy trade-off where values under 3 characters (e.g. "M") bind every whole-word occurrence in task text to prevent raw PHI transmission to the model.

Closes #2130.

Signed-off-by: Yunus Ardaguney yunusarda-sudo@users.noreply.github.com

…ding (OpenAdaptAI#2130)

Signed-off-by: Yunus Ardaguney <yunusarda-sudo@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

flow privacy: task placeholder binding edge cases (placeholder rewrite, short-value over-binding)

1 participant