Skip to content

fix(memory-core): downgrade cleanup warning to debug when missing operator.admin scope#68087

Closed
nightq wants to merge 1 commit into
openclaw:mainfrom
nightq:fix/issue-68074-memory-core-cleanup-warn
Closed

fix(memory-core): downgrade cleanup warning to debug when missing operator.admin scope#68087
nightq wants to merge 1 commit into
openclaw:mainfrom
nightq:fix/issue-68074-memory-core-cleanup-warn

Conversation

@nightq

@nightq nightq commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Summary

The memory-core plugin's dreaming feature generates a warning log every 4 hours when narrative session cleanup fails due to missing operator.admin scope. This is expected behavior since the dreaming cron runs in the main session which lacks this scope.

Root Cause

The subagent.deleteSession() method requires operator.admin permission, but the dreaming cron job runs in the main session which does not have this scope. The cleanup is best-effort and the core dreaming/promotion functionality still works correctly.

Fix

When deleteSession() fails with "missing scope: operator.admin", log at debug level instead of warn since this is expected behavior. Other cleanup failures still log at warn level.

Changes

  • dreaming-narrative.ts: Check error message for 'missing scope: operator.admin' and use logger.debug instead of logger.warn
  • dreaming-narrative.test.ts: Add test coverage for the new behavior and add debug mock to createMockLogger

Test Plan

  • Unit tests pass (43 tests in dreaming-narrative.test.ts)
  • New test verifies debug logging for missing scope error
  • New test verifies warn logging is NOT called for missing scope error

Closes #68074

…rator.admin scope

Fixes openclaw#68074

Root cause: The dreaming cron job runs in the main session which lacks operator.admin scope, causing narrative session cleanup to fail with a warning log every 4 hours.
Fix: When deleteSession() fails due to missing operator.admin scope, log at debug level instead of warn since this is expected behavior and cleanup is best-effort.

Changes:
- dreaming-narrative.ts: Check error message for 'missing scope: operator.admin' and use logger.debug instead of logger.warn
- dreaming-narrative.test.ts: Add test coverage for the new behavior and add debug mock to createMockLogger
@greptile-apps

greptile-apps Bot commented Apr 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Downgrade the deleteSession cleanup error from warn to debug when the dreaming cron fails with "missing scope: operator.admin", since this is expected behavior in the main session. The fix is well-scoped with matching unit test coverage for both the new debug path and the existing warn path for other errors.

Confidence Score: 5/5

Safe to merge — the change is a targeted log-level adjustment for expected behavior with full test coverage.

No P0/P1 findings. The string-matching approach is a minor pragmatic trade-off in a catch block, and the regression direction (if the message ever changes) is toward more logging rather than silently suppressing warnings. All paths are covered by existing and new tests.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(memory-core): downgrade cleanup warn..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e52c21807

ℹ️ 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".

// Missing operator.admin scope is expected when running in main session;
// treat as best-effort cleanup and log at debug level only.
if (errMsg.includes("missing scope: operator.admin")) {
params.logger.debug(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard optional debug logger call during cleanup

PluginLogger.debug is optional in this codebase, but this new branch calls params.logger.debug(...) unconditionally. In environments/tests that provide only info/warn/error, hitting the expected "missing scope: operator.admin" cleanup error will throw a TypeError from inside finally, turning a best-effort cleanup path into a hard failure for generateAndAppendDreamNarrative and potentially aborting the parent dreaming flow.

Useful? React with 👍 / 👎.

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group ultimate-chow-4ei0

Title: Open PR duplicate: [Bug]: memory-core: narrative session cleanup fails with "missing scope: operator.admin"

Number Title
#68020 fix(memory-core): silence expected operator.admin scope miss in dreaming cleanup
#68087* fix(memory-core): downgrade cleanup warning to debug when missing operator.admin scope
#68130 fix: reduce log level for narrative session cleanup scope failures
#68312 fix(memory-core): downgrade narrative cleanup WARN to debug for missing-scope errors
#68681 fix(memory-core): suppress expected dreaming cleanup scope warnings

* This PR

@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

Close #68087 as duplicate/superseded. Current main has not merged this PR's log-level branch, but the same memory-core dreaming cleanup warning is already tracked by the canonical open maintainer/member PR #68020, and this contributor PR has an unresolved implementation risk around logger.debug. The underlying gateway contract still matches the PR's root cause: sessions.delete is admin-scoped and fallback plugin subagent deletion intentionally does not mint operator.admin.

Best possible solution:

Close this duplicate contributor PR and keep the remaining memory-core cleanup-warning fix on the canonical maintainer-owned #68020/#68252 path, preserving the existing security invariant that fallback background plugin calls do not receive operator.admin. A final fix should either guard optional debug/no-warn logging at the memory-core call site or introduce a narrower owned-session cleanup API if maintainers decide to solve orphan cleanup directly.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against d54d2d6b9b8a.

@clawsweeper clawsweeper Bot closed this Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-core: narrative session cleanup fails with "missing scope: operator.admin"

1 participant