Repository navigation
fix(memory): the memory fences use the shared neutralization - #392
Merged
Merged
Conversation
The persisted memory document and the memory curator's evidence blocks neutralize their text with the shared function, so the text cannot carry the fence tag or the id in any written form. A text without a token gives the same prompt as before. A test refuses a fence that neutralizes by hand.
…-the-shared-neutralization # Conflicts: # docs/UPSTREAM_COMPATIBILITY_LEDGER.md
…e a closing tag A file that writes a fence tag must call the shared neutralization or a builder that does; importing it is not enough. A tag with the id in its name counts as a fence tag. Removing a closing tag with replace or replaceAll is refused like split and join.
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.
Summary
The persisted-memory document and the memory curator's three evidence blocks now neutralize their text with the shared
neutralizeFence, so text inside them cannot open or close the block, however the tag or the id is written. A guard test refuses new private copies.What changed
lib/memory/prompt.tsfenceMemory:neutralizeFence(content, nonce, ["memory-document"]); the nonce is still derived from the original content.modules/memory/memory.curator.tsfenced:neutralizeFence(content, nonce, [the three labels]); the<label-UUID>format and the system prompt are unchanged.src/__tests__/promptFenceUse.test.ts: no hand-made neutralization outsidelib/promptFence.ts; every file that writes a nonce tag for a prompt reaches the shared function.Why
One implementation of the neutralization for every fence. The chat engine, the training prompts and the playbook prompts already use the shared function; these two fences had their own.
Testing
New tests through
buildMemoryTurnandrunMemoryCuratorScopebyte-for-byte equality with the old output for text without a token, cache stability of the memory document, cross-label checks for the curator, the guard with samples. Targeted suites,npm run build,npm run typecheck:testpass. Mutants (old split/join in either file, own label only, a private copy) are caught.Deploy notes
No migration or configuration. Prompts for text without a reserved token are unchanged byte for byte, so provider prefix caches are not affected. Text that contains a reserved tag now shows
<in place of its<. Cost per call, measured on a shared, loaded host: tens of microseconds for a memory document of ordinary size and 0.2 to 2 ms at its largest size (16,384 units; about 5 ms for the slowest text built); 1 to 7 ms for a curator block at its largest size (48,000 units). A text that starts with a reserved name (for instance<existing-memory-notes>) is neutralized too.