2026-03-21 10:05:04 +00:00
|
|
|
|
# AX Package Standards
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
This page describes how to build packages on top of CoreGO in the style described by RFC-025.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 1. Prefer Predictable Names
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Use names that tell an agent what the thing is without translation.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Good:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
- `RepositoryService`
|
|
|
|
|
|
- `RepositoryServiceOptions`
|
|
|
|
|
|
- `WorkspaceCountQuery`
|
|
|
|
|
|
- `SyncRepositoryTask`
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Avoid shortening names unless the abbreviation is already universal.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 2. Put Real Usage in Comments
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Write comments that show a real call with realistic values.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Good:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
// Sync a repository into the local workspace cache.
|
|
|
|
|
|
// svc.SyncRepository("core-go", "/srv/repos/core-go")
|
2026-01-30 19:48:28 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Avoid comments that only repeat the signature.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 3. Keep Paths Semantic
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
If a command or template lives at a path, let the path explain the intent.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Good:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
```text
|
|
|
|
|
|
deploy/to/homelab
|
|
|
|
|
|
workspace/create
|
|
|
|
|
|
template/workspace/go
|
2026-01-30 19:48:28 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
That keeps the CLI, tests, docs, and message vocabulary aligned.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 4. Reuse CoreGO Primitives
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
At Core boundaries, prefer the shared shapes:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
- `core.Options` for lightweight input
|
|
|
|
|
|
- `core.Result` for output
|
|
|
|
|
|
- `core.Service` for lifecycle registration
|
|
|
|
|
|
- `core.Message`, `core.Query`, `core.Task` for bus protocols
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Inside your package, typed structs are still good. Use `ServiceRuntime[T]` when you want typed package options plus a `Core` reference.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
type repositoryServiceOptions struct {
|
|
|
|
|
|
BaseDirectory string
|
2026-01-30 19:48:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
type repositoryService struct {
|
|
|
|
|
|
*core.ServiceRuntime[repositoryServiceOptions]
|
2026-01-30 19:48:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 5. Prefer Explicit Registration
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Register services and commands with names and paths that stay readable in grep results.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
c.Service("repository", core.Service{...})
|
|
|
|
|
|
c.Command("repository/sync", core.Command{...})
|
2026-01-30 19:48:28 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 6. Use the Bus for Decoupling
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
When one package needs another package’s behavior, prefer queries and tasks over tight package coupling.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
type repositoryCountQuery struct{}
|
|
|
|
|
|
type syncRepositoryTask struct {
|
|
|
|
|
|
Name string
|
2026-01-30 19:48:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
That keeps the protocol visible in code and easy for agents to follow.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 7. Use Structured Errors
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Use `core.E`, `core.Wrap`, and `core.WrapCode`.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
return core.Result{
|
|
|
|
|
|
Value: core.E("repository.Sync", "git fetch failed", err),
|
|
|
|
|
|
OK: false,
|
2026-01-30 19:48:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Do not introduce free-form `fmt.Errorf` chains in framework code.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 8. Keep Testing Names Predictable
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Follow the repository pattern:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
- `_Good`
|
|
|
|
|
|
- `_Bad`
|
|
|
|
|
|
- `_Ugly`
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Example:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
|
|
|
|
|
```go
|
2026-03-21 10:05:04 +00:00
|
|
|
|
func TestRepositorySync_Good(t *testing.T) {}
|
|
|
|
|
|
func TestRepositorySync_Bad(t *testing.T) {}
|
|
|
|
|
|
func TestRepositorySync_Ugly(t *testing.T) {}
|
2026-01-30 19:48:28 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 9. Prefer Stable Shapes Over Clever APIs
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
For package APIs, avoid patterns that force an agent to infer too much hidden control flow.
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Prefer:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
- clear structs
|
|
|
|
|
|
- explicit names
|
|
|
|
|
|
- path-based commands
|
|
|
|
|
|
- visible message types
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
Avoid:
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
- implicit global state unless it is truly a default service
|
|
|
|
|
|
- panic-hiding constructors
|
|
|
|
|
|
- dense option chains when a small explicit struct would do
|
2026-01-30 19:48:28 +00:00
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
## 10. Document the Current Reality
|
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
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
If the implementation is in transition, document what the code does now, not the API shape you plan to have later.
|
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
|
|
|
|
|
2026-03-21 10:05:04 +00:00
|
|
|
|
That keeps agents correct on first pass, which is the real AX metric.
|