Skip to content

RuleScript v1.10.0-rc1.1

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 07 Jul 03:26

RuleScript v1.10.0-rc1.1

RuleScript v1.10.0-rc1.1 refines the HostTrigger release candidate by aligning long-running runtimes with the existing engine and debug-session flows.

Runtime Creation From Files

RuleScriptEngine can now create a long-running runtime from a script file, using the same file-loading behavior as ExecuteFile and ExecuteFileAsync.

var engine = new RuleScriptEngine
{
    WorkingDirectory = @"C:\rules"
};

var runtime = engine.CreateRuntimeFromFile("main");

foreach (var trigger in runtime.HostTriggers)
{
    Console.WriteLine($"{trigger.HostTriggerMetadata?.Name}: {trigger.Signature}");
}

CreateRuntimeFromFile uses:

  • WorkingDirectory
  • ScriptFileExtension
  • ImportResolver
  • existing import/module loading

This keeps HostTrigger runtime startup consistent with the existing file execution pipeline.

Debug Session Runtime Support

RuleScriptDebugSession can now create runtimes directly, so HostTrigger applications can use breakpoints, stepping, and runtime-event inspection.

var engine = new RuleScriptEngine
{
    WorkingDirectory = @"C:\rules",
    ExecutionTimeoutEnabled = false
};

engine.AddBreakpoint("main.rules", 12);

var session = new RuleScriptDebugSession(engine);
var runtime = session.CreateRuntimeFromFile("main.rules");

var running = runtime.StartAsync();
var pause = await session.WaitForPauseAsync();

Console.WriteLine(pause.Kind);
Console.WriteLine(session.CurrentSnapshot?.CallStack.Count);

session.Continue();

await runtime.TriggerAsync("LotArrived", ["LOT-001"]);
await runtime.StopAsync();
await running;

Debug-session runtime creation is also available for script text:

var session = new RuleScriptDebugSession(engine);
var runtime = session.CreateRuntime("""
    @HostTrigger("LotArrived")
    function OnLotArrived(lotId: string) -> void:
        Log(lotId);
        return;
    endfunction

    parallel:
        trigger task:
            dispatch;
        endtask
    endparallel
    """);

HostTrigger Runtime Example

@HostTrigger("LotArrived")
function OnLotArrived(lotId: string) -> void:
    Log("lot arrived: " + lotId);
    return;
endfunction

parallel:
    trigger task:
        dispatch;
    endtask
endparallel
var runtime = engine.CreateRuntimeFromFile("main.rules");
var running = runtime.StartAsync();

await runtime.TriggerAsync("LotArrived", ["LOT-001"]);
await runtime.TriggerAsync("LotArrived", ["LOT-002"]);

await runtime.StopAsync();
await running;

Compatibility Notes

  • Existing CreateRuntime(script, context) behavior is preserved.
  • Existing ExecuteFile and ExecuteFileAsync behavior is unchanged.
  • Debug runtime creation installs debug event handlers only while the runtime is executing, then restores the previous engine handlers.
  • trigger task remains interpreter-owned; host trigger calls still enqueue requests instead of directly invoking user functions.

Validation

This release candidate is covered by tests for:

  • creating runtimes from files via RuleScriptEngine
  • applying WorkingDirectory and file extension resolution
  • creating runtimes through RuleScriptDebugSession
  • breakpoint pause and continue behavior with debug-created runtimes
  • debug-session runtime creation from files
  • existing HostTrigger FIFO and metadata behavior
  • full regression coverage