H-300: wire Captain Skills into Web runtime (#48)

* H-300: wire Captain Skills into Web runtime

* H-300: enforce effective model and conservative skill budget

* H-300: fix CI gosec step

* ci: extend golangci-lint timeout

* fix lint findings across backend

* fix(push): resolve delivery protocol blockers

* test(repository): close SQLite test databases

* test(repository): reuse SQLite schema per package

* H-307: restore backend Go cache in CI

* H-307: prefetch modules before cold lint

* H-307: resolve govulncheck security gate

* H-307: build lint with patched Go toolchain

* H-307: clear remaining security scan findings

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-19 07:08:14 +08:00
committed by GitHub
co-authored by rogee
parent f50eacdc92
commit 2b182f9956
224 changed files with 3814 additions and 10626 deletions
@@ -254,7 +254,9 @@ func (s *MessageHandlerTestSuite) TestList_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
data, ok := resp["payload"].([]interface{})
assert.True(s.T(), ok)
assert.GreaterOrEqual(s.T(), len(data), 1)
@@ -274,7 +276,9 @@ func (s *MessageHandlerTestSuite) TestList_Empty() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
data, ok := resp["payload"].([]interface{})
assert.True(s.T(), ok)
assert.Equal(s.T(), 0, len(data))
@@ -303,7 +307,9 @@ func (s *MessageHandlerTestSuite) TestList_BeforeAfterMessageFinder() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var beforeResp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &beforeResp)
if err := json.Unmarshal(w.Body.Bytes(), &beforeResp); err != nil {
panic(err)
}
beforePayload := beforeResp["payload"].([]interface{})
assert.Len(s.T(), beforePayload, 3)
assert.Equal(s.T(), float64(ids[0]), beforePayload[0].(map[string]interface{})["id"])
@@ -315,7 +321,9 @@ func (s *MessageHandlerTestSuite) TestList_BeforeAfterMessageFinder() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var afterResp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &afterResp)
if err := json.Unmarshal(w.Body.Bytes(), &afterResp); err != nil {
panic(err)
}
afterPayload := afterResp["payload"].([]interface{})
assert.Len(s.T(), afterPayload, 2)
assert.Equal(s.T(), float64(ids[3]), afterPayload[0].(map[string]interface{})["id"])
@@ -348,7 +356,9 @@ func (s *MessageHandlerTestSuite) TestCreate_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.NotNil(s.T(), resp["id"])
assert.Equal(s.T(), "New message", resp["content"])
assert.Equal(s.T(), float64(1), resp["message_type"])
@@ -463,7 +473,9 @@ func (s *MessageHandlerTestSuite) TestCreate_ChatwootFrontendPayloadDefaultsOutg
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "Frontend payload", resp["content"])
assert.Equal(s.T(), float64(s.testAccount.ID), resp["account_id"])
assert.Equal(s.T(), float64(s.testInbox.ID), resp["inbox_id"])
@@ -504,7 +516,9 @@ func (s *MessageHandlerTestSuite) TestCreate_MultipartAttachmentPersistsAndSeria
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
attachments, ok := resp["attachments"].([]interface{})
assert.True(s.T(), ok)
assert.Len(s.T(), attachments, 1)
@@ -558,7 +572,9 @@ func (s *MessageHandlerTestSuite) TestGet_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), float64(s.testMessage.ID), resp["id"])
assert.Equal(s.T(), "Hello world", resp["content"])
assert.Equal(s.T(), float64(*s.testConv.DisplayID), resp["conversation_id"])
@@ -600,7 +616,9 @@ func (s *MessageHandlerTestSuite) TestUpdate_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "Hello world", resp["content"])
assert.Equal(s.T(), "delivered", resp["status"])
}
@@ -623,7 +641,9 @@ func (s *MessageHandlerTestSuite) TestUpdate_StatusExternalError() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "failed", resp["status"])
attrs := resp["content_attributes"].(map[string]interface{})
assert.Equal(s.T(), "provider rejected message", attrs["external_error"])
@@ -670,7 +690,9 @@ func (s *MessageHandlerTestSuite) TestDelete_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "This message was deleted", resp["content"])
attrs := resp["content_attributes"].(map[string]interface{})
assert.Equal(s.T(), true, attrs["deleted"])
@@ -706,7 +728,9 @@ func (s *MessageHandlerTestSuite) TestRetry_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), float64(s.testMessage.ID), resp["id"])
assert.Equal(s.T(), float64(1), resp["message_type"])
assert.Equal(s.T(), "sent", resp["status"])
@@ -769,7 +793,9 @@ func (s *MessageHandlerTestSuite) TestTranslate_Success() {
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "Bonjour le monde", resp["content"])
}
@@ -883,7 +909,9 @@ func (s *MessageHandlerTestSuite) TestTranslate_EmptyChoices() {
// Empty choices → translated_content is empty string → still returns 200 OK
assert.Equal(s.T(), http.StatusOK, w.Code)
var resp map[string]interface{}
json.Unmarshal(w.Body.Bytes(), &resp)
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
panic(err)
}
assert.Equal(s.T(), "", resp["content"])
}