fix(ci): repair delegation list and merge queue tests
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 24s
Harness Replays / detect-changes (pull_request) Successful in 22s
CI / Detect changes (pull_request) Successful in 1m15s
E2E API Smoke Test / detect-changes (pull_request) Successful in 1m15s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 1m20s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 18s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 1m7s
qa-review / approved (pull_request) Successful in 27s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 45s
security-review / approved (pull_request) Failing after 25s
gate-check-v3 / gate-check (pull_request) Successful in 41s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m33s
sop-tier-check / tier-check (pull_request) Successful in 27s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 1m41s
Harness Replays / Harness Replays (pull_request) Successful in 17s
CI / Canvas (Next.js) (pull_request) Successful in 8s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 6s
CI / Python Lint & Test (pull_request) Successful in 10s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 14s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 7s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2m11s
CI / Platform (Go) (pull_request) Failing after 3m23s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Failing after 3m24s
CI / Canvas Deploy Reminder (pull_request) Successful in 4s
sop-checklist / na-declarations (pull_request) awaiting /sop-n/a declaration for: qa-review, security-review
sop-checklist / all-items-acked (pull_request) [info tier:low] acked: 5/7 — missing: root-cause, no-backwards-compat — body-unfilled: comprehensive-testing, local-postgres-e2e, staging-sm
CI / all-required (pull_request) Successful in 3s

This commit is contained in:
hongming-codex-laptop 2026-05-14 06:17:58 -07:00 committed by Molecule AI Core-BE
parent 4e92e46182
commit 2e3b682e97
3 changed files with 20 additions and 18 deletions

View File

@ -85,7 +85,10 @@ def test_pr_needs_update_when_base_sha_absent_from_commits():
def test_merge_decision_requires_main_green_pr_green_and_current_base():
required = ["CI / all-required (pull_request)"]
main_status = {"state": "success", "statuses": []}
main_status = {
"state": "success",
"statuses": [{"context": "CI / all-required (push)", "status": "success"}],
}
pr_status = {
"state": "success",
"statuses": [{"context": "CI / all-required (pull_request)", "status": "success"}],
@ -104,7 +107,10 @@ def test_merge_decision_requires_main_green_pr_green_and_current_base():
def test_merge_decision_updates_stale_pr_before_merge():
decision = mq.evaluate_merge_readiness(
main_status={"state": "success", "statuses": []},
main_status={
"state": "success",
"statuses": [{"context": "CI / all-required (push)", "status": "success"}],
},
pr_status={"state": "success", "statuses": [{"context": "CI / all-required (pull_request)", "status": "success"}]},
required_contexts=["CI / all-required (pull_request)"],
pr_has_current_base=False,

View File

@ -2,6 +2,7 @@ package handlers
import (
"context"
"database/sql"
"encoding/json"
"log"
"net/http"
@ -698,7 +699,8 @@ func (h *DelegationHandler) listDelegationsFromLedger(ctx context.Context, works
var result []map[string]interface{}
for rows.Next() {
var delegationID, callerID, calleeID, taskPreview, status, resultPreview, errorDetail string
var delegationID, callerID, calleeID, taskPreview, status string
var resultPreview, errorDetail sql.NullString
var lastHeartbeat, deadline, createdAt, updatedAt *time.Time
if err := rows.Scan(
&delegationID, &callerID, &calleeID, &taskPreview,
@ -717,11 +719,11 @@ func (h *DelegationHandler) listDelegationsFromLedger(ctx context.Context, works
"updated_at": updatedAt,
"_ledger": true, // marker so callers know this row is from the ledger
}
if resultPreview != "" {
entry["response_preview"] = textutil.TruncateBytes(resultPreview, 300)
if resultPreview.Valid && resultPreview.String != "" {
entry["response_preview"] = textutil.TruncateBytes(resultPreview.String, 300)
}
if errorDetail != "" {
entry["error"] = errorDetail
if errorDetail.Valid && errorDetail.String != "" {
entry["error"] = errorDetail.String
}
if lastHeartbeat != nil {
entry["last_heartbeat"] = lastHeartbeat

View File

@ -145,7 +145,6 @@ func TestListDelegationsFromLedger_MultipleRows(t *testing.T) {
}
}
=======
func TestListDelegationsFromLedger_NullsOmitted(t *testing.T) {
// last_heartbeat, deadline, result_preview, error_detail are all NULL.
// Handler must not panic and must omit those keys from the map.
@ -158,7 +157,11 @@ func TestListDelegationsFromLedger_NullsOmitted(t *testing.T) {
t.Cleanup(func() { mockDB.Close(); db.DB = prevDB })
now := time.Now()
rows := sqlmock.NewRows([]string{}).
rows := sqlmock.NewRows([]string{
"delegation_id", "caller_id", "callee_id", "task_preview",
"status", "result_preview", "error_detail",
"last_heartbeat", "deadline", "created_at", "updated_at",
}).
AddRow("del-1", "ws-1", "ws-2", "task", "queued", nil, nil, nil, nil, now, now)
mock.ExpectQuery("SELECT .+ FROM delegations").
WithArgs("ws-1").
@ -190,7 +193,6 @@ func TestListDelegationsFromLedger_NullsOmitted(t *testing.T) {
}
}
>>>>>>> 5531b471 (handlers: restore db.DB after each test to fix CI/Platform (Go) race failures)
func TestListDelegationsFromLedger_QueryError(t *testing.T) {
// Query failure returns nil — graceful fallback, no panic.
mockDB, mock, err := sqlmock.New()
@ -484,11 +486,3 @@ func TestListDelegationsFromActivityLogs_RowsErr(t *testing.T) {
t.Errorf("sqlmock expectations: %v", err)
}
}
<<<<<<< HEAD
// TestListDelegationsFromActivityLogs_ScanErrorSkipped is removed.
//
// Same reason as TestListDelegationsFromLedger_ScanError: Go 1.25 causes
// sqlmock.NewRows([]string{}).AddRow(...) to panic in test SETUP. The handler
// has no recover(), so a scan panic would crash the process — the correct
// behaviour. Real-DB integration tests cover this path.