feat(presidio): decide what happens to unmapped placeholders
Stacked on #1682 (feat/presidio-id-salt-scope) so the pl/zh docs pages line up — please merge #1682 first; this PR's diff then shrinks to its own commit. Closes #1675 together with #1685.
Problem. The restoring instance is the one place that knows which placeholders it could not resolve: a number the model made up, a placeholder a client carried back whose value is not in the request, or one the response phase allocated itself for a value the request never mapped (bob@example.com written in clear becomes <EMAIL_ADDRESS_2>, and nothing restores that — the existing stream test documents exactly this reaching the client). Today every one of them leaves as it is, and an operator has no choice in the matter. A string_replace guard can only guess by pattern.
Closes #1675
Change. New setting unmapped on a restoring presidio instance, for the response phase — reply text and tool-call arguments alike:
allow(default, unchanged): the client sees the placeholder.warn: passes the text, recordsunmapped(codepresidio_unmapped).block: rejects the response withmessage(presidio_unmapped); in a stream as an in-stream error after buffering.replace: swaps every one forunmapped_text(required; empty removes it) — in a stream a placeholder split across deltas is replaced when its window closes.
What counts: a placeholder of this instance's format left after the restore. What does not: the prompt phase (placeholder-shaped text in the prompt is text like any other), a tool in restore_tools_exclude (keeps its placeholders by design). The setting needs restore: true; unmapped_text is only read with replace — both are config errors otherwise.
Tests. Unit: all four modes in text and tool-call arguments, mapped vs unmapped in one reply, Markdown-escaped spelling, keep tools, prompt phase untouched, stream policy and in-flight replace, config errors. e2e through the gateway: default, block with its code, replace with the mapped value still restoring, tool-call arguments, a value the response phase anonymizes anew, streamed block and replace, prompt phase. Docs en/de/pl/zh. Sabotage run: with the decision disabled 8 unit cases fail.
Not in this PR. Nothing else from #1675 — proposals 1 (#1676, merged) and 3 (#1685) cover the rest.
Summary by CodeRabbit
- New Features
- Presidio can now scope hashed placeholder IDs to an individual user path, helping keep identifiers separate between clients.
- Unresolved placeholders in responses can be allowed, logged as warnings, blocked, or replaced with configured text. This also applies to tool-call arguments and streaming responses.
- Documentation
- Expanded configuration guidance on placeholder handling, ID scope, and how changing the scope affects previously created placeholders.