Repository navigation
fix(s09): parse frontmatter line-by-line instead of splitting on --- - #664
Open
shuhuNB515 wants to merge 1 commit into
Open
shuhuNB515 wants to merge 1 commit into
shuhuNB515 wants to merge 1 commit into
Conversation
parse_frontmatter had two defects, both silently corrupting persisted
memories:
1. text.split("---", 2) ends the frontmatter at the first "---"
anywhere -- including inside a legal YAML scalar like
'description: prefer uv---pip fallback', which safe_dump writes
unquoted. The value gets truncated and the body picks up residue.
2. startswith("---\n") rejects CRLF files, so every field degrades
to defaults for a file edited with Windows line endings.
Switch to the line-based parser s07 already uses: the closing
delimiter must be a line of its own ("---" stays inside values), and
\r\n is tolerated. s09's error semantics (return {}, text on YAML
errors / non-dict metadata) are preserved, and normal LF files parse
identically. The embedded s09 source in the web registry is synced.
Fixes shareAI-lab#663
This branch has not been deployed
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.
Fixes #663
Problem
parse_frontmatter(s09_memory/code.py:75-88) had two defects, both silently corrupting persisted memory records:text.split("---", 2)ends the frontmatter at the first---anywhere. YAML scalars containing---are legal andyaml.safe_dumpwrites them unquoted — e.g.description: prefer uv---pip fallback. Verified against the real module: the old parser returns{'description': 'prefer uv'}(rest of the value leaks into the body), and the corruption is served back byrebuild_memory_index()on every later turn.startswith("---\n")is false for"---\r\n", so name/type/description all degrade for a file edited with Windows line endings.Fix
Switch to the line-based parser s07 already uses for the identical file format (
s07_skill_loading/code.py:66-88): the closing delimiter must be a line of its own, and\r\nis tolerated. s09's existing error semantics ({}, texton YAML errors / non-dict metadata) are preserved, with a comment explaining the approach.Verification (real module)
description: prefer uv---pip fallback{'description': 'prefer uv'}+ body residue({}, text)python3 -m pytest tests/— 503 passed, 118 subtests passed. Embedded s09 source inweb/src/data/generated/versions.jsonsynced.Disclosed AI assistance: found and fixed during an AI-assisted review; all failure modes reproduced against the real module before and after the change, and I stand behind it.