Memory Defense rejects an oversized Postgres append when redaction changes previously stored text
Nessuno ha ancora preso questa issue.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
On self-hosted Hindsight API 1.3.0 with Postgres, a single oversized append to a JSON conversation failed after we enabled Memory Defense on the bank. The incoming item contained ordinary status notes. The matches that caused the failure were in the already stored conversation.
Our Docker image includes local patches. The relevant merge, screening, splitter and append-guard helpers match stock v1.3.0. Source inspection shows the same mechanism in v1.3.1 and on main at 42f863c. The end-to-end result below is from the patched v1.3.0 deployment.
Steps to reproduce
- On a fresh Postgres-backed bank with document text stored, retain a document with an explicit document ID and
update_mode: "append". Use a JSON array of message objects with synthetic GitHub and Slack bot token-shaped values in one message. Do this before enabling the policy. Our stored body was 324 characters and contained both values. - Set the bank's
memory_defenseconfig to{"enabled": true, "rules": [{"on": "sensitive_data", "action": "redact"}]}. - Submit one async append to the same document ID. Use another nonempty JSON array of message objects, large enough that the incoming item alone exceeds
retain_batch_tokens. Ours contained 220 pairs of status notes and acknowledgments, totaling 97,020 characters.
Observed result
The API accepted the request. The operation finished with status failed and this error:
AppendWouldTruncateDocument: append to canary-c produced a 97,293-char body that does not extend the stored 324-char one; refusing to overwrite it
Afterward the stored document still measured 324 characters and contained both original synthetic values.
Expected result
The append should preserve the stored messages and apply the current policy to incoming content, as a small append does. In the same run, a small append to a different pre-policy document completed. Both sampled old values remained in the document, the new matching value was absent, and a redaction marker appeared.
Cause
On the split path, _iter_raw_sub_batches calls append_document_body(base, incoming) to predict the complete body. iter_sub_batches sends that prediction to _screen_document_body, which calls redact_document_body on it. That changes matching values in the stored portion as well as the tail. Body prediction, screening the prediction, redactor call
On the first slice, retain_batch checks the prediction against the actual stored text. Extending a JSON array moves its closing bracket, so the literal prefix test fails. The guard then compares the original objects with the leading objects in the new array. The redacted string in the first message makes that comparison fail too. Guard call, prefix comparisons
The reported length matches that explanation. For these two arrays the join replaced two brackets with comma-space, giving 324 + 97,020 = 97,344 characters. The 40-character GitHub value became [REDACTED:github_token] (23 characters). The 56-character Slack value became [REDACTED:slack_token] (22). The total reduction was 51 characters, giving the reported 97,293.
In a separate database-free control we called the merge, screen and guard helpers directly. A matching value in the stored body with the policy enabled reproduced the exception. A clean base with the same policy passed, as did the original base with the policy disabled.
Suggested fix
Screen the complete incoming tail before joining it to the stored base. Use that joined body for the override and its sanitized representation for the content hash. Keep the guard against the actual stored document. A split-versus-unsplit test with synthetic matches in both old and new messages could verify that both paths preserve the earlier objects and redact the new match.
Related work
#4229 introduced the guard while addressing #3989. #4436 allowed merged JSON arrays through when the earlier objects are unchanged. In this case redaction changes an earlier object before the comparison.
- Lingua principale
- Python
- Stelle
- 45.2k
- Fork
- 5.9k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di vectorize-io/hindsight
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vectorize-io/hindsight#7254 ·
-
Control Plane shows different calendar dates for the same occurrence in Constellation and TimelineApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
vectorize-io/hindsight#7240 · 1 commento ·
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vectorize-io/hindsight#7233 ·
-
core
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
vectorize-io/hindsight#7231 ·
-
Flaky system test: test_embedding_and_rerank_calls_are_in_request_history raises StopIterationApertacore
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
vectorize-io/hindsight#7228 · 1 commento ·
Tutte le issue di vectorize-io/hindsight
Issue simili
-
Test: to_hijri() accepts datetime.datetime and uses only the date partForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertagood first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 95/100
omarelshamy25x/shamy-hijri#63 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
polish
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresForse già presa @AshutoshSingh840 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
UKGovernmentBEIS/control-arena#992 ·
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
mvalentsev/awesome-free-ai-coding#70 ·
I maintainer di solito rispondono entro 1 giorno