feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
package setup
|
|
|
|
|
|
|
|
|
|
import (
|
2026-03-29 21:34:46 +00:00
|
|
|
"context"
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
"testing"
|
|
|
|
|
|
2026-03-29 22:35:34 +00:00
|
|
|
"dappco.re/go/agent/pkg/agentic"
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
core "dappco.re/go/core"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2026-03-29 22:35:34 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestService_Register_Good(t *testing.T) {
|
|
|
|
|
c := core.New(core.WithService(Register))
|
|
|
|
|
svc, ok := core.ServiceFor[*Service](c, "setup")
|
|
|
|
|
assert.True(t, ok)
|
|
|
|
|
assert.NotNil(t, svc)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 21:34:46 +00:00
|
|
|
func TestService_OnStartup_Good(t *testing.T) {
|
|
|
|
|
c := core.New()
|
|
|
|
|
svc := &Service{ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{})}
|
|
|
|
|
|
|
|
|
|
result := svc.OnStartup(context.Background())
|
|
|
|
|
assert.True(t, result.OK)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-29 22:35:34 +00:00
|
|
|
func TestService_OnStartup_Bad_CancelledContext(t *testing.T) {
|
|
|
|
|
c := core.New()
|
|
|
|
|
svc := &Service{ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{})}
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
cancel()
|
|
|
|
|
|
|
|
|
|
result := svc.OnStartup(ctx)
|
|
|
|
|
assert.True(t, result.OK)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestService_OnStartup_Ugly_NilRuntime(t *testing.T) {
|
|
|
|
|
result := (&Service{}).OnStartup(context.Background())
|
|
|
|
|
assert.True(t, result.OK)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestService_DetectGitRemote_Good_GitOrigin(t *testing.T) {
|
|
|
|
|
dir := t.TempDir()
|
|
|
|
|
c := core.New()
|
|
|
|
|
require.True(t, agentic.ProcessRegister(c).OK)
|
|
|
|
|
svc := &Service{ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{})}
|
|
|
|
|
|
|
|
|
|
require.True(t, c.Process().RunIn(context.Background(), dir, "git", "init").OK)
|
|
|
|
|
require.True(t, c.Process().RunIn(context.Background(), dir, "git", "remote", "add", "origin", "git@forge.lthn.ai:core/agent.git").OK)
|
|
|
|
|
|
|
|
|
|
assert.Equal(t, "core/agent", svc.DetectGitRemote(dir))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestService_DetectGitRemote_Bad_NonGitDir(t *testing.T) {
|
feat(v0.8.0): full AX migration — ServiceRuntime, Actions, quality gates, transport
go-process:
- Register factory, Result lifecycle, 5 named Action handlers
- Start/Run/StartWithOptions/RunWithOptions all return core.Result
- core.ID() replaces fmt.Sprintf, core.As replaces errors.As
core/agent:
- PrepSubsystem + monitor.Subsystem + setup.Service embed ServiceRuntime[T]
- 22 named Actions + agent.completion Task pipeline in OnStartup
- ChannelNotifier removed — all IPC via c.ACTION(messages.X{})
- proc.go: all methods via s.Core().Process(), returns core.Result
- status.go: WriteAtomic + JSONMarshalString
- paths.go: Fs.NewUnrestricted() replaces unsafe.Pointer
- transport.go: ONE net/http file — HTTPGet/HTTPPost/HTTPDo/MCP transport
- All disallowed imports eliminated from source files (13 quality gates)
- String concat eliminated — core.Concat() throughout
- 1:1 _test.go + _example_test.go for every source file
- Reference docs synced from core/go v0.8.0
- RFC-025 updated with net/http, net/url, io/fs quality gates
- lib.go: io/fs eliminated via Data.ListNames, Array[T].Deduplicate
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-26 01:27:46 +00:00
|
|
|
c := core.New()
|
|
|
|
|
svc := &Service{ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{})}
|
|
|
|
|
remote := svc.DetectGitRemote(t.TempDir())
|
|
|
|
|
assert.Equal(t, "", remote)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestService_DetectGitRemote_Ugly_EmptyPath(t *testing.T) {
|
|
|
|
|
c := core.New()
|
|
|
|
|
svc := &Service{ServiceRuntime: core.NewServiceRuntime(c, SetupOptions{})}
|
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
|
svc.DetectGitRemote("")
|
|
|
|
|
})
|
|
|
|
|
}
|