001/* 002 * Copyright 2022-2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.soklet; 018 019import org.jspecify.annotations.NonNull; 020 021import javax.annotation.concurrent.ThreadSafe; 022import java.util.Optional; 023 024/** 025 * Thread-safe, server-owned MCP trace-correlation control plane. 026 * <p> 027 * Correlation is disabled unless a key is supplied when the server is built. 028 * Rotation atomically replaces both active key ID and key material. Soklet 029 * retains no public history or historical-token derivation facility. 030 * 031 * @author <a href="https://www.revetkn.com">Mark Allen</a> 032 */ 033@ThreadSafe 034public interface McpTraceCorrelationKeyManager { 035 /** @return whether trace correlation was enabled at server construction */ 036 @NonNull 037 Boolean isEnabled(); 038 039 /** @return active non-secret key ID, or empty when disabled */ 040 @NonNull 041 Optional<@NonNull String> getActiveKeyId(); 042 043 /** @return active configuration fingerprint, or empty when disabled */ 044 @NonNull 045 Optional<@NonNull McpTraceCorrelationFingerprint> 046 getFingerprint(); 047 048 /** 049 * Atomically rotates both active key ID and material. 050 * <p> 051 * Re-supplying the byte-identical active entry is an idempotent no-op. Reuse 052 * of the active ID with different material is rejected so structured-log key 053 * IDs continue to identify one correlation-key version unambiguously. 054 * 055 * @param activeKey new active correlation key 056 * @throws IllegalArgumentException if its ID ambiguously reuses the active 057 * ID or its material equals any protection 058 * ring key material 059 * @throws IllegalStateException if correlation was not enabled when the 060 * server was built 061 */ 062 void rotateActiveKey(@NonNull McpTraceCorrelationKey activeKey); 063}