From 79bdbaa1ed32096d1d535525bc7d2f7128412022 Mon Sep 17 00:00:00 2001 From: B3 Date: Wed, 26 Aug 2026 02:50:47 -0400 Subject: [PATCH] test(mcp_server): regression test for classic engraphis_remember subject_key/claim_kind chain persistence --- tests/test_mcp_server.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_mcp_server.py b/tests/test_mcp_server.py index fa7f2710..0490bc12 100644 --- a/tests/test_mcp_server.py +++ b/tests/test_mcp_server.py @@ -1222,3 +1222,38 @@ def test_smart_gateway_unknown_exception_never_leaks_internals(monkeypatch): assert parsed["error"]["code"] == "E_INTERNAL" assert "SECRET" not in parsed["error"]["message"] assert "/home/user" not in parsed["error"]["message"] + + +def test_classic_remember_persists_subject_key_and_claim_kind_to_chain(monkeypatch): + """Classic engraphis_remember must persist subject_key/claim_kind to the chain. + + Regression guard for the class binding that powers every direct Command Code + caller: the SMART gateway now carries subject_key/claim_kind (PR #171) but the + classic binding had no end-to-end test that exercised these parameters. A + direct call must (a) return a memory id, not a delegation envelope, and + (b) round-trip the subject/claim metadata through the inspect chain. + """ + srv = _module_with_memory_db(monkeypatch) + + response = srv.engraphis_remember( + content="The deployment timeout is 30 seconds.", + workspace="w", + subject_key="deploy.timeout", + claim_kind="configured_value", + ) + assert not response.startswith("Error:"), response + payload = json.loads(response) + assert payload["op"] == "add" + assert isinstance(payload.get("id"), str) and payload["id"] + # The id must be a memory id, not a Smart gateway delegation envelope. + assert not payload["id"].startswith("del_"), payload["id"] + + fetched = srv.engraphis_get_memory(memory_id=payload["id"], workspace="w") + assert not fetched.startswith("Error:"), fetched + fetched_payload = json.loads(fetched) + assert fetched_payload["id"] == payload["id"] + assert fetched_payload["chain"], "inspect must return a non-empty chain" + head = fetched_payload["chain"][0] + assert head["id"] == payload["id"] + assert head["subject_key"] == "deploy.timeout" + assert head["claim_kind"] == "configured_value"