From 6adbf9227727f482f72de81de12cc85d230f67a8 Mon Sep 17 00:00:00 2001 From: Virgil Date: Wed, 1 Apr 2026 19:03:54 +0000 Subject: [PATCH] feat(agentic): delegate runner controls to pkg/runner Co-Authored-By: Virgil --- pkg/agentic/runner.go | 27 +++++++++++++++++++++++++-- pkg/agentic/runner_test.go | 32 +++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/pkg/agentic/runner.go b/pkg/agentic/runner.go index 4925253..6d4335e 100644 --- a/pkg/agentic/runner.go +++ b/pkg/agentic/runner.go @@ -2,10 +2,33 @@ package agentic +import ( + "context" + + core "dappco.re/go/core" +) + // subsystem := agentic.NewPrep() // subsystem.StartRunner() -func (s *PrepSubsystem) StartRunner() {} +func (s *PrepSubsystem) StartRunner() { + s.runRunnerAction("runner.start") +} // subsystem := agentic.NewPrep() // subsystem.Poke() -func (s *PrepSubsystem) Poke() {} +func (s *PrepSubsystem) Poke() { + s.runRunnerAction("runner.poke") +} + +func (s *PrepSubsystem) runRunnerAction(name string) { + if s == nil || s.ServiceRuntime == nil { + return + } + + action := s.Core().Action(name) + if action == nil || !action.Exists() { + return + } + + action.Run(context.Background(), core.NewOptions()) +} diff --git a/pkg/agentic/runner_test.go b/pkg/agentic/runner_test.go index 959fb93..4a62b16 100644 --- a/pkg/agentic/runner_test.go +++ b/pkg/agentic/runner_test.go @@ -3,12 +3,14 @@ package agentic import ( + "context" "testing" + core "dappco.re/go/core" "github.com/stretchr/testify/assert" ) -// StartRunner and Poke are no-ops — queue drain is owned by pkg/runner.Service. +// StartRunner and Poke delegate to pkg/runner.Service when it is registered. func TestRunner_StartRunner_Good(t *testing.T) { s := newPrepWithProcess() @@ -25,3 +27,31 @@ func TestRunner_Poke_Ugly_NilChannel(t *testing.T) { s := newPrepWithProcess() assert.NotPanics(t, func() { s.Poke() }) } + +func TestRunner_StartRunner_Good_DelegatesToRunnerStartAction(t *testing.T) { + coreApp := core.New(core.WithOption("name", "test")) + called := false + coreApp.Action("runner.start", func(_ context.Context, _ core.Options) core.Result { + called = true + return core.Result{OK: true} + }) + + s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(coreApp, AgentOptions{})} + s.StartRunner() + + assert.True(t, called) +} + +func TestRunner_Poke_Good_DelegatesToRunnerPokeAction(t *testing.T) { + coreApp := core.New(core.WithOption("name", "test")) + called := false + coreApp.Action("runner.poke", func(_ context.Context, _ core.Options) core.Result { + called = true + return core.Result{OK: true} + }) + + s := &PrepSubsystem{ServiceRuntime: core.NewServiceRuntime(coreApp, AgentOptions{})} + s.Poke() + + assert.True(t, called) +}