Skip to content

feat(adapters): SME adapter for the Go MemPalace server (sefodo26)#255

Merged
jphein merged 1 commit into
mainfrom
feat/mempalace-server-adapter
Jul 4, 2026
Merged

feat(adapters): SME adapter for the Go MemPalace server (sefodo26)#255
jphein merged 1 commit into
mainfrom
feat/mempalace-server-adapter

Conversation

@jphein

@jphein jphein commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Contract adapter for sefodo26's Go+Postgres+AGE MemPalace server (our eval fork: techempower-org/mempalace-server), enabling multipass runs against it.

  • MemPalaceServerAdapter over REST /mp/api/v1 (bearer auth): ingest / query / graph snapshot (via /taxonomy) / reset (list+delete — server tenancy is config-level, no per-request switch, documented)
  • Cat 9b harness probes (MCP health + REST search)
  • CLI registry aliases mempalace-server / mp-server; added to the fork contract kit — purely additive, no existing adapter touched
  • 31 mocked unit tests + 1 opt-in live round-trip (MEMPALACE_SERVER_LIVE=1, skips clean when absent)
  • Verified twice: agent run + orchestrator re-run (112 pass; the 2 failures are the pre-existing hindsight network flakes) including a real live round-trip against the dockerized server on katana

Two server behaviors the adapter handles (worth relaying to sefodo26): deterministic drawer IDs make re-ingest idempotent (already_exists), and pure bullet-list content gets split into N drawers (bullets_stored response shape).

🤖 Generated with Claude Code

Add MemPalaceServerAdapter for sefodo26's Go reimplementation of the
MemPalace server (fork: techempower-org/mempalace-server). Talks to the
server's REST API (/mp/api/v1, bearer auth) — the same shape the Go
project's own benchmark harness uses — so SME numbers stay comparable.

- ingest_corpus: one drawer per row (content ← document|content|text;
  wing/room ← row|metadata|session_id|id fallbacks), optional
  wing-scoped reset-before-ingest for per-question-haystack isolation.
  Handles the server's deterministic-id idempotency (already_exists) and
  bullet-splitting (bullets_stored) responses. Never raises on transport
  failure — errors are captured into the result dict.
- query: POST /search, constructor n_results default, optional
  wing/room/max_distance (omitted by default → server default, matching
  the reference benchmark). Returns a QueryResult with error set, never
  raises.
- get_graph_snapshot: projects GET /taxonomy through the shared
  project_graph (wing/room/member_of), identical to the daemon adapter.
- reset(wing=None): paginated list+delete isolation (the server has no
  per-request tenant; MEMPALACE_TENANT_ID is server-level config).
- get_harness_manifest: real Cat 9b surfaces — the MCP endpoint (health
  probe) and REST search — since the server's core identity is an MCP
  server. get_flat_retrieval / get_ontology_source provided.
- Config via constructor → env (MEMPALACE_SERVER_URL / _API_KEY /
  _TENANT) → docker-compose defaults; zero-config against a fresh
  `docker compose up`.

Registered in sme.cli (aliases mempalace-server / mempalace_server /
mp-server; no rename). Added to the fork contract test kit. 31 mocked
unit tests (fake_urlopen_factory) + 1 opt-in live round-trip test
(MEMPALACE_SERVER_LIVE=1, skips cleanly when absent). ruff check clean;
full suite green (pre-existing hindsight network failures unrelated).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 4, 2026 03:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jphein, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9791ecbd-3168-4cee-be51-e7d8eacaea47

📥 Commits

Reviewing files that changed from the base of the PR and between c422883 and 3edef03.

📒 Files selected for processing (4)
  • sme/adapters/mempalace_server_adapter.py
  • sme/cli.py
  • tests/test_fork_adapters_contract.py
  • tests/test_mempalace_server_adapter.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mempalace-server-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the MemPalaceServerAdapter to interface with the Go MemPalace server's REST API, along with CLI integration and comprehensive unit and contract tests. The feedback suggests adding defensive type checks in the query and get_graph_snapshot methods to robustly handle unexpected API response structures.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +265 to +271
if not results:
return QueryResult(
answer="",
context_string="",
error="NO_RESULTS",
retrieval_path=retrieval_path,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Defensively verify that results is a list before iterating over it. If the server returns an unexpected type for results (such as a dictionary or a string), iterating over it or calling .get() on its elements will raise an AttributeError or other runtime exceptions.

Suggested change
if not results:
return QueryResult(
answer="",
context_string="",
error="NO_RESULTS",
retrieval_path=retrieval_path,
)
if not isinstance(results, list) or not results:
return QueryResult(
answer="",
context_string="",
error="NO_RESULTS",
retrieval_path=retrieval_path,
)
References
  1. Prefer keeping defensive null checks even if they are currently unreachable due to early returns. Such checks document the intended contract and prevent regressions if the function's control flow is refactored in the future.

Comment on lines +336 to +339
for wing_name, room_map in tree.items():
room_map = room_map or {}
wings[wing_name] = sum(int(v or 0) for v in room_map.values())
rooms.append({"wing": wing_name, "rooms": room_map})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Defensively verify that room_map is a dictionary before calling .values() on it. If the server returns an unexpected taxonomy structure (e.g., a list or a string), calling .values() will raise an AttributeError and crash the snapshot projection.

        for wing_name, room_map in tree.items():
            if not isinstance(room_map, dict):
                continue
            wings[wing_name] = sum(int(v or 0) for v in room_map.values())
            rooms.append({"wing": wing_name, "rooms": room_map})
References
  1. Prefer keeping defensive null checks even if they are currently unreachable due to early returns. Such checks document the intended contract and prevent regressions if the function's control flow is refactored in the future.

@jphein jphein merged commit 8037476 into main Jul 4, 2026
4 checks passed
@jphein jphein deleted the feat/mempalace-server-adapter branch July 4, 2026 03:23
jphein added a commit that referenced this pull request Jul 4, 2026
…buted) + engram-2 deaccession note (#258)

Adds sefodo26's Go+Postgres+AGE server to the field explorer with the
2026-07-04 structural readings (committed baselines; basis=taxonomy
honestly recorded — the server does no KG auto-extraction, verified in
source and live via SME #255/#257). Publishes his methodology-matched
R@5 0.972 in the published_field column with source. Marks engram-2
withdrawn (repo deleted upstream; claims unverifiable).

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants