Skip to content

feat(openfga): extract model DSL to files/model.fga#136

Open
bramwelt wants to merge 11 commits intomainfrom
tbramwell/LFXV2-1646-extract-fga-model
Open

feat(openfga): extract model DSL to files/model.fga#136
bramwelt wants to merge 11 commits intomainfrom
tbramwell/LFXV2-1646-extract-fga-model

Conversation

@bramwelt
Copy link
Copy Markdown
Contributor

@bramwelt bramwelt commented May 5, 2026

Summary

  • Extracts the OpenFGA authorization model DSL from the inline Helm template into a standalone charts/lfx-platform/files/model.fga file
  • Loads the model via .Files.Get with indent 8 to preserve the YAML block scalar
  • Adds a CI workflow (fga-model-check) that detects model changes and requires a corresponding edit to model.yaml (version bump is a social contract)

🤖 Generated with Claude Code

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
Signed-off-by: Trevor Bramwell tbramwell@linuxfoundation.org

Copilot AI review requested due to automatic review settings May 5, 2026 17:25
@bramwelt bramwelt requested review from a team and emsearcy as code owners May 5, 2026 17:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Extracts the OpenFGA DSL into charts/lfx-platform/files/model.fga, updates the Helm chart to load that file, adds a GitHub Actions workflow that enforces model/version consistency on PRs, and updates docs and agent skills to reference the canonical DSL location.

Changes

OpenFGA model extraction and CI enforcement

Layer / File(s) Summary
Data Shape
charts/lfx-platform/files/model.fga
Adds the full OpenFGA authorization model (schema 1.1) covering user, team, project, committee, groupsio_* aliases, meeting/past_meeting and attachments, v1_* compatibility types and artifact-scoped viewers, vote/vote_response, survey/survey_response, and hidden member.
Core Template
charts/lfx-platform/templates/openfga/model.yaml
Replaces the inline authorizationModel block with `{{ .Files.Get "files/model.fga"
Wiring / CI Enforcement
.github/workflows/fga-model-check.yml
Adds FGA Model Check workflow on pull_request that checks out full history, compares base vs HEAD files/model.fga (stripping comments/blank lines), treats added model when base is missing as a change, and fails the job with an error if model.fga changed without a corresponding templates/openfga/model.yaml update.
Docs / Skills / Generated Output
docs/openfga.md, .agents/skills/.../SKILL.md, PERMISSIONS.md
Updates Quick Start, "Updating Authorization Models", skills, and generated header to reference charts/lfx-platform/files/model.fga as the canonical source, show the {{ .Files.Get ... }} inclusion, adjust indentation/JTBD guidance, and note CI requires bumping the template version when the DSL changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: extracting the OpenFGA model DSL from an inline Helm template into a standalone file.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description accurately summarizes the key changes: extracting the OpenFGA model DSL to a standalone file, loading it via .Files.Get, and adding CI validation with version bump expectations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tbramwell/LFXV2-1646-extract-fga-model

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/fga-model-check.yml (1)

22-22: 💤 Low value

strip() may exit non-zero if input contains only comments/blanks.

If the model file contains only comments and blank lines, the second grep -v will produce no output and return exit code 1. While this is currently absorbed by command substitution, it could cause issues if the script is later modified to use set -e or if the behavior changes.

♻️ Defensive fix
-         strip() { grep -v '^[[:space:]]*#' | grep -v '^[[:space:]]*$'; }
+         strip() { grep -v '^[[:space:]]*#' | grep -v '^[[:space:]]*$' || true; }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/fga-model-check.yml at line 22, The strip() helper can
return a non-zero exit status when the input is only comments/blanks; change the
implementation of strip() so the pipeline never fails (for example append a
fallback like "|| true" to the grep pipeline or use a single awk/sed command
that always exits 0) so that calling strip() always returns success; update the
strip() function definition accordingly to ensure safe behavior under set -e.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/fga-model-check.yml:
- Around line 22-28: git show "$BASE:$MODEL" can fail when model.fga doesn't
exist on the base branch; update the script around the BASE_DSL/HEAD_DSL
assignment to first test for the base file's existence (e.g., with git cat-file
-e "$BASE:$MODEL" or git ls-tree "$BASE" -- "$MODEL") and only run git show
"$BASE:$MODEL" if it exists, otherwise set BASE_DSL to an empty string (or a
sentinel) so the subsequent comparison with HEAD_DSL treats a newly added model
as "changed" rather than failing the workflow; keep HEAD_DSL logic the same and
still pipe through strip().

---

Nitpick comments:
In @.github/workflows/fga-model-check.yml:
- Line 22: The strip() helper can return a non-zero exit status when the input
is only comments/blanks; change the implementation of strip() so the pipeline
never fails (for example append a fallback like "|| true" to the grep pipeline
or use a single awk/sed command that always exits 0) so that calling strip()
always returns success; update the strip() function definition accordingly to
ensure safe behavior under set -e.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c595a67b-8556-4d59-8846-9b3b08bd09a8

📥 Commits

Reviewing files that changed from the base of the PR and between c17836f and fe9d512.

📒 Files selected for processing (4)
  • .github/workflows/fga-model-check.yml
  • charts/lfx-platform/files/model.fga
  • charts/lfx-platform/templates/openfga/model.yaml
  • docs/openfga.md

Comment thread .github/workflows/fga-model-check.yml Outdated
bramwelt and others added 5 commits May 5, 2026 10:28
Move the FGA authorization model DSL out of the
inline Helm template and into a standalone file at
charts/lfx-platform/files/model.fga (single source
of truth). model.yaml now uses .Files.Get to include
it. Add a CI workflow that fails PRs which change the
model without bumping the version. Update docs to
reference the new canonical location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
- Add heuristic caveat comment to fga-model-check CI
- Comment indent vs nindent choice in model.yaml
- Fix docs code example note about column-0 template line

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Strip comment and blank lines before comparing model
DSL so that annotation-only updates (@fgadoc:jtbd,
@fgadoc:alias, @fgadoc:hide) do not require a version
bump, matching the policy documented in model.yaml.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
- Pipe directly into strip() instead of passing
  /dev/stdin, which is unreliable in subshells
- Replace \s with [[:space:]] for POSIX portability

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Add committee_for_member_roster_access,
committee_for_member_email_access, roster_viewer,
and email_viewer relations merged in #130.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt bramwelt force-pushed the tbramwell/LFXV2-1646-extract-fga-model branch from fe9d512 to 43d722a Compare May 5, 2026 17:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the OpenFGA authorization model so the DSL lives in a standalone chart file instead of being embedded inline in the Helm template, and adds documentation/CI around that workflow. It fits the codebase by separating the model source from deployment metadata while keeping the chart-rendered AuthorizationModelRequest shape the same.

Changes:

  • Extracted the OpenFGA DSL into charts/lfx-platform/files/model.fga and updated the Helm template to load it with .Files.Get.
  • Updated docs/openfga.md to describe the new edit flow and the template indirection.
  • Added a new fga-model-check GitHub Actions workflow intended to guard model updates.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
docs/openfga.md Updates operator/model maintenance docs to reference the extracted DSL file.
charts/lfx-platform/templates/openfga/model.yaml Replaces the inline authorization model block with a .Files.Get include.
charts/lfx-platform/files/model.fga New standalone source file containing the OpenFGA model DSL and @fgadoc annotations.
.github/workflows/fga-model-check.yml Adds PR-time checks around OpenFGA model edits and version-update enforcement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread charts/lfx-platform/templates/openfga/model.yaml
Comment thread .github/workflows/fga-model-check.yml
Comment thread .github/workflows/fga-model-check.yml
Comment thread docs/openfga.md Outdated
Address review comments from coderabbitai[bot],
copilot-pull-request-reviewer[bot]:

- .github/workflows/fga-model-check.yml: handle missing model.fga on
  base branch — git show now uses 2>/dev/null with fallback so first-
  time additions are treated as changed rather than failing CI
  (per coderabbitai[bot])
- .github/workflows/fga-model-check.yml: add || true to strip() so
  comment/blank-only model files don't produce non-zero exits
  (per coderabbitai[bot])
- .agents/skills/render-permissions/SKILL.md: update to read
  files/model.fga directly instead of parsing the authorizationModel
  block in model.yaml (per copilot-pull-request-reviewer[bot])
- .agents/skills/populate-jtbds/SKILL.md: update to write @fgadoc:jtbd
  annotations into files/model.fga; fix indentation note (4 spaces
  not 12) and ripgrep command (per copilot-pull-request-reviewer[bot])
- PERMISSIONS.md: update generated-intro source path to model.fga
- docs/openfga.md: clarify that CI verifies co-editing of both files,
  not that version numbers were incremented — version bump is a social
  contract (per copilot-pull-request-reviewer[bot])

Resolves 4 review threads.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
@bramwelt
Copy link
Copy Markdown
Contributor Author

bramwelt commented May 5, 2026

Review Feedback Addressed

Commit: edccc5b

Changes Made

  • .github/workflows/fga-model-check.yml: handle missing model.fga on base branch — git show now uses 2>/dev/null | strip || true so first-time file additions are treated as changed rather than failing CI (per coderabbitai[bot])
  • .github/workflows/fga-model-check.yml: added || true to strip() so blank/comment-only input never exits non-zero (per coderabbitai[bot])
  • .agents/skills/render-permissions/SKILL.md: updated to read charts/lfx-platform/files/model.fga directly; removed outdated Helm-template parsing gotcha (per copilot-pull-request-reviewer[bot])
  • .agents/skills/populate-jtbds/SKILL.md: all write targets updated to model.fga; indentation note corrected from 12 spaces (YAML block scalar offset) to 4 spaces (plain DSL); ripgrep command updated (per copilot-pull-request-reviewer[bot])
  • PERMISSIONS.md: updated generated-intro source path to model.fga
  • docs/openfga.md: clarified that CI verifies co-editing of both files, not that version numbers were incremented — version bump is a social contract (per copilot-pull-request-reviewer[bot])

No Change Needed

  • .github/workflows/fga-model-check.yml:29-37: checking that model.yaml was edited (rather than verifying exact version number increments) is intentional — version bumps are a social contract in this repo, documented both in the workflow comment and now in docs/openfga.md (flagged by copilot-pull-request-reviewer[bot])

Threads Resolved

5 of 5 unresolved threads addressed in this iteration.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/skills/populate-jtbds/SKILL.md:
- Around line 280-284: The fenced code block that begins with lines containing
"# `@fgadoc`:jtbd" and "define <relation>:" is missing a language identifier and
triggers MD040; fix it by adding a language tag (e.g., text) after the opening
triple backticks so the block becomes ```text and retains the same contents,
ensuring the markdown linter no longer flags it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ba49f62-213a-45da-9b30-077e0456f4f4

📥 Commits

Reviewing files that changed from the base of the PR and between 43d722a and edccc5b.

📒 Files selected for processing (5)
  • .agents/skills/populate-jtbds/SKILL.md
  • .agents/skills/render-permissions/SKILL.md
  • .github/workflows/fga-model-check.yml
  • PERMISSIONS.md
  • docs/openfga.md
✅ Files skipped from review due to trivial changes (1)
  • PERMISSIONS.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/fga-model-check.yml
  • docs/openfga.md

Comment thread .agents/skills/populate-jtbds/SKILL.md Outdated
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 5, 2026 17:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/fga-model-check.yml Outdated
Comment thread .agents/skills/populate-jtbds/SKILL.md Outdated
Comment thread .github/workflows/fga-model-check.yml
Comment thread .agents/skills/populate-jtbds/SKILL.md
Comment thread docs/openfga.md Outdated
bramwelt and others added 2 commits May 5, 2026 10:48
Restore the yaml code fence indicator and the explicit
whitespace in the ripgrep outlier-detection pattern that
were incorrectly removed in the previous review commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Address review comments from copilot-pull-request-reviewer[bot]:

- .github/workflows/fga-model-check.yml: fix strip() to use sed to
  remove inline trailing comments (e.g. "# Parent relationship") so
  that inline-comment-only edits are correctly skipped
  (per copilot-pull-request-reviewer[bot])
- .agents/skills/populate-jtbds/SKILL.md: fix ripgrep outlier pattern
  to whitelist both 4-space relation-level lines and 0-space type-level
  @fgadoc: annotations; update Step 8 verify to note PERMISSIONS.md
  should also be regenerated after JTBD edits
  (per copilot-pull-request-reviewer[bot])
- docs/openfga.md: add step 3 to regenerate PERMISSIONS.md via the
  render-permissions skill after editing model.fga
  (per copilot-pull-request-reviewer[bot])
- PR description: remove overstatement about syntax validation and
  strip portability checks (per copilot-pull-request-reviewer[bot])

Resolves 5 review threads.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 5, 2026 18:33
@bramwelt
Copy link
Copy Markdown
Contributor Author

bramwelt commented May 5, 2026

Review Feedback Addressed (Round 2)

Commit: 7ba2db3

Changes Made

  • .github/workflows/fga-model-check.yml: fixed strip() to use sed to remove inline trailing comments before filtering blank lines — inline comments like # Parent relationship are now correctly stripped (per copilot-pull-request-reviewer[bot])
  • .agents/skills/populate-jtbds/SKILL.md: fixed ripgrep outlier pattern to whitelist both 4-space relation-level lines and 0-space type-level # @fgadoc: annotations — the old 12/8-space pattern was a leftover from the YAML block scalar era (per copilot-pull-request-reviewer[bot])
  • .agents/skills/populate-jtbds/SKILL.md: updated Step 8 verification to note that PERMISSIONS.md should also be regenerated after annotation updates (per copilot-pull-request-reviewer[bot])
  • docs/openfga.md: added step 3 to regenerate PERMISSIONS.md via the render-permissions skill after editing model.fga; deploy step renumbered to 4 (per copilot-pull-request-reviewer[bot])
  • PR description: removed overstatement — workflow detects model/template co-editing, does not validate syntax or strip portability (per copilot-pull-request-reviewer[bot])

Threads Resolved

5 of 5 unresolved threads addressed in this iteration.

@bramwelt
Copy link
Copy Markdown
Contributor Author

bramwelt commented May 5, 2026

Review Feedback Addressed (Round 2)

Commit: 7ba2db3

Changes Made

  • .github/workflows/fga-model-check.yml: fixed strip() to use sed to remove inline trailing comments before the blank-line filter — e.g. define groupsio_service: [groupsio_service] # Parent relationship is now correctly treated as a non-DSL-change (per copilot-pull-request-reviewer[bot])
  • .agents/skills/populate-jtbds/SKILL.md: fixed ripgrep outlier pattern to whitelist both 4-space relation-level lines and 0-space type-level # @fgadoc: annotations; updated Step 8 to note PERMISSIONS.md should be regenerated after annotation edits (per copilot-pull-request-reviewer[bot])
  • docs/openfga.md: added step 3 — regenerate PERMISSIONS.md via render-permissions skill after editing model.fga; deploy step renumbered to 4 (per copilot-pull-request-reviewer[bot])
  • PR description: removed overstatement about syntax validation and strip portability (per copilot-pull-request-reviewer[bot])

Threads Resolved

5 of 5 unresolved threads addressed in this iteration.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/fga-model-check.yml Outdated
bramwelt and others added 2 commits May 5, 2026 11:40
The previous sed pattern used [[:space:]]* (zero or more spaces)
which also stripped # in DSL type references like team#member.
Fix by splitting the removal into two passes:
  1. grep removes full-line comments (^[[:space:]]*#)
  2. sed removes trailing inline comments ([[:space:]]+#.*$)
     using \+ (one or more spaces) so team#member is preserved.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Issue: LFXV2-1646
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Pass github.base_ref through an environment variable instead of
interpolating it directly into the shell script, preventing a
crafted branch name from injecting shell commands.

Co-authored-by: Copilot (claude-sonnet-4.6) <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Copilot AI review requested due to automatic review settings May 5, 2026 22:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

fga-model-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants