2026-03-30 10:35:08 +00:00
|
|
|
# Core API Contract (RFC)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
This file is the canonical API catalog for `dappco.re/go/core`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
- Exports follow the `core.Result` contract (`{Value any, OK bool}`) for outcomes.
|
|
|
|
|
- Inputs are passed as `core.Options` collections of `core.Option` key-value pairs.
|
|
|
|
|
- All method and function examples below compile against current repository behavior.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 1) Core construction and top-level bootstrap types
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type CoreOption func(*Core) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
func customOption(*core.Core) core.Result
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func New(opts ...CoreOption) *Core`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(
|
|
|
|
|
core.WithOption("name", "agent"),
|
|
|
|
|
core.WithService(process.Register),
|
|
|
|
|
core.WithServiceLock(),
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WithOptions(opts Options) CoreOption`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(core.WithOptions(core.NewOptions(
|
|
|
|
|
core.Option{Key: "name", Value: "agent"},
|
|
|
|
|
)))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WithService(factory func(*Core) Result) CoreOption`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(core.WithService(process.Register))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WithName(name string, factory func(*Core) Result) CoreOption`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(core.WithName("process", process.Register))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WithOption(key string, value any) CoreOption`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(
|
|
|
|
|
core.WithOption("name", "agent"),
|
|
|
|
|
core.WithOption("debug", true),
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WithServiceLock() CoreOption`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := core.New(
|
|
|
|
|
core.WithService(auth.Register),
|
|
|
|
|
core.WithServiceLock(),
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ServiceFactory func() Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type ServiceFactory func() core.Result
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func NewWithFactories(app any, factories map[string]ServiceFactory) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := core.NewWithFactories(nil, map[string]core.ServiceFactory{
|
|
|
|
|
"audit": func() core.Result {
|
|
|
|
|
return core.Result{Value: mySvc(core.NewServiceRuntime(core.Core, core.MyOptions{})), OK: true}
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
if !r.OK { panic(r.Value) }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func NewRuntime(app any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := core.NewRuntime(nil)
|
|
|
|
|
runtime := r.Value.(*core.Runtime)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Runtime struct`
|
|
|
|
|
|
|
|
|
|
- `app any`
|
|
|
|
|
- `Core *Core`
|
|
|
|
|
|
|
|
|
|
#### `func (r *Runtime) ServiceName() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
name := rt.ServiceName() // "Core"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (r *Runtime) ServiceStartup(ctx context.Context, options any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := rt.ServiceStartup(context.Background(), nil)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (r *Runtime) ServiceShutdown(ctx context.Context) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := rt.ServiceShutdown(context.Background())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 2) Core accessors and lifecycle
|
|
|
|
|
|
|
|
|
|
### `type Core struct`
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Options() *Options`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
name := c.Options().String("name")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) App() *App`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
appName := c.App().Name
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Data() *Data`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().ReadString("brain/prompt.md")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Drive() *Drive`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Drive().Get("api")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Fs() *Fs`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Write("status.json", "ok")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Config() *Config`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Config().Set("debug", true)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Error() *ErrorPanic`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
defer c.Error().Recover()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Log() *ErrorLog`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Log().Info("boot")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Cli() *Cli`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Cli().SetBanner(func(_ *core.Cli) string { return "agent" })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) IPC() *Ipc`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.RegisterAction(func(_ *core.Core, _ core.Message) core.Result { return core.Result{OK: true} })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) I18n() *I18n`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.I18n().Language()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Env(key string) string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
home := c.Env("DIR_HOME")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Context() context.Context`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
goCtx := c.Context()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Core() *Core`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
self := c.Core()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) RunE() error`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
if err := c.RunE(); err != nil { /* handle */ }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Run()`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Run()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) ACTION(msg Message) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.ACTION(core.ActionServiceStartup{})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) QUERY(q Query) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.QUERY(core.NewOptions(core.Option{Key: "name", Value: "agent"}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) QUERYALL(q Query) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.QUERYALL(core.NewOptions())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) LogError(err error, op, msg string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.LogError(err, "core.Start", "startup failed")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) LogWarn(err error, op, msg string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.LogWarn(err, "agent.Check", "warning")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Must(err error, op, msg string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Must(err, "core.op", "must hold")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) RegistryOf(name string) *Registry[any]`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
svcNames := c.RegistryOf("services").Names()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 3) Service and lifecycle discovery APIs
|
|
|
|
|
|
|
|
|
|
### `type Service struct`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type Service struct {
|
|
|
|
|
Name string
|
|
|
|
|
Instance any
|
|
|
|
|
Options Options
|
|
|
|
|
OnStart func() Result
|
|
|
|
|
OnStop func() Result
|
|
|
|
|
OnReload func() Result
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Service(name string, service ...Service) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Service("cache", core.Service{
|
|
|
|
|
OnStart: func() core.Result { return core.Result{OK: true} },
|
|
|
|
|
OnStop: func() core.Result { return core.Result{OK: true} },
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RegisterService(name string, instance any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.RegisterService("process", processSvc)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Services() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
names := c.Services()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Lock(name string) *Lock`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
l := c.Lock("agent")
|
|
|
|
|
l.Mutex.Lock()
|
|
|
|
|
defer l.Mutex.Unlock()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) LockEnable(name ...string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.LockEnable()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) LockApply(name ...string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.LockApply()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Startables() Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Startables()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Stoppables() Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Stoppables()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) ServiceStartup(ctx context.Context, options any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.ServiceStartup(context.Background(), nil)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) ServiceShutdown(ctx context.Context) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.ServiceShutdown(context.Background())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ServiceRuntime[T any]`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
sr := core.NewServiceRuntime(c, MyServiceOptions{})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func NewServiceRuntime[T any](c *Core, opts T) *ServiceRuntime[T]`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
sr := core.NewServiceRuntime(c, core.MyOpts{})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (r *ServiceRuntime[T]) Core() *Core`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c := sr.Core()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (r *ServiceRuntime[T]) Options() T`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
opts := sr.Options()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (r *ServiceRuntime[T]) Config() *Config`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
cfg := sr.Config()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ServiceRegistry struct`
|
|
|
|
|
|
|
|
|
|
`*Registry[*Service]` + `lockEnabled bool`.
|
|
|
|
|
|
|
|
|
|
### `func ServiceFor[T any](c *Core, name string) (T, bool)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
svc, ok := core.ServiceFor[*myService](c, "myservice")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func MustServiceFor[T any](c *Core, name string) T`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
svc := core.MustServiceFor[*myService](c, "myservice")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Startable interface { OnStartup(context.Context) Result }`
|
|
|
|
|
|
|
|
|
|
### `type Stoppable interface { OnShutdown(context.Context) Result }`
|
|
|
|
|
|
|
|
|
|
## 4) Actions, Tasks, and message-driven capability primitives
|
|
|
|
|
|
|
|
|
|
### `type ActionHandler func(context.Context, Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
var h ActionHandler = func(ctx context.Context, opts core.Options) core.Result { return core.Result{OK: true} }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Action struct`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
a := c.Action("process.run")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *Action) Run(ctx context.Context, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := a.Run(ctx, core.NewOptions(core.Option{Key: "command", Value: "go test"}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *Action) Exists() bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
if c.Action("process.run").Exists() { /* invoke */ }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Action(name string, handler ...ActionHandler) *Action`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Action("agent.echo", func(_ context.Context, opts core.Options) core.Result {
|
|
|
|
|
return core.Result{Value: opts.String("msg"), OK: true}
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Actions() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
names := c.Actions()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Step struct`
|
|
|
|
|
|
|
|
|
|
`Action`, `With`, `Async`, `Input`.
|
|
|
|
|
|
|
|
|
|
### `type Task struct`
|
|
|
|
|
|
|
|
|
|
`Name`, `Description`, `Steps`.
|
|
|
|
|
|
|
|
|
|
#### `func (t *Task) Run(ctx context.Context, c *Core, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Task("deploy").Run(ctx, c, core.NewOptions())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Task(name string, def ...Task) *Task`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Task("deploy", core.Task{Steps: []core.Step{{Action: "agent.echo", Async: false}}})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Tasks() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
for _, n := range c.Tasks() {}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Message any`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.ACTION(core.ActionTaskStarted{TaskIdentifier: "t1", Action: "agent.echo"})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Query any`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type statusQuery struct{}
|
|
|
|
|
_ = statusQuery{}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type QueryHandler func(*Core, Query) Result`
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Query(q Query) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Query(core.Query("ping"))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) QueryAll(q Query) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.QueryAll(core.Query("ping"))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RegisterQuery(handler QueryHandler)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.RegisterQuery(func(_ *core.Core, _ core.Query) core.Result { return core.Result{Value: "pong", OK: true} })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RegisterAction(handler func(*Core, Message) Result)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.RegisterAction(func(_ *core.Core, msg core.Message) core.Result { return core.Result{OK: true} })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RegisterActions(handlers ...func(*Core, Message) Result)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.RegisterActions(h1, h2)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RemoteAction(name string, ctx context.Context, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.RemoteAction("charon:agent.status", ctx, core.NewOptions())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ActionServiceStartup struct{}`
|
|
|
|
|
### `type ActionServiceShutdown struct{}`
|
|
|
|
|
|
|
|
|
|
### `type ActionTaskStarted struct`
|
|
|
|
|
|
|
|
|
|
`TaskIdentifier`, `Action`, `Options`.
|
|
|
|
|
|
|
|
|
|
### `type ActionTaskProgress struct`
|
|
|
|
|
|
|
|
|
|
`TaskIdentifier`, `Action`, `Progress`, `Message`.
|
|
|
|
|
|
|
|
|
|
### `type ActionTaskCompleted struct`
|
|
|
|
|
|
|
|
|
|
`TaskIdentifier`, `Action`, `Result`.
|
|
|
|
|
|
|
|
|
|
## 5) Remote API and stream transport
|
|
|
|
|
|
|
|
|
|
### `type Stream interface`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
type Stream interface {
|
|
|
|
|
Send(data []byte) error
|
|
|
|
|
Receive() ([]byte, error)
|
|
|
|
|
Close() error
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type StreamFactory func(handle *DriveHandle) (Stream, error)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
var f core.StreamFactory = func(h *core.DriveHandle) (core.Stream, error) { return nil, nil }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type API struct`
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) API() *API`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.API()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *API) RegisterProtocol(scheme string, factory StreamFactory)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.API().RegisterProtocol("mcp", mcpStreamFactory)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *API) Stream(name string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.API().Stream("api")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *API) Call(endpoint, action string, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.API().Call("api", "agent.status", core.NewOptions())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a *API) Protocols() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
names := c.API().Protocols()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 6) Command and CLI layer
|
|
|
|
|
|
|
|
|
|
### `type CliOptions struct{}`
|
|
|
|
|
### `type Cli struct`
|
|
|
|
|
|
|
|
|
|
#### `func CliRegister(c *Core) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = core.CliRegister(c)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Cli) Print(format string, args ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
cl.Print("starting %s", "agent")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Cli) SetOutput(w io.Writer)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
cl.SetOutput(os.Stderr)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Cli) Run(args ...string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := cl.Run("deploy", "to", "homelab")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Cli) PrintHelp()`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
cl.PrintHelp()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Core) SetBanner(fn func(*Cli) string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
cl.SetBanner(func(_ *core.Cli) string { return "agent-cli" })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cl *Cli) Banner() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
label := cl.Banner()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type CommandAction func(Options) Result`
|
|
|
|
|
|
|
|
|
|
### `type Command struct`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Command("deploy", core.Command{Action: func(opts core.Options) core.Result {
|
|
|
|
|
return core.Result{Value: "ok", OK: true}
|
|
|
|
|
}})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cmd *Command) I18nKey() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
key := c.Command("deploy/to/homelab").Value.(*core.Command).I18nKey()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cmd *Command) Run(opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := cmd.Run(core.NewOptions(core.Option{Key: "name", Value: "x"}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (cmd *Command) IsManaged() bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
if cmd.IsManaged() { /* managed lifecycle */ }
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type CommandRegistry struct`
|
|
|
|
|
|
|
|
|
|
`*Registry[*Command]`.
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Command(path string, command ...Command) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Command("agent/deploy", core.Command{
|
|
|
|
|
Action: func(opts core.Options) core.Result { return core.Result{OK: true} },
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Commands() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
paths := c.Commands()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Command` fields
|
|
|
|
|
`Name`, `Description`, `Path`, `Action`, `Managed`, `Flags`, `Hidden`, internal `commands`.
|
|
|
|
|
|
|
|
|
|
## 7) Subsystems: App, Data, Drive, Fs, I18n, Process
|
|
|
|
|
|
|
|
|
|
### `type App struct`
|
|
|
|
|
|
|
|
|
|
#### `func (a App) New(opts Options) App`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
app := (core.App{}).New(core.NewOptions(
|
|
|
|
|
core.Option{Key: "name", Value: "agent"},
|
|
|
|
|
))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (a App) Find(filename, name string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := core.App{}.Find("go", "Go")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Data struct`
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) New(opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().New(core.NewOptions(
|
|
|
|
|
core.Option{Key: "name", Value: "brain"},
|
|
|
|
|
core.Option{Key: "source", Value: brainFS},
|
|
|
|
|
core.Option{Key: "path", Value: "prompts"},
|
|
|
|
|
))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) ReadFile(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().ReadFile("brain/readme.md")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) ReadString(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().ReadString("brain/readme.md")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) List(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().List("brain/templates")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) ListNames(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().ListNames("brain/templates")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) Extract(path, targetDir string, templateData any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Data().Extract("brain/template", "/tmp/ws", map[string]string{"Name": "demo"})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (d *Data) Mounts() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
for _, m := range c.Data().Mounts() {}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type DriveHandle struct`
|
|
|
|
|
|
|
|
|
|
`Name`, `Transport`, `Options`.
|
|
|
|
|
|
|
|
|
|
### `type Drive struct`
|
|
|
|
|
|
|
|
|
|
#### `func (d *Drive) New(opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Drive().New(core.NewOptions(
|
|
|
|
|
core.Option{Key: "name", Value: "mcp"},
|
|
|
|
|
core.Option{Key: "transport", Value: "mcp://localhost:1234"},
|
|
|
|
|
))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Fs struct`
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) New(root string) *Fs`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
fs := (&core.Fs{}).New("/tmp")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) NewUnrestricted() *Fs`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
fs := (&core.Fs{}).NewUnrestricted()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Root() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
root := c.Fs().Root()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Read(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Read("status.txt")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Write(p, content string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().Write("status.txt", "ok")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) WriteMode(p, content string, mode os.FileMode) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().WriteMode("secret", "x", 0600)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) TempDir(prefix string) string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
tmp := c.Fs().TempDir("agent-")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) WriteAtomic(p, content string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().WriteAtomic("status.json", "{\"ok\":true}")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) EnsureDir(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().EnsureDir("cache")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) IsDir(p string) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
ok := c.Fs().IsDir("cache")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) IsFile(p string) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
ok := c.Fs().IsFile("go.mod")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Exists(p string) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
if c.Fs().Exists("go.mod") {}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) List(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().List(".")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Stat(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Stat("go.mod")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Open(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Open("go.mod")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Create(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Create("notes.txt")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Append(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().Append("notes.txt")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Rename(oldPath, newPath string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().Rename("a.txt", "b.txt")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) Delete(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().Delete("tmp.txt")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) DeleteAll(p string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = c.Fs().DeleteAll("tmpdir")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) ReadStream(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().ReadStream("go.mod")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (m *Fs) WriteStream(path string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Fs().WriteStream("go.mod")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Package functions in `fs.go`
|
|
|
|
|
|
|
|
|
|
### `func DirFS(dir string) fs.FS`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
fsys := core.DirFS("/tmp")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func ReadAll(reader any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := core.ReadAll(c.Fs().ReadStream("go.mod").Value)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func WriteAll(writer any, content string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := core.WriteAll(c.Fs().WriteStream("out.txt").Value, "value")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func CloseStream(v any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
core.CloseStream(handle)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type I18n struct`
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) AddLocales(mounts ...*Embed)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.I18n().AddLocales(emb)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) Locales() Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.I18n().Locales()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) SetTranslator(t Translator)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.I18n().SetTranslator(translator)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) Translator() Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.I18n().Translator()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) Translate(messageID string, args ...any) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.I18n().Translate("cmd.deploy.description")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) SetLanguage(lang string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.I18n().SetLanguage("de")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) Language() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
lang := c.I18n().Language()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (i *I18n) AvailableLanguages() []string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
langs := c.I18n().AvailableLanguages()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Process struct`
|
|
|
|
|
|
|
|
|
|
#### `func (c *Core) Process() *Process`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
p := c.Process()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) Run(ctx context.Context, command string, args ...string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Process().Run(ctx, "git", "status")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) RunIn(ctx context.Context, dir, command string, args ...string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Process().RunIn(ctx, "/tmp", "go", "test", "./...")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) RunWithEnv(ctx context.Context, dir string, env []string, command string, args ...string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Process().RunWithEnv(ctx, "/", []string{"CI=true"}, "go", "version")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) Start(ctx context.Context, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Process().Start(ctx, core.NewOptions(core.Option{Key: "command", Value: "sleep"}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) Kill(ctx context.Context, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Process().Kill(ctx, core.NewOptions(core.Option{Key: "id", Value: "1234"))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (p *Process) Exists() bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
if c.Process().Exists() {}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 8) Task/background execution and progress
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) PerformAsync(action string, opts Options) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.PerformAsync("agent.dispatch", core.NewOptions(core.Option{Key: "id", Value: 1}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) Progress(taskID string, progress float64, message string, action string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Progress(taskID, 0.5, "halfway", "agent.dispatch")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func (c *Core) RegisterAction(handler func(*Core, Message) Result)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.RegisterAction(func(_ *core.Core, msg core.Message) core.Result {
|
|
|
|
|
_ = msg
|
|
|
|
|
return core.Result{OK: true}
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## 9) Logging and output
|
|
|
|
|
|
|
|
|
|
### `type Level int`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
const (
|
|
|
|
|
core.LevelQuiet Level = iota
|
|
|
|
|
core.LevelError
|
|
|
|
|
core.LevelWarn
|
|
|
|
|
core.LevelInfo
|
|
|
|
|
core.LevelDebug
|
|
|
|
|
)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l Level) String() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
s := core.LevelInfo.String()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type Log struct`
|
|
|
|
|
|
|
|
|
|
#### `func NewLog(opts LogOptions) *Log`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger := core.NewLog(core.LogOptions{Level: core.LevelDebug})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) SetLevel(level Level)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.SetLevel(core.LevelWarn)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Level() Level`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
lvl := logger.Level()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) SetOutput(w io.Writer)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.SetOutput(os.Stderr)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) SetRedactKeys(keys ...string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.SetRedactKeys("token", "password")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Debug(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.Debug("booted", "pid", 123)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Info(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.Info("agent started")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Warn(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.Warn("disk nearly full")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Error(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.Error("failed to bind", "err", err)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (l *Log) Security(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
logger.Security("sandbox escape", "attempt", path)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ErrorLog struct`
|
|
|
|
|
|
|
|
|
|
#### `func (el *ErrorLog) Error(err error, op, msg string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Log().Error(err, "core.Run", "startup failed")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (el *ErrorLog) Warn(err error, op, msg string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Log().Warn(err, "warn", "soft error")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (el *ErrorLog) Must(err error, op, msg string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Log().Must(err, "core.maybe", "must hold")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type ErrorPanic struct`
|
|
|
|
|
|
|
|
|
|
#### `func (h *ErrorPanic) Recover()`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
defer c.Error().Recover()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (h *ErrorPanic) SafeGo(fn func())`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
c.Error().SafeGo(func() { panic("boom") })
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (h *ErrorPanic) Reports(n int) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r := c.Error().Reports(3)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type LogErr struct`
|
|
|
|
|
|
|
|
|
|
#### `func NewLogErr(log *Log) *LogErr`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
le := core.NewLogErr(core.Default())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (le *LogErr) Log(err error)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
le.Log(err)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `type LogPanic struct`
|
|
|
|
|
|
|
|
|
|
#### `func NewLogPanic(log *Log) *LogPanic`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
lp := core.NewLogPanic(core.Default())
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
#### `func (lp *LogPanic) Recover()`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
defer lp.Recover()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Package-level logger helpers
|
|
|
|
|
|
|
|
|
|
`Default`, `SetDefault`, `SetLevel`, `SetRedactKeys`, `Debug`, `Info`, `Warn`, `Error`, `Security`.
|
|
|
|
|
|
|
|
|
|
### `func Default() *Log`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
l := core.Default()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func SetDefault(l *Log)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
core.SetDefault(core.NewLog(core.LogOptions{Level: core.LevelDebug}))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func SetLevel(level Level)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
core.SetLevel(core.LevelInfo)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func SetRedactKeys(keys ...string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
core.SetRedactKeys("password")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func Debug(msg string, keyvals ...any)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
core.Debug("start")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Info(msg string, keyvals ...any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.Info("ready")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Warn(msg string, keyvals ...any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
core.Warn("high load")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Error(msg string, keyvals ...any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
core.Error("failure", "err", err)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Security(msg string, keyvals ...any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.Security("policy", "event", "denied")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type LogOptions struct`
|
|
|
|
|
|
|
|
|
|
`Level`, `Output`, `Rotation`, `RedactKeys`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type RotationLogOptions struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Filename`, `MaxSize`, `MaxAge`, `MaxBackups`, `Compress`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `var RotationWriterFactory func(RotationLogOptions) io.WriteCloser`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.RotationWriterFactory = myFactory
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Username() string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
u := core.Username()
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 10) Error model and diagnostics
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Err struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Operation`, `Message`, `Cause`, `Code`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Err) Error() string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
_ = err.Error()
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Err) Unwrap() error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
_ = errors.Unwrap(err)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func E(op, msg string, err error) error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.E("core.Run", "startup failed", err)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Wrap(err error, op, msg string) error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.Wrap(err, "api.Call", "request failed")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func WrapCode(err error, code, op, msg string) error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.WrapCode(err, "NOT_AUTHORIZED", "api.Call", "forbidden")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func NewCode(code, msg string) error`
|
2026-03-25 16:40:47 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
_ = core.NewCode("VALIDATION", "invalid input")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func NewError(text string) error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
_ = core.NewError("boom")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func ErrorJoin(errs ...error) error`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
err := core.ErrorJoin(e1, e2, e3)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func ErrorMessage(err error) string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
msg := core.ErrorMessage(err)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func ErrorCode(err error) string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
code := core.ErrorCode(err)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Operation(err error) string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
op := core.Operation(err)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Root(err error) error`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
root := core.Root(err)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func AllOperations(err error) iter.Seq[string]`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
for op := range core.AllOperations(err) { fmt.Println(op) }
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func StackTrace(err error) []string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
stack := core.StackTrace(err)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func FormatStackTrace(err error) string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
fmt.Println(core.FormatStackTrace(err))
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func As(err error, target any) bool`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
var ee *core.Err
|
|
|
|
|
_ = core.As(err, &ee)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Is(err, target error) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = core.Is(err, io.EOF)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type CrashReport struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type CrashSystem struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 11) Asset packing and embed helpers
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type AssetGroup struct`
|
|
|
|
|
### `type AssetRef struct`
|
|
|
|
|
### `type ScannedPackage struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func AddAsset(group, name, data string)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.AddAsset("g", "n", "payload")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func GetAsset(group, name string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.GetAsset("g", "n")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func GetAssetBytes(group, name string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.GetAssetBytes("g", "n")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func ScanAssets(filenames []string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.ScanAssets([]string{"main.go"})
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func GeneratePack(pkg ScannedPackage) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.GeneratePack(scanned)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Mount(fsys fs.FS, basedir string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.Mount(appFS, "assets")
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### `func MountEmbed(efs embed.FS, basedir string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.MountEmbed(efs, "assets")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Extract(fsys fs.FS, targetDir string, data any, opts ...ExtractOptions) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.Extract(embeds, "/tmp/out", map[string]string{"Name": "demo"})
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type ExtractOptions struct`
|
|
|
|
|
`TemplateFilters []string`, `IgnoreFiles map[string]struct{}`, `RenameFiles map[string]string`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Embed struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) Open(name string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := emb.Open("readme.md")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) ReadDir(name string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := emb.ReadDir("templates")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) ReadFile(name string) Result`
|
2026-03-25 16:44:39 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := emb.ReadFile("readme.md")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) ReadString(name string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := emb.ReadString("readme.md")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) Sub(subDir string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := emb.Sub("assets")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) FS() fs.FS`
|
2026-03-25 16:44:39 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
fsys := emb.FS()
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) EmbedFS() embed.FS`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
efs := emb.EmbedFS()
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Embed) BaseDirectory() string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
base := emb.BaseDirectory()
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 12) Configuration and primitives
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Option struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
opt := core.Option{Key: "name", Value: "agent"}
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type ConfigVar[T any]`
|
2026-03-25 16:40:47 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func NewConfigVar[T any](val T) ConfigVar[T]`
|
2026-03-25 16:40:47 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
v := core.NewConfigVar("blue")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (v *ConfigVar[T]) Get() T`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
val := v.Get()
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (v *ConfigVar[T]) Set(val T)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v.Set("red")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (v *ConfigVar[T]) IsSet() bool`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
if v.IsSet() {}
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (v *ConfigVar[T]) Unset()`
|
2026-03-25 16:40:47 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v.Unset()
|
2026-03-25 16:40:47 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type ConfigOptions struct`
|
|
|
|
|
`Settings map[string]any`, `Features map[string]bool`.
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Config struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) New() *Config`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
cfg := (&core.Config{}).New()
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Set(key string, val any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
cfg.Set("port", 8080)
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Get(key string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := cfg.Get("port")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) String(key string) string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v := cfg.String("port")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Int(key string) int`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
v := cfg.Int("retries")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Bool(key string) bool`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v := cfg.Bool("debug")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Enable(feature string)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
e.Enable("tracing")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Disable(feature string)`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
e.Disable("tracing")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) Enabled(feature string) bool`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
if e.Enabled("tracing") {}
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (e *Config) EnabledFeatures() []string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
features := e.EnabledFeatures()
|
|
|
|
|
```
|
2026-03-25 16:44:39 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func ConfigGet[T any](e *Config, key string) T`
|
2026-03-25 17:40:55 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
limit := core.ConfigGet[int](cfg, "retries")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Options struct`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func NewOptions(items ...Option) Options`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
opts := core.NewOptions(core.Option{Key: "name", Value: "x"})
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o *Options) Set(key string, value any)`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
opts.Set("debug", true)
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Get(key string) Result`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := opts.Get("debug")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Has(key string) bool`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
if opts.Has("debug") {}
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) String(key string) string`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v := opts.String("name")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Int(key string) int`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
v := opts.Int("port")
|
|
|
|
|
```
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Bool(key string) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
b := opts.Bool("debug")
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Len() int`
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
n := opts.Len()
|
|
|
|
|
```
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (o Options) Items() []Option`
|
2026-03-25 11:17:48 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
all := opts.Items()
|
|
|
|
|
```
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Result struct`
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r Result) Result(args ...any) Result`
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.Result{}.Result(file, err)
|
2026-03-25 11:17:48 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r Result) New(args ...any) Result`
|
2026-03-25 11:17:48 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.Result{}.New(file, nil)
|
2026-03-25 11:17:48 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r Result) Get() Result`
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
v := r.Get()
|
|
|
|
|
```
|
2026-03-25 11:17:48 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func JSONMarshal(v any) Result`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.JSONMarshal(map[string]string{"k": "v"})
|
|
|
|
|
```
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func JSONMarshalString(v any) string`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
s := core.JSONMarshalString(map[string]any{"k": "v"})
|
|
|
|
|
```
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func JSONUnmarshal(data []byte, target any) Result`
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.JSONUnmarshal([]byte(`{"x":1}`), &cfg)
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func JSONUnmarshalString(s string, target any) Result`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.JSONUnmarshalString(`{"x":1}`, &cfg)
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 13) Registry primitive
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Registry[T any] struct`
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func NewRegistry[T any]() *Registry[T]`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.NewRegistry[*core.Service]()
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Set(name string, item T) Result`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r.Set("process", svc)
|
|
|
|
|
```
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Get(name string) Result`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
got := r.Get("process")
|
|
|
|
|
```
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Has(name string) bool`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
if r.Has("process") {}
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Names() []string`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
for _, n := range r.Names() {}
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
```
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) List(pattern string) []T`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
vals := r.List("process.*")
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Each(fn func(string, T))`
|
feat(rfc): Section 18 — Action and Task execution primitives
Action = named, registered callable. The atomic unit of work.
Task = composition of Actions (chain, parallel, conditional, scheduled).
Key design:
- c.Action("name", handler) registers, c.Action("name").Run() invokes
- Services register actions during OnStartup (same as commands)
- Namespace IS capability map (process.*, agentic.*, brain.*)
- Registration IS permission — no action = no capability
- Current IPC verbs (ACTION/QUERY/PERFORM) become invocation modes
- c.Process() is sugar over process.* actions
- Tasks compose Actions into flows (sequential, parallel, conditional, cron)
- Action registry is queryable — agents inspect capabilities before using
Sections: 18.1-18.10 covering concept, API, registration, permission,
task composition (chain/parallel/conditional/scheduled), IPC mapping,
process integration, and registry inspection.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:24:44 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r.Each(func(name string, v *core.Service) {})
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Len() int`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
n := r.Len()
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Delete(name string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = r.Delete("legacy")
|
2026-03-25 11:46:36 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Disable(name string) Result`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
_ = r.Disable("legacy")
|
2026-03-25 11:46:36 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Enable(name string) Result`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
_ = r.Enable("legacy")
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Disabled(name string) bool`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
if r.Disabled("legacy") {}
|
2026-03-25 11:46:36 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Lock()`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
r.Lock()
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Locked() bool`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
locked := r.Locked()
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Seal()`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r.Seal()
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Sealed() bool`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
if r.Sealed() {}
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (r *Registry[T]) Open()`
|
2026-03-25 11:46:36 +00:00
|
|
|
|
fix(rfc): pass 3 — rewrite Sections 18, 19, 20 to match implementation
Section 18: Removed PERFORM references, ActionDef→Action, TaskDef→Task,
OnStartup returns Result, removed aspirational patterns (Parallel,
Conditional, Scheduled), kept what's implemented.
Section 19: Removed old struct definition, Stream returns Result not
(Stream, error), RemoteAction uses c.RemoteAction() not c.Action(),
removed stale subsystem map, added Web3 snider.lthn example.
Section 20: Removed migration history (20.1 The Problem, 20.6-20.8),
kept the API contract. Added 20.6 "What Embeds Registry" reference.
4193 → 1519 lines (64% reduction total).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 16:51:51 +00:00
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r.Open()
|
2026-03-25 11:46:36 +00:00
|
|
|
```
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 14) Entitlement and security policy hooks
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Entitlement struct`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Allowed`, `Unlimited`, `Limit`, `Used`, `Remaining`, `Reason`.
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func (e Entitlement) NearLimit(threshold float64) bool`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
if e.NearLimit(0.8) {}
|
2026-03-25 12:13:19 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func (e Entitlement) UsagePercent() float64`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
pct := e.UsagePercent()
|
2026-03-25 12:13:19 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type EntitlementChecker func(action string, quantity int, ctx context.Context) Entitlement`
|
|
|
|
|
### `type UsageRecorder func(action string, quantity int, ctx context.Context)`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (c *Core) Entitled(action string, quantity ...int) Entitlement`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
e := c.Entitled("process.run")
|
2026-03-25 12:13:19 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (c *Core) SetEntitlementChecker(checker EntitlementChecker)`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
c.SetEntitlementChecker(myChecker)
|
2026-03-25 12:13:19 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (c *Core) RecordUsage(action string, quantity ...int)`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
c.RecordUsage("process.run")
|
|
|
|
|
```
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (c *Core) SetUsageRecorder(recorder UsageRecorder)`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
c.SetUsageRecorder(myRecorder)
|
2026-03-25 12:13:19 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 15) Generic and helper collections
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Array[T comparable]`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func NewArray[T comparable](items ...T) *Array[T]`
|
2026-03-25 12:13:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr := core.NewArray("a", "b")
|
|
|
|
|
```
|
2026-03-25 11:46:36 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Add(values ...T)`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr.Add("c")
|
|
|
|
|
```
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) AddUnique(values ...T)`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
arr.AddUnique("a")
|
2026-03-25 11:13:35 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Contains(val T) bool`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
_ = arr.Contains("a")
|
|
|
|
|
```
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Filter(fn func(T) bool) Result`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := arr.Filter(func(v string) bool { return v != "x" })
|
|
|
|
|
```
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Each(fn func(T))`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr.Each(func(v string) {})
|
2026-03-25 11:13:35 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Remove(val T)`
|
2026-03-25 11:13:35 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr.Remove("b")
|
|
|
|
|
```
|
2026-03-25 13:23:19 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Deduplicate()`
|
2026-03-25 13:21:11 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr.Deduplicate()
|
|
|
|
|
```
|
2026-03-25 16:01:59 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Len() int`
|
2026-03-25 16:01:59 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
n := arr.Len()
|
|
|
|
|
```
|
2026-03-25 16:01:59 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) Clear()`
|
2026-03-25 16:01:59 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
arr.Clear()
|
|
|
|
|
```
|
2026-03-25 16:01:59 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func (s *Array[T]) AsSlice() []T`
|
2026-03-25 12:30:03 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
vals := arr.AsSlice()
|
|
|
|
|
```
|
2026-03-25 12:30:03 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 16) String and path utility API
|
2026-03-25 12:30:03 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### String helpers
|
|
|
|
|
- `HasPrefix`, `HasSuffix`, `TrimPrefix`, `TrimSuffix`, `Contains`, `Split`, `SplitN`, `Join`, `Replace`, `Lower`, `Upper`, `Trim`, `RuneCount`, `NewBuilder`, `NewReader`, `Sprint`, `Sprintf`, `Concat`.
|
2026-03-25 12:30:03 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
core.Join("/", "deploy", "to", "homelab")
|
|
|
|
|
core.Concat("cmd.", "deploy", ".description")
|
|
|
|
|
```
|
2026-03-25 12:30:03 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### Path helpers
|
|
|
|
|
- `Path`, `PathBase`, `PathDir`, `PathExt`, `PathIsAbs`, `JoinPath`, `CleanPath`, `PathGlob`.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
core.Path("Code", "agent")
|
|
|
|
|
core.PathIsAbs("/tmp")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func JoinPath(segments ...string) string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
p := core.JoinPath("workspace", "deploy", "main.go")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### Generic I/O helpers
|
|
|
|
|
- `Arg`, `ArgString`, `ArgInt`, `ArgBool`, `ParseFlag`, `FilterArgs`, `IsFlag`, `ID`, `ValidateName`, `SanitisePath`.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
id := core.ID()
|
|
|
|
|
name := core.ValidateName("agent").Value
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### Package-level functions in this section
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func Print(w io.Writer, format string, args ...any)`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.Print(os.Stderr, "hello %s", "world")
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func Println(args ...any)`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
core.Println("ready")
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func Arg(index int, args ...any) Result`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
r := core.Arg(0, "x", 1)
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ArgString(index int, args ...any) string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v := core.ArgString(0, "x", 1)
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ArgInt(index int, args ...any) int`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
v := core.ArgInt(1, "x", 42)
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ArgBool(index int, args ...any) bool`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
v := core.ArgBool(2, true)
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func IsFlag(arg string) bool`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
ok := core.IsFlag("--debug")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ParseFlag(arg string) (string, string, bool)`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
key, val, ok := core.ParseFlag("--name=agent")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func FilterArgs(args []string) []string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
clean := core.FilterArgs(os.Args[1:])
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ID() string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
id := core.ID()
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func ValidateName(name string) Result`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
r := core.ValidateName("deploy")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func SanitisePath(path string) string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
safe := core.SanitisePath("../../etc")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
#### `func DirFS(dir string) fs.FS`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
root := core.DirFS("/tmp")
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 17) System and environment helpers
|
|
|
|
|
|
|
|
|
|
### `func Env(key string) string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
home := core.Env("DIR_HOME")
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func EnvKeys() []string`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
keys := core.EnvKeys()
|
|
|
|
|
```
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `func Username() string`
|
|
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
who := core.Username()
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 18) Remaining interfaces and types
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type ErrorSink interface`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Error(msg string, keyvals ...any)` and `Warn(msg string, keyvals ...any)`.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Stream interface`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Send`, `Receive`, `Close` as above.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Translator interface`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Translate`, `SetLanguage`, `Language`, `AvailableLanguages`.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type LocaleProvider interface`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
`Locales() *Embed`.
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Runtime helpers`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
- `type Ipc` (named fields, no exported methods)
|
|
|
|
|
- `type Lock struct{ Name string; Mutex *sync.RWMutex }`
|
|
|
|
|
- `type SysInfo struct{ values map[string]string }`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Ipc struct`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
ipc := c.IPC()
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type Lock struct`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
|
|
|
|
```go
|
2026-03-30 10:35:08 +00:00
|
|
|
guard := c.Lock("core-bootstrap")
|
|
|
|
|
guard.Mutex.Lock()
|
|
|
|
|
defer guard.Mutex.Unlock()
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
### `type SysInfo struct`
|
2026-03-25 15:23:00 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
```go
|
|
|
|
|
// SysInfo values are accessed through Env()/EnvKeys(); direct type construction is not required.
|
|
|
|
|
home := core.Env("DIR_HOME")
|
|
|
|
|
keys := core.EnvKeys()
|
2026-03-25 15:23:00 +00:00
|
|
|
```
|
|
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
## 19) Legacy behavior notes
|
feat: add docs/RFC.md — CoreGO API contract specification
Full API spec covering all 16 subsystems: Core container, primitives
(Option/Options/Result), service system, IPC (ACTION/QUERY/PERFORM),
Config, Data, Drive, Fs, CLI, error handling, logging, strings, paths,
utils, locks, ServiceRuntime.
An agent can write a Core service from this document alone.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-25 11:01:58 +00:00
|
|
|
|
2026-03-30 10:35:08 +00:00
|
|
|
- `Service` lifecycle callbacks are the DTO fields `OnStart` and `OnStop`.
|
|
|
|
|
- `Startable`/`Stoppable` are the interface contracts and map to `OnStartup(context.Context)` / `OnShutdown(context.Context)`.
|
|
|
|
|
- Registry iteration (`Names`, `List`, `Each`, `Services`, `Startables`, `Stoppables`) is insertion-order based via `Registry.order`.
|