add observer runtime model

Instrument command, payload, update, scene, runner, polling, and policy flows
Add observer regression coverage and mark observability backlog item done
This commit is contained in:
2026-03-31 13:50:21 +03:00
parent 140f3397b2
commit a818174fbf
18 changed files with 1255 additions and 62 deletions
+10 -18
View File
@@ -322,55 +322,47 @@ func (p *Plugin[T]) Close() error {
}
// Internal helper that validates and executes a command handler.
func (p *Plugin[T]) executeCmd(cmd string, ctx *MsgContext, db T) {
func (p *Plugin[T]) executeCmd(cmd string, ctx *MsgContext, db T) error {
command, exists := p.commands[cmd]
if !exists {
ctx.error(AsInternalError(errCommandNotFound))
return
return AsInternalError(errCommandNotFound)
}
if err := command.validateArgs(ctx.Args); err != nil {
ctx.error(err)
return
return AsUserError(err)
}
// Run command-specific middlewares
for _, m := range command.middlewares {
if !m.Execute(ctx, db) {
return
return AsInternalError(errors.New("middleware blocked call"))
}
}
// Execute command
if err := command.exec(ctx, db); err != nil {
ctx.error(err)
}
return command.exec(ctx, db)
}
// Internal helper that validates and executes a payload handler.
func (p *Plugin[T]) executePayload(payload string, ctx *MsgContext, db T) {
func (p *Plugin[T]) executePayload(payload string, ctx *MsgContext, db T) error {
command, exists := p.payloads[payload]
if !exists {
ctx.error(AsInternalError(errPayloadNotFound))
return
return AsInternalError(errPayloadNotFound)
}
if err := command.validateArgs(ctx.Args); err != nil {
ctx.error(err)
return
return AsUserError(err)
}
// Run command-specific middlewares
for _, m := range command.middlewares {
if !m.Execute(ctx, db) {
return
return AsInternalError(errors.New("middleware blocked call"))
}
}
// Execute payload
if err := command.exec(ctx, db); err != nil {
ctx.error(err)
}
return command.exec(ctx, db)
}
// Internal helper that runs plugin middlewares in order.