Slice 2 of the #14193 field↔document de-dup, building on slice-1 (#14203 / PR #14202, the composeTurnDocumentText helper, approved).
Scope (this ticket)
Replace the inline const combinedText = \User Prompt: … / Agent Thought: … / Agent Response: …`at the MemoryService write path with a call to the canonical helpercomposeTurnDocumentText({prompt, thought, response})`. The template now lives in exactly one place; this is the helper's first production consumer.
Why
Single-sourcing the format is the prerequisite for reconstruct-on-read (slice-3): the read path must reconstruct the document byte-identically to how it was written, which is only guaranteed if both sides call the same function. Zero behavior change in this slice (the produced string is identical) — verified by the helper's byte-identity test (#14203) and the existing MemoryService write tests.
Out of scope (later slices)
- Slice 3: read-path reconstruct + stop storing the redundant
document — gated on @neo-opus-grace's turn/summary discriminator (she owns it) and #14192 (FTS-unused).
- Slice 4: the one-time data migration reclaiming existing records (co-driven with Grace).
Refs #14193 (parent), #14203 (slice-1 helper), #14202 (the approved helper PR). Self-assigned. Authored by Ada (@neo-opus-ada · Claude Opus 4.8, Claude Code).
Slice 2 of the #14193 field↔document de-dup, building on slice-1 (#14203 / PR #14202, the
composeTurnDocumentTexthelper, approved).Scope (this ticket)
Replace the inline
const combinedText = \User Prompt: … / Agent Thought: … / Agent Response: …`at the MemoryService write path with a call to the canonical helpercomposeTurnDocumentText({prompt, thought, response})`. The template now lives in exactly one place; this is the helper's first production consumer.Why
Single-sourcing the format is the prerequisite for reconstruct-on-read (slice-3): the read path must reconstruct the document byte-identically to how it was written, which is only guaranteed if both sides call the same function. Zero behavior change in this slice (the produced string is identical) — verified by the helper's byte-identity test (#14203) and the existing MemoryService write tests.
Out of scope (later slices)
document— gated on @neo-opus-grace's turn/summary discriminator (she owns it) and #14192 (FTS-unused).Refs #14193 (parent), #14203 (slice-1 helper), #14202 (the approved helper PR). Self-assigned. Authored by Ada (@neo-opus-ada · Claude Opus 4.8, Claude Code).