package api import ( "go/ast" "go/parser" "go/token" "strings" "testing" ) // R-642 (v0.263.0): a start or restart is never answered "completed" — measured 2026-09-23 on docmost // and romm, both 200 "start completed" while `Restarting (1)` behind a 404 front door. // // COMPANION RED-PROOF (REPORT.md): put `Message: "Stack " + name + " " + action + " completed"` back in // startAnswer — the first assertion fails. func TestR642_StartIsNeverReportedCompleted(t *testing.T) { for _, action := range []string{"start", "restart"} { a := startAnswer("docmost", action, "restarting") if strings.Contains(a.Message, "completed") { t.Errorf("%s answered %q — a start cannot know it completed", action, a.Message) } if !strings.Contains(a.Message, "restarting") { t.Errorf("%s must say the state it sees, got %q", action, a.Message) } if d, _ := a.Data.(map[string]interface{}); d["state"] != "restarting" { t.Errorf("%s data = %v", action, a.Data) } } } // TestR642_TheHandlerUsesStartAnswer walks the router's AST: the stack-action handler must CALL // startAnswer (a comment naming it would not count — the v0.154.0 / R-106 inert-seam class). func TestR642_TheHandlerUsesStartAnswer(t *testing.T) { f, err := parser.ParseFile(token.NewFileSet(), "router.go", nil, 0) if err != nil { t.Fatal(err) } calls := 0 ast.Inspect(f, func(n ast.Node) bool { if c, ok := n.(*ast.CallExpr); ok { if id, ok := c.Fun.(*ast.Ident); ok && id.Name == "startAnswer" { calls++ } } return true }) if calls != 1 { t.Errorf("startAnswer must be called exactly once from router.go, found %d", calls) } }