Repository navigation
fix(memory-core): denoise dreaming wrappers and promote grounded REM truths - #71837
vicenteliu wants to merge 3 commits into
Conversation
Greptile SummaryThis PR completes the second half of Dreaming denoise work across three areas: (1) session corpus scaffolding is stripped earlier during text extraction, (2) REM dreaming applies meta-tag and snippet filtering with positive/negative signal biases, and (3) REM candidate truths are fed back into the grounded short-term candidate pipeline to unblock deep promotion. The logic is well-structured and the new test coverage exercises the key filtering and gating scenarios. Confidence Score: 4/5Safe to merge; both findings are non-blocking style and design concerns with no runtime impact. No P0 or P1 issues found. The two P2 findings are a redundant double-normalization call and a hardcoded signal count that may under-differentiate candidate quality, but neither causes incorrect behavior today. Score stays at 4 per P2-only ceiling. extensions/memory-core/src/dreaming-phases.ts (signalCount hardcoding); src/memory-host-sdk/host/session-files.ts and packages/memory-host-sdk/src/host/session-files.ts (double normalization in extractSessionText) Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/memory-host-sdk/host/session-files.ts
Line: 338-341
Comment:
**Redundant double normalization in `extractSessionText`**
`stripSessionScaffolding` already calls `normalizeSessionText` internally before returning, so the `normalizeSessionText(stripped)` call here is redundant. `normalizeSessionText` is idempotent (collapses whitespace + trims), so there's no correctness issue, but the extra call is misleading — it implies `stripSessionScaffolding` returns un-normalized text. The same pattern exists in `packages/memory-host-sdk/src/host/session-files.ts` at the equivalent line.
```suggestion
const stripped = stripSessionScaffolding(rawText, role);
return stripped ? stripped : null;
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-phases.ts
Line: 1853
Comment:
**Hardcoded `signalCount: 3` ignores per-entry confidence**
Every REM candidate is recorded with the same fixed `signalCount: 3` regardless of its computed `calculateCandidateTruthConfidence(entry)` value. A candidate with confidence 0.46 (barely over the 0.45 threshold) receives the same grounded signal boost as one with confidence 0.95. If `recordGroundedShortTermCandidates` uses this count to increment `groundedCount`, weaker candidates gain the same effective weight as strong ones, which could allow marginally-passing truths to clear the deep gate as easily as high-confidence ones. Consider scaling `signalCount` proportionally to the computed score (e.g. `Math.round(1 + score * 2)`) or at least clamping to a lower floor for low-confidence candidates.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(memory-core): denoise dreaming wrapp..." | Re-trigger Greptile |
| if (rawText === null) { | ||
| return null; | ||
| } | ||
| const stripped = stripInboundMetadataForUserRole(rawText, role); | ||
| const stripped = stripSessionScaffolding(rawText, role); |
There was a problem hiding this comment.
Redundant double normalization in
extractSessionText
stripSessionScaffolding already calls normalizeSessionText internally before returning, so the normalizeSessionText(stripped) call here is redundant. normalizeSessionText is idempotent (collapses whitespace + trims), so there's no correctness issue, but the extra call is misleading — it implies stripSessionScaffolding returns un-normalized text. The same pattern exists in packages/memory-host-sdk/src/host/session-files.ts at the equivalent line.
| if (rawText === null) { | |
| return null; | |
| } | |
| const stripped = stripInboundMetadataForUserRole(rawText, role); | |
| const stripped = stripSessionScaffolding(rawText, role); | |
| const stripped = stripSessionScaffolding(rawText, role); | |
| return stripped ? stripped : null; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/memory-host-sdk/host/session-files.ts
Line: 338-341
Comment:
**Redundant double normalization in `extractSessionText`**
`stripSessionScaffolding` already calls `normalizeSessionText` internally before returning, so the `normalizeSessionText(stripped)` call here is redundant. `normalizeSessionText` is idempotent (collapses whitespace + trims), so there's no correctness issue, but the extra call is misleading — it implies `stripSessionScaffolding` returns un-normalized text. The same pattern exists in `packages/memory-host-sdk/src/host/session-files.ts` at the equivalent line.
```suggestion
const stripped = stripSessionScaffolding(rawText, role);
return stripped ? stripped : null;
```
How can I resolve this? If you propose a fix, please make it concise.| endLine: entry.endLine, | ||
| snippet: entry.snippet, | ||
| score: calculateCandidateTruthConfidence(entry), | ||
| signalCount: 3, |
There was a problem hiding this comment.
Hardcoded
signalCount: 3 ignores per-entry confidence
Every REM candidate is recorded with the same fixed signalCount: 3 regardless of its computed calculateCandidateTruthConfidence(entry) value. A candidate with confidence 0.46 (barely over the 0.45 threshold) receives the same grounded signal boost as one with confidence 0.95. If recordGroundedShortTermCandidates uses this count to increment groundedCount, weaker candidates gain the same effective weight as strong ones, which could allow marginally-passing truths to clear the deep gate as easily as high-confidence ones. Consider scaling signalCount proportionally to the computed score (e.g. Math.round(1 + score * 2)) or at least clamping to a lower floor for low-confidence candidates.
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/memory-core/src/dreaming-phases.ts
Line: 1853
Comment:
**Hardcoded `signalCount: 3` ignores per-entry confidence**
Every REM candidate is recorded with the same fixed `signalCount: 3` regardless of its computed `calculateCandidateTruthConfidence(entry)` value. A candidate with confidence 0.46 (barely over the 0.45 threshold) receives the same grounded signal boost as one with confidence 0.95. If `recordGroundedShortTermCandidates` uses this count to increment `groundedCount`, weaker candidates gain the same effective weight as strong ones, which could allow marginally-passing truths to clear the deep gate as easily as high-confidence ones. Consider scaling `signalCount` proportionally to the computed score (e.g. `Math.round(1 + score * 2)`) or at least clamping to a lower floor for low-confidence candidates.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac97488d17
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| query: `__dreaming_rem__:${remDayBucket}`, | ||
| dayBucket: remDayBucket, |
There was a problem hiding this comment.
Use stable REM query IDs for grounded candidate writes
The REM grounding path now writes candidates with a day-suffixed query key (__dreaming_rem__:${remDayBucket}), and recordGroundedShortTermCandidates hashes that query into queryHashes. If the same candidate is selected across multiple days, this creates a new synthetic query hash per day and inflates uniqueQueries/context diversity in rankShortTermPromotionCandidates, so entries can satisfy diversity gates without truly distinct recall contexts. Since deduping is already day-scoped via dayBucket, the query ID should stay stable across days.
Useful? React with 👍 / 👎.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Keep this PR open: current main does not implement the central REM-grounding change, and no merged or safe open replacement supersedes it. The branch is not merge-ready because real behavior proof is missing and the patch changes deep-promotion gates plus persisted grounded state in ways that need repair or explicit maintainer approval. Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. So I’m closing this here because the remaining work is already tracked in the canonical issue. Review detailsBest possible solution: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review. Do we have a high-confidence way to reproduce the issue? Yes for the PR-introduced concerns: source inspection shows phase hits being counted as gate/diversity inputs and REM candidates writing fixed, day-keyed grounded state. I did not live-reproduce the original Dreaming rebuild behavior in this read-only review. Is this the best way to solve the issue? No as submitted. The denoise direction is useful, but gate semantics, REM grounding identity/weight, current-main refresh, and real rebuild proof need repair or explicit approval before this is the best maintainable solution. Security review: Security review cleared: The diff is memory-core TypeScript and tests only; it does not change dependencies, workflows, lockfiles, secrets, packaging, permissions, or external code execution surfaces. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 4fc504d321b6. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
Heads up: this PR needs to be updated against current |
|
This pull request has been automatically marked as stale due to inactivity. |
|
ClawSweeper applied the proposed close for this PR.
|
Summary
This PR finishes the second half of the Dreaming denoise work and unblocks deep promotion.
It does three things:
assistant,report,candidate, etc.) while biasing toward project-grade truthsWhat changed
A. Strip session wrapper pollution earlier
Filtered from session extraction / corpus ingestion:
<relevant-memories>...</relevant-memories>Current time:NO_REPLY/SKIPPEDSystem (untrusted): ...)B. Denoise REM themes and truths
Added REM-side filtering for:
Assistant:/User:transcript linesAdded positive REM bias for project-like signals:
Added negative suppression for engineering-noise terms:
C. Unblock deep promotion
Previously REM could produce better output, but deep still stayed at 0 because the candidate pipeline did not treat REM truths as strong enough promotion signals.
This PR:
Validation
Observed progression during rebuild validation:
assistant/user/reportpassingCount=0topassingCount=3Example passing candidates after the final rebuild included:
gog gmailguardrail decisionTests
Added or updated coverage for:
Notes