Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Preserve Patrol controls during full-mode activation

rcourtman21e0b40363f8
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 079b8c93d4..e429f9a2a9 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -5604,6 +5604,9 @@ Task 08 actor/RBAC/approval boundary, Task 07 dispatch contract, and Task 10
two-axis result contract. API tokens are ineligible for the human Autopilot
acknowledgement even where an owner-bound token remains compatible with an
authenticated action capability.
+Consuming that acknowledgement at the API gate changes only the effective
+tenant Patrol mode: omitted investigation budget and timeout controls remain
+unchanged and cannot be synthesized as zero-valued lifecycle authority.
### Task 07 generic durable agent-operation receipts and Task 09 APT adapter
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index 89e9c7da5d..80b364b223 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -7117,6 +7117,9 @@ admission through the existing Task 04 policy-mutation coordinator. The API
handler and every tenant AI service share the same injected server clock and
current-version provider, so a newly supported contract cannot activate at the
API boundary while remaining stale in the runtime that enforces Patrol mode.
+When that API gate consumes an acknowledgement and normalizes the downstream
+paid-handler request, it must preserve omitted investigation budget and timeout
+fields as omitted so a mode-only activation cannot reset existing controls.
The accepted limits promise only policy allowlisting, emergency-stop and
approval-floor enforcement, reconciliation when supported, disclosed evidence
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index ecfe4daf8a..fd18a8ba26 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -8717,6 +8717,9 @@ boolean, the current expected versioned contract, and the selected record's
version/status metadata without rewriting historical evidence. Stable failure codes distinguish
missing, stale, wrong-organization, wrong-actor, expired, revoked, malformed,
conflicting, and unavailable-store evidence.
+The full-mode acknowledgement gate consumes `acknowledgement_id` before strict
+paid-handler decoding but must preserve omitted investigation budget and timeout
+fields as omitted; a mode-only activation cannot reset existing controls.
Paid adapters may return a compact mutation acknowledgement from `PUT`; it is
not the canonical effective-state projection. First-party clients must follow
diff --git a/internal/api/ai_handlers.go b/internal/api/ai_handlers.go
index ea4b2ce8b3..2f55b9638a 100644
--- a/internal/api/ai_handlers.go
+++ b/internal/api/ai_handlers.go
@@ -7982,6 +7982,18 @@ type PatrolAutonomySettings struct {
InvestigationTimeoutSec int `json:"investigation_timeout_sec"` // Max seconds per investigation (60-1800)
}
+// patrolAutonomyGateSettings preserves whether optional investigation controls
+// were present while the full-mode gate consumes acknowledgement_id. The paid
+// handler owns partial-update semantics and must not receive fabricated zeroes
+// for fields the caller omitted.
+type patrolAutonomyGateSettings struct {
+ AutonomyLevel string `json:"autonomy_level"`
+ FullModeUnlocked *bool `json:"full_mode_unlocked,omitempty"`
+ AcknowledgementID string `json:"acknowledgement_id,omitempty"`
+ InvestigationBudget *int `json:"investigation_budget,omitempty"`
+ InvestigationTimeoutSec *int `json:"investigation_timeout_sec,omitempty"`
+}
+
// PatrolAutonomyResponse represents the patrol autonomy configuration for API responses
// Uses plain bool for FullModeUnlocked since responses always include the actual value
type PatrolAutonomyResponse struct {
@@ -8259,7 +8271,7 @@ func (h *AISettingsHandler) GatePatrolAutonomyUpdate(next http.HandlerFunc) http
writeErrorResponse(w, http.StatusBadRequest, "invalid_request", "Invalid Patrol autonomy request", nil)
return
}
- var settings PatrolAutonomySettings
+ var settings patrolAutonomyGateSettings
if err := decodeStrictPatrolAutopilotJSONBytes(body, &settings); err != nil {
writeErrorResponse(w, http.StatusBadRequest, "invalid_request", "Invalid Patrol autonomy request", nil)
return
diff --git a/internal/api/patrol_autopilot_test.go b/internal/api/patrol_autopilot_test.go
index 9018c0384c..27c720c088 100644
--- a/internal/api/patrol_autopilot_test.go
+++ b/internal/api/patrol_autopilot_test.go
@@ -290,6 +290,49 @@ func TestPatrolAutopilotActivationForwardsStrictDecodableBody(t *testing.T) {
}
}
+func TestPatrolAutopilotActivationPreservesOmittedInvestigationControls(t *testing.T) {
+ now := time.Date(2026, 8, 17, 18, 0, 0, 0, time.UTC)
+ handler, _ := newPatrolAutopilotTestHandler(t, "org-a", &now)
+
+ created := createPatrolAutopilotAcknowledgement(t, handler, "org-a", "alice", "session-partial", "ack-partial-001")
+ if created.Code != http.StatusCreated {
+ t.Fatalf("create status=%d body=%s", created.Code, created.Body.String())
+ }
+
+ activate := patrolAutopilotSessionRequest(t, http.MethodPut, "/api/ai/patrol/autonomy", `{"autonomy_level":"full","acknowledgement_id":"ack-partial-001"}`, "org-a", "alice", "session-partial")
+ rec := httptest.NewRecorder()
+ handler.GatePatrolAutonomyUpdate(func(w http.ResponseWriter, gated *http.Request) {
+ body, err := io.ReadAll(gated.Body)
+ if err != nil {
+ t.Fatalf("read gated body: %v", err)
+ }
+ if strings.Contains(string(body), "investigation_budget") || strings.Contains(string(body), "investigation_timeout_sec") {
+ t.Fatalf("gated body fabricated omitted investigation controls: %s", body)
+ }
+ var downstream struct {
+ AutonomyLevel string `json:"autonomy_level"`
+ FullModeUnlocked *bool `json:"full_mode_unlocked,omitempty"`
+ InvestigationBudget *int `json:"investigation_budget,omitempty"`
+ InvestigationTimeoutSec *int `json:"investigation_timeout_sec,omitempty"`
+ }
+ dec := json.NewDecoder(bytes.NewReader(body))
+ dec.DisallowUnknownFields()
+ if err := dec.Decode(&downstream); err != nil {
+ t.Fatalf("gated body fails strict decode: %v body=%s", err, body)
+ }
+ if downstream.AutonomyLevel != string(config.PatrolAutonomyFull) || downstream.FullModeUnlocked == nil || !*downstream.FullModeUnlocked {
+ t.Fatalf("gated body lost activation shape: %s", body)
+ }
+ if downstream.InvestigationBudget != nil || downstream.InvestigationTimeoutSec != nil {
+ t.Fatalf("gated body changed omitted controls: %#v", downstream)
+ }
+ w.WriteHeader(http.StatusOK)
+ })(rec, activate)
+ if rec.Code != http.StatusOK {
+ t.Fatalf("gate status=%d body=%s", rec.Code, rec.Body.String())
+ }
+}
+
func TestPatrolAutopilotLowerModeDoesNotCreateOrRefreshAcknowledgement(t *testing.T) {
now := time.Date(2026, 7, 11, 20, 0, 0, 0, time.UTC)
handler, persistence := newPatrolAutopilotTestHandler(t, "org-a", &now)