Each request is associated with a {@link ProtoSession} that contains the configuration + * and context necessary for request processing, including: + *
Requests can optionally carry trace information through {@link RequestTrace} to support: + *
This interface is designed to be extended by specific request types that handle
+ * different Maven operations. All implementations must be immutable to ensure thread safety
+ * and predictable behavior in concurrent environments.
+ *
+ * @param the type of ProtoSession associated with this request, allowing for
+ * type-safe session handling in specific request implementations
+ *
+ * @see ProtoSession
+ * @see RequestTrace
+ * @see Result
+ * @since 4.0.0
+ */
+@Experimental
+@Immutable
+public interface Request {
+
+ /**
+ * Returns the session associated with this request.
+ *
+ * @return the session instance, never {@code null}
+ */
+ @Nonnull
+ S getSession();
+
+ /**
+ * Returns the trace information associated with this request, if any.
+ * The trace provides context about the request's position in the operation
+ * hierarchy and can carry additional diagnostic information.
+ *
+ * @return the request trace, or {@code null} if no trace information is available
+ */
+ @Nullable
+ RequestTrace getTrace();
+
+ /**
+ * Returns a string representation of this request, used for debugging and logging purposes.
+ * The format should include the request type and any significant attributes that define the
+ * request's state.
+ *
+ * @return a string representation of this request, never {@code null}
+ */
+ @Override
+ @Nonnull
+ String toString();
+}
diff --git a/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java
new file mode 100644
index 000000000000..6dafc3aeaf57
--- /dev/null
+++ b/api/maven-api-core/src/main/java/org/apache/maven/api/services/RequestTrace.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.api.services;
+
+import org.apache.maven.api.annotations.Nullable;
+
+/**
+ * Represents a hierarchical trace of nested requests within a session, enabling correlation between
+ * session events and their originating operations in the application code. The trace structure
+ * supports the following key features:
+ *
+ *
+ *
+ *
+ *
For internal session operations, the trace typically contains {@code *Request} objects + * that represent the current processing state. Client code can also create traces with + * application-specific data to provide context when invoking session methods.
+ * + *This trace information is particularly useful for:
+ *Each result is linked to its originating {@link Request}, allowing for: + *