Skip to content

fix(pinky_memory): coerce legacy invalid reflection type on row read - #976

Open
ziomik wants to merge 2 commits into
bradbrok:mainfrom
ziomik:fix/reflection-type-hydrate-fallback
Open

fix(pinky_memory): coerce legacy invalid reflection type on row read#976
ziomik wants to merge 2 commits into
bradbrok:mainfrom
ziomik:fix/reflection-type-hydrate-fallback

Conversation

@ziomik

@ziomik ziomik commented Aug 2, 2026

Copy link
Copy Markdown

Follow-up to #965. That fix only guarded the write path (reflect()), defaulting an unrecognized type to fact instead of raising. Any row already stored with a since-retired/renamed type value (e.g. session_log, episode, nav_audit — dream-run hallucinations from before #965 landed) still crashed ReflectionType(row["type"]) on every hydration, aborting recall/introspect and dream post-processing (link building, orphan pruning) whenever that row was touched.

Confirmed live in production: seo-pro's dream run failed tonight with 'session_log' is not a valid ReflectionType — after the dream report itself completed successfully — because a legacy poisoned row from April got read back during post-processing. Same pattern found in satoshi's own memory.db (4 rows with type=episode).

Moves the coercion into a shared coerce_reflection_type() in types.py, used by both the write path (server.py) and row hydration (store.py::_row_to_reflection). Adds a regression test that poisons a stored row's type directly via SQL and confirms recall still returns it (coerced to fact) instead of crashing.

Tested: full pinky_memory suite (65/65) + full repo suite (689 passed, 1 skipped) green in an isolated worktree.

Fixer and others added 2 commits August 1, 2026 07:06
…of crashing

Dream runs occasionally call reflect() with a plausible-sounding but
invalid type (observed: 'session_log'), which raised an unhandled
ValueError from ReflectionType() and aborted the entire dream run
rather than just failing that one memory write.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
reflect()'s existing fallback (invalid type -> 'fact') only guarded the
write path. Any row already stored with a since-retired/renamed type
(e.g. 'session_log', 'episode', 'nav_audit' from before that fix
landed) still crashed ReflectionType(row["type"]) on every hydration,
aborting recall/introspect and dream post-processing (prune/link)
whenever that row was touched — confirmed live against seo-pro's and
satoshi's own memory.db.

Moves the fallback into a shared coerce_reflection_type() in types.py,
used by both the write path (server.py) and row hydration (store.py).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant