feat(AGX1-301): authorize states via parent task#262
Open
deepthi-rao-scale wants to merge 5 commits into
Open
Conversation
rpatel-scale
reviewed
Jun 2, 2026
…gac-state-route-migration-enforce-via-parent-task # Conflicts: # agentex/src/utils/authorization_shortcuts.py
asherfink
reviewed
Jun 3, 2026
| read = "read" | ||
| update = "update" | ||
| delete = "delete" | ||
| manage_access = "manage_access" |
Contributor
There was a problem hiding this comment.
we need to add this to agentex-auth, otherwise this will fail
asherfink
reviewed
Jun 3, 2026
| state_id: DAuthorizedId( | ||
| TaskChildResourceType.state, AuthorizedOperationType.update | ||
| ), | ||
| state_id: DAuthorizedId(TaskChildResourceType.state, _STATE_WRITE_OPERATION), |
Contributor
There was a problem hiding this comment.
are you sure manage_access is the right operation here? maybe something new like create_child would be better
asherfink
reviewed
Jun 3, 2026
| assert authz_data["resource"]["type"] == AgentexResourceType.task.value | ||
| assert authz_data["resource"]["selector"] == test_task.id | ||
| # AGX1-237 exposes manage_access as an owner-only task permission. | ||
| assert authz_data["operation"] == "manage_access" |
Contributor
There was a problem hiding this comment.
nit: use enum value rather than string, looks like greptile also flagged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: Authorizes state list/get/create/update through the parent task instead of any state AuthZ resource. GET /states now filters to tasks the caller can read via list_resources(task, read); GET /states/{id} continues to resolve the state parent task and checks read with 404 collapse from the shared task-child path; state create/update now use task.execute as the current owner-level placeholder, with a TODO for AGX1-237 if agentex-auth adds a dedicated state create/upsert task permission. Tests: added integration coverage for view-not-owner create denial, no-view list/get denial, accessible-task list filtering, owner create, and no state register_resource call. Local verification: python3.14 compileall on changed files passes; git diff --check passes. Blocked: pytest and ruff via Poetry cannot run locally because this shell has Python 3.11/3.13/3.14 but the project requires >=3.12,<3.13.
Greptile Summary
This PR moves state authorization away from a dedicated state auth resource and instead gates all state reads/writes through the parent task.
GET /stateswith an explicittask_idnow does a directcheck()on the task, the no-task_idpath useslist_resourcesto filter to accessible tasks, and create/update both require the newmanage_accesstask operation added to the enum.states.py):filter_statesinjectsDAuthorizationServicedirectly and branches on whethertask_idis provided, callingcheck_task_or_collapse_to_404for the explicit-id path andlist_resourcesfor the wildcard path; create and update use_STATE_WRITE_OPERATION = manage_accessvia the existingDAuthorizedBodyId/DAuthorizedIdshortcuts.states_use_case.py):list()gainsauthorized_task_ids; when populated it applies a$infilter and short-circuits to[]on an empty set, preserving the previous directtask_idfilter when that is supplied.test_states_authz_api.py): New integration suite covering create/update denial for view-only callers, list filtering to accessible tasks, direct-check for explicit task_id, and the owner-create happy path including an assertion that/v1/authz/registeris never called for states.Confidence Score: 5/5
Safe to merge; the new task-scoped auth logic is consistent across all five state endpoints and the bypass path is handled correctly in all branches.
All read/write state endpoints now consistently resolve auth through the parent task, the bypass path is handled correctly, and the new test suite covers the key scenarios including the previously flagged direct-check and update-denial paths.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["GET /states"] --> B{task_id provided?} B -->|Yes| C["check_task_or_collapse_to_404\n(task, read)"] C -->|Denied| D["→ 404"] C -->|Allowed| E["list states\nfiltered by task_id"] B -->|No| F["list_resources\n(task, read)"] F -->|None bypass| G["list all states\n(auth disabled)"] F -->|Empty set| H["→ []"] F -->|IDs returned| I["list states\nfiltered by $in task_ids"] J["POST /states"] --> K["DAuthorizedBodyId\n(task, manage_access)"] K -->|Denied| D K -->|Allowed| L["states_use_case.create"] M["PUT /states/{id}"] --> N["DAuthorizedId\n(state → parent task, manage_access)"] N -->|Denied| D N -->|Allowed| O["states_use_case.update"] P["GET /states/{id}"] --> Q["DAuthorizedId\n(state → parent task, read)"] Q -->|Denied| D Q -->|Allowed| R["states_use_case.get"] S["DELETE /states/{id}"] --> T["DAuthorizedId\n(state → parent task, delete)"] T -->|Denied| D T -->|Allowed| U["states_use_case.delete"]Prompt To Fix All With AI
Reviews (2): Last reviewed commit: "fix(AGX1-301): reuse task auth collapse ..." | Re-trigger Greptile