zara-memory: isolate expected provenance from backend mutation during write verification #130

Closed
opened 2026-09-08 02:03:02 +00:00 by nsaspy · 0 comments
Owner

Problem

MemoryService.remember() currently creates expected_provenance = dict(provenance) and passes that exact mutable object to the backend. A backend that mutates the provenance mapping in place can therefore mutate the value later used as expected write evidence. The subsequent equality check can false-green a rewritten provenance payload.

Nested mutable provenance values can create the same aliasing problem with shallow copies.

Required behavior

  • capture backend-independent expected provenance before dispatch;
  • pass a separate deep copy to the backend;
  • reject backend in-place mutation/rewrite of top-level or nested provenance;
  • retain deterministic structured MemoryError write-evidence failure;
  • no backend/network requirement in tests;
  • full registry/plugin/Nix compatibility gates remain green.

Tracks the provenance/write-evidence portion of #7.

## Problem `MemoryService.remember()` currently creates `expected_provenance = dict(provenance)` and passes that exact mutable object to the backend. A backend that mutates the provenance mapping in place can therefore mutate the value later used as expected write evidence. The subsequent equality check can false-green a rewritten provenance payload. Nested mutable provenance values can create the same aliasing problem with shallow copies. ## Required behavior - capture backend-independent expected provenance before dispatch; - pass a separate deep copy to the backend; - reject backend in-place mutation/rewrite of top-level or nested provenance; - retain deterministic structured `MemoryError` write-evidence failure; - no backend/network requirement in tests; - full registry/plugin/Nix compatibility gates remain green. Tracks the provenance/write-evidence portion of #7.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nsaspy/zara-plugins#130
No description provided.