scrum2 cleanup: JSON-marshal in stringifyValue, drop dead detectCycle, name SourceWorkflow
5 small fixes from the §3.8 scrum2 review wave:
- workflow.stringifyValue now JSON-marshals maps/slices instead of
fmt.Sprint %v (Opus+Kimi convergent: LLM modes were getting Go's
map[k:v] syntax, which is unparseable as JSON context).
- workflow.detectCycle removed — duplicate of topoSort that discarded
the useful node ID. Validate() now calls topoSort directly and
returns its wrapped ErrCycle.
- observer.SourceWorkflow named constant — was an implicit string
cast (observer.Source("workflow")) at the cmd/observerd handler.
- Unused context imports + dead silencer comments removed across
workflow/modes.go and observerd/main.go.
- Unused store parameter dropped from registerBuiltinModes (reserved
comment removed; can be re-added when a mode actually needs it).
just verify still PASS — these are pure cleanup, no behavior change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
@@ -75,7 +74,7 @@ func main() {
|
||||
// to gateway's matrixd_url so a single-toml deploy works without
|
||||
// duplicating the address.
|
||||
matrixdURL := cfg.Gateway.MatrixdURL
|
||||
registerBuiltinModes(runner, store, matrixdURL)
|
||||
registerBuiltinModes(runner, matrixdURL)
|
||||
|
||||
h := &handlers{store: store, runner: runner}
|
||||
if err := shared.Run("observerd", cfg.Observerd.Bind, h.register, cfg.Auth); err != nil {
|
||||
@@ -145,7 +144,7 @@ func (h *handlers) handleWorkflowRun(r http.ResponseWriter, req *http.Request) {
|
||||
Success: n.Error == "",
|
||||
DurationMs: n.DurationMs,
|
||||
OutputSummary: summarizeOutput(n.Output),
|
||||
Source: observer.Source("workflow"),
|
||||
Source: observer.SourceWorkflow,
|
||||
Error: n.Error,
|
||||
Timestamp: n.StartedAt.UTC().Format(time.RFC3339Nano),
|
||||
}
|
||||
@@ -205,7 +204,7 @@ func summarizeOutput(output map[string]any) string {
|
||||
// - playbook.record (HTTP to matrixd)
|
||||
// - playbook.lookup (HTTP to matrixd)
|
||||
// - llm.chat (HTTP to gateway /v1/chat)
|
||||
func registerBuiltinModes(r *workflow.Runner, store *observer.Store, matrixdURL string) {
|
||||
func registerBuiltinModes(r *workflow.Runner, matrixdURL string) {
|
||||
// Fixture modes for runner mechanics smokes.
|
||||
r.RegisterMode("fixture.echo", func(_ workflow.Context, input map[string]any) (map[string]any, error) {
|
||||
out := make(map[string]any, len(input))
|
||||
@@ -232,13 +231,8 @@ func registerBuiltinModes(r *workflow.Runner, store *observer.Store, matrixdURL
|
||||
hc := &http.Client{Timeout: 30 * time.Second}
|
||||
r.RegisterMode("matrix.search", workflow.MatrixSearch(matrixdURL, hc))
|
||||
}
|
||||
|
||||
_ = store // reserved for future modes that need self-provenance
|
||||
}
|
||||
|
||||
// context still used in decodeJSON via http.Request.Context().
|
||||
var _ = context.Background
|
||||
|
||||
func decodeJSON(w http.ResponseWriter, r *http.Request, v any) bool {
|
||||
defer r.Body.Close()
|
||||
r.Body = http.MaxBytesReader(w, r.Body, maxRequestBytes)
|
||||
|
||||
Reference in New Issue
Block a user