feat(palace): add MemoryScope::All and Wing/Room variants (jcode shape) (mp-migration 3/8)#22
Merged
Merged
Conversation
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>
This was referenced Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extend
MemoryScopeenum with 3 jcode-compat variants and 3 helper methods:Motivation
Required for the jcode → mempalace Mode C library migration (mp-migration 3/8). jcode's
MemoryScope::{Project, Global, All}is the canonical enum; withoutAllthe adapter has to callremembertwice (once forLocal, once forGlobal) and merge — error-prone and races with concurrent writes.Wing(String)andRoom { wing, room }cover jcode's per-wing/per-room calls that today are sugar overSearchScopefilters.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 existingMemoryScopeenum from 3 to 6 variants and adds 3 methods.The
Copyderive is removed (newWing(String)andRoom { … }variants can't beCopy);Cloneis 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_globalsemantics:Local,Auto→ only projectGlobal→ only globalAll→ bothWing(_),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 --lib→ 1127 passed, 0 failed (250s)cargo check -p mempalace-corecleancargo fmt --check -p mempalace-corecleanSeries status
🤖 Generated with Claude Code