From 1fecaad47c3cfaffa117104b2d70d9fd77981928 Mon Sep 17 00:00:00 2001 From: codex Date: Tue, 4 Aug 2026 16:35:42 +0300 Subject: [PATCH] fix: bound automation cleanup and bind apply visibility --- Launcher.Next.App/PilotCli.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Launcher.Next.App/PilotCli.cs b/Launcher.Next.App/PilotCli.cs index 81eba09..91002da 100644 --- a/Launcher.Next.App/PilotCli.cs +++ b/Launcher.Next.App/PilotCli.cs @@ -186,7 +186,7 @@ internal static class PilotCli // It must never mint an Apply permit or start an Apply process. if (options.Diagnostic) return Success; var permitPath = Path.Combine(options.EvidenceRoot, "apply-permit.json"); - await File.WriteAllTextAsync(permitPath, JsonSerializer.Serialize(new ApplyPermit(true, options.FixtureMarker, preview.SelectedCandidateHash, preview.PlanIdRun1, "Visible", options.AnnotationTemplateDwg))); + await File.WriteAllTextAsync(permitPath, JsonSerializer.Serialize(new ApplyPermit(true, options.FixtureMarker, preview.SelectedCandidateHash, preview.PlanIdRun1, "М25 DN15-32", options.AnnotationTemplateDwg))); var applyConfigPath = Path.Combine(options.EvidenceRoot, "automation-apply.config.json"); var applyEvidence = Path.Combine(options.EvidenceRoot, "apply-result.json"); await File.WriteAllTextAsync(applyConfigPath, JsonSerializer.Serialize(new { phase = "Apply", orthoDrawingPath = options.OrthoDrawing, modelDrawingPath = options.ModelDrawing, annotationTemplateDwgPath = options.AnnotationTemplateDwg, evidencePath = applyEvidence, fixtureMarkerPath = options.FixtureMarker, entryAssemblySha256 = entryHash, automationTranscriptPath = Path.Combine(options.EvidenceRoot, "apply-transcript.log"), diagnostic = false })); @@ -229,13 +229,14 @@ internal static class PilotCli // terminal evidence is durable. Killing an active AutoCAD // command before that boundary would turn ForceAfterEvidence // into an unsafe general process killer. + var evidenceTimeout = Task.Delay(TimeSpan.FromSeconds(Math.Clamp(config.GracefulExitTimeoutSeconds, 1, 120))); while (!exit.IsCompleted && !HasCompletedEvidence(evidencePath)) - await Task.Delay(TimeSpan.FromSeconds(1)); + if (await Task.WhenAny(exit, evidenceTimeout) == evidenceTimeout) break; if (exit.IsCompleted) gracefulExit = true; else { var timeout = Task.Delay(TimeSpan.FromSeconds(Math.Clamp(config.GracefulExitTimeoutSeconds, 1, 120))); - if (await Task.WhenAny(exit, timeout) == exit) gracefulExit = true; + if (HasCompletedEvidence(evidencePath) && await Task.WhenAny(exit, timeout) == exit) gracefulExit = true; else { using var process = Process.GetProcessById(execution.ProcessId.Value);