taskflow: task read roles and caller-filtered actions

Abierto
#374 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@mushrafmim ya está trabajando en esto.

Desde el 3/11/2026.

  • #378 de @mushrafmim — abierto

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
12/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
go, sql

Línea de trabajo

Start with the proposal's design rather than code: it spans the task template schema, the gorm task store (new task_roles table written in the same transaction as the task row), GetTaskRenderInfo and GetAllTasks, renderer.Facts, and ZoneViewAssembler.Assemble. Work is already under way in linked PR 375, so review that first. Done means the proposal's access_roles and Commands filtering are implemented as specified, with the breaking changes handled.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Type/New Feature
Problem

taskflow has no way to say who may open a task, or to show a caller only the actions they may take.

  • Who may open a task. GetTaskRenderInfo and GetAllTasks return any task to any caller. A host that wants to gate a task, or list only the caller's tasks, has nothing in the task record to match against. It ends up keeping its own task-to-role mapping outside taskflow, and that mapping can drift from the templates.
  • What a caller may do. The PRE_RESUME authz extension decides on the server which commands a caller may issue. The zoneview renderer, however, keeps a handle whenever its command is legal in the current state. A caller who may see a section but not act on it still gets its actions, which the server rejects only when they submit.
Proposed Solution

Keep the policy in the host. taskflow stores what the templates declare and forwards what the host has resolved. The two parts are independent and ship as separate PRs.

  1. Task read roles (#375). Task templates already carry read.roles (#377), an optional list of opaque role strings:

    { "id": "apply", "workflow_id": "apply-flow", "render_config_id": "apply-render", "read": { "roles": ["applicant", "reviewer"] } }
    

    StartTask copies them to the task as TaskRecord.ReadRoles. The gorm store writes them to a task_roles (task_id, role, case_id) table in the same transaction as the task row, so a task never exists without its roles. A host gates and lists tasks by joining its own record of who holds each role on (case_id, role). The roles never change after the task starts. A template with no read roles writes no rows.

  2. Caller-filtered actions (#378). renderer.Facts gains Commands map[string]bool: the commands the caller may issue, which the host resolves from the same rules its authz extension enforces. The zoneview renderer keeps a handle only if its command is legal in the state and allowed for the caller, so a visible section with no allowed actions renders read-only. nil means nothing is filtered. ZoneViewAssembler.Assemble takes a Caller{Claims, Commands}.

What each mechanism decides:

Question Decided by
Can the caller open the task? read.roles, recorded in task_roles (#375)
Can the caller see a section? visibleWhen.requireClaim (unchanged)
Can the caller take an action? the commands authz allows, enforced on submit and reflected in Facts.Commands (#378)

Breaking changes: hosts must create task_roles before upgrading (#375), and Assemble's signature changes (#378). Templates need no change.

Alternatives
  • A separate, required access_roles field on the task template. Dropped once #377 added read.roles: two lists of who may read a task would drift from each other.
  • Roles with a permission each (e.g. {"role": "read&write"}). Rejected. Whether a role may write is already answered per command by the authz rules, and a second answer would drift from them. It's also coarser: "write" can't tell approve apart from reject.
  • Roles as an array column on the task row. Rejected. Listing a caller's tasks needs a join and a B-tree index on (case_id, role), which a row per role gives directly, along with idempotent inserts through the primary key.
  • Keep the task-to-role mapping only in the host. Possible, but the host would have to re-read templates and keep its copy in step with the task's manifest version. Recording roles when the task starts, in the same transaction as the row, avoids both.
Lenguaje dominante
Go
Estrellas
6
Forks
8
Merge medio
21 h 36 min
PR fusionados (30 d)
42

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de OpenNSW/core

Todos los issues de OpenNSW/core

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.