Motivated by uncertain parameters in nonlinear dynamic systems, we define a nonclassical optimal control problem where the cost functional is given by a Riemann-Stieltjes "functional of a functional." Using the properties of Riemann-Stieltjes sums, a minimum principle is generated from the limit of a semidiscretization. The optimal control minimizes a Riemann-Stieltjes integral of the Pontryagin Hamiltonian. The challenges associated with addressing the noncommutative operations of integration and minimization are addressed via cubature techniques leading to the concept of hyper-pseudospectral points. These ideas are then applied to address the practical uncertainties in control moment gyroscopes that drive an agile spacecraft. Ground test results conducted at Honeywell demonstrate the new principles. The Riemann-Stieltjes optimal control problem is a generalization of the unscented optimal control problem. It can be connected to many independently developed ideas across several disciplines: search theory, viability theory, quantum control and many other applications involving tychastic differential equations.