mirror of
https://github.com/zenstackhq/zenstack
synced 2026-05-24 10:08:55 +00:00
Fixed issue where access policy rules couldn't reference fields inherited from mixins defined in separate imported files. The language service now correctly resolves these fields during scope computation. ## Root Cause The `getRecursiveBases()` function only searched for mixin declarations in the current document (`decl.$container.declarations`), which failed for imported mixins. ## Solution - Modified `getRecursiveBases()` to accept optional `LangiumDocuments` parameter - Implemented two-strategy approach: 1. Use resolved reference if available (post-linking) 2. Search by name across all documents including imports (pre-linking) - Updated `ZModelScopeComputation.processNode()` to pass `LangiumDocuments` - Leverages existing `getAllDeclarationsIncludingImports()` helper ## Changes - **packages/language/src/utils.ts**: Fixed `getRecursiveBases()` to search imported documents - **packages/language/src/zmodel-scope.ts**: Pass LangiumDocuments to scope computation - **packages/language/test/mixin.test.ts**: Added tests for imported mixin field resolution - **packages/testtools**: Added `extraZModelFiles` option for multi-file test schemas - **tests/regression/test/issue-598.test.ts**: Regression test for the issue ## Test Results ✅ All language package tests pass (65 tests) ✅ Regression test validates policy rules can access imported mixin fields ✅ Handles edge cases: cyclic imports, nested mixins, transitive imports Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| attribute-application.test.ts | ||
| delegate.test.ts | ||
| expression-validation.test.ts | ||
| function-invocation.test.ts | ||
| import.test.ts | ||
| mixin.test.ts | ||
| procedure-validation.test.ts | ||
| this-resolution.test.ts | ||
| utils.ts | ||
| view.test.ts | ||