-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Planning-time ContextResolvers (read-only) to populate Request.Context before condition evaluation #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
500f29f
Initial plan
Copilot 091f14d
feat: implement planning-time ContextResolvers for Request.Context po…
Copilot 12c2d28
refactor: remove To from ContextResolvers schema, add predefined path…
Copilot 08ac130
Merge branch 'main' into copilot/implement-context-resolvers
blindzero 6693e57
fix: auth session threading, ambiguity detection, context type confli…
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
examples/workflows/mock/joiner-with-context-resolvers.psd1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| @{ | ||
| # Joiner workflow demonstrating ContextResolvers to enrich Request.Context at planning time. | ||
| # | ||
| # ContextResolvers run BEFORE step conditions are evaluated. They use read-only provider | ||
| # capabilities to fetch data and write it under Request.Context.*. | ||
| # | ||
| # Each capability writes to a predefined path (no user-configurable 'To'): | ||
| # IdLE.Entitlement.List -> Request.Context.Identity.Entitlements | ||
| # IdLE.Identity.Read -> Request.Context.Identity.Profile | ||
|
|
||
| Name = 'Joiner - ContextResolvers Demo' | ||
| LifecycleEvent = 'Joiner' | ||
|
|
||
| # Planning-time resolvers: run before condition evaluation. | ||
| # Each capability has a predefined output path under Request.Context.* | ||
| ContextResolvers = @( | ||
| @{ | ||
| # Fetch current entitlements for the identity being onboarded. | ||
| # Writes to Request.Context.Identity.Entitlements (predefined). | ||
| Capability = 'IdLE.Entitlement.List' | ||
|
|
||
| # The provider alias that supports IdLE.Entitlement.List. | ||
| # If omitted, the first provider advertising the capability is used. | ||
| Provider = 'Identity' | ||
|
|
||
| # Resolver inputs. | ||
| With = @{ | ||
| IdentityKey = 'user1' | ||
| } | ||
| } | ||
| ) | ||
|
|
||
| Steps = @( | ||
| @{ | ||
| # Always runs - ensures the base group membership. | ||
| Name = 'EnsureBaseGroup' | ||
| Type = 'IdLE.Step.EnsureEntitlement' | ||
| With = @{ | ||
| IdentityKey = 'user1' | ||
| Entitlement = @{ Kind = 'Group'; Id = 'all-employees' } | ||
| State = 'Present' | ||
| Provider = 'Identity' | ||
| } | ||
| } | ||
|
|
||
| @{ | ||
| # Runs only when entitlements were successfully pre-resolved by the ContextResolver. | ||
| # References the predefined context path for IdLE.Entitlement.List. | ||
| Name = 'EmitContextAvailable' | ||
| Type = 'IdLE.Step.EmitEvent' | ||
| Condition = @{ | ||
| Exists = 'Request.Context.Identity.Entitlements' | ||
| } | ||
| With = @{ | ||
| Message = 'Entitlement context was pre-resolved by ContextResolvers and is available for planning.' | ||
| } | ||
| } | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| Set-StrictMode -Version Latest | ||
|
|
||
| function Get-IdleReadOnlyCapabilities { | ||
| <# | ||
| .SYNOPSIS | ||
| Returns the allow-list of read-only capabilities usable in ContextResolvers. | ||
|
|
||
| .DESCRIPTION | ||
| ContextResolvers may only invoke capabilities from this allow-list. | ||
| This enforces the read-only guarantee at planning time: resolvers cannot | ||
| trigger mutations or side effects via the planning pipeline. | ||
|
|
||
| Only capabilities that are safe to invoke at planning time (no side effects, | ||
| deterministic, serializable output) should be added to this list. | ||
|
|
||
| Each capability in this list has a predefined output path in Request.Context | ||
| (see Get-IdleCapabilityContextPath). | ||
|
|
||
| .OUTPUTS | ||
| String[] | ||
|
|
||
| .EXAMPLE | ||
| $allowed = Get-IdleReadOnlyCapabilities | ||
| # Returns: @('IdLE.Entitlement.List', 'IdLE.Identity.Read') | ||
| #> | ||
| [CmdletBinding()] | ||
| [OutputType([string[]])] | ||
| param() | ||
|
|
||
| return @( | ||
| 'IdLE.Entitlement.List' | ||
| 'IdLE.Identity.Read' | ||
| ) | ||
| } | ||
|
|
||
| function Get-IdleCapabilityContextPath { | ||
| <# | ||
| .SYNOPSIS | ||
| Returns the predefined Request.Context sub-path for a read-only capability. | ||
|
|
||
| .DESCRIPTION | ||
| Each read-only capability allowed in ContextResolvers writes its result to a fixed, | ||
| predefined path under Request.Context. This prevents user-configurable overwrites | ||
| and ensures consistent context shape across workflows. | ||
|
|
||
| The path is relative to Request.Context (e.g., 'Identity.Entitlements' maps to | ||
| Request.Context.Identity.Entitlements). | ||
|
|
||
| .PARAMETER Capability | ||
| The capability identifier (must be in the read-only allow-list). | ||
|
|
||
| .OUTPUTS | ||
| String | ||
|
|
||
| .EXAMPLE | ||
| Get-IdleCapabilityContextPath -Capability 'IdLE.Entitlement.List' | ||
| # Returns: 'Identity.Entitlements' | ||
|
|
||
| .EXAMPLE | ||
| Get-IdleCapabilityContextPath -Capability 'IdLE.Identity.Read' | ||
| # Returns: 'Identity.Profile' | ||
| #> | ||
| [CmdletBinding()] | ||
| [OutputType([string])] | ||
| param( | ||
| [Parameter(Mandatory)] | ||
| [ValidateNotNullOrEmpty()] | ||
| [string] $Capability | ||
| ) | ||
|
|
||
| switch ($Capability) { | ||
| 'IdLE.Entitlement.List' { return 'Identity.Entitlements' } | ||
| 'IdLE.Identity.Read' { return 'Identity.Profile' } | ||
| default { | ||
| throw [System.ArgumentException]::new( | ||
| "No predefined context path defined for capability '$Capability'.", | ||
| 'Capability' | ||
| ) | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.