verify automation interruption recovery and manual debug lifecycle

This commit is contained in:
2026-09-29 12:06:48 +01:00
parent 4f148a50de
commit e6a83c94e0
10 changed files with 300 additions and 17 deletions
@@ -227,8 +227,8 @@ public class StudioApplicationConfiguration {
return new p.studio.core.project.ProjectAccessRegistry();
}
@Bean
ProjectSessionFactory projectSessionFactory(ProjectLocalStudioStateStore stateStore,
@Bean(destroyMethod = "close")
DefaultProjectSessionFactory projectSessionFactory(ProjectLocalStudioStateStore stateStore,
ProjectLocalStudioSetupStore setupStore, LspLifecyclePort lsp,
p.studio.core.project.ProjectAccessRegistry access, OperationExecutor operations) {
return new DefaultProjectSessionFactory(stateStore, setupStore, lsp, access, operations);
@@ -141,11 +141,23 @@ final class HeadlessProcessSession implements HeadlessGateway.Session {
var target = advance.get();
if (target == null || target.result.isDone() || !target.cancelled.compareAndSet(false, true) || dead.get()) return;
var cancel = new Pending("cancel", null, null);
send(cancel, mapper.createObjectNode().put("targetRequestId", target.id));
timer.schedule(() -> { if (!target.result.isDone() || !cancel.result.isDone()) abort("Runtime did not stop after cancellation"); }, limits.shutdownTimeoutMs(), TimeUnit.MILLISECONDS);
try {
send(cancel, mapper.createObjectNode().put("targetRequestId", target.id));
timer.schedule(() -> { if (!target.result.isDone() || !cancel.result.isDone()) abort("Runtime did not stop after cancellation"); }, limits.shutdownTimeoutMs(), TimeUnit.MILLISECONDS);
} catch (RuntimeException lost) {
// A concurrent crash may close the writer/timer. Fail the pending operation,
// but do not prevent the authority owner from awaiting shutdown and cleanup.
abort("Headless session lost during cancellation");
}
}
@Override public synchronized CompletionStage<Void> shutdown() {
if (shutdown != null) return shutdown;
if (shutdown != null) {
// The first forced shutdown reports infrastructure failure. An explicit human
// retry may acknowledge completed cleanup, but never releases a living process.
if (shutdown.isCompletedExceptionally() && dead.get() && !alive())
shutdown = CompletableFuture.completedFuture(null);
return shutdown;
}
closing = true;
shutdown = CompletableFuture.runAsync(() -> {
long deadline = System.nanoTime() + TimeUnit.MILLISECONDS.toNanos(limits.shutdownTimeoutMs());