mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-01 01:52:30 +01:00
Correct agent paths and Patrol admin auth boundaries in Help docs
Fix factual route and authorization mismatches in the candidate Help edits: - Replace non-existent /api/agent/recent-changes and /api/agent/patrol-control-status with the manifest-owned /api/agent/changes and /api/agent/patrol-control/status (and legacy /api/agent/operations-loop/status) routes in docs/UNIFIED_RESOURCES.md and its shipped mirror. - Align GET /api/ai/cost/summary (ensureSettingsReadScope) and POST /api/ai/patrol/preflight and /api/ai/patrol/readiness (ensureSettingsWriteScope) with their actual instance-administrator enforcement in docs/AI_AUTONOMY.md and its shipped mirror. - Clarify Autopilot acknowledgement actor requirements as authenticated human sessions (refusing API tokens) in docs/PATROL_ARCHITECTURE.md and its shipped mirror. - Anchor all corrected route paths and handler checks in scripts/tests/test_actions_patrol_and_resources_auth_docs.py. Contract-Neutral: Documentation and router-anchored regression test corrections only; aligns shipped Help with existing runtime routes and authorization checks without changing runtime behavior. Change-source: pulse-maintainer
This commit is contained in:
@@ -234,7 +234,7 @@ For current Patrol run detail, finding investigation state, and provider circuit
|
||||
|
||||
Token usage and estimated costs are tracked per provider:
|
||||
- **UI:** Settings → Pulse Intelligence → Provider & Models → Provider Usage & Spend
|
||||
- **API:** `GET /api/ai/cost/summary`, `GET /api/ai/patrol/cost-preview`, and `GET /api/ai/patrol/model-guidance` require `settings:read`. `GET /api/ai/cost/export` requires an instance administrator with `settings:read`, and `POST /api/ai/cost/reset` requires an instance administrator with `settings:write`.
|
||||
- **API:** `GET /api/ai/patrol/cost-preview` and `GET /api/ai/patrol/model-guidance` require `settings:read`. `GET /api/ai/cost/summary` and `GET /api/ai/cost/export` require an instance administrator with `settings:read`, and `POST /api/ai/cost/reset` requires an instance administrator with `settings:write`.
|
||||
- Set a 30-day budget limit (`30-day budget (USD)`) to flag spend over budget
|
||||
|
||||
### Patrol and Circuit Status
|
||||
@@ -242,7 +242,7 @@ Token usage and estimated costs are tracked per provider:
|
||||
- **API:** `GET /api/ai/patrol/status` (`ai:execute`) for current Patrol runtime status
|
||||
- **API:** `GET /api/ai/patrol/runs`, `GET /api/ai/patrol/runs/{id}`, and `GET /api/ai/patrol/stream` (`ai:execute`) for recent Patrol run history and live streaming. Host-command tool output (`include=tool_calls` and stream tool output) is withheld unless the caller also holds `execute` action authority.
|
||||
- **API:** `GET /api/ai/patrol/findings` (`ai:execute`) for active findings and investigation status. `DELETE /api/ai/patrol/findings` and standing suppression rules (`POST /api/ai/patrol/suppress`, `POST /api/ai/patrol/suppressions`, and `DELETE /api/ai/patrol/suppressions/{id}` for non-`finding_` rules) require an organisation administrator with `ai:execute`.
|
||||
- **API:** `POST /api/ai/patrol/run` requires an instance administrator with `ai:execute`. `POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require settings write permission with `settings:write`.
|
||||
- **API:** `POST /api/ai/patrol/run` requires an instance administrator with `ai:execute`. `POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require an instance administrator with settings write permission and `settings:write`.
|
||||
- **API:** `GET /api/ai/circuit/status` (`ai:execute`) for AI provider circuit breaker state
|
||||
- **Prompt-context notes and objectives:** Creating, updating, or deleting Patrol objectives (`/api/ai/patrol/objectives`), saving or modifying guest knowledge notes (`/api/ai/knowledge/save`, `/delete`, `/import`, `/clear`), setting finding notes (`/api/ai/patrol/findings/note`), and attaching free-text notes on `/api/ai/patrol/dismiss` or `/api/ai/patrol/resolve` require `execute` action authority in browser or proxy sessions (and `ai:execute` for API tokens) because that text enters Patrol's prompt context. Missing authority returns HTTP `403` (`action_capability_denied`).
|
||||
|
||||
|
||||
@@ -218,8 +218,8 @@ inputs, suppression rules, and autonomy controls in
|
||||
`plan` and `execute` action capabilities with `ai:execute` (plus Pulse Pro).
|
||||
`GET` and `PUT /api/ai/patrol/autonomy` and the Autopilot acknowledgement
|
||||
endpoints (`/api/ai/patrol/autonomy/acknowledgements*`) require an instance
|
||||
administrator with `settings:write`, with acknowledgements restricted to human
|
||||
browser sessions.
|
||||
administrator with `settings:write`, with acknowledgements restricted to
|
||||
authenticated human sessions (API tokens are refused).
|
||||
|
||||
## Why it is built this way
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ Returns all unified resources. Supports query parameters:
|
||||
|
||||
- **Resource reads and identity mutations:** Reading `/api/resources`, `/api/resources/{id}`, facets, timelines, stats, storage summaries, storage incidents, and maintenance verifications requires `monitoring:read`, and delayed responses recheck live session or token validity before returning data. Resource identity writes (`POST` link, unlink, and report-merge) and maintenance-verification reruns or reviews require `monitoring:write`.
|
||||
- **Operator overrides (`PUT`/`DELETE /api/resources/{id}/operator-state`):** API tokens require `monitoring:write`. Browser and proxy sessions also require administrator privileges or an explicit `approve` action grant to change the **Never auto-remediate** lock, **Lifecycle** state (`Retired`), or automatic remediation policy (refused with HTTP `403` otherwise), while non-remediation fields such as notes or maintenance windows remain editable when saved remediation fields are unchanged.
|
||||
- **Agent context and event streams (`/api/agent/*`):** `GET /api/agent/capabilities` is an unauthenticated discovery manifest. `/api/agent/resource-context/{id}`, `/api/agent/resource-capabilities/{id}`, `/api/agent/fleet-context`, `/api/agent/recent-changes`, `/api/agent/metric-history`, `/api/agent/patrol-control-status`, and the `/api/agent/events` SSE stream require `monitoring:read`. On `/api/agent/resource-context/{id}`, `/api/agent/recent-changes`, and `/api/agent/events`, callers without `ai:execute` (for API tokens) or `approve` action authority (for browser and proxy sessions) receive command-redacted projections (`commandRedacted: true`) with command text, raw `ActionResultV2` output, verification commands and notes, and free-form action error suffixes stripped.
|
||||
- **Agent context and event streams (`/api/agent/*`):** `GET /api/agent/capabilities` is an unauthenticated discovery manifest. `/api/agent/resource-context/{id}`, `/api/agent/resource-capabilities/{id}`, `/api/agent/fleet-context`, `/api/agent/changes`, `/api/agent/metric-history`, `/api/agent/patrol-control/status` (and its legacy `/api/agent/operations-loop/status` alias), and the `/api/agent/events` SSE stream require `monitoring:read`. On `/api/agent/resource-context/{id}`, `/api/agent/changes`, and `/api/agent/events`, callers without `ai:execute` (for API tokens) or `approve` action authority (for browser and proxy sessions) receive command-redacted projections (`commandRedacted: true`) with command text, raw `ActionResultV2` output, verification commands and notes, and free-form action error suffixes stripped.
|
||||
- **On-host infrastructure update checks:** `POST /api/infra-updates/check` queues a Docker update scan on the target host (which can invoke a configured registry credential helper) and therefore requires both `monitoring:write` and `execute` action authority.
|
||||
|
||||
## Frontend Architecture
|
||||
|
||||
@@ -234,7 +234,7 @@ For current Patrol run detail, finding investigation state, and provider circuit
|
||||
|
||||
Token usage and estimated costs are tracked per provider:
|
||||
- **UI:** Settings → Pulse Intelligence → Provider & Models → Provider Usage & Spend
|
||||
- **API:** `GET /api/ai/cost/summary`, `GET /api/ai/patrol/cost-preview`, and `GET /api/ai/patrol/model-guidance` require `settings:read`. `GET /api/ai/cost/export` requires an instance administrator with `settings:read`, and `POST /api/ai/cost/reset` requires an instance administrator with `settings:write`.
|
||||
- **API:** `GET /api/ai/patrol/cost-preview` and `GET /api/ai/patrol/model-guidance` require `settings:read`. `GET /api/ai/cost/summary` and `GET /api/ai/cost/export` require an instance administrator with `settings:read`, and `POST /api/ai/cost/reset` requires an instance administrator with `settings:write`.
|
||||
- Set a 30-day budget limit (`30-day budget (USD)`) to flag spend over budget
|
||||
|
||||
### Patrol and Circuit Status
|
||||
@@ -242,7 +242,7 @@ Token usage and estimated costs are tracked per provider:
|
||||
- **API:** `GET /api/ai/patrol/status` (`ai:execute`) for current Patrol runtime status
|
||||
- **API:** `GET /api/ai/patrol/runs`, `GET /api/ai/patrol/runs/{id}`, and `GET /api/ai/patrol/stream` (`ai:execute`) for recent Patrol run history and live streaming. Host-command tool output (`include=tool_calls` and stream tool output) is withheld unless the caller also holds `execute` action authority.
|
||||
- **API:** `GET /api/ai/patrol/findings` (`ai:execute`) for active findings and investigation status. `DELETE /api/ai/patrol/findings` and standing suppression rules (`POST /api/ai/patrol/suppress`, `POST /api/ai/patrol/suppressions`, and `DELETE /api/ai/patrol/suppressions/{id}` for non-`finding_` rules) require an organisation administrator with `ai:execute`.
|
||||
- **API:** `POST /api/ai/patrol/run` requires an instance administrator with `ai:execute`. `POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require settings write permission with `settings:write`.
|
||||
- **API:** `POST /api/ai/patrol/run` requires an instance administrator with `ai:execute`. `POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require an instance administrator with settings write permission and `settings:write`.
|
||||
- **API:** `GET /api/ai/circuit/status` (`ai:execute`) for AI provider circuit breaker state
|
||||
- **Prompt-context notes and objectives:** Creating, updating, or deleting Patrol objectives (`/api/ai/patrol/objectives`), saving or modifying guest knowledge notes (`/api/ai/knowledge/save`, `/delete`, `/import`, `/clear`), setting finding notes (`/api/ai/patrol/findings/note`), and attaching free-text notes on `/api/ai/patrol/dismiss` or `/api/ai/patrol/resolve` require `execute` action authority in browser or proxy sessions (and `ai:execute` for API tokens) because that text enters Patrol's prompt context. Missing authority returns HTTP `403` (`action_capability_denied`).
|
||||
|
||||
|
||||
@@ -218,8 +218,8 @@ inputs, suppression rules, and autonomy controls in
|
||||
`plan` and `execute` action capabilities with `ai:execute` (plus Pulse Pro).
|
||||
`GET` and `PUT /api/ai/patrol/autonomy` and the Autopilot acknowledgement
|
||||
endpoints (`/api/ai/patrol/autonomy/acknowledgements*`) require an instance
|
||||
administrator with `settings:write`, with acknowledgements restricted to human
|
||||
browser sessions.
|
||||
administrator with `settings:write`, with acknowledgements restricted to
|
||||
authenticated human sessions (API tokens are refused).
|
||||
|
||||
## Why it is built this way
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ Returns all unified resources. Supports query parameters:
|
||||
|
||||
- **Resource reads and identity mutations:** Reading `/api/resources`, `/api/resources/{id}`, facets, timelines, stats, storage summaries, storage incidents, and maintenance verifications requires `monitoring:read`, and delayed responses recheck live session or token validity before returning data. Resource identity writes (`POST` link, unlink, and report-merge) and maintenance-verification reruns or reviews require `monitoring:write`.
|
||||
- **Operator overrides (`PUT`/`DELETE /api/resources/{id}/operator-state`):** API tokens require `monitoring:write`. Browser and proxy sessions also require administrator privileges or an explicit `approve` action grant to change the **Never auto-remediate** lock, **Lifecycle** state (`Retired`), or automatic remediation policy (refused with HTTP `403` otherwise), while non-remediation fields such as notes or maintenance windows remain editable when saved remediation fields are unchanged.
|
||||
- **Agent context and event streams (`/api/agent/*`):** `GET /api/agent/capabilities` is an unauthenticated discovery manifest. `/api/agent/resource-context/{id}`, `/api/agent/resource-capabilities/{id}`, `/api/agent/fleet-context`, `/api/agent/recent-changes`, `/api/agent/metric-history`, `/api/agent/patrol-control-status`, and the `/api/agent/events` SSE stream require `monitoring:read`. On `/api/agent/resource-context/{id}`, `/api/agent/recent-changes`, and `/api/agent/events`, callers without `ai:execute` (for API tokens) or `approve` action authority (for browser and proxy sessions) receive command-redacted projections (`commandRedacted: true`) with command text, raw `ActionResultV2` output, verification commands and notes, and free-form action error suffixes stripped.
|
||||
- **Agent context and event streams (`/api/agent/*`):** `GET /api/agent/capabilities` is an unauthenticated discovery manifest. `/api/agent/resource-context/{id}`, `/api/agent/resource-capabilities/{id}`, `/api/agent/fleet-context`, `/api/agent/changes`, `/api/agent/metric-history`, `/api/agent/patrol-control/status` (and its legacy `/api/agent/operations-loop/status` alias), and the `/api/agent/events` SSE stream require `monitoring:read`. On `/api/agent/resource-context/{id}`, `/api/agent/changes`, and `/api/agent/events`, callers without `ai:execute` (for API tokens) or `approve` action authority (for browser and proxy sessions) receive command-redacted projections (`commandRedacted: true`) with command text, raw `ActionResultV2` output, verification commands and notes, and free-form action error suffixes stripped.
|
||||
- **On-host infrastructure update checks:** `POST /api/infra-updates/check` queues a Docker update scan on the target host (which can invoke a configured registry credential helper) and therefore requires both `monitoring:write` and `execute` action authority.
|
||||
|
||||
## Frontend Architecture
|
||||
|
||||
@@ -86,6 +86,8 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
ai_handlers = (ROOT / "internal/api/ai_handlers.go").read_text(encoding="utf-8")
|
||||
op_state = (ROOT / "internal/api/resources_operator_state.go").read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn('HandleFunc("/api/ai/cost/summary", RequireAuth(r.config, RequireScope(config.ScopeSettingsRead,', ai_router)
|
||||
self.assertIn("ensureSettingsReadScope(r.config, w, req)", ai_router)
|
||||
self.assertIn('HandleFunc("/api/ai/cost/export", RequireAdmin(r.config, RequireScope(config.ScopeSettingsRead,', ai_router)
|
||||
self.assertIn('HandleFunc("/api/ai/cost/reset", RequireAdmin(r.config, RequireScope(config.ScopeSettingsWrite,', ai_router)
|
||||
self.assertIn('HandleFunc("/api/ai/patrol/run", RequireAdmin(r.config, RequireScope(config.ScopeAIExecute,', ai_router)
|
||||
@@ -96,6 +98,8 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
self.assertIn("RequireOrgAdmin(r.config, r.aiSettingsHandler.HandleClearAllFindings)", router_go)
|
||||
self.assertIn("requireActionCapability(r.config, r.authorizer, auth.ActionPlan,", router_go)
|
||||
self.assertIn("patrolToolOutputAllowed", ai_handlers)
|
||||
self.assertIn("ensureSettingsWriteScope(h.getConfig(r.Context()), w, r)", ai_handlers)
|
||||
self.assertIn("Autopilot acknowledgement requires an authenticated human session", ai_handlers)
|
||||
self.assertIn("Writing a finding resolution note requires permission to execute actions", ai_handlers)
|
||||
self.assertIn("Writing a dismissal note requires permission to execute actions", ai_handlers)
|
||||
self.assertIn("operatorStateRemediationDenied", op_state)
|
||||
@@ -103,12 +107,13 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
for token in (
|
||||
"PUT` or `DELETE /api/resources/{id}/operator-state` requires `monitoring:write` for API tokens",
|
||||
"explicit `approve` action grant",
|
||||
"`GET /api/ai/cost/export` requires an instance administrator with `settings:read`",
|
||||
"`GET /api/ai/patrol/cost-preview` and `GET /api/ai/patrol/model-guidance` require `settings:read`",
|
||||
"`GET /api/ai/cost/summary` and `GET /api/ai/cost/export` require an instance administrator with `settings:read`",
|
||||
"`POST /api/ai/cost/reset` requires an instance administrator with `settings:write`",
|
||||
"Host-command tool output (`include=tool_calls` and stream tool output) is withheld unless the caller also holds `execute` action authority",
|
||||
"`DELETE /api/ai/patrol/findings` and standing suppression rules",
|
||||
"`POST /api/ai/patrol/run` requires an instance administrator with `ai:execute`",
|
||||
"`POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require settings write permission with `settings:write`",
|
||||
"`POST /api/ai/patrol/preflight` and `POST /api/ai/patrol/readiness` require an instance administrator with settings write permission and `settings:write`",
|
||||
"Prompt-context notes and objectives",
|
||||
"`action_capability_denied`",
|
||||
):
|
||||
@@ -126,6 +131,7 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
"`DELETE /api/ai/patrol/findings`",
|
||||
"`POST /api/ai/findings/{id}/reinvestigate` requires both `plan` and `execute` action capabilities",
|
||||
"`/api/ai/patrol/autonomy/acknowledgements*`",
|
||||
"authenticated human sessions (API tokens are refused)",
|
||||
):
|
||||
with self.subTest(doc="PATROL_ARCHITECTURE.md", token=token):
|
||||
self.assertIn(token, patrol_doc)
|
||||
@@ -134,7 +140,11 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
doc = normalized(UNIFIED_DOC)
|
||||
monitoring_router = (ROOT / "internal/api/router_routes_monitoring.go").read_text(encoding="utf-8")
|
||||
redaction_go = (ROOT / "internal/api/agent_command_redaction.go").read_text(encoding="utf-8")
|
||||
projection_go = (ROOT / "internal/agentcapabilities/projection.go").read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn('RecentChangesCapabilityPath = "/api/agent/changes"', projection_go)
|
||||
self.assertIn('PatrolControlStatusCapabilityPath = "/api/agent/patrol-control/status"', projection_go)
|
||||
self.assertIn('OperationsLoopStatusCompatibilityPath = "/api/agent/operations-loop/status"', projection_go)
|
||||
self.assertIn("SetOperatorStateRemediationAuthority(", monitoring_router)
|
||||
self.assertIn('HandleFunc("/api/agent/capabilities", HandleAgentCapabilitiesManifest)', monitoring_router)
|
||||
self.assertIn('HandleFunc("/api/infra-updates/check", RequireAuth(r.config, RequireScope(config.ScopeMonitoringWrite,', monitoring_router)
|
||||
@@ -149,7 +159,10 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
"`PUT`/`DELETE /api/resources/{id}/operator-state`",
|
||||
"explicit `approve` action grant",
|
||||
"`GET /api/agent/capabilities` is an unauthenticated discovery manifest",
|
||||
"`/api/agent/resource-context/{id}`, `/api/agent/recent-changes`, and `/api/agent/events`",
|
||||
"`/api/agent/changes`",
|
||||
"`/api/agent/patrol-control/status`",
|
||||
"`/api/agent/operations-loop/status`",
|
||||
"`/api/agent/resource-context/{id}`, `/api/agent/changes`, and `/api/agent/events`",
|
||||
"`commandRedacted: true`",
|
||||
"`POST /api/infra-updates/check`",
|
||||
"both `monitoring:write` and `execute` action authority",
|
||||
@@ -157,6 +170,9 @@ class ActionsPatrolAndResourcesAuthDocsTest(unittest.TestCase):
|
||||
with self.subTest(token=token):
|
||||
self.assertIn(token, doc)
|
||||
|
||||
self.assertNotIn("/api/agent/recent-changes", doc)
|
||||
self.assertNotIn("/api/agent/patrol-control-status", doc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user