Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Forward Assistant stream deadlines through API status middleware
pulse-triage[bot]7db0b33983b7
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex 2065f7a51c..8da31705bd 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -18,7 +18,8 @@### Assistant result streams do not own agent execution lifetimeAssistant HTTP result readers recheck current token authority at their serialized-writer, including deadline control. Token withdrawal denies further Assistant+writer, including deadline control forwarded through the outer API status/error+wrapper without exposing its raw writer. Token withdrawal denies further Assistantoutput; it does not introduce an agent disconnect, deployment cancellation orcommand-cancellation operation. Legacy execute and alert investigation retaintheir independent 15/5-minute work bounds; chat retains request cancellation.diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex 30b20e2977..3558d4e608 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -37,7 +37,9 @@ A frame admitted before concurrent withdrawal can already be in flight.The guard exposes deadline setters, not an unguarded response-writer escape:Assistant handlers still clear the initial server deadlines and bound each-write. Closure joins active transport writes and rejects queued/late callbacks.+write. The outer API error/status wrapper forwards these same two controls+without exposing its raw writer; native short-server-deadline regressions run+all three actual routes past that initial deadline. Closure joins active transport writes and rejects queued/late callbacks.Legacy execute and investigation keep their independent background executionand original 15/5-minute bounds; denying their read is not cancelling their work,and HTTP completion can therefore wait for that work. Chat keeps its existingdiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 7352726b39..95ad6a1963 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -27,7 +27,8 @@ The shared API stream guard also covers Assistant results, not recovery-statemutation. Current API-token refusal suppresses subsequent response frames andretains the admitted organisation; it never deletes stored evidence, clears arecovery marker or cancels an independent recovery job. Deadline forwarding does-not expose an unguarded writer. Legacy Assistant work remains background-bound;+not expose an unguarded writer, including through the outer API status/error+wrapper. Legacy Assistant work remains background-bound;chat remains request-bound. Native Assistant independent-reader/lifetime andpersisted-token-delete regressions in `internal/api/` pin this boundary usingsynthetic text, not a recovery replay or customer workload.diff --git a/internal/api/assistant_stream_lifetime_test.go b/internal/api/assistant_stream_lifetime_test.goindex 0e040a6393..bdba4c5987 100644--- a/internal/api/assistant_stream_lifetime_test.go+++ b/internal/api/assistant_stream_lifetime_test.go@@ -5,6 +5,7 @@ import ("encoding/json""fmt""io"+ "net""net/http""net/http/httptest""strings"@@ -63,7 +64,7 @@ type assistantStreamFixture struct {otherCalls atomic.Int32}-func newAssistantStreamFixture(t *testing.T, kind string, scopes []string) *assistantStreamFixture {+func newAssistantStreamFixture(t *testing.T, kind string, scopes []string, writeTimeout ...time.Duration) *assistantStreamFixture {t.Helper()f := &assistantStreamFixture{kind: kind, primary: newAssistantProviderGate(), control: newAssistantProviderGate()}f.licensed.Store(true)@@ -141,7 +142,22 @@ func newAssistantStreamFixture(t *testing.T, kind string, scopes []string) *assi}t.Cleanup(func() { _ = f.router.aiHandler.Stop(context.Background()) })}- f.server = newIPv4HTTPServer(t, f.router.Handler())+ if len(writeTimeout) == 0 {+ f.server = newIPv4HTTPServer(t, f.router.Handler())+ } else {+ // Set before Start: an initial server deadline must really be cleared+ // through the complete Router/middleware/guard chain, not a test writer.+ server := httptest.NewUnstartedServer(f.router.Handler())+ _ = server.Listener.Close()+ listener, err := net.Listen("tcp4", "127.0.0.1:0")+ if err != nil {+ t.Fatal(err)+ }+ server.Listener = listener+ server.Config.WriteTimeout = writeTimeout[0]+ server.Start()+ f.server = server+ }t.Cleanup(f.server.Close)t.Cleanup(func() { f.primary.unblock(); f.control.unblock() })return f@@ -386,3 +402,17 @@ func TestAssistantStreamsPreserveExecutionLifetimes(t *testing.T) {})}}++func TestAssistantStreamsClearNativeServerDeadline(t *testing.T) {+ for _, kind := range []string{"execute", "investigate-alert", "chat"} {+ t.Run(kind, func(t *testing.T) {+ f := newAssistantStreamFixture(t, kind, []string{assistantScope(kind)}, 100*time.Millisecond)+ response := f.open(t, "primary", f.token, "header")+ // The initial HTTP deadline has passed, but this stream was+ // deliberately admitted with a longer execution/write budget.+ time.Sleep(200 * time.Millisecond)+ f.primary.unblock()+ readAssistantResult(t, response, true)+ })+ }+}diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 79d7e519f1..db22df1dd2 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -29001,3 +29001,10 @@ func TestContract_AssistantStreamsWithdrawAfterPersistedTokenDelete(t *testing.T})}}++// The production middleware is part of the transport contract, not merely a+// recorder used for direct handler tests. All three native journeys must live+// past the server's initial write deadline without bypassing the guard.+func TestContract_AssistantStreamDeadlineSurvivesAPIWrappers(t *testing.T) {+ TestAssistantStreamsClearNativeServerDeadline(t)+}diff --git a/internal/api/middleware.go b/internal/api/middleware.goindex 0dc0d0cbca..2294706ba8 100644--- a/internal/api/middleware.go+++ b/internal/api/middleware.go@@ -168,6 +168,17 @@ type responseWriter struct {written bool}+// Keep ResponseController deadline operations available to streaming handlers.+// Do not expose Unwrap: transports can forward these controls without creating+// an unguarded response-writer escape for callers further inside the chain.+func (rw *responseWriter) SetWriteDeadline(deadline time.Time) error {+ return http.NewResponseController(rw.ResponseWriter).SetWriteDeadline(deadline)+}++func (rw *responseWriter) SetReadDeadline(deadline time.Time) error {+ return http.NewResponseController(rw.ResponseWriter).SetReadDeadline(deadline)+}+func (rw *responseWriter) WriteHeader(code int) {if !rw.written {rw.statusCode = code