mirror of
https://github.com/Pasta-Devs/Marinara-Agents.git
synced 2026-12-03 18:55:07 +07:00
[GH-ISSUE #1534] [Issue]: Long-Term Memory: an extraction fails outright when a dropped unit belongs to a note id with a digit after the prefix #1509
Labels
No labels
agent: chess
agent: conversation-calls
agent: eightball
agent: haptic
agent: hierarchical-maps
agent: hierarchical-maps
agent: illustrator
agent: poker
agent: rock-paper-scissors
agent: tic-tac-toe
agent: uno
artifacts
bug
bugfix
build
catalog
ci
client
dependencies
docs
documentation
enhancement
feature
fixed-in-staging
in-pr
normal-scope
packages
pull-request
qol
regression
roadmap
scope-risk
server
soup
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Agents#1509
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Promansis on GitHub (Oct 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Agents/issues/1534
Originally assigned to: @Promansis on GitHub.
Summary
An extraction can fail outright, and nothing from that source is kept, when a unit belongs to a note whose id has a digit right after the prefix (an older note such as
rel_96dfe1cd8f75, or a new character named "2B",char_2_b), and validation then drops that unit. Removing the prefix leaves96dfe1cd8f75as the unit'ssubjectId. That id is invalid, so when the dropped unit is stored as arecoveryCandidate, the identifier rule rejects the whole draft. This is a cause of #1040 that is still there: the #1040 fix normalizes case and punctuation, not a leading digit.Affected package
long-term-memory1.4.69 (upstream/staging5984f0784).S=packages/long-term-memory/src/engine/packages/server/src/services/long-term-memorySH=packages/long-term-memory/src/engine/packages/shared/src/features/agents/long-term-memoryExpected behavior
subjectIdthat passes the identifier rule and maps back to the same note id.Actual behavior
subjectIdForTarget(S/identity/subject-identity.ts:2555; called at:1356and:1433) removeschar_orrel_and keeps whatever is left.subjectIdForResolvedNoteId(S/extraction/scoped-targets.ts:208) does the same.rel_96dfe1cd8f75, the rest is96dfe1cd8f75. The identifier rule (SH/schema.ts:465-469,^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$) requires a leading letter.relationship_state_missing_caused_by), it is stored asextractionOutcome.droppedCandidates[n].recoveryCandidate. TherecoveryCandidate.subjectIdpreprocess (SH/schema.ts:2209-2222, the #1040 fix) lowercases the id and replaces punctuation, but leaves the leading digit.ltmExtractionDraftSchema.safeParseinS/drafts/draft-store.ts:164fails, so the draft is never written. #1057's debug eventrecovery_subject_id_validation_failedrecords the value.ZodError: extractionOutcome.droppedCandidates[2].recoveryCandidate.subjectId: Identifier must be lowercase snake_case.canonicalNoteIdForEntriesbuildschar_<name slug>, so a character whose name starts with a digit (2B→char_2_b) hits the same failure when its unit is dropped.subjectIdForResolvedNoteIdapplies to every bucket's prefix (timeline_,thread_,world_,tone_,rel_,char_).stripUnitSubjectPrefix,S/extraction/structured-summary-normalizer.ts:1774, vianormalizeTargetShapeUnitandnormalizeUnit). It runs before identity (S/extraction/source-extraction.ts:554) and again insidecompileEvidenceUnitExtraction(S/extraction/evidence-unit-extraction.ts:1506) right before validation, so a fixed identity result is stripped again before the drop. The first pass matters too: identity rejects an untrusted subject with that unit as its recovery candidate.Evidence
Private vault, private PL-1 harness (responses cached, so the run reproduces exactly). 1 of 16 runs failed this way. The vault has one note whose id has a digit after
rel_orchar_: a relationship note from an older version. Only aggregate facts are shared.Steps to reproduce
rel_96dfe1cd8f75, or a new character named "2B" (char_2_b).relationship_state_missing_caused_by).ltmExtractionDraftSchema.safeParsefails withZodError: extractionOutcome.droppedCandidates[2].recoveryCandidate.subjectId: Identifier must be lowercase snake_case, and the debug eventrecovery_subject_id_validation_failedrecords the value. Nothing from that source is kept.Minimal fix
Change only the copy of a dropped unit that becomes its
recoveryCandidate: when itssubjectIddoes not start with a letter, use the full note id (noteIdForEvidenceUnit) instead. Kept units keep the stripped form, because theirsubjectIdfeeds candidate reconciliation's identity key (S/extraction/candidate-reconciliation.ts:278,:291), validation's alias guard (S/extraction/evidence-unit-validation.ts:214) and a warning (:390); changing it there causes duplicates, a guard that fails open and a false warning.S/extraction/evidence-unit-validation.ts,recoveryCandidateForUnit(unit): the unit unchanged when itssubjectIdstarts with a letter, otherwise a copy withsubjectId: noteIdForEvidenceUnit(unit).recoveryCandidate:droppedCandidatein validation,dropLocalCharactersOutsideRoleplayandcloseSourceEventGraphinS/extraction/evidence-unit-extraction.ts, andsubjectRejectioninS/identity/subject-identity.ts(identity rejects an unknown, untrusted or ambiguous subject with the unit as its recovery candidate, before the normalizer's second pass).noteIdForEvidenceUnit(S/extraction/evidence-unit-validation.ts:748) callsprefixed(), which keeps asubjectIdthat already starts withrel_/char_. Sorel_96dfe1cd8f75maps back to itself, and it passes the identifier rule.recoveryCandidate.subjectIdpreprocess alone. Adding a letter there would point the suggestion at a note that doesn't exist.CHANGELOG (user-visible): "An extraction no longer fails as a whole when it leaves out a memory about a note whose id has a digit right after its prefix. This hit older notes with ids such as
rel_96dfe1cd8f75, and new characters whose name starts with a digit, such as "2B". The left-out suggestion couldn't be saved, so nothing from that source was kept. The left-out memory now appears as a rejected suggestion, like any other."Regression proof
Write first; it must fail on the current code.
In
tests/long-term-memory-storage.regression.ts, after the #1040/#1057 cases (:924,:975,:1484), add:rel_<digit…>. A relationship unit resolves to it and is then dropped by validation. Expect the draft to be written, the dropped candidate'srecoveryCandidate.subjectIdto equalrel_<digit…>, and norecovery_subject_id_validation_failedevent.developmentsfact (char_2_b, dropped assource_event_graph_open), and both cases against a structured summary as well as the unstructured source.3_cwith no subject names is rejected by identity, and its recovery copy haschar_3_c. This fails if only identity keeps the old code.rel_<digit…>and creates norel_rel_…note. It passes today.Environment
staging87d1ccadc)upstream/staging5984f0784)Logs, screenshots, or video
The error is quoted under Actual behavior. The failing run used a private vault, so only aggregate facts are shared.
Additional context
Tracker item EX-I12, found during the PL-1 harness run. It is a remaining cause of #1040; #1057 added the
recovery_subject_id_validation_faileddebug event.A separate, pre-existing follow-up: a canonical id whose slug starts with the prefix word loses it. Roster "Char Aznable" gives
char_char_aznable,subjectIdForTargetstrips it tochar_aznable, andprefixed()keeps that, so compile createschar_aznable.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: