feat(studio): coordinate integrated AI activity and internal language services
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

Start project-owned language and authenticated MCP services when opening a
project, reusing the embedded LSP backend without a desktop TCP listener.
Keep editor overlays separate from saved-file MCP queries.

Reserve conflicting editing before ACP prompt delivery and retain protection
through native/tool termination, runtime cleanup and document refresh. Preserve
drafts on rejected admission, provide cleanup/preparation recovery, distinguish
terminal outcomes and redact permission previews.

Add lifecycle, language parity, activity, composition and UI regressions and
update the canonical Studio contracts. Keep distribution update alignment as
the separate WRK-002A follow-up.

Validation: complete make -C tooling verify PASSED in
20261127T035822Z-ec5d9266 (1172 unit, 131 compiler fixture, 31 headless tests).
Opt-in real-model and native AI-view qualification are outside that gate.

Work: WRK-0029; decision: DEC-0001.
This commit is contained in:
2026-11-27 09:58:57 +00:00
parent 802a13a6aa
commit e6542df56e
46 changed files with 1485 additions and 180 deletions
@@ -22,6 +22,10 @@ public interface AgentConnection {
record Turn(CompletionStage<Void> accepted, CompletionStage<String> completion) { }
boolean available();
/** Includes admission and finalization, not just the active ACP prompt. */
default boolean busy() { return false; }
default boolean servicesReady() { return true; }
default CompletionStage<Void> recoverActivity() { return CompletableFuture.completedFuture(null); }
Status status();
AutoCloseable observe(Consumer<Status> listener);
void events(Consumer<Event> listener);
@@ -31,6 +35,8 @@ public interface AgentConnection {
CompletionStage<String> newSession();
Turn prompt(String sessionId, String text);
CompletionStage<Void> cancel(String sessionId);
/** After transport failure, proves native work stopped before editing can resume. */
default CompletionStage<Void> awaitQuiescence() { return closeAsync(); }
CompletionStage<Void> closeAsync();
static AgentConnection unavailable() {
@@ -16,7 +16,18 @@ public interface AutomationSession {
default CompletionStage<ControlResult> reclaimDiscardingUnsavedGameData() {
return java.util.concurrent.CompletableFuture.failedFuture(new UnsupportedOperationException("Runtime discard is unavailable"));
}
/** Project-owned infrastructure that must stop before close can succeed. */
default OperationSubscription registerProjectShutdown(java.util.function.Supplier<CompletionStage<Void>> shutdown) { return ()->{}; }
CompletionStage<ControlResult> closeAsync();
/** Ensures project MCP publication, without acquiring editing authority. May perform IO. */
default ControlResult prepareIntegratedServices() { return ControlResult.of(ControlResult.Status.GRANTED,""); }
/** Studio-owned activity; independent of external human grant actions. */
default CompletionStage<ControlResult> beginIntegratedActivity() {
return java.util.concurrent.CompletableFuture.failedFuture(new UnsupportedOperationException("Integrated activity is unavailable"));
}
/** Interrupts managed work while retaining the activity reservation until ACP stops. */
default void requestIntegratedCancellation() { }
default CompletionStage<ControlResult> finishIntegratedActivity(boolean cancel) { return reclaim(); }
/** Internal specialized service work, not a generic MCP shell/tool endpoint. */
OperationHandle<AutomationOutcome> submit(TaskIdentity task, String summary, Callable<AutomationOutcome> work);
/** Null identity is reserved for a local manual service holding an active manual lease. */
@@ -0,0 +1,25 @@
package p.studio.api.session;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
/** Project-owned editor view. MCP uses its independently admitted, saved-file view. */
public interface ProjectLanguageService {
record Document(String uri, int version, String text) {
public Document { Objects.requireNonNull(uri); Objects.requireNonNull(text); if(version<0)throw new IllegalArgumentException("Negative document version"); }
}
record Request(String operation, Document document, Map<String,Object> parameters) {
public Request { Objects.requireNonNull(operation); parameters=p.studio.api.values.ValueMaps.object(parameters); }
}
record Result(Map<String,Object> values) {
public Result { values=p.studio.api.values.ValueMaps.object(values); }
}
CompletionStage<Result> query(Request request);
/** Discards an editor overlay only on an explicit editor close/discard action. */
default void closeDocument(String uri) { }
static ProjectLanguageService unavailable() {
return request -> CompletableFuture.failedFuture(new IllegalStateException("Project language service is unavailable"));
}
}
@@ -15,6 +15,7 @@ public interface ProjectSession extends AutoCloseable {
ExecutionSession executionSession();
p.studio.api.automation.AutomationSession automation();
default ProjectLanguageService language() { return ProjectLanguageService.unavailable(); }
default java.util.Optional<p.studio.api.automation.EvidenceTools> evidenceTools() { return java.util.Optional.empty(); }
default java.util.Optional<p.studio.api.automation.GuestTestTools> guestTestTools() { return java.util.Optional.empty(); }
default java.util.Optional<p.studio.api.assets.AssetAuthoringService> assetAuthoring() { return java.util.Optional.empty(); }