Skip to content

fix: keep private memory out of shared sessions by default - #99225

Closed
steipete wants to merge 1 commit into
mainfrom
codex/memory-privacy-boundary
Closed

steipete wants to merge 1 commit into
mainfrom
codex/memory-privacy-boundary

Conversation

@steipete

@steipete steipete commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Closes #84466

What Problem This Solves

Fixes a privacy boundary bug where shared group, channel, scheduled, or delegated team-operation sessions could receive private long-term workspace memory by default when their session key or persisted metadata looked like a private/direct session.

Why This Change Was Made

The change centralizes the long-term memory default policy around canonical session classification and persisted policy stamps, then routes bootstrap loading, memory tools, transcript rotation, compaction, ACP/MCP/plugin tool contexts, scheduled/continuation runs, media/context-engine paths, and memory promotion through that boundary.

Private/direct agent use keeps the documented default include behavior. Shared surfaces default to explicit-only memory unless they reach an allowed on-demand path.

Non-goals: no new config knob, no version/release/changelog change, and no UI or visual changes.

Owner review: this is security/privacy-sensitive session and memory behavior; please include the normal security/privacy and session-state owner review before taking it out of draft.

User Impact

Private long-term memory is no longer injected into shared/group/channel/team-operation sessions by default.

Shared transcripts keep their restrictive stamp through reset, compaction, continuation, tool inventory/invocation, MCP attach lifecycle, and scheduled/operator reconstruction paths. A later private/direct turn rotates to a fresh private transcript instead of mixing private memory into an explicit-only transcript.

Direct/private sessions retain the existing documented behavior, including default long-term memory inclusion and explicit on-demand memory interactions where allowed.

Evidence

  • Local focused final-head proof on fb16e9a: ACP initialization/runtime handle regressions plus gateway MCP regressions passed.
  • Local generated/docs/type proof on final head: config baseline, plugin SDK API baseline, plugin SDK exports, plugin SDK surface report, docs map, docs MDX, docs formatting, prompt snapshots, plugin SDK declaration build, and diff whitespace checks all passed.
  • Fresh local autoreview at extra-high reasoning against origin/main: clean, no accepted/actionable findings.
  • Remote Testbox-through-Crabbox proof: tbx_01kwj8v6twg1ebjgnpq7cx1hk7, provider blacksmith-testbox, exact branch ref codex/memory-privacy-boundary, remote HEAD fb16e9a. Passed 11 Vitest shards plus generated/docs/type checks, prompt snapshots, plugin SDK declaration build, and diff whitespace checks. Actions run: https://github.com/openclaw/openclaw/actions/runs/28620033391

AI-assisted under maintainer direction.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime extensions: llm-task Extension: llm-task extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb scripts Repository scripts commands Command implementations agents Agent runtime and tooling extensions: acpx extensions: memory-wiki extensions: codex extensions: copilot size: XL maintainer Maintainer-authored PR labels Jul 2, 2026
@clawsweeper

clawsweeper Bot commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 2:15 PM ET / 18:15 UTC.

ClawSweeper review

What this changes

Centralizes long-term-memory defaults around session scope so private workspace memory is not automatically injected into shared group, channel, delegated, scheduled, and provider-runtime sessions.

Merge readiness

⛔ Blocked until real behavior proof is added - 12 items remain

Keep this draft, maintainer-protected PR open. Current main demonstrably violates the documented shared-session memory boundary, but the proposed context-engine opt-in would silently disable existing third-party engines in shared sessions unless maintainers explicitly accept and document that upgrade break; the supplied PR evidence also lacks direct redacted runtime proof, and this checkout cannot inspect the PR head or the required sibling Codex source.

Priority: P1
Reviewed head: f9ef9c8492f0281b8d235f541235df5dc618638b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The PR has a source-proven target bug but remains unready because of a P1 plugin-upgrade blocker, missing direct behavior proof, and unavailable exact-head/Codex contract inspection.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: The PR body supplies test and Testbox claims, but the reviewed discussion contains no redacted after-fix direct-versus-shared channel transcript, terminal output, recording, or runtime log that demonstrates the privacy boundary. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body supplies test and Testbox claims, but the reviewed discussion contains no redacted after-fix direct-versus-shared channel transcript, terminal output, recording, or runtime log that demonstrates the privacy boundary. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main defect: The workspace loader always reads MEMORY.md, and the only session filtering excludes files for subagent and cron keys; ordinary group/channel sessions therefore retain MEMORY.md, contradicting the documented Discord contract.
Bootstrap call path: The bootstrap resolver applies filterBootstrapFilesForSession to the loaded workspace files, making the current filter the owner boundary for normal model bootstrap context.
Documented user contract: Current docs state that MEMORY.md only auto-loads in Discord DM sessions and that guild channels should use on-demand memory tools instead.
Findings 1 actionable finding [P1] Avoid silently disabling existing context engines
Security Needs attention Legacy context engines lose shared-session execution: The proposed supportsSharedSessionScope opt-in treats engines without the new field as private-only and bypasses them in shared sessions, changing installed plugin behavior without a demonstrated migration, warning, or approved compatibility contract.

How this fits together

Workspace bootstrap files feed agent harnesses, context engines, plugins, and provider runtimes before each model turn. Session classification and persisted session metadata determine whether private long-term memory may enter that turn, including after continuation or transcript reuse.

flowchart LR
  A[Channel or scheduled turn] --> B[Session key and chat metadata]
  B --> C[Session memory policy]
  C --> D[Bootstrap and memory tools]
  C --> E[Context engines and plugins]
  C --> F[Provider thread runtime]
  D --> G[Model context]
  E --> G
  F --> G
  G --> H[Shared or private response]
Loading

Decision needed

Question Recommendation
Should existing context engines that lack supportsSharedSessionScope be bypassed in shared sessions immediately, or should OpenClaw preserve them under a compatible restrictive-scope contract while plugin authors migrate? Fail closed with an explicit migration: Keep shared sessions restricted by default, but require a documented compatibility version, a visible warning or doctor guidance, and tests proving the behavior for pre-existing engines.

Why: This is a privacy-default decision with a direct upgrade consequence for external plugins; source review cannot determine whether maintainers accept losing existing shared-session engine behavior as the safer default.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body supplies test and Testbox claims, but the reviewed discussion contains no redacted after-fix direct-versus-shared channel transcript, terminal output, recording, or runtime log that demonstrates the privacy boundary. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Avoid silently disabling existing context engines (P1) - This new opt-in makes every existing engine private-only; the accompanying text says the host bypasses engines that omit it in group or channel sessions. Current engines are registered without this field, so an upgrade can silently remove their context behavior. Preserve a compatible restrictive path or make the fail-closed break versioned, visible, and explicitly approved.
  • Resolve security concern: Legacy context engines lose shared-session execution - The proposed supportsSharedSessionScope opt-in treats engines without the new field as private-only and bypasses them in shared sessions, changing installed plugin behavior without a demonstrated migration, warning, or approved compatibility contract.
  • Resolve merge risk (P1) - Existing third-party context engines omit the new shared-session opt-in, so the proposed fail-closed behavior can silently remove their group/channel context after upgrade.
  • Resolve merge risk (P1) - The PR changes persisted session-policy and transcript-reuse behavior; maintainers need an explicit decision on fail-closed migration semantics and visible operator diagnostics.
  • Resolve merge risk (P1) - The supplied PR body reports tests and remote validation but does not provide redacted direct-versus-shared after-fix runtime evidence.
  • Resolve merge risk (P1) - The local checkout cannot verify the exact PR head or the Codex app-server contract because the PR object and sibling Codex source are unavailable and GitHub DNS failed.
  • Complete next step (P2) - A protected, security-sensitive PR needs maintainer resolution of the legacy plugin compatibility boundary and contributor-supplied runtime proof; this is not a safe automated repair lane.
  • Improve patch quality - Add redacted direct-versus-shared Telegram or Discord proof showing a private memory fact is not automatically available in a shared session.
  • Improve patch quality - Resolve the legacy context-engine migration decision and add focused coverage for an engine that omits the new flag.
  • Improve patch quality - Provide an exact-head Codex app-server contract check or make the required sibling Codex source available for review.

Findings

  • [P1] Avoid silently disabling existing context engines — docs/concepts/context-engine.md:131
  • [medium] Legacy context engines lose shared-session execution — docs/concepts/context-engine.md:131
Agent review details

Security

Needs attention: The privacy goal is sound, but the new context-engine gate is a security-boundary upgrade decision that can silently alter installed plugin behavior.

Review metrics

Metric Value Why it matters
Context-engine API 1 new shared-session capability flag Existing plugin context engines do not declare it, so the new default can change their behavior on upgrade.

Stored data model

Persistent data-model change detected: database schema: extensions/codex/src/app-server/side-question.test.ts, database schema: extensions/copilot/harness.ts, serialized state: extensions/codex/src/app-server/attempt-context.test.ts, serialized state: extensions/codex/src/app-server/session-binding.ts, serialized state: src/hooks/bundled/session-memory/handler.test.ts, serialized state: src/hooks/bundled/session-memory/handler.ts, and 15 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #84466
Summary: This PR is the explicit candidate repair for the documented Discord shared-memory exposure; the issue remains canonical until a reviewed fix merges.

Members:

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

Mantis proof suggestion

A Telegram Desktop proof can directly compare direct-session availability of a redacted memory fact with its absence from a group-session bootstrap. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: verify with redacted evidence that a private MEMORY.md fact remains available in a direct chat but is not automatically exposed in a group chat.

Merge-risk options

Maintainer options:

  1. Resolve the legacy context-engine upgrade path (recommended)
    Before merge, make the new shared-session capability gate an explicitly approved and documented compatibility transition, with coverage for an existing engine that omits the field.
  2. Accept immediate fail-closed behavior
    Maintainers may intentionally accept bypassing legacy shared-session engines only after confirming that the privacy gain outweighs the operator-visible loss of custom context behavior.
  3. Pause the broad branch
    Pause this PR if the required provider, context-engine, and persisted-session migration contract cannot be proven as one coherent change.

Technical review

Best possible solution:

Keep one canonical session-memory policy, but make the context-engine transition an explicit, versioned compatibility decision: either preserve existing engines while they receive restrictive scope inputs, or fail closed with a documented upgrade path, diagnostics, and focused direct/shared regression coverage before merge.

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

Yes, from current source: loadWorkspaceBootstrapFiles includes MEMORY.md, while filterBootstrapFilesForSession filters only cron and subagent sessions, so a normal group/channel bootstrap keeps the file despite the documented contract.

Is this the best way to solve the issue?

Unclear — centralizing the decision at the session-memory boundary is the right direction, but immediately bypassing legacy context engines without an approved migration or compatibility contract is not the best complete solution.

Full review comments:

  • [P1] Avoid silently disabling existing context engines — docs/concepts/context-engine.md:131
    This new opt-in makes every existing engine private-only; the accompanying text says the host bypasses engines that omit it in group or channel sessions. Current engines are registered without this field, so an upgrade can silently remove their context behavior. Preserve a compatible restrictive path or make the fail-closed break versioned, visible, and explicitly approved.
    Confidence: 0.91

Overall correctness: patch is incorrect
Overall confidence: 0.84

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ac5cdddb2c54.

Labels

Label justifications:

  • P1: The PR addresses a documented privacy leak that can expose private workspace memory to shared conversations.
  • merge-risk: 🚨 compatibility: A new context-engine capability gate can bypass already-installed plugin engines that lack the field.
  • merge-risk: 🚨 session-state: The branch persists memory-policy state and rotates or invalidates transcripts when that policy changes.
  • merge-risk: 🚨 security-boundary: The branch controls whether private long-term memory enters shared sessions by default.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies test and Testbox claims, but the reviewed discussion contains no redacted after-fix direct-versus-shared channel transcript, terminal output, recording, or runtime log that demonstrates the privacy boundary. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The shared-versus-direct memory behavior is visible in Telegram and can be proved with a short redacted native Desktop recording.

Evidence

Security concerns:

  • [medium] Legacy context engines lose shared-session execution — docs/concepts/context-engine.md:131
    The proposed supportsSharedSessionScope opt-in treats engines without the new field as private-only and bypasses them in shared sessions, changing installed plugin behavior without a demonstrated migration, warning, or approved compatibility contract.
    Confidence: 0.91

What I checked:

  • Current-main defect: The workspace loader always reads MEMORY.md, and the only session filtering excludes files for subagent and cron keys; ordinary group/channel sessions therefore retain MEMORY.md, contradicting the documented Discord contract. (src/agents/workspace.ts:973, ac5cdddb2c54)
  • Bootstrap call path: The bootstrap resolver applies filterBootstrapFilesForSession to the loaded workspace files, making the current filter the owner boundary for normal model bootstrap context. (src/agents/bootstrap-files.ts:218, ac5cdddb2c54)
  • Documented user contract: Current docs state that MEMORY.md only auto-loads in Discord DM sessions and that guild channels should use on-demand memory tools instead. Public docs: docs/channels/discord.md. (docs/channels/discord.md:289, ac5cdddb2c54)
  • Plugin compatibility regression in the proposed branch: The supplied PR diff adds supportsSharedSessionScope; its accompanying documentation says engines that omit it are bypassed in shared sessions. Existing context engines registered under the current contract lack this field, so an upgrade can silently remove their context behavior. Public docs: docs/concepts/context-engine.md. (docs/concepts/context-engine.md:131, f9ef9c8492f0)
  • Current context-engine contract: Current public documentation registers a context engine without any shared-session capability declaration, establishing that existing plugin engines do not provide the new opt-in metadata. Public docs: docs/concepts/context-engine.md. (docs/concepts/context-engine.md:126, ac5cdddb2c54)
  • History and ownership provenance: Current-main blame attributes both the documented Discord boundary and the workspace bootstrap implementation to the current shallow-root commit; provided related-item context also identifies merged PR https://github.com/openclaw/openclaw/pull/99816 as adjacent trusted session-scope work by steipete. (src/agents/workspace.ts:945, 27c04ecac489)

Likely related people:

  • steipete: Current-main blame identifies Peter Steinberger on the documented and bootstrap surfaces, and the provided related history shows steipete authored the merged trusted-scope repair in https://github.com/openclaw/openclaw/pull/99816. (role: current contract contributor and adjacent session-scope author; confidence: medium; commits: 27c04ecac489, 23b878a04b0b; files: src/agents/workspace.ts, docs/channels/discord.md, src/sessions/session-chat-type-shared.ts)

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 (4 earlier review cycles)
  • reviewed 2026-07-02T20:57:18.392Z sha fb16e9a :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T16:28:15.484Z sha f9ef9c8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-04T16:35:53.757Z sha f9ef9c8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-30T20:18:04.595Z sha f9ef9c8 :: needs real behavior proof before merge. :: none

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 2, 2026
@steipete
steipete force-pushed the codex/memory-privacy-boundary branch from fb16e9a to f9ef9c8 Compare July 4, 2026 16:20
@steipete

steipete commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (post #99816/#99817 and the soft-resume work).

Textual conflicts (15 files) were mostly both-sides-added import/code anchors, resolved keep-both; plus regenerated config/plugin-SDK baselines and the 7 prompt-snapshot fixtures (pnpm prompt:snapshots:gen), and surface-report budgets set to main plus this branch's export delta.

Semantic reconciliation with main's soft-resume CLI-session contract (the interesting part):

  • This branch's memory-boundary invalidation in resolveCliSessionReuse now returns a proper discriminated result (mode: "invalidate") and a first-class reason: new "memory-policy" member on CliSessionInvalidatedReason and the raw-transcript reseed union, instead of overloading main's "system-prompt" (which main now treats as soft drift / reuse-with-drift). A memory-boundary flip stays a hard invalidation — drift-resume would carry previously injected private memory across the boundary.
  • Main's soft-resume tests that hand-build shared-scope (group) CLI session bindings now stamp longTermMemoryDefaultPolicy: "explicit-only": unstamped legacy shared bindings are deliberately invalidated once by this PR's fail-closed rule, which is the intended upgrade behavior, so post-upgrade fixtures must carry the stamp.
  • Branch tests updated to main's reuse-result shapes ({mode: "reuse", ...}), and a duplicated diagnostic-events import block from the auto-merge in src/gateway/server-methods/agent.test.ts was deduped.

Local proof on head f9ef9c8: pnpm tsgo clean; all 131 test files touched by this PR — 5,334 tests passing (the earlier 9 failures were the semantic drifts above, all repaired and re-verified).

Remaining before merge per prior review: rerun/repair the Mantis Telegram Desktop proof workflow on this head, redacted live Discord/Telegram shared-channel proof, and security/privacy + session-state owner review. The upgrade behavior (existing shared sessions rotate transcripts and lose default MEMORY.md injection on first post-upgrade turn) still needs an explicit owner decision on release-notes handling.

@clawsweeper clawsweeper Bot removed the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 4, 2026
@clawsweeper clawsweeper Bot added the rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. label Jul 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Thanks, Peter Steinberger (@steipete). Your authorship and credit for identifying the shared-memory privacy issue are preserved in the focused landing.

The owner-boundary repair landed via #119198 at d06fc25. This draft is being closed because its uneditable, conflicted 273-file branch includes much broader context-engine and session-policy work, while the landed diff intentionally differs by narrowing the scope to the bootstrap privacy boundary.

The focused landing closed #84466.

@vincentkoc vincentkoc closed this Aug 4, 2026
@RomneyDa
RomneyDa deleted the codex/memory-privacy-boundary branch October 22, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui channel: discord Channel integration: discord channel: telegram Channel integration: telegram commands Command implementations docs Improvements or additions to documentation extensions: acpx extensions: codex extensions: copilot extensions: llm-task Extension: llm-task extensions: memory-core Extension: memory-core extensions: memory-lancedb Extension: memory-lancedb extensions: memory-wiki gateway Gateway runtime maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MEMORY.md loads in Discord guild channels despite documentation stating otherwise

2 participants