fix(management): compile an API method once per save — CompileForPublish replaces the validate pre-pass (review 2026-10-21 05/M1)

This commit is contained in:
Joseph Doherty
2026-10-22 09:20:00 -04:00
parent 36d57f11b3
commit 72f96bdbcb
5 changed files with 160 additions and 14 deletions
@@ -3667,12 +3667,16 @@ public class ManagementActor : ReceiveActor
var executor = sp.GetService<InboundAPI.InboundScriptExecutor>();
if (executor is null)
return null;
var compiled = executor.ValidateCompilation(method, out var errors);
// ONE compile (review 2026-10-21 05/M1): each compile pins a non-collectible script
// assembly, so the diagnostics for the warning and the handler registration come
// from the same compile. Registration still waits for the commit when the command
// runs inside a configuration transaction.
var compiled = executor.CompileForPublish(method, out var errors, out var publish);
var actions = sp.GetService<IConfigurationCommitActions>();
if (actions is not null)
actions.Add(() => { executor.CompileAndRegister(method); return Task.CompletedTask; });
actions.Add(() => { publish(); return Task.CompletedTask; });
else
executor.CompileAndRegister(method);
publish();
if (compiled)
return null;