Merge branch 'worktree-agent-ac243fcc404f04015' into feat/flow-debugger-script-entry

This commit is contained in:
Joseph Doherty
2026-09-08 01:23:36 -04:00
2 changed files with 38 additions and 15 deletions
@@ -75,13 +75,6 @@ public sealed class FlowDebugService : IFlowDebugService
/// <summary>Upper bound on the template parent chain the script resolver walks (cycle guard).</summary>
private const int MaxTemplateChain = 16;
/// <summary>
/// Ask-sizing fallback for a call-kind script that declares no timeout of its own — mirrors
/// <c>SiteRuntimeOptions.ScriptExecutionTimeoutSeconds</c>, the site default the run would
/// actually be bounded by (the UI has no site options to read it from).
/// </summary>
private const int DefaultScriptTimeoutSeconds = 30;
private static readonly JsonSerializerOptions ResultJsonOptions = new()
{
PropertyNameCaseInsensitive = true,
@@ -244,14 +237,15 @@ public sealed class FlowDebugService : IFlowDebugService
{
// The server re-resolves the script and never trusts a client-supplied trigger kind
// (design 2026-09-08 §2); the kind is read here only to size the Ask wait — a call kind
// is bounded by the script's own execution timeout, a write kind by the trigger-wait
// window. An unresolvable script falls back to the write-kind wait, which is the longer
// of the two for a default-timeout script.
// is bounded by the script's own execution timeout — falling back to the runner's own
// FlowDebugRunner.DefaultScriptTimeoutSeconds so client and server agree on the bound —
// a write kind by the trigger-wait window. An unresolvable script falls back
// to the write-kind wait, which is the longer of the two for a default-timeout script.
var command = new FlowDebugRunScriptCommand(instanceId, scriptName, parameters, value);
var option = (await GetInstanceScriptsAsync(instanceId, cancellationToken))
.FirstOrDefault(o => o.CanonicalName.Equals(scriptName, StringComparison.OrdinalIgnoreCase));
var timeout = option is { IsWriteKind: false }
? RunAskTimeoutFor(option.ExecutionTimeoutSeconds ?? DefaultScriptTimeoutSeconds)
? RunAskTimeoutFor(option.ExecutionTimeoutSeconds ?? FlowDebugRunner.DefaultScriptTimeoutSeconds)
: ValueChangeAskTimeoutFor(command.WaitSeconds);
return await SendAndBuildAsync(command, timeout, cancellationToken);
@@ -411,8 +405,10 @@ public sealed class FlowDebugService : IFlowDebugService
/// Loads an instance's scripts from its flattened configuration (design 2026-09-08 §2) —
/// canonical names, effective trigger kinds and effective parameter definitions, i.e. exactly
/// what the site's Instance Actor keys on — memoised for the life of this scoped service.
/// Returns null when the instance does not exist or the flatten failed; a flatten failure is
/// a debug-level note, never a page error, because the picker simply has nothing to offer.
/// Returns null when the instance does not exist (Debug — an id from a stale link) or the
/// flatten failed (Warning — the same severity <c>DeploymentService</c> and the Configure
/// page give it, since the instance could not be deployed either). Neither is a page error:
/// the picker simply has no scripts to offer.
/// </summary>
private async Task<InstanceScripts?> LoadScriptsAsync(int instanceId, CancellationToken ct)
{
@@ -426,7 +422,9 @@ public sealed class FlowDebugService : IFlowDebugService
var flattened = await _pipeline.FlattenAndValidateAsync(instance.Id, ct, validateScripts: false);
if (flattened.IsFailure)
{
_logger.LogDebug("Flow Debugger could not flatten instance {InstanceId}: {Error}", instanceId, flattened.Error);
_logger.LogWarning(
"Flow Debugger could not flatten instance {InstanceId} ({UniqueName}): {Error}",
instanceId, instance.UniqueName, flattened.Error);
return null;
}