Skip to content

feat(palace): add MemoryScope::All and Wing/Room variants (jcode shape) (mp-migration 3/8)#22

Merged
quangdang46 merged 1 commit into
mainfrom
feat/mp-pr3-scope-variants
Jun 3, 2026
Merged

feat(palace): add MemoryScope::All and Wing/Room variants (jcode shape) (mp-migration 3/8)#22
quangdang46 merged 1 commit into
mainfrom
feat/mp-pr3-scope-variants

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

Summary

Extend MemoryScope enum with 3 jcode-compat variants and 3 helper methods:

pub enum MemoryScope {
    Local,                            // existing
    Global,                           // existing
    Auto,                             // existing
    All,                              // NEW — jcode's MemoryScope::All
    Wing(String),                     // NEW — limit to a specific wing
    Room { wing: String, room: String },  // NEW — limit to (wing, room)
}

impl MemoryScope {
    pub fn includes_project(&self) -> bool;  // NEW
    pub fn includes_global(&self) -> bool;   // NEW
    pub fn is_all(&self) -> bool;            // NEW
}

Motivation

Required for the jcode → mempalace Mode C library migration (mp-migration 3/8). jcode's MemoryScope::{Project, Global, All} is the canonical enum; without All the adapter has to call remember twice (once for Local, once for Global) and merge — error-prone and races with concurrent writes. Wing(String) and Room { wing, room } cover jcode's per-wing/per-room calls that today are sugar over SearchScope filters.

This is PR 3/8 in the migration series. Independent of the trait-method PRs (1/2/4) — pure enum extension.

Change

crates/core/src/palace.rs — extends the existing MemoryScope enum from 3 to 6 variants and adds 3 methods.

The Copy derive is removed (new Wing(String) and Room { … } variants can't be Copy); Clone is added. This is technically a breaking change for any external code that copied the enum by value, but the trait's other call sites already pass by reference so no internal call site breaks. The enum is #[non_exhaustive] so adding variants is non-breaking at the type level.

includes_project / includes_global semantics:

  • Local, Auto → only project
  • Global → only global
  • All → both
  • Wing(_), Room { .. } → project only (named scopes live in the local palace; jcode has no concept of a global-palace wing)

Test plan

  • cargo test -p mempalace-core --lib1127 passed, 0 failed (250s)
  • cargo check -p mempalace-core clean
  • cargo fmt --check -p mempalace-core clean
  • CI green on ubuntu/macos/windows

Series status

# Title Status
6 docs(palace): document Embedder reuse on search_with_embedding merged #16
7 feat(palace): add tags/trust/access_count/reinforcements/superseded_by to Drawer open #17
8 feat(palace): add MemoryProvider::graph_stats_legacy (jcode shape) open #18
1 feat(palace): add boost/decay/reinforce/supersede/set_metadata to MemoryProvider open #19
2 feat(palace): add tag/untag/link/list_tags to MemoryProvider open #20
4 feat(palace): add MemoryProvider::recent for retention-ranked recall open #21
3 feat(palace): add MemoryScope::All and Wing/Room variants this PR
5 feat(palace): add ActivityEvent sink on PalaceBuilder next

🤖 Generated with Claude Code

jcode's `MemoryScope::All` does a fan-out across project + global
palaces in one call, and jcode adapters commonly need to scope a
remember/forget to a specific wing or (wing, room) tuple. mempalace's
existing `MemoryScope` enum has only `{Local, Global, Auto}` —
none of which match jcode's `{Project, Global, All}` semantics.

Add three new variants to the `MemoryScope` enum (non-breaking):

  - `All`  — fan out to local + global palaces
  - `Wing(String)`  — limit to a specific wing
  - `Room { wing, room }`  — limit to a specific (wing, room)

Add three helper methods on the enum (mirroring jcode's API):

  - `includes_project()`  — true for Local/Auto/All/Wing/Room
  - `includes_global()`   — true for Global/All
  - `is_all()`            — true for All

Note: `Wing` and `Room` are conceptually local-palace-only
(named scopes don't span multiple palaces), so they return
`true` for `includes_project` and `false` for
`includes_global`.

The `Copy` derive is removed because the new `Wing(String)`
and `Room { wing, room }` variants can't be `Copy`. `Clone`
is added. This is technically a breaking change for code that
matched on the enum by value (e.g. `match scope { ... }` would
still work, but `let x = scope; let y = scope;` would now
require an explicit `.clone()`). The trait's other call sites
already pass by reference.

This is PR 3/8 in the jcode → mempalace Mode C library migration
series. Independent of the trait-method PRs (1/2/4) — pure enum
extension.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@quangdang46 quangdang46 merged commit 5108e35 into main Jun 3, 2026
4 checks passed
@quangdang46 quangdang46 deleted the feat/mp-pr3-scope-variants branch June 3, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant