Skip to content

fix: port upstream correctness fixes (#1164, #1214, #1215, #1243, #1314)#5

Merged
quangdang46 merged 2 commits into
mainfrom
devin/1778510201-port-upstream-fixes
May 11, 2026
Merged

fix: port upstream correctness fixes (#1164, #1214, #1215, #1243, #1314)#5
quangdang46 merged 2 commits into
mainfrom
devin/1778510201-port-upstream-fixes

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

Summary

Sync the Rust port with upstream milla-jovovich/mempalace HEAD (68319dc). The previous sync ledger point recorded in port.txt was 94f1689, so this PR scans the 335 intervening commits and ports five high-priority correctness fixes that affect data integrity or KG query results.

Each fix carries the upstream issue number in a Rust code comment + a regression test mirroring the upstream test name, so the next sync session can grep for them.

Ported

Upstream Area Fix
#1243 (e9222b4) MCP diary tool_diary_write / tool_diary_read lowercase agent_name so reads are case-insensitive. Writing as Claude and reading as claude no longer silently returns zero rows.
#1214 (0b8c2c1) KG add_triple rejects inverted intervals (valid_to < valid_from) at write time — they would otherwise be invisible to every query and corrupt the store silently.
#1215 (4f36145 + 2e441d1) EntityRegistry save() now writes to a sibling .tmp, fsyncs, renames over the target, and (on Unix) fsyncs the parent directory for ext4-class durability across power loss.
#1164 (4d98b05) MCP boundary New config::sanitize_iso_temporal validates ISO-8601 dates / canonical UTC datetimes for as_of, valid_from, valid_to, ended. Malformed dates now produce a clear MCP error instead of silently returning empty result sets.
#1314 (e4e25ed) MCP KG tools tool_kg_add forwards valid_to and source_file (so historical facts can be backfilled in one call); tool_kg_invalidate resolves an omitted ended to today's date in the response instead of the literal sentinel "today".

Not in scope (explicitly deferred, recorded in port.txt)

  • KG source_drawer_id provenance — requires ALTER TABLE triples migration; tracked for a follow-up PR.
  • Gitignore-aware drawer prune (1d3eecb feat(sync), Python mempalace/sync.py) — larger feature, own PR.
  • LLM-assisted init / --llm-* CLI flags — carried forward from the previous ledger.

Sync infrastructure

  • Added .devin/skills/sync-upstream-mempalace/SKILL.md documenting the upstream-sync procedure (clone, diff against ledger commit, triage priorities, port checklist, gating commands) so future sessions can replay this loop deterministically.
  • Updated port.txt with a new "Sync update — upstream HEAD 68319dc" entry listing what was ported and the updated remaining gaps.

Review & Testing Checklist for Human

  • Verify the diary case-insensitive change is acceptable as a behavior change for existing palaces. Diaries written before this PR under mixed-case agent names (e.g. Claude) will continue to be readable, but only when read with the lowercased name; reading them with the original mixed-case form will now match too because the comparison is case-insensitive. New writes are stored lowercased.
  • Spot-check the KG inverted-interval rejection. Confirm with mempalace_kg_add that valid_from=2026-12-31 valid_to=2026-01-01 is rejected, and that point-in-time facts (valid_from == valid_to) and open intervals (only one bound) still succeed.
  • Confirm EntityRegistry.save durability on your filesystem. On macOS / non-ext4 platforms the parent-dir fsync is a no-op (errors are swallowed), which matches the Python implementation's behavior; on ext4 it is the durability guarantee.
  • Read the new SKILL.md and the appended port.txt entry to confirm the sync procedure and ledger match how you want future sync sessions to work.

Test plan to verify end-to-end:

  1. rustup update stable && cargo build --workspace
  2. cargo test --workspace — expect 424 passed; 0 failed total (17 new regression tests added in this PR).
  3. cargo clippy --workspace --all-targets -- -D warnings — expect clean.
  4. Smoke-test the MCP boundary:
    • mempalace_kg_query with as_of="not-a-date" should return an MCP error.
    • mempalace_kg_invalidate without ended should return a real YYYY-MM-DD value in the response, not the string "today".

Notes

The five fixes touch four files; each fix is locally scoped so the diff stays small. No new dependencies. No schema changes. The new sanitize_iso_temporal lives next to existing Config::* helpers in crates/core/src/config.rs so it's discoverable by other MCP tools that need date validation in the future.

Sync the Rust port with upstream milla-jovovich/mempalace HEAD (68319dc),
porting five high-priority correctness fixes since the previous sync
point 94f1689.

* #1243 — diary tools lowercase agent_name so reads are case-insensitive
* #1214 — KG.add_triple rejects inverted intervals (valid_to < valid_from)
* #1215 — EntityRegistry.save uses atomic write (tmp + fsync + rename +
  parent dir fsync on Unix)
* #1164 — ISO-8601 validation at MCP boundary for as_of, valid_from,
  valid_to, and ended
* #1314 — tool_kg_add forwards valid_to and source_file;
  tool_kg_invalidate resolves omitted ended to today

Also adds .devin/skills/sync-upstream-mempalace/SKILL.md documenting the
sync procedure for future sessions, and updates port.txt with the new
sync ledger entry and remaining gaps.
@quangdang46 quangdang46 merged commit 6eb752c into main May 11, 2026
4 checks passed
@quangdang46 quangdang46 deleted the devin/1778510201-port-upstream-fixes branch May 11, 2026 15: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