Skip to content

feat: add authz schema loading - #475

Merged
rodmgwgu merged 6 commits into
mainfrom
rod/authz-schema-loader-only
Oct 2, 2026
Merged

rodmgwgu merged 6 commits into
mainfrom
rod/authz-schema-loader-only

Conversation

@rodmgwgu

Copy link
Copy Markdown
Contributor

Problem

Discovered resources are still opaque bytes. They need to be parsed into typed schema documents, with the source identity and content digest that later phases and the provenance tables depend on (ADR 0018 §1).

Approach

The load phase, plus the shared vocabulary the remaining phases are written against.

  • openedx_authz/engine/schema/loading.py — SchemaLoader
  • openedx_authz/engine/schema/types.py — the schema dataclasses
  • openedx_authz/engine/schema/exceptions.py — the pipeline exception hierarchy
  • openedx_authz/constants/schema.py — SchemaOriginKind
  • openedx_authz/tests/schema/{factories,test_loading,test_types}.py

types.py and exceptions.py land whole rather than sliced across the stack: they are the shared vocabulary, and splitting them would make every later PR conflict on the same two files. Some names in them (CompiledSchema, CompiledDefinition, RelationshipSource, and the compile/validate/apply errors) are unused until later PRs.

Manual testing instructions

pytest openedx_authz/tests/schema/

Rollback plan

Revert this PR. Nothing consumes the loader yet, so the revert is inert.

Retro compatibility

No authorization behavior changes. No models, no migration, no automatic code path.

AI Usage

Kiro was used to assist on feature planning and implementation. Implementation was done step by step with human guidance and validation, based on the ADRs.


Stack (2/8) — #446 split into reviewable pieces. Bases chain bottom-up; merge in order.

  1. feat: add authz schema discovery #474 — schema discovery
  2. This PR — schema loading (base: rod/authz-schema-discovery)
  3. rod/authz-schema-compiler — schema compilation
  4. rod/authz-schema-validator — schema validation
  5. rod/authz-schema-models — definition models + migration
  6. rod/authz-schema-renderer — policy renderer
  7. rod/authz-schema-applier — schema applier
  8. feat: add authz schema pipeline and load_authz_schema command #446 — pipeline + load_authz_schema command, version bump and changelog

Base is the previous branch; review only the incremental diff.

Merge checklist:

  • Version bumped — deferred to 8/8 so the stack does not conflict on every restack
  • Changelog record added — deferred to 8/8
  • Documentation updated (not only docstrings) — covered by the already-merged ADRs
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets — depends on feat: add authz schema discovery #474; no migration

@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 Sep 23, 2026
@openedx-webhooks

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.

@mariajgrimaldi mariajgrimaldi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A few comments for you to review! Thanks a lot for this :))

Comment thread src/openedx_authz/engine/schema/loading.py
Comment thread src/openedx_authz/engine/schema/loading.py Outdated
except Exception: # noqa: BLE001 - defensive; metadata quirks across envs
mapping = {}
candidates = mapping.get(top_level) or []
if candidates:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could there be duplicates?

@rodmgwgu rodmgwgu Oct 1, 2026 •

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.

In theory yes, I'm adding a way to deterministically choosing the candidate:

  1. First search for the distribution that actually has the discovered resource file
  2. If more than one matches exists, sort and return the first one as a deterministic fallback (and log a warning about it.)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if these decisions should be recorded somehow. When we merge this stack, can we do like a reverse-engineering review to capture the deliberate decisions we're making here?

Comment thread src/openedx_authz/engine/schema/loading.py
Comment thread src/openedx_authz/engine/schema/loading.py
``hidden`` is tri-state: ``None`` leaves the current value untouched.
"""

role: str

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we use some kind of role_id to reference the role we're extending?

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.

This also comes form the yaml definition as specified in the ADRs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The reference mentions role with a description of role ID, which is very straightforward. By itself not so much. We can update the ADRs and references if needed. Let me know what you think!

Comment thread openedx_authz/engine/schema/types.py Outdated
Comment thread openedx_authz/engine/schema/types.py Outdated
Comment thread openedx_authz/tests/schema/test_loading.py Outdated
Comment thread src/openedx_authz/tests/schema/test_loading.py
@rodmgwgu
rodmgwgu force-pushed the rod/authz-schema-loader-only branch from c9a67dc to bc3bd6b Compare September 24, 2026 21:35
@rodmgwgu
rodmgwgu force-pushed the rod/authz-schema-loader-only branch from 6bbb22e to 442e19d Compare September 29, 2026 15:12
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Sep 29, 2026
Base automatically changed from rod/authz-schema-discovery to main September 30, 2026 21:59

@mariajgrimaldi mariajgrimaldi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thanks so much for addressing my comments!

(The comments left to address are only nits so I'll leave my approval! :))

@rodmgwgu
rodmgwgu merged commit 4310932 into main Oct 2, 2026
8 checks passed
@rodmgwgu
rodmgwgu deleted the rod/authz-schema-loader-only branch October 2, 2026 17:01
@BryanttV BryanttV linked an issue Oct 2, 2026 that may be closed by this pull request
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). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Core Loader, Compilation, and Definition Validation

5 participants