-
Notifications
You must be signed in to change notification settings - Fork 31
feat(core): implement parseMemory with structured section extraction #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
NicholaiVogel
merged 4 commits into
Signet-AI:main
from
Alexi5000:pr/implement-parse-memory
May 23, 2026
+176
−4
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d92a828
feat(core): implement parseMemory with structured section extraction
Alexi5000 4368531
fix(core): tighten memory markdown parsing
NicholaiVogel 6880673
Merge branch 'main' into pr/implement-parse-memory
NicholaiVogel d11eb17
fix(core): ignore manual headings in memory parser
NicholaiVogel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { generateMemory, parseMemory } from "../memory"; | ||
|
|
||
| describe("parseMemory", () => { | ||
| test("parses the generated template as empty structured fields", () => { | ||
| const markdown = generateMemory(); | ||
|
|
||
| expect(parseMemory(markdown)).toEqual({ | ||
| userProfile: "", | ||
| keyFacts: "", | ||
| ongoingContext: "", | ||
| manualNotes: "", | ||
| raw: markdown, | ||
| }); | ||
| }); | ||
|
|
||
| test("extracts populated sections and manual notes without cross-contamination", () => { | ||
| const markdown = `# Memory | ||
|
|
||
| ## User Profile | ||
|
|
||
| Prefers terse updates. | ||
|
|
||
| ## Key Facts | ||
|
|
||
| - Uses Signet locally. | ||
|
|
||
| ## Ongoing Context | ||
|
|
||
| Reviewing parser behavior. | ||
|
|
||
| <!-- MANUAL:START --> | ||
| Keep this hand-written note. | ||
| <!-- MANUAL:END --> | ||
| `; | ||
|
|
||
| expect(parseMemory(markdown)).toEqual({ | ||
| userProfile: "Prefers terse updates.", | ||
| keyFacts: "- Uses Signet locally.", | ||
| ongoingContext: "Reviewing parser behavior.", | ||
| manualNotes: "Keep this hand-written note.", | ||
| raw: markdown, | ||
| }); | ||
| }); | ||
|
|
||
| test("ignores markdown headings inside manual notes when parsing structured sections", () => { | ||
| const markdown = `# Memory | ||
|
|
||
| ## User Profile | ||
|
|
||
| Real profile. | ||
|
|
||
| ## Key Facts | ||
|
|
||
| Real fact. | ||
|
|
||
| ## Ongoing Context | ||
|
|
||
| Real context. | ||
|
|
||
| <!-- MANUAL:START --> | ||
| ## User Profile | ||
|
|
||
| Manual note profile heading. | ||
|
|
||
| ## Key Facts | ||
|
|
||
| Manual note fact heading. | ||
| <!-- MANUAL:END --> | ||
| `; | ||
|
|
||
| expect(parseMemory(markdown)).toEqual({ | ||
| userProfile: "Real profile.", | ||
| keyFacts: "Real fact.", | ||
| ongoingContext: "Real context.", | ||
| manualNotes: "## User Profile\n\nManual note profile heading.\n\n## Key Facts\n\nManual note fact heading.", | ||
| raw: markdown, | ||
| }); | ||
| }); | ||
|
|
||
| test("preserves raw markdown for round trips", () => { | ||
| const markdown = "# Memory\n\n## Key Facts\n\n- one\n"; | ||
|
|
||
| expect(parseMemory(markdown).raw).toBe(markdown); | ||
| }); | ||
| }); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual-note content is still parsed for
##headings afterMANUAL:START. BecausecurrentSectionis set to null but there is noinManualBlockguard untilMANUAL:END, a user note like## User Profile\nmanual textinside the manual block will be captured intosections["User Profile"]and can overwrite the real generated section. That violates the stated separation betweenmanualNotesand the structured fields, and it can corrupt parsed memory data for perfectly reasonable markdown notes. The parser should skip all section parsing while inside the manual block.