Skip to content

feat(auth): LogicalModel scope for Method ACL and FieldRule - #259

Open
buke wants to merge 10 commits into
mainfrom
feat/logical-model-acl-field-rule
Open

feat(auth): LogicalModel scope for Method ACL and FieldRule#259
buke wants to merge 10 commits into
mainfrom
feat/logical-model-acl-field-rule

Conversation

@buke

@buke buke commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

  • Add a fifth exclusive LogicalModel scope on RoleMethodAccess / RoleFieldRule so one grant covers per-app isomorphic inject models (TranslationTerm / FieldDefault / AppSetting) across all host apps.
  • Wire runtime eval (CheckMethodAccess, FieldRule, PermissionState ACL aggregation), core base-class self-registration for logical names, bootstrap preset grants, and admin Method/Field scope UI (selection + Onchange exclusivity).
  • Keep system catalog/pipeline reads on narrow withRepositoryAuthzRuleBypass (e.g. Login AppSetting.Get); do not use Logical grants as data-plane sudo.

Test plan

  • ./choysum test unit auth --be
  • ./choysum test unit auth --fe
  • ./choysum test unit core --be (logical model registry)
  • Rebuild DB / reinstall modules; confirm bootstrap seeds Logical grants for terminology.editor / base.user / sys.admin
  • Admin UI: create Method Access with Logical Model + Methods; Field Rule with Logical Model; verify Meta* and Logical clear each other via Onchange
  • With terminology.editor, Search/Update on base.TranslationTerm (non-auth host) is allowed; GetTranslations still works via internal path without user Logical grant

Made with Cursor


Summary by cubic

Adds a LogicalModel scope to RoleMethodAccess and RoleFieldRule so one rule covers per‑app inject models across all host apps. Updates runtime, admin UI, and seeds; rebuild the DB or reinstall modules to apply new grants.

  • New Features

    • Added LogicalModelName as a fifth, exclusive scope; optional LogicalMethods whitelist (empty/null = all).
    • Core logical model registry with self‑registration from platform bases; initial names: AppSetting, FieldDefault, TranslationTerm.
    • Runtime: method access matches Logical Model and honors LogicalMethods; field rules resolve in order Field > Model > Application > Logical Model > Global; ACL aggregation expands logical grants to matching app models and allowed methods.
    • Admin: forms/lists expose Logical Model and LogicalMethods; Onchange enforces exclusive scopes. Seeds add logical grants for terminology.editor (TranslationTerm), base.user (FieldDefault), and sys.admin (AppSetting).
  • Bug Fixes

    • Hardened LogicalMethods: malformed payloads fail closed; non‑string entries rejected; stale whitelists cleared when the logical model changes; renames require methods only when the name actually changes; reaffirming the same name is allowed; methods‑only updates keep the name; rejected updates leave stored scope/mode unchanged.
    • Bulk reaffirm guard: Count proofs now match Update options and updates run only on rows already at the target LogicalModelName to prevent racey renames.
    • Internal ops bypass Record/Field rules where needed: AppSetting.Get and FieldDefault store Get/Set/Unset use narrow repository‑level bypass so logical grants work without per‑app RR/FR seeds. E2E smoke reuses loginAsE2EAdmin to avoid auth init races.
    • RoleMethodAccess.Create lets Source default via the field factory; ui is coerced to manual when provided.

Written for commit 75936a8. Summary will update on new commits.

Review in cubic


PR Type

Enhancement


Description

  • Go core (outside modules/): No changes in this PR.

  • TypeScript modules: Added LogicalModel scope to RoleMethodAccess and RoleFieldRule.

  • Registered AppSetting, FieldDefault, and TranslationTerm in core logical model registry.

  • Updated runtime evaluation, ACL aggregation, bootstrap grants, and admin views.

  • Verified SPDX headers on all 4 new source files; expanded unit test coverage.


File Walkthrough

Relevant files
Enhancement
13 files
logical_model_registry.ts
Create process-local registry for logical model names       
+52/-0   
app_setting_base_model.ts
Register AppSetting as a logical model short name               
+4/-0     
field_default_base_model.ts
Register FieldDefault as a logical model short name           
+4/-0     
translation_term_base_model.ts
Register TranslationTerm as a logical model short name     
+4/-0     
_logical_model_registry.ts
Provide auth helpers for logical model normalization and matching
+95/-0   
_rule_scope_helpers.ts
Support LogicalModelName in exclusive scope validation     
+45/-17 
_user_field_rule_eval.ts
Evaluate LogicalModel scoped rules in field rule evaluation
+34/-7   
_user_method_access.ts
Incorporate LogicalModel scope into method access resolution
+30/-3   
_user_permission_state_acl.ts
Aggregate LogicalModel ACL grants into permission state   
+36/-6   
role_field_rule.ts
Add LogicalModelName field and Onchange clear handlers     
+52/-5   
role_method_access.ts
Add LogicalModelName and LogicalMethods fields with payload
normalization
+115/-13
RoleFieldRuleFormView.vue
Expose LogicalModel selection in Field Rule form view       
+8/-1     
RoleMethodAccessFormView.vue
Expose LogicalModel and LogicalMethods in Method Access form view
+8/-1     
Configuration changes
1 files
bootstrap.json
Update seed bootstrap grants to use LogicalModel scope     
+50/-20 
Tests
6 files
logical_model_registry.test.ts
Add tests for core logical model registry self-registration
+49/-0   
logical_model_registry.test.ts
Add unit tests for auth logical model registry helpers     
+41/-0   
rule_scope_helpers.test.ts
Update scope helper tests for LogicalModel shapes               
+47/-19 
permission_state_acl_source.test.ts
Add test for LogicalModel scope in ACL aggregation             
+43/-0   
method_access_eval_observability.test.ts
Add method access evaluation test for logical methods whitelist
+23/-0   
access_rules_field_binding.test.ts
Verify LogicalModel field bindings in admin Vue views       
+11/-0   
Additional files
5 files
_user_lifecycle_auth.ts +6/-1     
user.ts +1/-1     
field_rule.test.ts +40/-0   
RoleFieldRuleListView.vue +1/-0     
RoleMethodAccessListView.vue +1/-0     

Summary by CodeRabbit

  • New Features
    • Added Logical Model scopes for method access and field rules.
    • Added method-specific permissions for Search, Browse, Update, and Count.
    • Added Logical Model and method selection fields to access-rule forms and lists.
    • Added ACL support for TranslationTerm, FieldDefault, and AppSetting models.
  • Bug Fixes
    • Improved scope validation and prevented conflicting permission scopes.
  • Tests
    • Added coverage for logical-model registration, validation, filtering, and permission evaluation.

- Add LogicalModelName (and Method LogicalMethods) as a fifth exclusive scope so one rule covers per-app isomorphic inject models across host apps.

- Wire CheckMethodAccess, FieldRule eval, and PermissionState ACL aggregation; register short names from platform inject bases; seed bootstrap grants and admin scope UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Safely handle invalid JSON in method evaluation

Wrap normalizeLogicalMethods in a try...catch block within logicalMethodsAllow. If
LogicalMethods contains malformed JSON data in the database, catching the error and
returning false prevents unhandled runtime exceptions during authorization
evaluation.

modules/auth/service/models/_logical_model_registry.ts [88-95]

 export function logicalMethodsAllow(methods: unknown, methodName: string): boolean {
   const want = String(methodName || '')
     .trim()
     .toLowerCase();
   if (!want) return false;
-  const list = normalizeLogicalMethods(methods);
+  let list: string[] | null;
+  try {
+    list = normalizeLogicalMethods(methods);
+  } catch {
+    return false;
+  }
   if (list == null) return true;
   return list.some(m => m.toLowerCase() === want);
 }
Suggestion importance[1-10]: 6

__

Why: normalizeLogicalMethods throws an error when passed invalid JSON or non-array values. Wrapping it in a try...catch inside logicalMethodsAllow prevents runtime exceptions during authorization checks if malformed data exists.

Low

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change adds registered logical models as authorization scopes. It supports logical method and field rules, evaluates them in ACL paths, exposes them in administration views, adds bootstrap permissions, and applies repository authorization bypasses to selected internal operations.

Changes

Logical-model ACL support

Layer / File(s) Summary
Logical-model registry and registrations
modules/core/service/orm/model/logical_model_registry.ts, modules/auth/service/models/_logical_model_registry.ts, modules/core/service/orm/model/*_base_model.ts, modules/*/tests/logical_model_registry.test.ts
Registers logical-model names and normalizes logical method lists. Core models register AppSetting, FieldDefault, and TranslationTerm.
Logical-model rule contracts and administration UI
modules/auth/service/models/_rule_scope_helpers.ts, modules/auth/service/models/role_field_rule.ts, modules/auth/service/models/role_method_access.ts, modules/auth/web/views/*Role*Rule*
Adds logical-model scopes, method-list validation, scope exclusivity handlers, form fields, list columns, and scope guidance.
Method, field, and permission-state ACL evaluation
modules/auth/service/models/_user_*, modules/auth/service/models/user.ts, modules/auth/service/tests/*
Matches logical models during field and method evaluation. Method lists filter access by requested method. ACL aggregation applies logical permissions to matching models.
Bootstrap permissions and repository bypasses
modules/auth/data/bootstrap.json, modules/core/service/orm/model/field_default_base_model.ts, modules/auth/service/models/_user_lifecycle_auth.ts
Adds logical permissions for platform models and bypasses repository authorization rules for selected internal lookups, writes, and deletes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Admin
  participant RoleMethodAccessFormView
  participant RoleMethodAccess
  participant evaluateRoleMethodAccess
  participant PermissionStateACL
  Admin->>RoleMethodAccessFormView: Select logical model and methods
  RoleMethodAccessFormView->>RoleMethodAccess: Submit logical scope rule
  evaluateRoleMethodAccess->>RoleMethodAccess: Query logical-model rules
  RoleMethodAccess-->>evaluateRoleMethodAccess: Return matching method permissions
  PermissionStateACL->>RoleMethodAccess: Load logical model and method data
  PermissionStateACL-->>Admin: Expose effective permission state
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding LogicalModel scope support to Method ACL and FieldRule.
Description check ✅ Passed The description explains the scope, runtime changes, UI updates, bootstrap grants, safeguards, and test plan in sufficient detail.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/logical-model-acl-field-rule

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (4)
modules/auth/web/views/access_rules_field_binding.test.ts (2)

37-46: 📐 Maintainability & Code Quality | 🔵 Trivial

Run the required validation checks before merge.

Build the CLI and generate ignored embedded assets before installing modules. Then run the affected auth module typecheck and unit tests, plus applicable auth E2E tests. Confirm that application code remains compatible with embedded QuickJS.

As per coding guidelines, these checks are required for frontend modules and the auth module.

🤖 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 `@modules/auth/web/views/access_rules_field_binding.test.ts` around lines 37 -
46, Before merging changes to the access-rules form bindings tested by
“PR-LM-4”, build the CLI and generate ignored embedded assets before installing
modules. Then run the auth module typecheck, unit tests, applicable auth E2E
tests, and the compatibility validation for embedded QuickJS.

Source: Coding guidelines


37-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend this binding test to cover the new UI contracts.

The test checks the logical property names, but it does not verify :allow-array="true" in modules/auth/web/views/RoleMethodAccessFormView.vue or the new LogicalModelName columns in modules/auth/web/views/RoleMethodAccessListView.vue and modules/auth/web/views/RoleFieldRuleListView.vue. Add assertions for these bindings. The array binding is part of the contract defined by modules/auth/service/models/_logical_model_registry.ts:52-82.

Suggested assertions
     expect(methodForm).toContain('prop="LogicalMethods"');
+    expect(methodForm).toContain(':allow-array="true"');
     expect(methodForm).toContain('Logical Model (all host apps sharing that short name)');

+    expect(viewSource('RoleMethodAccessListView.vue')).toContain('prop="LogicalModelName"');
+    expect(viewSource('RoleFieldRuleListView.vue')).toContain('prop="LogicalModelName"');
🤖 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 `@modules/auth/web/views/access_rules_field_binding.test.ts` around lines 37 -
46, Extend the test case around viewSource in access_rules_field_binding.test.ts
to assert RoleMethodAccessFormView.vue includes the :allow-array="true" binding,
and assert RoleMethodAccessListView.vue and RoleFieldRuleListView.vue each
include the new LogicalModelName column. Preserve the existing property and
label assertions.
modules/auth/service/models/_rule_scope_helpers.ts (1)

29-30: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

supportsLogicalModel is never read.

assertExclusiveScope branches on the field key LogicalModelName at Line 145, not on spec.supportsLogicalModel. The flag is therefore unused metadata. Either use it in the normalization branch or drop it to avoid two sources of truth.

♻️ Option: drive normalization from the flag
-    if (f === 'LogicalModelName') {
+    if (f === 'LogicalModelName' && spec.supportsLogicalModel) {
       ids[f] = normalizeLogicalModelName((values as any)[f]);
     } else {
       ids[f] = normalizeRefId((values as any)[f]);
     }

Also applies to: 145-149

🤖 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 `@modules/auth/service/models/_rule_scope_helpers.ts` around lines 29 - 30,
Resolve the duplicate source of truth between supportsLogicalModel and the
LogicalModelName key check in assertExclusiveScope. Prefer using
spec.supportsLogicalModel to drive the normalization branch, replacing the
hardcoded field-key condition while preserving existing behavior; alternatively
remove the unused flag and its related metadata.
modules/auth/service/tests/permission_state_acl_source.test.ts (1)

270-277: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a case for a logical rule without LogicalMethods.

The current test covers the method-restricted path only. The methods == null branch sets allowAll and emits the rpc:/<app>.<Model>/* wildcard. That branch is untested.

💚 Suggested extra assertions
     expect(allows.has('rpc:/auth.User/*')).toBe(false);
+
+    (RoleMethodAccess as any).Search = async () => [
+      {
+        RoleId: 'role_1',
+        MetaServiceId: null,
+        MetaModelId: null,
+        MetaApplicationId: null,
+        LogicalModelName: 'FieldDefault',
+        LogicalMethods: null,
+        Mode: 'allow',
+        Source: 'manual',
+      },
+    ];
+    const aggAll = await buildAclAggregation(['role_1'], { role_1: { global: true, companies: [] } });
+    const allowsAll = aggAll.requiresAllowKeysByCompany.get('*') || new Set();
+    expect(allowsAll.has('rpc:/auth.FieldDefault/*')).toBe(true);
+    expect(aggAll.companyGlobalAllow.has('*')).toBe(false);
🤖 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 `@modules/auth/service/tests/permission_state_acl_source.test.ts` around lines
270 - 277, Extend the aggregation test around buildAclAggregation to include a
logical rule whose methods value is null or omitted. Assert that the resulting
allows include the rpc:/<app>.<Model>/* wildcard for that rule, covering the
allowAll branch while preserving the existing method-specific assertions.
🤖 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 `@modules/auth/data/bootstrap.json`:
- Around line 76-104: Add a RoleRecordRule grant for the FieldDefault model to
the auth.role_base_user permissions in bootstrap.json, granting the required
write and create access used by FieldDefault.Set. Keep the existing
rma_base_user_field_default_logical and rfr_base_user_field_default_logical
grants unchanged.

In `@modules/auth/service/models/_user_permission_state_acl.ts`:
- Around line 194-199: Handle malformed LogicalMethods consistently per ACL
path: in modules/auth/service/models/_user_permission_state_acl.ts at lines
194-199, preserve the deny row and treat a normalization failure as model-wide;
in modules/auth/service/models/_user_method_access.ts at lines 160-169, catch
normalization errors per row and skip only that invalid rule so method checks do
not fail globally. Update the surrounding ACL projection and method-access
filtering logic without changing valid payload handling.

In `@modules/auth/service/models/role_method_access.ts`:
- Around line 176-195: Update the LogicalModelName handling in the role-method
validation flow to prevent stale LogicalMethods when the scope changes between
logical models. In the update path around touchesLogicalName, detect a changed
non-empty LogicalModelName and either clear LogicalMethods when it is omitted or
require a replacement whitelist in the same payload, while preserving existing
behavior for unchanged scope and non-logical rows.

---

Nitpick comments:
In `@modules/auth/service/models/_rule_scope_helpers.ts`:
- Around line 29-30: Resolve the duplicate source of truth between
supportsLogicalModel and the LogicalModelName key check in assertExclusiveScope.
Prefer using spec.supportsLogicalModel to drive the normalization branch,
replacing the hardcoded field-key condition while preserving existing behavior;
alternatively remove the unused flag and its related metadata.

In `@modules/auth/service/tests/permission_state_acl_source.test.ts`:
- Around line 270-277: Extend the aggregation test around buildAclAggregation to
include a logical rule whose methods value is null or omitted. Assert that the
resulting allows include the rpc:/<app>.<Model>/* wildcard for that rule,
covering the allowAll branch while preserving the existing method-specific
assertions.

In `@modules/auth/web/views/access_rules_field_binding.test.ts`:
- Around line 37-46: Before merging changes to the access-rules form bindings
tested by “PR-LM-4”, build the CLI and generate ignored embedded assets before
installing modules. Then run the auth module typecheck, unit tests, applicable
auth E2E tests, and the compatibility validation for embedded QuickJS.
- Around line 37-46: Extend the test case around viewSource in
access_rules_field_binding.test.ts to assert RoleMethodAccessFormView.vue
includes the :allow-array="true" binding, and assert
RoleMethodAccessListView.vue and RoleFieldRuleListView.vue each include the new
LogicalModelName column. Preserve the existing property and label assertions.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 293fff57-2078-406c-bfaa-2e74eb5a9390

📥 Commits

Reviewing files that changed from the base of the PR and between 1e3b529 and 2eb050b.

📒 Files selected for processing (25)
  • modules/auth/data/bootstrap.json
  • modules/auth/service/models/_logical_model_registry.ts
  • modules/auth/service/models/_rule_scope_helpers.ts
  • modules/auth/service/models/_user_field_rule_eval.ts
  • modules/auth/service/models/_user_lifecycle_auth.ts
  • modules/auth/service/models/_user_method_access.ts
  • modules/auth/service/models/_user_permission_state_acl.ts
  • modules/auth/service/models/role_field_rule.ts
  • modules/auth/service/models/role_method_access.ts
  • modules/auth/service/models/user.ts
  • modules/auth/service/tests/field_rule.test.ts
  • modules/auth/service/tests/logical_model_registry.test.ts
  • modules/auth/service/tests/method_access_eval_observability.test.ts
  • modules/auth/service/tests/permission_state_acl_source.test.ts
  • modules/auth/service/tests/rule_scope_helpers.test.ts
  • modules/auth/web/views/RoleFieldRuleFormView.vue
  • modules/auth/web/views/RoleFieldRuleListView.vue
  • modules/auth/web/views/RoleMethodAccessFormView.vue
  • modules/auth/web/views/RoleMethodAccessListView.vue
  • modules/auth/web/views/access_rules_field_binding.test.ts
  • modules/core/service/orm/model/app_setting_base_model.ts
  • modules/core/service/orm/model/field_default_base_model.ts
  • modules/core/service/orm/model/logical_model_registry.test.ts
  • modules/core/service/orm/model/logical_model_registry.ts
  • modules/core/service/orm/model/translation_term_base_model.ts

Comment thread modules/auth/data/bootstrap.json
Comment thread modules/auth/service/models/_user_permission_state_acl.ts
Comment thread modules/auth/service/models/role_method_access.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 25 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread modules/auth/service/models/_user_permission_state_acl.ts Outdated
Comment thread modules/auth/service/models/_logical_model_registry.ts
Comment thread modules/auth/service/models/_user_permission_state_acl.ts
Comment thread modules/auth/service/models/_rule_scope_helpers.ts
Comment thread modules/auth/service/models/_user_permission_state_acl.ts
Comment thread modules/auth/service/models/_user_field_rule_eval.ts Outdated
Comment thread modules/auth/web/views/access_rules_field_binding.test.ts
Comment thread modules/auth/service/models/_logical_model_registry.ts
Comment thread modules/auth/service/models/role_method_access.ts Outdated
Comment thread modules/auth/service/models/_rule_scope_helpers.ts Outdated
buke and others added 2 commits August 7, 2026 22:47
- Reuse auth's loginAsE2EAdmin helper so Login submit waits for nprogress and Login RPC, matching meta and avoiding stuck /web/login redirects.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Fail closed on malformed LogicalMethods (deny keeps/model-wide; allow skips) and reject non-string whitelist entries.

- Clear stale LogicalMethods when LogicalModelName changes; allow methods-only updates; drop unused supportsLogicalModel.

- Bypass RecordRule/FieldRule on FieldDefault store Get/Set/Unset paths so preset Logical Method grants work without O(apps) RR seeds.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 10 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread modules/auth/service/models/role_method_access.ts Outdated
Comment thread modules/auth/web/views/access_rules_field_binding.test.ts
- Cover LogicalMethods normalize/Onchange/FieldsGet, malformed fail-closed paths, and Logical FieldRule eval.

- Exercise remaining registry and method-access branch edges Codecov reported as partials.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread modules/auth/service/tests/logical_model_acl_coverage.test.ts Outdated
- Require an explicit LogicalMethods payload when LogicalModelName is updated so clearing the whitelist cannot silently widen an allow.

- Restore Logical Model help-text assertions and tighten empty-modelName FieldRule deny-default expectations.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@modules/auth/service/tests/logical_model_acl_coverage.test.ts`:
- Around line 187-200: Update the ACL coverage tests around the rejected rename
and LogicalMethods validation to read the row after each attempted update and
assert that LogicalModelName and LogicalMethods remain equal to their pre-update
values. Preserve the existing rejection-message and rejection assertions while
verifying failed updates do not alter the stored logical scope or whitelist.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: c78a6a1c-eab0-4840-8994-0cfa9924b78a

📥 Commits

Reviewing files that changed from the base of the PR and between 87ab23f and 53ed309.

📒 Files selected for processing (3)
  • modules/auth/service/models/role_method_access.ts
  • modules/auth/service/tests/logical_model_acl_coverage.test.ts
  • modules/auth/web/views/access_rules_field_binding.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • modules/auth/web/views/access_rules_field_binding.test.ts
  • modules/auth/service/models/role_method_access.ts

Comment thread modules/auth/service/tests/logical_model_acl_coverage.test.ts

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread modules/auth/service/models/role_method_access.ts Outdated
Comment thread modules/auth/service/tests/logical_model_acl_coverage.test.ts
- Gate the rename fail-closed throw on an actual LogicalModelName change versus the persisted value so Mode toggles that re-echo scope still succeed.

- Assert rejected renames leave stored scope/methods unchanged and methods-only updates keep LogicalModelName.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread modules/auth/service/models/role_method_access.ts Outdated
Comment thread modules/auth/service/models/role_method_access.ts Outdated
- Prove every matched row already has the target LogicalModelName via Count equality instead of a capped Search sample.

- Fail closed when any matched row is non-logical or has a different name so null whitelist cannot widen allow.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@modules/auth/service/tests/logical_model_acl_coverage.test.ts`:
- Around line 304-312: Update the mixedAfter query and assertions around
RoleMethodAccess.Search to include Mode in the requested fields, then assert
that both the logical-model row and service row retain Mode equal to allow after
the rejected bulk update.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92cc66fe-716a-4156-82ed-a669a25a474f

📥 Commits

Reviewing files that changed from the base of the PR and between 53ed309 and 1e4a145.

📒 Files selected for processing (2)
  • modules/auth/service/models/role_method_access.ts
  • modules/auth/service/tests/logical_model_acl_coverage.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • modules/auth/service/models/role_method_access.ts

Comment thread modules/auth/service/tests/logical_model_acl_coverage.test.ts
- Verify both mixed-scope rows keep Mode=allow when a no-methods LogicalModelName bulk update is rejected.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 2 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="modules/auth/service/models/role_method_access.ts">

<violation number="1" location="modules/auth/service/models/role_method_access.ts:280">
P2: Bulk reaffirm validation checks a different row set when callers use `withDeleted` or `onlyDeleted`, allowing an unvalidated logical-model rename or rejecting a valid reaffirm. Passing the same `options` to both `Count` calls would keep validation aligned with `super.Update`.</violation>

<violation number="2" location="modules/auth/service/models/role_method_access.ts:284">
P1: A concurrent update can change a matched row's logical scope after these counts, so this call may perform a real rename without an explicit `LogicalMethods` whitelist and retain methods from the intervening scope. The proof should be coupled atomically to locked rows, or the final update condition should also require `LogicalModelName === next` so raced rows are skipped safely.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic

Comment thread modules/auth/service/models/role_method_access.ts Outdated
Comment thread modules/auth/service/models/role_method_access.ts Outdated
buke and others added 2 commits August 8, 2026 13:51
- Pass Update options into both Count proofs so withDeleted/onlyDeleted match the write set.

- Narrow the update condition to LogicalModelName === next after a successful reaffirm proof so concurrent scope races are skipped instead of silently renamed.

Co-authored-by: Cursor <cursoragent@cursor.com>
- Cover nullish _needsPreviousLogicalModelName, Count=0 bulk updates, non-logical bulk renames, and missing UpdateById rows.

- Let Create omit Source so the Field default factory runs; still coerce Source=ui to manual when present.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant