Repository navigation
feat(dream): add reversible lifecycle observation and maintenance - #2561
Open
Cookie0103 wants to merge 8 commits into
Open
Cookie0103 wants to merge 8 commits into
Cookie0103 wants to merge 8 commits into
Conversation
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.
Description
Dream archive/update/merge actions currently call the graph writer with an incompatible signature, while the maintenance entry point is unimplemented. This proposal repairs those native writes and adds one opt-in lifecycle shared by Dream persistence, final retrieval observation, explicitly affected successful feedback and bounded maintenance.
Related design proposal: #2560. The issue is published; maintainer acceptance and the contribution guide's target branch are pending. The documented bare
devbranch does not exist, so this contribution is provisionally based on currentmain; it can be retargeted to the requested versioned development branch.The initial atomic backend is PostgreSQL. Scoped row-lock reductions, transactional rollback and ordinary-write protection preserve committed lifecycle evidence and protected archive status across stale updates and Context upserts. Retention recomputes from fixed event-time anchors, separates retrieval from attributed usefulness, bounds deduplication by age/capacity, rejects policy reinterpretation/corrupt state, respects pins for passive retention and requires deliberate recovery for invalidated evidence. Original confidence, content and embeddings remain separate from retention state.
Maintenance reads metadata-only keyset pages, revalidates current evidence under locks and publishes scoped/versioned JSON cursors after committed pages. Reports retain bounded decisions/revisions/reasons and exact page retry IDs; dry runs create no state or checkpoint files. Explicit cube registration and optional periodic execution allow quiet cubes to age. Notifications observe detached final results after pipes, preserve the single-provider version hook and report delivery separately from business success. No public route, request/response model, database schema or core dependency is added.
Type of change
Validation
make formatpassed over 644 Python files. Repository pre-commit hooks on changed files passed.make testcannot collect two optional Torch test files in this environment. The identical missing-Torch errors occur on the untouched complete base snapshot.MEMOS_TEST_PG_DSN; the native run above supplied it.Example native test command:
Install the existing tree/scheduler extras and the PostgreSQL backend's documented psycopg2-binary dependency. The DSN must point to a disposable database where tests can create/drop their own schemas. No model API key is needed.
Limits and review context
Notifications are best effort, not a durable outbox or transaction with recall/feedback writes. Only committed observations protect a racing archive. Explicit SDK events need stable producer IDs and original timestamps; automatic observation covers the decorated API search path only. Receipt age/capacity is bounded, and source IDs cannot be recycled into an unlimited exactly-once guarantee. Cooperative limits/shutdown do not forcibly terminate arbitrary blocked backend calls. The current capability is PostgreSQL only; unsupported backends fail clearly when enabled. No improved QA, causal attribution, calibrated confidence or privacy-unlearning claim is made.
AI assistance disclosure: Codex automation produced the implementation, tests, documentation and local checks. Automated self-review and independent automated review are reported separately; the submitting user is not claimed to have personally reviewed or run them. No CLA statement or maintainer approval is asserted.
Contribution checklist
Production Python diff at dc03795: +2,158/-150 physical lines; +1,917/-137 nonblank; +1,765/-85 code-token lines excluding comments/docstrings. Tests +1,398 and Markdown +90 are separate. The caller's actual module scope is reported without padding. No-envelope legacy upsert semantics remain the existing baseline; this change does not certify general tenant isolation for all legacy writer paths. Explicit archive is a deliberate caller operation, including ownership of an already archived target; it is not a passive retention decision.