Skip to content

fix(memory): explain unpromoted candidates in dreaming reports - #145458

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
migelizaga-rgb:fix/dreaming-rejection-report
Sep 12, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
migelizaga-rgb:fix/dreaming-rejection-report

Conversation

@migelizaga-rgb

@migelizaga-rgb migelizaga-rgb commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #121232

What Problem This Solves

Resolves a problem where operators reading a scheduled deep dreaming report see ranked candidates and zero promotions without an explanation of why promotion rejected them. Mixed outcomes also omit the reasons for candidates that were not promoted.

Why This Change Was Made

The promotion owner now records a fixed rejection category alongside each existing detailed reason. The existing deep report aggregates those categories into one bounded line, such as Not promoted: 2 candidate(s) (consolidation origin/session: 2). This preserves promotion gates, gate order, and existing CLI reason text while keeping rejected snippets, source identifiers, and threshold values out of the new summary.

The summary covers ranked candidates that reach the applier. It does not explain records excluded during ranking, and late revalidation retains a general candidate changed reason. This addresses the diagnostic portion of #121232, not every eligibility concern in that issue. No new storage, configuration, or schema is introduced.

User Impact

Operators can distinguish promotion filters from a lack of candidates and investigate the recorded cause without weakening promotion rules. Empty sweeps continue to avoid creating memory or dreaming files.

Evidence

  • Reproduced through the registered cron hook with a real temporary SQLite recall store and the normal report writer. Before the fix, three regression cases failed specifically because the explanation was missing despite correct ranked/promoted totals.
  • After the fix, all 294 tests across dreaming, promotion, consolidation, markdown reporting, and CLI behavior passed. Coverage includes rejected-only and mixed outcomes, many private candidates, bounded reports, unchanged memory for rejected-only runs, and late concurrent changes.
  • Independent review found no actionable defects in the patch.
  • Validation uses isolated synthetic state. The real scheduled runtime proof below was captured after the fix; no production sweep was forced and the patch has not been deployed in a released runtime.
  • Extension production and test typechecks, formatting, plugin boundaries, and the six doctor contract tests passed. The aggregate changed-file check stopped on existing unused exports in ui/src/pages/new-session/cloud-target.ts: renderCloudConfiguration and renderConnectMachineMenuItem. Running the same scan with this entire patch reversed reproduced the identical failures on base 34cdbaf303542717f5521ef4da504d57e20b644c; the reviewed commit was then restored exactly. These baseline failures are not treated as a passing aggregate check.
  • Targeted extension lint and the remaining storage, media, runtime-sidecar, and import-cycle guards passed when run separately after the aggregate check stopped. A final toSorted() lint correction was followed by another passing run of all 34 dreaming tests and a formatting check.

Real scheduled runtime proof (pre-rebase head, unchanged patch)

On September 12, 2026 at 01:46:00 UTC, the actual Gateway scheduler ran the plugin-managed Memory Dreaming Promotion cron job in an isolated local setup. The supported pnpm openclaw launcher built commit 495e0ca616ecce79cec04c2a7b9cf1985fb8f2bd (OpenClaw 2026.9.4). This was a natural minute-boundary execution, not automations run, a test scheduler, a mocked plugin API, or a direct hook invocation.

Setup: isolated home/config/state/workspace, loopback-only Gateway, no credentials, no channels configured, and delivery mode none. Light, REM, and deep phases stayed enabled with normal promotion thresholds (minimum score 0.75, three recalls, three queries). The only schedule change in this isolated fixture was dreaming.frequency: "* * * * *"; separate phase reports were enabled. A preparation script used the real recall/state owners to seed one synthetic session-corpus candidate with 12 distinct recalls and explicit agent/cron provenance. It did not call promotion or the report writer. The real phases then ingested, repaired, ranked, applied, and wrote the report.

Actual deep report:

# Deep Sleep

- Repaired recall artifacts: rewrote recall store.
- Ranked 1 candidate(s) for durable promotion.
- Promoted 0 candidate(s) into MEMORY.md.
- Not promoted: 1 candidate(s) (consolidation origin/session: 1).

The native automation receipt recorded action: finished, status: ok, completionStatus: succeeded, duration 1016 ms, and deliveryStatus: not-requested. The synthetic MEMORY.md remained byte-for-byte equal to its initial content. The isolated Gateway was stopped after capturing the receipt/report, and its listening port was verified closed.

Limit: narrative generation logged missing-auth fallbacks for light/REM and Async work scope is closed for deep. This is proof of the real scheduled rejection report, not successful LLM narratives, all-green health, or production acceptance. No credentials were added to mask these outcomes.

Data compatibility

This patch does not change a persistent data model: category belongs to the returned rejection diagnostic, not a recall record or SQLite row. The existing store writer still persists latestStore; the rejection objects are constructed separately in the return value. Schema, migrations, table definitions, namespaces, embedding metadata, config shape, and stored-record types are unchanged by the seven-file diff. Existing detailed reason values remain unchanged; CLI JSON gains an additive category field and textual CLI output keeps using reason.

The real run retained schema version 17. Inspecting its 21 stored memory-core values found zero category keys. A consolidated SQLite backup passed the supported read-only database preflight command with status: exact, target/found version 17, no issues, and requiresWrite: false. This verifies the diagnostic does not require a new migration; it does not claim compatibility of unrelated changes between older releases and this checkout.

Prior CI failures outside this patch

CI run 34663155555 evaluated synthetic merge dd81cc424ef4ad8307c1eabddf50c3dfd362e0bd against upstream 6983dd95cb1f8606423df72cfa8819866dad156d; its diff against that upstream parent contains only these seven dreaming files. Three UI checks fail:

  • Dependency check: the two unused cloud-target.ts exports described above; identical failure reproduced with the whole patch reversed to its base.
  • Core lint 4: unchanged where-chip.test.ts has 1020 lines, exceeding 1000. The targeted lint command reproduces the same error locally.
  • UI test shard: unchanged new-session.css has unconditional pointer selector .new-session-page__touch-details. The exact cursor-policy test reproduces it locally.

The relevant UI inputs were not changed by this PR or by the four intervening upstream commits since its original base. The aggregate CI gate is failing; these findings are documented, not waived or counted as passing checks.

Rebase and maintainer follow-up

Rebased onto upstream dda647045420956f7900180c5ca32d457dbc4973, which contains the upstream UI repairs for the preceding CI failures. The contributor patch remained identical through c2e48b8a3bd6fcf9e4b88484934eea6e6e0c90fa; all 295 focused tests and the complete selected changed-file check passed there, including both typecheck lanes, lint, dead-export scans, and storage/import guards.

Current head: 610be988d614c9deaf7b8eaaea981b7dbb4a4068. An independent autoreview found one adjacent classification defect: when the ranked latest recall disappeared before consolidation, the rejection was reported as consolidation origin/session even though its provenance had not failed. The maintainer follow-up now classifies that race as candidate changed. Its regression failed on the prior implementation and passes on this head. The two focused files pass 123 tests, and the native focused review-test gate passes. This changes only returned diagnostics; it does not change promotion eligibility, storage, schema, configuration, or the report bound.

Exact-head hosted CI run 34694214855 completed successfully on 610be988d614c9deaf7b8eaaea981b7dbb4a4068.

The runtime captures remain explicitly attributed to the SHAs that executed them.

Pre-follow-up scheduled proof

Repeated the supported real Gateway flow on c2e48b8a3bd6fcf9e4b88484934eea6e6e0c90fa, reusing the isolated synthetic state created and exercised by the previous build. The scheduler naturally started the run at 2026-09-12T03:53:59.831Z and completed in 798 ms (status: ok, completionStatus: succeeded, deliveryStatus: not-requested). The deep report again recorded 1 ranked, 0 promoted, and 1 consolidation origin/session rejection. MEMORY.md remained byte-for-byte unchanged and the state schema remained 17. The same disclosed narrative fallbacks occurred; the isolated Gateway was stopped after capture. This pre-follow-up runtime proof confirms that the previous build's synthetic state is readable without inventing a migration for the diagnostic field.

ClawSweeper disposition

The exact-head ClawSweeper review found no actionable patch defect and accepted the real behavior proof. Its remaining Add data-model compatibility proof checkbox is skipped as inapplicable because the same review verifies the actual boundary: category exists only on returned rejection diagnostics, while latestStore remains the persisted value and stored recall records are unchanged. The schema-17 inspection, zero persisted category keys, and exact read-only database preflight above provide the relevant compatibility evidence. No migration or unrelated persistence change is warranted.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: memory-core Extension: memory-core size: M labels Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 12, 2026, 9:18 AM ET / 13:18 UTC (Revision 8).

ClawSweeper review

What this changes

Adds bounded rejection-category counts to scheduled memory dreaming reports, with documentation and regression coverage.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open as useful, well-supported work with no actionable patch defects. Current main still lacks the report explanation, and the earlier migration blocker is inapplicable because the new category is returned diagnostic data, not persisted state.

Priority: P2
Reviewed head: 610be988d614c9deaf7b8eaaea981b7dbb4a4068

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable diagnostic repair with real scheduled output, useful regression coverage, and no remaining substantive blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated Gateway scheduler runs exercised the actual promotion owner and report writer, showing the rejection-count line and unchanged MEMORY.md. Runtime evidence remains attributed to the pre-follow-up SHAs; the final diagnostic-only race correction has focused regression coverage, and disclosed narrative failures do not undermine report proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied isolated Gateway scheduler runs exercised the actual promotion owner and report writer, showing the rejection-count line and unchanged MEMORY.md. Runtime evidence remains attributed to the pre-follow-up SHAs; the final diagnostic-only race correction has focused regression coverage, and disclosed narrative failures do not undermine report proof.
Evidence reviewed 9 items Current main still needs the diagnostic: The fetched main revision records ranked and promoted totals, then writes the deep report without consuming rejectedCandidates. Existing verbose logging also does not summarize rejection reasons.
Latest release comparison: The v2026.9.4 source likewise reports the promoted count without a rejection summary; the requested report behavior is not already supplied by that release.
Diagnostic and persistence boundaries: The applier constructs category-bearing rejection objects separately from latestStore. Line 659 still persists latestStore, whose recall-record type has no category field. The existing CLI consumes the result, adding category to JSON while retaining reason-based text output; the helper is not exported through memory-core/api.ts. No migration, new plugin SDK contract, or changed promotion authority is introduced.
Findings None None.
Security None None.

How this fits together

Memory Core's scheduled dreaming process ranks recalled information and applies promotion checks before updating MEMORY.md. Its human-readable reports summarize the results for operators.

flowchart TD
  A[Scheduled dreaming run] --> B[Rank recalled information]
  B --> C[Promotion checks]
  C --> D[Accepted memories]
  D --> E[MEMORY.md]
  C --> F[Rejection categories]
  F --> G[Dreaming report]
  D --> G
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +60, Tests +156, Docs +5. Total +221 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 85 25 +60
Tests 3 157 1 +156
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 247 26 +221

Review metrics

Metric Value Why it matters
Diagnostic contract 12 fixed categories; 1 additive CLI JSON field; 0 stored-record fields added The report remains bounded without introducing a data migration.
Production versus test growth production net +60 lines; tests net +156 lines Production growth supplies typed rejection classification, while tests cover report privacy, mixed outcomes, and changed candidates.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/memory-core/src/short-term-promotion-types.ts, unknown-data-model-change: extensions/memory-core/src/short-term-promotion-apply.ts, vector/embedding metadata: extensions/memory-core/src/short-term-promotion-apply.ts, vector/embedding metadata: extensions/memory-core/src/short-term-promotion-types.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #121232
Summary: This PR addresses the umbrella issue's missing rejection explanations; broader rank/apply eligibility concerns remain separate.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep rejection classification with the promotion owner and expose only aggregate counts through the existing report writer, preserving eligibility rules and stored recall data.

Do we have a high-confidence way to reproduce the issue?

Yes: current main discards available rejection diagnostics when constructing the deep report, so a ranked candidate rejected during apply produces unexplained totals. Source inspection establishes this path; this review did not execute it.

Is this the best way to solve the issue?

Yes: typed categories reuse the existing rejection owner and report writer without parsing detailed reasons or duplicating eligibility policy. The prior migration request does not apply to this returned diagnostic field.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against bce88774daa4.

Labels

Label justifications:

  • P2: This resolves a concrete operator diagnostic gap in scheduled memory promotion without changing promotion policy.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied isolated Gateway scheduler runs exercised the actual promotion owner and report writer, showing the rejection-count line and unchanged MEMORY.md. Runtime evidence remains attributed to the pre-follow-up SHAs; the final diagnostic-only race correction has focused regression coverage, and disclosed narrative failures do not undermine report proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied isolated Gateway scheduler runs exercised the actual promotion owner and report writer, showing the rejection-count line and unchanged MEMORY.md. Runtime evidence remains attributed to the pre-follow-up SHAs; the final diagnostic-only race correction has focused regression coverage, and disclosed narrative failures do not undermine report proof.

Evidence

What I checked:

  • Current main still needs the diagnostic: The fetched main revision records ranked and promoted totals, then writes the deep report without consuming rejectedCandidates. Existing verbose logging also does not summarize rejection reasons. (extensions/memory-core/src/dreaming.ts:650, bce88774daa4)
  • Latest release comparison: The v2026.9.4 source likewise reports the promoted count without a rejection summary; the requested report behavior is not already supplied by that release. (extensions/memory-core/src/dreaming.ts:649, 3a9d69db306c)
  • Diagnostic and persistence boundaries: The applier constructs category-bearing rejection objects separately from latestStore. Line 659 still persists latestStore, whose recall-record type has no category field. The existing CLI consumes the result, adding category to JSON while retaining reason-based text output; the helper is not exported through memory-core/api.ts. No migration, new plugin SDK contract, or changed promotion authority is introduced. (extensions/memory-core/src/short-term-promotion-apply.ts:659, 610be988d614)
  • Bounded report and meaningful regression coverage: The report aggregates fixed categories without candidate text or identifiers. The cron-hook cases cover rejected-only, mixed, and 40-private-candidate outcomes, checking report bounds and MEMORY.md contents. Additional applier coverage checks removed recalls and category classification. These tests were inspected, not executed during this read-only review. (extensions/memory-core/src/dreaming.test.ts:1321, 610be988d614)
  • Real scheduled behavior proof: The supplied PR body, captured under sourceRevision fe82114b0accdffcdff73a732d3aefe34910f3fd9201e6e554db487b9ab2eb3c, includes actual deep-report output from isolated Gateway scheduler runs at 495e0ca616ecce79cec04c2a7b9cf1985fb8f2bd and c2e48b8. The latter recorded one ranked, zero promoted, one consolidation-origin/session rejection, a successful automation receipt, unchanged MEMORY.md, and reused schema-17 state. Disclosed narrative fallbacks limit narrative claims but do not invalidate the observed report output. (c2e48b8a3bd6)
  • Proof continuity through final follow-up: GitHub's exact-head commit patch changes only the missing-recall rejection classification and adds its regression. The scheduled report implementation remains unchanged from the supplied runtime proof. A local historical-blob comparison failed; the read-only GitHub commit response supplied the follow-up patch instead. (extensions/memory-core/src/short-term-promotion-apply.ts:300, 610be988d614)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-12T00:51:22.838Z sha d347dc354c9ad7571fec032efe6748064a6833dc :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-12T00:59:42.754Z sha 495e0ca616ecce79cec04c2a7b9cf1985fb8f2bd :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-12T01:53:43.492Z sha 495e0ca616ecce79cec04c2a7b9cf1985fb8f2bd :: blocked before merge. :: none
  • reviewed 2026-09-12T03:38:43.229Z sha c2e48b8 :: blocked before merge. :: none
  • reviewed 2026-09-12T03:46:25.840Z sha c2e48b8 :: blocked before merge. :: none
  • reviewed 2026-09-12T04:06:31.412Z sha c2e48b8 :: blocked before merge. :: none
  • reviewed 2026-09-12T12:43:35.515Z sha 610be98 :: blocked before merge. :: none

@migelizaga-rgb
migelizaga-rgb marked this pull request as ready for review September 12, 2026 00:54
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 12, 2026
@migelizaga-rgb
migelizaga-rgb force-pushed the fix/dreaming-rejection-report branch from 495e0ca to c2e48b8 Compare September 12, 2026 03:31
@vincentkoc vincentkoc self-assigned this Sep 12, 2026
@vincentkoc

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc merged commit 60e57fb into openclaw:main Sep 12, 2026
172 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…law#145458)

* fix(memory): explain unpromoted candidates in dreaming reports

* fix(memory): use nonmutating report category sorting

* fix(memory): classify removed promotion candidates

---------

Co-authored-by: migelizaga-rgb <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: memory-core Extension: memory-core P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants