Skip to content

chore(codegen): fold ROLE_RANK into gen_frontend_types.py, matching Permission/Role #16491

Description

@mrveiss

Follow-up from #16243

#16243 extended autobot-infrastructure/shared/scripts/gen_frontend_types.py to
generate the Permission union from autobot_shared/auth/permissions.py, the
same pipeline Role already uses. constants/roles.ts's ROLE_RANK (added by
#16244, mirroring _ROLE_META's priority field) stays hand-maintained for
now -- it's DATA (a Dict[Role, int]), not a type/enum shape, and the codegen
framework's MANIFEST only supports emitting TypeScript from a Python
@dataclass or Enum (see gen_frontend_types.py's own module doc).

Ask

Extend the codegen framework to also support emitting a typed data constant
from a Python dict (or add a small, purpose-built second code path) so
ROLE_RANK (and potentially the backend's real _ROLE_META priorities
directly) can be generated rather than hand-mirrored -- closing the same
silent-drift gap #16243 closed for Permission.

Refs #16243, #16244.

Activity

  1. mrveiss commented on Sep 13, 2026

    @mrveiss
    OwnerAuthor

    Closure evidence (batch 2c)

    Verified against origin/main (PR #16493, 79c6344). No checkboxes, so the issue's ask is taken as the criteria. All met.

    Criterion Evidence
    Codegen emits a typed data constant from a Python dict autobot-infrastructure/shared/scripts/gen_frontend_types.py:142 class ConstMap(NamedTuple), :415 def _render_const_map; tests in repo_tests/gen_frontend_types_test.py
    ROLE_RANK is generated from _ROLE_META, not hand-mirrored gen_frontend_types.py:166 ConstMap(..., "_ROLE_META", "ROLE_PRIORITY", "Role", "number", "priority"); autobot-frontend/src/constants/roles.ts:61 ROLE_RANK ... = ROLE_PRIORITY; tests constants/__tests__/roles.test.ts expect(ROLE_RANK).toBe(ROLE_PRIORITY) and gen_frontend_types_test.py::test_const_manifest_emits_the_role_maps_the_frontend_consumes

    Caveat: the drift check is not required (#16568).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions