go/ipc_test.go

143 lines
3.5 KiB
Go
Raw Permalink Normal View History

package core_test
import (
"context"
"testing"
2026-03-20 21:00:48 +00:00
. "dappco.re/go/core"
"github.com/stretchr/testify/assert"
)
// --- IPC: Actions ---
type testMessage struct{ payload string }
func TestAction_Good(t *testing.T) {
c := New()
var received Message
c.RegisterAction(func(_ *Core, msg Message) Result {
received = msg
return Result{OK: true}
})
r := c.ACTION(testMessage{payload: "hello"})
assert.True(t, r.OK)
assert.Equal(t, testMessage{payload: "hello"}, received)
}
func TestAction_Multiple_Good(t *testing.T) {
c := New()
count := 0
handler := func(_ *Core, _ Message) Result { count++; return Result{OK: true} }
c.RegisterActions(handler, handler, handler)
c.ACTION(nil)
assert.Equal(t, 3, count)
}
func TestAction_None_Good(t *testing.T) {
c := New()
// No handlers registered — should succeed
r := c.ACTION(nil)
assert.True(t, r.OK)
}
feat: implement RFC plans 1-5 — Registry[T], Action/Task, Process, primitives Plans 1-5 complete for core/go scope. 456 tests, 84.4% coverage, 100% AX-7 naming. Critical bugs (Plan 1): - P4-3+P7-3: ACTION broadcast calls all handlers with panic recovery - P7-2+P7-4: RunE() with defer ServiceShutdown, Run() delegates - P3-1: Startable/Stoppable return Result (breaking, clean) - P9-1: Zero os/exec — App.Find() rewritten with os.Stat+PATH - I3: Embed() removed, I15: New() comment fixed - I9: CommandLifecycle removed → Command.Managed field Registry[T] (Plan 2): - Universal thread-safe named collection with 3 lock modes - All 5 registries migrated: services, commands, drive, data, lock - Insertion order preserved (fixes P4-1) - c.RegistryOf("name") cross-cutting accessor Action/Task system (Plan 3): - Action type with Run()/Exists(), ActionHandler signature - c.Action("name") dual-purpose accessor (register/invoke) - TaskDef with Steps — sequential chain, async dispatch, previous-input piping - Panic recovery on all Action execution - broadcast() internal, ACTION() sugar Process primitive (Plan 4): - c.Process() returns Action sugar — Run/RunIn/RunWithEnv/Start/Kill/Exists - No deps added — delegates to c.Action("process.*") - Permission-by-registration: no handler = no capability Missing primitives (Plan 5): - core.ID() — atomic counter + crypto/rand suffix - ValidateName() / SanitisePath() — reusable validation - Fs.WriteAtomic() — write-to-temp-then-rename - Fs.NewUnrestricted() / Fs.Root() — legitimate sandbox bypass - AX-7: 456/456 tests renamed to TestFile_Function_{Good,Bad,Ugly} Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 15:18:25 +00:00
func TestAction_Bad_HandlerFails(t *testing.T) {
c := New()
c.RegisterAction(func(_ *Core, _ Message) Result {
return Result{Value: NewError("intentional"), OK: false}
})
// ACTION is broadcast — even with a failing handler, dispatch succeeds
r := c.ACTION(testMessage{payload: "test"})
assert.True(t, r.OK)
}
func TestAction_Ugly_HandlerFailsChainContinues(t *testing.T) {
c := New()
var order []int
c.RegisterAction(func(_ *Core, _ Message) Result {
order = append(order, 1)
return Result{OK: true}
})
c.RegisterAction(func(_ *Core, _ Message) Result {
order = append(order, 2)
return Result{Value: NewError("handler 2 fails"), OK: false}
})
c.RegisterAction(func(_ *Core, _ Message) Result {
order = append(order, 3)
return Result{OK: true}
})
r := c.ACTION(testMessage{payload: "test"})
assert.True(t, r.OK)
assert.Equal(t, []int{1, 2, 3}, order, "all 3 handlers must fire even when handler 2 returns !OK")
}
func TestAction_Ugly_HandlerPanicsChainContinues(t *testing.T) {
c := New()
var order []int
c.RegisterAction(func(_ *Core, _ Message) Result {
order = append(order, 1)
return Result{OK: true}
})
c.RegisterAction(func(_ *Core, _ Message) Result {
panic("handler 2 explodes")
})
c.RegisterAction(func(_ *Core, _ Message) Result {
order = append(order, 3)
return Result{OK: true}
})
r := c.ACTION(testMessage{payload: "test"})
assert.True(t, r.OK)
assert.Equal(t, []int{1, 3}, order, "handlers 1 and 3 must fire even when handler 2 panics")
}
// --- IPC: Queries ---
feat: implement RFC plans 1-5 — Registry[T], Action/Task, Process, primitives Plans 1-5 complete for core/go scope. 456 tests, 84.4% coverage, 100% AX-7 naming. Critical bugs (Plan 1): - P4-3+P7-3: ACTION broadcast calls all handlers with panic recovery - P7-2+P7-4: RunE() with defer ServiceShutdown, Run() delegates - P3-1: Startable/Stoppable return Result (breaking, clean) - P9-1: Zero os/exec — App.Find() rewritten with os.Stat+PATH - I3: Embed() removed, I15: New() comment fixed - I9: CommandLifecycle removed → Command.Managed field Registry[T] (Plan 2): - Universal thread-safe named collection with 3 lock modes - All 5 registries migrated: services, commands, drive, data, lock - Insertion order preserved (fixes P4-1) - c.RegistryOf("name") cross-cutting accessor Action/Task system (Plan 3): - Action type with Run()/Exists(), ActionHandler signature - c.Action("name") dual-purpose accessor (register/invoke) - TaskDef with Steps — sequential chain, async dispatch, previous-input piping - Panic recovery on all Action execution - broadcast() internal, ACTION() sugar Process primitive (Plan 4): - c.Process() returns Action sugar — Run/RunIn/RunWithEnv/Start/Kill/Exists - No deps added — delegates to c.Action("process.*") - Permission-by-registration: no handler = no capability Missing primitives (Plan 5): - core.ID() — atomic counter + crypto/rand suffix - ValidateName() / SanitisePath() — reusable validation - Fs.WriteAtomic() — write-to-temp-then-rename - Fs.NewUnrestricted() / Fs.Root() — legitimate sandbox bypass - AX-7: 456/456 tests renamed to TestFile_Function_{Good,Bad,Ugly} Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 15:18:25 +00:00
func TestIpc_Query_Good(t *testing.T) {
c := New()
c.RegisterQuery(func(_ *Core, q Query) Result {
if q == "ping" {
return Result{Value: "pong", OK: true}
}
return Result{}
})
r := c.QUERY("ping")
assert.True(t, r.OK)
assert.Equal(t, "pong", r.Value)
}
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
feat: implement RFC plans 1-5 — Registry[T], Action/Task, Process, primitives Plans 1-5 complete for core/go scope. 456 tests, 84.4% coverage, 100% AX-7 naming. Critical bugs (Plan 1): - P4-3+P7-3: ACTION broadcast calls all handlers with panic recovery - P7-2+P7-4: RunE() with defer ServiceShutdown, Run() delegates - P3-1: Startable/Stoppable return Result (breaking, clean) - P9-1: Zero os/exec — App.Find() rewritten with os.Stat+PATH - I3: Embed() removed, I15: New() comment fixed - I9: CommandLifecycle removed → Command.Managed field Registry[T] (Plan 2): - Universal thread-safe named collection with 3 lock modes - All 5 registries migrated: services, commands, drive, data, lock - Insertion order preserved (fixes P4-1) - c.RegistryOf("name") cross-cutting accessor Action/Task system (Plan 3): - Action type with Run()/Exists(), ActionHandler signature - c.Action("name") dual-purpose accessor (register/invoke) - TaskDef with Steps — sequential chain, async dispatch, previous-input piping - Panic recovery on all Action execution - broadcast() internal, ACTION() sugar Process primitive (Plan 4): - c.Process() returns Action sugar — Run/RunIn/RunWithEnv/Start/Kill/Exists - No deps added — delegates to c.Action("process.*") - Permission-by-registration: no handler = no capability Missing primitives (Plan 5): - core.ID() — atomic counter + crypto/rand suffix - ValidateName() / SanitisePath() — reusable validation - Fs.WriteAtomic() — write-to-temp-then-rename - Fs.NewUnrestricted() / Fs.Root() — legitimate sandbox bypass - AX-7: 456/456 tests renamed to TestFile_Function_{Good,Bad,Ugly} Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 15:18:25 +00:00
func TestIpc_Query_Unhandled_Good(t *testing.T) {
c := New()
c.RegisterQuery(func(_ *Core, q Query) Result {
return Result{}
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
})
r := c.QUERY("unknown")
assert.False(t, r.OK)
}
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
feat: implement RFC plans 1-5 — Registry[T], Action/Task, Process, primitives Plans 1-5 complete for core/go scope. 456 tests, 84.4% coverage, 100% AX-7 naming. Critical bugs (Plan 1): - P4-3+P7-3: ACTION broadcast calls all handlers with panic recovery - P7-2+P7-4: RunE() with defer ServiceShutdown, Run() delegates - P3-1: Startable/Stoppable return Result (breaking, clean) - P9-1: Zero os/exec — App.Find() rewritten with os.Stat+PATH - I3: Embed() removed, I15: New() comment fixed - I9: CommandLifecycle removed → Command.Managed field Registry[T] (Plan 2): - Universal thread-safe named collection with 3 lock modes - All 5 registries migrated: services, commands, drive, data, lock - Insertion order preserved (fixes P4-1) - c.RegistryOf("name") cross-cutting accessor Action/Task system (Plan 3): - Action type with Run()/Exists(), ActionHandler signature - c.Action("name") dual-purpose accessor (register/invoke) - TaskDef with Steps — sequential chain, async dispatch, previous-input piping - Panic recovery on all Action execution - broadcast() internal, ACTION() sugar Process primitive (Plan 4): - c.Process() returns Action sugar — Run/RunIn/RunWithEnv/Start/Kill/Exists - No deps added — delegates to c.Action("process.*") - Permission-by-registration: no handler = no capability Missing primitives (Plan 5): - core.ID() — atomic counter + crypto/rand suffix - ValidateName() / SanitisePath() — reusable validation - Fs.WriteAtomic() — write-to-temp-then-rename - Fs.NewUnrestricted() / Fs.Root() — legitimate sandbox bypass - AX-7: 456/456 tests renamed to TestFile_Function_{Good,Bad,Ugly} Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 15:18:25 +00:00
func TestIpc_QueryAll_Good(t *testing.T) {
c := New()
c.RegisterQuery(func(_ *Core, _ Query) Result {
return Result{Value: "a", OK: true}
})
c.RegisterQuery(func(_ *Core, _ Query) Result {
return Result{Value: "b", OK: true}
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
})
r := c.QUERYALL("anything")
assert.True(t, r.OK)
results := r.Value.([]any)
assert.Len(t, results, 2)
assert.Contains(t, results, "a")
assert.Contains(t, results, "b")
}
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
// --- IPC: Named Action Invocation ---
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
func TestIpc_ActionInvoke_Good(t *testing.T) {
c := New()
c.Action("compute", func(_ context.Context, opts Options) Result {
return Result{Value: 42, OK: true}
})
r := c.Action("compute").Run(context.Background(), NewOptions())
assert.True(t, r.OK)
assert.Equal(t, 42, r.Value)
Implement Background Goroutines for Long-Running Operations (#309) * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. * feat: implement background goroutines for long-running operations Introduced `PerformAsync` in the Core framework to support non-blocking execution of long-running tasks. This mechanism uses the IPC system to broadcast `ActionTaskStarted` and `ActionTaskCompleted` events, ensuring the frontend remains responsive and informed. - Added `PerformAsync(Task) string` to `Core`. - Defined framework-level lifecycle actions: `ActionTaskStarted`, `ActionTaskProgress`, and `ActionTaskCompleted`. - Updated `internal/cmd/dev/service.go` to support `AutoPush` in `TaskWork`, removing interactive prompts during background execution. - Added comprehensive documentation for the background operations pattern in `docs/pkg/PACKAGE_STANDARDS.md`. - Added unit tests for the async task mechanism in `pkg/framework/core/ipc_test.go`. - Fixed formatting in `pkg/io/local/client.go`. * feat: implement background goroutines with progress reporting This version addresses feedback by providing a more complete implementation of the background task mechanism, including progress reporting and demonstrating actual usage in the AI service. - Added `TaskWithID` interface to support task ID injection. - Updated `PerformAsync` to inject IDs and provided `Core.Progress` helper. - Applied background processing pattern to `TaskPrompt` in `agentic` service. - Included a fix for the `auto-merge` CI failure by providing explicit repo context to the `gh` command in a local workflow implementation. - Fixed formatting in `pkg/io/local/client.go` and `pkg/agentic/service.go`. - Updated documentation with the new progress reporting pattern. * feat: implement non-blocking background tasks with progress reporting This submission provides a complete framework-level solution for running long-running operations in the background to prevent UI blocking, addressing previous review feedback. Key changes: - Introduced `PerformAsync(Task) string` in the `Core` framework. - Added `TaskWithID` interface to allow tasks to receive their unique ID. - Provided `Core.Progress` helper for services to report granular updates. - Applied the background pattern to the AI service (`agentic.TaskPrompt`). - Updated the dev service (`TaskWork`) to support an `AutoPush` flag, eliminating interactive prompts during background execution. - Added a local implementation for the `auto-merge` CI workflow to bypass repo context issues and fix the blocking CI failure. - Included comprehensive documentation in `docs/pkg/PACKAGE_STANDARDS.md`. - Resolved formatting discrepancies across the codebase. - Verified functionality with unit tests in `pkg/framework/core/ipc_test.go`. --------- Co-authored-by: Claude <developers@lethean.io> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 10:26:45 +00:00
}