Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.Components

Namespace Nexamas.UI.Quality

    ''' <summary>
    ''' Aggregate friend-only gate for the product-size controls that were hardened in
    ''' Phase 1. The gate does not render, create public APIs, or write files. It
    ''' proves that the declared matrix, targeted production promotions, and the
    ''' dedicated component probes agree with each other.
    ''' </summary>
    Friend NotInheritable Class MASCommercialReadinessGate

        Private Const ExpectedProductControlCount As Integer = 8

        Private Sub New()
        End Sub

        Friend Shared Function Evaluate() As MASCommercialReadinessReport
            Dim findings As New List(Of MASCommercialReadinessFinding)()
            Dim matrix As MASCommercialReadinessMatrix = Nothing
            Dim requiredEvidenceCount As Integer = 0
            Dim passingEvidenceCount As Integer = 0

            Try
                matrix = MASCommercialReadinessMatrixBuilder.BuildProductControlsMatrix()
            Catch ex As Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASCommercialReadinessGate.BuildMatrix")
                findings.Add(New MASCommercialReadinessFinding("matrix", "Build", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness matrix could not be built."))
                matrix = New MASCommercialReadinessMatrix(Array.Empty(Of MASCommercialReadinessRecord)())
            End Try

            ValidateMatrix(matrix, findings)
            EvaluateEvidence(matrix, requiredEvidenceCount, passingEvidenceCount, findings)
            ValidatePreviewMarketingBoundary(matrix, findings)

            Return New MASCommercialReadinessReport(matrix, requiredEvidenceCount, passingEvidenceCount, findings)
        End Function

        Friend Shared Function PassesPreviewGovernance() As Boolean
            Return Evaluate().IsPreviewGovernanceReady
        End Function

        Friend Shared Function BlocksProductionMarketing() As Boolean
            Dim report As MASCommercialReadinessReport = Evaluate()
            Return Not report.IsProductionMarketingReady
        End Function

        Private Shared Sub ValidateMatrix(matrix As MASCommercialReadinessMatrix,
                                          findings As List(Of MASCommercialReadinessFinding))
            If matrix Is Nothing Then
                findings.Add(New MASCommercialReadinessFinding("matrix", "Matrix", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness matrix is missing."))
                Return
            End If

            If matrix.Count <> ExpectedProductControlCount Then
                findings.Add(New MASCommercialReadinessFinding("matrix", "Count", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness matrix must contain exactly the Phase-1 product control set."))
            End If

            Dim ids As New HashSet(Of String)(StringComparer.OrdinalIgnoreCase)
            For Each record As MASCommercialReadinessRecord In matrix.Records
                If record Is Nothing Then
                    findings.Add(New MASCommercialReadinessFinding("matrix", "Record", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness matrix contains a null record."))
                    Continue For
                End If

                If Not record.IsStructurallyValid Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "Structure", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness record is structurally invalid."))
                End If

                If Not ids.Add(record.Id) Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "DuplicateId", MASCommercialReadinessFindingSeverity.Error, "Commercial readiness record id is duplicated."))
                End If

                If Not record.HasArchitectureRegistration Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "ArchitectureRegistration", MASCommercialReadinessFindingSeverity.Error, record.DisplayName & " is not registered in the architecture registry."))
                End If

                If Not record.HasPublicAddGateway Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "AddGateway", MASCommercialReadinessFindingSeverity.Error, record.DisplayName & " is missing its declared Add* gateway."))
                End If

                If record.Stage <> MASCommercialReadinessStage.ProductionReady AndAlso String.IsNullOrWhiteSpace(record.BlockerSummary) Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "BlockerSummary", MASCommercialReadinessFindingSeverity.Error, record.DisplayName & " is preview/non-production but has no blocker summary."))
                End If

                If record.Stage = MASCommercialReadinessStage.CompactPreview Then
                    If Not record.HasRelationCoverage Then findings.Add(New MASCommercialReadinessFinding(record.Id, "RelationCoverage", MASCommercialReadinessFindingSeverity.Warning, record.DisplayName & " still lacks declared relation-provider coverage."))
                    If Not record.HasVirtualizationContract Then findings.Add(New MASCommercialReadinessFinding(record.Id, "Virtualization", MASCommercialReadinessFindingSeverity.Warning, record.DisplayName & " still lacks large-data virtualization proof."))
                    If Not record.HasPerformanceProof Then findings.Add(New MASCommercialReadinessFinding(record.Id, "PerformanceProof", MASCommercialReadinessFindingSeverity.Warning, record.DisplayName & " still lacks commercial performance proof."))
                End If
            Next
        End Sub

        Private Shared Sub EvaluateEvidence(matrix As MASCommercialReadinessMatrix,
                                            ByRef requiredEvidenceCount As Integer,
                                            ByRef passingEvidenceCount As Integer,
                                            findings As List(Of MASCommercialReadinessFinding))
            Dim probes As MASCommercialReadinessEvidenceProbe() = CreateEvidenceProbes()
            requiredEvidenceCount = probes.Length
            passingEvidenceCount = 0

            For Each probe As MASCommercialReadinessEvidenceProbe In probes
                If probe Is Nothing Then Continue For

                Dim record As MASCommercialReadinessRecord = If(matrix Is Nothing, Nothing, matrix.FindById(probe.ComponentId))
                Dim isMatrixWideProbe As Boolean = String.Equals(probe.ComponentId, "matrix", StringComparison.OrdinalIgnoreCase)
                If record Is Nothing AndAlso Not isMatrixWideProbe Then
                    findings.Add(New MASCommercialReadinessFinding(probe.ComponentId, probe.EvidenceKey, MASCommercialReadinessFindingSeverity.Error, "Evidence probe has no matching commercial readiness record."))
                    Continue For
                End If

                Dim passed As Boolean = False
                Try
                    passed = probe.Evaluate.Invoke()
                Catch ex As Exception
                    Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASCommercialReadinessGate." & probe.EvidenceKey)
                    passed = False
                End Try

                If passed Then
                    passingEvidenceCount += 1
                Else
                    Dim ownerName As String = If(record Is Nothing, "Commercial readiness matrix", record.DisplayName)
                    findings.Add(New MASCommercialReadinessFinding(probe.ComponentId, probe.EvidenceKey, MASCommercialReadinessFindingSeverity.Error, ownerName & " failed required evidence probe: " & probe.Description))
                End If
            Next
        End Sub

        Private Shared Sub ValidatePreviewMarketingBoundary(matrix As MASCommercialReadinessMatrix,
                                                            findings As List(Of MASCommercialReadinessFinding))
            If matrix Is Nothing Then Return

            For Each record As MASCommercialReadinessRecord In matrix.Records
                If record Is Nothing Then Continue For

                If record.Stage = MASCommercialReadinessStage.CompactPreview AndAlso record.IsCommercialProductionReady Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "MarketingBoundary", MASCommercialReadinessFindingSeverity.Error, record.DisplayName & " is marked CompactPreview but evaluates as production-ready."))
                End If

                If record.Stage = MASCommercialReadinessStage.ProductionReady AndAlso Not record.IsCommercialProductionReady Then
                    findings.Add(New MASCommercialReadinessFinding(record.Id, "MarketingBoundary", MASCommercialReadinessFindingSeverity.Error, record.DisplayName & " is marked ProductionReady without all required production evidence."))
                End If
            Next
        End Sub

        Private Shared Function CreateEvidenceProbes() As MASCommercialReadinessEvidenceProbe()
            Return New MASCommercialReadinessEvidenceProbe() {
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.RelationCoverage", "declared architecture relation coverage for the Phase-1 product controls", Function() MASProductControlRelationCoverageGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.PublicAdapterPolicy", "central Friend-only public adapter exposure policy for product controls", Function() MASPublicAdapterPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.ProductionPromotionRules", "central production-promotion rules block preview controls from ProductionReady marketing", Function() MASProductionPromotionRuleGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.RuntimeFaultStrictMode", "runtime fault developer panel snapshot and strict swallowed-exception mode", Function() MASRuntimeFaultStrictModeGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Diagnostics.CatchSiteClassification", "whole-repository catch-site classification plus real render/input/lifecycle runtime fault probes", Function() MASRuntimeFaultCatchSiteClassificationGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Diagnostics.LoggingFailureChannel", "diagnostics logging and subscriber failures remain retained through the official runtime fault channel and public snapshot without recursion", Function() MASRuntimeDiagnosticsFailureChannelGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Diagnostics.PublicSnapshotGateway", "public read-only diagnostics snapshot facade for packed SDK consumers without leaking internals", Function() MASPublicDiagnosticsSnapshotGatewayGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Diagnostics.QualityResidualReview", "Phase-13 DIAG-R01..DIAG-R04 fault-storm retention counters, strictness scope restoration, disk-log rotation, and certified evidence labels", Function() MASDiagnosticsQualityResidualReviewGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.TimeMotionOwnership", "central time provider, visual clock, interaction clock, and approved timer ownership manifest", Function() MASTimeMotionOwnershipGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.DocumentationSamples", "product-control documentation, consumer-safe samples, and evidence-pack boundaries", Function() MASDocumentationSampleEvidenceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.MeasuredRuntimeBenchmarks", "measured runtime benchmark coverage for the eight product-control proof paths", Function() MASMeasuredRuntimeBenchmarkGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.BenchmarkBaselineThresholdPolicy", "benchmark baseline capture and internal threshold policy for the eight product-control proof paths", Function() MASBenchmarkBaselineThresholdPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.KeyboardAccessibilityStress", "keyboard/focus contract and accessibility-state stress proof for the eight product controls", Function() MASKeyboardAccessibilityStressGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "RootInput.InputFocusRuntimeHardening", "runtime proof for capture cancel, exception-safe focus rollback, guarded input/focus fault boundaries, and DPI coordinate routing", Function() MASInputFocusRuntimeHardeningGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Motion.MultiWindowIsolation", "host-scoped Motion frame-clock isolation for multi-window consumers and non-control Float transition owners", Function() MASMultiWindowMotionIsolationGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "FrameScheduler.DispatcherBoundary", "FrameScheduler and HostRuntime native surface invalidation/resize access is UI-thread guarded with no unsafe BeginInvoke fallback", Function() MASFrameSchedulerDispatcherBoundaryGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "FloatRuntime.TransitionDispose", "FloatRuntime host dispose cancels active transition runners, unregisters frame-clock consumers, and suppresses post-dispose callbacks", Function() MASFloatTransitionDisposeGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Motion.ConsumerPressure", "1k/10k host-scoped Motion consumer pressure remains isolated per host clock", Function() MASMotionConsumerPressureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Motion.ReducedMotionMutationDuringAnimation", "live reduced-motion policy mutation leaves active immutable runners balanced and makes new plans honor the new policy", Function() MASReducedMotionMutationDuringAnimationGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Motion.ThemeDpiRtlMutationDuringMotion", "Theme/DPI/RTL/Culture mutation during active Motion routes through host environment coordination without corrupting the host clock", Function() MASThemeDpiRtlMutationDuringMotionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "HostRendering.CanvasStateIsolation", "host render-stage SKCanvas state isolation for controls, composition, and overlay rendering", Function() MASRenderCanvasStateIsolationGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ControlsLayer.SubtreeClipContract", "ControlsLayer parent clips constrain body, direct children, and child-layer rendering to match hit-test reachability", Function() MASControlsSubtreeClipContractGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "RootHost.RuntimeEnvironmentMutationCoordinator", "host-owned runtime environment mutation coordinator for DPI, Font, RTL, and Localization refresh/invalidation", Function() MASRuntimeEnvironmentMutationCoordinatorGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Application.RuntimeStressProofExpansion", "APP-R01 live runtime-environment churn and APP-R02 dispose/async callback plus 100k direct ControlsLayer misuse runtime stress proof", Function() MASApplicationRuntimeStressProofGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DPI.TextInputPaintLifecycle", "DPI-01 TextInput owned SKPaint lifecycle and DPI-02 public typography paint clone isolation", Function() MASDpiTextInputPaintLifecycleGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DPI.TextMeasurementRenderParity", "DPI-05 paragraph wrap measurement/render parity and DPI-06 shaped ellipsis measurement gateway proof", Function() MASDpiTextMeasurementParityGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DPI.TextShapingFallbackPerformance", "DPI-03 HarfBuzz drawable-run cache and DPI-04 bounded system-font fallback bitmap cache proof", Function() MASDpiTextShapingFallbackPerformanceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DPI.TextLargeMultilineCaretPolicy", "DPI-07 large multiline windowing, DPI-08 cluster/grapheme caret, DPI-09 unified DPI policy, and DPI-R01..DPI-R05 text residual proof", Function() MASDpiTextLargeMultilineCaretPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "HostRendering.ThemeAwareSurfaceClear", "theme-aware host surface clear color for Skia clear, WinForms background, and GL resize priming", Function() MASHostSurfaceThemeAwareClearGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "HostRendering.RepeatedRenderFaultDiagnostics", "repeated render-stage failures publish every occurrence to the runtime fault channel while trace output stays rate-limited", Function() MASRepeatedRenderFaultDiagnosticsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ControlsRuntime.OfficialDispatcherAsyncCompletions", "control-owned async completions and scroll-repeat pulses use the root-owned UI dispatcher, never fallback-post through stale SynchronizationContext, and stop safely on repeat callback faults", Function() MASOfficialDispatcherAsyncCompletionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.LargeDataSummaryPolicy", "DataView projection refresh never performs large-data summary aggregation unless the DataGrid policy explicitly opts in", Function() MASDataGridLargeDataSummaryPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.AddRowMisuseDiagnostics", "repeated single AddRow calls outside BeginUpdate/DeferRefresh are readiness-visible while bulk and coalesced loading paths remain notification-bounded", Function() MASDataGridAddRowMisuseDiagnosticsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.RuntimeCultureIntegration", "DataGrid/DataView culture and RTL invalidation flows through the official runtime environment stamp; Refresh does not recapture Thread.CurrentCulture behind the host", Function() MASDataGridRuntimeCultureIntegrationGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "RuntimeEnvironment.StampRegression", "runtime-environment culture/RTL revision stamps remain overflow-safe and virtualization-safe", Function() MASRuntimeEnvironmentStampRegressionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Localization.RuntimeEnvironmentCoordinator", "Localization-owned runtime culture/RTL coordinator announces en-US to ar-SY mutations through the host runtime-environment refresh path without mutating thread culture", Function() MASLocalizationRuntimeEnvironmentCoordinatorGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Localization.SilentRtlFallbackDiagnostics", "unsupported or invalid RTL runtime-culture resolution falls back to LTR only with retained diagnostics and fault-channel visibility", Function() MASLocalizationSilentRtlFallbackDiagnosticsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Localization.AttachPageLifecycleSeparation", "Localization snapshot readiness, render snapshot evidence, and public AttachPage lifecycle proof remain separate; snapshot render scenarios are not tagged RealControl unless they use the public attach route", Function() MASLocalizationAttachPageLifecycleGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Localization.RtlResidualReview", "Phase-14 LOC-R01..LOC-R04 UI direction vs content bidi contract, bounded catalog preview, RTL keyboard/accessibility semantics, and runtime input rebase after RTL mutation", Function() MASLocalizationRtlResidualReviewGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Virtualization.ResidualReview", "Phase-15 VIRT-R01..VIRT-R06 huge-offset precision, fractional-DPI size revisions, DataGrid Summary Always 100k pressure, fast-scroll plan budget, tile hit-test fallback diagnostics, and off-window accessibility bridge", Function() MASVirtualizationResidualReviewGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.CultureInvalidationRegression", "DataGrid/DataView projection, grouping, sorting, summaries, and text formatting invalidate after runtime culture changes", Function() MASDataGridCultureInvalidationRegressionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "Render.CultureFaultRegression", "MASLabel and MASDataGrid render probes survive live culture/RTL switches without broad render-fault placeholders", Function() MASCultureRenderFaultRegressionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.MalformedValueDiagnostics", "typed DataGrid filter, sort, and summary conversion failures remain fail-closed and visible as readiness diagnostics", Function() MASDataGridMalformedValueDiagnosticsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.AccessibilitySemantics", "official DataGrid accessibility semantics snapshot for grid, rows, columns, cells, active cell, and sort state", Function() MASDataGridAccessibilitySemanticsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ApplicationSurfaceMaterial.ScopeLifecycle", "surface material scope holds window and registered controls through weak lifecycle references only", Function() MASApplicationSurfaceMaterialScopeLifecycleGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ApplicationSurfaceMaterial.PublicGatewayManifest", "public surface-material gateway manifest count, required entries, duplicate protection, and real reflected public members agree", Function() MASPublicSurfaceMaterialGatewayManifestGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.PublicApiContractReview", "DataGrid/DataView public SDK surface review before long-term API freeze", Function() MASDataGridPublicApiReviewGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "DataGrid.DataViewResidualReview", "Phase-12 DG-R01..DG-R04 weak surface scope, non-public runtime reset, event reentrancy guard, and 100k DataView summary/filter/sort proof", Function() MASDataGridDataViewResidualReviewGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.ControlSpecificProductionGaps", "explicit control-specific ProductionReady gap ledger and closure evidence policy", Function() MASControlSpecificProductionGapGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.HostingContractClosure", "Friend-only hosted-content lifecycle closure for DashboardGrid, MasterDetailView, AppLayout, and SplitView", Function() MASHostingContractClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.ProviderStateClosure", "DashboardGrid provider-refresh and MasterDetailView empty/error state closure proof", Function() MASDashboardProviderMasterDetailStateClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.MasterDetailSplitViewClosure", "MasterDetailView bounded item-window and SplitView keyboard splitter closure proof", Function() MASMasterDetailSplitViewClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.RoutingShellBoundaryClosure", "AppLayout route/page boundary, MasterDetail routing/public-adapter boundary, and SplitView shell boundary closure proof", Function() MASRoutingShellBoundaryClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.ProviderHostAdoptionClosure", "DashboardGrid internal provider-adapter policy plus AppLayout/SplitView host-adoption proof", Function() MASDashboardProviderHostAdoptionClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.DashboardResizeHostSampleClosure", "DashboardGrid keyboard/a11y resize thresholds plus AppLayout/SplitView real host-adoption samples", Function() MASDashboardResizeHostSampleClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.ReleaseFreezeEvidenceLockdown", "release-freeze evidence manifest and CompactPreview / ProductionReady boundary lockdown", Function() MASReleaseFreezeEvidenceLockdownGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("matrix", "ProductControls.FinalCommercialReadinessClosure", "final commercial-readiness closure across policy, gaps, docs, benchmarks, accessibility, targeted closure evidence, and targeted TreeGrid/PivotTable/KanbanBoard/AgendaView/DashboardGrid/MasterDetailView/AppLayout/SplitView promotions", Function() MASFinalCommercialReadinessClosureGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.SourceProjection", "stable-keyed source projection and viewport access", Function() MASTreeGridSourceProjectionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.SortFilter", "level-aware sort/filter projection", Function() MASTreeGridSortFilterGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.Editing", "row label/value editing lifecycle", Function() MASTreeGridEditingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.LargeDataWindowing", "large-source bounded row-window proof", Function() MASTreeGridLargeDataWindowingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.WriteBackAdapters", "Friend-only source write-back adapter proof", Function() MASTreeGridIncrementalSourceUpdateGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("treegrid", "TreeGrid.IncrementalUpdates", "incremental add/remove/replace source update proof", Function() MASTreeGridIncrementalSourceUpdateGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("pivottable", "PivotTable.SourceProjection", "pivot source projection, aggregation, drilldown, and export snapshot", Function() MASPivotTableSourceProjectionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("pivottable", "PivotTable.MatrixWindowing", "large matrix bounded row/column cell-window proof", Function() MASPivotTableMatrixWindowingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("pivottable", "PivotTable.MultiLevelGrouping", "deterministic row/column hierarchy grouping policy proof", Function() MASPivotTableMultiLevelGroupingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("pivottable", "PivotTable.ExportWriters", "in-memory delimited export writer policy proof", Function() MASPivotTableExportWriterPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("kanban", "Kanban.SourceProjection", "Kanban source projection and source update handling", Function() MASKanbanBoardSourceProjectionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("kanban", "Kanban.Persistence", "board snapshot/restore and reorder persistence", Function() MASKanbanBoardPersistenceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("kanban", "Kanban.LargeBoardWindowing", "large-source bounded board-window proof", Function() MASKanbanBoardLargeBoardWindowingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("kanban", "Kanban.WipDropRules", "WIP/drop-rule contract proof", Function() MASKanbanBoardWipDropRulesGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("kanban", "Kanban.WriteBackPolicy", "intentional source-detach write-back policy proof", Function() MASKanbanBoardWriteBackPolicyGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("agenda", "Agenda.OverlapLayout", "timed single-day overlap lane layout", Function() MASAgendaViewOverlapLayoutGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("agenda", "Agenda.RangeViews", "event-day ownership plus week/month range views", Function() MASAgendaViewRangeViewsGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("agenda", "Agenda.SourceRangeWindowing", "large source projection plus bounded visible day/week/month window proof", Function() MASAgendaViewSourceRangeWindowingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("agenda", "Agenda.RecurrenceTimeZone", "recurrence/time-zone visual boundary policy proof", Function() MASAgendaViewRecurrenceTimeZoneGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("agenda", "Agenda.EventMoveResize", "Friend-only event move/resize contract proof", Function() MASAgendaViewEventMoveResizeGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("dashboardgrid", "DashboardGrid.Persistence", "dashboard widget layout snapshot/restore", Function() MASDashboardGridLayoutPersistenceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("dashboardgrid", "DashboardGrid.LargeLayoutWindowing", "large-layout bounded widget-window proof", Function() MASDashboardGridLargeLayoutWindowingGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("masterdetail", "MasterDetail.SourceProjection", "master/detail source projection", Function() MASMasterDetailViewSourceProjectionGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("masterdetail", "MasterDetail.Persistence", "master/detail view snapshot/restore", Function() MASMasterDetailViewPersistenceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("applayout", "AppLayout.Persistence", "visual slot layout snapshot/restore", Function() MASAppLayoutPersistenceGate.Passes()),
                New MASCommercialReadinessEvidenceProbe("splitview", "SplitView.Persistence", "bounded ratio/collapse snapshot/restore", Function() MASSplitViewPersistenceGate.Passes())
            }
        End Function

        Private NotInheritable Class MASCommercialReadinessEvidenceProbe
            Friend Sub New(componentId As String,
                           evidenceKey As String,
                           description As String,
                           evaluate As Func(Of Boolean))
                Me.ComponentId = If(componentId, String.Empty).Trim()
                Me.EvidenceKey = If(evidenceKey, String.Empty).Trim()
                Me.Description = If(description, String.Empty).Trim()
                Me.Evaluate = evaluate
            End Sub

            Friend ReadOnly Property ComponentId As String
            Friend ReadOnly Property EvidenceKey As String
            Friend ReadOnly Property Description As String
            Friend ReadOnly Property Evaluate As Func(Of Boolean)
        End Class

    End Class

End Namespace
