-
Notifications
You must be signed in to change notification settings - Fork 1
Added composite resource 'AADSyncRuleCounts' #11
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,31 +4,52 @@ _Last updated: 2026-05-18_ | |
|
|
||
| ## Current Focus | ||
|
|
||
| Project is in **maintenance mode**. No active feature work. The module has not | ||
| been touched for an extended period (last substantive work: October 2025 | ||
| documentation pass). | ||
|
|
||
| This turn: refreshed the Memory Bank to align with the current agent | ||
| definition (folder renamed `memory-bank/` → `.memory-bank/`, added | ||
| `promptHistory.md`, trimmed `activeContext.md` and `progress.md` to the | ||
| prescribed caps). | ||
| Adding a new composite resource `AADSyncRuleCounts` that wraps the report-only | ||
| `AADSyncRuleCount` DSC resource introduced in the `feature/AadsyncrulecountResource` | ||
| branch of the `AADConnectDsc` repository (working copy at `d:\a`). | ||
|
|
||
| The composite mirrors the existing `AADSyncRules` / | ||
| `AADConnectDirectoryExtensionAttributes` schema-module pattern. It accepts an | ||
| array of hashtables (`ConnectorName`, `RuleCount`) and emits one | ||
| `AADSyncRuleCount` instance per item, mapping empty / `'*'` connector names to | ||
| the literal token `AllConnectors` so execution names stay unique. | ||
|
|
||
| Files added/changed on branch `ai/add-aadsyncrulecounts`: | ||
|
|
||
| - `source/DSCResources/AADSyncRuleCounts/AADSyncRuleCounts.psd1` | ||
| - `source/DSCResources/AADSyncRuleCounts/AADSyncRuleCounts.schema.psm1` | ||
| - `tests/Unit/DSCResources/Assets/Config/AADSyncRuleCounts.yml` | ||
| - `docs/AADSyncRuleCounts.md` | ||
| - `examples/6-AADSyncRuleCounts.ps1` | ||
| - `examples/README.md`, `README.md`, `CHANGELOG.md` updates | ||
| - This memory bank refresh | ||
|
|
||
| ## Open Decisions | ||
|
|
||
| None. No pending design questions. | ||
| - Discovered (and fixed) a pre-existing bug: the module manifest was missing | ||
| `DscResourcesToExport`, which made `Get-DscResource -Module` return zero | ||
| composite resources in PowerShell 7. The build had been silently broken. | ||
| - The `AADSyncRuleCounts` compile test is enabled. It requires an | ||
| `AADConnectDsc` build that exposes `AADSyncRuleCount` (v0.6.0 of | ||
| `AADConnectDsc` or later). Local build uses the 0.6.0 build copied | ||
| from `d:\a` into `output/RequiredModules/AADConnectDsc/0.6.0/`. CI will | ||
| pick it up once `RequiredModules.psd1` (already `latest`) resolves to a | ||
| published version that ships `AADSyncRuleCount`. | ||
| - **In-process DSC parser caching**: `Get-DscResource -Module` and the DSC | ||
| keyword table are cached per process. Re-running the build in a long-lived | ||
| pwsh session that previously loaded an older `AADConnectDsc` will leave | ||
| stale keywords and make the new resource appear missing. Always run the | ||
| build in a fresh process (or `pwsh -NoProfile`) when changing the | ||
| underlying `AADConnectDsc` version. | ||
|
|
||
| ## Next Steps (when work resumes) | ||
|
|
||
| 1. Verify build still passes against current `AADConnectDsc` and `Sampler` | ||
| versions (`./build.ps1 -AutoRestore -Tasks test`). | ||
| 2. Refresh `RequiredModules.psd1` pins if dependencies have moved. | ||
| 3. Review open issues / PRs on the DscCommunity repo before any change. | ||
| 4. Reconsider whether `productContext.md` should be folded into | ||
| `projectbrief.md` — it is no longer in the always-loaded set per the new | ||
| agent spec and currently lives as an on-demand topic file. | ||
| 1. Wait for the `AADConnectDsc` PR (`feature/AadsyncrulecountResource`) to be | ||
| merged and a new version published, so CI can resolve `AADConnectDsc` from | ||
| the gallery instead of relying on the local 0.6.0 copy. | ||
| 2. Cut a release with the `Unreleased` entry promoted to a numbered version. | ||
|
|
||
| ## Non-Goals | ||
|
|
||
| - No new composite resources planned. | ||
| - No restructuring of the build pipeline. | ||
| - No migration off Sampler / ModuleBuilder. | ||
| - No additional composite resources planned. | ||
| - No restructuring of the build pipeline. | ||
|
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a single trailing newline at EOF.
🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 55-55: Files should end with a single newline character (MD047, single-trailing-newline) 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Prompt History | ||
|
|
||
| A one-line entry per substantive Copilot turn. Format: | ||
| `YYYY-MM-DD HH:mm UTC | agent | one-line intent` | ||
|
|
||
| 2026-05-18 09:53 UTC | software-engineer | Add AADSyncRuleCounts composite wrapping new AADSyncRuleCount resource from AADConnectDsc | ||
| 2026-05-18 10:06 UTC | software-engineer | Fix broken build: add DscResourcesToExport to manifest; skip AADSyncRuleCounts test until AADConnectDsc ships AADSyncRuleCount | ||
| 2026-05-18 10:30 UTC | software-engineer | Re-enable AADSyncRuleCounts test against local AADConnectDsc 0.6.0; root cause of false failures was per-process DSC keyword caching |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| # AADSyncRuleCounts Composite Resource | ||
|
|
||
| ## Description | ||
|
|
||
| The `AADSyncRuleCounts` composite resource processes arrays of Azure AD Connect | ||
| sync-rule-count expectations and generates individual `AADSyncRuleCount` DSC | ||
| resource instances. It is intended for bulk drift detection: each item declares | ||
| the expected number of sync rules for a given connector (or across all | ||
| connectors) and the underlying [AADSyncRuleCount](https://github.com/dsccommunity/AADConnectDsc) resource reports a configuration failure | ||
| when the actual count diverges from the expected count. | ||
|
|
||
| > [!NOTE] | ||
| > The underlying `AADSyncRuleCount` resource is **report-only**. It does not | ||
| > create or remove sync rules to reach the expected count. When drift is | ||
| > detected the LCM marks the configuration as failed and the operator must | ||
| > investigate manually. | ||
|
|
||
| ## Parameters | ||
|
|
||
| ### Items | ||
|
|
||
| - **Type**: `hashtable[]` | ||
| - **Required**: Yes | ||
| - **Description**: Array of hashtables describing the expected sync-rule counts. | ||
|
|
||
| Each hashtable must contain the parameters required by the underlying | ||
| `AADSyncRuleCount` resource: | ||
|
|
||
| | Property | Type | Required | Description | | ||
| |-----------------|----------|----------|-------------| | ||
| | `ConnectorName` | `string` | Yes (key) | Name of the AAD Connect connector to scope the count to. Use an empty string or `'*'` to count rules across **all** connectors. | | ||
| | `RuleCount` | `uint32` | Yes | The expected number of sync rules for the scope. | | ||
|
|
||
| ## Behavior | ||
|
|
||
| ### Execution Name Generation | ||
|
|
||
| Execution names are generated using the pattern: | ||
|
|
||
| ```text | ||
| AADSyncRuleCount__{scope} | ||
| ``` | ||
|
|
||
| Where `{scope}` is the value of `ConnectorName`, except that an empty string or | ||
| `'*'` is mapped to the literal token `AllConnectors` so the name remains a | ||
| valid, unique resource identifier. Special characters (whitespace, brackets, | ||
| slashes, colons, dashes) are replaced with `_` using the regex pattern | ||
| `[\s(){}/\\:-]`. | ||
|
|
||
| Examples: | ||
|
|
||
| | `ConnectorName` value | Generated execution name | | ||
| |-----------------------|---------------------------------------| | ||
| | `contoso.com` | `AADSyncRuleCount__contoso.com` | | ||
| | `fabrikam.com` | `AADSyncRuleCount__fabrikam.com` | | ||
| | `''` (empty) | `AADSyncRuleCount__AllConnectors` | | ||
| | `*` | `AADSyncRuleCount__AllConnectors` | | ||
|
|
||
| ### Resource Delegation | ||
|
|
||
| Each item is passed to a single `AADSyncRuleCount` resource instance via the | ||
| `Get-DscSplattedResource` utility. The composite performs no validation beyond | ||
| ensuring the items are processable; the underlying resource is responsible for | ||
| key/type validation. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Example 1: Per-connector count check | ||
|
|
||
| ```powershell | ||
| Configuration BasicRuleCounts { | ||
| Import-DscResource -ModuleName DscConfig.AADConnect | ||
|
|
||
| Node localhost { | ||
| AADSyncRuleCounts 'CompanyRuleCounts' { | ||
| Items = @( | ||
| @{ ConnectorName = 'contoso.com'; RuleCount = 42 } | ||
| @{ ConnectorName = 'fabrikam.com'; RuleCount = 30 } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Example 2: Total count across all connectors | ||
|
|
||
| ```powershell | ||
| Configuration TotalRuleCount { | ||
| Import-DscResource -ModuleName DscConfig.AADConnect | ||
|
|
||
| Node localhost { | ||
| AADSyncRuleCounts 'TotalCount' { | ||
| Items = @( | ||
| @{ ConnectorName = '*'; RuleCount = 168 } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Example 3: Configuration-management integration | ||
|
|
||
| ```yaml | ||
| # Datum / DscWorkshop configuration data | ||
| AADSyncRuleCounts: | ||
| Items: | ||
| - ConnectorName: contoso.com | ||
| RuleCount: 42 | ||
| - ConnectorName: fabrikam.com | ||
| RuleCount: 30 | ||
| - ConnectorName: '*' | ||
| RuleCount: 168 | ||
| ``` | ||
|
|
||
| ```powershell | ||
| Configuration DataDrivenRuleCounts { | ||
| Import-DscResource -ModuleName DscConfig.AADConnect | ||
|
|
||
| Node $AllNodes.NodeName { | ||
| AADSyncRuleCounts 'RuleCounts' { | ||
| Items = $ConfigurationData.AADSyncRuleCounts.Items | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Related Resources | ||
|
|
||
| - [AADSyncRuleCount](https://github.com/dsccommunity/AADConnectDsc) — the | ||
| underlying report-only DSC resource provided by `AADConnectDsc`. | ||
| - [AADSyncRules](AADSyncRules.md) — companion composite resource that manages | ||
| the sync rules themselves. | ||
|
|
||
| ## Notes | ||
|
|
||
| - This composite resource runs during DSC configuration compilation. | ||
| - The companion `AADSyncRuleCount` resource ships with `AADConnectDsc` | ||
| starting with the version that introduces report-only count drift detection. | ||
| If your installed `AADConnectDsc` predates that version, compilation will | ||
| fail because the underlying resource is not present. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a single trailing newline at end of file. Markdown lint indicates missing final newline ( 🧰 Tools🪛 markdownlint-cli2 (0.22.1)[warning] 140-140: Files should end with a single newline character (MD047, single-trailing-newline) 🤖 Prompt for AI Agents |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix ordered-list prefix style to satisfy markdownlint.
The second item uses
2.while your configured MD029 style expects repeated1.prefixes.Suggested patch
1. Wait for the `AADConnectDsc` PR (`feature/AadsyncrulecountResource`) to be merged and a new version published, so CI can resolve `AADConnectDsc` from the gallery instead of relying on the local 0.6.0 copy. -2. Cut a release with the `Unreleased` entry promoted to a numbered version. +1. Cut a release with the `Unreleased` entry promoted to a numbered version.📝 Committable suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 50-50: Ordered list item prefix
Expected: 1; Actual: 2; Style: 1/1/1
(MD029, ol-prefix)
🤖 Prompt for AI Agents