Skip to content

Align ContextResolver parameters with Step.With and document AuthSession support#249

Merged
blindzero merged 4 commits intomainfrom
copilot/align-contextresolver-parameters
Feb 27, 2026
Merged

Align ContextResolver parameters with Step.With and document AuthSession support#249
blindzero merged 4 commits intomainfrom
copilot/align-contextresolver-parameters

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 27, 2026

Context Resolvers now use the same With.* parameter shape as Steps. Root-level Provider on a resolver entry is a breaking change — it is no longer a valid key and will fail schema validation.

Changes Made

Schema validation (Test-IdleWorkflowSchema.ps1)

  • Removed Provider from the ContextResolver allowed root keys (now only Capability and With are permitted at resolver root).
  • Added validation for With.Provider (must be a non-empty string when present) and With.AuthSessionOptions (must be a hashtable when present).

Resolver execution (Invoke-IdleContextResolvers.ps1)

  • Provider alias is now read from With.Provider instead of the resolver root.
  • Ambiguity error message updated to reference With.Provider.

Test fixtures and example workflows

  • All resolver test fixtures (tests/fixtures/workflows/resolver-*.psd1) and the mock example workflow (examples/workflows/mock/joiner-with-context-resolvers.psd1) updated to use With.Provider.

Documentation

  • docs/use/workflows/context-resolver.md: canonical With.* schema with a full parameter table covering IdentityKey, Provider, AuthSessionName, and AuthSessionOptions; full example showing With.AuthSessionName usage with AuthSessionBroker; troubleshooting updated to reference With.Provider.
  • docs/reference/capabilities.md: example updated to use With.Provider inside With.
  • Provider docs template (docs/reference/providers/_provider-name_template.md) and AD provider docs updated with a Context Resolvers section describing supported capabilities, output paths, and AuthSession applicability.

New tests (Test-IdleWorkflowSchema.Tests.ps1)

Added schema validation tests:

  • Root-level Provider key is rejected.
  • With.Provider empty string is rejected.
  • With.AuthSessionOptions non-hashtable is rejected.
  • Valid resolver with With.Provider and With.AuthSessionOptions is accepted.

Canonical ContextResolver schema

ContextResolvers = @(
  @{
    Capability = 'IdLE.Identity.Read'
    With = @{
      IdentityKey        = '{{Request.IdentityKeys.Primary}}'
      Provider           = 'Identity'           # optional
      AuthSessionName    = 'Tier0'              # optional; requires AuthSessionBroker in Providers
      AuthSessionOptions = @{ Role = 'Tier0' }  # optional hashtable
    }
  }
)

Testing

  • ✅ All 691 tests pass
  • ✅ Script analyzer: 0 errors (8 pre-existing warnings unrelated to this change)
Original prompt

This section details on the original issue you should resolve

<issue_title>Align ContextResolver parameters with Step.With + document AuthSession support</issue_title>
<issue_description>## Problem Statement

Context Resolvers must behave exactly like Steps regarding parameter shape and provider/auth handling.

Today there are two inconsistencies:

  1. Provider parameter shape is inconsistent

    • Steps pass execution parameters via With.* (including With.Provider).
    • Context Resolvers currently accept Provider as a root-level key (outside of With).
    • This creates two different workflow “dialects” and increases misconfiguration risk.
  2. AuthSession is implemented but under-documented

    • The engine already supports With.AuthSessionName and With.AuthSessionOptions for Context Resolvers via the same AuthSessionBroker pattern as Steps.
    • The public docs do not document this consistently.

This issue is a breaking change by design:

  • No legacy compatibility, no aliases, no “migration” docs, no “deprecated” comments.

Proposed Solution

1) Canonical ContextResolver schema (same as Steps)

Context Resolvers MUST use Step-like With.* parameters:

ContextResolvers = @(
  @{
    Capability = 'IdLE.Identity.Read'
    With = @{
      IdentityKey        = '{{Request.IdentityKeys.Primary}}'
      Provider           = 'Identity'           # optional
      AuthSessionName    = 'Tier0'              # optional
      AuthSessionOptions = @{ Role = 'Tier0' }  # optional hashtable
    }
  }
)

Rules:

  • Capability stays a required root key (unchanged).
  • Provider at resolver root is removed (breaking; invalid schema).
  • With.IdentityKey is required per capability:
    • required for IdLE.Identity.Read
    • required for IdLE.Entitlement.List
  • With.Provider is optional, but provider selection MUST follow Step-like behavior (see below).
  • With.AuthSessionName / With.AuthSessionOptions are supported and MUST behave like Steps.

2) Provider selection behavior (must match Steps)

Provider selection for Context Resolvers MUST be performed by the engine (not by providers), and MUST behave like Steps:

  • If With.Provider is set: use that provider alias.
  • If With.Provider is not set:
    • Find providers that advertise the resolver capability.
    • 0 matches → fail-fast (clear error).
    • 1 match → use that provider.
    • >1 matches → fail-fast (ambiguity; user must specify With.Provider).

No “pick first”, no hidden ordering-based behavior.

3) AuthSession behavior (must match Steps)

Context Resolvers MUST use the same AuthSessionBroker mechanism as Steps:

  • If With.AuthSessionName is specified:
    • Require an AuthSessionBroker in Providers.
    • Acquire session via broker using name and options.
    • Pass AuthSession into provider methods that accept it (backwards-compatible via parameter detection).
  • If no With.AuthSessionName is specified:
    • Behavior MUST be identical to Steps (keep the same default-acquisition rules Steps use today).

Security boundary:

  • With.AuthSessionOptions must be a hashtable.
  • ScriptBlocks inside AuthSessionOptions are rejected (same guardrails as Steps).

4) Implementation changes

4.1 Workflow schema validation

Update IdLE.Core/Private/Test-IdleWorkflowSchema.ps1:

  • ContextResolvers allowed keys at resolver root:
    • Capability
    • With
  • Remove root key Provider from the allowlist.
  • Validate:
    • With must be a hashtable if present.
    • With.Provider must be a non-empty string if present.
    • With.AuthSessionOptions must be a hashtable if present.

Capability-specific required keys like With.IdentityKey are validated at dispatch time (see below), but may also be enforced at schema-validation time if desired (optional).

4.2 Resolver execution

Update IdLE.Core/Private/Invoke-IdleContextResolvers.ps1:

  • Provider alias must be read from With.Provider (not from resolver root).
  • Provider selection must follow the behavior defined above (0/1/>1 matches).
  • Auth session acquisition must match Steps (align with Invoke-IdleProviderMethod behavior).
  • Dispatch must continue to validate capability-specific required inputs (e.g., With.IdentityKey for current allowlisted capabilities).

5) Documentation updates (required)

Update docs (no legacy notes, no migration section, no deprecated comments):

  • Context Resolver docs in docs/use/workflows/...:
    • show canonical schema with With.Provider
    • document With.IdentityKey, With.Provider, With.AuthSessionName, With.AuthSessionOptions
    • include at least one example using AuthSessionBroker (With.AuthSessionName)
  • Provider docs template + provider docs:
    • Context Resolver provider section must describe:
      • which Context Resolver capabilities are supported
      • what is written into Request.Context.*
      • how AuthSession applies (same pattern as Steps)

Alt...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

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.

Copilot wasn't able to review any files in this pull request.

@blindzero
Copy link
Copy Markdown
Owner

@copilot pls start a new agent session to realize this pr

…ovider key

Co-authored-by: blindzero <13959569+blindzero@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 27, 2026

@copilot pls start a new agent session to realize this pr

Done in commit 075efa1. Here's a summary of what was implemented:

Breaking change — root Provider removed from ContextResolver schema

  • Test-IdleWorkflowSchema.ps1: removed Provider from the resolver allowed-keys list; added validation for With.Provider (non-empty string) and With.AuthSessionOptions (hashtable)
  • Invoke-IdleContextResolvers.ps1: provider alias is now read from With.Provider instead of root Provider; ambiguity error updated to reference With.Provider
  • All resolver test fixtures and the mock example workflow updated to use With.Provider
  • Docs updated: docs/use/workflows/context-resolver.md now shows the canonical With.* schema with a full key table covering IdentityKey, Provider, AuthSessionName, and AuthSessionOptions (including an AuthSessionBroker example); docs/reference/capabilities.md example updated to match
  • New schema validation tests added to Test-IdleWorkflowSchema.Tests.ps1 (root Provider rejected, With.Provider empty string, With.AuthSessionOptions non-hashtable, valid resolver accepted)

All 691 tests pass.

Copilot AI changed the title [WIP] Align ContextResolver parameters with Step.With and document AuthSession support Align ContextResolver parameters with Step.With and document AuthSession support Feb 27, 2026
@blindzero blindzero marked this pull request as ready for review February 27, 2026 20:27
Copilot AI review requested due to automatic review settings February 27, 2026 20:27
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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 13 out of 13 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/IdLE.Core/Private/Invoke-IdleContextResolvers.ps1:21

  • The help text claims AuthSession handling uses the “same pattern as step execution”, but the resolver implementation currently always swallows exceptions from default auth acquisition (AcquireAuthSession('', $null)), whereas Invoke-IdleProviderMethod rethrows when the target provider method supports AuthSession. This can cause resolvers to silently proceed without auth even when a provider supports/requires it. Please align the resolver’s default acquisition error handling with step behavior (or adjust the help text if the difference is intentional).
    - Auth sessions are supported via With.AuthSessionName / With.AuthSessionOptions,
      using the AuthSessionBroker in Providers (same pattern as step execution).

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Code Coverage Report

Overall Project 74.12% 🍏

There is no coverage information present for the Files changed

@blindzero blindzero merged commit e401541 into main Feb 27, 2026
8 checks passed
@blindzero blindzero deleted the copilot/align-contextresolver-parameters branch March 22, 2026 16:22
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.

Align ContextResolver parameters with Step.With + document AuthSession support

3 participants