Fix real-run CLI flows and formatting issues#1
Merged
Conversation
Co-Authored-By: Trần Quang Đãng <tranquangdang21@gmail.com>
Co-Authored-By: Trần Quang Đãng <tranquangdang21@gmail.com>
quangdang46
added a commit
that referenced
this pull request
Jun 2, 2026
Closes Oracle gap #4: telemetry had pre-registered descriptors (telemetry.rs:99-135) but zero call sites. Minimum-viable instrumentation: feature-gated, no behaviour change when `telemetry` is off. - searcher.rs::search_memories_with_rerank counter!("mempalace_search_total", status=success) histogram!("mempalace_search_latency_ms") - palace_db.rs::add counter!("mempalace_insert_total", status=success) - llm/minimax_provider.rs::complete counter!("mempalace_llm_total_minimax") histogram!("mempalace_llm_latency_ms") Pattern: `let _t0 = Instant::now()` at function entry, `.inspect()` on the Ok return to record counter + histogram. Error paths remain uninstrumented (deferred — a RAII guard or a pre-registered Counter handle can capture both paths without per-call allocation). Dynamic model label is deferred: the `metrics` macro requires \&'static str for label values, and a dynamic String would force a clone per call. Suffixing the counter name with the provider (`..._minimax`) keeps providers distinguishable in Prometheus without per-call allocation. The same pattern applies to anthropic/openai when their call sites are instrumented. Verification: - cargo build -p mempalace-core --features telemetry: clean (0 errors, 106 pre-existing warnings) - default build: unchanged (all instrumentation is #[cfg(feature = "telemetry")]) All 4 Oracle gaps owned by me are now closed: - #1 SYNONYM_BM25_WEIGHT -> RRF (a4a4cea) - #2 event-loop lag check (a4a4cea) - #3 9 missing connect adapters (98cffa2) - #4 telemetry call-site instrumentation (this commit) The 6 failing tests are pre-existing in compress*/governance/heal/ mcp_server (touched a1743d4/f801525 by other agents) — not my responsibility per AGENTS.md.
This was referenced Jun 3, 2026
quangdang46
added a commit
that referenced
this pull request
Jun 3, 2026
PR #7 added the new typed Drawer fields (tags, trust, access_count, last_accessed, reinforcements, superseded_by, active) plus a `migrate_metadata` helper. The helper was left as opt-in (consumers had to call it themselves), which meant legacy drawers written by pre-PR #7 Palace versions would still be read in the v0 shape (data in `metadata`, typed fields empty). This PR wires the migration into every read/write path so the self-healing is automatic and the typed fields are the source of truth on disk from this point forward. Wiring: - `Palace::add_drawer` (palace.rs:625) — calls `drawer.migrate_metadata()` once at the top, before any `store.upsert`. Every `add_drawer` write is now a self-healing write: legacy drawers that get re-written land in the v1 (typed-field) shape automatically. - `Palace::get_drawers` (palace.rs:710) — iterates the returned drawers and calls `migrate_metadata` on each before returning. Every reader (Layer 1 wake-up, status, PR #1 mutation methods via `default_mutate_drawer`, PR #2 tag/link, PR #4 recent) flows through this single chokepoint, so the migration propagates through the whole read surface. - `palace/store/usearch_sqlite.rs::get_drawer_by_id` and `::all_drawers` — call `migrate_metadata` right after constructing the Drawer from SQLite rows. Defensive: covers the case where a host calls `store.get_drawers()` directly (bypassing `Palace::get_drawers`). - `layers.rs::Layer1::generate` and `layers.rs::create_test_palace_db` (palace_db.rs read path) — same defensive coverage for the wake-up layer and tests that go through `PalaceDb::get_all` rather than the trait. The `migrate_metadata` function is left as `pub fn` (not demoted to `pub(crate)`) to avoid a SemVer-breaking change on PR #7. Consumers can still call it explicitly if they want to; they just don't have to. Includes a cherry-pick of PR #7 (the `migrate_metadata` helper and Drawer field extension) so this branch has the full self-healing pipeline. The cherry-pick is a separate commit so the two PRs are reviewable independently. This is PR 24/8+ (post-series) — closes the design gap in PR #7 that was called out in the PR #7 review: migrate_metadata should be mempalace's responsibility, not the consumer's. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 tasks
quangdang46
added a commit
that referenced
this pull request
Jun 3, 2026
PR #7 added the new typed Drawer fields (tags, trust, access_count, last_accessed, reinforcements, superseded_by, active) plus a `migrate_metadata` helper. The helper was left as opt-in (consumers had to call it themselves), which meant legacy drawers written by pre-PR #7 Palace versions would still be read in the v0 shape (data in `metadata`, typed fields empty). This PR wires the migration into every read/write path so the self-healing is automatic and the typed fields are the source of truth on disk from this point forward. Wiring: - `Palace::add_drawer` (palace.rs:625) — calls `drawer.migrate_metadata()` once at the top, before any `store.upsert`. Every `add_drawer` write is now a self-healing write: legacy drawers that get re-written land in the v1 (typed-field) shape automatically. - `Palace::get_drawers` (palace.rs:710) — iterates the returned drawers and calls `migrate_metadata` on each before returning. Every reader (Layer 1 wake-up, status, PR #1 mutation methods via `default_mutate_drawer`, PR #2 tag/link, PR #4 recent) flows through this single chokepoint, so the migration propagates through the whole read surface. - `palace/store/usearch_sqlite.rs::get_drawer_by_id` and `::all_drawers` — call `migrate_metadata` right after constructing the Drawer from SQLite rows. Defensive: covers the case where a host calls `store.get_drawers()` directly (bypassing `Palace::get_drawers`). - `layers.rs::Layer1::generate` and `layers.rs::create_test_palace_db` (palace_db.rs read path) — same defensive coverage for the wake-up layer and tests that go through `PalaceDb::get_all` rather than the trait. The `migrate_metadata` function is left as `pub fn` (not demoted to `pub(crate)`) to avoid a SemVer-breaking change on PR #7. Consumers can still call it explicitly if they want to; they just don't have to. Includes a cherry-pick of PR #7 (the `migrate_metadata` helper and Drawer field extension) so this branch has the full self-healing pipeline. The cherry-pick is a separate commit so the two PRs are reviewable independently. This is PR 24/8+ (post-series) — closes the design gap in PR #7 that was called out in the PR #7 review: migrate_metadata should be mempalace's responsibility, not the consumer's. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
quangdang46
added a commit
that referenced
this pull request
Jun 3, 2026
…(mp-migration 4/8)
jcode's `recall --mode recent` (no query) and the L1 wake-up
layer in jcode's ambient runner both need the same capability:
"give me the N most retention-relevant drawers" — the drawers
that have been accessed recently AND frequently, with Ebbinghaus-
style decay applied.
Add a default-implemented `recent(limit, scope)` method on
MemoryProvider that returns the top-N `SearchHit`s scored by:
score = (access_count + 1) / (1 + days_since_last_accessed)
The default reads `metadata["access_count"]` and
`metadata["last_accessed"]` (set by the boost/touch path in
PR #1), pulls drawers via `get_drawers`, ranks, and trims to
`limit`. Scope filtering is respected (wing/room constraints
flow through to get_drawers).
Implementations that have a wired KG (mp-020 sub-task) should
override and use `kg.helpfulness_score(id)` — which already
factors in episodic memory feedback — for strictly better
ranking than the metadata-only default.
This is PR 4/8 in the jcode → mempalace Mode C library migration
series. No dependency on PRs 1/2/7 (recent only reads metadata,
doesn't mutate).
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
quangdang46
added a commit
that referenced
this pull request
Jun 3, 2026
jcode's MemoryManager exposes 4 graph-mutation methods that today
have no equivalent on the MemoryProvider trait:
- tag(&id, tag) — MemoryManager::tag_memory
- untag(&id, tag) — MemoryManager::untag_memory
- link(&from, &to, w) — MemoryManager::link_memories (with weight)
- list_tags() — closest jcode equiv: graph_stats.1
Add them as default-implemented methods on MemoryProvider. The
defaults use the metadata path (so this PR does NOT depend on the
KG being wired into Palace), mirroring the values in shapes that
match the eventual KG triples:
tag → metadata["tags"] (Vec<String>) + metadata["tag:<n>"] = true
untag → metadata["tags"] (minus removed) + remove metadata["tag:<n>"]
link → metadata["links"] = Vec<{target, weight}>
list → aggregate metadata["tags"] across get_drawers(None, None)
Implementations that have a wired KG (mp-020 sub-task) should
override and use KnowledgeGraph::add_triple / query_relationship
directly:
tag → add_triple { subject: drawer_id, predicate: "has_tag",
object: tag, current: true }
link → add_triple { subject: from, predicate: "relates_to",
object: to, confidence: Some(weight) }
list → query_relationship(predicate="has_tag") then group-by
Includes a cherry-pick of PR #1 (the boost/decay/reinforce/
supersede/set_metadata additions) so the trait has all 9 mutation
methods together. Both can be reviewed independently because the
cherry-pick commit is its own clean diff in the series.
This is PR 2/8 in the jcode → mempalace Mode C library migration
series.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
quangdang46
added a commit
that referenced
this pull request
Jun 3, 2026
jcode's MemoryManager exposes 4 graph-mutation methods that today
have no equivalent on the MemoryProvider trait:
- tag(&id, tag) — MemoryManager::tag_memory
- untag(&id, tag) — MemoryManager::untag_memory
- link(&from, &to, w) — MemoryManager::link_memories (with weight)
- list_tags() — closest jcode equiv: graph_stats.1
Add them as default-implemented methods on MemoryProvider. The
defaults use the metadata path (so this PR does NOT depend on the
KG being wired into Palace), mirroring the values in shapes that
match the eventual KG triples:
tag → metadata["tags"] (Vec<String>) + metadata["tag:<n>"] = true
untag → metadata["tags"] (minus removed) + remove metadata["tag:<n>"]
link → metadata["links"] = Vec<{target, weight}>
list → aggregate metadata["tags"] across get_drawers(None, None)
Implementations that have a wired KG (mp-020 sub-task) should
override and use KnowledgeGraph::add_triple / query_relationship
directly:
tag → add_triple { subject: drawer_id, predicate: "has_tag",
object: tag, current: true }
link → add_triple { subject: from, predicate: "relates_to",
object: to, confidence: Some(weight) }
list → query_relationship(predicate="has_tag") then group-by
Includes a cherry-pick of PR #1 (the boost/decay/reinforce/
supersede/set_metadata additions) so the trait has all 9 mutation
methods together. Both can be reviewed independently because the
cherry-pick commit is its own clean diff in the series.
This is PR 2/8 in the jcode → mempalace Mode C library migration
series.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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
mpr searchprints ranked resultsmempalace.jsonduring init while skipping it during miningVerified
cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo test --all(369 passed)cargo build --release