Skip to content

Add FOCUS 1.4 schema tests and changelog entries#2136

Draft
flanakin wants to merge 12 commits into
flanakin/focus14-phase6-pluginfrom
flanakin/focus14-phase7-tests-changelog
Draft

Add FOCUS 1.4 schema tests and changelog entries#2136
flanakin wants to merge 12 commits into
flanakin/focus14-phase6-pluginfrom
flanakin/focus14-phase7-tests-changelog

Conversation

@flanakin

@flanakin flanakin commented May 6, 2026

Copy link
Copy Markdown
Collaborator

🛠️ Description

PR 4 of the FOCUS 1.4 stack (#2126#2128#2135#2136#2194). Delivers the static KQL regression harness (FOCUS-1.4-PLAN.md D6) plus the v15 changelog entries, and merges the upstream stack fixes.

Test harness (src/powershell/Tests/Unit/HubsFocusSchemas.Tests.ps1)

  • Check 1 — registration completeness (glob-based): dynamically discovers every IngestionSetup_v1_*.kql / HubSetup_v1_*.kql (+ HubSetup_Latest.kql) and asserts each is registered in .build.config combineKql and loaded via loadTextContent in Analytics/app.bicep; also asserts versioned HubSetup files precede HubSetup_Latest.kql. Automatically covers the D9 split file (IngestionSetup_v1_4_Datasets.kql) and any future v1_5 files. Prevents regression add IngestionSetup_v1_2.kql to build process #1777.
  • Check 2 — version-string consistency (new): every cross-version identifier (*_v1_Y where Y ≠ the file's own version) must match a data-driven allowlist (cross-version union arms, deprecation docstrings, one known benign TODO). Also asserts no v1_3 references and no git conflict markers in any KQL/Bicep file under src/templates/finops-hub/ — both defects actually occurred on this stack.
  • Check 3 — exactly one enabled update policy version (new): parses every .alter table ... policy update block; enabled policies must live in exactly one schema version (derived as the highest discovered, not hardcoded), older versions must be fully disabled, and every raw source table must stay wired to an enabled current-version policy (handles the C360 ActualCosts_raw/AmortizedCosts_rawCosts_raw retrofit).
  • Check 4 — tightened contracts: union-arm occurrence counts (5 managed datasets × 3 final table versions in HubSetup_v1_4.kql; 3 new datasets read _final_v1_4 only), back-compat _final_v1_4 arms in HubSetup_v1_0.kql/HubSetup_v1_2.kql, HubSetup_Latest.kql guards against _v1_0() and _v1_2() aliases with all 8 unversioned functions pointing at _v1_4(), and the D3 provider column rename round trip (ProviderName = HostProviderName / PublisherName = ServiceProviderName down-conversion present; inverted direct assignments guarded in the v1_4 files).

Changelog (docs-mslearn/toolkit/changelog.md)

Reconciled the Unreleased "FinOps hubs v15.0.0" section with what the fixed stack ships: FOCUS 1.4 conversion behavior, new Costs columns, three new datasets (empty until Cost Management exports FOCUS 1.4), unversioned alias retarget, dashboard repoint, v1_2 transform deprecation + policy disablement, and ProviderName/PublisherName removal with down-conversion. Removed the docs/README.md procedure-refresh bullet (ships via #2123, not this stack). The internal ingestion-script split is not listed (no user-facing impact, consistent with v12/v14 granularity).

Red-green validation

Each new check was validated against an injected defect in a throwaway edit, then reverted:

Injected defect Failing test
Conflict markers appended to HubSetup_v1_4.kql Has no git conflict markers in finops-hub KQL or Bicep files
Stray Costs_transform_v1_2() reference in IngestionSetup_v1_4.kql IngestionSetup_v1_4.kql only references other schema versions via allowlisted patterns
One v1_2 policy flipped to "IsEnabled": true Enables update policies in exactly one schema version + IngestionSetup_v1_2.kql has zero enabled update policies
IngestionSetup_v1_4_Datasets.kql removed from .build.config IngestionSetup_v1_4_Datasets.kql is registered in .build.config combineKql
Provider mapping swapped in HubSetup_v1_2.kql HubSetup_v1_2.kql down-converts the provider columns in its v1_4 arm
Direct ServiceProviderName = ProviderName added to IngestionSetup_v1_4.kql IngestionSetup_v1_4.kql does not invert the provider column mapping

Each scenario failed exactly the targeted test(s); pristine state passes all 207 tests.

Verification

  • Invoke-Pester -Path ./src/powershell/Tests/Unit/HubsFocusSchemas.Tests.ps1 — 207 passed, 0 failed.
  • Full unit suite Invoke-Pester -Path ./src/powershell/Tests/Unit/* — 2047 passed, 0 failed, 4 skipped.
  • ./src/scripts/Build-Toolkit finops-hub — exit 0.
  • Red-green validation of every new check (table above).
  • No conflict markers in src/ or docs-mslearn/.

📋 Checklist

🔬 How did you test this change?

  • 🤏 Lint tests
  • 🤞 PS -WhatIf / az validate
  • 👍 Manually deployed + verified
  • 💪 Unit tests
  • 🙌 Integration tests

📦 Deploy to test?

  • Hubs + ADX (managed)
  • Hubs + Fabric (manual) — URI:
  • Hubs (manual)
  • Hubs (no data)
  • Workbooks
  • Alerts

🙋‍♀️ Do any of the following that apply?

  • 🚨 This is a breaking change.
  • 🤏 The change is less than 20 lines of code.

🤖 Generated with Claude Code

- HubsFocusSchemas.Tests.ps1: 108 Pester tests asserting the
  FOCUS 1.3 and 1.4-preview schema additions land where expected:
  Costs_raw additions, ContractCommitment_raw definition with
  both 1.3 and 1.4 columns, presence of versioned transforms
  and final tables in IngestionSetup_v1_3 / v1_4, presence of
  versioned hub functions in HubSetup_v1_3 / v1_4, the union
  arms in Costs_v1_3 and Costs_v1_4, the Latest aliases pinned
  to v1_3 (not preview v1_4), and the Bicep / build-config
  wiring.
- changelog.md: adds v15.0.0 hub entries describing the FOCUS
  1.3 GA and 1.4-preview schema additions, the new
  ContractCommitment dataset, the unversioned alias retarget,
  and the upgrade-procedure refresh. Adds a plugin entry for
  #2119. Updates ms.date to today.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 6, 2026 18:13
@flanakin flanakin requested a review from MSBrett as a code owner May 6, 2026 18:13
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs: Review 👀 PR that is ready to be reviewed label May 6, 2026
@flanakin flanakin changed the base branch from flanakin/focus14-phase6-plugin to flanakin/focus14 May 6, 2026 23:00
@flanakin flanakin marked this pull request as draft May 6, 2026 23:16
@flanakin flanakin added this to the v15 milestone May 15, 2026
Updates Pester tests to validate v1_4 (not v1_3) schema files, removes
tests for the eliminated intermediate v1_3 schema, and corrects
HubSetup_Latest assertions to expect _v1_4() aliases. Updates changelog
to reflect FOCUS 1.4 GA release without preview designation.

Co-Authored-By: Claude <noreply@anthropic.com>
@flanakin flanakin changed the title Add FOCUS schema tests and changelog entries Add FOCUS 1.4 schema tests and changelog entries May 17, 2026
flanakin and others added 3 commits May 26, 2026 00:31
Tests:
- Pluralize ContractCommitments_raw / _final_v1_4 / _v1_4 assertions
- Assert new BillingPeriods_raw + InvoiceDetails_raw datasets exist with their FOCUS 1.4 columns
- Assert new BillingPeriods_v1_4(), InvoiceDetails_v1_4(), ContractCommitments_v1_4() hub functions
- Assert HubSetup_Latest aliases for BillingPeriods(), ContractCommitments(), InvoiceDetails()
- Assert Costs_raw and Costs_final_v1_4 include the 14 new FOCUS 1.4 columns
- Assert NO singular ContractCommitment_raw / ContractCommitment_v1_4 / ContractCommitment() exists
- Assert Costs_raw keeps removed ProviderName/PublisherName/Region for back compat

Changelog:
- Expand v15.0.0 entry with the 14 new FOCUS 1.4 columns and the three new supplemental datasets (ContractCommitments, BillingPeriods, InvoiceDetails)
- Update plugin entry to list ContractCommitments() / BillingPeriods() / InvoiceDetails()

🤖 Generated with [Claude Code](https://claude.ai/claude-code)

Co-Authored-By: Michael Flanakin <flanakin@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@flanakin

Copy link
Copy Markdown
Collaborator Author

🤖 [AI][Claude Code] PR Update Summary

Cascade of PR #2126 review feedback (tests + changelog):

  • ✅ Pester tests now cover the pluralized ContractCommitments naming and the new BillingPeriods + InvoiceDetails datasets — 152 assertions, all green
  • ✅ Tests guard against regressions: singular ContractCommitment must not appear; deprecated ProviderName/PublisherName/Region must stay in Costs_raw for back compat
  • ✅ Changelog v15.0.0 entry expanded with the 14 new FOCUS 1.4 cost columns and three new supplemental datasets

Depends on PRs #2126, #2128, and #2135.

flanakin and others added 2 commits July 15, 2026 13:29
…into flanakin/focus14-phase7-tests-changelog
…rness

Rework HubsFocusSchemas.Tests.ps1 per FOCUS-1.4-PLAN.md D6:
- Check 1: glob-discover all IngestionSetup_v1_*/HubSetup_v1_* scripts and
  assert .build.config + app.bicep registration (covers the D9 split file
  and future versions automatically; prevents regression #1777)
- Check 2 (new): version-string consistency with a data-driven allowlist
  (union arms, deprecation docstrings, known benign TODO) plus v1_3 and
  git conflict marker guards
- Check 3 (new): exactly one enabled update policy schema version, derived
  from the highest discovered version; every raw source stays wired
- Check 4: tightened union arm occurrence counts (5 managed datasets x 3
  versions + 3 new v1_4-only datasets), back-compat _final_v1_4 arms in
  v1_0/v1_2 hub functions, _v1_0()/_v1_2() alias guards in HubSetup_Latest,
  and the D3 provider column rename round trip with an inversion guard

Also reconcile the v15 changelog with what the stack ships: FOCUS 1.4
conversion behavior, three new datasets (empty until Cost Management
exports FOCUS 1.4), v1_2 deprecation/policy disablement, provider column
removal with down-conversion, and the dashboard repoint.

All new checks were red-green validated against injected defects.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@flanakin flanakin changed the base branch from flanakin/focus14 to flanakin/focus14-phase6-plugin July 15, 2026 20:48
@flanakin

Copy link
Copy Markdown
Collaborator Author

W4 rework complete (commit 9eb79ca).

  • Merged origin/flanakin/focus14-phase6-plugin (778080f) to pick up all upstream stack fixes (provider mapping, C360 retrofit, v1_2 policies disabled, D9 file split, conflict-marker cleanup); zero conflict markers post-merge.
  • Rewrote HubsFocusSchemas.Tests.ps1 into the full D6 harness: glob-based registration completeness, version-string consistency with a data-driven allowlist (+ v1_3 and conflict-marker guards), exactly-one-enabled-policy-version derived from the highest discovered schema version, and tightened union/alias/provider-mapping contracts including the D3 round trip.
  • Every new check was red-green validated against an injected defect (details in the PR body) — each failed exactly the targeted test, and the pristine tree passes all 207 tests.
  • Changelog reconciled with what the stack actually ships; the docs/README.md procedure bullet moved out (ships via Refresh FinOps hub upgrade procedure for multi-version FOCUS adoption #2123).
  • Full unit suite: 2047 passed / 0 failed / 4 skipped. Build-Toolkit finops-hub: exit 0.
  • Base retargeted to flanakin/focus14-phase6-plugin.

🤖 Generated with Claude Code

Resolved changelog ms.date conflict to today per repo convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Updates HubsFocusSchemas.Tests.ps1 to pin the spec-prefixed column names
(30 FOCUS columns, including new ContractCommitmentDescription and
ServiceProviderName), asserts the old unprefixed names are gone, and
adds exact 30-column count checks for the raw and final tables. Also
updates the changelog dataset column count (28 -> 30) and notes the
spec-aligned naming.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@flanakin

Copy link
Copy Markdown
Collaborator Author

Synced with phase 6 (dev merge + Q4 ContractCommitments spec alignment upstream). One conflict in docs-mslearn/toolkit/changelog.md (ms.date) — resolved to today per repo convention.

Q4 follow-through:

  • HubsFocusSchemas.Tests.ps1: golden lists updated to the spec-prefixed IDs (30 FOCUS columns including new ContractCommitmentDescription and ServiceProviderName), plus new assertions that the old unprefixed names are gone and exact 30-column count checks for the raw and final tables.
  • Changelog: ContractCommitments dataset count 28 → 30 with a note on spec-aligned column IDs; ms.date set to 07/15/2026.

Verified: HubsFocusSchemas.Tests.ps1 green (225/225); full unit suite green (2117 passed, 0 failed, 4 skipped); no conflict markers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Review 👀 PR that is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants