Skip to content

The agent that grows with you

fix: preserve pre-editor credential identity and native control coverage

Teknium8e3b3a0c67a9
diff --git a/gateway/session_policy_credentials.py b/gateway/session_policy_credentials.py
index d18236d10f0..5e7c70dccaa 100644
--- a/gateway/session_policy_credentials.py
+++ b/gateway/session_policy_credentials.py
@@ -15,6 +15,8 @@ def policy_identity(policy):
data = asdict(policy)
data.pop('credential_ref')
data.pop('config_secret_ref')
+ if data.get('editor_mcp_json') is None:
+ data.pop('editor_mcp_json', None)
return hashlib.sha256(json.dumps(data, sort_keys=True).encode()).hexdigest()
diff --git a/tests/acp/test_gateway_editor_mcp.py b/tests/acp/test_gateway_editor_mcp.py
index a67e867e5d1..2baf383dbc3 100644
--- a/tests/acp/test_gateway_editor_mcp.py
+++ b/tests/acp/test_gateway_editor_mcp.py
@@ -171,6 +171,7 @@ async def test_native_cold_editor_rebind_refuses_changed_secret(daemon, specs, t
assert 'acp_mcp_policy_conflict' in json.dumps(refused), refused
loaded = await acp.rpc('session/load', sessionId=sid, cwd=str(tmp_path), mcpServers=[specs[0]])
assert 'result' in loaded, loaded
+ acp.frames.clear() # Old replay is not evidence of new execution.
assert 'result' in await prompt(acp, sid, 'Use owned echo after restart')
assert 'OWNED_RESULT_A' in json.dumps(acp.frames)
print('ACP_MCP_COLD_RECEIPT=' + json.dumps({'session_id': sid,
diff --git a/tests/acp/test_gateway_wire_controls.py b/tests/acp/test_gateway_wire_controls.py
index 77aee9876d4..73491108ae3 100644
--- a/tests/acp/test_gateway_wire_controls.py
+++ b/tests/acp/test_gateway_wire_controls.py
@@ -40,8 +40,6 @@ async def test_real_acp_answer_resolves_the_exact_pending_control(daemon, tmp_pa
sid = snapshot["session_id"]
async with editor(daemon, tmp_path) as acp:
await acp.rpc("initialize", protocolVersion=1, clientCapabilities={})
- unsupported = await acp.rpc("session/new", cwd=str(tmp_path), mcpServers=[])
- assert "acp_policy_unavailable" in json.dumps(unsupported)
await acp.rpc("session/resume", cwd=str(tmp_path), sessionId=sid, mcpServers=[])
task = asyncio.create_task(acp.rpc("session/prompt", sessionId=sid,
prompt=[{"type": "text", "text": "Remove owned fixture after consent"}]))
diff --git a/tests/acp/test_policy_identity_compat.py b/tests/acp/test_policy_identity_compat.py
new file mode 100644
index 00000000000..aabcf9f5923
--- /dev/null
+++ b/tests/acp/test_policy_identity_compat.py
@@ -0,0 +1,16 @@
+"""Absent optional editor state cannot revoke an older credential reference."""
+from dataclasses import asdict
+import hashlib
+import json
+
+
+def test_policy_identity_preserves_pre_editor_credential_binding(tmp_path):
+ from gateway.session_policy import build_policy
+ from gateway.session_policy_credentials import policy_identity
+ policy = build_policy({'source': 'cli', 'cwd': str(tmp_path), 'model': 'local'}, {})
+ legacy = asdict(policy)
+ legacy.pop('credential_ref')
+ legacy.pop('config_secret_ref')
+ legacy.pop('editor_mcp_json')
+ expected = hashlib.sha256(json.dumps(legacy, sort_keys=True).encode()).hexdigest()
+ assert policy_identity(policy) == expected