Skip to content

docs: ADR - Audit Trail for Custom Role Changes - #614

Open
rodmgwgu wants to merge 4 commits into
mainfrom
docs/custom-roles-audit
Open

rodmgwgu wants to merge 4 commits into
mainfrom
docs/custom-roles-audit

Conversation

@rodmgwgu

@rodmgwgu rodmgwgu commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Closes #587

Problem

Nothing records changes to custom role definitions. ADR 0012 records assignment changes, but an assignment removed because its role was deleted or reassigned looks like a manual change (PR #603 review). ADR 0025 left source tracking for dynamic definitions to a future decision.

Approach

  • Added ADR 0037, which defines:
    • A RoleDefinitionAudit table recording each custom role change (created, updated, deleted, members_reassigned) with actor, timestamp, and what changed, following the ADR 0012 rules.
    • A nullable role_change_id on RoleAssignmentAudit that links assignment changes to the role change that caused them.
    • New role definition events in openedx-events, handled like the ADR 0012 events.
    • The created record as the provenance of a custom role, with no ADR 0025 source rows.
    • History in Django admin only. A REST endpoint is deferred.
  • Added addenda to ADR 0012 and ADR 0025 pointing to ADR 0037.

Manual testing instructions

Docs only. All three files pass python -m docutils --halt=warning.

Rollback plan

Revert this PR. Docs only. No code or migration.

Retro compatibility

No behavior change. This PR only records the decision. The implementation will follow in separate PRs.

AI Usage

Kiro assisted with research and ADR authoring, with human guidance on the decisions and validation against the existing ADRs.


Merge checklist:

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 9, 2026
@openedx-webhooks

openedx-webhooks commented Nov 9, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @rodmgwgu!

This repository is currently maintained by @openedx/committers-openedx-authz.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@BryanttV BryanttV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, I agree with the decisions, I just have a couple of minor comments. Thank you so much!

Comment thread docs/decisions/0012-auditability.rst Outdated
Comment on lines +194 to +196
`ADR 0037`_ records custom role changes in a separate ``RoleDefinitionAudit`` table and adds a
nullable ``role_change_id`` to ``RoleAssignmentAudit`` and the assignment event data. It links
assignments deleted or created by removing a role or moving its members to that role change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the part about moving members to another role, since reassignment won't be considered for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, done, thanks!

Comment on lines +75 to +78
openedx-events gains ``ROLE_DEFINITION_CREATED``, ``ROLE_DEFINITION_UPDATED``,
and ``ROLE_DEFINITION_DELETED``. The payload carries the operation,
``change_id``, role, ``changes`` (as a JSON string, so the event bus can serialize it), and
``actor_id``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should the payload include the operation? Doesn't the event itself describe it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, previously ROLE_DEFINITION_UPDATED also handled reassignments, that was the reason, but now that we don't have that is not needed. I changed so it doesn't repeat it. thanks!

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

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

ADR: Custom roles audit model

3 participants