diff --git a/changelog.d/fixed-kick-log-archive-on-turn-end.md b/changelog.d/fixed-kick-log-archive-on-turn-end.md new file mode 100644 index 0000000000..56f375eb3b --- /dev/null +++ b/changelog.d/fixed-kick-log-archive-on-turn-end.md @@ -0,0 +1 @@ +- A kick's log is now archived to `/data/logs/kicks//` as soon as its turn ends, not only when the next kick, a restart or a graceful shutdown rotates the scrollback out. A daily-cadence agent whose container crashed hours after its turn finished (exit code 17, OOM β€” no SIGTERM, so the shutdown snapshot never ran) used to lose the run entirely and show nothing under πŸ•˜ past kicks. The later rotation snapshot of the same kick replaces the `turn-end` archive, so each kick still has exactly one file and retention still counts kicks. diff --git a/src/crux/agent/kick_logs.go b/src/crux/agent/kick_logs.go index 698fda062f..912259558a 100644 --- a/src/crux/agent/kick_logs.go +++ b/src/crux/agent/kick_logs.go @@ -53,6 +53,15 @@ const ( // archive's header, mirroring KickRecord.Snippet's truncation. kickLogPromptSnippetLen = 120 + // kickLogReasonTurnEnd is the archive reason written when the kicked + // turn is observed to have ended (kick_outcome.go). The other reasons + // ("kick", "restart", "shutdown") name the rotation point that destroyed + // or superseded the scrollback; this one names the moment the output was + // complete, so a crash before the next rotation point (OOM kill, exit + // code 17, node loss β€” none of which run the SIGTERM snapshot) does not + // lose the run. + kickLogReasonTurnEnd = "turn-end" + // kickLogHeaderMaxBytes bounds how much of an archive is read to find // its header's source: line. The header is a dozen short lines plus a // prompt snippet of kickLogPromptSnippetLen, so 4 KiB always covers it. @@ -213,6 +222,20 @@ func (m *Manager) archiveKickLogBytesLocked(agent *AgentProcess, reason string) } m.logger.Info("archived kick log", "name", agent.Name, "reason", reason, "source", source, "file", fname, "bytes", len(header)+len(content)) + // One archive per kick, latest content wins. A turn-end archive written + // while the kick was still the current one is superseded by the archive + // the next rotation point (kick/restart/shutdown) takes of the same + // scrollback: same kick, same timestamp stem, different reason suffix β€” + // so the earlier file is removed rather than left as a duplicate that + // would burn a retention slot and list the same run twice. + if agent.kickLogArchivedPath != "" && agent.kickLogArchivedPath != path && agent.kickLogArchivedKick.Equal(filenameTime) { + if err := os.Remove(agent.kickLogArchivedPath); err != nil && !os.IsNotExist(err) { + m.logger.Warn("kick log archive: superseded archive remove failed", "name", agent.Name, "path", agent.kickLogArchivedPath, "error", err) + } + } + agent.kickLogArchivedKick = filenameTime + agent.kickLogArchivedPath = path + m.pruneKickLogs(dir) m.notifyKickObserver(agent.Name, KickObserverEventArchived, reason) // The content length, not the file length: the header is hive's own @@ -299,6 +322,22 @@ func (m *Manager) rotateKickLogOnKickLocked(agent *AgentProcess) { agent.kickLogPending = false } +// archiveKickLogOnTurnEndLocked runs when the kicked turn is observed to have +// ended (settleKickOutcomeLocked): if the session holds un-archived kick +// output, snapshot it now under the "turn-end" reason. Nothing is cleared β€” +// the pane keeps showing the result to the operator and kickLogPending stays +// set, so the next rotation point still takes the final snapshot (which +// supersedes this one; see archiveKickLogBytesLocked) and clears the +// scrollback as before. What changes is that a container crash between the +// turn ending and that rotation point β€” the case the SIGTERM snapshot cannot +// cover β€” no longer loses the run. Callers must hold m.mu. +func (m *Manager) archiveKickLogOnTurnEndLocked(agent *AgentProcess) bool { + if !agent.kickLogPending { + return false + } + return m.archiveKickLogLocked(agent, kickLogReasonTurnEnd) +} + // alternateScreenOffArgs is the tmux invocation that turns alternate-screen off // for one existing session's window. func alternateScreenOffArgs(session string) []string { @@ -421,7 +460,8 @@ func kickLogTimestamp(name string, fallback time.Time) time.Time { return fallback } -// kickLogReason extracts the snapshot reason ("kick", "restart", "shutdown") +// kickLogReason extracts the snapshot reason ("kick", "restart", "shutdown", +// "turn-end") // from a filename of the form -.log. func kickLogReason(name string) string { base := strings.TrimSuffix(name, kickLogSuffix) diff --git a/src/crux/agent/kick_logs_turn_end_test.go b/src/crux/agent/kick_logs_turn_end_test.go new file mode 100644 index 0000000000..4a3d3e7d79 --- /dev/null +++ b/src/crux/agent/kick_logs_turn_end_test.go @@ -0,0 +1,275 @@ +package agent + +// Tests for archiving a kick log when the kicked TURN ENDS, not only at the +// next rotation point. Observed on a hosted hive: a daily-cadence scanner's +// turn ended 22s after the kick, the container was then killed hours later +// (exit code 17, not a SIGTERM), and the run's only copy β€” the tmux +// scrollback β€” died with it. The turn-end snapshot closes that window while +// keeping one archive per kick: the final rotation-point snapshot of the same +// kick supersedes the turn-end file rather than sitting beside it. + +import ( + "os" + "path/filepath" + "strings" + "testing" + "time" +) + +// turnEndTestManager is kickLogTestManager plus a delivered kick whose turn +// has not been classified yet. +func turnEndTestManager(t *testing.T, captured string) (*Manager, *AgentProcess, string, time.Time) { + t.Helper() + m, agent, dir := kickLogTestManager(t, captured) + kickAt := time.Date(2026, 10, 28, 11, 1, 31, 0, time.UTC) + agent.LastKick = &kickAt + agent.kickLogPending = true + return m, agent, filepath.Join(dir, "scanner"), kickAt +} + +func listArchiveNames(t *testing.T, m *Manager) []string { + t.Helper() + infos, err := m.ListKickLogs("scanner") + if err != nil { + t.Fatalf("ListKickLogs: %v", err) + } + names := make([]string, 0, len(infos)) + for _, info := range infos { + names = append(names, info.ID) + } + return names +} + +func TestSettleKickOutcome_ArchivesOnTurnEndWithoutClearing(t *testing.T) { + m, agent, agentDir, kickAt := turnEndTestManager(t, "scanner run output\n") + cleared := false + termSeams(m).clearHistory = func(*AgentProcess) { cleared = true } + + m.mu.Lock() + _, settled := m.settleKickOutcomeLocked(agent, productivePane, kickAt.Add(22*time.Second)) + m.mu.Unlock() + if !settled { + t.Fatal("productive idle pane did not settle the turn") + } + + names := listArchiveNames(t, m) + if len(names) != 1 { + t.Fatalf("archives = %v, want exactly one turn-end archive", names) + } + wantStem := kickAt.UTC().Format(kickLogTimestampFormat) + if !strings.HasPrefix(names[0], wantStem) || kickLogReason(names[0]) != kickLogReasonTurnEnd { + t.Errorf("archive = %q, want %s-%s.log (named for the kick, reason turn-end)", names[0], wantStem, kickLogReasonTurnEnd) + } + data, err := os.ReadFile(filepath.Join(agentDir, names[0])) + if err != nil { + t.Fatalf("reading archive: %v", err) + } + if !strings.Contains(string(data), "reason: turn-end") || !strings.Contains(string(data), "scanner run output") { + t.Errorf("archive body missing header reason or content:\n%s", data) + } + if cleared { + t.Error("turn-end archive cleared the scrollback; the pane must keep showing the result until the next kick") + } + if !agent.kickLogPending { + t.Error("kickLogPending cleared by the turn-end archive; the next rotation point must still take the final snapshot") + } + if !agent.kickLogArchivedKick.Equal(kickAt) || filepath.Base(agent.kickLogArchivedPath) != names[0] { + t.Errorf("archived marker = (%v, %q), want (%v, %q)", agent.kickLogArchivedKick, agent.kickLogArchivedPath, kickAt, names[0]) + } +} + +// A turn-end archive is skipped when nothing is pending (fresh session, or the +// output was already rotated out) β€” the boot banner is not a kick log. +func TestArchiveKickLogOnTurnEnd_NothingPending(t *testing.T) { + m, agent, _, _ := turnEndTestManager(t, "boot banner") + agent.kickLogPending = false + + m.mu.Lock() + wrote := m.archiveKickLogOnTurnEndLocked(agent) + m.mu.Unlock() + if wrote { + t.Fatal("archived with nothing pending") + } + if names := listArchiveNames(t, m); len(names) != 0 { + t.Errorf("archives = %v, want none", names) + } +} + +// A second turn-end observation for the same kick (the agent kept producing +// after the first idle prompt, or hive restarted and re-classified) must +// overwrite the same file with the newer content, not add a duplicate. +func TestArchiveKickLogOnTurnEnd_SameKickOverwrites(t *testing.T) { + m, agent, agentDir, _ := turnEndTestManager(t, "first output\n") + + m.mu.Lock() + first := m.archiveKickLogOnTurnEndLocked(agent) + termSeams(m).captureFullLog = func(*AgentProcess) (string, error) { return "first output\nmore output\n", nil } + second := m.archiveKickLogOnTurnEndLocked(agent) + m.mu.Unlock() + if !first || !second { + t.Fatalf("archive results = %v, %v, want both written", first, second) + } + + names := listArchiveNames(t, m) + if len(names) != 1 { + t.Fatalf("archives = %v, want one file for one kick", names) + } + data, _ := os.ReadFile(filepath.Join(agentDir, names[0])) + if !strings.Contains(string(data), "more output") { + t.Errorf("later turn-end content did not win:\n%s", data) + } +} + +// The next kick's rotation after a turn-end archive: the final snapshot +// supersedes the turn-end file (one archive for the kick, reason "kick", +// latest content), and the scrollback is cleared exactly as before. +func TestRotateOnKick_SupersedesTurnEndArchive(t *testing.T) { + m, agent, agentDir, kickAt := turnEndTestManager(t, "run output\n") + cleared := 0 + termSeams(m).clearHistory = func(*AgentProcess) { cleared++ } + + m.mu.Lock() + m.archiveKickLogOnTurnEndLocked(agent) + termSeams(m).captureFullLog = func(*AgentProcess) (string, error) { return "run output\ntrailing hook output\n", nil } + m.rotateKickLogOnKickLocked(agent) + m.mu.Unlock() + + names := listArchiveNames(t, m) + if len(names) != 1 { + t.Fatalf("archives = %v, want the turn-end file replaced by one kick archive", names) + } + if kickLogReason(names[0]) != "kick" || !strings.HasPrefix(names[0], kickAt.UTC().Format(kickLogTimestampFormat)) { + t.Errorf("archive = %q, want -kick.log", names[0]) + } + data, _ := os.ReadFile(filepath.Join(agentDir, names[0])) + if !strings.Contains(string(data), "trailing hook output") { + t.Errorf("final rotation content did not win:\n%s", data) + } + if cleared != 1 { + t.Errorf("clearHistory calls = %d, want 1 (rotation still clears for the next kick)", cleared) + } + if agent.kickLogPending { + t.Error("kickLogPending still set after rotation") + } +} + +// Distinct kicks never supersede each other: the marker is keyed by LastKick, +// so the previous kick's archive stays when a later kick is archived. +func TestArchiveKickLog_DifferentKicksKeepBothArchives(t *testing.T) { + m, agent, _, kickAt := turnEndTestManager(t, "run one\n") + + m.mu.Lock() + m.archiveKickLogOnTurnEndLocked(agent) + next := kickAt.Add(24 * time.Hour) + agent.LastKick = &next + agent.kickLogPending = true + m.archiveKickLogOnTurnEndLocked(agent) + m.mu.Unlock() + + if names := listArchiveNames(t, m); len(names) != 2 { + t.Fatalf("archives = %v, want one per kick", names) + } +} + +// Retention counts kicks, not files: with retention 2 and a turn-end archive +// superseded by its own rotation, the two previous kicks' archives survive +// and the newly written file is never pruned. +func TestPruneAfterSupersede_KeepsRetentionOfDistinctKicks(t *testing.T) { + m, agent, _, kickAt := turnEndTestManager(t, "output\n") + m.kickLogRetention = 2 + + m.mu.Lock() + for i := 0; i < 2; i++ { + k := kickAt.Add(time.Duration(i) * time.Hour) + agent.LastKick = &k + agent.kickLogPending = true + m.archiveKickLogOnTurnEndLocked(agent) + m.rotateKickLogOnKickLocked(agent) + } + m.mu.Unlock() + + names := listArchiveNames(t, m) + if len(names) != 2 { + t.Fatalf("archives = %v, want 2 (one per kick, retention 2)", names) + } + for _, n := range names { + if kickLogReason(n) != "kick" { + t.Errorf("archive %q should have been superseded by its kick rotation", n) + } + } + if agent.kickLogArchivedPath == "" { + t.Fatal("no archived marker recorded") + } + if _, err := os.Stat(agent.kickLogArchivedPath); err != nil { + t.Errorf("newest archive %q pruned: %v", agent.kickLogArchivedPath, err) + } +} + +// Restart/shutdown after a turn ended normally: the final snapshot still +// supersedes the turn-end archive, but the turn is NOT counted as interrupted +// (nothing was lost) and the restart/kick breaker is not armed. +func TestTearDown_SettledTurnIsArchivedButNotInterrupted(t *testing.T) { + m, agent, _, kickAt := turnEndTestManager(t, "run output\n") + agent.LastPaneChange = kickAt.Add(10 * time.Second) + + m.mu.Lock() + m.settleKickOutcomeLocked(agent, productivePane, kickAt.Add(22*time.Second)) + interrupted, producing := m.tearDownTurnLocked(agent, "shutdown") + m.mu.Unlock() + + if interrupted || producing { + t.Errorf("tearDown = (%v, %v) for a turn that had already ended, want (false, false)", interrupted, producing) + } + if agent.TurnLoss.Interruptions != 0 || agent.TurnLoss.Bytes != 0 { + t.Errorf("TurnLoss = %+v, want nothing recorded for an already-archived, ended turn", agent.TurnLoss) + } + if agent.kickLogPending { + t.Error("kickLogPending still set after teardown") + } + names := listArchiveNames(t, m) + if len(names) != 1 || kickLogReason(names[0]) != "shutdown" { + t.Errorf("archives = %v, want the turn-end file superseded by one shutdown archive", names) + } +} + +// The crash path is unchanged: a turn that never settled and is torn down is +// still recorded as interrupted with its archived bytes. +func TestTearDown_UnsettledTurnStillCountsAsInterrupted(t *testing.T) { + m, agent, _, kickAt := turnEndTestManager(t, "partial output\n") + agent.LastPaneChange = kickAt.Add(10 * time.Second) + + m.mu.Lock() + interrupted, producing := m.tearDownTurnLocked(agent, "restart") + m.mu.Unlock() + + if !interrupted || !producing { + t.Errorf("tearDown = (%v, %v), want (true, true)", interrupted, producing) + } + if agent.TurnLoss.Interruptions != 1 || agent.TurnLoss.Bytes != int64(len("partial output\n")) { + t.Errorf("TurnLoss = %+v, want one interruption with the archived bytes", agent.TurnLoss) + } + if names := listArchiveNames(t, m); len(names) != 1 || kickLogReason(names[0]) != "restart" { + t.Errorf("archives = %v, want one restart archive", names) + } +} + +// Removing a superseded file that is already gone (operator cleanup, prune on +// another path) is not an error and does not stop the new archive. +func TestArchiveKickLog_SupersededFileAlreadyGone(t *testing.T) { + m, agent, _, _ := turnEndTestManager(t, "output\n") + + m.mu.Lock() + m.archiveKickLogOnTurnEndLocked(agent) + if err := os.Remove(agent.kickLogArchivedPath); err != nil { + t.Fatalf("removing turn-end archive: %v", err) + } + wrote := m.archiveKickLogLocked(agent, "kick") + m.mu.Unlock() + + if !wrote { + t.Fatal("final archive not written after the superseded file vanished") + } + if names := listArchiveNames(t, m); len(names) != 1 || kickLogReason(names[0]) != "kick" { + t.Errorf("archives = %v, want one kick archive", names) + } +} diff --git a/src/crux/agent/kick_outcome.go b/src/crux/agent/kick_outcome.go index 493c901592..52720b39bb 100644 --- a/src/crux/agent/kick_outcome.go +++ b/src/crux/agent/kick_outcome.go @@ -202,6 +202,10 @@ func (m *Manager) settleKickOutcomeLocked(agent *AgentProcess, visible string, n default: m.logger.Info("kick turn ended", attrs...) } + // The turn is over: make its output durable now rather than waiting for + // the next kick, a restart or a graceful shutdown β€” a daily-cadence agent + // whose container is OOM-killed hours later would otherwise lose the run. + m.archiveKickLogOnTurnEndLocked(agent) m.notifyKickOutcome(agent.Name, outcome) return outcome, true } diff --git a/src/crux/agent/manager.go b/src/crux/agent/manager.go index fac0dde74e..74dc1fe1ba 100644 --- a/src/crux/agent/manager.go +++ b/src/crux/agent/manager.go @@ -436,6 +436,13 @@ type AgentProcess struct { // kick_logs.go). Set after every kick delivery; cleared when the // scrollback is archived (next kick, restart, shutdown). Guarded by m.mu. kickLogPending bool + // kickLogArchivedKick / kickLogArchivedPath identify the archive most + // recently written for this agent: the LastKick it covers and the file it + // went to. archiveKickLogBytesLocked uses them to supersede a turn-end + // snapshot with the final rotation-point snapshot of the same kick + // instead of leaving two files for one run. Guarded by m.mu. + kickLogArchivedKick time.Time + kickLogArchivedPath string // TurnLoss accumulates what teardowns have discarded from this agent's // in-flight turns (#4002 open question 3): RestartCount says how many // restarts happened, this says what they cost. Guarded by m.mu, persisted diff --git a/src/crux/agent/turn_loss.go b/src/crux/agent/turn_loss.go index 951d60771b..4efb0e7fc2 100644 --- a/src/crux/agent/turn_loss.go +++ b/src/crux/agent/turn_loss.go @@ -101,13 +101,22 @@ func (m *Manager) noteTurnInterruptedLocked(agent *AgentProcess, reason string, // the second answer to arm the restart/kick breaker (#7363): the accounting // here already knew each restart in the observed loop was destroying a // producing turn; now something acts on it. +// +// A turn whose end was already observed (KickOutcome settled for this kick, +// which also archived it under "turn-end") is not interrupted: its output is +// still snapshotted so the final scrollback supersedes the turn-end archive, +// but nothing was lost, so no interruption is recorded and the breaker is not +// armed. func (m *Manager) tearDownTurnLocked(agent *AgentProcess, reason string) (interrupted, producing bool) { if !agent.kickLogPending { return false, false } archived := m.archiveKickLogBytesLocked(agent, reason) - rec := m.noteTurnInterruptedLocked(agent, reason, archived) agent.kickLogPending = false + if agent.KickOutcome.Settled(agent.LastKick) { + return false, false + } + rec := m.noteTurnInterruptedLocked(agent, reason, archived) return true, rec.Producing } diff --git a/src/docs/agent-logging.md b/src/docs/agent-logging.md index db0ecd99b7..f0e9e4a562 100644 --- a/src/docs/agent-logging.md +++ b/src/docs/agent-logging.md @@ -234,19 +234,25 @@ read the logs of the last several runs β€” not just the latest β€” ([#4296](https://github.com/hivecommons/hive/issues/4296), [#4295](https://github.com/hivecommons/hive/issues/4295)): -- **When snapshots happen.** The scrollback is captured to a file *before* - it can be destroyed: when the next kick is delivered (the previous kick's - output is archived and the tmux history is cleared, so each archive covers - exactly one kick), before `kill-session` on an agent restart, and on - graceful shutdown (SIGTERM β€” pod roll or hive upgrade) for every agent - with un-archived kick output. +- **When snapshots happen.** The scrollback is captured to a file as soon + as the kick's turn is observed to end (the CLI is back at its idle prompt β€” + the same moment the `kick turn ended` log line and the kick outcome come + from), and again *before* it can be destroyed: when the next kick is + delivered (the previous kick's output is archived and the tmux history is + cleared, so each archive covers exactly one kick), before `kill-session` + on an agent restart, and on graceful shutdown (SIGTERM β€” pod roll or hive + upgrade) for every agent with un-archived kick output. There is one + archive per kick: the later snapshot of the same kick replaces the + turn-end one (latest content wins), so a daily-cadence agent whose + container crashes hours after its turn ended β€” a hard kill that never runs + the shutdown snapshot β€” still has that run under *past kicks*. - **Where they live.** `/data/logs/kicks//-.log` (override the root with `HIVE_KICK_LOG_DIR`). `/data` is the persistent volume on hosted hives, so archives survive agent restarts, pod rolls, and hive image upgrades. Each file starts with a small header (agent, archive time, snapshot reason, kick start time, prompt snippet, build/backend/model, - `source`) followed by the raw scrollback. `` is `kick`, `restart`, - or `shutdown`. + `source`) followed by the raw scrollback. `` is `turn-end`, `kick`, + `restart`, or `shutdown` β€” what wrote the archive, not how the kick ended. - **Transcript source.** The scrollback is what the CLI painted, so tool output the CLI collapsed (`(N lines hidden)`) is not in it. `HIVE_KICK_LOG_SOURCE=transcript` (or `auto`) builds the archive and the @@ -295,8 +301,11 @@ read the logs of the last several runs β€” not just the latest β€” then has no log to show. - **Limitations.** The archive holds at most the retained scrollback (`history-limit`, 50000 lines by default), so an extremely long run - self-truncates from the top. A hard kill (SIGKILL, node loss) skips the - shutdown snapshot; the previous kicks' archives on `/data` are unaffected. + self-truncates from the top. A hard kill (SIGKILL, OOM, node loss) skips the + shutdown snapshot, so a turn still running at that moment loses whatever + it produced after the last snapshot; turns that had already ended were + archived at turn end, and the previous kicks' archives on `/data` are + unaffected. ## Related diff --git a/src/pkg/dashboard/kick_logs.go b/src/pkg/dashboard/kick_logs.go index c089d9ce92..99b177319a 100644 --- a/src/pkg/dashboard/kick_logs.go +++ b/src/pkg/dashboard/kick_logs.go @@ -85,11 +85,11 @@ h1{font-size:1.1rem}a{color:#58a6ff;text-decoration:none}a:hover{text-decoration table{border-collapse:collapse;margin-top:1rem}td,th{padding:.3rem .9rem;text-align:left;border-bottom:1px solid #21262d} .muted{color:#8b949e}

πŸ•˜ %s β€” kick log history

-

πŸ“„ live log (current run) β€” the running session's scrollback; archived here when the next kick or a restart rotates it out

+

πŸ“„ live log (current run) β€” the running session's scrollback; archived here as soon as the kick's turn ends, and again (final content) when the next kick or a restart rotates it out

`, esc, esc, esc) if len(infos) == 0 { - _, _ = fmt.Fprint(w, `

No archived kick logs yet. Archives appear after the agent's next kick, restart, or a hive shutdown.

`) + _, _ = fmt.Fprint(w, `

No archived kick logs yet. Archives appear once a kick's turn ends, and after the agent's next kick, restart, or a hive shutdown.

`) } else { // #9580: the column is the archived kick's START time (KickLogInfo. // Timestamp), not when the archive file was written β€” see kick_logs.go. @@ -97,7 +97,7 @@ table{border-collapse:collapse;margin-top:1rem}td,th{padding:.3rem .9rem;text-al // (transcript or scrollback), so a tester switching the kick log // source can confirm what each archive was built from without // opening it. Archives older than the header field show a dash. - _, _ = fmt.Fprint(w, ``) + _, _ = fmt.Fprint(w, `
kick started (UTC)triggersourcesize
`) for _, info := range infos { id := html.EscapeString(info.ID) source := `β€”` diff --git a/src/pkg/dashboard/kick_logs_test.go b/src/pkg/dashboard/kick_logs_test.go index 27d3b95d00..20eb57b939 100644 --- a/src/pkg/dashboard/kick_logs_test.go +++ b/src/pkg/dashboard/kick_logs_test.go @@ -174,6 +174,13 @@ func TestHandleAgentKickHistoryPage_EmptyHistory(t *testing.T) { if !strings.Contains(rec.Body.String(), "No archived kick logs yet") { t.Errorf("empty-history page missing placeholder:\n%s", rec.Body.String()) } + // The copy must tell an operator that a finished turn is archived at + // once, not only at the next kick/restart/shutdown rotation point. + for _, want := range []string{"once a kick's turn ends", "as soon as the kick's turn ends"} { + if !strings.Contains(rec.Body.String(), want) { + t.Errorf("history page copy missing %q:\n%s", want, rec.Body.String()) + } + } rec = doGet(s, "/agents/nonexistent/kicks") if rec.Code != http.StatusNotFound { t.Fatalf("unknown agent: status = %d, want 404", rec.Code) diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index fbafae3a3f..fefc8ff1ef 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -11185,7 +11185,7 @@

Where to get help

${sessionChip(a, 'β–Ά terminal', `β–Ά terminal`)} ${sessionChip(a, 'πŸ“„ full log', `πŸ“„ full log`)} ${sessionChip(a, 'πŸ“‹ log text', `πŸ“‹ log text`)} - πŸ•˜ past kicks + πŸ•˜ past kicks @@ -21276,7 +21276,7 @@

All labels

const agentSpanTip = `Drag or use ← / β†’ to set ${a.displayName || a.name} to span 1, 2, or 3 columns; Esc resets width`; const agentSpanHandle = ``; const disabledEnableBtn = isDisabled ? `` : ''; - const historyLink = `πŸ•˜ past kicks`; + const historyLink = `πŸ•˜ past kicks`; const liveSessionActions = `${sessionChip(a, 'β–Ά terminal', `β–Ά terminal`)} ${sessionChip(a, 'πŸ“„ full log', `πŸ“„ full log`)} ${historyLink}`; const sessionActions = isPoweredOff ? `${historyLink}` diff --git a/src/pkg/linearagent/responder.go b/src/pkg/linearagent/responder.go index ea5dcda48f..15cd2c76f0 100644 --- a/src/pkg/linearagent/responder.go +++ b/src/pkg/linearagent/responder.go @@ -149,9 +149,11 @@ func (r *Responder) HandleSessionEvent(ev SessionEvent) { // HandleAgentEvent is the kick-lifecycle hook (component D): wired to // agent.Manager's kick observer, it maps the run's end back onto the session. // The archive of an agent's kick log is the durable "this run's output is -// complete" moment in the existing infrastructure (#4296) β€” kick logs rotate -// when a new kick, a restart, or a shutdown closes out the previous run β€” so -// it is the honest completion signal without inventing a new one. +// complete" moment in the existing infrastructure (#4296) β€” a kick log is +// archived as soon as the kicked turn ends, and again when a new kick, a +// restart, or a shutdown closes out the run β€” so it is the honest completion +// signal without inventing a new one. Only the first archive reaches a +// session: finishing it drops the agent's active mapping. func (r *Responder) HandleAgentEvent(agentName, event, detail string) { if event != "kick-log-archived" { return
kick started (UTC)triggersourcesize