Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-15311-pane-timeout-diagnostics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The fleet self-report feed's diagnostics excerpt is now bounded at 4096 bytes instead of 512: the `agent-runtime` "pane content at timeout" warning logs a `head_500` attribute before `tail_500`, and at the old cap `head_500` alone (worse with multi-byte box-drawing characters) filled the budget and silently dropped `tail_500` — the pane's current state and the only field useful for diagnosing a stuck CLI — every time the warning fired. Self-reports for `agent_pane_timeout` now carry a usable excerpt ([#15311](https://github.com/hivecommons/hive/issues/15311), [#14586](https://github.com/hivecommons/hive/issues/14586)).
15 changes: 14 additions & 1 deletion src/pkg/fleetreport/slogfeed/slogfeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@ const (
maxKeyBytes = 200
// maxDiagnosticsBytes bounds the attribute excerpt attached to the
// observation; the tracker scrubs and bounds again on storage.
maxDiagnosticsBytes = 512
//
// Sized to outlive agent.manager's "pane content at timeout" WARN
// (src/crux/agent/manager.go), whose head_500/tail_500 attrs are each up
// to 500 runes and can run ~1500 bytes apiece when the pane is full of
// multi-byte box-drawing characters (❯, ╰─, ...). diagnostics below
// writes attrs in record order and stops at the first one that would
// cross this cap, so a value too small for head_500 alone drops tail_500
// — the pane's CURRENT state, and the only field useful for diagnosing a
// stuck CLI — every single time. That is exactly what happened at 512
// bytes: hivecommons/hive#14586 and #15311 both self-reported this WARN
// with no usable excerpt attached. 4096 comfortably fits both fields plus
// the preceding flags with room to spare, while staying well under the
// tracker's own 8KiB storage bound.
maxDiagnosticsBytes = 4096
// minLevel is the lowest level the feed observes.
minLevel = slog.LevelWarn
)
Expand Down
42 changes: 42 additions & 0 deletions src/pkg/fleetreport/slogfeed/slogfeed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,48 @@ func TestHandlerWithAttrsCarriesBoundAttrsIntoDiagnostics(t *testing.T) {
}
}

// TestDiagnosticsKeepsBothPaneTimeoutExcerpts regression-tests
// hivecommons/hive#14586 and #15311: the "pane content at timeout" WARN
// (src/crux/agent/manager.go) logs head_500 before tail_500, each up to 500
// runes. At the old 512-byte cap, head_500 alone (worse with multi-byte
// box-drawing characters) filled the budget and diagnostics() dropped
// tail_500 — the pane's current state and the only field useful for
// diagnosing a stuck CLI — before it was ever written.
func TestDiagnosticsKeepsBothPaneTimeoutExcerpts(t *testing.T) {
logger, seen, _ := newFeed(t)
head := strings.Repeat("❯", 500) // worst case: 500 runes, 3 bytes each
tail := strings.Repeat("z", 480) + "TAIL-MARKER-PRESENT"
logger.Warn("pane content at timeout",
"agent", "quality",
"len", 28517,
"has_goose_ready", false,
"has_enter", false,
"has_arrow", true,
"has_question_form", false,
"has_bob_placeholder", false,
"has_codex_ready", false,
"head_500", head,
"tail_500", tail,
)
if len(*seen) != 1 {
t.Fatalf("observed = %+v, want exactly one", *seen)
}
got := (*seen)[0]
if got.class != fleetreport.ClassAgentPaneTimeout {
t.Fatalf("class = %q, want %q", got.class, fleetreport.ClassAgentPaneTimeout)
}
d := got.diagnostics
if !strings.Contains(d, "has_codex_ready=false") {
t.Fatalf("diagnostics dropped a flag before head_500: %q", d)
}
if !strings.Contains(d, "head_500=") {
t.Fatalf("diagnostics missing head_500 entirely: %q", d)
}
if !strings.Contains(d, "TAIL-MARKER-PRESENT") {
t.Fatalf("diagnostics dropped tail_500 (the pane's current state): %q", d)
}
}

func TestKeyBoundsAndNormalises(t *testing.T) {
a := Key("request failed for owner/repo-1 after 3 attempts (id 0123456789abcdef)")
b := Key("request failed for owner/other-9 after 17 attempts (id fedcba9876543210)")
Expand Down
Loading