Conversation
- replace JSON-string-bound condensed output with a shared delimiter-framed contract - parse literal summary text deterministically with CRLF normalization and complete outer-fence handling - fail closed on partial, duplicate, out-of-order, unterminated, or malformed framed output - preserve valid legacy JSON responses as a backward-compatible fallback - add regressions for quotes, backslashes, Windows paths, multiline text, Markdown fences, JSON-like content, and malformed legacy JSON
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.
What & why
This follows the framed output approach suggested in the issue. Condensed memory is now returned through a shared delimiter contract instead of being embedded inside a JSON string, so literal quotes, backslashes, Windows paths, multiline text, Markdown, and JSON-like fragments no longer depend on correct JSON escaping.
The parser handles framed responses deterministically, normalizes CRLF input, accepts a complete outer code fence, and fails closed on partial, duplicated, out-of-order, unterminated, contaminated, or malformed frames. Valid legacy JSON responses remain supported as a backward-compatible fallback.
This change is intentionally scoped to the structured-output failure described in Memory condensation aborts ~80% of the time: the payload has to survive JSON string escaping #459. Existing load, spawn, timeout, invocation failure, backup, verification, and atomic swap behavior remains unchanged.
Closes #459.
Type of change
Evidence
Before
Using the same framed summary fixture on the pre-fix implementation,
parseSummary()returnsnull.The fixture contains a Windows path, quoted text, a literal backslash, Markdown, and an incomplete JSON-like fragment. These are representative of the content that previously depended on surviving JSON string escaping.
After
Using the same fixture after this change,
parseSummary()preserves the literal condensed text and extracts the expectedhoistentry.The condensed payload no longer needs to be encoded as a JSON string, while malformed framed output still fails closed.
Focused regression coverage also passes all 7 cases.
How I tested it
The issue's production evidence came from an 18-day agent run. Since this change is isolated to the deterministic
parseSummary()boundary, the regression is reproduced directly in PowerShell with the same representative output shape rather than requiring another multi-day soak run.OS: Windows 11
Steps:
I also ran:
The new
reflect-summarycoverage passes in the focused suite. The full focused suite still contains existing Windows/platform-sensitive failures around symlink permissions, transcript HOME handling, and other unrelated baseline cases.The same framed fixture was used for the Before and After evidence. The pre-fix parser returns
null; after the change, the same input returns the expectedcondensedandhoistvalues.Regression coverage includes:
resultandtextenvelopesChecklist
npm run typecheckpasses.npm run test:focusedpasses.npm run buildsucceeds.DESIGN.md/tokens.tswith no ad-hoc colors, spacing, or fonts.ATTRIBUTION.md.