mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-12-02 10:09:02 +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:
@@ -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